changeset 5222:4600cb2846c1

RT-32829: loading of embedded font definitions doesn't work in PrismFontLoader
author Felipe Heidrich <felipe.heidrich@oracle.com>
date Tue, 01 Oct 2013 14:10:58 -0700
parents 8207cae52078
children 932cecc14e49
files modules/graphics/src/main/java/com/sun/javafx/font/PrismFontLoader.java
diffstat 1 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/javafx/font/PrismFontLoader.java	Tue Oct 01 15:41:38 2013 -0400
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/PrismFontLoader.java	Tue Oct 01 14:10:58 2013 -0700
@@ -49,7 +49,8 @@
         Properties map = new Properties();
         // locate the META-INF directory and search for a fonts.mf
         // located there
-        URL u = PrismFontLoader.class.getResource("/META-INF/fonts.mf");
+        ClassLoader loader = Thread.currentThread().getContextClassLoader();
+        URL u = loader.getResource("META-INF/fonts.mf");
         if (u == null) return map;
 
         // read in the contents of the file
@@ -66,17 +67,16 @@
             Properties map = loadEmbeddedFontDefinitions();
             Enumeration<?> names = map.keys();
             FontFactory fontFactory = getFontFactoryFromPipeline();
+            ClassLoader loader = Thread.currentThread().getContextClassLoader();
             while (names.hasMoreElements()) {
                 String n = (String)names.nextElement();
                 String p = map.getProperty(n);
-                try (InputStream in = this.getClass().getResourceAsStream(p)) {
-                    fontFactory.loadEmbeddedFont(n, in, 0, true);
-                } catch (Exception e) {
-/*
-                    java.lang.System.err.println
-                           ("WARNING: Attempted to find and load font "
-                            "'{n}' using path '{p}' but failed");
-*/
+                if (p.startsWith("/")) {
+                    p = p.substring(1);
+                    try (InputStream in = loader.getResourceAsStream(p)) {
+                        fontFactory.loadEmbeddedFont(n, in, 0, true);
+                    } catch (Exception e) {
+                    }
                 }
             }
             embeddedFontsLoaded = true;