July 07, 2006

Replacing ugly Helvetica fonts in Xorg

Helvetica, as implemented on most operating systems, is very ugly.

This beautiful font has always been the ugly duckling of fonts under Linux because of the status of its implementations. Due to licencing, proper scaling implementations of the font are very expensive, so instead of nice truetype Helvetica, it's normally only possible to use bitmapped versions of the font, which have no antialiasing and are thus very jagged and ugly, especially on LCD monitors.

There's a workaround for this...

A lot of web sites specify Helvetica fonts - they're probably designed on a Mac which has licenced the font and thus displays nicely. Unfortunately for the rest of us, this means that the ugly bitmapped font is used, bringing the page aesthetics down. For Windows users, no Helvetica implementation is there at all - Arial is generally substituted.

This problem is easily solved under Xorg, of which most GNU/Linux distributions now use. Gnome and KDE both use the Fontconfig system for font management, and with this, it's easy to get a good looking Helvetica replacement. The trick is to tell Fontconfig to substitute Helvetica with a better looking font. I chose Nimbus Sans, as it closely resembles Helvetica and is standard on most systems.

To configure Fontconfig, you just have to edit the file .fonts.conf in your home directory. Open (or create) it and put the following section into it:

 <match target="pattern" >
  <test name="family" qual="any" >
  <edit mode="assign" name="family" >
   <string>Nimbus Sans</string>

This needs to be placed outside any existing <match> .. </match> directive, and within the <fontconfig> block.

Then save the file and run fc-cache and restart Firefox. You should now have much prettier font where Helvetica once was. Compare the two screenshots below - on the left is the default bitmapped Helvetica, and on the right is the much smoother replacement Nimbus Sans.

This trick can also be done for other fonts - if you come across some font that renders horribly, insert another block into .fonts.conf with the old and new font names and enjoy your prettier X11!

Posted by Ben at July 7, 2006 07:46 PM
Post a comment

Remember personal info?

Recent Entries
- Linux on an HP Compaq NC6400
- Sodium in water? Bah..try Caesium!
- I'm off to Lugradio
- Food for thought...
- Replacing ugly Helvetica fonts in Xorg
Support me...

Email me: bb@bb.cactii.net
NL time:02:53
Book: Assassini (Thomas Gifford)
Amazon wish list
Search the web