725 } 726 } 727 728 @Override 729 protected void registerPlatformFontsUsedByFontConfiguration() { 730 // Lazily initialize fontConfigDirs. 731 getPlatformFontPathFromFontConfig(); 732 if (fontConfigDirs == null) { 733 return; 734 } 735 if (FontUtilities.isLinux) { 736 fontConfigDirs.add(jreLibDirName+File.separator+"oblique-fonts"); 737 } 738 fontdirs = fontConfigDirs.toArray(new String[0]); 739 } 740 741 // Implements SunGraphicsEnvironment.createFontConfiguration. 742 protected FontConfiguration createFontConfiguration() { 743 /* The logic here decides whether to use a preconfigured 744 * fontconfig.properties file, or synthesise one using platform APIs. 745 * On Solaris (as opposed to OpenSolaris) we try to use the 746 * pre-configured ones, but if the files it specifies are missing 747 * we fail-safe to synthesising one. This might happen if Solaris 748 * changes its fonts. 749 * For OpenSolaris I don't expect us to ever create fontconfig files, 750 * so it will always synthesise. Note that if we misidentify 751 * OpenSolaris as Solaris, then the test for the presence of 752 * Solaris-only font files will correct this. 753 * For Linux we require an exact match of distro and version to 754 * use the preconfigured file, and also that it points to 755 * existent fonts. 756 * If synthesising fails, we fall back to any preconfigured file 757 * and do the best we can. For the commercial JDK this will be 758 * fine as it includes the Lucida fonts. OpenJDK should not hit 759 * this as the synthesis should always work on its platforms. 760 */ 761 FontConfiguration mFontConfig = new MFontConfiguration(this); 762 if (FontUtilities.isOpenSolaris || 763 (FontUtilities.isLinux && 764 (!mFontConfig.foundOsSpecificFile() || 765 !mFontConfig.fontFilesArePresent()) || 766 (FontUtilities.isSolaris && !mFontConfig.fontFilesArePresent()))) { 767 FcFontConfiguration fcFontConfig = 768 new FcFontConfiguration(this); 769 if (fcFontConfig.init()) { 770 return fcFontConfig; 771 } 772 } 773 mFontConfig.init(); 774 return mFontConfig; 775 } 776 public FontConfiguration 777 createFontConfiguration(boolean preferLocaleFonts, 778 boolean preferPropFonts) { 779 780 return new MFontConfiguration(this, 781 preferLocaleFonts, preferPropFonts); 782 } 783 784 protected synchronized String getFontPath(boolean noType1Fonts) { 785 isHeadless(); // make sure GE is inited, as its the X11 lock. 786 return getFontPathNative(noType1Fonts, true); 787 } 788 789 @Override 790 protected FontUIResource getFontConfigFUIR(String family, int style, int size) { 791 792 CompositeFont font2D = getFontConfigManager().getFontConfigFont(family, style); 793 794 if (font2D == null) { // Not expected, just a precaution. 795 return new FontUIResource(family, style, size); | 725 } 726 } 727 728 @Override 729 protected void registerPlatformFontsUsedByFontConfiguration() { 730 // Lazily initialize fontConfigDirs. 731 getPlatformFontPathFromFontConfig(); 732 if (fontConfigDirs == null) { 733 return; 734 } 735 if (FontUtilities.isLinux) { 736 fontConfigDirs.add(jreLibDirName+File.separator+"oblique-fonts"); 737 } 738 fontdirs = fontConfigDirs.toArray(new String[0]); 739 } 740 741 // Implements SunGraphicsEnvironment.createFontConfiguration. 742 protected FontConfiguration createFontConfiguration() { 743 /* The logic here decides whether to use a preconfigured 744 * fontconfig.properties file, or synthesise one using platform APIs. 745 * On Solaris we try to use the 746 * pre-configured ones, but if the files it specifies are missing 747 * we fail-safe to synthesising one. This might happen if Solaris 748 * changes its fonts. 749 * For Linux we require an exact match of distro and version to 750 * use the preconfigured file. 751 * If synthesising fails, we fall back to any preconfigured file 752 * and do the best we can. For the commercial JDK this will be 753 * fine as it includes the Lucida fonts. OpenJDK should not hit 754 * this as the synthesis should always work on its platforms. 755 */ 756 FontConfiguration mFontConfig = new MFontConfiguration(this); 757 if ((FontUtilities.isLinux && !mFontConfig.foundOsSpecificFile()) || 758 (FontUtilities.isSolaris && !mFontConfig.fontFilesArePresent())) { 759 FcFontConfiguration fcFontConfig = 760 new FcFontConfiguration(this); 761 if (fcFontConfig.init()) { 762 return fcFontConfig; 763 } 764 } 765 mFontConfig.init(); 766 return mFontConfig; 767 } 768 769 public FontConfiguration 770 createFontConfiguration(boolean preferLocaleFonts, 771 boolean preferPropFonts) { 772 773 return new MFontConfiguration(this, 774 preferLocaleFonts, preferPropFonts); 775 } 776 777 protected synchronized String getFontPath(boolean noType1Fonts) { 778 isHeadless(); // make sure GE is inited, as its the X11 lock. 779 return getFontPathNative(noType1Fonts, true); 780 } 781 782 @Override 783 protected FontUIResource getFontConfigFUIR(String family, int style, int size) { 784 785 CompositeFont font2D = getFontConfigManager().getFontConfigFont(family, style); 786 787 if (font2D == null) { // Not expected, just a precaution. 788 return new FontUIResource(family, style, size); |