TrueType hinting tutorial - Basic global tables

Basic TrueType hinting involves three tables that are global to the entire font: the Control Value Table, the Preprogram Table and the Font Program Table.

Control Value Table ('cvt')

TrueType allows control over the regularity of features through the use of values stored in the 'cvt' table. Control values are measurements of features, such as lowercase stems widths. These stems, although similar to one another, may have slightly different outline distances. With cvts the distances can be controlled so they are the same pixel width at a low resolution. At a higher resolution the control value won't be used but the natural distance will display in the stems. The Control Value table doesn't require these values to be glyph feature distances. The values are an integer and can be accessed from many TrueType instructions. The table also can be written to as well as read from other tables.

Other examples of glyph and font features that can be stored in the control value table are: cap heights, x-heights, overshoot distances, ascender heights, baselines, figure heights, serif lengths and heights, italic angle, group (uppercase, lowercase, etc.) stem distances, group round distances. Other features might be: smaller group distances such as a math sign stem distance, braces, brackets, or parentheses distances.

tutorial picture 1

Figure 1. Features of a lowercase 'b'.

Preprogram ('prep')

In every font there are certain conditions that will always apply. In TrueType we control these conditions through code placed in the preprogram. The 'prep' table is executed each time a glyph size or resolution is changed and before the glyph's local instruction are executed. This is a good place to control global conditions for all glyphs. Some examples of what to put in a 'prep' are...

  • Controlling when hinting instructions are used and when they are not. In Microsoft fonts we turn off hints below 8ppem and above 2048ppem. We feel it unnecessary to use hints below 8ppem or above 2048ppem. This also prevents some technical issues from arising.
  • Turning on control to check for missing pixels in continuous strokes. In some cases the outline may pass between pixel centers and would result in holes in the bitmap8. This control checks for these conditions and adds pixel/s where these 'dropouts' occur.
  • Altering values in the 'cvt' used to control group features such as uppercase stems and rounds. Here you can control the size at which a stem breaks from one pixel to two, etc. It is common to force round and straight features to be equal until a desired size.
  • Setting the 'cvt' cut-in limit. This is a threshold (or thresholds) which are used to determine if a 'cvt' value will be used or the actual distance will be used. I use three threshold settings: one for small ppem sizes set so the 'cvt' will most always be used; one for medium ppem sizes where a more reasonable threshold is set; and a high ppem threshold set to always use the actual distance and not the 'cvt' value. You'll see below how some instructions are set to look at this 'cvt' cut-in limit.
  • Setting minimum distance. Sometimes it is necessary to maintain a minimum of one pixel between one outline point and another (in the case of hinting across the stem of a glyph, for example). I always set the minimum distance to be one pixel. If I then hint across a stem and the actual distance is less than a half a pixel, the stem width is always forced to be one pixel.

Font Program ('fpgm')

This table stores functions that can be called from the 'prep' or from the glyph's instructions. Functions are used to eliminate repetitive code from being used in multiple glyphs. A common example is to control the placement of a diacritic over a base glyph. TrueType supports composite glyphs (glyphs made up of other glyphs). In composite glyphs the bitmaps of these already hinted glyphs may not be placed in the same way as the original unhinted outline position in the horizontal and vertical direction. A function is often used to insure the diacritic centers over a base glyph and the diacritic does not touch the top of the base glyph.

Next section

Hinting and TrueType instructions