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

Print this page
rev 8725 : 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: alanb, prr, sla, chegar, michaelm, mullan
   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


  47 #include <awt.h>
  48 #else
  49 /* locks ought to be included from awt.h */
  50 #define AWT_LOCK()
  51 #define AWT_UNLOCK()
  52 #endif /* !HEADLESS */
  53 
  54 #if defined(__linux__) && !defined(MAP_FAILED)
  55 #define MAP_FAILED ((caddr_t)-1)
  56 #endif
  57 
  58 #ifndef HEADLESS
  59 extern Display *awt_display;
  60 #endif /* !HEADLESS */
  61 
  62 #define FONTCONFIG_DLL_VERSIONED VERSIONED_JNI_LIB_NAME("fontconfig", "1")
  63 #define FONTCONFIG_DLL JNI_LIB_NAME("fontconfig")
  64 
  65 #define MAXFDIRS 512    /* Max number of directories that contain fonts */
  66 
  67 #if !defined(__linux__)
  68 /*
  69  * This can be set in the makefile to "/usr/X11" if so desired.
  70  */
  71 #ifndef OPENWINHOMELIB
  72 #define OPENWINHOMELIB "/usr/openwin/lib/"
  73 #endif
  74 
  75 /* This is all known Solaris X11 directories on Solaris 8, 9 and 10.
  76  * It is ordered to give precedence to TrueType directories.
  77  * It is needed if fontconfig is not installed or configured properly.
  78  */
  79 static char *fullSolarisFontPath[] = {
  80     OPENWINHOMELIB "X11/fonts/TrueType",
  81     OPENWINHOMELIB "locale/euro_fonts/X11/fonts/TrueType",
  82     OPENWINHOMELIB "locale/iso_8859_2/X11/fonts/TrueType",
  83     OPENWINHOMELIB "locale/iso_8859_5/X11/fonts/TrueType",
  84     OPENWINHOMELIB "locale/iso_8859_7/X11/fonts/TrueType",
  85     OPENWINHOMELIB "locale/iso_8859_8/X11/fonts/TrueType",
  86     OPENWINHOMELIB "locale/iso_8859_9/X11/fonts/TrueType",
  87     OPENWINHOMELIB "locale/iso_8859_13/X11/fonts/TrueType",


  97     OPENWINHOMELIB "locale/zh_TW/X11/fonts/TrueType",
  98     OPENWINHOMELIB "locale/zh_TW.BIG5/X11/fonts/TT",
  99     OPENWINHOMELIB "locale/zh_HK.BIG5HK/X11/fonts/TT",
 100     OPENWINHOMELIB "locale/zh_CN.GB18030/X11/fonts/TrueType",
 101     OPENWINHOMELIB "locale/zh/X11/fonts/TrueType",
 102     OPENWINHOMELIB "locale/zh.GBK/X11/fonts/TrueType",
 103     OPENWINHOMELIB "X11/fonts/Type1",
 104     OPENWINHOMELIB "X11/fonts/Type1/sun",
 105     OPENWINHOMELIB "X11/fonts/Type1/sun/outline",
 106     OPENWINHOMELIB "locale/iso_8859_2/X11/fonts/Type1",
 107     OPENWINHOMELIB "locale/iso_8859_4/X11/fonts/Type1",
 108     OPENWINHOMELIB "locale/iso_8859_5/X11/fonts/Type1",
 109     OPENWINHOMELIB "locale/iso_8859_7/X11/fonts/Type1",
 110     OPENWINHOMELIB "locale/iso_8859_8/X11/fonts/Type1",
 111     OPENWINHOMELIB "locale/iso_8859_9/X11/fonts/Type1",
 112     OPENWINHOMELIB "locale/iso_8859_13/X11/fonts/Type1",
 113     OPENWINHOMELIB "locale/ar/X11/fonts/Type1",
 114     NULL, /* terminates the list */
 115 };
 116 
 117 #else /* __linux */
 118 /* All the known interesting locations we have discovered on
 119  * various flavors of Linux
 120  */
 121 static char *fullLinuxFontPath[] = {
 122     "/usr/X11R6/lib/X11/fonts/TrueType",  /* RH 7.1+ */
 123     "/usr/X11R6/lib/X11/fonts/truetype",  /* SuSE */
 124     "/usr/X11R6/lib/X11/fonts/tt",
 125     "/usr/X11R6/lib/X11/fonts/TTF",
 126     "/usr/X11R6/lib/X11/fonts/OTF",       /* RH 9.0 (but empty!) */
 127     "/usr/share/fonts/ja/TrueType",       /* RH 7.2+ */
 128     "/usr/share/fonts/truetype",
 129     "/usr/share/fonts/ko/TrueType",       /* RH 9.0 */
 130     "/usr/share/fonts/zh_CN/TrueType",    /* RH 9.0 */
 131     "/usr/share/fonts/zh_TW/TrueType",    /* RH 9.0 */
 132     "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType", /* Debian */
 133     "/usr/X11R6/lib/X11/fonts/Type1",
 134     "/usr/share/fonts/default/Type1",     /* RH 9.0 */
 135     NULL, /* terminates the list */
 136 };






 137 #endif
 138 
 139 static char **getFontConfigLocations();
 140 
 141 typedef struct {
 142     const char *name[MAXFDIRS];
 143     int  num;
 144 } fDirRecord, *fDirRecordPtr;
 145 
 146 #ifndef HEADLESS
 147 
 148 /*
 149  * Returns True if display is local, False of it's remote.
 150  */
 151 jboolean isDisplayLocal(JNIEnv *env) {
 152     static jboolean isLocal = False;
 153     static jboolean isLocalSet = False;
 154     jboolean ret;
 155 
 156     if (! isLocalSet) {


 480  * need to be added ito the host's font configuration database, typically
 481  * /etc/fonts/local.conf, and to ensure that directory contains a fonts.dir
 482  * NB: Fontconfig also depends heavily for performance on the host O/S
 483  * maintaining up to date caches.
 484  * This is consistent with the requirements of the desktop environments
 485  * on these OSes.
 486  * This also frees us from X11 APIs as JRE is required to function in
 487  * a "headless" mode where there is no Xserver.
 488  */
 489 static char *getPlatformFontPathChars(JNIEnv *env, jboolean noType1) {
 490 
 491     char **fcdirs = NULL, **x11dirs = NULL, **knowndirs = NULL, *path = NULL;
 492 
 493     /* As of 1.5 we try to use fontconfig on both Solaris and Linux.
 494      * If its not available NULL is returned.
 495      */
 496     fcdirs = getFontConfigLocations();
 497 
 498 #if defined(__linux__)
 499     knowndirs = fullLinuxFontPath;
 500 #else /* IF SOLARIS */
 501     knowndirs = fullSolarisFontPath;


 502 #endif
 503 
 504     /* REMIND: this code requires to be executed when the GraphicsEnvironment
 505      * is already initialised. That is always true, but if it were not so,
 506      * this code could throw an exception and the fontpath would fail to
 507      * be initialised.
 508      */
 509 #ifndef HEADLESS
 510 #if defined(__linux__)
 511     /* There's no headless build on linux ... */
 512     if (!AWTIsHeadless()) { /* .. so need to call a function to check */
 513 #endif
 514       /* Using the X11 font path to locate font files is now a fallback
 515        * useful only if fontconfig failed, or is incomplete. So we could
 516        * remove this code completely and the consequences should be rare
 517        * and non-fatal. If this happens, then the calling Java code can
 518        * be modified to no longer require that the AWT lock (the X11GE)
 519        * be initialised prior to calling this code.
 520        */
 521     AWT_LOCK();
 522     if (isDisplayLocal(env)) {
 523         x11dirs = getX11FontPath();


 575      */
 576     char *useFC = getenv("USE_J2D_FONTCONFIG");
 577     if (useFC != NULL && !strcmp(useFC, "no")) {
 578         return NULL;
 579     }
 580 
 581 #ifdef __solaris__
 582     /* fontconfig is likely not properly configured on S8/S9 - skip it,
 583      * although allow user to override this behaviour with an env. variable
 584      * ie if USE_J2D_FONTCONFIG=yes then we skip this test.
 585      * NB "4" is the length of a string which matches our patterns.
 586      */
 587     if (useFC == NULL || strcmp(useFC, "yes")) {
 588         if (sysinfo(SI_RELEASE, sysinfobuf, SYSINFOBUFSZ) == 4) {
 589             if ((!strcmp(sysinfobuf, "5.8") || !strcmp(sysinfobuf, "5.9"))) {
 590                 return NULL;
 591             }
 592         }
 593     }
 594 #endif



















 595     /* 64 bit sparc should pick up the right version from the lib path.
 596      * New features may be added to libfontconfig, this is expected to
 597      * be compatible with old features, but we may need to start
 598      * distinguishing the library version, to know whether to expect
 599      * certain symbols - and functionality - to be available.
 600      * Also add explicit search for .so.1 in case .so symlink doesn't exist.
 601      */
 602     libfontconfig = dlopen(FONTCONFIG_DLL_VERSIONED, RTLD_LOCAL|RTLD_LAZY);
 603     if (libfontconfig == NULL) {
 604         libfontconfig = dlopen(FONTCONFIG_DLL, RTLD_LOCAL|RTLD_LAZY);
 605         if (libfontconfig == NULL) {
 606             return NULL;
 607         }
 608     }

 609 
 610     /* Version 1.0 of libfontconfig crashes if HOME isn't defined in
 611      * the environment. This should generally never happen, but we can't
 612      * control it, and can't control the version of fontconfig, so iff
 613      * its not defined we set it to an empty value which is sufficient
 614      * to prevent a crash. I considered unsetting it before exit, but
 615      * it doesn't appear to work on Solaris, so I will leave it set.
 616      */
 617     homeEnv = getenv("HOME");
 618     if (homeEnv == NULL) {
 619         putenv(homeEnvStr);
 620     }
 621 
 622     return libfontconfig;
 623 }
 624 
 625 typedef void* (FcFiniFuncType)();
 626 
 627 static void closeFontConfig(void* libfontconfig, jboolean fcFini) {
 628 


1186         if (debugMinGlyphsStr != NULL) {
1187             int val = minGlyphs;
1188             sscanf(debugMinGlyphsStr, "%5d", &val);
1189             if (val >= 0 && val <= 65536) {
1190                 minGlyphs = val;
1191             }
1192         }
1193         for (j=0; j<nfonts; j++) {
1194             FcPattern *fontPattern = fontset->fonts[j];
1195             FcChar8 *fontformat;
1196             FcCharSet *unionCharset = NULL, *charset;
1197 
1198             fontformat = NULL;
1199             (*FcPatternGetString)(fontPattern, FC_FONTFORMAT, 0, &fontformat);
1200             /* We only want TrueType fonts but some Linuxes still depend
1201              * on Type 1 fonts for some Locale support, so we'll allow
1202              * them there.
1203              */
1204             if (fontformat != NULL
1205                 && (strcmp((char*)fontformat, "TrueType") != 0)
1206 #ifdef __linux__
1207                 && (strcmp((char*)fontformat, "Type 1") != 0)
1208 #endif
1209              ) {
1210                 continue;
1211             }
1212             result = (*FcPatternGetCharSet)(fontPattern,
1213                                             FC_CHARSET, 0, &charset);
1214             if (result != FcResultMatch) {
1215                 free(family);
1216                 free(fullname);
1217                 free(styleStr);
1218                 free(file);
1219                 (*FcPatternDestroy)(pattern);
1220                 (*FcFontSetDestroy)(fontset);
1221                 (*env)->ReleaseStringUTFChars(env,
1222                                               fcNameStr, (const char*)fcName);
1223                 closeFontConfig(libfontconfig, JNI_FALSE);
1224                 return;
1225             }
1226 


   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


  47 #include <awt.h>
  48 #else
  49 /* locks ought to be included from awt.h */
  50 #define AWT_LOCK()
  51 #define AWT_UNLOCK()
  52 #endif /* !HEADLESS */
  53 
  54 #if defined(__linux__) && !defined(MAP_FAILED)
  55 #define MAP_FAILED ((caddr_t)-1)
  56 #endif
  57 
  58 #ifndef HEADLESS
  59 extern Display *awt_display;
  60 #endif /* !HEADLESS */
  61 
  62 #define FONTCONFIG_DLL_VERSIONED VERSIONED_JNI_LIB_NAME("fontconfig", "1")
  63 #define FONTCONFIG_DLL JNI_LIB_NAME("fontconfig")
  64 
  65 #define MAXFDIRS 512    /* Max number of directories that contain fonts */
  66 
  67 #if defined(__solaris__)
  68 /*
  69  * This can be set in the makefile to "/usr/X11" if so desired.
  70  */
  71 #ifndef OPENWINHOMELIB
  72 #define OPENWINHOMELIB "/usr/openwin/lib/"
  73 #endif
  74 
  75 /* This is all known Solaris X11 directories on Solaris 8, 9 and 10.
  76  * It is ordered to give precedence to TrueType directories.
  77  * It is needed if fontconfig is not installed or configured properly.
  78  */
  79 static char *fullSolarisFontPath[] = {
  80     OPENWINHOMELIB "X11/fonts/TrueType",
  81     OPENWINHOMELIB "locale/euro_fonts/X11/fonts/TrueType",
  82     OPENWINHOMELIB "locale/iso_8859_2/X11/fonts/TrueType",
  83     OPENWINHOMELIB "locale/iso_8859_5/X11/fonts/TrueType",
  84     OPENWINHOMELIB "locale/iso_8859_7/X11/fonts/TrueType",
  85     OPENWINHOMELIB "locale/iso_8859_8/X11/fonts/TrueType",
  86     OPENWINHOMELIB "locale/iso_8859_9/X11/fonts/TrueType",
  87     OPENWINHOMELIB "locale/iso_8859_13/X11/fonts/TrueType",


  97     OPENWINHOMELIB "locale/zh_TW/X11/fonts/TrueType",
  98     OPENWINHOMELIB "locale/zh_TW.BIG5/X11/fonts/TT",
  99     OPENWINHOMELIB "locale/zh_HK.BIG5HK/X11/fonts/TT",
 100     OPENWINHOMELIB "locale/zh_CN.GB18030/X11/fonts/TrueType",
 101     OPENWINHOMELIB "locale/zh/X11/fonts/TrueType",
 102     OPENWINHOMELIB "locale/zh.GBK/X11/fonts/TrueType",
 103     OPENWINHOMELIB "X11/fonts/Type1",
 104     OPENWINHOMELIB "X11/fonts/Type1/sun",
 105     OPENWINHOMELIB "X11/fonts/Type1/sun/outline",
 106     OPENWINHOMELIB "locale/iso_8859_2/X11/fonts/Type1",
 107     OPENWINHOMELIB "locale/iso_8859_4/X11/fonts/Type1",
 108     OPENWINHOMELIB "locale/iso_8859_5/X11/fonts/Type1",
 109     OPENWINHOMELIB "locale/iso_8859_7/X11/fonts/Type1",
 110     OPENWINHOMELIB "locale/iso_8859_8/X11/fonts/Type1",
 111     OPENWINHOMELIB "locale/iso_8859_9/X11/fonts/Type1",
 112     OPENWINHOMELIB "locale/iso_8859_13/X11/fonts/Type1",
 113     OPENWINHOMELIB "locale/ar/X11/fonts/Type1",
 114     NULL, /* terminates the list */
 115 };
 116 
 117 #elif defined( __linux__)
 118 /* All the known interesting locations we have discovered on
 119  * various flavors of Linux
 120  */
 121 static char *fullLinuxFontPath[] = {
 122     "/usr/X11R6/lib/X11/fonts/TrueType",  /* RH 7.1+ */
 123     "/usr/X11R6/lib/X11/fonts/truetype",  /* SuSE */
 124     "/usr/X11R6/lib/X11/fonts/tt",
 125     "/usr/X11R6/lib/X11/fonts/TTF",
 126     "/usr/X11R6/lib/X11/fonts/OTF",       /* RH 9.0 (but empty!) */
 127     "/usr/share/fonts/ja/TrueType",       /* RH 7.2+ */
 128     "/usr/share/fonts/truetype",
 129     "/usr/share/fonts/ko/TrueType",       /* RH 9.0 */
 130     "/usr/share/fonts/zh_CN/TrueType",    /* RH 9.0 */
 131     "/usr/share/fonts/zh_TW/TrueType",    /* RH 9.0 */
 132     "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType", /* Debian */
 133     "/usr/X11R6/lib/X11/fonts/Type1",
 134     "/usr/share/fonts/default/Type1",     /* RH 9.0 */
 135     NULL, /* terminates the list */
 136 };
 137 #elif defined(_AIX)
 138 static char *fullAixFontPath[] = {
 139     "/usr/lpp/X11/lib/X11/fonts/Type1",    /* from X11.fnt.iso_T1  */
 140     "/usr/lpp/X11/lib/X11/fonts/TrueType", /* from X11.fnt.ucs.ttf */
 141     NULL, /* terminates the list */
 142 };
 143 #endif
 144 
 145 static char **getFontConfigLocations();
 146 
 147 typedef struct {
 148     const char *name[MAXFDIRS];
 149     int  num;
 150 } fDirRecord, *fDirRecordPtr;
 151 
 152 #ifndef HEADLESS
 153 
 154 /*
 155  * Returns True if display is local, False of it's remote.
 156  */
 157 jboolean isDisplayLocal(JNIEnv *env) {
 158     static jboolean isLocal = False;
 159     static jboolean isLocalSet = False;
 160     jboolean ret;
 161 
 162     if (! isLocalSet) {


 486  * need to be added ito the host's font configuration database, typically
 487  * /etc/fonts/local.conf, and to ensure that directory contains a fonts.dir
 488  * NB: Fontconfig also depends heavily for performance on the host O/S
 489  * maintaining up to date caches.
 490  * This is consistent with the requirements of the desktop environments
 491  * on these OSes.
 492  * This also frees us from X11 APIs as JRE is required to function in
 493  * a "headless" mode where there is no Xserver.
 494  */
 495 static char *getPlatformFontPathChars(JNIEnv *env, jboolean noType1) {
 496 
 497     char **fcdirs = NULL, **x11dirs = NULL, **knowndirs = NULL, *path = NULL;
 498 
 499     /* As of 1.5 we try to use fontconfig on both Solaris and Linux.
 500      * If its not available NULL is returned.
 501      */
 502     fcdirs = getFontConfigLocations();
 503 
 504 #if defined(__linux__)
 505     knowndirs = fullLinuxFontPath;
 506 #elif defined(__solaris__)
 507     knowndirs = fullSolarisFontPath;
 508 #elif defined(_AIX)
 509     knowndirs = fullAixFontPath;
 510 #endif

 511     /* REMIND: this code requires to be executed when the GraphicsEnvironment
 512      * is already initialised. That is always true, but if it were not so,
 513      * this code could throw an exception and the fontpath would fail to
 514      * be initialised.
 515      */
 516 #ifndef HEADLESS
 517 #if defined(__linux__)
 518     /* There's no headless build on linux ... */
 519     if (!AWTIsHeadless()) { /* .. so need to call a function to check */
 520 #endif
 521       /* Using the X11 font path to locate font files is now a fallback
 522        * useful only if fontconfig failed, or is incomplete. So we could
 523        * remove this code completely and the consequences should be rare
 524        * and non-fatal. If this happens, then the calling Java code can
 525        * be modified to no longer require that the AWT lock (the X11GE)
 526        * be initialised prior to calling this code.
 527        */
 528     AWT_LOCK();
 529     if (isDisplayLocal(env)) {
 530         x11dirs = getX11FontPath();


 582      */
 583     char *useFC = getenv("USE_J2D_FONTCONFIG");
 584     if (useFC != NULL && !strcmp(useFC, "no")) {
 585         return NULL;
 586     }
 587 
 588 #ifdef __solaris__
 589     /* fontconfig is likely not properly configured on S8/S9 - skip it,
 590      * although allow user to override this behaviour with an env. variable
 591      * ie if USE_J2D_FONTCONFIG=yes then we skip this test.
 592      * NB "4" is the length of a string which matches our patterns.
 593      */
 594     if (useFC == NULL || strcmp(useFC, "yes")) {
 595         if (sysinfo(SI_RELEASE, sysinfobuf, SYSINFOBUFSZ) == 4) {
 596             if ((!strcmp(sysinfobuf, "5.8") || !strcmp(sysinfobuf, "5.9"))) {
 597                 return NULL;
 598             }
 599         }
 600     }
 601 #endif
 602 
 603 #if defined(_AIX)
 604     /* On AIX, fontconfig is not a standard package supported by IBM.
 605      * instead it has to be installed from the "AIX Toolbox for Linux Applications"
 606      * site http://www-03.ibm.com/systems/power/software/aix/linux/toolbox/alpha.html
 607      * and will be installed under /opt/freeware/lib/libfontconfig.a.
 608      * Notice that the archive contains the real 32- and 64-bit shared libraries.
 609      * We first try to load 'libfontconfig.so' from the default library path in the
 610      * case the user has installed a private version of the library and if that
 611      * doesn't succeed, we try the version from /opt/freeware/lib/libfontconfig.a
 612      */
 613     libfontconfig = dlopen("libfontconfig.so", RTLD_LOCAL|RTLD_LAZY);
 614     if (libfontconfig == NULL) {
 615         libfontconfig = dlopen("/opt/freeware/lib/libfontconfig.a(libfontconfig.so.1)", RTLD_MEMBER|RTLD_LOCAL|RTLD_LAZY);
 616         if (libfontconfig == NULL) {
 617             return NULL;
 618         }
 619     }
 620 #else
 621     /* 64 bit sparc should pick up the right version from the lib path.
 622      * New features may be added to libfontconfig, this is expected to
 623      * be compatible with old features, but we may need to start
 624      * distinguishing the library version, to know whether to expect
 625      * certain symbols - and functionality - to be available.
 626      * Also add explicit search for .so.1 in case .so symlink doesn't exist.
 627      */
 628     libfontconfig = dlopen(FONTCONFIG_DLL_VERSIONED, RTLD_LOCAL|RTLD_LAZY);
 629     if (libfontconfig == NULL) {
 630         libfontconfig = dlopen(FONTCONFIG_DLL, RTLD_LOCAL|RTLD_LAZY);
 631         if (libfontconfig == NULL) {
 632             return NULL;
 633         }
 634     }
 635 #endif
 636 
 637     /* Version 1.0 of libfontconfig crashes if HOME isn't defined in
 638      * the environment. This should generally never happen, but we can't
 639      * control it, and can't control the version of fontconfig, so iff
 640      * its not defined we set it to an empty value which is sufficient
 641      * to prevent a crash. I considered unsetting it before exit, but
 642      * it doesn't appear to work on Solaris, so I will leave it set.
 643      */
 644     homeEnv = getenv("HOME");
 645     if (homeEnv == NULL) {
 646         putenv(homeEnvStr);
 647     }
 648 
 649     return libfontconfig;
 650 }
 651 
 652 typedef void* (FcFiniFuncType)();
 653 
 654 static void closeFontConfig(void* libfontconfig, jboolean fcFini) {
 655 


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