You are not logged in.

#1 2018-09-28 11:29:46

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,390

Firefox (and chromium) font substitution problem

Hi all.
I don't like the new Gmail look, expecially how roboto font does look.
So i made a font replacement rule in my: ~/.config/fontconfig/conf.d/20-substitutions.conf:

    <match target="pattern">
        <test qual="any" name="family"><string>Roboto</string></test>
        <edit name="family" mode="assign_replace"><string>Liberation Sans</string></edit>
    </match>

It seems to work every where in the system (at least in gtk2 and qt5 apps, it works), but firefox seems to completely ignore it.
I already tried to set gfx.font_rendering.fontconfig.max_generic_substitutions to 127 as the Arch Wiki suggests, but this made no difference at all.

Is there something else i need to do?

-EDIT-
"stracing" firefox does show that it reads my 20-substitutions.conf file.
Ugly hack: modifying the strings of liberation sans with the ones of roboto... firefox pick the hacked font, not really a solution of course.

As a workaround for my specific case, this stylish snippet seems to work:

@namespace url(http://www.w3.org/1999/xhtml);
div { font-family: "Liberation Sans", Tahoma, Verdana !important; }

...but still, i'd like to know why firefox seems to ignore fontconfig rules.

Thanks!

Last edited by kokoko3k (2018-09-28 12:15:26)


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

#2 2018-09-28 12:16:40

seth
Member
Registered: 2012-09-03
Posts: 49,981

Offline

#3 2018-10-01 06:32:20

bilabila
Member
Registered: 2018-08-07
Posts: 23
Website

Re: Firefox (and chromium) font substitution problem

I prefer override fonts globally which may not what you want
Gmail in chromium can use custom font with just fontconfig tweak
Firefox uncheck 'Allow pages to choose their own fonts, instead of your selections above' can achieve this too

<fontconfig>
    <match>
        <test qual='all' name='family' compare='not_eq'><string>mmonospace</string></test>
        <!--<test qual='all' name='family' compare='not_eq'><string>fontawesome</string></test>-->
        <test qual='all' name='family' compare='not_eq'><string>zhunyuan</string></test>
        <!--<test qual='all' name='family' compare='not_eq'><string>times new roman</string></test>-->
        <!--<test qual='all' name='family' compare='not_eq'><string>simhei</string></test>-->
        <!--<test qual='all' name='family' compare='not_eq'><string>simsun</string></test>-->
        <test qual='all' name='family' compare='not_contains'><string>symbols</string></test>
        <edit name='family' mode="assign_replace"><string>yahei consolas hybrid</string></edit>
    </match>
    <alias>
        <family>yahei consolas hybrid</family>
        <accept><family>mmonospace</family></accept>
    </alias>
    <alias>
        <family>mmonospace</family>
        <prefer><family>monospace</family></prefer>
    </alias>
</fontconfig>

Last edited by bilabila (2018-10-01 07:40:53)

Offline

#4 2018-10-01 07:12:27

seth
Member
Registered: 2012-09-03
Posts: 49,981

Re: Firefox (and chromium) font substitution problem

The point is that rewriting the system wide font resolution in order to alter the fonts in *one* webpage is to crack the nut with a sledgehammer.
Also you direct the browser to ignore the CSS font control (in favor of the configured set of fonts) - globally!

I can't say why the browsers ignore the family substitution, but they've got a track record of ignoring/replacing various fontconfig items (notably hinting and anti-aliasing are brought up often)

Offline

#5 2018-10-01 11:00:18

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,390

Re: Firefox (and chromium) font substitution problem

Well, in the end i used the following for stylish:

@namespace url(http://www.w3.org/1999/xhtml);
div { 
   font-family: "Liberation Sans", Tahoma, Verdana !important;
    /*font-size: 14px important;*/
    letter-spacing: 0px !important;
}

The letter-spacing thing is because any value higher than zero breaks kerning in firefox.


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

Board footer

Powered by FluxBB