How can I scale fonts on a high resolution screen?

On a high resolution screen (my example, Windows 8.1) is my Java application. Menus in particular are very small, and it is almost impossible to select a menu item.

On normal screens (72 DPI) everything is in order.

A font with a fixed size (in my case it would have <80px) is a poor choice. 72 DPI screens show that they are very large.

How to make fonts scalable so that the program matches its size, or the user gets the ability to customize?

+7
java fonts swing
source share
1 answer

You can change the default font size in one place by accessing your PLAF: Java Swing on a high DPI screen

but it will still make the application bad, because inter-component spaces will be in pixels and therefore will not scale with the font size. See http://www.javalobby.org/java/forums/t101878.html for a longer discussion.

My recommendation is to use a DPI-enabled layout library such as MigLayout , which supports sizing either in pixels or in DPI-aware mm or cm. You can then map both font scaling to DPI spacing using FontMetrics to find the right size for your fonts.

+4
source share

All Articles