markhuge MH\n s

Fontconfig Dotfiles

published:

signed with 0x683A22F9469CA4EB

tags:

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.

$XDG_CONFIG_HOME/fontconfig/conf.d/99-monospace.conf:

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

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!

About the Author

Mark Wilkerson

0x683A22F9469CA4EB

R&D engineer @ Twitch. Previously Blizzard, Hightail, Co-Founder @ SpeakUp

Mark is building open source tools to make web3 and decentralized self-ownership easy for regular people.

Live dev streams at Twitch.tv

More Posts