changeset 5964:b7940b612df5

RT-34244: fx applet hangs if java console is not shown Reviewed-by: Kevin, Anthony, Thomas
author Felipe Heidrich <felipe.heidrich@oracle.com>
date Fri, 06 Dec 2013 13:32:00 -0800
parents 35d622e670f1
children 0f28c98557a2
files modules/graphics/src/main/java/com/sun/javafx/font/FontFactory.java modules/graphics/src/main/java/com/sun/javafx/font/LogicalFont.java modules/graphics/src/main/java/com/sun/javafx/font/PrismFontFactory.java modules/graphics/src/main/java/com/sun/javafx/font/PrismFontLoader.java modules/graphics/src/main/java/com/sun/prism/j2d/J2DFontFactory.java
diffstat 5 files changed, 35 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/javafx/font/FontFactory.java	Tue Dec 10 12:43:30 2013 -0800
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/FontFactory.java	Fri Dec 06 13:32:00 2013 -0800
@@ -121,4 +121,6 @@
      */
     public PGFont loadEmbeddedFont(String name, String path, 
                                    float size, boolean register);
+
+    public boolean isPlatformFont(String name);
 }
--- a/modules/graphics/src/main/java/com/sun/javafx/font/LogicalFont.java	Tue Dec 10 12:43:30 2013 -0800
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/LogicalFont.java	Fri Dec 06 13:32:00 2013 -0800
@@ -67,6 +67,12 @@
         canonicalFamilyMap.put("dialoginput", MONOSPACED);
     }
 
+    static boolean isLogicalFont(String name) {
+        int spaceIndex = name.indexOf(' ');
+        if (spaceIndex != -1) name = name.substring(0, spaceIndex);
+        return canonicalFamilyMap.get(name) != null;
+    }
+
     private static String getCanonicalFamilyName(String name) {
          if (name == null) {
              return SANS_SERIF;
--- a/modules/graphics/src/main/java/com/sun/javafx/font/PrismFontFactory.java	Tue Dec 10 12:43:30 2013 -0800
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/PrismFontFactory.java	Fri Dec 06 13:32:00 2013 -0800
@@ -1338,6 +1338,18 @@
         return lcdEnabled;
     }
 
+    @Override
+    public boolean isPlatformFont(String name) {
+        if (name == null) return false;
+        /* Using String#startsWith as name can be either a fullName or a family name */
+        String lcName = name.toLowerCase();
+        if (LogicalFont.isLogicalFont(lcName)) return true;
+        if (lcName.startsWith("lucida sans")) return true;
+        String systemFamily = getSystemFont(LogicalFont.SYSTEM).toLowerCase();
+        if (lcName.startsWith(systemFamily)) return true;
+        return false;
+    }
+
     public static boolean isJreFont(FontResource fr) {
         String file = fr.getFileName();
         return file.startsWith(jreFontDir);
--- a/modules/graphics/src/main/java/com/sun/javafx/font/PrismFontLoader.java	Tue Dec 10 12:43:30 2013 -0800
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/PrismFontLoader.java	Fri Dec 06 13:32:00 2013 -0800
@@ -163,14 +163,17 @@
      */
     @Override public Font font(String family, FontWeight weight,
                                FontPosture posture, float size) {
-        loadEmbeddedFonts();
+
+        FontFactory fontFactory = getFontFactoryFromPipeline();
+        if (!embeddedFontsLoaded && !fontFactory.isPlatformFont(family)) {
+            loadEmbeddedFonts();
+        }
 
         // REMIND. Some day need to have better granularity.
 
         boolean bold = weight != null &&
                        weight.ordinal() >= FontWeight.BOLD.ordinal();
         boolean italic = posture == FontPosture.ITALIC;
-        FontFactory fontFactory = getFontFactoryFromPipeline();;
         PGFont prismFont = fontFactory.createFont(family, bold, italic, size);
 
         // Create Font and set implementation
@@ -184,13 +187,16 @@
      * @param font
      */
     @Override public void loadFont(Font font) {
-        loadEmbeddedFonts();
+        FontFactory fontFactory = getFontFactoryFromPipeline();
+        String fullName = font.getName();
+        if (!embeddedFontsLoaded && !fontFactory.isPlatformFont(fullName)) {
+            loadEmbeddedFonts();
+        }
+
         // find the native Prism Font object based on this JavaFX font. At the
         // conclusion of this method, be sure to set the name, family, and
         // style on the Font object via the setNativeFont method.
 
-        FontFactory fontFactory = getFontFactoryFromPipeline();
-        String fullName = font.getName();
         // the Prism font we're trying to find
         PGFont prismFont = fontFactory.createFont(fullName, (float)font.getSize());
 
--- a/modules/graphics/src/main/java/com/sun/prism/j2d/J2DFontFactory.java	Tue Dec 10 12:43:30 2013 -0800
+++ b/modules/graphics/src/main/java/com/sun/prism/j2d/J2DFontFactory.java	Fri Dec 06 13:32:00 2013 -0800
@@ -81,6 +81,10 @@
         return prismFontFactory.getFontFullNames(family);
     }
 
+    public boolean isPlatformFont(String name) {
+        return prismFontFactory.isPlatformFont(name);
+    }
+
     /* This is an important but tricky one. We need to copy the
      * stream. I don't want to have to manage the temp file deletion here,
      * so although its non-optimal I will create a temp file, provide