High-DPI aware KDE applications

Qt 4.6 recently gained support for scaling to higher DPI values on Windows and OS X. Nice, but what about us mortal Linux users? Luckily, X11 applications have long been designed to support different DPI values, at least with respect to fonts.

One of my goals for KDE is to make sure that applications work reasonably well with any display resolution. Text, icons, frames, and spacing between elements must be fully scalable for this to work. Below I will write about the current status and future plans.

Font sizes

KDE applications have been designed to adapt to different font sizes, so there should be no major problems with text sizes. I fixed a few places in KDE 4.3 where hardcoded font sizes where used (r965850, r966832, r966845), but some remaining uses may need to be fixed.

To check if an application uses the fonts specified in system settings, you could change them to some insane values. Some applications do not use the default font for widgets, but try to construct it based on the user settings. This may be a problem when customizable widget fonts are supported in the future. With the Skulpture layout visualizer, you can easily spot those widgets; they are rendered with an annoying red background.

Another problem is with style sheets. Applications that use style sheets internally might not react to color or font size changes. With the layout visualizer, those widgets are rendered with a magenta colored background. Regarding colors, applications should of course respect the user defined colors. In the layout visualizer, widgets that do not use the default palette get a light blue background.

KDE Menu with small fonts and icons
KDE Menu with very small text and icon size

Icon sizes

Qt defines multiple icon usage roles, and the platform’s style defines the actual sizes for them. Generally, applications respect these sizes automatically for widgets. KDE adds its own set of icon usage roles, and most applications also respect them. Unfortunately, there are still some applications that request fixed size icons.

Applications that want to use icons next to a single line text label should use the Small icon size; for icons that are to be rendered next to two lines of text, the Large icon size is recommended. Icons that are not used directly related to a text can use one of the other Qt or KDE icon sizes.

For KDE 4.4, I made the size for Dialog icons configurable (r986243). They were fixed to 32 pixels before, but you can now make them smaller or larger. Configuration dialogs already support variable icon sizes, and I hope that more programs respect the customizable size in the future. Note that KDE currently offers only a limited set of available sizes (16, 22, 32, 48, 64, …) because with any other size they tend to get blurry (see image above). I was hoping that we could get freely scalable icons, but this requires support for SVG filters in Qt.

Frame widths

The platform’s style is also responsible for rendering all frames. I do not know of any style that has changeable frame widths, so with very high DPI displays, the frames currently tend to get too thin. This may be addressed in a future KDE release.

Spacing and margins

Regarding the spacing around and between widgets, I already wrote about it previously. The situation will get better over time, as more and more applications respect the style’s sizes and do not use fixed values. Oxygen itself currently uses fixed values, but I plan to add variable spacing to KDE.

You can help making KDE better by testing applications with the layout visualizer. Please report bugs for applications in KDE 4.3 that use hardcoded colors, spacings, font or icon sizes; add “[UI]” to the bug titles, so I can find them easily.

KDE Menu with medium-sized fonts and icons

KDE Menu with large fonts and icons

With KDE, text and icons can be scaled to different sizes (here using the Skulpture style)