trying to improve the default font on macOS

This commit is contained in:
Ben Fry
2021-06-22 19:52:34 -04:00
parent 4712224041
commit 350ff313ad
2 changed files with 22 additions and 8 deletions
@@ -22,10 +22,7 @@
package processing.app.platform;
import java.awt.Color;
import java.awt.Component;
import java.awt.Desktop;
import java.awt.Graphics;
import java.awt.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -35,11 +32,13 @@ import javax.swing.Icon;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.UIManager;
import javax.swing.plaf.FontUIResource;
import processing.app.Base;
import processing.app.Messages;
import processing.app.Preferences;
import processing.app.ui.About;
import processing.app.ui.Toolkit;
/**
@@ -106,8 +105,14 @@ public class MacPlatform extends DefaultPlatform {
public void setLookAndFeel() throws Exception {
super.setLookAndFeel();
String laf = Preferences.get("editor.laf");
if ("org.violetlib.aqua.AquaLookAndFeel".equals(laf)) {
String laf = UIManager.getLookAndFeel().getClass().getName();
if ("com.apple.laf.AquaLookAndFeel".equals(laf)) {
//setUIFont(new FontUIResource(".AppleSystemUIFont", Font.PLAIN, 12));
// oh my god, the kerning, the tracking, my eyes...
//setUIFont(new FontUIResource(".SFNS-Regular", Font.PLAIN, 13));
//setUIFont(new FontUIResource(Toolkit.getSansFont(14, Font.PLAIN)));
} else if ("org.violetlib.aqua.AquaLookAndFeel".equals(laf)) {
Icon collapse = new VAquaTreeIcon(true);
Icon open = new VAquaTreeIcon(false);
Icon leaf = new VAquaEmptyIcon();
@@ -120,6 +125,17 @@ public class MacPlatform extends DefaultPlatform {
}
// Rewritten from https://stackoverflow.com/a/7434935
static private void setUIFont(FontUIResource f) {
for (Object key : UIManager.getLookAndFeelDefaults().keySet()) {
Object value = UIManager.get(key);
if (value instanceof FontUIResource) {
UIManager.put(key, f);
}
}
}
public File getSettingsFolder() throws Exception {
return new File(getLibraryFolder(), "Processing");
}
-2
View File
@@ -157,8 +157,6 @@ public class Toolkit {
* Create a menu item and set its KeyStroke by name (so it can be stored
* in the language settings or the preferences. Syntax is here:
* https://docs.oracle.com/javase/8/docs/api/javax/swing/KeyStroke.html#getKeyStroke-java.lang.String-
* @param sequence the name, as outlined by the KeyStroke API
* @param fallback what to use if getKeyStroke() comes back null
*/
static public JMenuItem newJMenuItemExt(String base) {
JMenuItem menuItem = new JMenuItem(Language.text(base));