changeset 5537:7274ae9bc2d9

Android: RT-33695 Add native text rendering suport.Uses freetype for simple text. Complex text is ignored until harfbuzz based implementation is available. Builds freetype independently from pango. Reviewers: felipe.heidrich@oracle.com, kevin.rushforth@oracle.com
author tb115823 <Tomas.Brandalik@oracle.com>
date Fri, 25 Oct 2013 12:04:34 +0200
parents 868a63435321
children ea1fd4f0f16d
files build.gradle buildSrc/android.gradle buildSrc/armv6hf.gradle buildSrc/armv6sf.gradle buildSrc/linux.gradle modules/graphics/src/main/java/com/sun/javafx/font/PrismFontFactory.java modules/graphics/src/main/java/com/sun/javafx/font/freetype/FTDisposer.java modules/graphics/src/main/java/com/sun/javafx/font/freetype/FTFactory.java modules/graphics/src/main/java/com/sun/javafx/font/freetype/FTFontFile.java modules/graphics/src/main/java/com/sun/javafx/font/freetype/FTFontStrike.java modules/graphics/src/main/java/com/sun/javafx/font/freetype/FTGlyph.java modules/graphics/src/main/java/com/sun/javafx/font/freetype/FT_Bitmap.java modules/graphics/src/main/java/com/sun/javafx/font/freetype/FT_GlyphSlotRec.java modules/graphics/src/main/java/com/sun/javafx/font/freetype/FT_Glyph_Metrics.java modules/graphics/src/main/java/com/sun/javafx/font/freetype/FT_Matrix.java modules/graphics/src/main/java/com/sun/javafx/font/freetype/HBGlyphLayout.java modules/graphics/src/main/java/com/sun/javafx/font/freetype/OSFreetype.java modules/graphics/src/main/java/com/sun/javafx/font/freetype/OSPango.java modules/graphics/src/main/java/com/sun/javafx/font/freetype/PangoGlyphInfo.java modules/graphics/src/main/java/com/sun/javafx/font/freetype/PangoGlyphLayout.java modules/graphics/src/main/java/com/sun/javafx/font/freetype/PangoGlyphString.java modules/graphics/src/main/java/com/sun/javafx/font/pango/FTDisposer.java modules/graphics/src/main/java/com/sun/javafx/font/pango/FTFontFile.java modules/graphics/src/main/java/com/sun/javafx/font/pango/FTFontStrike.java modules/graphics/src/main/java/com/sun/javafx/font/pango/FTGlyph.java modules/graphics/src/main/java/com/sun/javafx/font/pango/FT_Bitmap.java modules/graphics/src/main/java/com/sun/javafx/font/pango/FT_GlyphSlotRec.java modules/graphics/src/main/java/com/sun/javafx/font/pango/FT_Glyph_Metrics.java modules/graphics/src/main/java/com/sun/javafx/font/pango/FT_Matrix.java modules/graphics/src/main/java/com/sun/javafx/font/pango/OS.java modules/graphics/src/main/java/com/sun/javafx/font/pango/PangoFactory.java modules/graphics/src/main/java/com/sun/javafx/font/pango/PangoGlyphInfo.java modules/graphics/src/main/java/com/sun/javafx/font/pango/PangoGlyphLayout.java modules/graphics/src/main/java/com/sun/javafx/font/pango/PangoGlyphString.java modules/graphics/src/main/native-font/freetype.c modules/graphics/src/main/native-font/pango.c
diffstat 36 files changed, 1390 insertions(+), 1169 deletions(-) [+]
line wrap: on
line diff
--- a/build.gradle	Fri Oct 25 13:46:44 2013 +0400
+++ b/build.gradle	Fri Oct 25 12:04:34 2013 +0200
@@ -1076,6 +1076,7 @@
 
     if (IS_COMPILE_PANGO) {
         // TODO: embedded support
+        addNative(project, "fontFreetype", ["linux"])
         addNative(project, "fontPango", ["linux"])
     }
 
@@ -2160,7 +2161,7 @@
                 if (IS_COMPILE_PANGO) {
                     // TODO: embedded support
                     if ("${defaultHostTarget}" == "${t.name}") {
-                        libs += 'fontPango';
+                        libs += ['fontFreetype', 'fontPango'];
                     }
                 }
                 libs.each { lib ->
--- a/buildSrc/android.gradle	Fri Oct 25 13:46:44 2013 +0400
+++ b/buildSrc/android.gradle	Fri Oct 25 12:04:34 2013 +0200
@@ -163,6 +163,13 @@
     return
 }
 
+def freetypeDir = project.hasProperty("FREETYPE_DIR") ? "${FREETYPE_DIR}" : null
+if (!assertDir(freetypeDir)) {
+    logger.warn("FREETYPE_DIR $freetypeDir doesn't exists! Build continues without native text support.")
+    freetypeDir = null
+}
+def compileNativeText = freetypeDir != null
+
 def compiler = file("$compilerHome/bin/${toolchainArchs[0]}-gcc").getAbsolutePath()
 def linker = file("$compilerHome/bin/${toolchainArchs[0]}-g++").getAbsolutePath()
 
@@ -171,6 +178,8 @@
 logger.quiet("ANDROID_SDK_TARGET: $sdk_target")
 logger.quiet("ANDROID_NDK: $ndk")
 logger.quiet("ANDROID_NDK_TARGET: $ndk_target")
+logger.quiet("FREETYPE_DIR: $freetypeDir")
+logger.quiet("Compile native text: $compileNativeText") 
 logger.quiet("Android Compiler: $compiler")
 logger.quiet("Android Linker: $linker")
 
@@ -184,7 +193,7 @@
         classpath = files("build/classes/android")
         destinationDir = file("build/classes/android")
         dependencyCacheDir = file("build/dependency-cache")
-        source "src/android/java"
+        source fileTree(dir: 'src/android/java').matching { include 'com/oracle/dalvik/**' }
     }
 
     task jarDalvikLibs(type: Jar, group: "Build", dependsOn: compileDalvikLibs) {
@@ -195,12 +204,18 @@
         include("com/oracle/dalvik/**/*")
         dependsOn(compileDalvikLibs)
     }
-
+    
     afterEvaluate {
         addNative(project, "surface", ["android"])
         addNative(project, "vmlauncher", ["android"])
+        if (compileNativeText) {
+            addNative(project, "fontNativeFreetype", ["android"])
+        }
         tasks["javahAndroidVmlauncher"].dependsOn(compileDalvikLibs)
         tasks["native"].dependsOn("nativeSurface", "nativeVmlauncher")
+        if (compileNativeText) {
+            tasks["native"].dependsOn("nativeFontNativeFreetype")
+        }
 
         sdkAndroid  {
             dependsOn(jarDalvikLibs)
@@ -217,6 +232,12 @@
                     from ("modules/graphics/build/libs/${props.jfxdvklib}")
                     into ("build/android-sdk/dalvik/lib")
                 }
+                if (compileNativeText) {
+                    copy {
+                        from ("modules/graphics/build/libs/fontNativeFreetype/android")
+                        into ("build/android-sdk/rt/$ANDROID.libDest")
+                    }
+                }
             }
         }
     }
@@ -336,12 +357,16 @@
     "com/oracle/dalvik"
 ]
 
+def text = (compileNativeText) ? "native" : "t2k"
+
 ANDROID.javafxPlatformProperties = """
 javafx.platform=android
 android.glass.platform=Lens
 android.glass.lens=eglfb
 android.prism.glDepthSize=16
 android.prism.lcdtext=false
+android.prism.debugfonts=true
+android.prism.text=$text
 android.embedded=eglfb
 android.prism.allowhidpi=false
 android.prism.maxTextureSize=2048
@@ -352,7 +377,13 @@
 """
 def sysroot = "$ndk/platforms/$ndk_target/arch-arm"
 
-def ccFlags = ["--sysroot=$sysroot","-std=c99", "-DANDROID", "-c", "-nostdlib", "-DANDROID_NDK"]
+def ccFlags = ["--sysroot=$sysroot","-std=c99", "-DANDROID", "-c", "-nostdlib", 
+               "-DANDROID_NDK"]
+
+if (project.hasProperty("DALVIK_VM")) {
+    ccFlags += ["-DDALVIK_VM"]
+}
+
 def ccOptFlags = ["-fpic", "-ffunction-sections", "-funwind-tables","-fstack-protector",
                   "-Os", "-O2", "-fno-strict-aliasing", "-finline-limit=64", "-fomit-frame-pointer"]
 def ccWarnFlags = ["-Wa,--noexecstack", "-Wno-psabi"]
@@ -526,18 +557,44 @@
 ANDROID.font.linkFlags = [linkFlags].flatten()
 ANDROID.font.lib = "javafx_font"
 
-ANDROID.fontT2K = [:]
-ANDROID.fontT2K.javahInclude = ["com/sun/javafx/font/t2k/**/*"]
-ANDROID.fontT2K.nativeSource = [
-    file("$closedDir/javafx-font-t2k-native/src"),
-    file("$closedDir/javafx-font-t2k-native/src/layout"),
-    file("$closedDir/javafx-font-t2k-native/src/layoutfx")]
-ANDROID.fontT2K.compiler = compiler
-ANDROID.fontT2K.ccFlags = [ccFlags, "-fno-exceptions", "-fno-rtti", ccWarnFlags,
-    ccArchFlags, ccOptFlags, ccDebugFlags, ccDefaultIncludeFlags].flatten()
-ANDROID.fontT2K.linker = linker
-ANDROID.fontT2K.linkFlags = [linkFlags, "-lstdc++"].flatten()
-ANDROID.fontT2K.lib = "javafx_font_t2k"
+if (BUILD_CLOSED) {
+    ANDROID.fontT2K = [:]
+    ANDROID.fontT2K.javahInclude = ["com/sun/javafx/font/t2k/**/*"]
+    ANDROID.fontT2K.nativeSource = [
+        file("$closedDir/javafx-font-t2k-native/src"),
+        file("$closedDir/javafx-font-t2k-native/src/layout"),
+        file("$closedDir/javafx-font-t2k-native/src/layoutfx")]
+    ANDROID.fontT2K.compiler = compiler
+    ANDROID.fontT2K.ccFlags = [ccFlags, "-fno-exceptions", "-fno-rtti", ccWarnFlags,
+        ccArchFlags, ccOptFlags, ccDebugFlags, ccDefaultIncludeFlags].flatten()
+    ANDROID.fontT2K.linker = linker
+    ANDROID.fontT2K.linkFlags = [linkFlags, "-lstdc++"].flatten()
+    ANDROID.fontT2K.lib = "javafx_font_t2k"
+} 
+
+if (compileNativeText) {
+    ANDROID.fontNativeFreetype = [:]
+    ANDROID.fontNativeFreetype.javahInclude = [
+        "com/sun/javafx/font/freetype/OSFreetype.class"
+    ]
+    ANDROID.fontNativeFreetype.nativeSource = [
+        file("modules/graphics/src/main/native-font/freetype.c")
+    ]
+    ANDROID.fontNativeFreetype.compiler = compiler
+    ANDROID.fontNativeFreetype.linker = linker
+    ANDROID.fontNativeFreetype.lib = "javafx_font_freetype"
+
+    ccFlags += ["-D_ENABLE_HARFBUZZ"]
+
+    ANDROID.fontNativeFreetype.ccFlags = 
+        [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
+        ccDebugFlags, ccDefaultIncludeFlags,
+        "-I$freetypeDir/include", "-I$freetypeDir/include/freetype2"].flatten()  
+        
+    ANDROID.fontNativeFreetype.linkFlags = 
+        [linkFlags, "-llog", 
+         "-L$freetypeDir/lib", "$freetypeDir/lib/libfreetype.a"].flatten()
+}
 
 ANDROID.media = [:]
 ANDROID.media.compiler = compiler
--- a/buildSrc/armv6hf.gradle	Fri Oct 25 13:46:44 2013 +0400
+++ b/buildSrc/armv6hf.gradle	Fri Oct 25 12:04:34 2013 +0200
@@ -246,6 +246,30 @@
     }
 )
 
+def freetypeCCFlags = [ext.COMPILE_PANGO ? "-D_ENABLE_PANGO" : 
+                       ext.COMPILE_HARFBUZZ ? "-D_ENABLE_HARFBUZZ" : ""]
+def freetypeLinkFlags = []
+setupTools("armv6hf_freetype_tools",
+    { propFile ->
+        ByteArrayOutputStream results = new ByteArrayOutputStream();
+        exec {
+            commandLine "$sdk/bin/pkg-config", "--cflags", "freetype2"
+            standardOutput = results
+        }
+        propFile << "cflags=" << results.toString().trim() << "\n";
+
+        results = new ByteArrayOutputStream();
+        exec {
+            commandLine "$sdk/bin/pkg-config", "--libs", "freetype2"
+            standardOutput = results
+        }
+        propFile << "libs=" << results.toString().trim();
+    },
+    { properties ->
+        freetypeCCFlags.addAll(properties.getProperty("cflags").split(" "))
+        freetypeLinkFlags.addAll(properties.getProperty("libs").split(" "))
+    }
+)
 
 def compiler = file("$compilerHome/bin/arm-linux-gnueabihf-gcc").getAbsolutePath()
 def linker = file("$compilerHome/bin/arm-linux-gnueabihf-g++").getAbsolutePath()
@@ -426,11 +450,18 @@
 ARMV6HF.fontT2K.linkFlags = fontLFlags
 ARMV6HF.fontT2K.lib = "javafx_font_t2k"
 
+ARMV6HF.fontFreetype = [:]
+ARMV6HF.fontFreetype.javahInclude = ["com/sun/javafx/font/freetype/OSFreetype.class*"]
+ARMV6HF.fontFreetype.nativeSource = ["src/main/native-font/freetype.c"]
+ARMV6HF.fontFreetype.compiler = compiler
+ARMV6HF.fontFreetype.ccFlags = ["-DJFXFONT_PLUS", ccFlags, fontCFlags, freetypeCCFlags].flatten()
+ARMV6HF.fontFreetype.linker = linker
+ARMV6HF.fontFreetype.linkFlags = [linkFlags, fontLFlags, freetypeLinkFlags].flatten()
+ARMV6HF.fontFreetype.lib = "javafx_font_freetype"
+
 ARMV6HF.fontPango = [:]
-ARMV6HF.fontPango.javahInclude = ["com/sun/javafx/font/pango/*"]
-ARMV6HF.fontPango.nativeSource = [
-    "src/main/native-font/pango.c",
-    "src/main/native-font/freetype.c"]
+ARMV6HF.fontPango.javahInclude = ["com/sun/javafx/font/freetype/OSPango.class"]
+ARMV6HF.fontPango.nativeSource = ["src/main/native-font/pango.c"]
 ARMV6HF.fontPango.compiler = compiler
 ARMV6HF.fontPango.ccFlags = ["-DJFXFONT_PLUS", ccFlags, pangoCCFlags].flatten()
 ARMV6HF.fontPango.linker = linker
--- a/buildSrc/armv6sf.gradle	Fri Oct 25 13:46:44 2013 +0400
+++ b/buildSrc/armv6sf.gradle	Fri Oct 25 12:04:34 2013 +0200
@@ -265,6 +265,30 @@
     }
 )
 
+def freetypeCCFlags = [ext.COMPILE_PANGO ? "-D_ENABLE_PANGO" : 
+                       ext.COMPILE_HARFBUZZ ? "-D_ENABLE_HARFBUZZ" : ""]
+def freetypeLinkFlags = []
+setupTools("armv6sf_freetype_tools",
+    { propFile ->
+        ByteArrayOutputStream results = new ByteArrayOutputStream();
+        exec {
+            commandLine "$sdk/bin/pkg-config", "--cflags", "freetype2"
+            standardOutput = results
+        }
+        propFile << "cflags=" << results.toString().trim() << "\n";
+
+        results = new ByteArrayOutputStream();
+        exec {
+            commandLine "$sdk/bin/pkg-config", "--libs", "freetype2"
+            standardOutput = results
+        }
+        propFile << "libs=" << results.toString().trim();
+    },
+    { properties ->
+        freetypeCCFlags.addAll(properties.getProperty("cflags").split(" "))
+        freetypeLinkFlags.addAll(properties.getProperty("libs").split(" "))
+    }
+)
 
 def compiler = file("$compilerHome/bin/arm-linux-gnueabi-gcc").getAbsolutePath()
 def linker = file("$compilerHome/bin/arm-linux-gnueabi-g++").getAbsolutePath()
@@ -445,11 +469,18 @@
 ARMV6SF.fontT2K.linkFlags = fontLFlags
 ARMV6SF.fontT2K.lib = "javafx_font_t2k"
 
+ARMV6SF.fontFreetype = [:]
+ARMV6SF.fontFreetype.javahInclude = ["com/sun/javafx/font/freetype/OSFreetype.class"]
+ARMV6SF.fontFreetype.nativeSource = ["src/main/native-font/freetype.c"]
+ARMV6SF.fontFreetype.compiler = compiler
+ARMV6SF.fontFreetype.ccFlags = ["-DJFXFONT_PLUS", ccFlags, fontCFlags, freetypeCCFlags].flatten()
+ARMV6SF.fontFreetype.linker = linker
+ARMV6SF.fontFreetype.linkFlags = [linkFlags, fontLFlags, freetypeLinkFlags].flatten()
+ARMV6SF.fontFreetype.lib = "javafx_font_freetype"
+
 ARMV6SF.fontPango = [:]
-ARMV6SF.fontPango.javahInclude = ["com/sun/javafx/font/pango/*"]
-ARMV6SF.fontPango.nativeSource = [
-    "src/main/native-font/pango.c",
-    "src/main/native-font/freetype.c"]
+ARMV6SF.fontPango.javahInclude = ["com/sun/javafx/font/freetype/OSPango.class"]
+ARMV6SF.fontPango.nativeSource = ["src/main/native-font/pango.c"]
 ARMV6SF.fontPango.compiler = compiler
 ARMV6SF.fontPango.ccFlags = ["-DJFXFONT_PLUS", ccFlags, pangoCCFlags].flatten()
 ARMV6SF.fontPango.linker = linker
--- a/buildSrc/linux.gradle	Fri Oct 25 13:46:44 2013 +0400
+++ b/buildSrc/linux.gradle	Fri Oct 25 12:04:34 2013 +0200
@@ -128,6 +128,31 @@
     }
 )
 
+def freetypeCCFlags = [ext.COMPILE_PANGO ? "-D_ENABLE_PANGO" : 
+                       ext.COMPILE_HARFBUZZ ? "-D_ENABLE_HARFBUZZ" : ""]
+def freetypeLinkFlags = []
+setupTools("linux_freetype_tools",
+    { propFile ->
+        ByteArrayOutputStream results = new ByteArrayOutputStream();
+        exec {
+            commandLine "pkg-config", "--cflags", "freetype2"
+            standardOutput = results
+        }
+        propFile << "cflags=" << results.toString().trim() << "\n";
+
+        results = new ByteArrayOutputStream();
+        exec {
+            commandLine "pkg-config", "--libs", "freetype2"
+            standardOutput = results
+        }
+        propFile << "libs=" << results.toString().trim();
+    },
+    { properties ->
+        freetypeCCFlags.addAll(properties.getProperty("cflags").split(" "))
+        freetypeLinkFlags.addAll(properties.getProperty("libs").split(" "))
+    }
+)
+
 def compiler = IS_COMPILE_PARFAIT ? "parfait-gcc" : "gcc";
 def cc_compiler = IS_COMPILE_PARFAIT ? "parfait-cc" : "cc";
 def linker = IS_COMPILE_PARFAIT ? "parfait-g++" : "g++";
@@ -224,11 +249,18 @@
 LINUX.fontT2K.linkFlags = [linkFlags].flatten()
 LINUX.fontT2K.lib = "javafx_font_t2k"
 
+LINUX.fontFreetype = [:]
+LINUX.fontFreetype.javahInclude = ["com/sun/javafx/font/freetype/OSFreetype.class"]
+LINUX.fontFreetype.nativeSource = ["src/main/native-font/freetype.c"]
+LINUX.fontFreetype.compiler = compiler
+LINUX.fontFreetype.ccFlags = ["-DJFXFONT_PLUS", ccFlags, freetypeCCFlags].flatten()
+LINUX.fontFreetype.linker = linker
+LINUX.fontFreetype.linkFlags = [linkFlags, freetypeLinkFlags].flatten()
+LINUX.fontFreetype.lib = "javafx_font_freetype"
+
 LINUX.fontPango = [:]
-LINUX.fontPango.javahInclude = ["com/sun/javafx/font/pango/*"]
-LINUX.fontPango.nativeSource = [
-    "src/main/native-font/pango.c",
-    "src/main/native-font/freetype.c"]
+LINUX.fontPango.javahInclude = ["com/sun/javafx/font/freetype/OSPango.class"]
+LINUX.fontPango.nativeSource = ["src/main/native-font/pango.c"]
 LINUX.fontPango.compiler = compiler
 LINUX.fontPango.ccFlags = ["-DJFXFONT_PLUS", ccFlags, pangoCCFlags].flatten()
 LINUX.fontPango.linker = linker
--- a/modules/graphics/src/main/java/com/sun/javafx/font/PrismFontFactory.java	Fri Oct 25 13:46:44 2013 +0400
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/PrismFontFactory.java	Fri Oct 25 12:04:34 2013 +0200
@@ -69,7 +69,7 @@
     private static final String T2K_FACTORY = "com.sun.javafx.font.t2k.T2KFactory";
     private static final String CT_FACTORY = "com.sun.javafx.font.coretext.CTFactory";
     private static final String DW_FACTORY = "com.sun.javafx.font.directwrite.DWFactory";
-    private static final String PANGO_FACTORY = "com.sun.javafx.font.pango.PangoFactory";
+    private static final String FT_FACTORY = "com.sun.javafx.font.freetype.FTFactory";
 
     /* We need two maps. One to hold pointers to the raw fonts, another
      * to hold pointers to the composite resources. Top level look ups
@@ -156,7 +156,7 @@
     private static String getNativeFactoryName() {
         if (isWindows) return DW_FACTORY;
         if (isMacOSX || isIOS) return CT_FACTORY;
-        if (isLinux) return PANGO_FACTORY;
+        if (isLinux || isAndroid) return FT_FACTORY;
         return null;
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/freetype/FTDisposer.java	Fri Oct 25 12:04:34 2013 +0200
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.javafx.font.freetype;
+
+import com.sun.javafx.font.DisposerRecord;
+import com.sun.javafx.font.PrismFontFactory;
+
+class FTDisposer implements DisposerRecord  {
+    long library;
+    long face;
+
+    FTDisposer(long library, long face) {
+        this.library = library;
+        this.face = face;
+    }
+
+    public synchronized void dispose() {
+        if (face != 0) {
+            OSFreetype.FT_Done_Face(face);
+            if (PrismFontFactory.debugFonts) {
+                System.err.println("Done Face=" + face);
+            }
+            face = 0;
+        }
+        if (library != 0) {
+            OSFreetype.FT_Done_FreeType(library);
+            if (PrismFontFactory.debugFonts) {
+                System.err.println("Done Library=" + library);
+            }
+            library = 0;
+        }
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/freetype/FTFactory.java	Fri Oct 25 12:04:34 2013 +0200
@@ -0,0 +1,84 @@
+package com.sun.javafx.font.freetype;
+
+import com.sun.javafx.font.FontStrike;
+import com.sun.javafx.font.PGFont;
+import com.sun.javafx.font.PrismFontFactory;
+import com.sun.javafx.font.PrismFontFile;
+import com.sun.javafx.text.GlyphLayout;
+import com.sun.javafx.text.TextRun;
+
+public class FTFactory extends PrismFontFactory {
+    
+    static boolean LCD_SUPPORT;
+
+    public static PrismFontFactory getFactory() {
+        PrismFontFactory factory = null;
+        long[] ptr = new long[1];
+        int error = OSFreetype.FT_Init_FreeType(ptr);
+        long library = ptr[0];
+        int[] major = new int[1], minor = new int[1], patch = new int[1];
+        if (error == 0) {
+            factory = new FTFactory();
+            OSFreetype.FT_Library_Version(library, major, minor, patch);
+
+            /* This implementation only supports LCD if freetype has support. */
+            error = OSFreetype.FT_Library_SetLcdFilter(library, OSFreetype.FT_LCD_FILTER_DEFAULT);
+            LCD_SUPPORT = error == 0;
+            OSFreetype.FT_Done_FreeType(library);
+        }
+        if (PrismFontFactory.debugFonts) {
+            if (factory != null) {
+                String version = major[0] + "." + minor[0] + "." + patch[0];
+                System.err.println("Freetype2 Loaded (version " + version + ")");
+                String lcdSupport = LCD_SUPPORT ? "Enabled" : "Disabled";
+                System.err.println("LCD support " + lcdSupport);
+            } else {
+                System.err.println("Freetype2 Failed (error " + error + ")");
+            }
+        }
+        return factory;
+    }
+
+    private FTFactory() {
+    }
+
+    @Override
+    protected PrismFontFile createFontFile(String name, String filename,
+            int fIndex, boolean register, boolean embedded, boolean copy,
+            boolean tracked) throws Exception {
+        return new FTFontFile(name, filename, fIndex, register,
+                                 embedded, copy, tracked);
+    }
+
+    @Override
+    public GlyphLayout createGlyphLayout() {
+        if (OSFreetype.isPangoEnabled()) {
+            return new PangoGlyphLayout();
+        }
+        if (OSFreetype.isHarfbuzzEnabled()) {
+            return new HBGlyphLayout();
+        }
+        return new StubGlyphLayout();
+    }
+
+    @Override
+    public boolean isLCDTextSupported() {
+        return LCD_SUPPORT && super.isLCDTextSupported();
+    }
+
+    @Override
+    protected boolean registerEmbeddedFont(String path) {
+        return false;
+    }
+
+    private static class StubGlyphLayout extends GlyphLayout {
+
+        public StubGlyphLayout() {
+        }
+
+        @Override
+        public void layout(TextRun run, PGFont font, FontStrike strike, char[] text) {            
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/freetype/FTFontFile.java	Fri Oct 25 12:04:34 2013 +0200
@@ -0,0 +1,194 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.javafx.font.freetype;
+
+import com.sun.javafx.font.Disposer;
+import com.sun.javafx.font.FontResource;
+import com.sun.javafx.font.FontStrikeDesc;
+import com.sun.javafx.font.PrismFontFactory;
+import com.sun.javafx.font.PrismFontFile;
+import com.sun.javafx.font.PrismFontStrike;
+import com.sun.javafx.geom.Path2D;
+import com.sun.javafx.geom.transform.BaseTransform;
+
+class FTFontFile extends PrismFontFile {
+    /*
+     * Font files can be accessed by several threads. In general this are the
+     * JFX thread (measuring) and the Prism thread (rendering). But, if a Text
+     * node is no connected a Scene it can be used in any user thread, thus a
+     * font resource can be accessed from any thread.
+     *
+     * Freetype resources are not thread safe. In this implementation each font
+     * resources has its own FT_Face and FT_Library, and while it permits these
+     * resources be used by different threads it does not allow concurrent access.
+     * This is enforced by converging all operation (from FTFontStrike and
+     * FTGlyph) to this object and synchronizing the access to the native
+     * resources using the same lock.
+     */
+    private long library;
+    private long face;
+    private FTDisposer disposer;
+
+    FTFontFile(String name, String filename, int fIndex, boolean register,
+               boolean embedded, boolean copy, boolean tracked) throws Exception {
+        super(name, filename, fIndex, register, embedded, copy, tracked);
+        init();
+    }
+
+    private synchronized void init() throws Exception {
+        long[] ptr = new long[1];
+        int error = OSFreetype.FT_Init_FreeType(ptr);
+        if (error != 0) {
+            throw new Exception("FT_Init_FreeType Failed error " + error);
+        }
+        library = ptr[0];
+        if (FTFactory.LCD_SUPPORT) {
+            OSFreetype.FT_Library_SetLcdFilter(library, OSFreetype.FT_LCD_FILTER_DEFAULT);
+        }
+
+        String file = getFileName();
+        int fontIndex = getFontIndex();
+        /* Freetype expects 'a standard C string' */
+        byte[] buffer = (file+"\0").getBytes();
+        error = OSFreetype.FT_New_Face(library, buffer, fontIndex, ptr);
+        if (error != 0) {
+            throw new Exception("FT_New_Face Failed error " + error +
+                                " Font File " + file +
+                                " Font Index " + fontIndex);
+        }
+        face = ptr[0];
+
+        if (!isRegistered()) {
+            disposer = new FTDisposer(library, face);
+            Disposer.addRecord(this, disposer);
+        }
+    }
+
+    @Override
+    protected PrismFontStrike<?> createStrike(float size, BaseTransform transform,
+                                              int aaMode, FontStrikeDesc desc) {
+        return new FTFontStrike(this, size, transform, aaMode, desc);
+    }
+
+    @Override
+    protected synchronized int[] createGlyphBoundingBox(int gc) {
+        int flags = OSFreetype.FT_LOAD_NO_SCALE;
+        OSFreetype.FT_Load_Glyph(face, gc, flags);
+        int[] bbox = new int[4];
+        FT_GlyphSlotRec glyphRec = OSFreetype.getGlyphSlot(face);
+        if (glyphRec != null && glyphRec.metrics != null) {
+            FT_Glyph_Metrics gm = glyphRec.metrics;
+            bbox[0] = (int)gm.horiBearingX;
+            bbox[1] = (int)(gm.horiBearingY - gm.height);
+            bbox[2] = (int)(gm.horiBearingX + gm.width);
+            bbox[3] = (int)gm.horiBearingY;
+        }
+        return bbox;
+    }
+
+    synchronized Path2D createGlyphOutline(int gc, float size) {
+        int size26dot6 = (int)(size * 64);
+        OSFreetype.FT_Set_Char_Size(face, 0, size26dot6, 72, 72);
+        int flags = OSFreetype.FT_LOAD_NO_HINTING | OSFreetype.FT_LOAD_NO_BITMAP | OSFreetype.FT_LOAD_IGNORE_TRANSFORM;
+        OSFreetype.FT_Load_Glyph(face, gc, flags);
+        return OSFreetype.FT_Outline_Decompose(face);
+    }
+
+    synchronized void initGlyph(FTGlyph glyph, FTFontStrike strike) {
+        float size = strike.getSize();
+        if (size == 0) {
+            glyph.buffer = new byte[0];
+            glyph.bitmap = new FT_Bitmap();
+            return;
+        }
+        int size26dot6 = (int)(size * 64);
+        OSFreetype.FT_Set_Char_Size(face, 0, size26dot6, 72, 72);
+
+        boolean lcd = strike.getAAMode() == FontResource.AA_LCD &&
+                      FTFactory.LCD_SUPPORT;
+
+        int flags = OSFreetype.FT_LOAD_RENDER | OSFreetype.FT_LOAD_NO_HINTING;
+        FT_Matrix matrix = strike.matrix;
+        if (matrix != null) {
+            OSFreetype.FT_Set_Transform(face, matrix, 0, 0);
+        } else {
+            flags |= OSFreetype.FT_LOAD_IGNORE_TRANSFORM;
+        }
+        if (lcd) {
+            flags |= OSFreetype.FT_LOAD_TARGET_LCD;
+        } else {
+            flags |= OSFreetype.FT_LOAD_TARGET_NORMAL;
+        }
+
+        int glyphCode = glyph.getGlyphCode();
+        int error = OSFreetype.FT_Load_Glyph(face, glyphCode, flags);
+        if (error != 0) {
+            if (PrismFontFactory.debugFonts) {
+                System.err.println("FT_Load_Glyph failed " + error +
+                                   " glyph code " + glyphCode +
+                                   " load falgs " + flags);
+            }
+            return;
+        }
+
+        FT_GlyphSlotRec glyphRec = OSFreetype.getGlyphSlot(face);
+        if (glyphRec == null) return;
+        FT_Bitmap bitmap = glyphRec.bitmap;
+        if (bitmap == null) return;
+        int width = bitmap.width;
+        int height = bitmap.rows;
+        int pitch = bitmap.pitch;
+        byte[] buffer;
+        if (width != 0 && height != 0) {
+            buffer = OSFreetype.getBitmapData(face);
+            if (buffer != null && pitch != width) {
+                /* Common for LCD glyphs */
+                byte[] newBuffer = new byte[width * height];
+                int src = 0, dst = 0;
+                for (int y = 0; y < height; y++) {
+                    for (int x = 0; x < width; x++) {
+                        newBuffer[dst + x] = buffer[src + x];
+                    }
+                    dst += width;
+                    src += pitch;
+                }
+                buffer = newBuffer;
+            }
+        } else {
+            /* white space */
+            buffer = new byte[0];
+        }
+
+        glyph.buffer = buffer;
+        glyph.bitmap = bitmap;
+        glyph.bitmap_left = glyphRec.bitmap_left;
+        glyph.bitmap_top = glyphRec.bitmap_top;
+        glyph.advanceX = glyphRec.advance_x / 64f;    /* Fixed 26.6*/
+        glyph.advanceY = glyphRec.advance_y / 64f;
+        glyph.userAdvance = glyphRec.linearHoriAdvance / 65536.0f; /* Fixed 16.16 */
+        glyph.lcd = lcd;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/freetype/FTFontStrike.java	Fri Oct 25 12:04:34 2013 +0200
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.javafx.font.freetype;
+
+import com.sun.javafx.font.DisposerRecord;
+import com.sun.javafx.font.FontStrikeDesc;
+import com.sun.javafx.font.Glyph;
+import com.sun.javafx.font.PrismFontStrike;
+import com.sun.javafx.geom.Path2D;
+import com.sun.javafx.geom.transform.BaseTransform;
+
+class FTFontStrike extends PrismFontStrike<FTFontFile> {
+    FT_Matrix matrix;
+
+    protected FTFontStrike(FTFontFile fontResource, float size,
+                              BaseTransform tx, int aaMode,
+                              FontStrikeDesc desc) {
+        super(fontResource, size, tx, aaMode, desc);
+        float maxDim = 80f;
+        if (tx.isTranslateOrIdentity()) {
+            drawShapes = size > maxDim;
+        } else {
+            BaseTransform tx2d = getTransform();
+            matrix = new FT_Matrix();
+            /* Fixed 16.16 to int */
+            matrix.xx = (int)( tx2d.getMxx() * 65536.0f);
+            matrix.yx = (int)(-tx2d.getMyx() * 65536.0f); /*Inverted coordinates system */
+            matrix.xy = (int)(-tx2d.getMxy() * 65536.0f); /*Inverted coordinates system */
+            matrix.yy = (int)( tx2d.getMyy() * 65536.0f);
+
+            if (Math.abs(tx2d.getMxx() * size) > maxDim ||
+                Math.abs(tx2d.getMyx() * size) > maxDim ||
+                Math.abs(tx2d.getMxy() * size) > maxDim ||
+                Math.abs(tx2d.getMyy() * size) > maxDim)
+            {
+                drawShapes = true;
+            }
+        }
+    }
+
+    @Override
+    protected DisposerRecord createDisposer(FontStrikeDesc desc) {
+        return null;
+    }
+
+    @Override
+    protected Glyph createGlyph(int glyphCode) {
+        return new FTGlyph(this, glyphCode, drawShapes);
+    }
+
+    @Override
+    protected Path2D createGlyphOutline(int glyphCode) {
+        FTFontFile fontResource = getFontResource();
+        return fontResource.createGlyphOutline(glyphCode, getSize());
+    }
+
+    void initGlyph(FTGlyph glyph) {
+        FTFontFile fontResource = getFontResource();
+        fontResource.initGlyph(glyph, this);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/freetype/FTGlyph.java	Fri Oct 25 12:04:34 2013 +0200
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.javafx.font.freetype;
+
+import com.sun.javafx.font.Glyph;
+import com.sun.javafx.geom.RectBounds;
+import com.sun.javafx.geom.Shape;
+
+class FTGlyph implements Glyph {
+    FTFontStrike strike;
+    int glyphCode;
+    byte[] buffer;
+    FT_Bitmap bitmap;
+    int bitmap_left;
+    int bitmap_top;
+    float advanceX;
+    float advanceY;
+    float userAdvance;
+    boolean lcd;
+
+    FTGlyph(FTFontStrike strike, int glyphCode, boolean drawAsShape) {
+        this.strike = strike;
+        this.glyphCode = glyphCode;
+    }
+
+    @Override
+    public int getGlyphCode() {
+        return glyphCode;
+    }
+
+    private void init() {
+        if (bitmap != null) return;
+        strike.initGlyph(this);
+    }
+
+    @Override
+    public RectBounds getBBox() {
+        float[] bb = new float[4];
+        FTFontFile fontResource = strike.getFontResource();
+        fontResource.getGlyphBoundingBox(glyphCode, strike.getSize(), bb);
+        return new RectBounds(bb[0], bb[1], bb[2], bb[3]);
+    }
+
+    @Override
+    public float getAdvance() {
+        init();
+        return userAdvance;
+    }
+
+    @Override
+    public Shape getShape() {
+        return strike.createGlyphOutline(glyphCode);
+    }
+
+    @Override
+    public byte[] getPixelData() {
+        init();
+        return buffer;
+    }
+
+    @Override
+    public byte[] getPixelData(int subPixel) {
+        init();
+        return buffer;
+    }
+
+    @Override
+    public float getPixelXAdvance() {
+        init();
+        return advanceX;
+    }
+
+    @Override
+    public float getPixelYAdvance() {
+        init();
+        return advanceY;
+    }
+
+    @Override
+    public int getWidth() {
+        init();
+        /* Note: In Freetype the width is byte based */
+        return bitmap != null ? bitmap.width : 0;
+    }
+
+    @Override
+    public int getHeight() {
+        init();
+        return bitmap != null ? bitmap.rows : 0;
+    }
+
+    @Override
+    public int getOriginX() {
+        init();
+        return bitmap_left;
+    }
+
+    @Override
+    public int getOriginY() {
+        init();
+        return -bitmap_top; /* Inverted coordinates system */
+    }
+
+    @Override
+    public boolean isLCDGlyph() {
+        return lcd;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/freetype/FT_Bitmap.java	Fri Oct 25 12:04:34 2013 +0200
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.javafx.font.freetype;
+
+class FT_Bitmap {
+    int rows;
+    int width;
+    int pitch;
+    long buffer;
+    short num_grays;
+    byte pixel_mode;
+    char palette_mode;
+    long palette;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/freetype/FT_GlyphSlotRec.java	Fri Oct 25 12:04:34 2013 +0200
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.javafx.font.freetype;
+
+class FT_GlyphSlotRec {
+    FT_Glyph_Metrics metrics = new FT_Glyph_Metrics();
+    long linearHoriAdvance;
+    long linearVertAdvance;
+    long advance_x;
+    long advance_y;
+    int format;
+    FT_Bitmap bitmap = new FT_Bitmap();
+    int bitmap_left;
+    int bitmap_top;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/freetype/FT_Glyph_Metrics.java	Fri Oct 25 12:04:34 2013 +0200
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.javafx.font.freetype;
+
+class FT_Glyph_Metrics {
+    long width;
+    long height;
+    long horiBearingX;
+    long horiBearingY;
+    long horiAdvance;
+    long vertBearingX;
+    long vertBearingY;
+    long vertAdvance;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/freetype/FT_Matrix.java	Fri Oct 25 12:04:34 2013 +0200
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.javafx.font.freetype;
+
+class FT_Matrix {
+    long xx;
+    long xy;
+    long yx;
+    long yy;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/freetype/HBGlyphLayout.java	Fri Oct 25 12:04:34 2013 +0200
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.javafx.font.freetype;
+
+import com.sun.javafx.font.FontStrike;
+import com.sun.javafx.font.PGFont;
+import com.sun.javafx.text.GlyphLayout;
+import com.sun.javafx.text.TextRun;
+
+public class HBGlyphLayout extends GlyphLayout {
+
+    @Override
+    public void layout(TextRun run, PGFont font, FontStrike strike, char[] text) {
+        System.out.println("Only simple text supported.");
+    }
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/freetype/OSFreetype.java	Fri Oct 25 12:04:34 2013 +0200
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.javafx.font.freetype;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import com.sun.glass.utils.NativeLibLoader;
+import com.sun.javafx.geom.Path2D;
+
+class OSFreetype {
+
+    static {
+        AccessController.doPrivileged(new PrivilegedAction<Void>() {
+           public Void run() {
+               NativeLibLoader.loadLibrary("javafx_font_freetype");
+               return null;
+           }
+        });
+    }
+
+    /* Freetype */
+    static final int FT_FACE_FLAG_SCALABLE          = 1 <<  0;
+    static final int FT_FACE_FLAG_FIXED_SIZES       = 1 <<  1;
+    static final int FT_FACE_FLAG_FIXED_WIDTH       = 1 <<  2;
+    static final int FT_FACE_FLAG_SFNT              = 1 <<  3;
+    static final int FT_FACE_FLAG_HORIZONTAL        = 1 <<  4;
+    static final int FT_FACE_FLAG_VERTICAL          = 1 <<  5;
+    static final int FT_FACE_FLAG_KERNING           = 1 <<  6;
+    static final int FT_FACE_FLAG_FAST_GLYPHS       = 1 <<  7;
+    static final int FT_FACE_FLAG_MULTIPLE_MASTERS  = 1 <<  8;
+    static final int FT_FACE_FLAG_GLYPH_NAMES       = 1 <<  9;
+    static final int FT_FACE_FLAG_EXTERNAL_STREAM   = 1 << 10;
+    static final int FT_FACE_FLAG_HINTER            = 1 << 11;
+    static final int FT_FACE_FLAG_CID_KEYED         = 1 << 12;
+    static final int FT_FACE_FLAG_TRICKY            = 1 << 13;
+    static final int FT_STYLE_FLAG_ITALIC  = 1 << 0;
+    static final int FT_STYLE_FLAG_BOLD    = 1 << 1;
+    static final int FT_RENDER_MODE_NORMAL = 0;
+    static final int FT_RENDER_MODE_LIGHT = 1;
+    static final int FT_RENDER_MODE_MONO = 2;
+    static final int FT_RENDER_MODE_LCD = 3;
+    static final int FT_RENDER_MODE_LCD_V = 4;
+    static final int FT_PIXEL_MODE_NONE = 0;
+    static final int FT_PIXEL_MODE_MONO = 1;
+    static final int FT_PIXEL_MODE_GRAY = 2;
+    static final int FT_PIXEL_MODE_GRAY2 = 3;
+    static final int FT_PIXEL_MODE_GRAY4 = 4;
+    static final int FT_PIXEL_MODE_LCD = 5;
+    static final int FT_PIXEL_MODE_LCD_V = 6;
+    static final int FT_LOAD_DEFAULT                      = 0x0;
+    static final int FT_LOAD_NO_SCALE                     = 1 << 0;
+    static final int FT_LOAD_NO_HINTING                   = 1 << 1;
+    static final int FT_LOAD_RENDER                       = 1 << 2;
+    static final int FT_LOAD_NO_BITMAP                    = 1 << 3;
+    static final int FT_LOAD_VERTICAL_LAYOUT              = 1 << 4;
+    static final int FT_LOAD_FORCE_AUTOHINT               = 1 << 5;
+    static final int FT_LOAD_CROP_BITMAP                  = 1 << 6;
+    static final int FT_LOAD_PEDANTIC                     = 1 << 7;
+    static final int FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH  = 1 << 9;
+    static final int FT_LOAD_NO_RECURSE                   = 1 << 10;
+    static final int FT_LOAD_IGNORE_TRANSFORM             = 1 << 11;
+    static final int FT_LOAD_MONOCHROME                   = 1 << 12;
+    static final int FT_LOAD_LINEAR_DESIGN                = 1 << 13;
+    static final int FT_LOAD_NO_AUTOHINT                  = 1 << 15;
+    static final int FT_LOAD_TARGET_NORMAL  = (FT_RENDER_MODE_NORMAL & 15 ) << 16;
+    static final int FT_LOAD_TARGET_LIGHT   = (FT_RENDER_MODE_LIGHT  & 15 ) << 16;
+    static final int FT_LOAD_TARGET_MONO    = (FT_RENDER_MODE_MONO   & 15 ) << 16;
+    static final int FT_LOAD_TARGET_LCD     = (FT_RENDER_MODE_LCD    & 15 ) << 16;
+    static final int FT_LOAD_TARGET_LCD_V   = (FT_RENDER_MODE_LCD_V  & 15 ) << 16;
+    static final int FT_LCD_FILTER_NONE    = 0;
+    static final int FT_LCD_FILTER_DEFAULT = 1;
+    static final int FT_LCD_FILTER_LIGHT   = 2;
+    static final int FT_LCD_FILTER_LEGACY  = 16;
+
+    static final int FT_LOAD_TARGET_MODE(int x) {
+        return (x >> 16 ) & 15;
+    }
+
+    static final native Path2D FT_Outline_Decompose(long face);
+    static final native int FT_Init_FreeType(long[] alibrary);
+    static final native int FT_Done_FreeType(long library);
+    static final native void FT_Library_Version(long library, int[] amajor, int[] aminor, int[] apatch);
+    static final native int FT_Library_SetLcdFilter(long library, int filter);
+    static final native int FT_New_Face(long library, byte[] filepathname, long face_index, long[] aface);
+    static final native int FT_Done_Face(long face);
+    static final native int FT_Get_Char_Index(long face, long charcode);
+    static final native int FT_Set_Char_Size(long face, long char_width, long char_height, int horz_resolution, int vert_resolution);
+    static final native int FT_Load_Glyph(long face, int glyph_index, int load_flags);
+    static final native void FT_Set_Transform(long face, FT_Matrix matrix, long delta_x, long delta_y);
+    static final native FT_GlyphSlotRec getGlyphSlot(long face);
+    static final native byte[] getBitmapData(long face);
+    static final native boolean isPangoEnabled();
+    static final native boolean isHarfbuzzEnabled();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/freetype/OSPango.java	Fri Oct 25 12:04:34 2013 +0200
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.javafx.font.freetype;
+
+import java.nio.ByteBuffer;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import com.sun.glass.utils.NativeLibLoader;
+
+class OSPango {
+
+    static {
+        AccessController.doPrivileged(new PrivilegedAction<Void>() {
+           public Void run() {
+               NativeLibLoader.loadLibrary("javafx_font_pango");
+               return null;
+           }
+        });
+    }
+
+    /* Pango */
+    static final int PANGO_SCALE = 1024;
+    static final int PANGO_STRETCH_ULTRA_CONDENSED = 0x0;
+    static final int PANGO_STRETCH_EXTRA_CONDENSED = 0x1;
+    static final int PANGO_STRETCH_CONDENSED = 0x2;
+    static final int PANGO_STRETCH_SEMI_CONDENSED = 0x3;
+    static final int PANGO_STRETCH_NORMAL = 0x4;
+    static final int PANGO_STRETCH_SEMI_EXPANDED = 0x5;
+    static final int PANGO_STRETCH_EXPANDED = 0x6;
+    static final int PANGO_STRETCH_EXTRA_EXPANDED = 0x7;
+    static final int PANGO_STRETCH_ULTRA_EXPANDED = 0x8;
+    static final int PANGO_STYLE_ITALIC = 0x2;
+    static final int PANGO_STYLE_NORMAL = 0x0;
+    static final int PANGO_STYLE_OBLIQUE = 0x1;
+    static final int PANGO_WEIGHT_BOLD = 0x2bc;
+    static final int PANGO_WEIGHT_NORMAL = 0x190;
+
+    static final native long pango_ft2_font_map_new();
+    static final native long pango_font_map_create_context(long fontmap);
+    static final native long pango_font_describe(long font);
+    static final native long pango_font_description_new();
+    static final native void pango_font_description_free(long desc);
+    static final native String pango_font_description_get_family(long desc);
+    static final native int pango_font_description_get_stretch(long desc);
+    static final native int pango_font_description_get_style(long desc);
+    static final native int pango_font_description_get_weight(long desc);
+    static final native void pango_font_description_set_family(long desc, String family);
+    static final native void pango_font_description_set_absolute_size(long desc, double size);
+    static final native void pango_font_description_set_stretch(long desc, int stretch);
+    static final native void pango_font_description_set_style(long desc, int style);
+    static final native void pango_font_description_set_weight(long desc, int weight);
+    static final native long pango_attr_list_new();
+    static final native long pango_attr_font_desc_new(long desc);
+    static final native long pango_attr_fallback_new(boolean enable_fallback);
+    static final native void pango_attr_list_unref(long list);
+    static final native void pango_attr_list_insert(long list, long attr);
+    static final native long pango_itemize(long context, ByteBuffer text, int start_index, int length, long attrs, long cached_iter);
+    static final native PangoGlyphString pango_shape(ByteBuffer text, long pangoItem);
+    static final native void pango_item_free(long item);
+
+    /* Miscellaneous (glib, fontconfig) */
+    static final native int g_list_length(long list);
+    static final native long g_list_nth_data(long list, int n);
+    static final native void g_list_free(long list);
+    static final native void g_object_unref(long object);
+    static final native boolean FcConfigAppFontAddFile(long config, String file);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/freetype/PangoGlyphInfo.java	Fri Oct 25 12:04:34 2013 +0200
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.javafx.font.freetype;
+
+class PangoGlyphInfo {
+    int glyph;
+    /* Inline PangoGlyphGeometry */
+    int width;
+    int x_offset;
+    int y_offset;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/freetype/PangoGlyphLayout.java	Fri Oct 25 12:04:34 2013 +0200
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.javafx.font.freetype;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CoderResult;
+import java.nio.charset.StandardCharsets;
+import com.sun.javafx.font.CompositeFontResource;
+import com.sun.javafx.font.FontResource;
+import com.sun.javafx.font.FontStrike;
+import com.sun.javafx.font.PGFont;
+import com.sun.javafx.font.PrismFontFactory;
+import com.sun.javafx.scene.text.TextSpan;
+import com.sun.javafx.text.GlyphLayout;
+import com.sun.javafx.text.PrismTextLayout;
+import com.sun.javafx.text.TextRun;
+
+class PangoGlyphLayout extends GlyphLayout {
+
+    private int getSlot(PGFont font, PangoGlyphString glyphString) {
+        CompositeFontResource fr = (CompositeFontResource)font.getFontResource();
+        long fallbackFont = glyphString.font;
+        long fallbackFd = OSPango.pango_font_describe(fallbackFont);
+        String fallbackFamily = OSPango.pango_font_description_get_family(fallbackFd);
+        int fallbackStyle = OSPango.pango_font_description_get_style(fallbackFd);
+        int fallbackWeight = OSPango.pango_font_description_get_weight(fallbackFd);
+        OSPango.pango_font_description_free(fallbackFd);
+        boolean bold = fallbackWeight == OSPango.PANGO_WEIGHT_BOLD;
+        boolean italic = fallbackStyle != OSPango.PANGO_STYLE_NORMAL;
+
+        PrismFontFactory prismFactory = PrismFontFactory.getFontFactory();
+        PGFont fallbackPGFont = prismFactory.createFont(fallbackFamily, bold,
+                                                        italic, font.getSize());
+        String fallbackFullname =  fallbackPGFont.getFullName();
+        String primaryFullname = fr.getSlotResource(0).getFullName();
+
+        int slot = 0;
+        if (!fallbackFullname.equalsIgnoreCase(primaryFullname)) {
+            slot = fr.getSlotForFont(fallbackFullname);
+            if (PrismFontFactory.debugFonts) {
+                System.err.println("\tFallback font= "+ fallbackFullname + " slot=" + (slot>>24));
+            }
+        }
+        return slot;
+    }
+
+    protected TextRun addTextRun(PrismTextLayout layout, char[] chars, int start,
+                                 int length, PGFont font, TextSpan span, byte level) {
+
+        TextRun textRun = null;
+        Charset utf8 = StandardCharsets.UTF_8;
+        CharsetEncoder encoder = utf8.newEncoder();
+        CharBuffer in = CharBuffer.wrap(chars, start, length);
+        int capacity = (int)(length * (double)encoder.averageBytesPerChar());
+        ByteBuffer out = ByteBuffer.allocateDirect(capacity);
+        CoderResult result = encoder.encode(in, out, true);
+        if (result.isOverflow()) {
+            capacity = (int)(length * (double)encoder.maxBytesPerChar());
+            in.rewind();
+            out = ByteBuffer.allocateDirect(capacity);
+            encoder.encode(in, out, true);
+            if (PrismFontFactory.debugFonts) {
+                System.err.println("[PANGO] ByteBuffer capacity increased " + out);
+            }
+        }
+
+        FontResource fr = font.getFontResource();
+        boolean composite = fr instanceof CompositeFontResource;
+        if (composite) {
+            fr = ((CompositeFontResource)fr).getSlotResource(0);
+        }
+
+        long fontmap = OSPango.pango_ft2_font_map_new();
+        long context = OSPango.pango_font_map_create_context(fontmap);
+        float size = font.getSize();
+        int style = fr.isItalic() ? OSPango.PANGO_STYLE_ITALIC : OSPango.PANGO_STYLE_NORMAL;
+        int weight = fr.isBold() ? OSPango.PANGO_WEIGHT_BOLD : OSPango.PANGO_WEIGHT_NORMAL;
+        long desc = OSPango.pango_font_description_new();
+        OSPango.pango_font_description_set_family(desc, fr.getFamilyName());
+        OSPango.pango_font_description_set_absolute_size(desc, size * OSPango.PANGO_SCALE);
+        OSPango.pango_font_description_set_stretch(desc, OSPango.PANGO_STRETCH_NORMAL);
+        OSPango.pango_font_description_set_style(desc, style);
+        OSPango.pango_font_description_set_weight(desc, weight);
+        long attrList = OSPango.pango_attr_list_new();
+        long attr = OSPango.pango_attr_font_desc_new(desc);
+        OSPango.pango_attr_list_insert(attrList, attr);
+        if (!composite) {
+            attr = OSPango.pango_attr_fallback_new(false);
+            OSPango.pango_attr_list_insert(attrList, attr);
+        }
+        long runs = OSPango.pango_itemize(context, out, 0, out.position(), attrList, 0);
+        if (runs != 0) {
+            int runsCount = OSPango.g_list_length(runs);
+            int runStart = start;
+            for (int i = 0; i < runsCount; i++) {
+                long pangoItem = OSPango.g_list_nth_data(runs, i);
+                PangoGlyphString glyphString = OSPango.pango_shape(out, pangoItem);
+                OSPango.pango_item_free(pangoItem);
+                if (glyphString != null) {
+                    int slot = composite ? getSlot(font, glyphString) : 0;
+                    int glyphCount = glyphString.num_glyphs;
+                    int[] glyphs = new int[glyphCount];
+                    float[] pos = new float[glyphCount*2+2];
+                    PangoGlyphInfo info = null;
+                    int k = 2;
+                    int width = 0;
+                    for (int j = 0; j < glyphCount; j++) {
+                        info = glyphString.glyphs[j];
+                        if (slot != -1) {
+                            glyphs[j] = (slot << 24) | info.glyph;
+                        }
+                        if (size != 0) width += info.width;
+                        pos[k] = ((float)width) / OSPango.PANGO_SCALE;
+                        k += 2;
+                    }
+
+                    int runLength = glyphString.num_chars;
+                    textRun = new TextRun(runStart, runLength, level, true, 0, span, 0, false);
+                    textRun.shape(glyphCount, glyphs, pos, glyphString.log_clusters);
+                    layout.addTextRun(textRun);
+                    runStart += runLength;
+                }
+            }
+            OSPango.g_list_free(runs);
+        }
+        /* pango_attr_list_unref() also frees the attributes it contains */
+        OSPango.pango_attr_list_unref(attrList);
+        OSPango.pango_font_description_free(desc);
+        OSPango.g_object_unref(context);
+        OSPango.g_object_unref(fontmap);
+        return textRun;
+    }
+
+    public void layout(TextRun run, PGFont font, FontStrike strike, char[] text) {
+        // Nothing - complex run are analyzed by Pango during break run
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/freetype/PangoGlyphString.java	Fri Oct 25 12:04:34 2013 +0200
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.javafx.font.freetype;
+
+class PangoGlyphString {
+    /* Fields from PangoItem */
+    int offset;
+    int length;
+    int num_chars;
+    /* pangoItem->analysis->font*/
+    long font;
+    int num_glyphs;
+    PangoGlyphInfo[] glyphs;
+    int[] log_clusters;
+}
--- a/modules/graphics/src/main/java/com/sun/javafx/font/pango/FTDisposer.java	Fri Oct 25 13:46:44 2013 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.javafx.font.pango;
-
-import com.sun.javafx.font.DisposerRecord;
-import com.sun.javafx.font.PrismFontFactory;
-
-class FTDisposer implements DisposerRecord  {
-    long library;
-    long face;
-
-    FTDisposer(long library, long face) {
-        this.library = library;
-        this.face = face;
-    }
-
-    public synchronized void dispose() {
-        if (face != 0) {
-            OS.FT_Done_Face(face);
-            if (PrismFontFactory.debugFonts) {
-                System.err.println("Done Face=" + face);
-            }
-            face = 0;
-        }
-        if (library != 0) {
-            OS.FT_Done_FreeType(library);
-            if (PrismFontFactory.debugFonts) {
-                System.err.println("Done Library=" + library);
-            }
-            library = 0;
-        }
-    }
-}
\ No newline at end of file
--- a/modules/graphics/src/main/java/com/sun/javafx/font/pango/FTFontFile.java	Fri Oct 25 13:46:44 2013 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,194 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.javafx.font.pango;
-
-import com.sun.javafx.font.Disposer;
-import com.sun.javafx.font.FontResource;
-import com.sun.javafx.font.FontStrikeDesc;
-import com.sun.javafx.font.PrismFontFactory;
-import com.sun.javafx.font.PrismFontFile;
-import com.sun.javafx.font.PrismFontStrike;
-import com.sun.javafx.geom.Path2D;
-import com.sun.javafx.geom.transform.BaseTransform;
-
-class FTFontFile extends PrismFontFile {
-    /*
-     * Font files can be accessed by several threads. In general this are the
-     * JFX thread (measuring) and the Prism thread (rendering). But, if a Text
-     * node is no connected a Scene it can be used in any user thread, thus a
-     * font resource can be accessed from any thread.
-     *
-     * Freetype resources are not thread safe. In this implementation each font
-     * resources has its own FT_Face and FT_Library, and while it permits these
-     * resources be used by different threads it does not allow concurrent access.
-     * This is enforced by converging all operation (from FTFontStrike and
-     * FTGlyph) to this object and synchronizing the access to the native
-     * resources using the same lock.
-     */
-    private long library;
-    private long face;
-    private FTDisposer disposer;
-
-    FTFontFile(String name, String filename, int fIndex, boolean register,
-               boolean embedded, boolean copy, boolean tracked) throws Exception {
-        super(name, filename, fIndex, register, embedded, copy, tracked);
-        init();
-    }
-
-    private synchronized void init() throws Exception {
-        long[] ptr = new long[1];
-        int error = OS.FT_Init_FreeType(ptr);
-        if (error != 0) {
-            throw new Exception("FT_Init_FreeType Failed error " + error);
-        }
-        library = ptr[0];
-        if (PangoFactory.LCD_SUPPORT) {
-            OS.FT_Library_SetLcdFilter(library, OS.FT_LCD_FILTER_DEFAULT);
-        }
-
-        String file = getFileName();
-        int fontIndex = getFontIndex();
-        /* Freetype expects 'a standard C string' */
-        byte[] buffer = (file+"\0").getBytes();
-        error = OS.FT_New_Face(library, buffer, fontIndex, ptr);
-        if (error != 0) {
-            throw new Exception("FT_New_Face Failed error " + error +
-                                " Font File " + file +
-                                " Font Index " + fontIndex);
-        }
-        face = ptr[0];
-
-        if (!isRegistered()) {
-            disposer = new FTDisposer(library, face);
-            Disposer.addRecord(this, disposer);
-        }
-    }
-
-    @Override
-    protected PrismFontStrike<?> createStrike(float size, BaseTransform transform,
-                                              int aaMode, FontStrikeDesc desc) {
-        return new FTFontStrike(this, size, transform, aaMode, desc);
-    }
-
-    @Override
-    protected synchronized int[] createGlyphBoundingBox(int gc) {
-        int flags = OS.FT_LOAD_NO_SCALE;
-        OS.FT_Load_Glyph(face, gc, flags);
-        int[] bbox = new int[4];
-        FT_GlyphSlotRec glyphRec = OS.getGlyphSlot(face);
-        if (glyphRec != null && glyphRec.metrics != null) {
-            FT_Glyph_Metrics gm = glyphRec.metrics;
-            bbox[0] = (int)gm.horiBearingX;
-            bbox[1] = (int)(gm.horiBearingY - gm.height);
-            bbox[2] = (int)(gm.horiBearingX + gm.width);
-            bbox[3] = (int)gm.horiBearingY;
-        }
-        return bbox;
-    }
-
-    synchronized Path2D createGlyphOutline(int gc, float size) {
-        int size26dot6 = (int)(size * 64);
-        OS.FT_Set_Char_Size(face, 0, size26dot6, 72, 72);
-        int flags = OS.FT_LOAD_NO_HINTING | OS.FT_LOAD_NO_BITMAP | OS.FT_LOAD_IGNORE_TRANSFORM;
-        OS.FT_Load_Glyph(face, gc, flags);
-        return OS.FT_Outline_Decompose(face);
-    }
-
-    synchronized void initGlyph(FTGlyph glyph, FTFontStrike strike) {
-        float size = strike.getSize();
-        if (size == 0) {
-            glyph.buffer = new byte[0];
-            glyph.bitmap = new FT_Bitmap();
-            return;
-        }
-        int size26dot6 = (int)(size * 64);
-        OS.FT_Set_Char_Size(face, 0, size26dot6, 72, 72);
-
-        boolean lcd = strike.getAAMode() == FontResource.AA_LCD &&
-                      PangoFactory.LCD_SUPPORT;
-
-        int flags = OS.FT_LOAD_RENDER | OS.FT_LOAD_NO_HINTING;
-        FT_Matrix matrix = strike.matrix;
-        if (matrix != null) {
-            OS.FT_Set_Transform(face, matrix, 0, 0);
-        } else {
-            flags |= OS.FT_LOAD_IGNORE_TRANSFORM;
-        }
-        if (lcd) {
-            flags |= OS.FT_LOAD_TARGET_LCD;
-        } else {
-            flags |= OS.FT_LOAD_TARGET_NORMAL;
-        }
-
-        int glyphCode = glyph.getGlyphCode();
-        int error = OS.FT_Load_Glyph(face, glyphCode, flags);
-        if (error != 0) {
-            if (PrismFontFactory.debugFonts) {
-                System.err.println("FT_Load_Glyph failed " + error +
-                                   " glyph code " + glyphCode +
-                                   " load falgs " + flags);
-            }
-            return;
-        }
-
-        FT_GlyphSlotRec glyphRec = OS.getGlyphSlot(face);
-        if (glyphRec == null) return;
-        FT_Bitmap bitmap = glyphRec.bitmap;
-        if (bitmap == null) return;
-        int width = bitmap.width;
-        int height = bitmap.rows;
-        int pitch = bitmap.pitch;
-        byte[] buffer;
-        if (width != 0 && height != 0) {
-            buffer = OS.getBitmapData(face);
-            if (buffer != null && pitch != width) {
-                /* Common for LCD glyphs */
-                byte[] newBuffer = new byte[width * height];
-                int src = 0, dst = 0;
-                for (int y = 0; y < height; y++) {
-                    for (int x = 0; x < width; x++) {
-                        newBuffer[dst + x] = buffer[src + x];
-                    }
-                    dst += width;
-                    src += pitch;
-                }
-                buffer = newBuffer;
-            }
-        } else {
-            /* white space */
-            buffer = new byte[0];
-        }
-
-        glyph.buffer = buffer;
-        glyph.bitmap = bitmap;
-        glyph.bitmap_left = glyphRec.bitmap_left;
-        glyph.bitmap_top = glyphRec.bitmap_top;
-        glyph.advanceX = glyphRec.advance_x / 64f;    /* Fixed 26.6*/
-        glyph.advanceY = glyphRec.advance_y / 64f;
-        glyph.userAdvance = glyphRec.linearHoriAdvance / 65536.0f; /* Fixed 16.16 */
-        glyph.lcd = lcd;
-    }
-}
--- a/modules/graphics/src/main/java/com/sun/javafx/font/pango/FTFontStrike.java	Fri Oct 25 13:46:44 2013 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.javafx.font.pango;
-
-import com.sun.javafx.font.DisposerRecord;
-import com.sun.javafx.font.FontStrikeDesc;
-import com.sun.javafx.font.Glyph;
-import com.sun.javafx.font.PrismFontStrike;
-import com.sun.javafx.geom.Path2D;
-import com.sun.javafx.geom.transform.BaseTransform;
-
-class FTFontStrike extends PrismFontStrike<FTFontFile> {
-    FT_Matrix matrix;
-
-    protected FTFontStrike(FTFontFile fontResource, float size,
-                              BaseTransform tx, int aaMode,
-                              FontStrikeDesc desc) {
-        super(fontResource, size, tx, aaMode, desc);
-        float maxDim = 80f;
-        if (tx.isTranslateOrIdentity()) {
-            drawShapes = size > maxDim;
-        } else {
-            BaseTransform tx2d = getTransform();
-            matrix = new FT_Matrix();
-            /* Fixed 16.16 to int */
-            matrix.xx = (int)( tx2d.getMxx() * 65536.0f);
-            matrix.yx = (int)(-tx2d.getMyx() * 65536.0f); /*Inverted coordinates system */
-            matrix.xy = (int)(-tx2d.getMxy() * 65536.0f); /*Inverted coordinates system */
-            matrix.yy = (int)( tx2d.getMyy() * 65536.0f);
-
-            if (Math.abs(tx2d.getMxx() * size) > maxDim ||
-                Math.abs(tx2d.getMyx() * size) > maxDim ||
-                Math.abs(tx2d.getMxy() * size) > maxDim ||
-                Math.abs(tx2d.getMyy() * size) > maxDim)
-            {
-                drawShapes = true;
-            }
-        }
-    }
-
-    @Override
-    protected DisposerRecord createDisposer(FontStrikeDesc desc) {
-        return null;
-    }
-
-    @Override
-    protected Glyph createGlyph(int glyphCode) {
-        return new FTGlyph(this, glyphCode, drawShapes);
-    }
-
-    @Override
-    protected Path2D createGlyphOutline(int glyphCode) {
-        FTFontFile fontResource = getFontResource();
-        return fontResource.createGlyphOutline(glyphCode, getSize());
-    }
-
-    void initGlyph(FTGlyph glyph) {
-        FTFontFile fontResource = getFontResource();
-        fontResource.initGlyph(glyph, this);
-    }
-
-}
--- a/modules/graphics/src/main/java/com/sun/javafx/font/pango/FTGlyph.java	Fri Oct 25 13:46:44 2013 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.javafx.font.pango;
-
-import com.sun.javafx.font.Glyph;
-import com.sun.javafx.geom.RectBounds;
-import com.sun.javafx.geom.Shape;
-
-class FTGlyph implements Glyph {
-    FTFontStrike strike;
-    int glyphCode;
-    byte[] buffer;
-    FT_Bitmap bitmap;
-    int bitmap_left;
-    int bitmap_top;
-    float advanceX;
-    float advanceY;
-    float userAdvance;
-    boolean lcd;
-
-    FTGlyph(FTFontStrike strike, int glyphCode, boolean drawAsShape) {
-        this.strike = strike;
-        this.glyphCode = glyphCode;
-    }
-
-    @Override
-    public int getGlyphCode() {
-        return glyphCode;
-    }
-
-    private void init() {
-        if (bitmap != null) return;
-        strike.initGlyph(this);
-    }
-
-    @Override
-    public RectBounds getBBox() {
-        float[] bb = new float[4];
-        FTFontFile fontResource = strike.getFontResource();
-        fontResource.getGlyphBoundingBox(glyphCode, strike.getSize(), bb);
-        return new RectBounds(bb[0], bb[1], bb[2], bb[3]);
-    }
-
-    @Override
-    public float getAdvance() {
-        init();
-        return userAdvance;
-    }
-
-    @Override
-    public Shape getShape() {
-        return strike.createGlyphOutline(glyphCode);
-    }
-
-    @Override
-    public byte[] getPixelData() {
-        init();
-        return buffer;
-    }
-
-    @Override
-    public byte[] getPixelData(int subPixel) {
-        init();
-        return buffer;
-    }
-
-    @Override
-    public float getPixelXAdvance() {
-        init();
-        return advanceX;
-    }
-
-    @Override
-    public float getPixelYAdvance() {
-        init();
-        return advanceY;
-    }
-
-    @Override
-    public int getWidth() {
-        init();
-        /* Note: In Freetype the width is byte based */
-        return bitmap != null ? bitmap.width : 0;
-    }
-
-    @Override
-    public int getHeight() {
-        init();
-        return bitmap != null ? bitmap.rows : 0;
-    }
-
-    @Override
-    public int getOriginX() {
-        init();
-        return bitmap_left;
-    }
-
-    @Override
-    public int getOriginY() {
-        init();
-        return -bitmap_top; /* Inverted coordinates system */
-    }
-
-    @Override
-    public boolean isLCDGlyph() {
-        return lcd;
-    }
-
-}
--- a/modules/graphics/src/main/java/com/sun/javafx/font/pango/FT_Bitmap.java	Fri Oct 25 13:46:44 2013 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.javafx.font.pango;
-
-class FT_Bitmap {
-    int rows;
-    int width;
-    int pitch;
-    long buffer;
-    short num_grays;
-    byte pixel_mode;
-    char palette_mode;
-    long palette;
-}
--- a/modules/graphics/src/main/java/com/sun/javafx/font/pango/FT_GlyphSlotRec.java	Fri Oct 25 13:46:44 2013 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.javafx.font.pango;
-
-class FT_GlyphSlotRec {
-    FT_Glyph_Metrics metrics = new FT_Glyph_Metrics();
-    long linearHoriAdvance;
-    long linearVertAdvance;
-    long advance_x;
-    long advance_y;
-    int format;
-    FT_Bitmap bitmap = new FT_Bitmap();
-    int bitmap_left;
-    int bitmap_top;
-}
--- a/modules/graphics/src/main/java/com/sun/javafx/font/pango/FT_Glyph_Metrics.java	Fri Oct 25 13:46:44 2013 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.javafx.font.pango;
-
-class FT_Glyph_Metrics {
-    long width;
-    long height;
-    long horiBearingX;
-    long horiBearingY;
-    long horiAdvance;
-    long vertBearingX;
-    long vertBearingY;
-    long vertAdvance;
-}
--- a/modules/graphics/src/main/java/com/sun/javafx/font/pango/FT_Matrix.java	Fri Oct 25 13:46:44 2013 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.javafx.font.pango;
-
-class FT_Matrix {
-    long xx;
-    long xy;
-    long yx;
-    long yy;
-}
--- a/modules/graphics/src/main/java/com/sun/javafx/font/pango/OS.java	Fri Oct 25 13:46:44 2013 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,163 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.javafx.font.pango;
-
-import java.nio.ByteBuffer;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import com.sun.glass.utils.NativeLibLoader;
-import com.sun.javafx.geom.Path2D;
-
-class OS {
-
-    static {
-        AccessController.doPrivileged(new PrivilegedAction<Void>() {
-           public Void run() {
-               NativeLibLoader.loadLibrary("javafx_font_pango");
-               return null;
-           }
-        });
-    }
-
-    /* Pango */
-    static final int PANGO_SCALE = 1024;
-    static final int PANGO_STRETCH_ULTRA_CONDENSED = 0x0;
-    static final int PANGO_STRETCH_EXTRA_CONDENSED = 0x1;
-    static final int PANGO_STRETCH_CONDENSED = 0x2;
-    static final int PANGO_STRETCH_SEMI_CONDENSED = 0x3;
-    static final int PANGO_STRETCH_NORMAL = 0x4;
-    static final int PANGO_STRETCH_SEMI_EXPANDED = 0x5;
-    static final int PANGO_STRETCH_EXPANDED = 0x6;
-    static final int PANGO_STRETCH_EXTRA_EXPANDED = 0x7;
-    static final int PANGO_STRETCH_ULTRA_EXPANDED = 0x8;
-    static final int PANGO_STYLE_ITALIC = 0x2;
-    static final int PANGO_STYLE_NORMAL = 0x0;
-    static final int PANGO_STYLE_OBLIQUE = 0x1;
-    static final int PANGO_WEIGHT_BOLD = 0x2bc;
-    static final int PANGO_WEIGHT_NORMAL = 0x190;
-
-    static final native long pango_ft2_font_map_new();
-    static final native long pango_font_map_create_context(long fontmap);
-    static final native long pango_font_describe(long font);
-    static final native long pango_font_description_new();
-    static final native void pango_font_description_free(long desc);
-    static final native String pango_font_description_get_family(long desc);
-    static final native int pango_font_description_get_stretch(long desc);
-    static final native int pango_font_description_get_style(long desc);
-    static final native int pango_font_description_get_weight(long desc);
-    static final native void pango_font_description_set_family(long desc, String family);
-    static final native void pango_font_description_set_absolute_size(long desc, double size);
-    static final native void pango_font_description_set_stretch(long desc, int stretch);
-    static final native void pango_font_description_set_style(long desc, int style);
-    static final native void pango_font_description_set_weight(long desc, int weight);
-    static final native long pango_attr_list_new();
-    static final native long pango_attr_font_desc_new(long desc);
-    static final native long pango_attr_fallback_new(boolean enable_fallback);
-    static final native void pango_attr_list_unref(long list);
-    static final native void pango_attr_list_insert(long list, long attr);
-    static final native long pango_itemize(long context, ByteBuffer text, int start_index, int length, long attrs, long cached_iter);
-    static final native PangoGlyphString pango_shape(ByteBuffer text, long pangoItem);
-    static final native void pango_item_free(long item);
-
-    /* Miscellaneous (glib, fontconfig) */
-    static final native int g_list_length(long list);
-    static final native long g_list_nth_data(long list, int n);
-    static final native void g_list_free(long list);
-    static final native void g_object_unref(long object);
-    static final native boolean FcConfigAppFontAddFile(long config, String file);
-
-    /* Freetype */
-    static final int FT_FACE_FLAG_SCALABLE          = 1 <<  0;
-    static final int FT_FACE_FLAG_FIXED_SIZES       = 1 <<  1;
-    static final int FT_FACE_FLAG_FIXED_WIDTH       = 1 <<  2;
-    static final int FT_FACE_FLAG_SFNT              = 1 <<  3;
-    static final int FT_FACE_FLAG_HORIZONTAL        = 1 <<  4;
-    static final int FT_FACE_FLAG_VERTICAL          = 1 <<  5;
-    static final int FT_FACE_FLAG_KERNING           = 1 <<  6;
-    static final int FT_FACE_FLAG_FAST_GLYPHS       = 1 <<  7;
-    static final int FT_FACE_FLAG_MULTIPLE_MASTERS  = 1 <<  8;
-    static final int FT_FACE_FLAG_GLYPH_NAMES       = 1 <<  9;
-    static final int FT_FACE_FLAG_EXTERNAL_STREAM   = 1 << 10;
-    static final int FT_FACE_FLAG_HINTER            = 1 << 11;
-    static final int FT_FACE_FLAG_CID_KEYED         = 1 << 12;
-    static final int FT_FACE_FLAG_TRICKY            = 1 << 13;
-    static final int FT_STYLE_FLAG_ITALIC  = 1 << 0;
-    static final int FT_STYLE_FLAG_BOLD    = 1 << 1;
-    static final int FT_RENDER_MODE_NORMAL = 0;
-    static final int FT_RENDER_MODE_LIGHT = 1;
-    static final int FT_RENDER_MODE_MONO = 2;
-    static final int FT_RENDER_MODE_LCD = 3;
-    static final int FT_RENDER_MODE_LCD_V = 4;
-    static final int FT_PIXEL_MODE_NONE = 0;
-    static final int FT_PIXEL_MODE_MONO = 1;
-    static final int FT_PIXEL_MODE_GRAY = 2;
-    static final int FT_PIXEL_MODE_GRAY2 = 3;
-    static final int FT_PIXEL_MODE_GRAY4 = 4;
-    static final int FT_PIXEL_MODE_LCD = 5;
-    static final int FT_PIXEL_MODE_LCD_V = 6;
-    static final int FT_LOAD_DEFAULT                      = 0x0;
-    static final int FT_LOAD_NO_SCALE                     = 1 << 0;
-    static final int FT_LOAD_NO_HINTING                   = 1 << 1;
-    static final int FT_LOAD_RENDER                       = 1 << 2;
-    static final int FT_LOAD_NO_BITMAP                    = 1 << 3;
-    static final int FT_LOAD_VERTICAL_LAYOUT              = 1 << 4;
-    static final int FT_LOAD_FORCE_AUTOHINT               = 1 << 5;
-    static final int FT_LOAD_CROP_BITMAP                  = 1 << 6;
-    static final int FT_LOAD_PEDANTIC                     = 1 << 7;
-    static final int FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH  = 1 << 9;
-    static final int FT_LOAD_NO_RECURSE                   = 1 << 10;
-    static final int FT_LOAD_IGNORE_TRANSFORM             = 1 << 11;
-    static final int FT_LOAD_MONOCHROME                   = 1 << 12;
-    static final int FT_LOAD_LINEAR_DESIGN                = 1 << 13;
-    static final int FT_LOAD_NO_AUTOHINT                  = 1 << 15;
-    static final int FT_LOAD_TARGET_NORMAL  = (FT_RENDER_MODE_NORMAL & 15 ) << 16;
-    static final int FT_LOAD_TARGET_LIGHT   = (FT_RENDER_MODE_LIGHT  & 15 ) << 16;
-    static final int FT_LOAD_TARGET_MONO    = (FT_RENDER_MODE_MONO   & 15 ) << 16;
-    static final int FT_LOAD_TARGET_LCD     = (FT_RENDER_MODE_LCD    & 15 ) << 16;
-    static final int FT_LOAD_TARGET_LCD_V   = (FT_RENDER_MODE_LCD_V  & 15 ) << 16;
-    static final int FT_LCD_FILTER_NONE    = 0;
-    static final int FT_LCD_FILTER_DEFAULT = 1;
-    static final int FT_LCD_FILTER_LIGHT   = 2;
-    static final int FT_LCD_FILTER_LEGACY  = 16;
-
-    static final int FT_LOAD_TARGET_MODE(int x) {
-        return (x >> 16 ) & 15;
-    }
-
-    static final native Path2D FT_Outline_Decompose(long face);
-    static final native int FT_Init_FreeType(long[] alibrary);
-    static final native int FT_Done_FreeType(long library);
-    static final native void FT_Library_Version(long library, int[] amajor, int[] aminor, int[] apatch);
-    static final native int FT_Library_SetLcdFilter(long library, int filter);
-    static final native int FT_New_Face(long library, byte[] filepathname, long face_index, long[] aface);
-    static final native int FT_Done_Face(long face);
-    static final native int FT_Get_Char_Index(long face, long charcode);
-    static final native int FT_Set_Char_Size(long face, long char_width, long char_height, int horz_resolution, int vert_resolution);
-    static final native int FT_Load_Glyph(long face, int glyph_index, int load_flags);
-    static final native void FT_Set_Transform(long face, FT_Matrix matrix, long delta_x, long delta_y);
-    static final native FT_GlyphSlotRec getGlyphSlot(long face);
-    static final native byte[] getBitmapData(long face);
-}
--- a/modules/graphics/src/main/java/com/sun/javafx/font/pango/PangoFactory.java	Fri Oct 25 13:46:44 2013 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.javafx.font.pango;
-
-import com.sun.javafx.font.PrismFontFactory;
-import com.sun.javafx.font.PrismFontFile;
-import com.sun.javafx.text.GlyphLayout;
-
-public class PangoFactory extends PrismFontFactory {
-
-    static boolean LCD_SUPPORT;
-
-    public static PrismFontFactory getFactory() {
-        PrismFontFactory factory = null;
-        long[] ptr = new long[1];
-        int error = OS.FT_Init_FreeType(ptr);
-        long library = ptr[0];
-        int[] major = new int[1], minor = new int[1], patch = new int[1];
-        if (error == 0) {
-            factory = new PangoFactory();
-            OS.FT_Library_Version(library, major, minor, patch);
-
-            /* This implementation only supports LDC if freetype has support. */
-            error = OS.FT_Library_SetLcdFilter(library, OS.FT_LCD_FILTER_DEFAULT);
-            LCD_SUPPORT = error == 0;
-            OS.FT_Done_FreeType(library);
-        }
-        if (PrismFontFactory.debugFonts) {
-            if (factory != null) {
-                String version = major[0] + "." + minor[0] + "." + patch[0];
-                System.err.println("Freetype2 Loaded (version " + version + ")");
-                String lcdSupport = LCD_SUPPORT ? "Enabled" : "Disabled";
-                System.err.println("LCD support " + lcdSupport);
-            } else {
-                System.err.println("Freetype2 Failed (error " + error + ")");
-            }
-        }
-        return factory;
-    }
-
-    private PangoFactory() {
-    }
-
-    @Override
-    protected PrismFontFile createFontFile(String name, String filename,
-            int fIndex, boolean register, boolean embedded, boolean copy,
-            boolean tracked) throws Exception {
-        return new FTFontFile(name, filename, fIndex, register,
-                                 embedded, copy, tracked);
-    }
-
-    @Override
-    public GlyphLayout createGlyphLayout() {
-        /* Implementing a HarfbuzzGlyphLayout is needed to support
-         * font features and non-hinted glyph advances.  */
-        return new PangoGlyphLayout();
-    }
-
-    @Override
-    public boolean isLCDTextSupported() {
-        return LCD_SUPPORT && super.isLCDTextSupported();
-    }
-
-    @Override
-    protected boolean registerEmbeddedFont(String path) {
-        boolean result = false;
-
-        /* Test if freetype supports the file */
-        long[] ptr = new long[1];
-        int error = OS.FT_Init_FreeType(ptr);
-        if (error == 0) {
-            long library = ptr[0];
-            byte[] buffer = (path+"\0").getBytes();
-            error = OS.FT_New_Face(library, buffer, 0, ptr);
-            if (error == 0) {
-                result = true;
-                OS.FT_Done_Face(ptr[0]);
-            }
-            OS.FT_Done_FreeType(library);
-        }
-        /* Test if fontconfig supports the file  */
-        if (result) {
-            /* Adding the file to fontconfig so it can be used by pango */
-            result = OS.FcConfigAppFontAddFile(0, path);
-        }
-        if (debugFonts) {
-            if (result) {
-                System.err.println("[PANGO] Font registration succeeded:" + path);
-            } else {
-                System.err.println("[PANGO] Font registration failed:" + path);
-            }
-        }
-        return result;
-    }
-}
--- a/modules/graphics/src/main/java/com/sun/javafx/font/pango/PangoGlyphInfo.java	Fri Oct 25 13:46:44 2013 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.javafx.font.pango;
-
-class PangoGlyphInfo {
-    int glyph;
-    /* Inline PangoGlyphGeometry */
-    int width;
-    int x_offset;
-    int y_offset;
-}
--- a/modules/graphics/src/main/java/com/sun/javafx/font/pango/PangoGlyphLayout.java	Fri Oct 25 13:46:44 2013 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,163 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.javafx.font.pango;
-
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetEncoder;
-import java.nio.charset.CoderResult;
-import java.nio.charset.StandardCharsets;
-import com.sun.javafx.font.CompositeFontResource;
-import com.sun.javafx.font.FontResource;
-import com.sun.javafx.font.FontStrike;
-import com.sun.javafx.font.PGFont;
-import com.sun.javafx.font.PrismFontFactory;
-import com.sun.javafx.scene.text.TextSpan;
-import com.sun.javafx.text.GlyphLayout;
-import com.sun.javafx.text.PrismTextLayout;
-import com.sun.javafx.text.TextRun;
-
-class PangoGlyphLayout extends GlyphLayout {
-
-    private int getSlot(PGFont font, PangoGlyphString glyphString) {
-        CompositeFontResource fr = (CompositeFontResource)font.getFontResource();
-        long fallbackFont = glyphString.font;
-        long fallbackFd = OS.pango_font_describe(fallbackFont);
-        String fallbackFamily = OS.pango_font_description_get_family(fallbackFd);
-        int fallbackStyle = OS.pango_font_description_get_style(fallbackFd);
-        int fallbackWeight = OS.pango_font_description_get_weight(fallbackFd);
-        OS.pango_font_description_free(fallbackFd);
-        boolean bold = fallbackWeight == OS.PANGO_WEIGHT_BOLD;
-        boolean italic = fallbackStyle != OS.PANGO_STYLE_NORMAL;
-
-        PrismFontFactory prismFactory = PrismFontFactory.getFontFactory();
-        PGFont fallbackPGFont = prismFactory.createFont(fallbackFamily, bold,
-                                                        italic, font.getSize());
-        String fallbackFullname =  fallbackPGFont.getFullName();
-        String primaryFullname = fr.getSlotResource(0).getFullName();
-
-        int slot = 0;
-        if (!fallbackFullname.equalsIgnoreCase(primaryFullname)) {
-            slot = fr.getSlotForFont(fallbackFullname);
-            if (PrismFontFactory.debugFonts) {
-                System.err.println("\tFallback font= "+ fallbackFullname + " slot=" + (slot>>24));
-            }
-        }
-        return slot;
-    }
-
-    protected TextRun addTextRun(PrismTextLayout layout, char[] chars, int start,
-                                 int length, PGFont font, TextSpan span, byte level) {
-
-        TextRun textRun = null;
-        Charset utf8 = StandardCharsets.UTF_8;
-        CharsetEncoder encoder = utf8.newEncoder();
-        CharBuffer in = CharBuffer.wrap(chars, start, length);
-        int capacity = (int)(length * (double)encoder.averageBytesPerChar());
-        ByteBuffer out = ByteBuffer.allocateDirect(capacity);
-        CoderResult result = encoder.encode(in, out, true);
-        if (result.isOverflow()) {
-            capacity = (int)(length * (double)encoder.maxBytesPerChar());
-            in.rewind();
-            out = ByteBuffer.allocateDirect(capacity);
-            encoder.encode(in, out, true);
-            if (PrismFontFactory.debugFonts) {
-                System.err.println("[PANGO] ByteBuffer capacity increased " + out);
-            }
-        }
-
-        FontResource fr = font.getFontResource();
-        boolean composite = fr instanceof CompositeFontResource;
-        if (composite) {
-            fr = ((CompositeFontResource)fr).getSlotResource(0);
-        }
-
-        long fontmap = OS.pango_ft2_font_map_new();
-        long context = OS.pango_font_map_create_context(fontmap);
-        float size = font.getSize();
-        int style = fr.isItalic() ? OS.PANGO_STYLE_ITALIC : OS.PANGO_STYLE_NORMAL;
-        int weight = fr.isBold() ? OS.PANGO_WEIGHT_BOLD : OS.PANGO_WEIGHT_NORMAL;
-        long desc = OS.pango_font_description_new();
-        OS.pango_font_description_set_family(desc, fr.getFamilyName());
-        OS.pango_font_description_set_absolute_size(desc, size * OS.PANGO_SCALE);
-        OS.pango_font_description_set_stretch(desc, OS.PANGO_STRETCH_NORMAL);
-        OS.pango_font_description_set_style(desc, style);
-        OS.pango_font_description_set_weight(desc, weight);
-        long attrList = OS.pango_attr_list_new();
-        long attr = OS.pango_attr_font_desc_new(desc);
-        OS.pango_attr_list_insert(attrList, attr);
-        if (!composite) {
-            attr = OS.pango_attr_fallback_new(false);
-            OS.pango_attr_list_insert(attrList, attr);
-        }
-        long runs = OS.pango_itemize(context, out, 0, out.position(), attrList, 0);
-        if (runs != 0) {
-            int runsCount = OS.g_list_length(runs);
-            int runStart = start;
-            for (int i = 0; i < runsCount; i++) {
-                long pangoItem = OS.g_list_nth_data(runs, i);
-                PangoGlyphString glyphString = OS.pango_shape(out, pangoItem);
-                OS.pango_item_free(pangoItem);
-                if (glyphString != null) {
-                    int slot = composite ? getSlot(font, glyphString) : 0;
-                    int glyphCount = glyphString.num_glyphs;
-                    int[] glyphs = new int[glyphCount];
-                    float[] pos = new float[glyphCount*2+2];
-                    PangoGlyphInfo info = null;
-                    int k = 2;
-                    int width = 0;
-                    for (int j = 0; j < glyphCount; j++) {
-                        info = glyphString.glyphs[j];
-                        if (slot != -1) {
-                            glyphs[j] = (slot << 24) | info.glyph;
-                        }
-                        if (size != 0) width += info.width;
-                        pos[k] = ((float)width) / OS.PANGO_SCALE;
-                        k += 2;
-                    }
-
-                    int runLength = glyphString.num_chars;
-                    textRun = new TextRun(runStart, runLength, level, true, 0, span, 0, false);
-                    textRun.shape(glyphCount, glyphs, pos, glyphString.log_clusters);
-                    layout.addTextRun(textRun);
-                    runStart += runLength;
-                }
-            }
-            OS.g_list_free(runs);
-        }
-        /* pango_attr_list_unref() also frees the attributes it contains */
-        OS.pango_attr_list_unref(attrList);
-        OS.pango_font_description_free(desc);
-        OS.g_object_unref(context);
-        OS.g_object_unref(fontmap);
-        return textRun;
-    }
-
-    public void layout(TextRun run, PGFont font, FontStrike strike, char[] text) {
-        // Nothing - complex run are analyzed by Pango during break run
-    }
-}
--- a/modules/graphics/src/main/java/com/sun/javafx/font/pango/PangoGlyphString.java	Fri Oct 25 13:46:44 2013 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.javafx.font.pango;
-
-class PangoGlyphString {
-    /* Fields from PangoItem */
-    int offset;
-    int length;
-    int num_chars;
-    /* pangoItem->analysis->font*/
-    long font;
-    int num_glyphs;
-    PangoGlyphInfo[] glyphs;
-    int[] log_clusters;
-}
--- a/modules/graphics/src/main/native-font/freetype.c	Fri Oct 25 13:46:44 2013 +0400
+++ b/modules/graphics/src/main/native-font/freetype.c	Fri Oct 25 12:04:34 2013 +0200
@@ -23,18 +23,18 @@
  * questions.
  */
 
-#if defined __linux__
-#if defined _ENABLE_PANGO
+#if defined __linux__ || ANDROID_NDK
+#if defined _ENABLE_PANGO || _ENABLE_HARFBUZZ
 
 #include <jni.h>
-#include <com_sun_javafx_font_pango_OS.h>
+#include <com_sun_javafx_font_freetype_OSFreetype.h>
 #include <dlfcn.h>
 #include <ft2build.h>
 #include FT_FREETYPE_H
 #include FT_OUTLINE_H
 #include FT_LCD_FILTER_H
 
-#define OS_NATIVE(func) Java_com_sun_javafx_font_pango_OS_##func
+#define OS_NATIVE(func) Java_com_sun_javafx_font_freetype_OSFreetype_##func
 
 /**************************************************************************/
 /*                                                                        */
@@ -152,15 +152,15 @@
 void cacheFT_GlyphSlotRecFields(JNIEnv *env)
 {
     if (FT_GlyphSlotRecFc.cached) return;
-    jclass tmpClass = (*env)->FindClass(env, "com/sun/javafx/font/pango/FT_GlyphSlotRec");
+    jclass tmpClass = (*env)->FindClass(env, "com/sun/javafx/font/freetype/FT_GlyphSlotRec");
     FT_GlyphSlotRecFc.clazz =  (jclass)(*env)->NewGlobalRef(env, tmpClass);
-    FT_GlyphSlotRecFc.metrics = (*env)->GetFieldID(env, FT_GlyphSlotRecFc.clazz, "metrics", "Lcom/sun/javafx/font/pango/FT_Glyph_Metrics;");
+    FT_GlyphSlotRecFc.metrics = (*env)->GetFieldID(env, FT_GlyphSlotRecFc.clazz, "metrics", "Lcom/sun/javafx/font/freetype/FT_Glyph_Metrics;");
     FT_GlyphSlotRecFc.linearHoriAdvance = (*env)->GetFieldID(env, FT_GlyphSlotRecFc.clazz, "linearHoriAdvance", "J");
     FT_GlyphSlotRecFc.linearVertAdvance = (*env)->GetFieldID(env, FT_GlyphSlotRecFc.clazz, "linearVertAdvance", "J");
     FT_GlyphSlotRecFc.advance_x = (*env)->GetFieldID(env, FT_GlyphSlotRecFc.clazz, "advance_x", "J");
     FT_GlyphSlotRecFc.advance_y = (*env)->GetFieldID(env, FT_GlyphSlotRecFc.clazz, "advance_y", "J");
     FT_GlyphSlotRecFc.format = (*env)->GetFieldID(env, FT_GlyphSlotRecFc.clazz, "format", "I");
-    FT_GlyphSlotRecFc.bitmap = (*env)->GetFieldID(env, FT_GlyphSlotRecFc.clazz, "bitmap", "Lcom/sun/javafx/font/pango/FT_Bitmap;");
+    FT_GlyphSlotRecFc.bitmap = (*env)->GetFieldID(env, FT_GlyphSlotRecFc.clazz, "bitmap", "Lcom/sun/javafx/font/freetype/FT_Bitmap;");
     FT_GlyphSlotRecFc.bitmap_left = (*env)->GetFieldID(env, FT_GlyphSlotRecFc.clazz, "bitmap_left", "I");
     FT_GlyphSlotRecFc.bitmap_top = (*env)->GetFieldID(env, FT_GlyphSlotRecFc.clazz, "bitmap_top", "I");
     FT_GlyphSlotRecFc.init = (*env)->GetMethodID(env, FT_GlyphSlotRecFc.clazz, "<init>", "()V");
@@ -470,5 +470,23 @@
     return path2D;
 }
 
-#endif /* ENABLE_PANGO */
-#endif /* __linux__ */
+JNIEXPORT jboolean JNICALL JNICALL OS_NATIVE(isPangoEnabled)
+    (JNIEnv *env, jclass that) {
+    #ifdef _ENABLE_PANGO
+    return JNI_TRUE;
+    #else
+    return JNI_FALSE;
+    #endif
+}
+
+JNIEXPORT jboolean JNICALL JNICALL OS_NATIVE(isHarfbuzzEnabled)
+  (JNIEnv *env, jclass that) {
+    #ifdef _ENABLE_HARFBUZZ
+    return JNI_TRUE;
+    #else
+    return JNI_FALSE;
+    #endif
+}
+
+#endif /* ENABLE_PANGO || ENABLE_HARFBUZZ */
+#endif /* __linux__ || ANDROID_NDK */
--- a/modules/graphics/src/main/native-font/pango.c	Fri Oct 25 13:46:44 2013 +0400
+++ b/modules/graphics/src/main/native-font/pango.c	Fri Oct 25 12:04:34 2013 +0200
@@ -27,12 +27,12 @@
 #if defined _ENABLE_PANGO
 
 #include <jni.h>
-#include <com_sun_javafx_font_pango_OS.h>
+#include <com_sun_javafx_font_freetype_OSPango.h>
 #include <pango/pango.h>
 #include <pango/pangoft2.h>
 #include <dlfcn.h>
 
-#define OS_NATIVE(func) Java_com_sun_javafx_font_pango_OS_##func
+#define OS_NATIVE(func) Java_com_sun_javafx_font_freetype_OSPango_##func
 
 /**************************************************************************/
 /*                                                                        */