changeset 6436:efb0a3d40c1f

RT-35978 changing unltimate fallback for fonts when fontconfig is not present (embedded devices) Reviewed-by: kselle, fheidric
author ddhill
date Thu, 06 Mar 2014 17:50:58 -0500
parents 29346901e6f1
children b2217904cc6a
files modules/graphics/src/main/java/com/sun/javafx/font/FontConfigManager.java
diffstat 1 files changed, 10 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/javafx/font/FontConfigManager.java	Thu Mar 06 16:20:43 2014 -0500
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/FontConfigManager.java	Thu Mar 06 17:50:58 2014 -0500
@@ -365,38 +365,19 @@
                 fontDir = fontDirProp;
             } else {
                 try {
-                    // In a jar, the URL string for a class looks like
-                    // jar:file:/home/user/rt/lib/ext/jfxrt.jar!/com/pkg/FCM.class
-                    // Strip this down to get the "lib" directory URL.
-                    Class c = FontConfigManager.class;
-                    String name = "FontConfigManager.class";
-                    String urlStr = c.getResource(name).toString();
-                    if (debugFonts) {
-                        System.err.println("Class URL is " + urlStr);
-                    }
-                    if (urlStr == null) {
+                    // no fontConfig or -Dprism.fontdir, lets fallback
+                    // to {java.home}/lib/fonts if it exists
+                    final String javaHome = System.getProperty("java.home");
+                    if (javaHome == null) {
                         return;
                     }
-                    int ei =  urlStr.indexOf("!");
-                    if (urlStr.startsWith("jar:file:") || ei != -1) {
-                        urlStr = urlStr.substring(9, ei);
-                        int lsi = Math.max(urlStr.lastIndexOf("/"),
-                                           urlStr.lastIndexOf("\\"));
-                        urlStr = urlStr.substring(0, lsi);
-                    }
-
-                    if(urlStr.endsWith("lib/ext")) {
-                        // jfxrt.jar lives in lib/ext, and fonts in lib/fonts
-                        urlStr = urlStr.substring(0, urlStr.length()-3);
-                    }
-
-                    File fontDirectory = new File(urlStr, "fonts");
-                    fontDir = fontDirectory.getPath();
+                    File fontDirectory = new File(javaHome, "lib/fonts");
                     if (fontDirectory.exists()) {
                         fontDirFromJRE = true;
+                        fontDir = fontDirectory.getPath();
                     }
                     if (debugFonts) {
-                        System.err.println("Font Dir is " + fontDirectory +
+                        System.err.println("Fallback fontDir is " + fontDirectory +
                                            " exists = " +
                                            fontDirectory.exists());
                     }
@@ -488,6 +469,9 @@
                     for(int i=0; i < jreFontsProperties.length; i += 2) {
                         props.setProperty(jreFontsProperties[i],jreFontsProperties[i+1]);
                     }
+                    if (debugFonts) {
+                        System.err.println("Using fallback implied logicalfonts.properties");
+                    }
                 }
             } catch (IOException ioe) {
                 if (debugFonts) {