Ubuntu – the correct Fontconfig syntax for substituting a given uninstalled font with an installed font

fonts

The Fontconfig documentation is fairly opaque. I want applications looking up the 'Helvetica' family to instead receive the 'Helvetica LT Std' family and display that font, browsers in particular. The latest XML file I wrote to ~/.fontconfig/fonts.conf was

<fontconfig>

    <match target="pattern">
        <test name="family" target="default" compare="eq">
            <string>Helvetica</string>
        </test>
        <edit name="family" mode="assign">
            <string>Helvetica LT Std</string>
        </edit>
    </match>

</fontconfig>

What am I doing wrong and what would be a correct way to express this substitution?

Best Answer

This works for me to replace Arial with Ubuntu

<!--?xml version="1.0"?>-->
<!--DOCTYPE fontconfig SYSTEM "fonts.dtd">-->
<!-- ~/.fonts.conf for per-user font configuration -->
<fontconfig>
<match>
    <test name="family"><string>Arial</string></test>
    <edit name="family" mode="prepend" binding="strong">
        <string>Ubuntu</string>
        <string>Arial</string>
    </edit>
</match>
</fontconfig>

I found fc-match to be super helpful.

Also, I am on Precise so I use ~/.fonts.conf. In Quntal I understand you should use ~/.config/fontconfig/fonts.conf