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)

8 thoughts on “High-DPI aware KDE applications”

  1. I’m glad about this — I’ve had issues with KDE and high-DPI displays for a while (my laptop is about 145×145, and my netbook 135×135). My biggest issue is that kwin itself seems to use a different DPI than the apps, so if (for example) I choose a font for the window title bar, I need to choose a few sizes bigger than what I really want for it to render properly. Are you planning to address this?

    Relevant bugs:

  2. You are my hero. After KDE4 has improved a lot the problems surronding small icons and the waste of space if you use small icons and fonts, this problem is among my most hated. I have request the change of the short description to add [UI] as you wished.


    There is also a bug report for the icon size in the settings of some applications like Akregator, Kmail, Amarok. But I could not find it.

  3. I feel the current handling of high DPI displays is completely broken. There seems to be this notion that widgets should be displayed at the same actual size on these displays. Nothing could be further from the truth – high DPI displays tend to be small displays. Using additional pixels on high DPI displays eats up valuable screen real-estate. I find it painful to have to artificially specify a DPI of 96 on a netbook so that fonts and interface elements are not ridiculously scaled.

    If a high DPI display had the same physical dimensions, it would be wonderful to have scaled fonts and interfaces – having the same dimensions but higher resolution. Unfortunately I have never found this to be the case.

  4. Is there any chance someone could do something similar to this with system colors? There are quite a few applications that hardcode colors (some by default, some without alternatives), which can make white-on-black color schemes difficult.

  5. @Stefan, the idea is that you can select a very small font if you want, and icons and spacings should scale accordingly. See the screen shots on this page, they have all been made on a system with a 106 dpi display.

    @Peter, please file bug reports for those applications, use “[UI]” in the bug titles.

  6. Perhaps I have the wrong perspective.

    From my perspective I see that I want things to be the same size in pixels as on a larger display, and I approach the issue in that manner, by changing the DPI – indeed it’s the easiest approach – changing all the fonts, and what-not strikes me as difficult, and prone to leave the system feeling inconsistent if some setting is missed.

    On the other hand, I suppose one could say that they want smaller physical sizes for their smaller physical display. I suppose in this case the problem is one of poor default sizes on these devices, or a lack of appropriate means of changing a wide range of settings in a coordinated manner.

    I apologize if my previous post was overly judgemental or condemning; it was born of my frustration with the way small displays are handled – or more specifically, not. I see a lot of attention being paid to these devices, and I eagerly anticipate much improvement. Thank you for the work you have done, and are continuing to do.

  7. Hello and thank you for all this work. I think that your approach is very effective and intelligent. In facr, I just brought a hdtv and would like to use kde4 on it. As you seem to be very close to the project I hope that my throughts are heard 🙂 .
    First, my girlfriend has a bad sight so it is very important for her (and consequently for me) that the pc is fully useable and not a repellent as it is in our main room.
    As other people I think as you it would be wise if all icons could be set at custom size (ok it’s alerady planned)
    I also think there is a problem with big fonts and window decorations because the default theme doesn’t adapt very well to big titles.
    And at last it would be wise to be able to change mouse cursor size to have a bigger mouse cursor (if option is there, I didn’t find it). I don’t know how all this is anaged by kde and X these days so I didn’t try to modify the corresponding X option (cursor-size or the like)
    Also it would be wise to have big buttons on window decoration (proportionate to window decoration height/width).
    All of this is only polishing, I think you’re close to perfection and at last thank you.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s