Closed mlopatkin closed 2 years ago
The workaround that I use now is to run the app with JDK 11. Support for HiDPI in Swing was added in JDK 10, now it respects system-wide scaling. However, Android developers often stuck on JDK 8 so some solution is needed here:
Another workaround (on Windows) is to use JDK bundled with Android Studio (aka JetBrains Runtime). One needs to point JAVA_HOME to the Studio's JDK and set LOGVIEW_OPTS=-Dsun.java2d.uiScale.enabled=true
in environment.
It looks like the Linux situation is more broken than I thought. I've failed to set up 1.5 scaling on Ubuntu 16.04 with JDK 11. The same configuration seems to works on my desktop though (I need to re-check). Setting 2x scaling with GDK_SCALE=2
or -Dsun.java2d.uiScale.enabled=true
works though.
Fractional scaling on linux seems to be affected by https://bugs.openjdk.java.net/browse/JDK-8214227 (i.e. not supported)
Fractional scaling is not supported by Jetbrains Runtime as well: https://youtrack.jetbrains.com/issue/JBR-1365
Not so many options left:
JPackage is going to hit stable in Java 16. I should probably bundle the runtime with the app so users with HiDPI displays don't have to set up a separate JDK.
The simplest option might be to use flatlaf, it supports HiDPI. There are problems with colors though - default selection color doesn't play well with my priority colors.
Still works weirdly in my Linux environment and JDK 11 (Unity, scale 125%). The scaling is way to large, 200% or even more.
Still works weirdly in my Linux environment and JDK 11 (Unity, scale 125%). The scaling is way to large, 200% or even more.
Playing with flatlaf demo, I can see that it is indeed 200%, but only on JDKs 11-16. JDK 17 works fine. And I suppose, it might be different in Gnome/KDE. AARGH!
I give up. My other Linux box doesn't reproduce the problem, FlatLaf picks up user scale (1.25) successfully. I'm closing the issue, one can use -Dsun.java2d.uiScale.enabled=false
to force user scale, I guess.
Original report by me.
On 4K displays (e.g. 15" 3840*2160) the app window is too small. It needs to support default platform scaling.
I've tested on Linux (Ubuntu 16.04.1) only, because I don't have Win/Mac device with 4K display yet.