@Override protected String[] getDefaultPlatformFont() { final String[] info = new String[2]; getFontConfigManager().initFontConfigFonts(false); FontConfigManager.FcCompFont[] fontConfigFonts = getFontConfigManager().getFontConfigFonts(); for (int i=0; i<fontConfigFonts.length; i++) { if ("sans".equals(fontConfigFonts[i].fcFamily) && 0 == fontConfigFonts[i].style) { info[0] = fontConfigFonts[i].firstFont.familyName; info[1] = fontConfigFonts[i].firstFont.fontFile; break; } } /* Absolute last ditch attempt in the face of fontconfig problems. * If we didn't match, pick the first, or just make something * up so we don't NPE. */ if (info[0] == null) { if (fontConfigFonts.length > 0 && fontConfigFonts[0].firstFont.fontFile != null) { info[0] = fontConfigFonts[0].firstFont.familyName; info[1] = fontConfigFonts[0].firstFont.fontFile; } else { info[0] = "Dialog"; info[1] = "/dialog.ttf"; } } return info; }
/** * Initializes XAWTXSettings if a property for a given property name is provided by * XSettings and they are not initialized yet. * * @return true if the method has initialized XAWTXSettings. */ private boolean initXSettingsIfNeeded(final String propName) { if (!loadedXSettings && (propName.startsWith("gnome.") || propName.equals(SunToolkit.DESKTOPFONTHINTS) || propName.startsWith(dndPrefix))) { loadedXSettings = true; if (!GraphicsEnvironment.isHeadless()) { loadXSettings(); /* If no desktop font hint could be retrieved, check for * KDE running KWin and retrieve settings from fontconfig. * If that isn't found let SunToolkit will see if there's a * system property set by a user. */ if (desktopProperties.get(SunToolkit.DESKTOPFONTHINTS) == null) { if (XWM.isKDE2()) { Object hint = FontConfigManager.getFontConfigAAHint(); if (hint != null) { /* set the fontconfig/KDE property so that * getDesktopHints() below will see it * and set the public property. */ desktopProperties.put(UNIXToolkit.FONTCONFIGAAHINT, hint); } } desktopProperties.put(SunToolkit.DESKTOPFONTHINTS, SunToolkit.getDesktopFontHints()); } return true; } } return false; }
public String[] getDefaultPlatformFont() { if (defaultPlatformFont != null) { return defaultPlatformFont; } String[] info = new String[2]; getFontConfigManager().initFontConfigFonts(false); FontConfigManager.FcCompFont[] fontConfigFonts = getFontConfigManager().getFontConfigFonts(); for (int i=0; i<fontConfigFonts.length; i++) { if ("sans".equals(fontConfigFonts[i].fcFamily) && 0 == fontConfigFonts[i].style) { info[0] = fontConfigFonts[i].firstFont.familyName; info[1] = fontConfigFonts[i].firstFont.fontFile; break; } } /* Absolute last ditch attempt in the face of fontconfig problems. * If we didn't match, pick the first, or just make something * up so we don't NPE. */ if (info[0] == null) { if (fontConfigFonts.length > 0 && fontConfigFonts[0].firstFont.fontFile != null) { info[0] = fontConfigFonts[0].firstFont.familyName; info[1] = fontConfigFonts[0].firstFont.fontFile; } else { info[0] = "Dialog"; info[1] = "/dialog.ttf"; } } defaultPlatformFont = info; return defaultPlatformFont; }