Fontconfig Dotfiles

Published by Mark on

If you’re using a minimal Linux distro, you’ve probably noticed that your fonts are pretty wonky out of the box.

Override default monospace font

The fallback for pretty much everything that displays code or terminal output is “monospace”. Instead of setting up overrides in individual applications, you can just override it globally (for your user) in fontconfig.

In this example we return “Source Code Pro” whenever we match mono.


<?xml version="1.0"?><!DOCTYPE fontconfig SYSTEM "fonts.dtd">
        <prefer><family>Source Code Pro</family></prefer>

Your browsers will use this font for rendering otherwise unstyled monospace content (<pre> and <code> tags for example).

If you use suckless utils, most of them hardcode a font name at compile time. With this, you can set all of them to “mono” in your builds, and it’ll use the override. Now you can ditch the Xresources patch!