< prev index next >

src/java.desktop/share/classes/sun/font/SunFontManager.java

Print this page
rev 59961 : 8248468: java/awt/font/DefaultFontTest/DefaultFontTest.java fails in SunFontManager.findFont2D


 336                  * corresponds may be found as we don't have a way to
 337                  * handle two fonts of the same name, so the JRE one
 338                  * must be the first one registered. Pass "true" to
 339                  * registerFonts method as on-screen these JRE fonts
 340                  * always go through the JDK rasteriser.
 341                  */
 342                 if (FontUtilities.isLinux) {
 343                     /* Linux font configuration uses these fonts */
 344                     registerFontDir(jreFontDirName);
 345                 }
 346                 registerFontsInDir(jreFontDirName, true, Font2D.JRE_RANK,
 347                                    true, false);
 348 
 349                 /* Create the font configuration and get any font path
 350                  * that might be specified.
 351                  */
 352                 fontConfig = createFontConfiguration();
 353 
 354                 String[] fontInfo = getDefaultPlatformFont();
 355                 defaultFontName = fontInfo[0];



 356                 defaultFontFileName = fontInfo[1];
 357 
 358                 String extraFontPath = fontConfig.getExtraFontPath();
 359 
 360                 /* In prior releases the debugging font path replaced
 361                  * all normally located font directories except for the
 362                  * JRE fonts dir. This directory is still always located
 363                  * and placed at the head of the path but as an
 364                  * augmentation to the previous behaviour the
 365                  * changes below allow you to additionally append to
 366                  * the font path by starting with append: or prepend by
 367                  * starting with a prepend: sign. Eg: to append
 368                  * -Dsun.java2d.fontpath=append:/usr/local/myfonts
 369                  * and to prepend
 370                  * -Dsun.java2d.fontpath=prepend:/usr/local/myfonts Disp
 371                  *
 372                  * If there is an appendedfontpath it in the font
 373                  * configuration it is used instead of searching the
 374                  * system for dirs.
 375                  * The behaviour of append and prepend is then similar


1871         if (fontFamily != null) {
1872             font = fontFamily.getFont(style);
1873             if (font == null) {
1874                 font = fontFamily.getClosestStyle(style);
1875             }
1876         }
1877         return font;
1878     }
1879 
1880     private ConcurrentHashMap<String, Font2D> fontNameCache =
1881         new ConcurrentHashMap<>();
1882 
1883     /*
1884      * The client supplies a name and a style.
1885      * The name could be a family name, or a full name.
1886      * A font may exist with the specified style, or it may
1887      * exist only in some other style. For non-native fonts the scaler
1888      * may be able to emulate the required style.
1889      */
1890     public Font2D findFont2D(String name, int style, int fallback) {

1891         String lowerCaseName = name.toLowerCase(Locale.ENGLISH);
1892         String mapName = lowerCaseName + dotStyleStr(style);
1893 
1894         /* If preferLocaleFonts() or preferProportionalFonts() has been
1895          * called we may be using an alternate set of composite fonts in this
1896          * app context. The presence of a pre-built name map indicates whether
1897          * this is so, and gives access to the alternate composite for the
1898          * name.
1899          */
1900         Font2D font = fontNameCache.get(mapName);
1901         if (font != null) {
1902             return font;
1903         }
1904 
1905         if (FontUtilities.isLogging()) {
1906             FontUtilities.getLogger().info("Search for font: " + name);
1907         }
1908 
1909         // The check below is just so that the bitmap fonts being set by
1910         // AWT and Swing thru the desktop properties do not trigger the




 336                  * corresponds may be found as we don't have a way to
 337                  * handle two fonts of the same name, so the JRE one
 338                  * must be the first one registered. Pass "true" to
 339                  * registerFonts method as on-screen these JRE fonts
 340                  * always go through the JDK rasteriser.
 341                  */
 342                 if (FontUtilities.isLinux) {
 343                     /* Linux font configuration uses these fonts */
 344                     registerFontDir(jreFontDirName);
 345                 }
 346                 registerFontsInDir(jreFontDirName, true, Font2D.JRE_RANK,
 347                                    true, false);
 348 
 349                 /* Create the font configuration and get any font path
 350                  * that might be specified.
 351                  */
 352                 fontConfig = createFontConfiguration();
 353 
 354                 String[] fontInfo = getDefaultPlatformFont();
 355                 defaultFontName = fontInfo[0];
 356                 if (defaultFontName == null && FontUtilities.debugFonts()) {
 357                     FontUtilities.getLogger().warning("defaultFontName is null");
 358                 }
 359                 defaultFontFileName = fontInfo[1];
 360 
 361                 String extraFontPath = fontConfig.getExtraFontPath();
 362 
 363                 /* In prior releases the debugging font path replaced
 364                  * all normally located font directories except for the
 365                  * JRE fonts dir. This directory is still always located
 366                  * and placed at the head of the path but as an
 367                  * augmentation to the previous behaviour the
 368                  * changes below allow you to additionally append to
 369                  * the font path by starting with append: or prepend by
 370                  * starting with a prepend: sign. Eg: to append
 371                  * -Dsun.java2d.fontpath=append:/usr/local/myfonts
 372                  * and to prepend
 373                  * -Dsun.java2d.fontpath=prepend:/usr/local/myfonts Disp
 374                  *
 375                  * If there is an appendedfontpath it in the font
 376                  * configuration it is used instead of searching the
 377                  * system for dirs.
 378                  * The behaviour of append and prepend is then similar


1874         if (fontFamily != null) {
1875             font = fontFamily.getFont(style);
1876             if (font == null) {
1877                 font = fontFamily.getClosestStyle(style);
1878             }
1879         }
1880         return font;
1881     }
1882 
1883     private ConcurrentHashMap<String, Font2D> fontNameCache =
1884         new ConcurrentHashMap<>();
1885 
1886     /*
1887      * The client supplies a name and a style.
1888      * The name could be a family name, or a full name.
1889      * A font may exist with the specified style, or it may
1890      * exist only in some other style. For non-native fonts the scaler
1891      * may be able to emulate the required style.
1892      */
1893     public Font2D findFont2D(String name, int style, int fallback) {
1894         if (name == null) return null;
1895         String lowerCaseName = name.toLowerCase(Locale.ENGLISH);
1896         String mapName = lowerCaseName + dotStyleStr(style);
1897 
1898         /* If preferLocaleFonts() or preferProportionalFonts() has been
1899          * called we may be using an alternate set of composite fonts in this
1900          * app context. The presence of a pre-built name map indicates whether
1901          * this is so, and gives access to the alternate composite for the
1902          * name.
1903          */
1904         Font2D font = fontNameCache.get(mapName);
1905         if (font != null) {
1906             return font;
1907         }
1908 
1909         if (FontUtilities.isLogging()) {
1910             FontUtilities.getLogger().info("Search for font: " + name);
1911         }
1912 
1913         // The check below is just so that the bitmap fonts being set by
1914         // AWT and Swing thru the desktop properties do not trigger the


< prev index next >