src/solaris/classes/sun/awt/X11FontManager.java

Print this page
rev 9717 : 8039642: Fix raw and unchecked warnings in sun.awt.*
Reviewed-by:

*** 57,67 **** * We use this substring of a full XLFD because the font configuration files * define the XLFDs in a way that's easier to make into a request. * E.g., the -0-0-0-0-p-0- reported by X is -*-%d-*-*-p-*- in the font * configuration files. We need to remove that part for comparisons. */ ! private static Map fontNameMap = new HashMap(); /* * xlfdMap is a map from a platform path like * /usr/openwin/lib/locale/ja/X11/fonts/TT/HG-GothicB.ttf to an XLFD like * "-ricoh-hg gothic b-medium-r-normal--0-0-0-0-m-0-jisx0201.1976-0" --- 57,67 ---- * We use this substring of a full XLFD because the font configuration files * define the XLFDs in a way that's easier to make into a request. * E.g., the -0-0-0-0-p-0- reported by X is -*-%d-*-*-p-*- in the font * configuration files. We need to remove that part for comparisons. */ ! private static Map<String, String> fontNameMap = new HashMap<>(); /* * xlfdMap is a map from a platform path like * /usr/openwin/lib/locale/ja/X11/fonts/TT/HG-GothicB.ttf to an XLFD like * "-ricoh-hg gothic b-medium-r-normal--0-0-0-0-m-0-jisx0201.1976-0"
*** 70,80 **** * this map is always a vector where we store all the native names. * For fonts which we don't understand the key isn't a pathname, its * the full XLFD string like :- * "-ricoh-hg gothic b-medium-r-normal--0-0-0-0-m-0-jisx0201.1976-0" */ ! private static Map xlfdMap = new HashMap(); /* xFontDirsMap is also a map from a font ID to a font filepath. * The difference from fontNameMap is just that it does not have * resolved symbolic links. Normally this is not interesting except * that we need to know the directory in which a font was found to --- 70,80 ---- * this map is always a vector where we store all the native names. * For fonts which we don't understand the key isn't a pathname, its * the full XLFD string like :- * "-ricoh-hg gothic b-medium-r-normal--0-0-0-0-m-0-jisx0201.1976-0" */ ! private static Map<String, Vector<String>> xlfdMap = new HashMap<>(); /* xFontDirsMap is also a map from a font ID to a font filepath. * The difference from fontNameMap is just that it does not have * resolved symbolic links. Normally this is not interesting except * that we need to know the directory in which a font was found to
*** 86,96 **** * dir can be directly derived as its parent directory. * If a font is used by two XLFDs, each corresponding to a different * X11 font directory, then precautions must be taken to include both * directories. */ ! private static Map xFontDirsMap; /* * This is the set of font directories needed to be on the X font path * to enable AWT heavyweights to find all of the font configuration fonts. * It is populated by : --- 86,96 ---- * dir can be directly derived as its parent directory. * If a font is used by two XLFDs, each corresponding to a different * X11 font directory, then precautions must be taken to include both * directories. */ ! private static Map<String, String> xFontDirsMap; /* * This is the set of font directories needed to be on the X font path * to enable AWT heavyweights to find all of the font configuration fonts. * It is populated by :
*** 119,129 **** * same directory can then be skipped by checking this Map. * Access to this map is not synchronised here since creation * of the singleton GE instance is already synchronised and that is * the only code path that accesses this map. */ ! private static HashMap registeredDirs = new HashMap(); /* Array of directories to be added to the X11 font path. * Used by static method called from Toolkits which use X11 fonts. * Specifically this means MToolkit */ --- 119,129 ---- * same directory can then be skipped by checking this Map. * Access to this map is not synchronised here since creation * of the singleton GE instance is already synchronised and that is * the only code path that accesses this map. */ ! private static HashMap<String, Object> registeredDirs = new HashMap<>(); /* Array of directories to be added to the X11 font path. * Used by static method called from Toolkits which use X11 fonts. * Specifically this means MToolkit */
*** 181,202 **** * different directory. * * Add this XLFD (platform name) to the list of known * ones for this file. */ ! Vector xVal = (Vector) xlfdMap.get(fileName); if (xVal == null) { /* Try to be robust on Linux distros which move fonts * around by verifying that the fileName represents a * file that exists. If it doesn't, set it to null * to trigger a search. */ if (getFontConfiguration().needToSearchForFile(fileName)) { fileName = null; } if (fileName != null) { ! xVal = new Vector(); xVal.add(platName); xlfdMap.put(fileName, xVal); } } else { if (!xVal.contains(platName)) { --- 181,202 ---- * different directory. * * Add this XLFD (platform name) to the list of known * ones for this file. */ ! Vector<String> xVal = xlfdMap.get(fileName); if (xVal == null) { /* Try to be robust on Linux distros which move fonts * around by verifying that the fileName represents a * file that exists. If it doesn't, set it to null * to trigger a search. */ if (getFontConfiguration().needToSearchForFile(fileName)) { fileName = null; } if (fileName != null) { ! xVal = new Vector<>(); xVal.add(platName); xlfdMap.put(fileName, xVal); } } else { if (!xVal.contains(platName)) {
*** 209,219 **** return fileName; } } if (fontID != null) { ! fileName = (String)fontNameMap.get(fontID); /* On Linux check for the Lucida Oblique fonts */ if (fileName == null && FontUtilities.isLinux && !isOpenJDK()) { if (oblmap == null) { initObliqueLucidaFontMap(); } --- 209,219 ---- return fileName; } } if (fontID != null) { ! fileName = fontNameMap.get(fontID); /* On Linux check for the Lucida Oblique fonts */ if (fileName == null && FontUtilities.isLinux && !isOpenJDK()) { if (oblmap == null) { initObliqueLucidaFontMap(); }
*** 233,253 **** registerFontDirs(fontPath); if (FontUtilities.debugFonts()) { FontUtilities.getLogger() .warning("** Finished registering all font paths"); } ! fileName = (String)fontNameMap.get(fontID); } if (fileName == null && !isHeadless()) { /* Query X11 directly to see if this font is available * as a native font. */ fileName = getX11FontName(platName); } if (fileName == null) { fontID = switchFontIDForName(platName); ! fileName = (String)fontNameMap.get(fontID); } if (fileName != null) { fontNameMap.put(fontID, fileName); } } --- 233,253 ---- registerFontDirs(fontPath); if (FontUtilities.debugFonts()) { FontUtilities.getLogger() .warning("** Finished registering all font paths"); } ! fileName = fontNameMap.get(fontID); } if (fileName == null && !isHeadless()) { /* Query X11 directly to see if this font is available * as a native font. */ fileName = getX11FontName(platName); } if (fileName == null) { fontID = switchFontIDForName(platName); ! fileName = fontNameMap.get(fontID); } if (fileName != null) { fontNameMap.put(fontID, fileName); } }
*** 255,266 **** } @Override protected String[] getNativeNames(String fontFileName, String platformName) { ! Vector nativeNames; ! if ((nativeNames=(Vector)xlfdMap.get(fontFileName))==null) { if (platformName == null) { return null; } else { /* back-stop so that at least the name used in the * font configuration file is known as a native name --- 255,266 ---- } @Override protected String[] getNativeNames(String fontFileName, String platformName) { ! Vector<String> nativeNames; ! if ((nativeNames=xlfdMap.get(fontFileName))==null) { if (platformName == null) { return null; } else { /* back-stop so that at least the name used in the * font configuration file is known as a native name
*** 269,279 **** natNames[0] = platformName; return natNames; } } else { int len = nativeNames.size(); ! return (String[])nativeNames.toArray(new String[len]); } } /* NOTE: this method needs to be executed in a privileged context. * The superclass constructor which is the primary caller of --- 269,279 ---- natNames[0] = platformName; return natNames; } } else { int len = nativeNames.size(); ! return nativeNames.toArray(new String[len]); } } /* NOTE: this method needs to be executed in a privileged context. * The superclass constructor which is the primary caller of
*** 364,374 **** } fileName = fileName.substring(lastColon+1); } String fontPart = st.sval.substring(breakPos+1); String fontID = specificFontIDForName(fontPart); ! String sVal = (String) fontNameMap.get(fontID); if (FontUtilities.debugFonts()) { PlatformLogger logger = FontUtilities.getLogger(); logger.info("file=" + fileName + " xlfd=" + fontPart); --- 364,374 ---- } fileName = fileName.substring(lastColon+1); } String fontPart = st.sval.substring(breakPos+1); String fontID = specificFontIDForName(fontPart); ! String sVal = fontNameMap.get(fontID); if (FontUtilities.debugFonts()) { PlatformLogger logger = FontUtilities.getLogger(); logger.info("file=" + fileName + " xlfd=" + fontPart);
*** 384,401 **** * found to update the X server font path * for use by AWT heavyweights - and when 2D * wants to use the native rasteriser. */ if (xFontDirsMap == null) { ! xFontDirsMap = new HashMap(); } xFontDirsMap.put(fontID, path); fullPath = file.getCanonicalPath(); } catch (IOException e) { fullPath = path + File.separator + fileName; } ! Vector xVal = (Vector) xlfdMap.get(fullPath); if (FontUtilities.debugFonts()) { FontUtilities.getLogger() .info("fullPath=" + fullPath + " xVal=" + xVal); } --- 384,401 ---- * found to update the X server font path * for use by AWT heavyweights - and when 2D * wants to use the native rasteriser. */ if (xFontDirsMap == null) { ! xFontDirsMap = new HashMap<>(); } xFontDirsMap.put(fontID, path); fullPath = file.getCanonicalPath(); } catch (IOException e) { fullPath = path + File.separator + fileName; } ! Vector<String> xVal = xlfdMap.get(fullPath); if (FontUtilities.debugFonts()) { FontUtilities.getLogger() .info("fullPath=" + fullPath + " xVal=" + xVal); }
*** 406,416 **** .info("Map fontID:"+fontID + "to file:" + fullPath); } fontNameMap.put(fontID, fullPath); if (xVal == null) { ! xVal = new Vector(); xlfdMap.put (fullPath, xVal); } xVal.add(fontPart); } --- 406,416 ---- .info("Map fontID:"+fontID + "to file:" + fullPath); } fontNameMap.put(fontID, fullPath); if (xVal == null) { ! xVal = new Vector<>(); xlfdMap.put (fullPath, xVal); } xVal.add(fontPart); }
*** 445,456 **** * simply nulling out. * xFontDirsMap is a special case in that the implementation * will typically not ever need to initialise it so it can be null. */ xFontDirsMap = null; ! xlfdMap = new HashMap(1); ! fontNameMap = new HashMap(1); } private String getObliqueLucidaFontID(String fontID) { if (fontID.startsWith("-lucidasans-medium-i-normal") || fontID.startsWith("-lucidasans-bold-i-normal") || --- 445,456 ---- * simply nulling out. * xFontDirsMap is a special case in that the implementation * will typically not ever need to initialise it so it can be null. */ xFontDirsMap = null; ! xlfdMap = new HashMap<>(1); ! fontNameMap = new HashMap<>(1); } private String getObliqueLucidaFontID(String fontID) { if (fontID.startsWith("-lucidasans-medium-i-normal") || fontID.startsWith("-lucidasans-bold-i-normal") ||
*** 577,590 **** */ public String getFileNameFromXLFD(String name) { String fileName = null; String fontID = specificFontIDForName(name); if (fontID != null) { ! fileName = (String)fontNameMap.get(fontID); if (fileName == null) { fontID = switchFontIDForName(name); ! fileName = (String)fontNameMap.get(fontID); } if (fileName == null) { fileName = getDefaultFontFile(); } } --- 577,590 ---- */ public String getFileNameFromXLFD(String name) { String fileName = null; String fontID = specificFontIDForName(name); if (fontID != null) { ! fileName = fontNameMap.get(fontID); if (fileName == null) { fontID = switchFontIDForName(name); ! fileName = fontNameMap.get(fontID); } if (fileName == null) { fileName = getDefaultFontFile(); } }
*** 683,693 **** protected void addFontToPlatformFontPath(String platformName) { // Lazily initialize fontConfigDirs. getPlatformFontPathFromFontConfig(); if (xFontDirsMap != null) { String fontID = specificFontIDForName(platformName); ! String dirName = (String)xFontDirsMap.get(fontID); if (dirName != null) { fontConfigDirs.add(dirName); } } return; --- 683,693 ---- protected void addFontToPlatformFontPath(String platformName) { // Lazily initialize fontConfigDirs. getPlatformFontPathFromFontConfig(); if (xFontDirsMap != null) { String fontID = specificFontIDForName(platformName); ! String dirName = xFontDirsMap.get(fontID); if (dirName != null) { fontConfigDirs.add(dirName); } } return;