Kubuntu and HiDPI Screen

Kubuntu/KDE is not perfect on HiDPI screen. Currently, there is no utility to automatically detect and scale the UI based on device screen resolution and Dots Per Inch (DPI) value, but the workaround to make Kubuntu more usable on HiDPI screen is quite simple.

It is worth noting that scaling the screen display by 2.0 may not be right and scaling it higher than 2x may not be right either because there will be minor UI glitch such as menu that seems to be cramped. Still, by applying the right screen scaling and accurate DPI, applications will be more proportional and text are rendered crisper.

 Why This is Needed

When setting the scale value to 2.0, Kubuntu/KDE will imply the desktop as having lower screen resolution than it actually has, applications dimension will get rendered bigger in the context where it is not having the proportional size. Have a look at the differences when an application are scaled to 2.0 and 2.8

Accurately Counting the DPI and Scale Display

Finding the accurate DPI value is essential to find the accurate scaling value for the screen.

First of all, we need to grep the connected screen: xdpyinfo | grep -B2 resolution.

On my laptop, the output is:

 dimensions: 3200x1800 pixels (302x169 millimeters)

Since the value must be in inch, we then need to convert the value based on the output, so it is 302 ÷ 25.4 and then divide 3200 by 11.88. The result is 269. So this is it, the accurate DPI value for the 2015 HP Envy 13 is 269 DPI.

By default, the DPI value in KDE is set to 96 DPI. To find the accurate display scaling value we need to divide the accurate DPI by 96, so it is 269 ÷ 96 which is 2.8.

Now head to System Settings > Fonts > Force fonts DPI to set the DPI value and to System Settings > Display and Monitor > Display Configuration > Scale Display to scale the screen display, then re-login.

After scaling the display the UI will looks rather odd where the icon seems too small, so we need to readjust the icon size, this must be done manually as KDE will not scale it automatically when non-integer value is set. Head to System Settings > Icons > Advanced and double everything in there.

Now, verify if the system is using the given DPI value with xdpyinfo | grep dots. Finally to make the changes survive system reboot, we need to create a file named 77set_dpi and enter xrandr --dpi 269x269 in /etc/X11/Xsession.d/

$ nano /etc/X11/Xsession.d/77set_dpi

xrandr --dpi 269x269

Other best practice is to create .Xresources in /home/USER/, so that non DE’s applications will also use the given DPI value as well as other display configuration such as anti-aliasing and font hinting. My .Xresources parameter is as follows:

Xft.dpi: 269
Xft.autohint: 0
Xft.lcdfilter: lcddefault
Xft.hintstyle: hintslight
Xft.hinting: 1
Xft.antialias: 1
Xft.rgba: rgb

I hope this workaround are helpful for those wanting to have accurate display dimension on their Kubuntu/KDE Desktop. Cheers!

Giri Alam
My name is Giri Alam Wigunnara. I live in the beautiful, yet hectic city of Bandung in Indonesia. I am currently a graduate student at Parahyangan Catholic University studying International Relations. Besides politics, my other interest is in open source technology. I have been a Linux user since 2007, and have contributed to several open source projects since then. I enjoy blues music and old movies. Recently I have travelled widely around the ten ASEAN nations, as I see great potential in them and together with some friends, I export and import spices, fruits and leather into the region.