mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 22:10:54 +03:00
Linux: fixed scaling if GDK_SCALE environment variable is set or if running on JetBrains Runtime (issue #69)
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
FlatLaf Change Log
|
||||
==================
|
||||
|
||||
## Unreleased
|
||||
|
||||
- Linux: Fixed scaling if `GDK_SCALE` environment variable is set or if running
|
||||
on JetBrains Runtime. (issue #69)
|
||||
|
||||
|
||||
## 0.28
|
||||
|
||||
- PasswordField: Warn about enabled Caps Lock.
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.formdev.flatlaf;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Toolkit;
|
||||
import java.io.BufferedReader;
|
||||
@@ -31,6 +32,7 @@ import java.util.logging.Level;
|
||||
import javax.swing.text.StyleContext;
|
||||
import com.formdev.flatlaf.util.StringUtils;
|
||||
import com.formdev.flatlaf.util.SystemInfo;
|
||||
import com.formdev.flatlaf.util.UIScale;
|
||||
|
||||
/**
|
||||
* @author Karl Tauber
|
||||
@@ -99,6 +101,10 @@ class LinuxFontPolicy
|
||||
}
|
||||
|
||||
private static double getGnomeFontScale() {
|
||||
// do not scale font here if JRE scales
|
||||
if( isSystemScaling() )
|
||||
return 1;
|
||||
|
||||
// see class com.sun.java.swing.plaf.gtk.PangoFonts background information
|
||||
|
||||
Object value = Toolkit.getDefaultToolkit().getDesktopProperty( "gnome.Xft/DPI" );
|
||||
@@ -168,7 +174,7 @@ class LinuxFontPolicy
|
||||
|
||||
// font dpi
|
||||
int dpi = 96;
|
||||
if( forceFontDPI != null ) {
|
||||
if( forceFontDPI != null && !isSystemScaling() ) {
|
||||
try {
|
||||
dpi = Integer.parseInt( forceFontDPI );
|
||||
if( dpi <= 0 )
|
||||
@@ -247,4 +253,15 @@ class LinuxFontPolicy
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the JRE scales, which is the case if:
|
||||
* - environment variable GDK_SCALE is set and running on Java 9 or later
|
||||
* - running on JetBrains Runtime 11 or later and scaling is enabled in system Settings
|
||||
*/
|
||||
private static boolean isSystemScaling() {
|
||||
GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment()
|
||||
.getDefaultScreenDevice().getDefaultConfiguration();
|
||||
return UIScale.getSystemScaleFactor( gc ) > 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user