[Fontconfig] Please clarify matching rules

Lawrence D'Oliveiro ldo at geek-central.gen.nz
Sun Aug 6 07:45:55 UTC 2017


On Sun, 16 Jul 2017 16:36:40 +0100, Colin Caine wrote:

> I would like `fc-match monospace` to give "Noto Mono". I currently
> only have Noto {Mono,Sans,Serif} and some pixel fonts installed. So
> I'm expecting `fc-match monospace` to receive "Noto Mono" or one of
> the pixel fonts. But what I actually get is "Noto Sans".
> 
> So I add:
> 
> 
>     <alias>
>       <family>Noto Mono</family>
>       <default>
>         <family>monospace</family>
>       </default>
>     </alias>
> 
> 
> But I still get Sans.

First of all, the <family> directives are the wrong way round: the
first one should contain the generic “monospace”, the second one the
specific “Noto Mono” you want to match.

Secondly, <default> places the font at the end of the match list. You
need <prefer> if you want it to go on the front.

Here’s what I tried putting in my own ~/.config/fontconfig/fonts.conf:

    <?xml version='1.0'?>
    <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
    <fontconfig>
        <alias>
            <family>monospace</family>
            <prefer>
                <family>Noto Mono</family>
            </prefer>
        </alias>
    </fontconfig>

Here’s what I got before doing the above:

    ldo at theon:~> fc-match monospace file family
    DejaVu Sans Mono:file=/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf

and here’s what I got after:

    ldo at theon:~> fc-match monospace file family
    Noto Mono:file=/usr/share/fonts/truetype/noto/NotoMono-Regular.ttf



More information about the Fontconfig mailing list