FTFactory.java: Fonts loaded by Pango are never registered and always return <null>

Maurice info at cuhka.com
Thu Mar 3 13:48:27 UTC 2016

At the moment the embedded environment I'm using is not able to use 
downloaded or external supplied fonts. I've traced through the system 
and found that it looks like it fails in pango.c FcConfigAppFontAddFile, 
at least OSPango.FcConfigAppFontAddFile returns false, thus propagating 
a null all the way up.

Checking the pango.c file I noticed something very interesting:
JNIEXPORT jboolean JNICALL OS_NATIVE(FcConfigAppFontAddFile)
     (JNIEnv *env, jclass that, jlong arg0, jstring arg1)
     static void *fp = NULL;
     if (!fp) {
         void* handle = dlopen(LIB_FONTCONFIG, RTLD_LAZY);
         if (handle) fp = dlsym(handle, "FcConfigAppFontAddFile");
     jboolean rc = 0;
     if (arg1) {
         const char *text = (*env)->GetStringUTFChars(env, arg1, NULL);
         if (text) {
//            rc = (jboolean)FcConfigAppFontAddFile(arg0, text);
             if (fp) {
                 rc = (jboolean)((jboolean (*)(jlong, const char 
*))fp)(arg0, text);
             (*env)->ReleaseStringUTFChars(env, arg1, text);
     return rc;

Yes, you see it correctly! The line that actually should register the 
font with pango is commented out! I removed the comment, but still the 
result is false. I then overruled the return code in FTFactory.java 
registerEmbeddedFont to be always true after it has called the native 
function, and voilà, there are my external fonts.

What a journey.... :-)


More information about the openjfx-dev mailing list