11 votes

Firefox refuses to use fonts in ~user/.config/fontconfig/fonts.conf

I have the following on my fonts.conf

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <alias>
    <family>system-ui</family>
    <prefer>
      <family>FreeSans</family>
    </prefer>
  </alias>
</fontconfig>

But when websites use font-family: system-ui firefox just ignores this and uses Cantarell anyway, which I don't even know where it is getting it from. (Not Firefox font preferences).

Any idea how to make firefox respect my fonts.conf?

This is Linux with i3.

13 comments

  1. [4]
    Bauke
    Link
    By chance is Firefox installed through Snap or Flatpak? I know that can sometimes cause issues like this. Also, have you run fc-cache?

    By chance is Firefox installed through Snap or Flatpak? I know that can sometimes cause issues like this.

    Also, have you run fc-cache?

    5 votes
    1. [3]
      simao
      Link Parent
      No, I am using arch and installed using pacman. Yeah I ran fc-cache and restarted firefox but no change.

      No, I am using arch and installed using pacman.

      Yeah I ran fc-cache and restarted firefox but no change.

      3 votes
      1. [2]
        Bauke
        Link Parent
        Hmm, I took a look at my own fontconfig and noticed the DOCTYPE is slightly different: <!DOCTYPE fontconfig SYSTEM 'urn:fontconfig:fonts.dtd'> I'm not all that familiar with fontconfig so I don't...

        Hmm, I took a look at my own fontconfig and noticed the DOCTYPE is slightly different:

        <!DOCTYPE fontconfig SYSTEM 'urn:fontconfig:fonts.dtd'>
        

        I'm not all that familiar with fontconfig so I don't know if it matters, but maybe try changing that?

        2 votes
        1. simao
          Link Parent
          Tried it, still the same :| Thanks though

          Tried it, still the same :| Thanks though

          3 votes
  2. [2]
    Jessica
    Link
    Just as a sanity check, do you have your desired font and its config under /etc/fonts/conf.d/ and symlinked correctly?

    Just as a sanity check, do you have your desired font and its config under /etc/fonts/conf.d/ and symlinked correctly?

    4 votes
    1. simao
      Link Parent
      Yeah I can use the font in other apps..

      Yeah I can use the font in other apps..

  3. [4]
    bhrgunatha
    (edited )
    Link
    Sorry for these basic checks but: What are the results of: fc-match system-ui echo $XDG_CONFIG_HOME fc-conflist Does "+ /etc/fonts/conf.d/50-user.conf" appear in the output of fc-conflist? If so...

    Sorry for these basic checks but:

    What are the results of:

    1. fc-match system-ui
    2. echo $XDG_CONFIG_HOME
    3. fc-conflist

    Does "+ /etc/fonts/conf.d/50-user.conf" appear in the output of fc-conflist?

    • If so what is the output of: cat /etc/fonts/conf.d/50-user.conf
    • If not try adding it to /etc/fonts/conf.d/ - sudo ln -s /usr/share/fontconfig/conf.default/50-user.conf /etc/fonts/conf.d/

    After that although you said you used fc-cache did you use the flags fc-cache -frv?

    2 votes
    1. [3]
      simao
      Link Parent
      The output of fc-match is a bit strange but I think this is documented behavior: ~ ❯ fc-match 'system ui' FreeSans.otf: "FreeSans" "Regular" ~ ❯ fc-match 'system\-ui' FreeSans.otf: "FreeSans"...

      The output of fc-match is a bit strange but I think this is documented behavior:

      ~ ❯ fc-match  'system ui'
      FreeSans.otf: "FreeSans" "Regular"
      ~ ❯ fc-match  'system\-ui'
      FreeSans.otf: "FreeSans" "Regular"
      ~ ❯ fc-match system-ui
      SF-Pro-Display-Regular.otf: "SF Pro Display" "Regular"
      

      /etc/fonts/conf.d/50-user.conf is in the output of fc-conflist and loads my font.conf:

      <?xml version="1.0"?>
      <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
      <fontconfig>
        <description>Load per-user customization files</description>
      	<!--
      	    Load per-user customization files where stored on XDG Base Directory
      	    specification compliant places. it should be usually:
      	      $HOME/.config/fontconfig/conf.d
      	      $HOME/.config/fontconfig/fonts.conf
      	-->
      	<include ignore_missing="yes" prefix="xdg">fontconfig/conf.d</include>
      	<include ignore_missing="yes" prefix="xdg">fontconfig/fonts.conf</include>
      	<!-- the following elements will be removed in the future -->
      	<include ignore_missing="yes" deprecated="yes">~/.fonts.conf.d</include>
      	<include ignore_missing="yes" deprecated="yes">~/.fonts.conf</include>
      </fontconfig>
      

      $XDG_CONFIG_HOME is set to $HOME/.config I had used fc-cache -fv but just tried with -r and still get the same font... :|

      1 vote
      1. [2]
        bhrgunatha
        Link Parent
        That seems to point at firefox. Either a bug (possible but unlikely) or a configuration clash somewhere which is my guess. I once had a similar strange font replacement that I couldn't track down....

        That seems to point at firefox. Either a bug (possible but unlikely) or a configuration clash somewhere which is my guess.

        I once had a similar strange font replacement that I couldn't track down.

        In the Fonts section of about:preferences I was told to check the default font setting, but also to click the Advanced... button. In the Fonts For dropdown to check the settings for both Latin (because my language is set to English), but also for Other Writing Systems.

        In my case, those 2 settings were different and setting them all to be identical caused my problem to disappear.

        The only other advice I can think of is to open about:config, search for font (there will be a lot of results) and see if Cantarell appears somewhere in those advanced settings.

        Other than that I'm out of ideas and it may be worth filing a bug report. The experts will have far better troubleshooting skills than me.

        1 vote
        1. simao
          Link Parent
          tried that but didn't change. Thanks for your help anyway. I think I'll just try to get used to Cantarell :|

          tried that but didn't change. Thanks for your help anyway. I think I'll just try to get used to Cantarell :|

  4. [3]
    sparksbet
    Link
    In the past I had issues with Firefox not displaying an installed font, and the solution was decreasing Firefox's sandbox level in about:support. It's been a while since I did this so I don't...

    In the past I had issues with Firefox not displaying an installed font, and the solution was decreasing Firefox's sandbox level in about:support. It's been a while since I did this so I don't remember the details well enough to be better than just googling it, but that's what worked for me so it may be worth trying out.

    1 vote
    1. [2]
      simao
      Link Parent
      I am using privacy.resistFingerprinting and layout.css.font-visibility.resistFingerprinting but I just disabled these and I still get the same font. Do you remember the setting you used? I also...

      I am using privacy.resistFingerprinting and layout.css.font-visibility.resistFingerprinting but I just disabled these and I still get the same font. Do you remember the setting you used?

      I also tried with a new fresh profile and I get the wrong font :|

      1. sparksbet
        Link Parent
        I think it was security.sandbox.content.level -- it was definitely under security.sandbox and its value was an integer. Decreasing it (idr whether I needed 2 or 3 but I think the default was 4)...

        I think it was security.sandbox.content.level -- it was definitely under security.sandbox and its value was an integer. Decreasing it (idr whether I needed 2 or 3 but I think the default was 4) and then restarting firefox then allowed certain installed fonts to be used for me.

        1 vote