Changing the default fallback subsitution fonts in Linux

Sunday, Feb 7th, 2016

The default/fallback/substitution fonts are those used when an application or webpage doesn't specify a specific font or when a character glyph is not available in the selected font. When the CSS contains "font-family: sans", which font is that?
Note: I'm using an Ubuntu-based distribution, but the details should apply anywhere fontconfig is used.

Tools:

Character Map(mucharmap) - Right click on any character to see the name of the source font.

fc-list - Lists available fonts

fc-match - Display a list of what fonts will be used for a specific named font. Example: fc-match -s "Liberation Sans"

Changing the defaults

The Linxu font configuration is stored in /etc/fonts/fonts.conf with additional enabled files in /etc/fonts/conf.d/. The files in /etc/fonts/conf.d/ are explained by the README file:

Each file in this directory is a fontconfig configuration file. Fontconfig
scans this directory, loading all files of the form [0-9][0-9]*.conf.
These files are normally installed in /usr/share/fontconfig/conf.avail
and then symlinked here, allowing them to be easily installed and then
enabled/disabled by adjusting the symlinks.
The files are loaded in numeric order, the structure of the configuration
has led to the following conventions in usage:
Files begining with: Contain:
00 through 09 Font directories
10 through 19 system rendering defaults (AA, etc)
20 through 29 font rendering options
30 through 39 family substitution
40 through 49 generic identification, map family->generic
50 through 59 alternate config file loading
60 through 69 generic aliases, map generic->family
70 through 79 select font (adjust which fonts are available)
80 through 89 match target="scan" (modify scanned patterns)
90 through 99 font synthesis

Yes it is XML! Similar files exist for serif and monospaced fonts. The solution is to specify updated information in your user configuration or add a new file to change the option system-wide. Your user configuration goes in ~/.config/fontconfig/fonts.conf. An example changing the system defaults to use the Liberation font set: