# HG changeset patch # User prr # Date 1536517197 25200 # Node ID 9f912f45d6aa03f892fd140c9539004458e10d94 # Parent dcf301c53d23151e9792b8654540917e65b7f9ae 8210384: SunLayoutEngine.isAAT() font is expensive on MacOS Reviewed-by: dmarkov, kaddepalli diff -r dcf301c53d23 -r 9f912f45d6aa src/java.desktop/share/classes/sun/font/SunLayoutEngine.java --- a/src/java.desktop/share/classes/sun/font/SunLayoutEngine.java Sat Sep 08 12:32:51 2018 -0700 +++ b/src/java.desktop/share/classes/sun/font/SunLayoutEngine.java Sun Sep 09 11:19:57 2018 -0700 @@ -35,6 +35,7 @@ import java.lang.ref.SoftReference; import java.util.concurrent.ConcurrentHashMap; import java.util.Locale; +import java.util.WeakHashMap; /* * different ways to do this @@ -148,17 +149,30 @@ 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, float ptSize, int gmask,