5

I am using Iceweasel browser (Firefox derivative) on Debian system with an XFCE4 desktop.

I have not defined any custom font substitution in ~/.config/fontconfig/fonts.conf.

This what fc-match tells me currently.

lone@debian:~$ fc-match "Liberation Mono"
n022003l.pfb: "Nimbus Mono L" "Regular"
lone@debian:~$ fc-match Courier
n022003l.pfb: "Nimbus Mono L" "Regular"
lone@debian:~$ fc-match monospace
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"

So I expect that when I have an HTML, using 'Liberation Mono' font should provide same results as using 'Courier'. But as can be seen in the screenshot below, this is not the case (JSFiddle: http://jsfiddle.net/8L3rmyxn/).

enter image description here

I clicked on 'Inspect Element' and found the actual fonts used.

For the text using 'Liberation Mono' in CSS, the browser uses 'DejaVu Serif' instead which is not consistent with the output of fc-math.

For the text using 'Courier' in CSS, the browser uses 'Nimbus Mono L' which is consistent with the output of fc-match.

For the text using 'monospace' in CSS, the browser uses 'DejaVu Sans Mono' which is again consistent with the output of fc-match.

Question

Why is it that in case of 'Liberation Mono' font, the browser does not use 'Nimbus Mono L' and instead uses 'DejaVu Serif' font?

Known resolution

Note that I know a way to resolve this issue. If I define an alias for 'Liberation Mono' explicitly in ~/.config/fontconfig/fonts.conf then I get the desired results, i.e. text in 'Liberation Mono' font and text in 'Courier' font appear similar.

lone@debian:~$ cat ~/.config/fontconfig/fonts.conf 
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <alias>
        <family>Liberation Mono</family>
        <prefer><family>Nimbus Mono L</family></prefer>
    </alias>
</fontconfig>
lone@debian:~$ fc-match "Liberation Mono"
n022003l.pfb: "Nimbus Mono L" "Regular

enter image description here

Question, again

But my question remains. Why is it that without this explicit alias in fonts.conf, when I specify 'Liberation Mono' font in the CSS, the browser does not use 'Nimbus Mono L' and instead uses 'DejaVu Serif' font, even though the fc-match "Liberation Mono" outputs the same thing regardless of whether I have defined an alias in fonts.conf or not?

Lone Learner
  • 18,088
  • 20
  • 102
  • 200

1 Answers1

1

By default Firefox only allows a maximum of 3 replacements via fontconfig.

You can set gfx.font_rendering.fontconfig.max_generic_substitutions in about:config to increase this limit. The highest value allowed is 127.

Miles B Huff
  • 98
  • 1
  • 2
  • 9
  • 2
    According to [this issue](https://bugzilla.mozilla.org/show_bug.cgi?id=1243226) this limit is in place because *"Including a lot of extra fonts slows down font fallback when it occurs, so putting in an artificial limit was best thing"*. So setting this limit to 127 *may* not be the best idea depending on system speed etc. – Martin Tournoij Nov 28 '16 at 06:30