From de7b84703b57e38ddf620b8cf33b4f449d504003 Mon Sep 17 00:00:00 2001 From: weisj Date: Fri, 3 Apr 2020 15:21:52 +0200 Subject: [PATCH] Avoid iteratively creating the attribute collection. --- .../github/weisj/darklaf/task/FontDefaultsInitTask.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java b/core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java index 1d801a63..2e288ea1 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java +++ b/core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java @@ -47,6 +47,10 @@ public class FontDefaultsInitTask implements DefaultsInitTask { private static final String FONT_SIZE_DEFAULTS_NAME = "font_sizes"; private static final String FONT_DEFAULTS_NAME = "font"; + private static final Map ENABLE_KERNING + = Collections.singletonMap(TextAttribute.KERNING, TextAttribute.KERNING_ON); + private static final Map DISABLE_KERNING + = Collections.singletonMap(TextAttribute.KERNING, null); private static final String MAC_OS_CATALINA_FONT_NAME = ".AppleSystemUIFont"; private static final String MAC_OS_FONT_NAME = ".SF NS Text"; @@ -80,10 +84,8 @@ public class FontDefaultsInitTask implements DefaultsInitTask { } private Font macOSFontFromFont(final Font font) { - Map attributes - = Collections.singletonMap(TextAttribute.KERNING, TextAttribute.KERNING_ON); String fontName = SystemInfo.isMacOSCatalina ? MAC_OS_CATALINA_FONT_NAME : MAC_OS_FONT_NAME; - Font macFont = new Font(fontName, font.getStyle(), font.getSize()).deriveFont(attributes); + Font macFont = new Font(fontName, font.getStyle(), font.getSize()).deriveFont(ENABLE_KERNING); if (font instanceof UIResource) { macFont = new FontUIResource(macFont); }