public void advance() { myCurrentFontFamilyName = myNextFontFamilyName; myCurrentStartOffset = myCurrentOffset; for (; myCurrentOffset < myEndOffset; myCurrentOffset++) { FontInfo fontInfo = ComplementaryFontsRegistry.getFontAbleToDisplay(myCharSequence.charAt(myCurrentOffset), myFontStyle, myFontPreferences); String fontFamilyName = fontInfo.getFont().getFamily(); if (myCurrentFontFamilyName == null) { myCurrentFontFamilyName = fontFamilyName; } else if (!myCurrentFontFamilyName.equals(fontFamilyName)) { myNextFontFamilyName = fontFamilyName; break; } } }
@Nullable Font getFontAbleToDisplay(LookupElementPresentation p) { String sampleString = p.getItemText() + p.getTailText() + p.getTypeText(); // assume a single font can display all lookup item chars Set<Font> fonts = ContainerUtil.newHashSet(); FontPreferences fontPreferences = myLookup.getFontPreferences(); for (int i = 0; i < sampleString.length(); i++) { fonts.add(ComplementaryFontsRegistry.getFontAbleToDisplay(sampleString.charAt(i), Font.PLAIN, fontPreferences, null).getFont()); } eachFont: for (Font font : fonts) { if (font.equals(myNormalFont)) continue; for (int i = 0; i < sampleString.length(); i++) { if (!font.canDisplay(sampleString.charAt(i))) { continue eachFont; } } return font; } return null; }
@NotNull public static Font getFontAbleToDisplay(@NotNull String s, @NotNull Font defaultFont) { if (SystemInfo.isMac // On Macs, all fonts can display all the characters because the system renders using fallback fonts. || isExtendedAscii(s)) { // Assume that default font can handle ASCII return defaultFont; } Set<Font> fonts = Sets.newHashSetWithExpectedSize(10); FontPreferences fontPreferences = EditorColorsManager.getInstance().getGlobalScheme().getFontPreferences(); for (int i = 0; i < s.length(); i++) { if (s.charAt(i) > 255) { fonts.add(ComplementaryFontsRegistry.getFontAbleToDisplay(s.charAt(i), Font.PLAIN, fontPreferences).getFont()); } } if (fonts.isEmpty()) { return defaultFont; } // find the font the can handle the most # of characters Font bestFont = defaultFont; int max = 0; for (Font f : fonts) { int supportedChars = 0; for (int i = 0; i < s.length(); i++) { if (f.canDisplay(s.charAt(i))) { supportedChars++; } } if (supportedChars > max) { max = supportedChars; bestFont = f; } } return bestFont; }
private static FontInfo getFontInfo(@Nonnull Editor editor) { EditorColorsScheme colorsScheme = editor.getColorsScheme(); FontPreferences fontPreferences = colorsScheme.getFontPreferences(); TextAttributes attributes = editor.getColorsScheme().getAttributes(DebuggerColors.INLINED_VALUES_EXECUTION_LINE); int fontStyle = attributes == null ? Font.PLAIN : attributes.getFontType(); return ComplementaryFontsRegistry.getFontAbleToDisplay('a', fontStyle, fontPreferences, FontInfo.getFontRenderContext(editor.getContentComponent())); }
@NotNull public static FontInfo fontForChar(final char c, @JdkConstants.FontStyle int style, @NotNull Editor editor) { EditorColorsScheme colorsScheme = editor.getColorsScheme(); return ComplementaryFontsRegistry.getFontAbleToDisplay(c, style, colorsScheme.getFontPreferences()); }
@Override public Font getFontAbleToDisplay(char c, int size, @JdkConstants.FontStyle int style, @NotNull String defaultFontFamily) { return ComplementaryFontsRegistry.getFontAbleToDisplay(c, size, style, defaultFontFamily).getFont(); }
public FontInfo fontForChar(final char c, @JdkConstants.FontStyle int style) { return ComplementaryFontsRegistry.getFontAbleToDisplay(c, style, mySettingsProvider.getColorScheme().getConsoleFontPreferences()); }
public static FontInfo fontForChar(final char c, @JdkConstants.FontStyle int style, @NotNull Editor editor) { EditorColorsScheme colorsScheme = editor.getColorsScheme(); return ComplementaryFontsRegistry.getFontAbleToDisplay(c, style, colorsScheme.getFontPreferences()); }
public FontInfo fontForChar(final char c, @JdkConstants.FontStyle int style) { return ComplementaryFontsRegistry.getFontAbleToDisplay(c, style, mySettingsProvider.getColorScheme() .getConsoleFontPreferences()); }
@Nonnull public static FontInfo fontForChar(final char c, @JdkConstants.FontStyle int style, @Nonnull Editor editor) { EditorColorsScheme colorsScheme = editor.getColorsScheme(); return ComplementaryFontsRegistry.getFontAbleToDisplay(c, style, colorsScheme.getFontPreferences(), FontInfo.getFontRenderContext(editor.getContentComponent())); }
@Override public Font getFontAbleToDisplay(char c, int size, @JdkConstants.FontStyle int style, @Nonnull String defaultFontFamily) { return ComplementaryFontsRegistry.getFontAbleToDisplay(c, size, style, defaultFontFamily).getFont(); }
@Nonnull public static Font getFontAbleToDisplay(char c, int size, int style, @Nonnull String family) { return ComplementaryFontsRegistry.getFontAbleToDisplay(c, size, style, family).getFont(); }
private static Font getEditorFont(Editor editor) { return ComplementaryFontsRegistry.getFontAbleToDisplay('a', Font.PLAIN, editor.getColorsScheme().getFontPreferences(), null).getFont(); }