Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I scale fonts on a high resolution screen?

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

In the normal screens (72 DPI) everything is OK.

Font with a fixed size (in my case it would have <80px), is a poor choice. 72 DPI screens show it very large.

How can I make the fonts scalable so that the program conforms to its size, or the user gets the possibility of setting?

like image 388
Andiamo Avatar asked Feb 23 '15 11:02

Andiamo


People also ask

How do I change the font size on my computer screen?

Press and hold ⌘, near the bottom-left of the keyboard, and then use either of the zoom buttons to zoom in or out on your Mac. If you also hold down Option, only the font size will change, not the size of images. Another way to change the font size on your Windows computer is through settings that affect the whole operating system.

Is it possible to resize fonts proportionally to the screen size?

But If you're willing to give it a shot you could resize fonts proportionally to the screen size by: With the window resize event, but becomes a bit tricky when distinguishing between resizing the width and zooming, especially considering cross browser support, but it is doable if you focus on calculating the devicePixelRatio for all browsers.

How do I change the DPI of a font?

To adjust the DPI scaling for a specific program, if you 're own a high DPI device or monitor: 1. Right-click at the application (or the shortcut) that you face the "very small fonts" issue and click Properties. 2. At the Compatibility tab, click Change high DPI settings.

How do I increase the font size on my Mac?

Something else you can try if the other methods aren't working to increase the font size on your Mac is to adjust your computer's screen resolution: 1 From the main Apple menu, select System Preferences . 2 Choose Displays and then Display . 3 Select Scaled and then choose a lower resolution.


1 Answers

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

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

My recommendation is to use a DPI-aware layout library, such as MigLayout, which supports specifying sizes either in pixels or in DPI-aware mm or cm. You can then couple both font-scaling and DPI-aware spacing by using FontMetrics to find the correct size for your fonts.

like image 166
tucuxi Avatar answered Oct 06 '22 02:10

tucuxi