How to fix the new MS fonts in POSIXy systems

OK, you’ve got your new computer preinstalled with MS Vista and/or MS Office 2007. You didn’t waste time to install your favorite GNU/Linux distribution or BSD flavor and took the time to comb down that Windows partition for goodies the license and Title 17 of the US Copyright law may warrant you to use. That is, unless George of the Bush hasn’t killed it already with the help of his friends in the US Congress, each and every one of whom make Sarah Palin look like a Nobel Prize Winner, ten years in a row.

You find those nice fonts with names starting with “C”, Calibri, Cambria, Candara, Consolas, Constantia and Corbel. Diligently you copy them into your $HOME/.fonts directory and run the magic command fc-cache -r -v in a terminal emulator window, go to the font settings application for your preferred desktop environment and change the monospaced font to Consolas (new font from MS, several years in development, it has to be the ultimate coding font, right?). Open a new terminal or a text editor and you discover it is hideous! Blocky, blurry and bold although you made a point of not using bold in the settings, Something you learned the hard way after having written The Great American Novel, a thousand pages worth, printed it in Comic Sans Bold 10 points to save paper and sent it to your prospective editor, who answered back thanking you heartily for all the toilet paper supplies you sent along the other day.

The problem is that the MS “C” fonts are hinted in such way that they don’t work well if you don’t use subpixel rendering and as far as I can see there is no real traditional hinting in them worth a cent. Even after you fiddle with the LCD-type settings there is no improvement, because most GNU/Linux distros default to use the patented bytecode interpreter, which works just fine with traditional truetype hints, instead of the patent unencumbered autohinter (in typical “Bite me!” attitude). Even those distros that give you the choice to use one or the other, such as Debian, have for the most part managed to bastardize the code resulting in Freetype working as it shouldn’t. And all downstream distributions, including Ubuntu, receive the same turd.

But don’t fret! There are ways to work around the ugliness. We can create a $HOME/.fonts.conf like this:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- Use the Autohinter -->
  <match target="font">
    <test name="family">
        <string>Cambria Math</string>
        <edit name="autohint" mode="assign"><bool>true</bool></edit>

That ought to fix the ugliness, although results will vary depending on how bastardized is the Freetype library in your system. Of course you can add more configurations to the file as long as you respect the XML syntax. Do be careful if using KDE(3/4) because the KDE font configuration tools love to eat users .fonts.conf files raw and spit them out in pieces.