subpixel hinting

I was trying to "fix" why kde applications on my gentoo linux don't show anti-aliased fonts, whereas gtk based ones such as galeon do. I went in "kcontrol" and noticed a strange checkbox reading "activate sub-pixel hinting". No idea what it is... So I checked it :), saw no difference in rendering, and forgot about it.

A while later I began noticing strange color artifacts when browsing with galeon: some vertical bars of anti-aliased fonts looked a bit red, while some others looked a bit blue. Since the LCD monitor I use is very new (and I'm new to LCD monitors) I began wondering if this monitor was not going crazy, or if XFree needed any "special" LCD configuration. I made a screenshot, zoomed it, and saw that I wasn't dreaming, the black/grey color of the font was fucked up! Now what was going on?

My mind began to melt when I made another test: I connected my old CRT monitor instead of the LCD monitor, changed nothing in system configuration, fired up X again, did the screenshot, and noticed that the color artifacts were changed! Actually they were still here, but smoother, almost unnoticeable when not zooming. Now XFree detects something about the monitor at startup, and changes font rendering? Wow...

After some google searching, I discovered that the strange checkbox activating the sub-pixel hinting was the reason for that, especially with this very nice web page about ClearType, Microsoft's implementation of sub-pixel (rendering|hinting). In a few words, this technology allows to take advantage of the physical layout of a LCD monitor, because each pixel is actually an horizontal "triad" of red, green and blue pixels.

But now, why did I see it at all? I'm using an LCD monitor (a Dell 1703FP) and this is exactly where this technology is targeted at! Maybe this RGB/BGR thing? But even changing the ordering from RGB to BGR I still clearly saw the color artifacts... Maybe buggy software? Or just default gentoo configuration has a problem... The above-mentioned link seems to suggest that each pixel's energy must be horizontally splitted to the two neighbours or we see color artifacts, namely "Local Color Imbalance", and that seems to be clearly the case in the examples I show below. In contrast, I can see no color artifact at all on his "Sample Text String" "filtered example" at the end of the "Turning theory into practice" page.

These tests performed with:

media-libs/freetype-2.1.5-r1 *
media-libs/freetype-1.3.1-r3 *
media-libs/fontconfig-2.2.1 *

Regular anti-aliasing
Sub-pixel hinting, RGB order
Sub-pixel hinting, BGR order

Last update: Tue May 18 13:15:46 2004