Date: prev next · Thread: first prev next last
2015 Archives by date, by thread · List index


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



Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.