0

Many of the fonts, including those from the package manager (currently running a Arch System) don't include the generic family as "serif", "monospace" and "cursive". So I have to indicate the correct family manually (see also https://eev.ee/blog/2015/05/20/i-stared-into-the-fontconfig-and-the-fontconfig-stared-back-at-me/).

But for "monospace" fonts, there's a workaround: they all have the spacing property of 100. You can check this by running fc-list :spacing=100 (see also https://unix.stackexchange.com/a/363368/473666). So the idea is to automatically set every font with this property value as a "monospace" font.

As an example, in the default configuration files and documentation, they set every font that don't have "serif" and "monospace" as "sans-serif" this way:

  <match target="pattern">
    <test qual="all" name="family" compare="not_eq">
            <string>sans-serif</string>
    </test>
    <test qual="all" name="family" compare="not_eq">
            <string>serif</string>
    </test>
    <test qual="all" name="family" compare="not_eq">
            <string>monospace</string>
    </test>
    <edit name="family" mode="append_last">
            <string>sans-serif</string>
    </edit>
  </match>

So, I tried this:

  <match target="pattern">
    <test qual="all" name="spacing" compare="eq"> 
      <int>100</int>
    </test>
    <test qual="all" name="family"  compare="not_eq"> 
      <string>monospace</string>
    </test>
    <edit name="family" mode="append_last"> 
      <string>monospace</string>
    </edit>
  </match>

The result: EVERY font on the system is now monospace. This also happens changing <int>100</int> for <const>mono</const>. I already read the man fonts.conf and many of the default configuration files listed in fc-conflist but I couldn't make it work. I tried multiple combinations of properties and their values, but the result always is either NONE or EVERY font is treated as monospace.

For now, I used this command to generate a list of sources and added them all manually: fc-list :spacing=100 | awk -F: '{print $2}' | sort -u. This is my first time asking something in Stack Exchange, I hope I managed to make it clear.

2 Answers 2

1

Remove the argument qual="all" in the test for spacing. This is used to specify the behavior when testing a list (i.e. family is a list of strings). A scalar test with qual="all" always succeeds. That's a bug in fontconfig.

1
  • still doesn't work, I guess that's not the only problem
    – imsamuka
    Aug 25, 2021 at 16:57
0

I needed to change my match target, to <match target=font>, in order to test for spacing; I don't think fontconfig knows spacing at pattern match time.

I haven't tried setting the font family yet, since I don't need it, but a modified config let me turn off antialiasing in GNOME Terminal for console text only:

<match target="font">
  <test name="spacing" compare="eq">
    <int>100</int>
  </test>
  <test name="prgname" compare="contains">
    <string>gnome-terminal</string>
  </test>
  <edit name="antialias" mode="assign">
    <bool>false</bool>
  </edit>
</match>

Tested on fontconfig version 2.13.1.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .