diff --git a/src/share/classes/sun/font/SunLayoutEngine.java b/src/share/classes/sun/font/SunLayoutEngine.java index 5b85bcff0467c3ab8234008afcc6fc7164f0272f..bf866e6c69b42cb544ef2d261927ab137aae5761 100644 --- a/src/share/classes/sun/font/SunLayoutEngine.java +++ b/src/share/classes/sun/font/SunLayoutEngine.java @@ -35,6 +35,7 @@ import java.awt.geom.Point2D; import java.lang.ref.SoftReference; import java.util.concurrent.ConcurrentHashMap; import java.util.Locale; +import java.util.WeakHashMap; /* * different ways to do this @@ -149,17 +150,30 @@ public final class SunLayoutEngine implements LayoutEngine, LayoutEngineFactory this.key = key; } + static WeakHashMap aatInfo = new WeakHashMap<>(); + private boolean isAAT(Font2D font) { + Boolean aatObj; + synchronized (aatInfo) { + aatObj = aatInfo.get(font); + } + if (aatObj != null) { + return aatObj.booleanValue(); + } + boolean aat = false; if (font instanceof TrueTypeFont) { TrueTypeFont ttf = (TrueTypeFont)font; - return ttf.getDirectoryEntry(TrueTypeFont.morxTag) != null || + aat = ttf.getDirectoryEntry(TrueTypeFont.morxTag) != null || ttf.getDirectoryEntry(TrueTypeFont.mortTag) != null; } else if (font instanceof PhysicalFont) { PhysicalFont pf = (PhysicalFont)font; - return pf.getTableBytes(TrueTypeFont.morxTag) != null || + aat = pf.getTableBytes(TrueTypeFont.morxTag) != null || pf.getTableBytes(TrueTypeFont.mortTag) != null; } - return false; + synchronized (aatInfo) { + aatInfo.put(font, Boolean.valueOf(aat)); + } + return aat; } public void layout(FontStrikeDesc desc, float[] mat, int gmask,