7181199: [macosx] Startup is much slower in headless mode for apps using Fonts
authorbae
Tue, 11 Sep 2012 13:32:48 +0400
changeset 13767 5ea857776c3f
parent 13766 0e523a5ed1af
child 13768 4bf20f0aaac4
7181199: [macosx] Startup is much slower in headless mode for apps using Fonts Reviewed-by: jgodinez, prr
jdk/src/macosx/classes/sun/font/CFontManager.java
--- a/jdk/src/macosx/classes/sun/font/CFontManager.java	Mon Sep 10 10:07:10 2012 -0700
+++ b/jdk/src/macosx/classes/sun/font/CFontManager.java	Tue Sep 11 13:32:48 2012 +0400
@@ -37,6 +37,7 @@
 import javax.swing.plaf.FontUIResource;
 
 import sun.awt.FontConfiguration;
+import sun.awt.HeadlessToolkit;
 import sun.lwawt.macosx.*;
 
 public class CFontManager extends SunFontManager {
@@ -342,9 +343,14 @@
     @Override
     public String getFontPath(boolean noType1Fonts) {
         // In the case of the Cocoa toolkit, since we go through NSFont, we dont need to register /Library/Fonts
-        if (Toolkit.getDefaultToolkit() instanceof LWCToolkit) {
+        Toolkit tk = Toolkit.getDefaultToolkit();
+        if (tk instanceof HeadlessToolkit) {
+            tk = ((HeadlessToolkit)tk).getUnderlyingToolkit();
+        }
+        if (tk instanceof LWCToolkit) {
             return "";
         }
+
         // X11 case
         return "/Library/Fonts";
     }