jdk/src/share/classes/sun/font/FontUtilities.java
changeset 12047 320a714614e9
parent 9035 1255eb81cc2f
child 12538 211d6e82fe51
--- a/jdk/src/share/classes/sun/font/FontUtilities.java	Tue Mar 06 10:25:45 2012 +0800
+++ b/jdk/src/share/classes/sun/font/FontUtilities.java	Tue Mar 06 20:34:38 2012 +0000
@@ -48,6 +48,8 @@
 
     public static boolean isLinux;
 
+    public static boolean isMacOSX;
+
     public static boolean isSolaris8;
 
     public static boolean isSolaris9;
@@ -76,6 +78,8 @@
 
                 isLinux = osName.startsWith("Linux");
 
+                isMacOSX = osName.startsWith("Mac OS X"); // TODO: MacOSX
+
                 String t2kStr = System.getProperty("sun.java2d.font.scaler");
                 if (t2kStr != null) {
                     useT2K = "t2k".equals(t2kStr);
@@ -407,12 +411,12 @@
         }
 
         FontManager fm = FontManagerFactory.getInstance();
-        CompositeFont dialog2D =
-          (CompositeFont) fm.findFont2D("dialog", font.getStyle(),
-                                        FontManager.NO_FALLBACK);
-        if (dialog2D == null) { /* shouldn't happen */
+        Font2D dialog = fm.findFont2D("dialog", font.getStyle(), FontManager.NO_FALLBACK);
+        // Should never be null, but MACOSX fonts are not CompositeFonts
+        if (dialog == null || !(dialog instanceof CompositeFont)) {
             return fuir;
         }
+        CompositeFont dialog2D = (CompositeFont)dialog;
         PhysicalFont physicalFont = (PhysicalFont)font2D;
         ConcurrentHashMap<PhysicalFont, CompositeFont> compMap = compMapRef.get();
         if (compMap == null) { // Its been collected.