equal
deleted
inserted
replaced
495 * This is consistent with the requirements of the desktop environments |
495 * This is consistent with the requirements of the desktop environments |
496 * on these OSes. |
496 * on these OSes. |
497 * This also frees us from X11 APIs as JRE is required to function in |
497 * This also frees us from X11 APIs as JRE is required to function in |
498 * a "headless" mode where there is no Xserver. |
498 * a "headless" mode where there is no Xserver. |
499 */ |
499 */ |
500 static char *getPlatformFontPathChars(JNIEnv *env, jboolean noType1) { |
500 static char *getPlatformFontPathChars(JNIEnv *env, jboolean noType1, jboolean isX11) { |
501 |
501 |
502 char **fcdirs = NULL, **x11dirs = NULL, **knowndirs = NULL, *path = NULL; |
502 char **fcdirs = NULL, **x11dirs = NULL, **knowndirs = NULL, *path = NULL; |
503 |
503 |
504 /* As of 1.5 we try to use fontconfig on both Solaris and Linux. |
504 /* As of 1.5 we try to use fontconfig on both Solaris and Linux. |
505 * If its not available NULL is returned. |
505 * If its not available NULL is returned. |
517 * is already initialised. That is always true, but if it were not so, |
517 * is already initialised. That is always true, but if it were not so, |
518 * this code could throw an exception and the fontpath would fail to |
518 * this code could throw an exception and the fontpath would fail to |
519 * be initialised. |
519 * be initialised. |
520 */ |
520 */ |
521 #ifndef HEADLESS |
521 #ifndef HEADLESS |
|
522 if (isX11) { // The following only works in an x11 environment. |
522 #if defined(__linux__) |
523 #if defined(__linux__) |
523 /* There's no headless build on linux ... */ |
524 /* There's no headless build on linux ... */ |
524 if (!AWTIsHeadless()) { /* .. so need to call a function to check */ |
525 if (!AWTIsHeadless()) { /* .. so need to call a function to check */ |
525 #endif |
526 #endif |
526 /* Using the X11 font path to locate font files is now a fallback |
527 /* Using the X11 font path to locate font files is now a fallback |
536 } |
537 } |
537 AWT_UNLOCK(); |
538 AWT_UNLOCK(); |
538 #if defined(__linux__) |
539 #if defined(__linux__) |
539 } |
540 } |
540 #endif |
541 #endif |
|
542 } |
541 #endif /* !HEADLESS */ |
543 #endif /* !HEADLESS */ |
542 path = mergePaths(fcdirs, x11dirs, knowndirs, noType1); |
544 path = mergePaths(fcdirs, x11dirs, knowndirs, noType1); |
543 if (fcdirs != NULL) { |
545 if (fcdirs != NULL) { |
544 char **p = fcdirs; |
546 char **p = fcdirs; |
545 while (*p != NULL) free(*p++); |
547 while (*p != NULL) free(*p++); |
553 } |
555 } |
554 |
556 |
555 return path; |
557 return path; |
556 } |
558 } |
557 |
559 |
558 JNIEXPORT jstring JNICALL Java_sun_awt_X11FontManager_getFontPathNative |
560 JNIEXPORT jstring JNICALL Java_sun_awt_FcFontManager_getFontPathNative |
559 (JNIEnv *env, jobject thiz, jboolean noType1) { |
561 (JNIEnv *env, jobject thiz, jboolean noType1, jboolean isX11) { |
560 jstring ret; |
562 jstring ret; |
561 static char *ptr = NULL; /* retain result across calls */ |
563 static char *ptr = NULL; /* retain result across calls */ |
562 |
564 |
563 if (ptr == NULL) { |
565 if (ptr == NULL) { |
564 ptr = getPlatformFontPathChars(env, noType1); |
566 ptr = getPlatformFontPathChars(env, noType1, isX11); |
565 } |
567 } |
566 ret = (*env)->NewStringUTF(env, ptr); |
568 ret = (*env)->NewStringUTF(env, ptr); |
567 return ret; |
569 return ret; |
568 } |
570 } |
569 |
571 |