src/solaris/native/sun/awt/fontpath.c

Print this page
rev 7983 : 8024854: Basic changes and files to build the class library on AIX
Contributed-by: luchsh@linux.vnet.ibm.com, spoole@linux.vnet.ibm.com, thomas.stuefe@sap.com
Reviewed-by:
   1 /*
   2  * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  61 
  62 #ifdef MACOSX
  63 
  64 //
  65 // XXXDARWIN: Hard-code the path to Apple's fontconfig, as it is
  66 // not included in the dyld search path by default, and 10.4
  67 // does not support -rpath.
  68 //
  69 // This ignores the build time setting of ALT_FREETYPE_LIB_PATH,
  70 // and should be replaced with -rpath/@rpath support on 10.5 or later,
  71 // or via support for a the FREETYPE_LIB_PATH define.
  72 #define FONTCONFIG_DLL_VERSIONED X11_PATH "/lib/" VERSIONED_JNI_LIB_NAME("fontconfig", "1")
  73 #define FONTCONFIG_DLL X11_PATH "/lib/" JNI_LIB_NAME("fontconfig")
  74 #else
  75 #define FONTCONFIG_DLL_VERSIONED VERSIONED_JNI_LIB_NAME("fontconfig", "1")
  76 #define FONTCONFIG_DLL JNI_LIB_NAME("fontconfig")
  77 #endif
  78 
  79 #define MAXFDIRS 512    /* Max number of directories that contain fonts */
  80 
  81 #if !defined(__linux__) && !defined(MACOSX)
  82 /*
  83  * This can be set in the makefile to "/usr/X11" if so desired.
  84  */
  85 #ifndef OPENWINHOMELIB
  86 #define OPENWINHOMELIB "/usr/openwin/lib/"
  87 #endif
  88 
  89 /* This is all known Solaris X11 directories on Solaris 8, 9 and 10.
  90  * It is ordered to give precedence to TrueType directories.
  91  * It is needed if fontconfig is not installed or configured properly.
  92  */
  93 static char *fullSolarisFontPath[] = {
  94     OPENWINHOMELIB "X11/fonts/TrueType",
  95     OPENWINHOMELIB "locale/euro_fonts/X11/fonts/TrueType",
  96     OPENWINHOMELIB "locale/iso_8859_2/X11/fonts/TrueType",
  97     OPENWINHOMELIB "locale/iso_8859_5/X11/fonts/TrueType",
  98     OPENWINHOMELIB "locale/iso_8859_7/X11/fonts/TrueType",
  99     OPENWINHOMELIB "locale/iso_8859_8/X11/fonts/TrueType",
 100     OPENWINHOMELIB "locale/iso_8859_9/X11/fonts/TrueType",
 101     OPENWINHOMELIB "locale/iso_8859_13/X11/fonts/TrueType",


 111     OPENWINHOMELIB "locale/zh_TW/X11/fonts/TrueType",
 112     OPENWINHOMELIB "locale/zh_TW.BIG5/X11/fonts/TT",
 113     OPENWINHOMELIB "locale/zh_HK.BIG5HK/X11/fonts/TT",
 114     OPENWINHOMELIB "locale/zh_CN.GB18030/X11/fonts/TrueType",
 115     OPENWINHOMELIB "locale/zh/X11/fonts/TrueType",
 116     OPENWINHOMELIB "locale/zh.GBK/X11/fonts/TrueType",
 117     OPENWINHOMELIB "X11/fonts/Type1",
 118     OPENWINHOMELIB "X11/fonts/Type1/sun",
 119     OPENWINHOMELIB "X11/fonts/Type1/sun/outline",
 120     OPENWINHOMELIB "locale/iso_8859_2/X11/fonts/Type1",
 121     OPENWINHOMELIB "locale/iso_8859_4/X11/fonts/Type1",
 122     OPENWINHOMELIB "locale/iso_8859_5/X11/fonts/Type1",
 123     OPENWINHOMELIB "locale/iso_8859_7/X11/fonts/Type1",
 124     OPENWINHOMELIB "locale/iso_8859_8/X11/fonts/Type1",
 125     OPENWINHOMELIB "locale/iso_8859_9/X11/fonts/Type1",
 126     OPENWINHOMELIB "locale/iso_8859_13/X11/fonts/Type1",
 127     OPENWINHOMELIB "locale/ar/X11/fonts/Type1",
 128     NULL, /* terminates the list */
 129 };
 130 
 131 #elif MACOSX
 132 static char *full_MACOSX_X11FontPath[] = {
 133     X11_PATH "/lib/X11/fonts/TrueType",
 134     X11_PATH "/lib/X11/fonts/truetype",
 135     X11_PATH "/lib/X11/fonts/tt",
 136     X11_PATH "/lib/X11/fonts/TTF",
 137     X11_PATH "/lib/X11/fonts/OTF",
 138     PACKAGE_PATH "/share/fonts/TrueType",
 139     PACKAGE_PATH "/share/fonts/truetype",
 140     PACKAGE_PATH "/share/fonts/tt",
 141     PACKAGE_PATH "/share/fonts/TTF",
 142     PACKAGE_PATH "/share/fonts/OTF",
 143     X11_PATH "/lib/X11/fonts/Type1",
 144     PACKAGE_PATH "/share/fonts/Type1",
 145     NULL, /* terminates the list */
 146 };
 147 #else /* __linux */
 148 /* All the known interesting locations we have discovered on
 149  * various flavors of Linux
 150  */
 151 static char *fullLinuxFontPath[] = {
 152     "/usr/X11R6/lib/X11/fonts/TrueType",  /* RH 7.1+ */
 153     "/usr/X11R6/lib/X11/fonts/truetype",  /* SuSE */
 154     "/usr/X11R6/lib/X11/fonts/tt",
 155     "/usr/X11R6/lib/X11/fonts/TTF",
 156     "/usr/X11R6/lib/X11/fonts/OTF",       /* RH 9.0 (but empty!) */
 157     "/usr/share/fonts/ja/TrueType",       /* RH 7.2+ */
 158     "/usr/share/fonts/truetype",
 159     "/usr/share/fonts/ko/TrueType",       /* RH 9.0 */
 160     "/usr/share/fonts/zh_CN/TrueType",    /* RH 9.0 */
 161     "/usr/share/fonts/zh_TW/TrueType",    /* RH 9.0 */
 162     "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType", /* Debian */
 163     "/usr/X11R6/lib/X11/fonts/Type1",
 164     "/usr/share/fonts/default/Type1",     /* RH 9.0 */
 165     NULL, /* terminates the list */
 166 };








 167 #endif
 168 
 169 static char **getFontConfigLocations();
 170 
 171 typedef struct {
 172     const char *name[MAXFDIRS];
 173     int  num;
 174 } fDirRecord, *fDirRecordPtr;
 175 
 176 #ifndef HEADLESS
 177 
 178 /*
 179  * Returns True if display is local, False of it's remote.
 180  */
 181 jboolean isDisplayLocal(JNIEnv *env) {
 182     static jboolean isLocal = False;
 183     static jboolean isLocalSet = False;
 184     jboolean ret;
 185 
 186     if (! isLocalSet) {


 512  * NB: Fontconfig also depends heavily for performance on the host O/S
 513  * maintaining up to date caches.
 514  * This is consistent with the requirements of the desktop environments
 515  * on these OSes.
 516  * This also frees us from X11 APIs as JRE is required to function in
 517  * a "headless" mode where there is no Xserver.
 518  */
 519 static char *getPlatformFontPathChars(JNIEnv *env, jboolean noType1) {
 520 
 521     char **fcdirs = NULL, **x11dirs = NULL, **knowndirs = NULL, *path = NULL;
 522 
 523     /* As of 1.5 we try to use fontconfig on both Solaris and Linux.
 524      * If its not available NULL is returned.
 525      */
 526     fcdirs = getFontConfigLocations();
 527 
 528 #if defined(__linux__)
 529     knowndirs = fullLinuxFontPath;
 530 #elif defined(MACOSX)
 531     knowndirs = full_MACOSX_X11FontPath;
 532 #else /* IF SOLARIS */
 533     knowndirs = fullSolarisFontPath;


 534 #endif
 535 
 536     /* REMIND: this code requires to be executed when the GraphicsEnvironment
 537      * is already initialised. That is always true, but if it were not so,
 538      * this code could throw an exception and the fontpath would fail to
 539      * be initialised.
 540      */
 541 #ifndef HEADLESS
 542 #if defined(__linux__) || defined(MACOSX)
 543     /* There's no headless build on linux ... */
 544     if (!AWTIsHeadless()) { /* .. so need to call a function to check */
 545 #endif
 546       /* Using the X11 font path to locate font files is now a fallback
 547        * useful only if fontconfig failed, or is incomplete. So we could
 548        * remove this code completely and the consequences should be rare
 549        * and non-fatal. If this happens, then the calling Java code can
 550        * be modified to no longer require that the AWT lock (the X11GE)
 551        * be initialised prior to calling this code.
 552        */
 553     AWT_LOCK();


 607      */
 608     char *useFC = getenv("USE_J2D_FONTCONFIG");
 609     if (useFC != NULL && !strcmp(useFC, "no")) {
 610         return NULL;
 611     }
 612 
 613 #ifdef __solaris__
 614     /* fontconfig is likely not properly configured on S8/S9 - skip it,
 615      * although allow user to override this behaviour with an env. variable
 616      * ie if USE_J2D_FONTCONFIG=yes then we skip this test.
 617      * NB "4" is the length of a string which matches our patterns.
 618      */
 619     if (useFC == NULL || strcmp(useFC, "yes")) {
 620         if (sysinfo(SI_RELEASE, sysinfobuf, SYSINFOBUFSZ) == 4) {
 621             if ((!strcmp(sysinfobuf, "5.8") || !strcmp(sysinfobuf, "5.9"))) {
 622                 return NULL;
 623             }
 624         }
 625     }
 626 #endif



















 627     /* 64 bit sparc should pick up the right version from the lib path.
 628      * New features may be added to libfontconfig, this is expected to
 629      * be compatible with old features, but we may need to start
 630      * distinguishing the library version, to know whether to expect
 631      * certain symbols - and functionality - to be available.
 632      * Also add explicit search for .so.1 in case .so symlink doesn't exist.
 633      */
 634     libfontconfig = dlopen(FONTCONFIG_DLL_VERSIONED, RTLD_LOCAL|RTLD_LAZY);
 635     if (libfontconfig == NULL) {
 636         libfontconfig = dlopen(FONTCONFIG_DLL, RTLD_LOCAL|RTLD_LAZY);
 637         if (libfontconfig == NULL) {
 638             return NULL;
 639         }
 640     }

 641 
 642     /* Version 1.0 of libfontconfig crashes if HOME isn't defined in
 643      * the environment. This should generally never happen, but we can't
 644      * control it, and can't control the version of fontconfig, so iff
 645      * its not defined we set it to an empty value which is sufficient
 646      * to prevent a crash. I considered unsetting it before exit, but
 647      * it doesn't appear to work on Solaris, so I will leave it set.
 648      */
 649     homeEnv = getenv("HOME");
 650     if (homeEnv == NULL) {
 651         putenv(homeEnvStr);
 652     }
 653 
 654     return libfontconfig;
 655 }
 656 
 657 typedef void* (FcFiniFuncType)();
 658 
 659 static void closeFontConfig(void* libfontconfig, jboolean fcFini) {
 660 


1218         if (debugMinGlyphsStr != NULL) {
1219             int val = minGlyphs;
1220             sscanf(debugMinGlyphsStr, "%5d", &val);
1221             if (val >= 0 && val <= 65536) {
1222                 minGlyphs = val;
1223             }
1224         }
1225         for (j=0; j<nfonts; j++) {
1226             FcPattern *fontPattern = fontset->fonts[j];
1227             FcChar8 *fontformat;
1228             FcCharSet *unionCharset = NULL, *charset;
1229 
1230             fontformat = NULL;
1231             (*FcPatternGetString)(fontPattern, FC_FONTFORMAT, 0, &fontformat);
1232             /* We only want TrueType fonts but some Linuxes still depend
1233              * on Type 1 fonts for some Locale support, so we'll allow
1234              * them there.
1235              */
1236             if (fontformat != NULL
1237                 && (strcmp((char*)fontformat, "TrueType") != 0)
1238 #ifdef __linux__
1239                 && (strcmp((char*)fontformat, "Type 1") != 0)
1240 #endif
1241              ) {
1242                 continue;
1243             }
1244             result = (*FcPatternGetCharSet)(fontPattern,
1245                                             FC_CHARSET, 0, &charset);
1246             if (result != FcResultMatch) {
1247                 free(family);
1248                 free(fullname);
1249                 free(styleStr);
1250                 free(file);
1251                 (*FcPatternDestroy)(pattern);
1252                 (*FcFontSetDestroy)(fontset);
1253                 (*env)->ReleaseStringUTFChars(env,
1254                                               fcNameStr, (const char*)fcName);
1255                 closeFontConfig(libfontconfig, JNI_FALSE);
1256                 return;
1257             }
1258 


   1 /*
   2  * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  61 
  62 #ifdef MACOSX
  63 
  64 //
  65 // XXXDARWIN: Hard-code the path to Apple's fontconfig, as it is
  66 // not included in the dyld search path by default, and 10.4
  67 // does not support -rpath.
  68 //
  69 // This ignores the build time setting of ALT_FREETYPE_LIB_PATH,
  70 // and should be replaced with -rpath/@rpath support on 10.5 or later,
  71 // or via support for a the FREETYPE_LIB_PATH define.
  72 #define FONTCONFIG_DLL_VERSIONED X11_PATH "/lib/" VERSIONED_JNI_LIB_NAME("fontconfig", "1")
  73 #define FONTCONFIG_DLL X11_PATH "/lib/" JNI_LIB_NAME("fontconfig")
  74 #else
  75 #define FONTCONFIG_DLL_VERSIONED VERSIONED_JNI_LIB_NAME("fontconfig", "1")
  76 #define FONTCONFIG_DLL JNI_LIB_NAME("fontconfig")
  77 #endif
  78 
  79 #define MAXFDIRS 512    /* Max number of directories that contain fonts */
  80 
  81 #if defined(__solaris__)
  82 /*
  83  * This can be set in the makefile to "/usr/X11" if so desired.
  84  */
  85 #ifndef OPENWINHOMELIB
  86 #define OPENWINHOMELIB "/usr/openwin/lib/"
  87 #endif
  88 
  89 /* This is all known Solaris X11 directories on Solaris 8, 9 and 10.
  90  * It is ordered to give precedence to TrueType directories.
  91  * It is needed if fontconfig is not installed or configured properly.
  92  */
  93 static char *fullSolarisFontPath[] = {
  94     OPENWINHOMELIB "X11/fonts/TrueType",
  95     OPENWINHOMELIB "locale/euro_fonts/X11/fonts/TrueType",
  96     OPENWINHOMELIB "locale/iso_8859_2/X11/fonts/TrueType",
  97     OPENWINHOMELIB "locale/iso_8859_5/X11/fonts/TrueType",
  98     OPENWINHOMELIB "locale/iso_8859_7/X11/fonts/TrueType",
  99     OPENWINHOMELIB "locale/iso_8859_8/X11/fonts/TrueType",
 100     OPENWINHOMELIB "locale/iso_8859_9/X11/fonts/TrueType",
 101     OPENWINHOMELIB "locale/iso_8859_13/X11/fonts/TrueType",


 111     OPENWINHOMELIB "locale/zh_TW/X11/fonts/TrueType",
 112     OPENWINHOMELIB "locale/zh_TW.BIG5/X11/fonts/TT",
 113     OPENWINHOMELIB "locale/zh_HK.BIG5HK/X11/fonts/TT",
 114     OPENWINHOMELIB "locale/zh_CN.GB18030/X11/fonts/TrueType",
 115     OPENWINHOMELIB "locale/zh/X11/fonts/TrueType",
 116     OPENWINHOMELIB "locale/zh.GBK/X11/fonts/TrueType",
 117     OPENWINHOMELIB "X11/fonts/Type1",
 118     OPENWINHOMELIB "X11/fonts/Type1/sun",
 119     OPENWINHOMELIB "X11/fonts/Type1/sun/outline",
 120     OPENWINHOMELIB "locale/iso_8859_2/X11/fonts/Type1",
 121     OPENWINHOMELIB "locale/iso_8859_4/X11/fonts/Type1",
 122     OPENWINHOMELIB "locale/iso_8859_5/X11/fonts/Type1",
 123     OPENWINHOMELIB "locale/iso_8859_7/X11/fonts/Type1",
 124     OPENWINHOMELIB "locale/iso_8859_8/X11/fonts/Type1",
 125     OPENWINHOMELIB "locale/iso_8859_9/X11/fonts/Type1",
 126     OPENWINHOMELIB "locale/iso_8859_13/X11/fonts/Type1",
 127     OPENWINHOMELIB "locale/ar/X11/fonts/Type1",
 128     NULL, /* terminates the list */
 129 };
 130 
 131 #elif defined(MACOSX)
 132 static char *full_MACOSX_X11FontPath[] = {
 133     X11_PATH "/lib/X11/fonts/TrueType",
 134     X11_PATH "/lib/X11/fonts/truetype",
 135     X11_PATH "/lib/X11/fonts/tt",
 136     X11_PATH "/lib/X11/fonts/TTF",
 137     X11_PATH "/lib/X11/fonts/OTF",
 138     PACKAGE_PATH "/share/fonts/TrueType",
 139     PACKAGE_PATH "/share/fonts/truetype",
 140     PACKAGE_PATH "/share/fonts/tt",
 141     PACKAGE_PATH "/share/fonts/TTF",
 142     PACKAGE_PATH "/share/fonts/OTF",
 143     X11_PATH "/lib/X11/fonts/Type1",
 144     PACKAGE_PATH "/share/fonts/Type1",
 145     NULL, /* terminates the list */
 146 };
 147 #elif defined( __linux__)
 148 /* All the known interesting locations we have discovered on
 149  * various flavors of Linux
 150  */
 151 static char *fullLinuxFontPath[] = {
 152     "/usr/X11R6/lib/X11/fonts/TrueType",  /* RH 7.1+ */
 153     "/usr/X11R6/lib/X11/fonts/truetype",  /* SuSE */
 154     "/usr/X11R6/lib/X11/fonts/tt",
 155     "/usr/X11R6/lib/X11/fonts/TTF",
 156     "/usr/X11R6/lib/X11/fonts/OTF",       /* RH 9.0 (but empty!) */
 157     "/usr/share/fonts/ja/TrueType",       /* RH 7.2+ */
 158     "/usr/share/fonts/truetype",
 159     "/usr/share/fonts/ko/TrueType",       /* RH 9.0 */
 160     "/usr/share/fonts/zh_CN/TrueType",    /* RH 9.0 */
 161     "/usr/share/fonts/zh_TW/TrueType",    /* RH 9.0 */
 162     "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType", /* Debian */
 163     "/usr/X11R6/lib/X11/fonts/Type1",
 164     "/usr/share/fonts/default/Type1",     /* RH 9.0 */
 165     NULL, /* terminates the list */
 166 };
 167 #elif defined(AIX)
 168 /* Very basic start for AIX -  feel free to complete ..
 169  */
 170 static char *fullAixFontPath[] = {
 171     "/usr/lib/X11/fonts/TrueType",  /* */
 172     "/usr/lib/X11/fonts/Type1",     /* */
 173     NULL, /* terminates the list */
 174 };
 175 #endif
 176 
 177 static char **getFontConfigLocations();
 178 
 179 typedef struct {
 180     const char *name[MAXFDIRS];
 181     int  num;
 182 } fDirRecord, *fDirRecordPtr;
 183 
 184 #ifndef HEADLESS
 185 
 186 /*
 187  * Returns True if display is local, False of it's remote.
 188  */
 189 jboolean isDisplayLocal(JNIEnv *env) {
 190     static jboolean isLocal = False;
 191     static jboolean isLocalSet = False;
 192     jboolean ret;
 193 
 194     if (! isLocalSet) {


 520  * NB: Fontconfig also depends heavily for performance on the host O/S
 521  * maintaining up to date caches.
 522  * This is consistent with the requirements of the desktop environments
 523  * on these OSes.
 524  * This also frees us from X11 APIs as JRE is required to function in
 525  * a "headless" mode where there is no Xserver.
 526  */
 527 static char *getPlatformFontPathChars(JNIEnv *env, jboolean noType1) {
 528 
 529     char **fcdirs = NULL, **x11dirs = NULL, **knowndirs = NULL, *path = NULL;
 530 
 531     /* As of 1.5 we try to use fontconfig on both Solaris and Linux.
 532      * If its not available NULL is returned.
 533      */
 534     fcdirs = getFontConfigLocations();
 535 
 536 #if defined(__linux__)
 537     knowndirs = fullLinuxFontPath;
 538 #elif defined(MACOSX)
 539     knowndirs = full_MACOSX_X11FontPath;
 540 #elif defined(__solaris__)
 541     knowndirs = fullSolarisFontPath;
 542 #elif defined(AIX)
 543     knowndirs = fullAixFontPath;
 544 #endif
 545 
 546     /* REMIND: this code requires to be executed when the GraphicsEnvironment
 547      * is already initialised. That is always true, but if it were not so,
 548      * this code could throw an exception and the fontpath would fail to
 549      * be initialised.
 550      */
 551 #ifndef HEADLESS
 552 #if defined(__linux__) || defined(MACOSX)
 553     /* There's no headless build on linux ... */
 554     if (!AWTIsHeadless()) { /* .. so need to call a function to check */
 555 #endif
 556       /* Using the X11 font path to locate font files is now a fallback
 557        * useful only if fontconfig failed, or is incomplete. So we could
 558        * remove this code completely and the consequences should be rare
 559        * and non-fatal. If this happens, then the calling Java code can
 560        * be modified to no longer require that the AWT lock (the X11GE)
 561        * be initialised prior to calling this code.
 562        */
 563     AWT_LOCK();


 617      */
 618     char *useFC = getenv("USE_J2D_FONTCONFIG");
 619     if (useFC != NULL && !strcmp(useFC, "no")) {
 620         return NULL;
 621     }
 622 
 623 #ifdef __solaris__
 624     /* fontconfig is likely not properly configured on S8/S9 - skip it,
 625      * although allow user to override this behaviour with an env. variable
 626      * ie if USE_J2D_FONTCONFIG=yes then we skip this test.
 627      * NB "4" is the length of a string which matches our patterns.
 628      */
 629     if (useFC == NULL || strcmp(useFC, "yes")) {
 630         if (sysinfo(SI_RELEASE, sysinfobuf, SYSINFOBUFSZ) == 4) {
 631             if ((!strcmp(sysinfobuf, "5.8") || !strcmp(sysinfobuf, "5.9"))) {
 632                 return NULL;
 633             }
 634         }
 635     }
 636 #endif
 637 
 638 #if defined(AIX)
 639     /* On AIX, fontconfig is not a standard package supported by IBM.
 640      * insted it has to be installed from the "AIX Toolbox for Linux Applications"
 641      * site http://www-03.ibm.com/systems/power/software/aix/linux/toolbox/alpha.html
 642      * and will be installed under /opt/freeware/lib/libfontconfig.a.
 643      * Notice that the archive contains the real 32- and 64-bit shared libraries.
 644      * We first try to load 'libfontconfig.so' from the default library path in the
 645      * case the user has installed a private version of the library and if that
 646      * doesn't succeed, we try the version from /opt/freeware/lib/libfontconfig.a
 647      */
 648     libfontconfig = dlopen("libfontconfig.so", RTLD_LOCAL|RTLD_LAZY);
 649     if (libfontconfig == NULL) {
 650         libfontconfig = dlopen("/opt/freeware/lib/libfontconfig.a(libfontconfig.so.1)", RTLD_MEMBER|RTLD_LOCAL|RTLD_LAZY);
 651         if (libfontconfig == NULL) {
 652             return NULL;
 653         }
 654     }
 655 #else
 656     /* 64 bit sparc should pick up the right version from the lib path.
 657      * New features may be added to libfontconfig, this is expected to
 658      * be compatible with old features, but we may need to start
 659      * distinguishing the library version, to know whether to expect
 660      * certain symbols - and functionality - to be available.
 661      * Also add explicit search for .so.1 in case .so symlink doesn't exist.
 662      */
 663     libfontconfig = dlopen(FONTCONFIG_DLL_VERSIONED, RTLD_LOCAL|RTLD_LAZY);
 664     if (libfontconfig == NULL) {
 665         libfontconfig = dlopen(FONTCONFIG_DLL, RTLD_LOCAL|RTLD_LAZY);
 666         if (libfontconfig == NULL) {
 667             return NULL;
 668         }
 669     }
 670 #endif
 671 
 672     /* Version 1.0 of libfontconfig crashes if HOME isn't defined in
 673      * the environment. This should generally never happen, but we can't
 674      * control it, and can't control the version of fontconfig, so iff
 675      * its not defined we set it to an empty value which is sufficient
 676      * to prevent a crash. I considered unsetting it before exit, but
 677      * it doesn't appear to work on Solaris, so I will leave it set.
 678      */
 679     homeEnv = getenv("HOME");
 680     if (homeEnv == NULL) {
 681         putenv(homeEnvStr);
 682     }
 683 
 684     return libfontconfig;
 685 }
 686 
 687 typedef void* (FcFiniFuncType)();
 688 
 689 static void closeFontConfig(void* libfontconfig, jboolean fcFini) {
 690 


1248         if (debugMinGlyphsStr != NULL) {
1249             int val = minGlyphs;
1250             sscanf(debugMinGlyphsStr, "%5d", &val);
1251             if (val >= 0 && val <= 65536) {
1252                 minGlyphs = val;
1253             }
1254         }
1255         for (j=0; j<nfonts; j++) {
1256             FcPattern *fontPattern = fontset->fonts[j];
1257             FcChar8 *fontformat;
1258             FcCharSet *unionCharset = NULL, *charset;
1259 
1260             fontformat = NULL;
1261             (*FcPatternGetString)(fontPattern, FC_FONTFORMAT, 0, &fontformat);
1262             /* We only want TrueType fonts but some Linuxes still depend
1263              * on Type 1 fonts for some Locale support, so we'll allow
1264              * them there.
1265              */
1266             if (fontformat != NULL
1267                 && (strcmp((char*)fontformat, "TrueType") != 0)
1268 #if defined(__linux__) || defined(AIX)
1269                 && (strcmp((char*)fontformat, "Type 1") != 0)
1270 #endif
1271              ) {
1272                 continue;
1273             }
1274             result = (*FcPatternGetCharSet)(fontPattern,
1275                                             FC_CHARSET, 0, &charset);
1276             if (result != FcResultMatch) {
1277                 free(family);
1278                 free(fullname);
1279                 free(styleStr);
1280                 free(file);
1281                 (*FcPatternDestroy)(pattern);
1282                 (*FcFontSetDestroy)(fontset);
1283                 (*env)->ReleaseStringUTFChars(env,
1284                                               fcNameStr, (const char*)fcName);
1285                 closeFontConfig(libfontconfig, JNI_FALSE);
1286                 return;
1287             }
1288