Robotic Tendencies
The personal blog of Robert McQueen

March 16, 2005

Fontconfig fun

As is common when I upgrade fontconfig, all of my fonts changed appearance fairly randomly, using the wrong kind of hinting, selecting the wrong fonts, and generally looking very ugly. The usual problem is that debconf runs and decides something different to how I had it configured before, although I can’t quite see why (possibly related to losing my debconf cache to HDD corruption some time ago…). This time round, after upgrading from 2.2.3 to 2.3.0, I ran dpkg-reconfigure fontconfig and successfuly set it back to native hinting, and things looked roughly like they did before, with one major exception: some websites which requested serif fonts, and had previously used Bitstream Vera Serif, now used some other random font which hinted very badly and gave me coloured fringes, and looked generally horrible. The problem also applied in some cases to other sans and mono fonts on websites too, but not all of them.

After a while of using Firefox’s excellent Web Developer Extension to fiddle with the CSS, reading /etc/fonts/fonts.conf, and stracing firefox to see what fonts it was actually loading, I managed to work out that the change was due to this commit in fontconfig CVS. Rather than the old choice of just looking for Times New Roman to provide Times, Arial to provide Helvetica, and Courier New to provide Courier, the fonts.conf in 2.3.0 binds these to the Postscript Type1 Nimbus family of fonts that come in the gsfonts package, which 2.3.0 is now able to read even without having gsfonts-x11 installed. Previously websites which requested Times, "Times New Roman", serif fell back to Bitstream Vera Serif (I don’t have the Microsoft fonts installed) and looked fine, but now are using Nimbus Roman 9 to provide Times, causing the change in appearance.

My first attempt to fix this was to enable the autohinter on these fonts, rather than relying on the native hinting, which works well for the Bitstream Vera and Microsoft fonts, but not otherwise. It was better, but still not that good… So I just overrode the mapping of Times/Helvetica/Courier with my own mappings to the Bitstream Vera fonts. Which worked brilliantly, you can download my ~/.fonts.conf here. I left the autohinting stuff in because occasionally pango might use a glyph from the Nimbus fonts anyway. It also includes a snippet to put the fixed font back even if you have bitmapped fonts turned off, which dato was asking about in #debian-devel.

Sleeping from 7am to 1pm, and the fact I have no food in my room, cupboard or fridge, is probably not helping my cold, so I still feel utterly terrible… *sniff*

posted by ramcq @ 2:34 pm
Comments (3) .:. Trackback .:. Permalink

3 Responses to “Fontconfig fun”

  1. xuying says:

    Can you send me the font.conf file? I can’t link to http://www.hadesian.co.uk/files/fonts.conf. Thanks!

  2. Chris Conway says:

    I’ve been struggling with a similar problem: I can’t get my .fonts.conf right. It seems that the link you posted here has rotted… It would be great if you could repost it.

  3. robot101 says:

    Fixed the link.

Leave a Reply