saalfeldlab / paintera

GNU General Public License v2.0
99 stars 17 forks source link

Respect System Scaling to Support HiDPI Monitors #422

Closed cmhulbert closed 3 years ago

cmhulbert commented 3 years ago

Currently, text does not scale with the system scaling. This makes all the text, and the UI elements which are sized relative to the text they contain, very small on HiDPI. Currently, on Linux you can work around this by setting the environmental variable GDK_SCALE to match your scaling level (e.g. GDK_SCALE=2 for 200% scaling).

cmhulbert commented 3 years ago

This is a known issue with JavaFx on certain Linux distributions. Here is a bug tracker for the issue https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8248126. Notably, this has already been addressed by this commit: https://github.com/openjdk/jfx/commit/782f22a1 Unfortunately, this is currently only available in the JavaFx 17 Early Access version or newer (tested with version 17-ea+2). Still looking, but I can't seem to find a schedule for a full release of 17. I know at the moment, the newest release is 15.

Since currently, JavaFX depends on the GDK_SCALE environmental variable to be set, it may be possible to have a wrapper class which queries the systems scale, and set GDK_SCALE appropriately, until 17 is released. This would require a wrapper class though, since currently the entrypoint for Paintera is a direct child of the JavaFx Application class. And since the values returned by System.getenv() are immutable, I think this would require something like a ProcessBuilder to setup the environmental variables prior to launching (Or, reflection :shrug: ). Also, I'm not currently clear on how to consistently grab the system scale.

@axtimwalde thoughts on using an early access version of 17? Or implementing this fix as a wrapper for now? Ideally, I think we would avoid the added complexity of a wrapper to start a new process, but I don't get the impression a stable release of will be anytime soon. It may be better to detect and set GDK_SCALE in the paintera-cmd call, instead of anything here, for now.

cmhulbert commented 3 years ago

Per our conversation this morning, it makes the most sense to set the value in paintera-cmd. I created the issue https://github.com/saalfeldlab/paintera-cmd/issues/7 to track that effort. This should be closed when that is merged in.