src/solaris/classes/sun/font/FcFontConfiguration.java

Print this page
rev 1379 : [mq]: fontmanager.patch

*** 39,53 **** import java.util.Properties; import java.util.Scanner; import sun.awt.FontConfiguration; import sun.awt.FontDescriptor; import sun.awt.SunToolkit; import sun.font.CompositeFontDescriptor; import sun.font.FontManager; ! import sun.font.FontManager.FontConfigInfo; ! import sun.font.FontManager.FcCompFont; ! import sun.font.FontManager.FontConfigFont; import sun.java2d.SunGraphicsEnvironment; public class FcFontConfiguration extends FontConfiguration { /** Version of the cache file format understood by this code. --- 39,54 ---- import java.util.Properties; import java.util.Scanner; import sun.awt.FontConfiguration; import sun.awt.FontDescriptor; import sun.awt.SunToolkit; + import sun.awt.X11FontManager; import sun.font.CompositeFontDescriptor; import sun.font.FontManager; ! import sun.font.FontConfigManager.FontConfigInfo; ! import sun.font.FontConfigManager.FcCompFont; ! import sun.font.FontConfigManager.FontConfigFont; import sun.java2d.SunGraphicsEnvironment; public class FcFontConfiguration extends FontConfiguration { /** Version of the cache file format understood by this code.
*** 66,85 **** private static final String fileVersion = "1"; private String fcInfoFileName = null; private FcCompFont[] fcCompFonts = null; ! public FcFontConfiguration(SunGraphicsEnvironment environment) { ! super(environment); init(); } /* This isn't called but is needed to satisfy super-class contract. */ ! public FcFontConfiguration(SunGraphicsEnvironment environment, boolean preferLocaleFonts, boolean preferPropFonts) { ! super(environment, preferLocaleFonts, preferPropFonts); init(); } @Override public synchronized boolean init() { --- 67,86 ---- private static final String fileVersion = "1"; private String fcInfoFileName = null; private FcCompFont[] fcCompFonts = null; ! public FcFontConfiguration(SunFontManager fm) { ! super(fm); init(); } /* This isn't called but is needed to satisfy super-class contract. */ ! public FcFontConfiguration(SunFontManager fm, boolean preferLocaleFonts, boolean preferPropFonts) { ! super(fm, preferLocaleFonts, preferPropFonts); init(); } @Override public synchronized boolean init() {
*** 87,114 **** return true; } setFontConfiguration(); readFcInfo(); if (fcCompFonts == null) { ! fcCompFonts = FontManager.loadFontConfig(); if (fcCompFonts != null) { try { writeFcInfo(); } catch (Exception e) { ! if (SunGraphicsEnvironment.debugFonts) { Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); logger.warning("Exception writing fcInfo " + e); } } ! } else if (SunGraphicsEnvironment.debugFonts) { Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); logger.warning("Failed to get info from libfontconfig"); } } else { ! FontManager.populateFontConfig(fcCompFonts); } if (fcCompFonts == null) { return false; // couldn't load fontconfig. } --- 88,117 ---- return true; } setFontConfiguration(); readFcInfo(); + X11FontManager fm = X11FontManager.getInstance(); + FontConfigManager fcm = fm.getFontConfigManager(); if (fcCompFonts == null) { ! fcCompFonts = fcm.loadFontConfig(); if (fcCompFonts != null) { try { writeFcInfo(); } catch (Exception e) { ! if (FontUtilities.debugFonts()) { Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); logger.warning("Exception writing fcInfo " + e); } } ! } else if (FontUtilities.debugFonts()) { Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); logger.warning("Failed to get info from libfontconfig"); } } else { ! fcm.populateFontConfig(fcCompFonts); } if (fcCompFonts == null) { return false; // couldn't load fontconfig. }
*** 182,192 **** } @Override public String[] getPlatformFontNames() { HashSet<String> nameSet = new HashSet<String>(); ! FcCompFont[] fcCompFonts = FontManager.loadFontConfig(); for (int i=0; i<fcCompFonts.length; i++) { for (int j=0; j<fcCompFonts[i].allFonts.length; j++) { nameSet.add(fcCompFonts[i].allFonts[j].fontFile); } } --- 185,197 ---- } @Override public String[] getPlatformFontNames() { HashSet<String> nameSet = new HashSet<String>(); ! X11FontManager fm = X11FontManager.getInstance(); ! FontConfigManager fcm = fm.getFontConfigManager(); ! FcCompFont[] fcCompFonts = fcm.loadFontConfig(); for (int i=0; i<fcCompFonts.length; i++) { for (int j=0; j<fcCompFonts[i].allFonts.length; j++) { nameSet.add(fcCompFonts[i].allFonts[j].fontFile); } }
*** 221,231 **** } @Override public CompositeFontDescriptor[] get2DCompositeFontInfo() { ! FcCompFont[] fcCompFonts = FontManager.loadFontConfig(); CompositeFontDescriptor[] result = new CompositeFontDescriptor[NUM_FONTS * NUM_STYLES]; for (int fontIndex = 0; fontIndex < NUM_FONTS; fontIndex++) { --- 226,238 ---- } @Override public CompositeFontDescriptor[] get2DCompositeFontInfo() { ! X11FontManager fm = X11FontManager.getInstance(); ! FontConfigManager fcm = fm.getFontConfigManager(); ! FcCompFont[] fcCompFonts = fcm.loadFontConfig(); CompositeFontDescriptor[] result = new CompositeFontDescriptor[NUM_FONTS * NUM_STYLES]; for (int fontIndex = 0; fontIndex < NUM_FONTS; fontIndex++) {
*** 319,329 **** } else if ((f = new File("/etc/sun-release")).canRead()) { osName = "Sun"; osVersion = getVersionString(f); } } catch (Exception e) { ! if (SunGraphicsEnvironment.debugFonts) { Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); logger.warning("Exception identifying Linux distro."); } } } --- 326,336 ---- } else if ((f = new File("/etc/sun-release")).canRead()) { osName = "Sun"; osVersion = getVersionString(f); } } catch (Exception e) { ! if (FontUtilities.debugFonts()) { Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); logger.warning("Exception identifying Linux distro."); } } }
*** 354,364 **** } private void writeFcInfo() { Properties props = new Properties(); props.setProperty("version", fileVersion); ! FontConfigInfo fcInfo = FontManager.getFontConfigInfo(); props.setProperty("fcversion", Integer.toString(fcInfo.fcVersion)); if (fcInfo.cacheDirs != null) { for (int i=0;i<fcInfo.cacheDirs.length;i++) { if (fcInfo.cacheDirs[i] != null) { props.setProperty("cachedir."+i, fcInfo.cacheDirs[i]); --- 361,373 ---- } private void writeFcInfo() { Properties props = new Properties(); props.setProperty("version", fileVersion); ! X11FontManager fm = X11FontManager.getInstance(); ! FontConfigManager fcm = fm.getFontConfigManager(); ! FontConfigInfo fcInfo = fcm.getFontConfigInfo(); props.setProperty("fcversion", Integer.toString(fcInfo.fcVersion)); if (fcInfo.cacheDirs != null) { for (int i=0;i<fcInfo.cacheDirs.length;i++) { if (fcInfo.cacheDirs[i] != null) { props.setProperty("cachedir."+i, fcInfo.cacheDirs[i]);
*** 389,405 **** FileOutputStream fos = new FileOutputStream(tempFile); props.store(fos, "JDK Font Configuration Generated File: *Do Not Edit*"); fos.close(); boolean renamed = tempFile.renameTo(fcInfoFile); ! if (!renamed && SunGraphicsEnvironment.debugFonts) { System.out.println("rename failed"); Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); logger.warning("Failed renaming file to "+ getFcInfoFile()); } } catch (Exception e) { ! if (SunGraphicsEnvironment.debugFonts) { Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); logger.warning("IOException writing to "+ getFcInfoFile()); } } } --- 398,414 ---- FileOutputStream fos = new FileOutputStream(tempFile); props.store(fos, "JDK Font Configuration Generated File: *Do Not Edit*"); fos.close(); boolean renamed = tempFile.renameTo(fcInfoFile); ! if (!renamed && FontUtilities.debugFonts()) { System.out.println("rename failed"); Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); logger.warning("Failed renaming file to "+ getFcInfoFile()); } } catch (Exception e) { ! if (FontUtilities.debugFonts()) { Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); logger.warning("IOException writing to "+ getFcInfoFile()); } } }
*** 413,428 **** File fcFile = getFcInfoFile(); if (!fcFile.exists()) { return; } Properties props = new Properties(); try { FileInputStream fis = new FileInputStream(fcFile); props.load(fis); fis.close(); } catch (IOException e) { ! if (SunGraphicsEnvironment.debugFonts) { Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); logger.warning("IOException reading from "+fcFile.toString()); } return; } --- 422,439 ---- File fcFile = getFcInfoFile(); if (!fcFile.exists()) { return; } Properties props = new Properties(); + X11FontManager fm = X11FontManager.getInstance(); + FontConfigManager fcm = fm.getFontConfigManager(); try { FileInputStream fis = new FileInputStream(fcFile); props.load(fis); fis.close(); } catch (IOException e) { ! if (FontUtilities.debugFonts()) { Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); logger.warning("IOException reading from "+fcFile.toString()); } return; }
*** 437,451 **** if (fcVersionStr != null) { int fcVersion; try { fcVersion = Integer.parseInt(fcVersionStr); if (fcVersion != 0 && ! fcVersion != FontManager.getFontConfigVersion()) { return; } } catch (Exception e) { ! if (SunGraphicsEnvironment.debugFonts) { Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); logger.warning("Exception parsing version " + fcVersionStr); } --- 448,462 ---- if (fcVersionStr != null) { int fcVersion; try { fcVersion = Integer.parseInt(fcVersionStr); if (fcVersion != 0 && ! fcVersion != fcm.getFontConfigVersion()) { return; } } catch (Exception e) { ! if (FontUtilities.debugFonts()) { Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); logger.warning("Exception parsing version " + fcVersionStr); }
*** 507,517 **** } } fcCompFonts = fci; } catch (Throwable t) { ! if (SunGraphicsEnvironment.debugFonts) { Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); logger.warning(t.toString()); } } } --- 518,528 ---- } } fcCompFonts = fci; } catch (Throwable t) { ! if (FontUtilities.debugFonts()) { Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); logger.warning(t.toString()); } } }