StumpWM and fonts

Getting StumpWM to play nice with fonts was a headache on my HiDPI laptop so I thought to write a post about my adventure to help others who may want to modify the appearance of this great window manager.

1 StumpWM Contrib

First of all, you’re going to need the contrib repo — a collection of StumpWM modules. Clone that somewhere on your computer, preferably in the same directory with your StumpWM config.

I have my config in ~/.config/stumpwm, so I cloned that repo into ~/.config/stumpwm/stumpwm-contrib.

(defvar *stumpwm-config-dir* "~/.config/stumpwm")
(set-module-dir "~/.config/stumpwm/stumpwm-contrib")

Then you’ll need to load a specific module for fonts:

(load-module "ttf-fonts")

2 Changing fonts

To make StumpWM use a specific font, you’d write something like this:

(set-font (make-instance 'xft:font
                         :family "Source Code Pro"
                         :subfamily "Regular"
                         :size 10))

But none of this will work, because you’re missing a dependency. ttf-fonts requires clx-truetype. This package seems to no longer be available on quicklisp, but I managed to find the sources and put up a repository along with a Guix package.

I don’t know how you would go about installing clx-truetype if you’re not on Guix and your distribution doesn’t have it packaged already (I think Arch has it in their repos).

If you have the luck to be on Guix, to get it first add my channel to your ~/.config/guix/channels.scm:

 (list ;; your other channels
        (name 'brown121407)
        (url "https://git.sr.ht/~brown121407/guix.121407.xyz")))

Do a guix pull after that and then guix install sbcl-clx-truetype. You should be ready now.

One more thing you need to do is put this into your StumpWM config, before set-font, and follow the advice given in the comment (this applies for the first setup too, because you want fonts to be indexed):

;; Uncomment this whenever installing new fonts to refresh cache