r/archlinux 1d ago

SUPPORT Fontconfig: weird behaviour when setting system-ui

when i fc-match "system ui" it successfully binds to Roboto, but when i fc-match "system-ui" it binds to noto sans

    <?xml version="1.0"?>
    <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
    <fontconfig>
      <alias binding="strong">
        <family>serif</family>
        <prefer>
          <family>Noto Serif</family>
        </prefer>
      </alias>
      <alias binding="strong">
        <family>sans-serif</family>
        <prefer>
          <family>Noto Sans</family>
        </prefer>
      </alias>
      <alias binding="strong">
        <family>monospace</family>
        <prefer>
          <family>Jetbrains Mono</family>
        </prefer>
      </alias>
      <alias binding="strong">
        <family>system-ui</family>
        <prefer>
          <family>Roboto</family>
        </prefer>
      </alias>
    </fontconfig>

this is my /etc/fonts/local.conf

0 Upvotes

2 comments sorted by

1

u/Vegetable-Company572 1d ago

you've got "system ui" with a space matching roboto but "system-ui" with a hyphen falling back to noto sans, that's the issue. fontconfig treats hyphenated family names differently, the alias for system-ui is probably being overridden by the sans-serif preference since noto sans gets picked up first in the fallback chain

try adding the hyphenated alias before the generic sans-serif alias in your config, or check if there's another config file in /etc/fonts/conf.d that's messing with system-ui

0

u/_zepar 1d ago

i looked, and nothing in any conf.avail or /etc/fonts/conf.d really matches system-ui maps it to another generic family, just a bunch of mapping of common fonts to system-ui in 40-nonlatin and 45-latin, and then default font options for it in 60-nonlatin and 65-latin. i dont really know what 48-guessfamily is doing with it, but it looks innocent enough

<!-- system-ui -->
<match target="pattern">
  <test name="family" compare="contains">
    <string>system-ui</string>
  </test>
  <test qual="all" name="genericfamily" compare="contains">
    <const xsi:nil="true"/>
  </test>
  <edit name="genericfamily" mode="append">
  <const>system-ui</const>
  </edit>
</match>