Topic: Font Substitution for Better Text Display

Recently I've played around a bit with my fonts, to see what I could change to improve ergonomics. One particular issue may be of interest to others: There are some websites out there that use the Helvetica font. On X.org/XFree86 systems, Helvetica is a bitmap font, which means that you don't get an antialiased version, and it scales badly. One such website is http://www.theregister.co.uk . Using the default settings, it looks like this in my browser:

http://www.maxlor.com/images/thereg1.png

You can see that the fonts there aren't antialiased, and what's more, the titles which use scaled versions of the font look extremely ugly.

The solution is to replace Helvetica with something else. Arial is designed to be a drop-in replacement for Helvetica, and it's available in Microsoft's Corefonts package. Your systems package repository will have it. The second piece of the puzzle is Xft2, a powerful font drawing library that most modern X11 applications use. It allows the user to configure font display in great detail. We'll use it to substitute Helvetica with Arial (and while we're at it, "Times" with "Times New Roman").

So after you've installed the fonts, find Xft's local.conf. You'll find it in the same directory as fonts.conf, usually in /usr/X11R6/etc/fonts or /etc/fonts or something like that. Alternatively you can edit ~/.fonts.conf , which also means the changes will only apply to your user account. Edit it so it contains the following text:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
        <match target="pattern">
                <test qual="any" name="family">
                        <string>Helvetica</string>
                </test>
                <edit name="family" mode="assign">
                        <string>Arial</string>
                </edit>
        </match>
        <match target="pattern">
                <test qual="any" name="family">
                        <string>Times</string>
                </test>
                <edit name="family" mode="assign">
                        <string>Times New Roman</string>
                </edit>
        </match>
</fontconfig>

It's likely that the file already contains something, so just modify it so it contains the two <match> blocks. Make sure the XML code is valid.

What this do exactly? Everytime an application requests a font from Xft, Xft will see if the font family is "Helvetica", and if so, change it to "Arial". The same applies for "Times" and "Times New Roman".

From now one, the register should look something like this:

http://www.maxlor.com/images/thereg2.png

or possibly like this, if you have enabled font hinting:

http://www.maxlor.com/images/thereg3.png

Either version looks much better than the original one, you'll notice that individual pixels in slanted lines are no longer visible, and that the titles look much better.

This works with both Opera and Firefox. Interestingly, it doesn't work with Konqueror. I'm wondering whether Konqueror, besides using Xft, also uses the older X11 font APIs directly. If anyone figures out how to make this work with Konqueror, please let us know!