1

I am using Debian with XFCE.

Default behavior: No match or alias

First, let me show the default behavior of my system when ~/.config/fontconfig/fonts.conf has no match or alias tags.

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
</fontconfig>

In this case, fc-match outputs the following for Courier and Consolas.

lone@debian:~$ fc-match Courier
n022003l.pfb: "Nimbus Mono L" "Regular"
lone@debian:~$ fc-match Consolas
DejaVuSans.ttf: "DejaVu Sans" "Book"

Custom behaviour: When match is defined

Now I have the following in ~/.config/fontconfig/fonts.conf.

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <!-- Courier => DejaVu Sans Mono -->
    <match>
        <test name="family"><string>Courier</string></test>
        <edit name="family"><string>Deja Vu Sans Mono</string></edit>
    </match>

    <!-- Consolas => DejaVu Sans Mono -->
    <match>
        <test name="family"><string>Consolas</string></test>
        <edit name="family"><string>Deja Vu Sans Mono</string></edit>
    </match>
</fontconfig>

In this case, fc-match outputs the following.

lone@debian:~$ fc-match Courier
n022003l.pfb: "Nimbus Mono L" "Regular"
lone@debian:~$ fc-match Consolas
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"

Here we see that the system has respected my substitution rule for Consolas, but it has not respected my substitution rule for Courier. Why is output of fc-match Courier still "Nimbus Mono L" and not "DejaVu Sans Mono"?

3

I know this question is likely to be outdated, but I have come across it on my own search for a solution to override the systems replacement of Arial with Liberation Sans, which I disliked on a fresh Kubuntu Xenial 16.04 desktop.

If overriding fontconfig's default replacements for your user is what you want, maybe you are interested to read my post on Askubuntu: https://askubuntu.com/a/793363/306420

Short summary

On modern systems, fontconfig pulls user config from ~/.config/fontconfig/fonts.conf or (better for the purpose of separation) ~/.config/fontconfig/conf.d.

In my case I wanted Firefox to render text with a CSS font-family set to prefer Arial using Noto Sans. Fontconfig is configured by default to use Liberation Sans as metrical drop-in for Arial (/etc/fonts/conf.avail/30-metric-aliases.conf), which at first seemed impossible to override without altering fontconfig's main config files.

After long search, trial and error the solution was dead simple: Overrides are respected when in the mentioned user directories and named according to fontconfig's expectations in the form [0-9][0-9]*.conf (see /etc/fonts/conf.avail/50-user.conf and /etc/fonts/conf.d/README).

My working configuration to override Arial:

~/.config/fontconfig/conf.d/00-arial-noto.conf

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <!-- Map Arial to Noto Sans instead of Liberation Sans
       (overrides /etc/fonts/conf.d/30-metric-aliases.conf) -->
  <alias binding="same">
    <family>Arial</family>
    <accept>
      <family>Noto Sans</family>
    </accept>
  </alias>
</fontconfig>

Check with fc-match Arial on the console as your user, it should output "Noto Sans" (or whatever your new config is) without additional efforts.

After having spent half a day figuring all that out, including reading highly adventurous stories about brave fights in the realms of fontconfig, I hope this is of help for others.

0

If you haven't changed anything in the default configuration, the font configuration files in /etc/fonts/conf.d/ don't contain references to Consolas, so your setting is used for that one.

However, they do already contain entries for Courier, aliasing them to Nimbus Mono L.

So by the time your fonts.conf is parsed, Courier already has been processed and there is no longer a Courier to work on, only a Nimbus Mono L.

Solutions:

Either work on the font Nimbus Mono L in your fonts.conf.
If you write

<match>
    <test name="family"><string>Nimbus Mono L</string></test>
    <edit name="family"><string>DejaVu Sans Mono</string></edit>
</match>

then fc-match Courier will output DejaVu Sans Mono.

Or, remove the Courier aliases from all the .conf files in /etc/fonts/conf.d.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.