Sunday, August 11, 2013

Fixing ugly fonts on Tim Berners-Lee's (and other) webpages

Have you ever visited a webpage, such as Tim Berners-Lee's page (for those who don't know, he invented the World Wide Web), and found the font was wobbly, bumpy, jagged, or uneven? Various letters seem to be rendered at different sizes, making the text ugly and difficult to read. The problem is that on GNU/Linux and other Unix systems with FontConfig, URW Palladio L (which is the clone used for Palatino) suffers from really bad font hinting. Normally, hinting improves the appearance of fonts, particularly at small sizes and low resolutions. However, in this case it has gone horribly wrong. You can see the effect in these screenshots:



Fortunately, the fix is fairly simple once the problem has been identified. We can turn off hinting specifically for URW Palladio L with a little configuration. As the link above suggests, you can fix this on a per-user basis, but if you want to fix it system wide, simply create the file /etc/fonts/local.conf containing:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <match target="font">
    <test name="family">
      <string>URW Palladio L</string>
    </test>
    <edit name="hinting">
      <bool>false</bool>
    </edit>
  </match>
</fontconfig>

Then run:

fc-cache -f -v

to update the font cache information. You will need to close any applications that are currently open and reopen them for the changes to take effect. Now you should see much improved rendering for URW Palladio L, as seen in these screenshots:


Considering how bad the rendering is (I would consider it utterly broken), I'm not sure why hinting isn't turned off for URW Palladio L in the default configuration, but now at least you know how to fix it. And Tim Berners-Lee's home page should look much nicer.