Changing monospace fonts system-wide

fontconfigfontstrisquel

By default, the monospace font for my distribution (Trisquel) is Font A. I would like to change it to font B. Some time ago, I managed to make a partial change to Font C, but I have since forgotten this method and cannot reproduce it.

The trouble is that now I may see all three fonts in monospaced contexts. Using gnome-tweak-tool as both root and user, I have changed the "monospace" field to Font B. I have also done this via the command line on gsettings, again as both root and user. However:

  • If a web page requests the style {font-family: monospace;}, Font C displays. Edit: this was a setting in Firefox, which I have changed.
  • In the Inkscape and gedit font menus, there is a font called simply "Monospace", which is font A. My distribution's default UI fonts, which I have changed, also display in these menus under the names "Sans" and "Serif".
  • When Thunderbird messages I have received are formatted as plain text, they are displayed in Font A. Unless explicitly changed, messages I write also display in the fonts "Sans" and "Monospace".

How can I fix this situation, such that Font B displays in all contexts described above, and the mysterious "Sans" font is replaced by the UI font I am currently using?

Best Answer

Add this to yours ~/.config/fontconfig/fonts.conf file to set Font B as default monospace font

<match target="pattern">
  <test name="family" qual="any">
    <string>monospace</string>
  </test>
  <edit binding="strong" mode="prepend" name="family">
    <string>Font B</string>
  </edit>
</match>

Or to /etc/fonts/local.conf to set it system-wide.

Related Question