Angelos Orfanakos

Beautiful system fonts in Debian

Debian comes with DejaVu as the default system font which looks terrible (especially in Greek and bold).

Ubuntu looks much nicer and ships with all Ubuntu installations, so it’s somewhat considered a standard Linux font. Microsoft’s standard fonts (Arial, Verdana, Georgia, Times New Roman, etc) are also available in Debian.

This post provides instructions for setting Ubuntu as your default system font and adding support for Microsoft’s fonts (many websites use them).

Note: All commands are to be issued in a terminal.

Edit your system’s APT sources file as root (or with sudo) located at /etc/apt/sources.list and make sure it lists non-free (for the Ubuntu font) and contrib (for Microsoft’s fonts). For Debian Buster (current stable), you need something that looks like this:

deb http://ftp.debian.org/debian/ buster main contrib non-free
deb-src http://ftp.debian.org/debian/ buster main contrib non-free

Update the apt repository index:

sudo apt update

Install the font packages:

sudo apt install fonts-ubuntu fonts-liberation2 ttf-mscorefonts-installer

Create the directory to host the config file:

mkdir -p ~/.config/fontconfig/

Place the following configuration under ~/.config/fontconfig/fonts.conf:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <alias>
    <family>serif</family>
    <prefer>
      <family>Liberation Serif</family>
    </prefer>
  </alias>
  <alias>
    <family>sans-serif</family>
    <prefer>
      <family>Ubuntu</family>
    </prefer>
  </alias>
  <alias>
    <family>monospace</family>
    <prefer>
      <family>Ubuntu Mono</family>
    </prefer>
  </alias>
</fontconfig>

Go to your web browser settings and under font customization pick:

  • sans-serif (or sans) as default font
  • sans-serif (or sans) as sans-serif font
  • serif as serif font

To check everything works as expected issue:

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

The output should look something like:

serif: LiberationSerif-Regular.ttf: "Liberation Serif" "Regular"
sans-serif: Ubuntu-R.ttf: "Ubuntu" "Regular"
monospace: UbuntuMono-R.ttf: "Ubuntu Mono" "Regular"
Arial: Arial.ttf: "Arial" "Regular"
Helvetica: Arial.ttf: "Arial" "Regular"
Verdana: Verdana.ttf: "Verdana" "Regular"
Times New Roman: Times_New_Roman.ttf: "Times New Roman" "Regular"
Courier New: Courier_New.ttf: "Courier New" "Regular"

Note:

  1. Helvetica is not a free font and you need to buy it online and install it. Microsoft’s Arial is a good approximation of Helvetica and Debian comes with configuration to use it instead.
  2. You may need to logout and login again and/or restart programs for the changes to take effect.