423 fontPath = dbgFontPath;
424 }
425 registerFontDirs(fontPath);
426 } else if (extraFontPath != null) {
427 /* If the font configuration contains an
428 * "appendedfontpath" entry, it is interpreted as a
429 * set of locations that should always be registered.
430 * It may be additional to locations normally found
431 * for that place, or it may be locations that need
432 * to have all their paths registered to locate all
433 * the needed platform names.
434 * This is typically when the same .TTF file is
435 * referenced from multiple font.dir files and all
436 * of these must be read to find all the native
437 * (XLFD) names for the font, so that X11 font APIs
438 * can be used for as many code points as possible.
439 */
440 registerFontDirs(extraFontPath);
441 }
442
443 /* On Solaris, we need to register the Japanese TrueType
444 * directory so that we can find the corresponding
445 * bitmap fonts. This could be done by listing the
446 * directory in the font configuration file, but we
447 * don't want to confuse users with this quirk. There
448 * are no bitmap fonts for other writing systems that
449 * correspond to TrueType fonts and have matching XLFDs.
450 * We need to register the bitmap fonts only in
451 * environments where they're on the X font path, i.e.,
452 * in the Japanese locale. Note that if the X Toolkit
453 * is in use the font path isn't set up by JDK, but
454 * users of a JA locale should have it
455 * set up already by their login environment.
456 */
457 if (FontUtilities.isSolaris && Locale.JAPAN.equals(Locale.getDefault())) {
458 registerFontDir("/usr/openwin/lib/locale/ja/X11/fonts/TT");
459 }
460
461 initCompositeFonts(fontConfig, null);
462
463 return null;
464 }
465 });
466
467 boolean platformFont = AccessController.doPrivileged(
468 new PrivilegedAction<Boolean>() {
469 public Boolean run() {
470 String prop = System.getProperty("java2d.font.usePlatformFont");
471 String env = System.getenv("JAVA2D_USEPLATFORMFONT");
472 return "true".equals(prop) || env != null;
473 }
474 });
475
476 if (platformFont) {
477 usePlatformFontMetrics = true;
478 System.out.println("Enabling platform font metrics for win32. This is an unsupported option.");
479 System.out.println("This yields incorrect composite font metrics as reported by 1.1.x releases.");
480 System.out.println("It is appropriate only for use by applications which do not use any Java 2");
2067 }
2068
2069 /* If reach here and no match has been located, then if there are
2070 * uninitialised deferred fonts, load as many of those as needed
2071 * to find the deferred font. If none is found through that
2072 * search continue on.
2073 * There is possibly a minor issue when more than one
2074 * deferred font implements the same font face. Since deferred
2075 * fonts are only those in font configuration files, this is a
2076 * controlled situation, the known case being Solaris euro_fonts
2077 * versions of Arial, Times New Roman, Courier New. However
2078 * the larger font will transparently replace the smaller one
2079 * - see addToFontList() - when it is needed by the composite font.
2080 */
2081 if (deferredFontFiles.size() > 0) {
2082 font = findDeferredFont(name, style);
2083 if (font != null) {
2084 fontNameCache.put(mapName, font);
2085 return font;
2086 }
2087 }
2088
2089 /* Some apps use deprecated 1.0 names such as helvetica and courier. On
2090 * Solaris these are Type1 fonts in /usr/openwin/lib/X11/fonts/Type1.
2091 * If running on Solaris will register all the fonts in this
2092 * directory.
2093 * May as well register the whole directory without actually testing
2094 * the font name is one of the deprecated names as the next step would
2095 * load all fonts which are in this directory anyway.
2096 * In the event that this lookup is successful it potentially "hides"
2097 * TrueType versions of such fonts that are elsewhere but since they
2098 * do not exist on Solaris this is not a problem.
2099 * Set a flag to indicate we've done this registration to avoid
2100 * repetition and more seriously, to avoid recursion.
2101 */
2102 if (FontUtilities.isSolaris &&!loaded1dot0Fonts) {
2103 /* "timesroman" is a special case since that's not the
2104 * name of any known font on Solaris or elsewhere.
2105 */
2106 if (lowerCaseName.equals("timesroman")) {
2107 font = findFont2D("serif", style, fallback);
2108 fontNameCache.put(mapName, font);
2109 }
2110 register1dot0Fonts();
2111 loaded1dot0Fonts = true;
2112 Font2D ff = findFont2D(name, style, fallback);
2113 return ff;
2114 }
2115
2116 /* We check for application registered fonts before
2117 * explicitly loading all fonts as if necessary the registration
2118 * code will have done so anyway. And we don't want to needlessly
2119 * load the actual files for all fonts.
2120 * Just as for installed fonts we check for family before fullname.
2121 * We do not add these fonts to fontNameCache for the
2122 * app context case which eliminates the overhead of a per context
2123 * cache for these.
2124 */
2125
2126 if (fontsAreRegistered) {
2127 Hashtable<String, FontFamily> familyTable = createdByFamilyName;
2128 Hashtable<String, Font2D> nameTable = createdByFullName;
2129
2130 family = familyTable.get(lowerCaseName);
2131 if (family != null) {
2132 font = family.getFontWithExactStyleMatch(style);
2133 if (font == null) {
|
423 fontPath = dbgFontPath;
424 }
425 registerFontDirs(fontPath);
426 } else if (extraFontPath != null) {
427 /* If the font configuration contains an
428 * "appendedfontpath" entry, it is interpreted as a
429 * set of locations that should always be registered.
430 * It may be additional to locations normally found
431 * for that place, or it may be locations that need
432 * to have all their paths registered to locate all
433 * the needed platform names.
434 * This is typically when the same .TTF file is
435 * referenced from multiple font.dir files and all
436 * of these must be read to find all the native
437 * (XLFD) names for the font, so that X11 font APIs
438 * can be used for as many code points as possible.
439 */
440 registerFontDirs(extraFontPath);
441 }
442
443 initCompositeFonts(fontConfig, null);
444
445 return null;
446 }
447 });
448
449 boolean platformFont = AccessController.doPrivileged(
450 new PrivilegedAction<Boolean>() {
451 public Boolean run() {
452 String prop = System.getProperty("java2d.font.usePlatformFont");
453 String env = System.getenv("JAVA2D_USEPLATFORMFONT");
454 return "true".equals(prop) || env != null;
455 }
456 });
457
458 if (platformFont) {
459 usePlatformFontMetrics = true;
460 System.out.println("Enabling platform font metrics for win32. This is an unsupported option.");
461 System.out.println("This yields incorrect composite font metrics as reported by 1.1.x releases.");
462 System.out.println("It is appropriate only for use by applications which do not use any Java 2");
2049 }
2050
2051 /* If reach here and no match has been located, then if there are
2052 * uninitialised deferred fonts, load as many of those as needed
2053 * to find the deferred font. If none is found through that
2054 * search continue on.
2055 * There is possibly a minor issue when more than one
2056 * deferred font implements the same font face. Since deferred
2057 * fonts are only those in font configuration files, this is a
2058 * controlled situation, the known case being Solaris euro_fonts
2059 * versions of Arial, Times New Roman, Courier New. However
2060 * the larger font will transparently replace the smaller one
2061 * - see addToFontList() - when it is needed by the composite font.
2062 */
2063 if (deferredFontFiles.size() > 0) {
2064 font = findDeferredFont(name, style);
2065 if (font != null) {
2066 fontNameCache.put(mapName, font);
2067 return font;
2068 }
2069 }
2070
2071 /* We check for application registered fonts before
2072 * explicitly loading all fonts as if necessary the registration
2073 * code will have done so anyway. And we don't want to needlessly
2074 * load the actual files for all fonts.
2075 * Just as for installed fonts we check for family before fullname.
2076 * We do not add these fonts to fontNameCache for the
2077 * app context case which eliminates the overhead of a per context
2078 * cache for these.
2079 */
2080
2081 if (fontsAreRegistered) {
2082 Hashtable<String, FontFamily> familyTable = createdByFamilyName;
2083 Hashtable<String, Font2D> nameTable = createdByFullName;
2084
2085 family = familyTable.get(lowerCaseName);
2086 if (family != null) {
2087 font = family.getFontWithExactStyleMatch(style);
2088 if (font == null) {
|