diff options
| author | 2022-12-07 19:54:18 +0100 | |
|---|---|---|
| committer | 2022-12-07 18:54:18 +0000 | |
| commit | 9e24baef59b25ff1f8587999bc3250fe68ce32df (patch) | |
| tree | 8d1cd21c0c1ec22d52f9ebfa321c4c40c138ca18 | |
| parent | Bump version (diff) | |
| download | enigma-9e24baef59b25ff1f8587999bc3250fe68ce32df.tar.gz enigma-9e24baef59b25ff1f8587999bc3250fe68ce32df.tar.xz enigma-9e24baef59b25ff1f8587999bc3250fe68ce32df.zip | |
Provide fallback anti-aliasing for DEs the JRE doesn't recognize (#466)
| -rw-r--r-- | enigma-swing/src/main/java/cuchaz/enigma/gui/Main.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/Main.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/Main.java index 56f43859..213a5fea 100644 --- a/enigma-swing/src/main/java/cuchaz/enigma/gui/Main.java +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/Main.java | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma.gui; | 12 | package cuchaz.enigma.gui; |
| 13 | 13 | ||
| 14 | import java.awt.Toolkit; | ||
| 14 | import java.io.IOException; | 15 | import java.io.IOException; |
| 15 | import java.nio.file.Files; | 16 | import java.nio.file.Files; |
| 16 | import java.nio.file.Path; | 17 | import java.nio.file.Path; |
| @@ -102,7 +103,18 @@ public class Main { | |||
| 102 | EnigmaProfile parsedProfile = EnigmaProfile.read(options.valueOf(profile)); | 103 | EnigmaProfile parsedProfile = EnigmaProfile.read(options.valueOf(profile)); |
| 103 | 104 | ||
| 104 | I18n.setLanguage(UiConfig.getLanguage()); | 105 | I18n.setLanguage(UiConfig.getLanguage()); |
| 105 | System.setProperty("apple.laf.useScreenMenuBar", "true"); | 106 | |
| 107 | // Provide fallback anti-aliasing for desktop environments the JRE doesn't recognize | ||
| 108 | if (Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints") == null) { | ||
| 109 | setDefaultSystemProperty("awt.useSystemAAFontSettings", "lcd"); | ||
| 110 | } | ||
| 111 | |||
| 112 | // Not setting "swing.aatext" here because that property has been removed: | ||
| 113 | // https://bugs.openjdk.org/browse/JDK-6391267 | ||
| 114 | |||
| 115 | // If on MacOS, use the system's menu bar, not the in-app one | ||
| 116 | setDefaultSystemProperty("apple.laf.useScreenMenuBar", "true"); | ||
| 117 | |||
| 106 | Themes.setupTheme(); | 118 | Themes.setupTheme(); |
| 107 | 119 | ||
| 108 | Gui gui = new Gui(parsedProfile, editables); | 120 | Gui gui = new Gui(parsedProfile, editables); |
| @@ -147,6 +159,10 @@ public class Main { | |||
| 147 | } | 159 | } |
| 148 | } | 160 | } |
| 149 | 161 | ||
| 162 | private static void setDefaultSystemProperty(String property, String value) { | ||
| 163 | System.setProperty(property, System.getProperty(property, value)); | ||
| 164 | } | ||
| 165 | |||
| 150 | public static class PathConverter implements ValueConverter<Path> { | 166 | public static class PathConverter implements ValueConverter<Path> { |
| 151 | public static final ValueConverter<Path> INSTANCE = new PathConverter(); | 167 | public static final ValueConverter<Path> INSTANCE = new PathConverter(); |
| 152 | 168 | ||