From 62d3e1df5ecfa987295463f3c63bd3784f2c9962 Mon Sep 17 00:00:00 2001 From: Anton Tarasov Date: Fri, 25 Mar 2016 16:20:21 +0300 Subject: [PATCH] IDEA-149337 [follow-up] UI fonts are too big Additionally check if GTK LaF is supported, otherwise fallback to default behavior. --- .../util/src/com/intellij/util/ui/UIUtil.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index 3d7c0b2ef79f..f4437ce0d81b 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -30,6 +30,7 @@ import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.JBIterable; import com.intellij.util.containers.JBTreeTraverser; import com.intellij.util.containers.WeakHashMap; +import com.sun.java.swing.plaf.gtk.GTKLookAndFeel; import org.intellij.lang.annotations.Language; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -2544,11 +2545,25 @@ public class UIUtil { } } + private static String systemLaFClassName; + public static String getSystemLookAndFeelClassName() { - // Force GTK LaF on Linux to let it retrieve system font settings - // with proper font scale based on Xft.dpi - return SystemInfo.isLinux ? "com.sun.java.swing.plaf.gtk.GTKLookAndFeel" : - UIManager.getSystemLookAndFeelClassName(); + if (systemLaFClassName != null) { + return systemLaFClassName; + } + else if (SystemInfo.isLinux) { + // Normally, GTK LaF is considered "system" when: + // 1) Gnome session is run + // 2) gtk lib is available + // Here we weaken the requirements to only 2) and force GTK LaF + // installation in order to let it properly scale default font + // based on Xft.dpi value. + LookAndFeel laf = new GTKLookAndFeel(); + if (laf.isSupportedLookAndFeel()) { // if gtk lib is available + return systemLaFClassName = laf.getClass().getName(); + } + } + return systemLaFClassName = UIManager.getSystemLookAndFeelClassName(); } public static void initDefaultLAF() {