Skip to content

Instantly share code, notes, and snippets.

@robin-a-meade
Last active June 24, 2024 02:31
Show Gist options
  • Save robin-a-meade/70d09c6704091700fc2d441a6a283b65 to your computer and use it in GitHub Desktop.
Save robin-a-meade/70d09c6704091700fc2d441a6a283b65 to your computer and use it in GitHub Desktop.
fonts.config to switch from DejaVu to Liberation

Switch to Liberation from DejaVu for better font-handling in Firefox

Test page: https://en.wikipedia.org/wiki/User:Kaldari/Font_test

Firefox defaults to the system defaults, so it's best to make the change at the system level than in Firefox preferences.

First, check current defaults

for family in serif sans-serif monospace Arial Helvetica Verdana "Times New Roman" "Courier New"; do
  echo -n "$family: "
  fc-match "$family"
done

See: https://jichu4n.com/posts/how-to-set-default-fonts-and-font-aliases-on-linux/

Then set your system defaults by creating ~/.config/fontsconfig/fonts.conf and editing it.

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<!-- file: $HOME/.config/fontconfig/fonts.conf -->
<fontconfig>
<!-- Set preferred serif, sans serif, and monospace fonts. -->
<alias>
<family>serif</family>
<prefer><family>Liberation Serif</family></prefer>
</alias>
<alias>
<family>sans-serif</family>
<prefer><family>Liberation Sans</family></prefer>
</alias>
<alias>
<family>sans</family>
<prefer><family>Liberation Sans</family></prefer>
</alias>
<alias>
<family>monospace</family>
<prefer><family>Source Code Pro</family></prefer>
</alias>
</fontconfig>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment