Post updated. Small fonts and window frames: a problem of lightweight window managers

Original entry from 6th of March

Usually things go fine. You have your Openbox, Fluxbox, PekWM or Awesome  etc.  window manager running and everything scales up nicely. Sometimes you end up into a situation where you are not that lucky: window frames are too small and the desktop font is just too tiny – and you cannot even read the text properly.

Luckily, the previous issues are easy to fix. Usually, the root cause of them is that you have a big display and your window manager does not know how to size things correctly by itself. Another reason might be that you have changed your wires. For example, I replaced a broken old HDMI wire with a newer one and the issues appeared. You should edit your .Xresources file to apply changes to Gtk and QT programs alike. If you are only using GTK apps it might be a bit easier to change your DPI value via .Xdefaults file.

DPI stands for dots per inch. The DPI value is usually the one that causes  the issues mentioned above, as it does not automatically  get a reasonable default with some configurations.

Below is my current .Xdefaults file as an example

XTerm*Background: black
XTerm*Foreground: green
xterm*ScrollBar: on
*XTerm*scrollBar: true
xterm*rightScrollBar: true
xterm*multiScroll: on
xterm*jumpScroll: on
xterm*scrollTtyOutput: false
xterm*savelines: 16384

#! double-click to select whole URL
xterm*charClass: 33:48,36-47:48,58-59:48,61:48,63-64:48,95:

#Mouse fix size issue
Xcursor.size:  34

#Set the DPI value
Xft.dpi: 96

Tweak to Xft.dpi to match your display’s value. The usual value is somewhere around 90 to 96.  Furthermore, 96 appears to be a general value to ensure compatibility between displays – so use it as a starting point if you are unsure.

Tip if you have followed all the steps here and your display is otherwise fine but the font is just a little bit too small consider installing something like lxappearance. Lxappearance “window elements” has a section like this.lxappearance, linux font size

If I would click the Sans button then a window would open, which would let me choose a bigger font size. Note that you really should adjust the DPI size before adjusting the font size. Adjusting the font size is not enough if the DPI value is wrong/not detected correctly.

The above way works primarily for GTK apps and the .Xresources way seems to work for GTK and QT apps alike. However, if you are in any doubt there is absolutely no harm in having duplicate  DPI values within  .Xdefaults and .Xresources

The .Xresources way

At this point your GTK applications should be fine, but if you run also QT based applications there are still few things to do. QT applications do still display fonts way too small (actually just like GTK 2/3 applications before .Xdefaults).

First you will need to create .Xresources file

Here is an example of my current .Xresources file , which also contains some font related tweaks:

Xft.dpi: 96
Xft.rgba: rgb
xft.antialias: true
Xft.hinting true

Save the file. Now, open your .xinitrc (or whatever you use to autostart) and place this inside of it before the final openbox (or any other) wm entry:

xrdb -merge ~/.Xresources &

Example .xinitrc file from my config:

sh /home/$USER/.wall/wall.sh &

#If needed below is how you manually set the keyboard (examples:en=english es=spain fi=finland be=belgium ee=estonia. See more from the values file)

#setxkbmap fi &
tint2 &
xset -dpms s off &
xbindkeys &
python /usr/share/launchy &
bluedevil-monolithic &
notify-send -t 7000  “Press Winkey + x to view shortkeys” &
xrdb -merge ~/.Xresources &
exec ck-launch-session dbus-launch –exit-with-session openbox

After this you should be all set. Remember that you need to quit/logout from your desktop so that changes can take effect. If in any doubt then just reboot
and all the changes should apply.

Important appendix: KDE applications still having small fonts (added 20th of March. Applies to KDE4 applications)

Just migrated to a new user profile and it seems I forgot one step. After this step your QT applications should display decently sized fonts. The previous being said, I still recommend that you do all the steps before this as well.

Create the following folder structure(replace username with your actual username:

/home/username/.kde/share/config

Put kcmfonts file inside the config folder.

Place this text (or similar) inside your kcmfonts file:

[General]
dontChangeAASettings=true
forceFontDPI=96

Now, exit desktop or reboot. If in any doubt just reboot to make sure that the new settings will apply.

Added 21st of March:Making KDE5 applications to display correct font sizes

If you are reading this and your KDE5 applications are still displaying small fonts then there are two things you can do.

First way: Start desktop without a display manager(startx way)

You can start your Xserver with startx. This means that you do not need to have any display manager like Gdm or Slim installed.

Your .xinitrc file should still have xrdb -merge ~/.Xresources & line in it – just to make certain that everything will work.

When you use startx, to go graphical, you will run startx command like this:

startx example, startx with custom dpi

The above will set the dpi value correctly for Kde5.

Second way: Add dpi line to display manager’s autostart

If you do not want to give up from your display manager then you can  install x11-server-utils.

For example: sudo apt-get install x11-xserver-utils
We need xrandr from the x11-server-utils package. With xrandr it is possible to set the dpi value as follows. I have this line on .xinitrc when I am using Slim display manager:

xrandr custom dpi

After all said and done, your KDE and Gtk applications should finally play well. I also still recommend that you go though all the steps mentioned in this post. Of course, be ready to adapt all the content to  your own needs.