Being spoiled with the near perfect font rendering of Mac OS X on my MacBook, I always found Linux’ font appearance to be a bit behind. Especially in ye old days before libXft and FreeType2, font rendering in X11 applications was just plain ugly. However, with the introduction of font hinting, things have been improved a lot. Especially slight hinting looks very good.
As of Jaunty Jackalope, slight hinting (or “Subpixel Smooting” in Ubuntu terms) became the default in Ubuntu. But actually I kept reverting back to “Best Contrast” simply because of one annoying adverse effect of “Subpixel Smoothing”: Arial becomes too small on certain web pages. That is, on my 22” 1920x1200 LCD screen at work. Too bad. No subpixel smoothing at work for me.
Last week, with the release of Karmic Koala, I decided to revisit my subpixel smoothing choice again. I like it, so I found it was time to resolve my Arial 12px issue once and for all, so I could have my subpixel smoothing at work. So after the install finished, I switched to “Subpixel Smoothing” using the System → Preferences → Appearance → Fonts tab. Ahh, very nice… Except for Arial when I start browsing. Actually its even only Arial at a size of 12px.
So here’s what I need to solve: I don’t want any other font to change, it’s really only Arial 12px that’s bugging me. Yes, I’m being a nitpicker here, but hey, there are just too many websites that use Arial 12px, starting with my iGoogle start page already. The easiest workaround option is to remove Microsoft’s TrueType core fonts package, so Arial isn’t used, but a replacement. However, most websites do look a lot better with Microsoft’s core web fonts, and besides that, I hate workarounds. I like real solutions. So that’s when I decided to dive into fontconfig to see if that could fix my problem.
I couldn’t imagine it being so simple as putting a .fonts.conf in your home dir containing:
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<match target="font">
<test name="family" compare="eq"><string>Arial</string></test>
<test name="pixelsize" compare="eq"><double>12</double></test>
<edit name="pixelsize" mode="assign"><double>13</double></edit>
</match>
</fontconfig>
But it really is as simple as that. In human language, the XML file tells fontconfig to set the pixelsize of Arial to 13 when any program requests Arial with pixelsize 12. How beautiful.