284 TUGboat, Volume 18 (1997), No. 4

Hinting is very important at low resolution (on Forum screen, typically 72 dpi or 96 dpi), where it is hard to get an adequate representation of a continuous shape on a discrete grid. It is still significant at ‘Hinting’ of scalable outline medium (laser printer, typically 300 dpi or 600 dpi) Berthold K.P. Horn resolution, but is not important at very high resolu- tion (image setter). ‘Font smoothing’ or anti alias- ‘Hinting’ refers to methods that guide grid fitting of ing also reduces the importance of hinting, although continuous outlines onto a discrete grid, such hinting can reduce the number of ‘fuzzy edges’ that as those found on a display screen or laser printer. can be distracting in anti-aliased fonts. The need for hinting Different hinting ‘languages’ Scalable outline fonts — such as fonts in Adobe Type Intelligent grid-fitting of continuous shapes onto a 1 and TrueType format — have continuous shapes discrete grid requires a mapping that involves more described by mathematical curves. These are used than simply rounding of x and y coordinates. Much to create a discrete raster of dots on a display or can be achieved by instead setting up a piece-wise hardcopy output device at a specified size. If such linear mapping for each coordinate axis, with corner a bitmap is made in a simplistic way — such as sim- points at the edges of stems and alignment zones. ply blackening each cell whose center lies within the An alternative to such a ‘global’ approach is one contour — then a number of visually distracting ar- that depends instead on individually adjusting coor- tifacts arise — such as misalignments of features and dinates of knots. The latter approach is more pow- breaks in shapes, also called ‘drop-outs.’ erful, but more awkward to use. Typically hinting is used to do things like: The Adobe Type 1 hinting language is declar- • make sure stems intended to be equally thick ative, hence easy to use. Since the ‘brains’ behind appear equally thick; it is in the rasterizer, rasterizing quality of a font • suppress overshoots — rounded letters (O) are may be improved if an improved rasterizer is release. taller than flat ones (X); However, since the Type 1 rasterizer is not described anywhere, the exact effect of various hinting meth- • line up features on different that should ods can only be ascertained by experiment. be at the same height; The TrueType hinting language is imperative • avoid ‘drop-outs’; and powerful, but also painful to use by compari- • keep counters between stems open; son. The TrueType rasterizer is described, so it is • force consistent spacing between sets of parallel possible — in principle — to predict what the effects strokes; of a change might be. One reason the TrueType • compensate for ‘misfeatures’ of the rasteriza- hinting language needs to be more powerful is that tion algorithm such as drop-outs. the underlying rasterizer has misfeatures (like drop- outs) that need to be ‘patched up’. All the ‘brains’ A simple example is in the TrueType font — not in the rasterizer — so A simple demonstration of the need for hinting is the it benefits less from improvements to the rasterizer. following: suppose you have the letter ‘H,’ which — also provides methods for grid-fit- when scaled to the discrete grid of the output de- ting outlines, as described in ‘Discreteness and Dis- vice — happens to have vertical stems from x =1.2 cretion,’ chapter 24 of The METAFONTbook.There to x =2.8 and from x =4.8tox =6.4. So the is no separate ‘hinting language’ in this case. The original width of both stems is 1.6 pixels. work is done using METAFONT’s built-in mecha- Now suppose that the rasterizer ‘inks’ every cell nisms for enforcing constraints established by equal- whose center is inside the outline. Also suppose that ities or inequalities. the discrete grid of pixels has integer coordinates at Hint switching and delta hints the corners and that we round continuous values to the pixel centers. Then the discrete version of the Quality hinting code is tightly interlaced with the left stem will run from x =1tox = 3, while the program that draws the glyph, since different ‘hints’ discretized version of the right stem goes from x =5 may apply to different parts of the glyphs. This is to x = 6. In the discrete version then, the left stem called ‘hint switching’. is twice as fat as the right stem — a visually very For a simple example, let us consider the ‘R’ in noticeable difference. CMR10. It has a slab lying on the at the TUGboat, Volume 18 (1997), No. 4 285

bottom of the left leg and a curled shape that drops particular face at small sizes versus making it more below the baseline on the right leg. If horizontal readable. stem hints are applied to correctly grid fit the slab There are few good tools for doing quality man- on the left leg, then the right leg will be drawn be- ual hinting. For Type 1 fonts, most font generation low the baseline, even at very small sizes where this software has some support for manipulating hints looks ‘wrong’ and where pulling the right leg up to graphically. Type Designer even provides for hint the baseline produces a visually more pleasing re- switching. But without being able to see clearly sult. Conversely, if a horizontal stem hint were to what hints go where, it isn’t really good enough to be tuned for the curl in the right leg, then the slab be useful. For TrueType, the only hinting tools are at the bottom of the left leg would tend to be ras- from Type Solutions in New Hampshire. terized floating above the baseline. To get the best rasterization at all sizes, the glyph has to be split The quality of fonts and of rasterizers into two parts and the right leg rasterizered with Note that the ‘hinting’ code can be a substantial different hints than those used for the left. part of a font, particularly in the case of quality While simple shapes (like a sans ‘H’) re- TrueType fonts. If you pass one of the quire no hint switching at all, some complex shapes core fonts (, , and such as the ‘Weierstrass p’ (℘) may require many New) through one of the font generation tools you switches. will see a dramatic drop in size as a result of the TrueType provides a mechanism called ‘delta fact that the original hints are lost. In some cases hinting’ which makes it possible to make correc- quality TrueType fonts shrink by almost 50% (and tions specific to particular resolutions (measured in lose their quality, of course) by this kind of liposuc- ppem — pixels per ‘’). This is useful in correct- tion. Type 1 is simpler and so rarely ing drop-outs which occur over certain size ranges. adds more than 10% to 20% to file size. A glyph has to be checked at all sizes that a user Hinting code is interpreted by the rasterizer and is likely to use (‘waterfalls’), and drop-outs patched so its effectiveness depends on how well the raster- up using delta hints that apply at those sizes. It is izer makes use of it. (ATM) possible to draw a complete bitmap using TrueType does the best job for fonts in Type 1 format, with hinting code. PostScript interpreters in printers typically not be- Type 1 fonts use a different (undocumented) ing quite as sophisticated. Various Display PostScript rasterization algorithm that first creates a continu- systems mostly do not do as well as ATM either. ous outline that has no drop-outs, but that is ap- This may change as Adobe upgrades PostScript in- proximately 1/2 pixel too wide all the way around. terpreters under its control. Naturally ‘clones’ don’t It then erodes this outline using Euler-number-pre- do as well. serving binary image operations — which cannot in- troduce drop-outs. Hence there is no need to ‘patch Moral up’ the result. Use only quality fonts. Fonts on those discs that offer ‘a zillion fonts for $29.95’ are mostly poorly Hint types and hinting tools made derivatives of the real thing. Typically the Some hints are font wide, such as information on original hinting is stripped out (perhaps because it ‘alignment zones,’ dominant stem widths, and over- is thought to be better protected by copyright than shoot suppression. But the bulk of hinting code is at the rest of the font program). the character level. Often the character level code is designed to interact with the font level code (e.g. so- References called ‘ghost’ stems interacting with font level align- Adobe Systems Inc. Adobe Type 1 Font Format. ment zones at x-height, cap-height, figure-height, as- Addison-Wesley, 1.1 edition, 1993. cender, heights and so on). Adobe Systems Inc. “Font Hint Information”. Some simple types of hints follow systematic http://www.adobe.com/supportservice/ rules and can be generated automatically by some devrelations/typeforum/hinting.html, applications such as Fontographer, FontLab, Type- 1997. Includes references to electronic copies Designer, and Ikarus. Others require judgement; of the Type 1 format specification and related quality hinting is more of an art than a science. For information. example, you get to choose (roughly speaking) be- Apple Computer, Inc. Inside Macintosh/ Text. tween preserving more of the unique character of a Apple technical library. Addison-Wesley, Reading, MA, USA, 1993. 286 TUGboat, Volume 18 (1997), No. 4

Apple Computer, Inc. “How the Font Manager Renders Outline Fonts”. http://devworld. apple.com/dev/techsupport/insidemac/ Text/Text-199.html, 1997. From the book Inside Macintosh/ Text, chapter 4. Hersch, Roger D. and C. Betrisey. “Advanced Grid Constraints: Performance and Limitations”. In Raster Imaging and Digital Typography, edited by R. A. Morris and J. Andr´e, pages 190–204. Cambridge University Press, 1991a. Hersch, Roger D. and C. Betrisey. “Model-based Matching and Hinting of Fonts”. Computer Graphics 25(4), 71–80, 1991b. Proceedings of SIGGRAPH’91. Karow, Peter. “Automatic Hinting for Intelligent Font Scaling”. In Raster Imaging and Digital Typography, edited by J. Andr´e and R. D. Hersch, pages 233–241. Cambridge University Press, 1989. Karow, Peter. Digitale Schriften — Darstellung und Formate. Springer-Verlag, 1992. Knuth, Donald E. The METAFONTbook, volume C of Computers and . Addison-Wesley, Reading, MA, USA, 1986. Lee Hetherington, I. and P. Tutelaers. “Type 1 utility programs”. Available from CTAN fonts/utilities/t1utils, 1992. A set of programs for examining Type 1 fonts. Penney, Laurence. “TrueType Typography”. http: // www.truetype.demon.co.uk/tthints.htm, 1997. Studio Verso. “Font Discussion: Hinting”. http://fonts.verso.com/hinting/, 1996. Comments from a W3C discussion of Web fonts in November 1996. The Microsoft Corporation. “Features of TrueType: TrueType Hinting”. http:// www.microsoft.com/truetype/hinting/ hinting.htm, 1996. Type Solutions, Inc. “Type Solutions TrueType hinting software: Visual TypeMan and Visual StingRay”. http://www.typesolutions.com/ TTTools.html, 1997.

 Berthold K.P. Horn Y&Y, Inc. 45 Walden St. Concord, MA 01742 USA [email protected]