Better LCD Font Rendering

Apple and Microsoft have some pretty restrictive patents when it comes to font rendering but eventually improved font rendering is making it’s way to Linux. Ubuntu by default adds subpixel font rendering to Xft and cairo. These LCD-specific FreeType API’s though for most other distros will need to be patched in.

First be sure that your X server DPI settings are correct for your monitor. Then you’ll need the updated and patched versions of freetype, fontconfig, libXft, and cairo.

Installing on Gentoo

For Gentoo users these updated packages are in the devnull overlay. Devnull uses mercurial:

emerge mecurial

To add an overlay, use layman to add it:

layman -a devnull

Then emerge these four programs (For a note on USE flags to user read nico’s post):

emerge -1 freetype fontconfig libXft cairo

Arch Install

Take a look at the fonts wiki.

Setting Up Fontconfig

Setting up fontconfig should be done as simple as possible. If you add too many options, fontconfig will use all of them and your fonts will look terrible. Fontconfig knows what it’s doing and you shouldn’t get in it’s way. Basically the fonts options are already setup in /etc/fonts/conf.d/. The only two I added were:

ln -s /etc/fonts/conf.avail/10-sub-pixel-rgb.conf /etc/fonts/conf.d/
ln -s /etc/fonts/conf.avail/70-no-bitmaps.conf /etc/fonts/conf.d/

/etc/fonts/conf.d:

10-sub-pixel-rgb.conf 45-latin.conf 69-unifont.conf
20-fix-globaladvance.conf 49-sansserif.conf 70-no-bitmaps.conf
20-unhint-small-vera.conf 50-user.conf 80-delicious.conf
29-replace-bitmap-fonts.conf 51-local.conf 90-synthetic.conf
30-metric-aliases.conf 60-latin.conf README
30-urw-aliases.conf 65-fonts-persian.conf
40-nonlatin.conf 65-nonlatin.conf

Check your monitor’s subpixel layout before you link a sub-pixel option here.

Now a fontconfig configuration file needs to be built to define the LCD rendering type:

<?xml version="1.0"?><!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<!– lcddefault,lcdlight,lcdlegacy,lcdnone –>
<match target="font" >
<edit mode="assign" name="lcdfilter" >
<const>lcddefault</const>
</edit>
</match>
<match target="font" >
<edit mode="assign" name="rgba" >
<const>rgb</const>
</edit>
</match>
</fontconfig>

Again, keep it simple! You get too complicated and your fonts and your fonts are going to blur. Also you need to define your monitor’s subpixel layout again because of a bug where the link to conf.d doesn’t work yet. Save this to /etc/fonts/local.conf to apply it system-wide.

A Note About Desktops

Desktops have previously handled font rendering and can get in the way of the now system-wide configuration. KDE 4 has the ability to let the systemhandle font configuration. For KDE, I’d recommend starting with new KDE configuration files so that KDE settings don’t get in the way. You can either copy any documents you have to a new user. Or you might be able to logout and rename ~/.kde4 and ~/.config and ~/.fonts.conf (if you have one) from the console. This will repopulate most of your KDE configuration files. Now reboot and test fontconfig (Technically you shouldn’t ahve to reboot but since fontconfig is still in development, it’s not a bad idea).

6 Comments »

  1. Sebastian said

    >> Let’s get going. I’d like to thank bi3l who has been building the ebuilds, and also to whomever runs the devnull overlay.

    heh, you’re welcome

  2. nico said

    Nice article.
    @Sebastian: Thanks for the feedback (I’m from devnull overlay :)

  3. cheap lcd said

    Nice article. Am sure will help many people get the crsytal clear viewing that lcd’s are meant to give

  4. Bah! Post updated.

  5. nico said

    We from devnull overlay stopped using IUSE defaults in the font ebuilds. There are 2 useflags which affect font rendering now – cleartype and ubuntu. I suggest you to update your post that it says to use the cleartype useflag (1. this is what portage uses 2. ubuntu one does not work for me for some reason, but others report it works well). I would say that the ubuntu useflag is for more experienced users.

  6. Danke nico. Good tip, thanks for adding it.

RSS feed for comments on this post · TrackBack URI

Leave a Comment