Sunday, 31 May 2009

Font Hinting Comparison

Although it has taken me much longer than I expected here is the font hinting comparison I promised some weeks ago. The above image is a direct comparison between the four (auto) hinting options provided by FreeType.

The most striking thing is how poor the "Slight" and "Full" hinting options look. (Although they look similar closer inspection reveals them to have some subtle differences.) "None" and "Medium" both produce acceptable results, however. The most notable difference between the two is in the infinity symbol: notice how it is much more consistent with "Medium" hinting as opposed to "None."

So why does all of this matter? Well, rendering quality is extremely important, especially when bitmapped images are being produced -- a potentially common use case for the resulting Mathtex library. Therefore it is important to know exactly how the various rendering options affect the output in order to choose sensible defaults.

About the samples: these were all produced using the svn HEAD version of matplotlib using the Cairo backend (which when running under Linux uses FreeType + fontconfig, making it easy to change the hinting method).

3 comments:

  1. congrats! this looks great!

    ReplyDelete
  2. It would be interesting to compare with the hinting trick done in matplotlib's Agg backend -- to hint to 1/8 pixels in the X direction and full pixels in the Y direction. When I did something similar years ago, that was my favorite (though this stuff tends to be very subjective). This seems to be what Adobe Acrobat does also (which might also be an interesting comparison).

    ReplyDelete
  3. I'll try that later and append it to the article. Would be interesting to see how effective the trick is.

    I was somewhat surprised about how blurry full hinting looked - to the point where I ended up running the test several times to ensure that everything was configured correctly.

    Notice also the grey border around the "None" and "Full" hinting options. The output produced with this option is 2 pixels smaller (vertically) than the "Slight" or "Medium" options.

    Finally, it is also worth noticing the spacing between the x^3 and the dx. This is not present in the LaTeX string. I think I've found my first bug.

    ReplyDelete