mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
font defaults moved to darcula
This commit is contained in:
@@ -20,16 +20,11 @@ import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.ui.mac.foundation.Foundation;
|
||||
import com.intellij.ui.mac.foundation.MacUtil;
|
||||
import com.intellij.util.ui.FontInfo;
|
||||
import org.intellij.lang.annotations.JdkConstants;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.FontUIResource;
|
||||
import javax.swing.plaf.basic.BasicLookAndFeel;
|
||||
import javax.swing.plaf.metal.DefaultMetalTheme;
|
||||
import java.awt.*;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
@@ -64,54 +59,6 @@ public class IntelliJLaf extends DarculaLaf {
|
||||
return new IdeaBlueMetalTheme();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UIDefaults getDefaults() {
|
||||
UIDefaults defaults = super.getDefaults();
|
||||
if (SystemInfo.isMacOSYosemite) {
|
||||
installMacOSXFonts(defaults);
|
||||
}
|
||||
return defaults;
|
||||
}
|
||||
|
||||
private static void installMacOSXFonts(UIDefaults defaults) {
|
||||
final String face = "HelveticaNeue-Regular";
|
||||
final FontUIResource uiFont = getFont(face, 13, Font.PLAIN);
|
||||
LafManagerImpl.initFontDefaults(defaults, 13, uiFont);
|
||||
for (Object key : new HashSet<>(defaults.keySet())) {
|
||||
Object value = defaults.get(key);
|
||||
if (value instanceof FontUIResource) {
|
||||
FontUIResource font = (FontUIResource)value;
|
||||
if (font.getFamily().equals("Lucida Grande") || font.getFamily().equals("Serif")) {
|
||||
if (!key.toString().contains("Menu")) {
|
||||
defaults.put(key, getFont(face, font.getSize(), font.getStyle()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FontUIResource uiFont11 = getFont(face, 11, Font.PLAIN);
|
||||
defaults.put("TableHeader.font", uiFont11);
|
||||
|
||||
FontUIResource buttonFont = getFont("HelveticaNeue-Medium", 13, Font.PLAIN);
|
||||
defaults.put("Button.font", buttonFont);
|
||||
Font menuFont = getFont("Lucida Grande", 14, Font.PLAIN);
|
||||
defaults.put("Menu.font", menuFont);
|
||||
defaults.put("MenuItem.font", menuFont);
|
||||
defaults.put("MenuItem.acceleratorFont", menuFont);
|
||||
defaults.put("PasswordField.font", defaults.getFont("TextField.font"));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static FontUIResource getFont(String yosemite, int size, @JdkConstants.FontStyle int style) {
|
||||
if (SystemInfo.isMacOSElCapitan) {
|
||||
Font font = FontInfo.get(".SF NS Display").getFont();
|
||||
if (font != null) {
|
||||
return new FontUIResource(font.deriveFont(style, size));
|
||||
}
|
||||
}
|
||||
return new FontUIResource(yosemite, style, size);
|
||||
}
|
||||
|
||||
public static boolean isGraphite() {
|
||||
if (!SystemInfo.isMac) return false;
|
||||
try {
|
||||
|
||||
@@ -827,7 +827,7 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
|
||||
}
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
static void initFontDefaults(UIDefaults defaults, int fontSize, FontUIResource uiFont) {
|
||||
public static void initFontDefaults(UIDefaults defaults, int fontSize, FontUIResource uiFont) {
|
||||
defaults.put("Tree.ancestorInputMap", null);
|
||||
FontUIResource textFont = new FontUIResource("Serif", Font.PLAIN, fontSize);
|
||||
FontUIResource monoFont = new FontUIResource("Monospaced", Font.PLAIN, fontSize);
|
||||
|
||||
@@ -31,8 +31,10 @@ import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.ui.ColorUtil;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.containers.hash.HashMap;
|
||||
import com.intellij.util.ui.FontInfo;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.intellij.lang.annotations.JdkConstants;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import sun.awt.AppContext;
|
||||
|
||||
@@ -67,6 +69,45 @@ public class DarculaLaf extends BasicLookAndFeel {
|
||||
base = createBaseLookAndFeel();
|
||||
}
|
||||
|
||||
private static void installMacOSXFonts(UIDefaults defaults) {
|
||||
final String face = "HelveticaNeue-Regular";
|
||||
final FontUIResource uiFont = getFont(face, 13, Font.PLAIN);
|
||||
LafManagerImpl.initFontDefaults(defaults, 13, uiFont);
|
||||
for (Object key : new HashSet<>(defaults.keySet())) {
|
||||
Object value = defaults.get(key);
|
||||
if (value instanceof FontUIResource) {
|
||||
FontUIResource font = (FontUIResource)value;
|
||||
if (font.getFamily().equals("Lucida Grande") || font.getFamily().equals("Serif")) {
|
||||
if (!key.toString().contains("Menu")) {
|
||||
defaults.put(key, getFont(face, font.getSize(), font.getStyle()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FontUIResource uiFont11 = getFont(face, 11, Font.PLAIN);
|
||||
defaults.put("TableHeader.font", uiFont11);
|
||||
|
||||
FontUIResource buttonFont = getFont("HelveticaNeue-Medium", 13, Font.PLAIN);
|
||||
defaults.put("Button.font", buttonFont);
|
||||
Font menuFont = getFont("Lucida Grande", 14, Font.PLAIN);
|
||||
defaults.put("Menu.font", menuFont);
|
||||
defaults.put("MenuItem.font", menuFont);
|
||||
defaults.put("MenuItem.acceleratorFont", menuFont);
|
||||
defaults.put("PasswordField.font", defaults.getFont("TextField.font"));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static FontUIResource getFont(String yosemite, int size, @JdkConstants.FontStyle int style) {
|
||||
if (SystemInfo.isMacOSElCapitan) {
|
||||
Font font = FontInfo.get(".SF NS Display").getFont();
|
||||
if (font != null) {
|
||||
return new FontUIResource(font.deriveFont(style, size));
|
||||
}
|
||||
}
|
||||
return new FontUIResource(yosemite, style, size);
|
||||
}
|
||||
|
||||
protected BasicLookAndFeel createBaseLookAndFeel() {
|
||||
try {
|
||||
if (SystemInfo.isMac) {
|
||||
@@ -144,6 +185,9 @@ public class DarculaLaf extends BasicLookAndFeel {
|
||||
applySystemFonts(defaults);
|
||||
}
|
||||
defaults.put("EditorPane.font", defaults.getFont("TextField.font"));
|
||||
if (SystemInfo.isMacOSYosemite) {
|
||||
installMacOSXFonts(defaults);
|
||||
}
|
||||
return defaults;
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user