Hint: How to force autohinting on Fedora 15

In Fedora 15, Freetype was updated to enable the TrueType bytecode interpreter (BCI) by default. The BCI is used by default for all fonts which include hinting information, unhinted fonts will automatically use the autohinter. (That fallback magic was the last remaining blocker for enabling the BCI by default in Fedora, because the patents on the BCI expired recently.)

In most cases, the BCI is what you want. However, if, for whatever reason, you don’t like the resulting rendering, it is possible to force autohinting instead of BCI-hinting:

  • globally, using the 99-autohinter-only.conf below:
    <?xml version="1.0"?>
    <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
    <fontconfig>
      <match target="font">
        <edit name="autohint" mode="assign">
          <bool>true</bool>
        </edit>
      </match>
    </fontconfig>
  • per font, using something like 99-DejaVu-autohinter-only.conf. (That file disables the BCI for the DejaVu family, which is the default font in Fedora, except for GNOME 3 which uses Cantarell. It used to be shipped in old builds of freetype-freeworld. The font names can be changed to whatever font you want to disable the BCI for.)

These config files must be placed into the /etc/fonts/conf.d/ directory for Freetype to recognize them.

Advertisements
  1. #1 by Ben Boeckel on 2011-05-21 - 01:57:52

    Wouldn’t $HOME/.fontconfig/ also be a viable place to drop the configuration?

    • #2 by Kevin Kofler on 2011-05-21 - 02:15:57

      The proper location for per-user settings is actually ~/.fonts.conf.d, not ~/.fontconfig/.

      And you have to be warned that those settings are loaded from the global 50-user.conf, i.e. before all the font-specific systemwide settings, so this will break if a later (i.e. with a number >50) systemwide config file sets the autohint property back to false. (That said, that shouldn’t really happen. I see only the Farsiweb fonts touching the autohint property in their config file and they’re disabling hinting entirely for some reason.)

  2. #3 by Nadav Har'El on 2011-05-26 - 11:51:27

    Wow, thanks for this post! I had exactly this problem – the nice fonts in firefox suddenly became ugly – and I couldn’t figure out why. Your advice did the trick in fixing it.

    • #4 by Kevin Kofler on 2011-05-26 - 12:06:06

      Glad to be of help.

      Beauty is in the eye of the beholder, so it’d be useful to see before and after screenshots in order to judge whether the “ugly” rendering is what the font designers intended or whether it is the result of a bug or missing feature in Freetype. (I’ve seen a few situations in which Freetype would try to use the BCI, then not find hinting bytecode for the glyph and end up not hinting the glyph at all. In particular, partially hinted fonts are not supported, and there also seem to be issues with glyphs taken from other fonts (e.g. for ranges not covered by the selected font).)

  3. #5 by thm on 2011-07-01 - 13:59:52

    The config file to enable autohinting is already there, but inactive. It can be activated by creating a symlink:

    ln -s /etc/fonts/conf.avail/10-autohint.conf /etc/fonts/conf.d/

    (from http://fedoraunity.org/Members/khaytsus/improve-fonts)

  4. #6 by mRogers on 2011-07-04 - 20:29:13

    Sweet, that fixed it. It’s definitely more than an “eye of the beholder” problem for some people. On my setup (LCD widescreen) letter spacing was significantly affected. As an example on this page in first line –…Freetype was updated to enable… — the p and d in updated were welded together into one mega-letter.

    • #7 by Kevin Kofler on 2011-07-05 - 09:49:54

      Well, that sounds like a kerning bug in either the font or Freetype. Try reporting the bug to the upstream project for the font you’re seeing this with.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s