Can I override fonts installed by ttf-mscorefonts-installer, prefer Liberation fonts?

Solution 1:

fontconfig employs a complete set of font substitution systems. There are different levels of font definition: font name and font families. Given a specific font, fontconfig uses the font of the same name if available, then seeks otherwise the font family of the same name. If there is still no match, it uses the standard font family definition as substitution, i.e. Sans, Sans-serif and Mono.

Ubuntu has the font family 'Verdana' defined in `/etc/fonts/conf.d/45-latin.conf', where 'Verdana' is set default to 'Sans-serif', which means Sans-serif is employed for 'Verdana' by default. But 'Verdana.ttf' would be used instead if it's installed.

In your system, the preferred font in the Sans-serif family is 'Liberation Sans', so fontconfig uses the 'Liberation Sans' as substitution for 'Verdana' provided there is no font of the same name, whereas uses 'Verdana.ttf' if it's in the search path. This explains what you've posted.

So the solution to your problem is that, you have to remap the font 'Verdana' to a different font, or to a group of fonts which assigns to 'Liberation Sans' the highest priority. (The latter case is recommended)

Open or create the file ~/.config/fontconfig/fonts.conf, append following:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>

<match>
    <test name="family"><string>Verdana</string></test>
    <edit name="family" mode="prepend" binding="strong">
        <string>Liberation Sans</string>
        <string>Verdana</string>
    </edit>
</match>

</fontconfig>

Note that ~/.fonts.conf is deprecated now, and if you already have user-defined fonts.conf, remove the header and footer and only keep the 'match' section. And it would be too long-winded to demonstrate the same workaround on 'Arial'. I'm sure you can find it on your own.