Johan Kiviniemi’s series of tubes

Fixing the font rendering in Ubuntu

2008-01-11

News: Martin Ankerl posted screenshots comparing the font renderers.

If you’re like me and hate the blurry font rendering used by default in Ubuntu since 8.04 (hardy), you might want to install the following config files:

/etc/fonts/conf.d/99-sharp-fonts.conf

Since the filename begins with 99, these settings override pretty much everything else.

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <match target="font">
    <edit name="antialias" mode="assign"><bool>true</bool></edit>
    <edit name="hinting" mode="assign"><bool>true</bool></edit>
    <edit name="hintstyle" mode="assign"><const>hintfull</const></edit>
    <edit name="lcdfilter" mode="assign"><const>lcdlegacy</const></edit>
    <edit name="rgba" mode="assign"><const>rgb</const></edit>
  </match>
</fontconfig>

Change lcdlegacy to lcdfilterlegacy if you’re running 8.04.

/etc/X11/Xresources/sharp-fonts

As of this writing, cairo is unable to read the settings from fontconfig, so let’s add the equivalent X resources for cairo applications to obey.

Xft.antialias:  true
Xft.hinting:    true
Xft.hintstyle:  hintfull
Xft.lcdfilter:  lcdlegacy
Xft.rgba:       rgb

Again, change lcdlegacy to lcdfilterlegacy if you’re running 8.04.

Explanation of my issue with the default font rendering

The default font renderer draws translucent subpixels – a.k.a. blur – around vertical lines. That makes text less readable.

The legacy renderer draws all horizontal and vertical lines without any translucent pixels/subpixels. Only oblique lines and curves are rendered with antialiasing. That means the text is as sharp as possible with the display technology.

© 2011 Johan Kiviniemi

The image of a giraffe is from Wikimedia Commons