What I have learned during the last two days is that people tend to have vastly different preferences regarding font rendering. Some want their fonts crisp and clear, maybe even without Anti-Aliasing, while others want them really smooth, almost a bit blurry. The actual problem was, that in Debian (Squeeze) subpixel rendering is really nice everywhere else than in applications relying on libcairo for achieving that. This leads to Firefox having almost unreadably sharp fonts when hinting is set to full, while they tend to look just ugly when hinting is at a lower level.

Comparing rendering of fonts in Firefox (or other GTK-apps) to e.g. qt-apps like Konqueror made me want to fix that problem. At first it seemed like nobody else had noticed that behaviour and I thought it would just be nit-picking again, as I always want things to be “perfect” in one or the other sense. But finally, today I found this thread talking about the exact issue that was bugging me. So I read through it carefully and finally found a solution to my problem. There are two possibilities, both involving libcairo and libdirectfb:

  1. Ubuntu packages can be used. Ubuntu has a patch applied to libcairo (and seemingly libdirectfb) which makes font rendering look much nicer. You can actually install these packages without problems. Just get them from the Karmic repository.
  2. Use patched packages provided by Hadret in the linked thread. You can find them here. Actually, these are the AMD64 packages. Read through the thread to get the i386 ones or build them yourself. A link to the patch guide should also be given in that thread.

Having these packages installed, you just have to enable subpixel rendering and set hinting to an appropriate value. Personally, I like slight hinting the most as it gives the whole thing a really smooth look. Settings can be made system-wide in /etc/fonts or per-user in ~/.fonts.conf. Here are the contents of my ~/.fonts.conf:

1 <?xml version='1.0'?>
2 <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
3 <fontconfig>
4 <match target="font" >
5 <edit mode="assign" name="rgba" >
6 <const>rgb</const>
7 </edit>
8 </match>
9 <match target="font" >
10 <edit mode="assign" name="hinting" >
11 <bool>true</bool>
12 </edit>
13 </match>
14 <match target="font" >
15 <edit mode="assign" name="hintstyle" >
16 <const>hintslight</const>
17 </edit>
18 </match>
19 <match target="font" >
20 <edit mode="assign" name="antialias" >
21 <bool>true</bool>
22 </edit>
23 </match>
24 </fontconfig>

Finally, Firefox (and XChat, and Icedove, and…) font rendering looks fine again :-)

Note that it may be necessary to upgrade some packages to versions from Debian sid (e.g. xulrunner-1.9.1) to make this work.

4 Responses to “Debian Squeeze and Subpixel-Rendering in libcairo (aka ugly Firefox/Iceweasel fonts)”

  1. The way fonts look is for me of the utmost importance, because I spend a lot of hours behind my screen.
    You can read here on my blog how I solved it : http://debian-bits-and-snips.blogspot.com/2010/09/rebuild-libcairo21810-4amd64deb.html

  2. Thanks for your comment :)

    I switched to Arch Linux in the meantime. There they had (and still have) patched packets in the user repositories which could be easily installed. However, I believe the whole thing with the bytecode stuff which affected font hinting/subpixel rendering was due to a patent, which has expired in May (according to Wikipedia and other sources). So it could well be that patches will not be necessary anymore in the future :)

  3. Thanks a lot! your post has been very useful.
    (2001/May) I’m using debian wheezy (testing) with this packages:
    libcairo2 1.10.2-6
    libdirectfb-1.2-9 1.2.10.0-4
    xulrunner-1.9.1 1.9.1.19-2
    xulrunner-2.0 2.0.1-1~bpo60+1

  4. Eric says:

    “The way fonts look is for me of the utmost importance, because I spend a lot of hours behind my screen.”

    That’s funny, when I go behind my screen I don’t see any fonts. He must use a mirror or have one of those new-fangled two-way monitors. :-)

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© 2012 P=NP! Suffusion theme by Sayontan Sinha