TrueType Typography
TrueType Hinting

What is Hinting?

Ever since software developers and typographers were given the task of rendering scalable type on low-resolution devices, the hinting problem has been acknowledged. The problem, much more noticeable with scalable type than with other scalable graphics, reflects the high demands for visual consistency the eye makes on type.

The "mathematically correct" pixels for character outlines scaled to a given size and resolution are often unaesthetic or illegible. Hinting is the name for the set of techniques for restoring, as far as possible, their aesthetics and legibility.

In general, hinting consists of careful and usually small adjustments in the outline-filling process. At low device resolutions, undesirable rounding effects mean that parts of some characters can disappear, and other parts can appear too thin or too thick. Hints attempt to correct this by equalizing the weights of stems, preventing parts of glyphs disappearing, and generally maintaining aesthetic appearance and legibility down to as low a resolution as is possible.


Hinting in TrueType

Introduction
Hinting is at the heart of TrueType. Its inventors, mindful of the diversity of opinion on the "correct" way to hint type, decided there was no single hinting paradigm that they would impose upon type developers. Instead, they linked a relatively simple rasterizer to a new interpreted programming language. Each glyph in the font contains its own little hint program, with which the control points of the outlines can be manipulated just prior to rasterization in any way the hint programmer desires. In practice, this means that the outline is carefully distorted by each glyph's hinting instructions to surround only those pixels that produce the desired bitmap image. The language includes:
  • loops
  • conditional branches
  • user-definable functions
  • instructions to move, align and interpolate points in various ways - often with reference to "control values"
  • methods to round points to the "grid" of the device
  • arithmetic and logical instructions

Design of the Language
The TrueType hinting language is "stack-based", like PostScript, in that the instructions take all their arguments from the stack. Instructions take the form of single-byte codes. Unlike PostScript, there are explicit PUSH instructions to push bytes and words from the instruction stream (these are the only instructions to take arguments from the stack). Also unlike PostScript, there are no actual drawing instructions - only instructions that move existing control points.

Note that TrueType hint editors, such as TypeMan, hide the stack-based nature of the language from the hint programmer, letting one edit each instruction alongside its arguments.

Glyph Scaling
Before any hints are applied, the glyph is scaled with respect to the current ppem. (This value [pixels per em] is a measure of the number of pixels available for rasterization, derived from point-size and resolution.) All the glyph's coordinates are now measured in fractional pixels, rather than integral font design units. Coordinates are "F26DOT6" values: 32-bit fixed-point numbers with 6 fractional bits. Each point is stored twice: once for its original position, once for its current "instructed" position.

Moving Points and the Projection and Freedom Vectors
There are instructions for absolute and relative movements, with measurements taken from the stack, the CVT (see below), or from other points that have already been moved. All moving of points takes place with respect to two vectors: the Projection Vector P, along which all measurements are taken, and the Freedom Vector F, along which movement actually happens. TrueType's power stems partly from the independence of these vectors, and the ability to set them diagonally.

Maintaining Consistency with Control Values
One key aim of hinting is to maintain the "spirit" of a typeface throughout all its letters. This is the purpose of TrueType's Control Value Table (CVT). It should contain measurements that are used frequently within the hints for each glyph. The CVT is always "scaled" to the current ppem. Sample CVT entries might be:

  • How thick are the vertical stems?
  • How thick are the horizontal stems?
  • How thick are the serifs?
  • By how much do round features overshoot the baseline?

The Twilight Zone and the Storage Area
Often it is convenient to manipulate points that are not part of the final outline, yet are useful to take measurements from. In TrueType the "Twilight Zone" refers to the set of such points. They are often initialized in the CVT Program ('prep'). It's also useful to have a place for arbitrary temporary variables: the Storage Area, an array of 32-bit values, is used for this. Values in the each fonts's 'maxp' table declare the number of Twilight Points and storage locations.

Functions
In any programming language functions, or subroutines, make the program smaller and more manageable. In TrueType, functions can be defined in the Font Program ('fpgm' table) or the CVT Program ('prep' table), but not in the glyph programs. Before any characters are rasterized in a font, the Font Program table ('fpgm') is executed.

The Font Program and the CVT Program
The Font Program ('fpgm' table) only contains function definitions; these may be called from the CVT program ('prep') or from individual glyphs. The CVT Program (or preprogram), exectuted before any glyphs at that ppem are rasterized, may define additional functions or redefine exisiting ones. Although instructions that move outline points are illegal in the CVT Program, you can set points in the Twilight Zone.

Delta Hinting
Although the same TrueType code (if well-written) can deal with a wide range of sizes, the best fonts also use the "Delta" instructions to nudge control points at specific sizes. These are of the form: "At 12 ppem (pixels per em) move control point 5 by 1.25 pixels", paying respect to P and F. The CVT values can also be adjusted by Delta instructions, normally from within the preprogram 'prep'.

Dropout Control
Some glyph features are extremely difficult to hint, especially with very complex glyphs, or when glyphs are rotated. (Indeed, hinting rotated fonts is not well-explored.) In these cases, it is useful to switch on TrueType's "dropout control", a relatively slow means of ensuring delicate glyph features do not disappear entirely.

Performance
You might imagine that running these programs wastes a huge amount of time when displaying characters (and displaying characters is something you definitely don't want your computer to stall at). TrueType avoids hold-ups by:

  • Use of a font cache, so that once a character has been hinted and scan-converted, its bitmap can be used repeatedly (like many other scalable font systems). In the Macintosh and Windows implementations this cache expands and contracts dynamically.

  • Precomputation of frequently used values: most importantly, character widths at common sizes (the 'hdmx' table).
Windows 3.1 hinting limitations
Windows 3.1 uses 16-bit values in many parts of its hinting implementation where you'd expect 32-bit values from the specification. Thus hinting code must be written carefully to prevent arithmetic overflow.



TrueType and auto-hinting

Programs that claim to convert Type 1 fonts to TrueType normally make some attempt to place hinting in the new TrueType file. DTP Type Designer and FontLab 3.0 translate hints in the Type 1 font. Fontographer offers 3 levels of TrueType auto-hinting: dropout-prevention only; autohinted; autohinted + diagonal control. But it is not made clear what algorithms are followed in the autohinting process, so the best results are achieved with "trial and error".

Auto-hinting in professional TrueType production
The task of writing a hinting program for every character in every font you create is a rather daunting prospect (for a family of 8 fonts, that might mean around 2000 little programs!). So, even expert TrueType hinters sometimes make use of auto-hinting, which they fine-tune later. Type Solutions' StingRay is dedicated to this, but Fontographer or FontLab could feasibly be used in certain cases.

Auto-hinting can only be effective when there are lots of characters in a font to relate to each other; thus, an auto-hinted logo (or other graphic) will not generally be any better than the unhinted version.


Other references to hinting

How does TrueType hinting differ from other outline font formats?
Informative page from Microsoft, describing TrueType's capabilities of shape modification, optical scaling (based on the number of pixels available), non-linear scaling, diagonal control, and how the "intelligence" in TrueType font display is in the font itself, not the rasterizer.

Instructing / Hinting
Arleigh Movitz & Dave Opstad of Apple write, as part of the TrueType GX font quality specification. This is a fine overview of the concepts to bear in mind for TrueType hinting.

TrueType Hinting
What is hinting? Why is it necessary? How does it help? TrueType hinting vs other methods... explained by Microsoft.

Basic hinting philosophies and TrueType instructions
Microsoft Typographic Engineer Vincent Connare's TrueType hinting tutorial. He covers hinting from the high-level concepts down to the native instructions, using the letter 'O' as an example.

Get The Hint!
Tom Rickner of Monotype explains to Daniel Will-Harris how, using TrueType hinting, he produced the Verdana and Georgia families - outline fonts that, at small sizes on screen, match exactly the bitmaps required by designer Matthew Carter.

Hinting
A page or two from the W3 Consortium (not very useful).

Article by Charles Bigelow (1994)
Chuck writes on the genesis of Times New Roman (at Monotype) and Times Roman (at Linotype), and how this pair of fonts emerged as the litmus test in the race to develop the ultimate scalable font rendering system in that heady period for the digital fontologist, the late 1980s.

Model-based Matching and Hinting of Fonts
A paper by Roger D. Hersch and Claude Betrisey of the Ecole Polytechnique Fédérale de Lausanne, in SIGGRAPH '91, pp. 71-80. The paper describes an approach to the automatic hinting of non-fancy fonts.

Automatic Hinting for Intelligent Font Scaling
A paper by Peter Karow, URW, in the proceedings of the 1989 Raster Imaging and Digital Typography conference, pp. 233-241.

Hinting in FontLab
This online extract from the FontLab help system is an excellent guide to both Type 1 and TrueType hinting.

The raster tragedy at low resolution
Microsoft's Beat Stamm explains, with the aid of lots of pictures, why you need to control carefully what happens when graphics (of course, letterforms being the most important of these) are displayed at low resolutions.


TYPE*chimérique | TrueType Typography | TYPE*links