< prev index next >

modules/graphics/src/main/java/com/sun/prism/j2d/J2DFontFactory.java

Print this page

        

@@ -93,24 +93,31 @@
      * 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
      * input streams on it to both prism and 2D, then when they are done,
      * remove it.
      */
-    public PGFont loadEmbeddedFont(String name, InputStream fontStream,
-                                   float size, boolean register) {
+    public PGFont[] loadEmbeddedFont(String name, InputStream fontStream,
+                                     float size,
+                                     boolean register,
+                                     boolean loadAll) {
 
         if (!hasPermission()) {
-            return createFont(DEFAULT_FULLNAME, size);
+            PGFont[] fonts = new PGFont[1];
+            fonts[0] = createFont(DEFAULT_FULLNAME, size);
+            return fonts;
         }
 
-        PGFont font = prismFontFactory.loadEmbeddedFont(name, fontStream,
-                                                        size, register);
-
-        if (font == null) return null;
-        final FontResource fr = font.getFontResource();
-        registerFont(font.getFontResource());
-        return font;
+        PGFont[] fonts =
+          prismFontFactory.loadEmbeddedFont(name, fontStream,
+                                            size, register, loadAll);
+
+        if (fonts == null || fonts.length == 0) return null;
+        final FontResource fr = fonts[0].getFontResource();
+        // REMIND: this needs to be upgraded to use JDK9 createFont
+        // which can handle a collection.
+        registerFont(fonts[0].getFontResource());
+        return fonts;
     }
 
     /**
      * Printing uses the 2D pipeline which isn't initialised until
      * printing begins, so grabs a copy of the file holding an

@@ -137,22 +144,29 @@
             }
             return null;
         });
     }
 
-    public PGFont loadEmbeddedFont(String name, String path,
-                                   float size, boolean register) {
+    public PGFont[] loadEmbeddedFont(String name, String path,
+                                     float size,
+                                     boolean register,
+                                     boolean loadAll) {
 
         if (!hasPermission()) {
-            return createFont(DEFAULT_FULLNAME, size);
+            PGFont[] fonts = new PGFont[1];
+            fonts[0] = createFont(DEFAULT_FULLNAME, size);
+            return fonts;
         }
 
-        PGFont font = prismFontFactory.loadEmbeddedFont(name, path,
-                                                        size, register);
-
-        if (font == null) return null;
-        final FontResource fr = font.getFontResource();
+        PGFont[] fonts =
+            prismFontFactory.loadEmbeddedFont(name, path,
+                                              size, register, loadAll);
+
+        if (fonts == null || fonts.length == 0) return null;
+        // REMIND: this needs to be upgraded to use JDK9 createFont
+        // which can handle a collection.
+        final FontResource fr = fonts[0].getFontResource();
         AccessController.doPrivileged(new PrivilegedAction<Object>() {
             public Object run() {
                 try {
                     File file = new File(fr.getFileName());
                     Font font = Font.createFont(Font.TRUETYPE_FONT, file);

@@ -161,11 +175,11 @@
                     e.printStackTrace();
                 }
                 return null;
             }
         });
-        return font;
+        return fonts;
     }
 
     private static boolean compositeFontMethodsInitialized = false;
     private static Method getCompositeFontUIResource = null;
 
< prev index next >