@NotNull private static FontInfo doGetFontAbleToDisplay( int codePoint, int size, @JdkConstants.FontStyle int style) { synchronized (lock) { if (ourUndisplayableChars.contains(codePoint)) return ourSharedDefaultFont; final Collection<FontInfo> descriptors = ourUsedFonts.values(); for (FontInfo font : descriptors) { if (font.getSize() == size && font.getStyle() == style && font.canDisplay(codePoint)) { return font; } } for (int i = 0; i < ourFontNames.size(); i++) { String name = ourFontNames.get(i); FontInfo font = new FontInfo(name, size, style); if (font.canDisplay(codePoint)) { ourUsedFonts.put(new FontKey(name, size, style), font); ourFontNames.remove(i); return font; } } ourUndisplayableChars.add(codePoint); return ourSharedDefaultFont; } }
@Nullable private static FontInfo doGetFontAbleToDisplay( int codePoint, int size, @JdkConstants.FontStyle int originalStyle, @NotNull String defaultFontFamily) { synchronized (lock) { @JdkConstants.FontStyle int style = originalStyle; if (Patches.JDK_MAC_FONT_STYLE_DETECTION_WORKAROUND && style > 0 && style < 4) { Pair<String, Integer>[] replacement = ourStyledFontMap.get(defaultFontFamily); if (replacement != null) { defaultFontFamily = replacement[style].first; style = replacement[style].second; } } if (ourSharedKeyInstance.mySize == size && ourSharedKeyInstance.myStyle == style && ourSharedKeyInstance.myFamilyName != null && ourSharedKeyInstance.myFamilyName.equals(defaultFontFamily) && ourSharedDefaultFont != null && (codePoint < 128 || ourSharedDefaultFont.canDisplay(codePoint))) { return ourSharedDefaultFont; } ourSharedKeyInstance.myFamilyName = defaultFontFamily; ourSharedKeyInstance.mySize = size; ourSharedKeyInstance.myStyle = style; FontInfo defaultFont = ourUsedFonts.get(ourSharedKeyInstance); if (defaultFont == null) { defaultFont = new FontInfo(defaultFontFamily, size, style, originalStyle); ourUsedFonts.put(ourSharedKeyInstance, defaultFont); ourSharedKeyInstance = new FontKey("", 0, 0); } ourSharedDefaultFont = defaultFont; if (codePoint < 128 || defaultFont.canDisplay(codePoint)) { return defaultFont; } else { return null; } } }