mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-97665 Provide an option to specify fall back fonts
Colors scheme now listens for font preferences changes and updates its caches accordingly
This commit is contained in:
+2
-2
@@ -1067,10 +1067,10 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
}
|
||||
|
||||
public void apply(EditorColorsScheme scheme) {
|
||||
getFontPreferences().copyTo(scheme.getFontPreferences());
|
||||
scheme.setFontPreferences(getFontPreferences());
|
||||
scheme.setLineSpacing(myLineSpacing);
|
||||
scheme.setQuickDocFontSize(getQuickDocFontSize());
|
||||
getConsoleFontPreferences().copyTo(scheme.getConsoleFontPreferences());
|
||||
scheme.setConsoleFontPreferences(getConsoleFontPreferences());
|
||||
scheme.setConsoleLineSpacing(getConsoleLineSpacing());
|
||||
|
||||
for (EditorSchemeAttributeDescriptor descriptor : myDescriptors) {
|
||||
|
||||
@@ -54,6 +54,7 @@ public interface EditorColorsScheme extends Cloneable, JDOMExternalizable, Schem
|
||||
*/
|
||||
@NotNull
|
||||
FontPreferences getFontPreferences();
|
||||
void setFontPreferences(@NotNull FontPreferences preferences);
|
||||
|
||||
String getEditorFontName();
|
||||
void setEditorFontName(String fontName);
|
||||
@@ -78,6 +79,7 @@ public interface EditorColorsScheme extends Cloneable, JDOMExternalizable, Schem
|
||||
*/
|
||||
@NotNull
|
||||
FontPreferences getConsoleFontPreferences();
|
||||
void setConsoleFontPreferences(@NotNull FontPreferences preferences);
|
||||
|
||||
String getConsoleFontName();
|
||||
void setConsoleFontName(String fontName);
|
||||
|
||||
@@ -44,21 +44,33 @@ public class FontPreferences {
|
||||
@NotNull private final TObjectIntHashMap<String> myFontSizes = new TObjectIntHashMap<String>();
|
||||
@NotNull private final List<String> myEffectiveFontFamilies = ContainerUtilRt.newArrayList();
|
||||
@NotNull private final List<String> myRealFontFamilies = ContainerUtilRt.newArrayList();
|
||||
|
||||
@Nullable Runnable myChangeListener;
|
||||
|
||||
/**
|
||||
* Font size to use by default. Default value is {@link #DEFAULT_FONT_SIZE}.
|
||||
*/
|
||||
private int myTemplateFontSize = DEFAULT_FONT_SIZE;
|
||||
|
||||
|
||||
public void setChangeListener(@Nullable Runnable changeListener) {
|
||||
myChangeListener = changeListener;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
myEffectiveFontFamilies.clear();
|
||||
myRealFontFamilies.clear();
|
||||
myFontSizes.clear();
|
||||
if (myChangeListener != null) {
|
||||
myChangeListener.run();
|
||||
}
|
||||
}
|
||||
|
||||
public void clearFonts() {
|
||||
myEffectiveFontFamilies.clear();
|
||||
myRealFontFamilies.clear();
|
||||
if (myChangeListener != null) {
|
||||
myChangeListener.run();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasSize(@NotNull String fontName) {
|
||||
@@ -76,6 +88,9 @@ public class FontPreferences {
|
||||
public void setSize(@NotNull String fontFamily, int size) {
|
||||
myFontSizes.put(fontFamily, size);
|
||||
myTemplateFontSize = size;
|
||||
if (myChangeListener != null) {
|
||||
myChangeListener.run();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,6 +147,9 @@ public class FontPreferences {
|
||||
if (!myEffectiveFontFamilies.contains(effectiveFontFamily)) {
|
||||
myEffectiveFontFamilies.add(effectiveFontFamily);
|
||||
}
|
||||
if (myChangeListener != null) {
|
||||
myChangeListener.run();
|
||||
}
|
||||
}
|
||||
|
||||
public void copyTo(@NotNull final FontPreferences preferences) {
|
||||
|
||||
+20
-2
@@ -90,6 +90,12 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme {
|
||||
protected AbstractColorsScheme(EditorColorsScheme parentScheme, DefaultColorSchemesManager defaultColorSchemesManager) {
|
||||
myParentScheme = parentScheme;
|
||||
myDefaultColorSchemesManager = defaultColorSchemesManager;
|
||||
myFontPreferences.setChangeListener(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
initFonts();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public AbstractColorsScheme(DefaultColorSchemesManager defaultColorSchemesManager) {
|
||||
@@ -179,7 +185,13 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme {
|
||||
public FontPreferences getFontPreferences() {
|
||||
return myFontPreferences;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setFontPreferences(@NotNull FontPreferences preferences) {
|
||||
preferences.copyTo(myFontPreferences);
|
||||
initFonts();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEditorFontName() {
|
||||
if (myFallbackFontName != null) {
|
||||
@@ -581,7 +593,13 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme {
|
||||
public FontPreferences getConsoleFontPreferences() {
|
||||
return myConsoleFontPreferences;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setConsoleFontPreferences(@NotNull FontPreferences preferences) {
|
||||
preferences.copyTo(myConsoleFontPreferences);
|
||||
initFonts();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConsoleFontName() {
|
||||
return myConsoleFontPreferences.getFontFamily();
|
||||
|
||||
+10
@@ -84,6 +84,11 @@ public abstract class DelegateColorScheme implements EditorColorsScheme {
|
||||
return myDelegate.getFontPreferences();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFontPreferences(@NotNull FontPreferences preferences) {
|
||||
myDelegate.setFontPreferences(preferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEditorFontSize() {
|
||||
return myDelegate.getEditorFontSize();
|
||||
@@ -158,6 +163,11 @@ public abstract class DelegateColorScheme implements EditorColorsScheme {
|
||||
return myDelegate.getConsoleFontPreferences();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConsoleFontPreferences(@NotNull FontPreferences preferences) {
|
||||
myDelegate.setConsoleFontPreferences(preferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConsoleFontName() {
|
||||
return myDelegate.getConsoleFontName();
|
||||
|
||||
@@ -5684,7 +5684,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
|
||||
private class MyColorSchemeDelegate implements EditorColorsScheme {
|
||||
|
||||
private final FontPreferences myFontPreferences = new FontPreferences();
|
||||
private final FontPreferences myFontPreferences = new FontPreferences();
|
||||
private final Map<TextAttributesKey, TextAttributes> myOwnAttributes = ContainerUtilRt.newHashMap();
|
||||
private final Map<ColorKey, Color> myOwnColors = ContainerUtilRt.newHashMap();
|
||||
private final EditorColorsScheme myCustomGlobalScheme;
|
||||
@@ -5807,6 +5807,12 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
return myFontPreferences.getEffectiveFontFamilies().isEmpty() ? getGlobal().getFontPreferences() : myFontPreferences;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFontPreferences(@NotNull FontPreferences preferences) {
|
||||
preferences.copyTo(myFontPreferences);
|
||||
initFonts();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEditorFontName() {
|
||||
if (myFaceName == null) {
|
||||
@@ -5874,7 +5880,12 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
public FontPreferences getConsoleFontPreferences() {
|
||||
return getGlobal().getConsoleFontPreferences();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setConsoleFontPreferences(@NotNull FontPreferences preferences) {
|
||||
getGlobal().setConsoleFontPreferences(preferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConsoleFontName() {
|
||||
return getGlobal().getConsoleFontName();
|
||||
|
||||
Reference in New Issue
Block a user