4

I am using Iceweasel browser (rebranded Firefox) on Debian with XFCE4.

I have defined an alias rule in my ~/.config/fontconfig/fonts.conf.

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <alias>
        <family>Consolas</family>
        <prefer><family>DejaVu Sans Mono</family></prefer>
    </alias>
</fontconfig>

The output of fc-match confirms that Consolas would now be substituted as DejaVu Sans Mono.

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

Now, see the following output in the browser for JSFiddle: http://jsfiddle.net/yyvgcw02/.

enter image description here

The above screenshot shows that the browser has correctly used DejaVu Sans Mono for Consolas and Nimbus Mono L for Courier.

However, I was expecting it to use DejaVu Sans Mono for Consolas, Courier as well but the above output shows that it has used Nimbus Mono L again for Consolas, Courier?

Why did it not use DejaVu Sans Mono for Consolas, Courier even though Consolas appears first in the list and the font for it, i.e. DejaVu Sans Mono, is available on the system?

Even the following ~/.config/fontconfig/fonts.conf has no effect. The output of fc-match and the output in browser remain the same with the following configuration.

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <match>
        <test name="family"><string>Consolas</string></test>
        <edit name="family"><string>DejaVu Sans Mono</string></edit>
    </match>
</fontconfig>

Known solution

Here is a solution that works for me. If I add binding="strong" attribute to the edit tag as shown below in ~/.config/fontconfig/fonts.conf, then the browser uses DejaVu Sans Mono for font-family: Consolas, Courier as shown in the screeshot below.

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <match>
        <test name="family"><string>Consolas</string></test>
        <edit name="family" binding="strong"><string>DejaVu Sans Mono</string></edit>
    </match>
</fontconfig>

enter image description here

Question

I want to understand why is binding="strong" necessary for the browser to be able to use DejaVu Sans Mono for font-family: Consolas, Courier on Debian?

Even without binding="strong", fc-match Consolas was outputting DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book" but why wasn't the browser able to use DejaVu Sans Mono in that case?

Lone Learner
  • 18,088
  • 20
  • 102
  • 200
  • Does the problem also occur on other browsers/OS? – Bram Vanroy Jun 21 '15 at 09:37
  • @BramVanroy I only have Firefox/Windows as another browser/OS. In Windows, there is no `fc-match` and the `Consolas` font is readily available, so I don't see this problem there. In `Firefox/Windows`, `Consolas` font is used when I specify `font-family: Consolas, Courier` in CSS. – Lone Learner Jun 21 '15 at 15:39
  • I can say that the problem occurs also on my systems: Firefox, Midori and dwb browsers all show this issue in different flavours of Debian, Chromium oddly doesn't. It seems related to fontconfig rather than the browsers, but I cannot be sure. – Daniele Feb 15 '17 at 10:05

0 Answers0