132 ConcurrentHashMap cache = (ConcurrentHashMap)cacheref.get(); 133 if (cache == null) { 134 cache = new ConcurrentHashMap(); 135 cacheref = new SoftReference(cache); 136 } 137 138 LayoutEngine e = (LayoutEngine)cache.get(key); 139 if (e == null) { 140 LayoutEngineKey copy = key.copy(); 141 e = new SunLayoutEngine(copy); 142 cache.put(copy, e); 143 } 144 return e; 145 } 146 private SoftReference cacheref = new SoftReference(null); 147 148 private SunLayoutEngine(LayoutEngineKey key) { 149 this.key = key; 150 } 151 152 public void layout(FontStrikeDesc desc, float[] mat, int gmask, 153 int baseIndex, TextRecord tr, int typo_flags, 154 Point2D.Float pt, GVData data) { 155 Font2D font = key.font(); 156 FontStrike strike = font.getStrike(desc); 157 long layoutTables = font.getLayoutTableCache(); 158 nativeLayout(font, strike, mat, gmask, baseIndex, 159 tr.text, tr.start, tr.limit, tr.min, tr.max, 160 key.script(), key.lang(), typo_flags, pt, data, 161 font.getUnitsPerEm(), layoutTables); 162 } 163 164 private static native void 165 nativeLayout(Font2D font, FontStrike strike, float[] mat, int gmask, 166 int baseIndex, char[] chars, int offset, int limit, 167 int min, int max, int script, int lang, int typo_flags, 168 Point2D.Float pt, GVData data, long upem, long layoutTables); 169 } | 132 ConcurrentHashMap cache = (ConcurrentHashMap)cacheref.get(); 133 if (cache == null) { 134 cache = new ConcurrentHashMap(); 135 cacheref = new SoftReference(cache); 136 } 137 138 LayoutEngine e = (LayoutEngine)cache.get(key); 139 if (e == null) { 140 LayoutEngineKey copy = key.copy(); 141 e = new SunLayoutEngine(copy); 142 cache.put(copy, e); 143 } 144 return e; 145 } 146 private SoftReference cacheref = new SoftReference(null); 147 148 private SunLayoutEngine(LayoutEngineKey key) { 149 this.key = key; 150 } 151 152 private boolean isAAT(Font2D font) { 153 if (font instanceof TrueTypeFont) { 154 TrueTypeFont ttf = (TrueTypeFont)font; 155 return ttf.getDirectoryEntry(TrueTypeFont.morxTag) != null || 156 ttf.getDirectoryEntry(TrueTypeFont.mortTag) != null; 157 } else if (font instanceof PhysicalFont) { 158 PhysicalFont pf = (PhysicalFont)font; 159 return pf.getTableBytes(TrueTypeFont.morxTag) != null || 160 pf.getTableBytes(TrueTypeFont.mortTag) != null; 161 } 162 return false; 163 } 164 165 public void layout(FontStrikeDesc desc, float[] mat, int gmask, 166 int baseIndex, TextRecord tr, int typo_flags, 167 Point2D.Float pt, GVData data) { 168 Font2D font = key.font(); 169 FontStrike strike = font.getStrike(desc); 170 long layoutTables = font.getLayoutTableCache(); 171 if (isAAT(font) && (typo_flags & 0x80000000) != 0) { 172 // Ignore layout tables for RTL AAT fonts 173 // due to lack of support in ICU 174 layoutTables = 0; 175 } 176 nativeLayout(font, strike, mat, gmask, baseIndex, 177 tr.text, tr.start, tr.limit, tr.min, tr.max, 178 key.script(), key.lang(), typo_flags, pt, data, 179 font.getUnitsPerEm(), layoutTables); 180 } 181 182 private static native void 183 nativeLayout(Font2D font, FontStrike strike, float[] mat, int gmask, 184 int baseIndex, char[] chars, int offset, int limit, 185 int min, int max, int script, int lang, int typo_flags, 186 Point2D.Float pt, GVData data, long upem, long layoutTables); 187 } |