Skip to content

Commit 350ff31

Browse files
committed
trying to improve the default font on macOS
1 parent 4712224 commit 350ff31

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

app/src/processing/app/platform/MacPlatform.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@
2222

2323
package processing.app.platform;
2424

25-
import java.awt.Color;
26-
import java.awt.Component;
27-
import java.awt.Desktop;
28-
import java.awt.Graphics;
25+
import java.awt.*;
2926
import java.io.File;
3027
import java.io.FileNotFoundException;
3128
import java.io.IOException;
@@ -35,11 +32,13 @@
3532
import javax.swing.JMenu;
3633
import javax.swing.JMenuBar;
3734
import javax.swing.UIManager;
35+
import javax.swing.plaf.FontUIResource;
3836

3937
import processing.app.Base;
4038
import processing.app.Messages;
4139
import processing.app.Preferences;
4240
import processing.app.ui.About;
41+
import processing.app.ui.Toolkit;
4342

4443

4544
/**
@@ -106,8 +105,14 @@ public void initBase(Base base) {
106105
public void setLookAndFeel() throws Exception {
107106
super.setLookAndFeel();
108107

109-
String laf = Preferences.get("editor.laf");
110-
if ("org.violetlib.aqua.AquaLookAndFeel".equals(laf)) {
108+
String laf = UIManager.getLookAndFeel().getClass().getName();
109+
if ("com.apple.laf.AquaLookAndFeel".equals(laf)) {
110+
//setUIFont(new FontUIResource(".AppleSystemUIFont", Font.PLAIN, 12));
111+
// oh my god, the kerning, the tracking, my eyes...
112+
//setUIFont(new FontUIResource(".SFNS-Regular", Font.PLAIN, 13));
113+
//setUIFont(new FontUIResource(Toolkit.getSansFont(14, Font.PLAIN)));
114+
115+
} else if ("org.violetlib.aqua.AquaLookAndFeel".equals(laf)) {
111116
Icon collapse = new VAquaTreeIcon(true);
112117
Icon open = new VAquaTreeIcon(false);
113118
Icon leaf = new VAquaEmptyIcon();
@@ -120,6 +125,17 @@ public void setLookAndFeel() throws Exception {
120125
}
121126

122127

128+
// Rewritten from https://stackoverflow.com/a/7434935
129+
static private void setUIFont(FontUIResource f) {
130+
for (Object key : UIManager.getLookAndFeelDefaults().keySet()) {
131+
Object value = UIManager.get(key);
132+
if (value instanceof FontUIResource) {
133+
UIManager.put(key, f);
134+
}
135+
}
136+
}
137+
138+
123139
public File getSettingsFolder() throws Exception {
124140
return new File(getLibraryFolder(), "Processing");
125141
}

app/src/processing/app/ui/Toolkit.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ static public KeyStroke getKeyStrokeExt(String base) {
157157
* Create a menu item and set its KeyStroke by name (so it can be stored
158158
* in the language settings or the preferences. Syntax is here:
159159
* https://docs.oracle.com/javase/8/docs/api/javax/swing/KeyStroke.html#getKeyStroke-java.lang.String-
160-
* @param sequence the name, as outlined by the KeyStroke API
161-
* @param fallback what to use if getKeyStroke() comes back null
162160
*/
163161
static public JMenuItem newJMenuItemExt(String base) {
164162
JMenuItem menuItem = new JMenuItem(Language.text(base));

0 commit comments

Comments
 (0)