use of com.intellij.openapi.editor.colors.FontPreferences in project intellij-community by JetBrains.
the class LineLayout method createFragments.
private static List<BidiRun> createFragments(@NotNull EditorView view, @NotNull CharSequence text, @JdkConstants.FontStyle int fontStyle) {
if (text.length() == 0)
return Collections.emptyList();
FontRenderContext fontRenderContext = view.getFontRenderContext();
FontPreferences fontPreferences = view.getEditor().getColorsScheme().getFontPreferences();
char[] chars = CharArrayUtil.fromSequence(text);
List<BidiRun> runs = createRuns(view, chars, -1);
for (BidiRun run : runs) {
for (Chunk chunk : run.getChunks(text, 0)) {
chunk.fragments = new ArrayList<>();
addFragments(run, chunk, chars, chunk.startOffset, chunk.endOffset, fontStyle, fontPreferences, fontRenderContext, null);
}
}
return runs;
}
use of com.intellij.openapi.editor.colors.FontPreferences in project android by JetBrains.
the class FontUtil method getFontAbleToDisplay.
@NotNull
public static Font getFontAbleToDisplay(@NotNull String s, @NotNull Font defaultFont) {
if (// On Macs, all fonts can display all the characters because the system renders using fallback fonts.
SystemInfo.isMac || 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, null).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;
}
use of com.intellij.openapi.editor.colors.FontPreferences in project intellij-community by JetBrains.
the class EditorColorsSchemeDelegateTest method testSecondaryFontIsAvailable.
public void testSecondaryFontIsAvailable() throws Exception {
FontPreferences globalPrefs = myTestScheme.getFontPreferences();
assertInstanceOf(globalPrefs, ModifiableFontPreferences.class);
((ModifiableFontPreferences) globalPrefs).register("DummyFont", globalPrefs.getSize(globalPrefs.getFontFamily()));
assertEquals(2, globalPrefs.getRealFontFamilies().size());
init("blah", TestFileType.TEXT);
FontPreferences editorPrefs = myEditor.getColorsScheme().getFontPreferences();
assertEquals(2, editorPrefs.getRealFontFamilies().size());
assertEquals("DummyFont", editorPrefs.getRealFontFamilies().get(1));
}
use of com.intellij.openapi.editor.colors.FontPreferences in project intellij-community by JetBrains.
the class ConsoleFontOptions method setDelegatingPreferences.
@Override
protected void setDelegatingPreferences(boolean isDelegating) {
FontPreferences currPrefs = getCurrentScheme().getConsoleFontPreferences();
if (currPrefs instanceof DelegatingFontPreferences == isDelegating)
return;
if (isDelegating) {
getCurrentScheme().setUseEditorFontPreferencesInConsole();
} else {
getCurrentScheme().setConsoleFontPreferences(getFontPreferences());
}
updateOptionsList();
updateDescription(true);
}
use of com.intellij.openapi.editor.colors.FontPreferences in project intellij-community by JetBrains.
the class LookupCellRenderer method getFontAbleToDisplay.
@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;
}
Aggregations