RFC: using system font size instead of querying HiDPI stuff

Noel Grandin noel at peralex.com
Thu Jan 22 05:31:14 PST 2015


Hi

I would like to propose a change of direction in how we currently implement HiDPI and general UI sizing stuff.

I suggest that we code the sizes of all of our UI elements by making the pixel sizes a function of the pixel size of the 
current system font.

For example, the Java user-interfaces I build are littered with code like this [1]:

     final int charWidth = getFontMetrics(getFont()).stringWidth("m");
     final int fontHeight = getFontMetrics(getFont()).getHeight();
     setPreferredWidth(charWidth * 10);
     setPreferredHeight(fontHeight * 10);

This has a couple of desirable effects

(1) When people with dodgy vision (like myself) crank up the size of the system font to compensate, all of the UI 
elements like icons/borders/panel-sizes scale nicely in tandem.

(2) Hi-DPI screens "Just Work" because, on a high-DPI screen, you are naturally going to be using a system font with 
more pixels.

Am I missing something why this approach would not work?

Regards, Noel Grandin

[1] I did not invent this approach, I borrowed it from the excellent open-source SwingGoodies library :-)


Disclaimer: http://www.peralex.com/disclaimer.html




More information about the LibreOffice mailing list