Learning to Write

So I am looking into the automatic hinting right now. I always find it easier to grok something when I explain it to others, so let’s explain what I am doing right now. The automatic hinting process can roughly be divided into 3 phases:

  1. Global font analysis: Certain important properties of the font are determined and stored. The important properties for Latin fonts are the standard stem widths and the so-called blue zones. The former is the usual width of the character stems which has to be the same for all glyphs when things should look good (you know a non-hinted glyph when you see some stems 1 pixel width, others 2 etc). The blue zones are characteristic horizontal stripes, comparable to the lines in the notebook in your first year in school (namely these are capital-top, capital-bottom, small-top, small-bottom, small-minor and small-f-top. you can make up from the names what stripes these are). Later, all points that fall within one of these stripes is aligned. (Again, when you see non-hinted text the height of certain characteristic points is not regular). All this is not really performance critical as it is only performed once per font and not on each rendering of a glyph.
  2. Local glyph analysis: For each glyph to be rendered we need to detect the so-called Segments (points that form an approximately horizontal or vertical line), Edges (sets of Segments that all lie approximately on the same line. For instance, the glyph W has three segments at the top which frequently form an edge) and Stems (Segments that form the characteristic vertical or horizontal lines. For instance an I character has 1 vertical stem – which makes up the whole glyph for sansserif fonts). This is performance critical as it is done in realtime when beeing rendered.
  3. The actual hinting: With the information collected in step 1 and 2 we can now move around the outline points of a glyph so that it fits the target grid. The goal here is that points that fall within one of the blue zones get aligned into one height and points that make up a stem are moved so that all stems have the same rendered width. When this is done, the location of the remaining points of the glyph have to be interpolated so that the glyph is rendered smoothly.

I find it interesting to see what is performed behind the scenes on a normal desktop computer only to get the nice TrueType rendering that we got used to in the past couple of years.

For GNU Classpath I have already implemented most of phase one above which I will finish and test really soon plus some bits of phase 2 because that is actually needed for phase one too, after all, what is done in the global phase is to analyse a couple of characteristic glyphs.

More details to follow soon…


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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: