From 42d801f123cf3791c465d3e962d0445ea59219f7 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sun, 13 Oct 2019 14:15:37 +0200 Subject: [PATCH] Linux: - allow user scaling mode on Linux even if running in Java 9+ - update fonts (and scaling) when user changes text size or scaling in Gnome settings (#1) --- flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java | 5 +++++ .../src/main/java/com/formdev/flatlaf/util/UIScale.java | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java index 3e99f945..b2bb4ad2 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java @@ -124,6 +124,11 @@ public abstract class FlatLaf // Windows 10 allows increasing font size independent of scaling: // Settings > Ease of Access > Display > Make text bigger (100% - 225%) desktopPropertyName = "win.messagebox.font"; + } else if( SystemInfo.IS_LINUX ) { + // Linux/Gnome allows extra scaling and larger text: + // Settings > Devices > Displays > Scale (100% or 200%) + // Settings > Universal access > Large Text (off or on, 125%) + desktopPropertyName = "gnome.Xft/DPI"; } if( desktopPropertyName != null ) { desktopPropertyListener = e -> { diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/util/UIScale.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/util/UIScale.java index d673944e..a6a36c83 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/util/UIScale.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/util/UIScale.java @@ -48,8 +48,7 @@ import javax.swing.plaf.UIResource; * * 2) user scaling mode * - * This mode is for Java 8 compatibility and can be removed when changing minimum - * required Java version to 9. + * This mode is mainly for Java 8 compatibility, but is also used on Linux. * The user scale factor is computed based on the used font. * The JRE does not scale anything. * So we have to invoke {@link #scale(float)} where necessary. @@ -166,7 +165,7 @@ public class UIScale } private static boolean isUserScalingEnabled() { - if( isSystemScalingEnabled() ) + if( isSystemScalingEnabled() && !SystemInfo.IS_LINUX ) return false; // disable user scaling if JRE scales // same as in IntelliJ IDEA