Skip to content

Commit

Permalink
Only replace default fonts i.e. logical Dialog fonts.
Browse files Browse the repository at this point in the history
  • Loading branch information
weisJ committed Feb 14, 2021
1 parent 71276ca commit d9b0de5
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public class FontDefaultsInitTask implements DefaultsInitTask {
*/
private static final String MAC_OS_CATALINA_FONT_NAME = ".AppleSystemUIFont";
private static final String MAC_OS_CATALINA_FONT_NAME_FALLBACK = "Helvetica Neue";
private static final String WINDOWS_10_FONT_NAME = "Segoe UI";
private static final String MAC_OS_FONT_NAME = ".SF NS Text";
private static final String WINDOWS_10_FONT_NAME = "Segoe UI";

@Override
public void run(final Theme currentTheme, final UIDefaults defaults) {
Expand Down Expand Up @@ -181,12 +181,15 @@ private void loadFontProperties(final UIDefaults defaults) {
}

private void patchOSFonts(final UIDefaults defaults, final Function<Map.Entry<Object, Font>, Font> mapper) {
PropertyLoader.replacePropertyEntriesOfType(Font.class, defaults, e -> true, mapper);
PropertyLoader.replacePropertyEntriesOfType(Font.class, defaults,
e -> Font.DIALOG.equals(e.getValue().getName()), mapper);
}

private Font mapMacOSFont(final Map.Entry<Object, Font> entry) {
Font font = entry.getValue();
String fontName = SystemInfo.isMacOSCatalina ? MAC_OS_CATALINA_FONT_NAME_FALLBACK : MAC_OS_FONT_NAME;
String fontName = SystemInfo.isMacOSCatalina
? MAC_OS_CATALINA_FONT_NAME_FALLBACK
: MAC_OS_FONT_NAME;
Font macFont = FontUtil.createFont(fontName, font.getStyle(), font.getSize());
if (SystemInfo.isMacOSMojave) macFont = macFont.deriveFont(ENABLE_KERNING);
if (font instanceof UIResource) {
Expand Down

0 comments on commit d9b0de5

Please sign in to comment.