jdk/src/solaris/native/sun/awt/fontpath.c
changeset 21130 0f0b9c8f701a
parent 18232 b538b71fb429
child 22597 7515a991bb37
equal deleted inserted replaced
21129:e1f4474a6723 21130:0f0b9c8f701a
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    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
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 #if defined(__linux__) || defined(MACOSX)
    26 #if defined(__linux__)
    27 #include <string.h>
    27 #include <string.h>
    28 #endif /* __linux__ */
    28 #endif /* __linux__ */
    29 #include <stdio.h>
    29 #include <stdio.h>
    30 #include <stdlib.h>
    30 #include <stdlib.h>
    31 #include <strings.h>
    31 #include <strings.h>
    57 
    57 
    58 #ifndef HEADLESS
    58 #ifndef HEADLESS
    59 extern Display *awt_display;
    59 extern Display *awt_display;
    60 #endif /* !HEADLESS */
    60 #endif /* !HEADLESS */
    61 
    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")
    62 #define FONTCONFIG_DLL_VERSIONED VERSIONED_JNI_LIB_NAME("fontconfig", "1")
    76 #define FONTCONFIG_DLL JNI_LIB_NAME("fontconfig")
    63 #define FONTCONFIG_DLL JNI_LIB_NAME("fontconfig")
    77 #endif
       
    78 
    64 
    79 #define MAXFDIRS 512    /* Max number of directories that contain fonts */
    65 #define MAXFDIRS 512    /* Max number of directories that contain fonts */
    80 
    66 
    81 #if !defined(__linux__) && !defined(MACOSX)
    67 #if !defined(__linux__)
    82 /*
    68 /*
    83  * This can be set in the makefile to "/usr/X11" if so desired.
    69  * This can be set in the makefile to "/usr/X11" if so desired.
    84  */
    70  */
    85 #ifndef OPENWINHOMELIB
    71 #ifndef OPENWINHOMELIB
    86 #define OPENWINHOMELIB "/usr/openwin/lib/"
    72 #define OPENWINHOMELIB "/usr/openwin/lib/"
   126     OPENWINHOMELIB "locale/iso_8859_13/X11/fonts/Type1",
   112     OPENWINHOMELIB "locale/iso_8859_13/X11/fonts/Type1",
   127     OPENWINHOMELIB "locale/ar/X11/fonts/Type1",
   113     OPENWINHOMELIB "locale/ar/X11/fonts/Type1",
   128     NULL, /* terminates the list */
   114     NULL, /* terminates the list */
   129 };
   115 };
   130 
   116 
   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 */
   117 #else /* __linux */
   148 /* All the known interesting locations we have discovered on
   118 /* All the known interesting locations we have discovered on
   149  * various flavors of Linux
   119  * various flavors of Linux
   150  */
   120  */
   151 static char *fullLinuxFontPath[] = {
   121 static char *fullLinuxFontPath[] = {
   398 }
   368 }
   399 
   369 
   400 
   370 
   401 #endif /* !HEADLESS */
   371 #endif /* !HEADLESS */
   402 
   372 
   403 #if defined(__linux__) || defined(MACOSX)
   373 #if defined(__linux__)
   404 /* from awt_LoadLibrary.c */
   374 /* from awt_LoadLibrary.c */
   405 JNIEXPORT jboolean JNICALL AWTIsHeadless();
   375 JNIEXPORT jboolean JNICALL AWTIsHeadless();
   406 #endif
   376 #endif
   407 
   377 
   408 /* This eliminates duplicates, at a non-linear but acceptable cost
   378 /* This eliminates duplicates, at a non-linear but acceptable cost
   525      */
   495      */
   526     fcdirs = getFontConfigLocations();
   496     fcdirs = getFontConfigLocations();
   527 
   497 
   528 #if defined(__linux__)
   498 #if defined(__linux__)
   529     knowndirs = fullLinuxFontPath;
   499     knowndirs = fullLinuxFontPath;
   530 #elif defined(MACOSX)
       
   531     knowndirs = full_MACOSX_X11FontPath;
       
   532 #else /* IF SOLARIS */
   500 #else /* IF SOLARIS */
   533     knowndirs = fullSolarisFontPath;
   501     knowndirs = fullSolarisFontPath;
   534 #endif
   502 #endif
   535 
   503 
   536     /* REMIND: this code requires to be executed when the GraphicsEnvironment
   504     /* REMIND: this code requires to be executed when the GraphicsEnvironment
   537      * is already initialised. That is always true, but if it were not so,
   505      * 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
   506      * this code could throw an exception and the fontpath would fail to
   539      * be initialised.
   507      * be initialised.
   540      */
   508      */
   541 #ifndef HEADLESS
   509 #ifndef HEADLESS
   542 #if defined(__linux__) || defined(MACOSX)
   510 #if defined(__linux__)
   543     /* There's no headless build on linux ... */
   511     /* There's no headless build on linux ... */
   544     if (!AWTIsHeadless()) { /* .. so need to call a function to check */
   512     if (!AWTIsHeadless()) { /* .. so need to call a function to check */
   545 #endif
   513 #endif
   546       /* Using the X11 font path to locate font files is now a fallback
   514       /* 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
   515        * useful only if fontconfig failed, or is incomplete. So we could
   553     AWT_LOCK();
   521     AWT_LOCK();
   554     if (isDisplayLocal(env)) {
   522     if (isDisplayLocal(env)) {
   555         x11dirs = getX11FontPath();
   523         x11dirs = getX11FontPath();
   556     }
   524     }
   557     AWT_UNLOCK();
   525     AWT_UNLOCK();
   558 #if defined(__linux__) || defined(MACOSX)
   526 #if defined(__linux__)
   559     }
   527     }
   560 #endif
   528 #endif
   561 #endif /* !HEADLESS */
   529 #endif /* !HEADLESS */
   562     path = mergePaths(fcdirs, x11dirs, knowndirs, noType1);
   530     path = mergePaths(fcdirs, x11dirs, knowndirs, noType1);
   563     if (fcdirs != NULL) {
   531     if (fcdirs != NULL) {