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/.
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>
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?