Java 类com.intellij.openapi.editor.impl.ComplementaryFontsRegistry 实例源码

项目:intellij-ce-playground    文件:TextWithMarkupProcessor.java   
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;
    }
  }
}
项目:consulo    文件:LookupCellRenderer.java   
@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;
}
项目:consulo    文件:TextWithMarkupProcessor.java   
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;
    }
  }
}
项目:intellij-ce-playground    文件:FontUtil.java   
@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;
}
项目:consulo    文件:XDebuggerInlayUtil.java   
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()));
}
项目:intellij-ce-playground    文件:EditorUtil.java   
@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());
}
项目:intellij-ce-playground    文件:SuitableFontProviderImpl.java   
@Override
public Font getFontAbleToDisplay(char c, int size, @JdkConstants.FontStyle int style, @NotNull String defaultFontFamily) {
  return ComplementaryFontsRegistry.getFontAbleToDisplay(c, size, style, defaultFontFamily).getFont();
}
项目:intellij-ce-playground    文件:JBTerminalPanel.java   
public FontInfo fontForChar(final char c, @JdkConstants.FontStyle int style) {
  return ComplementaryFontsRegistry.getFontAbleToDisplay(c, style, mySettingsProvider.getColorScheme().getConsoleFontPreferences());
}
项目:tools-idea    文件:EditorUtil.java   
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());
}
项目:consulo-terminal    文件:JBTerminalPanel.java   
public FontInfo fontForChar(final char c, @JdkConstants.FontStyle int style)
{
    return ComplementaryFontsRegistry.getFontAbleToDisplay(c, style, mySettingsProvider.getColorScheme()
            .getConsoleFontPreferences());
}
项目:consulo    文件:EditorUtil.java   
@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()));
}
项目:consulo    文件:SuitableFontProviderImpl.java   
@Override
public Font getFontAbleToDisplay(char c, int size, @JdkConstants.FontStyle int style, @Nonnull String defaultFontFamily) {
  return ComplementaryFontsRegistry.getFontAbleToDisplay(c, size, style, defaultFontFamily).getFont();
}
项目:consulo    文件:FontUtil.java   
@Nonnull
public static Font getFontAbleToDisplay(char c, int size, int style, @Nonnull String family) {
  return ComplementaryFontsRegistry.getFontAbleToDisplay(c, size, style, family).getFont();
}
项目:consulo    文件:BreadcrumbsWrapper.java   
private static Font getEditorFont(Editor editor) {
  return ComplementaryFontsRegistry.getFontAbleToDisplay('a', Font.PLAIN, editor.getColorsScheme().getFontPreferences(), null).getFont();
}