Subpixel Font Rendering in Linux

Due to some patent issues, most of the distributions ship their freetype packages with subpixel rendering option disabled. In fact, as far as I know Ubuntu is the only one that enabled this option. If you want cleartype-like font rendering in your distro, you have to uncomment a macro in the code and  build the package yourself. But this is not enough since the newest LCD-specific FreeType APIs have not been implemented in Xft and Cairo. So you have to patch and build these packages too. I have downloaded the sources of these packages from Ubuntu  and applied the patches to Debian code. Cairo and Freetype compiled fine but Xft wouldn’t. So I used David Turner’s patch for that one. Though font rendering issues are a matter of taste, the results are miraculous in LCD displays. Here are some screenshots with and without patches, see how fonts differ in webpages.

Unpatched freetype, cairo and xft:



patched builds:



Sources and patches of freetype 2.3.7, xft 2.1.12, cairo 1.6.4 can be found here. The tar archive also includes patched versions of the packages that I have built for Debian (deb archives for i386).

To enable subpixel rendering, you have to choose subpixel smoothing from appearance preferences menu in gnome. If you are using Debian or a Debian-based distro, you can configure system-wide settings through dpkg with the following options:

sudo dpkg-reconfigure fontconfig-config




More information about patches and patents can be found in:


23 thoughts on “Subpixel Font Rendering in Linux

  1. I think Debian is not implementing this rendering technology because it may be violating some microsoft patents. I checked experimental and unstable branches but the packages were the same. and I didn’t see any bug report about this issue. Maybe we should file a bug report about it.

  2. I’m very confused. In the article you say that Debian doesn’t have subpixel font rendering, yet on my ‘testing’ box if I run dpkg-reconfigure fontconfig-config then I am asked if I want to enable sub-pixel hinting, which I accepted and it changed how the fonts looked.

    If Debian doesn’t support subpixel font rendering, why does fontconfig-config ask me if I want to enable it? It doesn’t appear to be an empty option as it changes how the text looks (for the worse) in KDE.

    I notice in KDE however the option to enable ‘sub-pixel hinting’ is greyed out (unselectable) no matter what font configuration I use.

  3. >In your before/after comparison pictures,
    >you’re using two totally different font sizes.
    >You might want to fix this.

    Yes, I am aware of that but somehow fonts get bigger with lcd rendering option that I have chosen (slight hinting) so I used a different font size. or maybe I should have put the screenshots with same font size.

  4. An informative article but I am still a bit confused.
    Bekir, is it possible for you to do a more detailed, step-by-step procedure for implementing the patching and building etc for a Debian OS? I really would like to have my Debian fonts rendered in a similar quality to my Ubuntu ones.
    Many thanks.

  5. If you are using 32-bit Lenny, you don’t need to compile the packages again. Because I included the patched versions of the packages that I have compiled for myself. Inside the archive that I have uploaded, you can find the necessary deb’s:


    You can install them with “sudo dpkg -i package_name.deb”. and make sure they don’t get re-installed when you run an upgrade. You can pin the packages with apt preferences or hold them with gjig. I would recommend gjig because it’s easier.
    To configure the system to use LCD rendering, run “sudo dpkg-reconfigure fontconfig-config” with the options above. In gnome settings, I use subpixel smoothing with slight the way, fonts look a little bigger with this patch, so I use smaller size fonts, like 9 or 8.

  6. Hi bekir :
    Is the source you supply already patched ?
    so i want to install those package in AMD64 debian system , just cd the src and dpkg-buildpackage ??


  7. yes I have patched cairo and freetype, you just need to do dpkg-buildpackage as long as you have the build dependencies. I had to patch xft by hand but I can’t find the patched sources now. if you are not using kde it won’t matter much, the only program that uses xft in gnome is terminal afaik.

  8. I can’t implement this pathes to my debian(squeeze) due to the version of packages is more higher than you supplied.and it always says the dependency problems for runing dpkg -i ***deb.and also OS says can’t find the corresponding dependencies .
    here is the example

    lenovo@debian:~/Desktop/freetype$ sudo aptitude install freetype2-demos
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    Reading extended state information
    Initializing package states… Done
    Writing extended state information… Done
    Reading task descriptions… Done
    The following packages will be upgraded:
    1 packages upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
    Need to get 0B/198kB of archives. After unpacking 12.3kB will be used.
    Do you want to continue? [Y/n/?] y
    Writing extended state information… Done
    (Reading database … 88096 files and directories currently installed.)
    Preparing to replace freetype2-demos 2.3.7-2 (using …/freetype2-demos_2.3.9-4_i386.deb) …
    Unpacking replacement freetype2-demos …
    Setting up freetype2-demos (2.3.9-4) …
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    Reading extended state information
    Initializing package states… Done
    Reading task descriptions… Done

    lenovo@debian:~/Desktop/freetype$ sudo dpkg -i freetype2-demos_2.3.7-2_i386.deb
    dpkg – warning: downgrading freetype2-demos from 2.3.9-4 to 2.3.7-2.
    (Reading database … 88096 files and directories currently installed.)
    Preparing to replace freetype2-demos 2.3.9-4 (using freetype2-demos_2.3.7-2_i386.deb) …
    Unpacking replacement freetype2-demos …
    dpkg: dependency problems prevent configuration of freetype2-demos:
    freetype2-demos depends on libfreetype6 (= 2.3.7-2); however:
    Version of libfreetype6 on system is 2.3.9-4.
    dpkg: error processing freetype2-demos (–install):
    dependency problems – leaving unconfigured
    Errors were encountered while processing:

    so how to down to the lower version of these files?

  9. i’m not sure it’s a good idea to downgrade these packages since almost the whole graphical environment depends on them. you could use force option of dpkg, i’m not sure it would work, and even if it did, it would break hundreds of dependencies. I have another solution in my mind which also doesn’t seem to be “right” even if it will probably work. you can give it a go but do this at your own risk:

    when you open the source folder of cairo-1.6.4 and freetype-2.3.7, you will see a debian folder, which usually includes debian-specific patches and changes to a source code. and in those folders, you will see the folders with actual package names that will be created as debs when you compile. ex: freetype2-demos, libfreetype6, libcairo2. those folders include a DEBIAN folder (yes, with upper-case letters). in DEBIAN folder you can find the control file of a package, which also includes version of a package etc. you can play with versions of packages there. Make them look really high so that your system will not complain about unmet dependencies. and then compile the packages yourself with dpkg-buildpackage.

    as i said, this is not a secure solution. you can breakdown your system. download and keep a deb file of the packages from debian repos, the packages you will replace, somewhere reasonable. if anything goes wrong, use dpkg to reinstall them. I did it a few times while i was experimenting with these packages. even if x server won’t start, you can reinstall these packages from a terminal screen with dpkg and restart x.

    i hope this helps.

  10. thanks,
    now I compile sources by myself following this instruction

    I think either patching libcairo2 or patching libxft2 is easy and clear,but for patching freetype and build package, I am confused with some commands
    $ dch -i ,is this necessary for patching?

    $ cd .. && rm -rf freetype-2.2.1.tar.bz2
    $ tar cvjf freetype-2.2.1.tar.bz2 ./freetype-2.2.1/
    $ rm -rf freetype-2.2.1
    this three commands seems delete the file before extract it to folder,but later still delete the whole folder.

    and if you have time,can you explain the paragraph of patching freetype to me? and also how to check wherher my patched file is correct(included the pactched code inside)

    you can reach me at helai826 at

    Thanks again

  11. There doesn’t seem to be much documentation on this topic despite how horrible the stock fonts look in Debian. Where would we get the latest packages to avoid downgrading?

    Thanks for addressing this issue!

  12. The problem is there is no repository for that, neither official nor unofficial. (Ubuntu community had an unofficial repo for these packages before they included the pathces in their distribution but Debian users, as far as I can see, don’t really care about these issues) If you are using lenny, you can use the packages that I prepared. These packages don’t get updated much often anyway. But if you are using the testing or experimental branch, you have to compile them yourself.

  13. @bekir: Thanks for the prompt response! So, to compile these, I need the current sources for what packages? Do you know of a decent writeup on this? Thx!

  14. Thank you very much for your article on subpixel hinting.
    Because of this I was stimulated to take a closer look at Ubuntu’s fonts and 9.04 is gorgeous in that area.

    OpenSUSE is enabling subpixel hinting after a one-click install from here:
    I compared my screeen with your pictures and the results are equally gorgeous.

    It’s fascinating to research which distro’s do offer this feature in a easy way.

  15. I have patched and built Lenny’s debs according the following guide : This gives me the same result as the debs from here : The result is beautiful, but the fonts are a bit to bold ( my taste ). I still had an old install of Ubuntu Gutsy on a different harddisk, the font rendering is my favorite, so I rebuilt the debs from it. These were downgraded packages compared to the ones in Lenny. I was happy to come across your site, your debs give me exact the same result !
    Thanks for sharing !

  16. I’m still curious to know the details of the patching and building. What did you mean with ” I have downloaded the sources of these packages from Ubuntu and applied the patches to Debian code “. I hope you can answer my questions.

  17. Debian and Ubuntu (as a matter of fact, all the distributions) have “diff” files to store the distribution specific patches that they apply. I used ubuntu diffs (which include the related subpixel hinting code) to patch the debian source files. Then I compiled them.

  18. Thanks for your quick reply. I will see if I can accomplish the same process of patching and building. I’ll let you know.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s