changeset 6944:b6812eeecbc9

[Font] New native font rasterizer in Linux fails to load non system true type fonts
author Felipe Heidrich <felipe.heidrich@oracle.com>
date Wed, 30 Apr 2014 06:22:16 -0700
parents 5e0c832019c3
children 52f27b865f51
files modules/graphics/src/main/java/com/sun/javafx/font/freetype/FTFactory.java
diffstat 1 files changed, 18 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/javafx/font/freetype/FTFactory.java	Wed Apr 30 08:30:58 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/freetype/FTFactory.java	Wed Apr 30 06:22:16 2014 -0700
@@ -8,7 +8,7 @@
 import com.sun.javafx.text.TextRun;
 
 public class FTFactory extends PrismFontFactory {
-    
+
     static boolean LCD_SUPPORT;
 
     public static PrismFontFactory getFactory() {
@@ -44,10 +44,11 @@
 
     @Override
     protected PrismFontFile createFontFile(String name, String filename,
-            int fIndex, boolean register, boolean embedded, boolean copy,
-            boolean tracked) throws Exception {
+                                           int fIndex, boolean register,
+                                           boolean embedded, boolean copy,
+                                           boolean tracked) throws Exception {
         return new FTFontFile(name, filename, fIndex, register,
-                                 embedded, copy, tracked);
+                              embedded, copy, tracked);
     }
 
     @Override
@@ -68,7 +69,18 @@
 
     @Override
     protected boolean registerEmbeddedFont(String path) {
-        return false;
+        long[] ptr = new long[1];
+        int error = OSFreetype.FT_Init_FreeType(ptr);
+        if (error != 0) return false;
+        long library = ptr[0];
+        byte[] buffer = (path+"\0").getBytes();
+        error = OSFreetype.FT_New_Face(library, buffer, 0, ptr);
+        if (error != 0) {
+            long face = ptr[0];
+            OSFreetype.FT_Done_Face(face);
+        }
+        OSFreetype.FT_Done_FreeType(library);
+        return error == 0;
     }
 
     private static class StubGlyphLayout extends GlyphLayout {
@@ -77,7 +89,7 @@
         }
 
         @Override
-        public void layout(TextRun run, PGFont font, FontStrike strike, char[] text) {            
+        public void layout(TextRun run, PGFont font, FontStrike strike, char[] text) {
         }
     }