|
Computers & Writing Systems
You are here: Type Design > Design Tools Notes on Hinting with FontLab
Most fonts look great when printed, but look terrible on screen. It takes special instructions, built into the font, to improve screen appearance. These "hints" tell the computer how to be consistent when drawing strokes and individual features. Font development programs, such as FontLab, will automatically generate these hints, but the results are not always satisfying. Some of these also include the ability to manually set hints. Hinting a font manually can be a long, tedious, frustrating process. It doesn't take much effort, however, to improve upon FontLab's autohinting. You can also tweak individual glyphs while allowing FontLab to deal with the rest. The key to successful hinting is the correct setting of alignment zones and stem values. Once those are in place, even FontLab's automatic hinting works better. Then you can go in and play with those glyphs that really bother you. This article is intended to help you maximize FontLab's autohinting behavior. It is not a full tutorial on hinting strategies or techniques, and doesn't get into details of when it's better to use an align instead of a link, etc. There are some documents that do discuss this. See the list of links at the end of this article. Screenshots are from FontLab 4.5 for Macintosh, but are not substantially different from what you'd see in Windows. Examples are from Roman fonts, but the same concepts can be applied to non-Roman ones as well. If you have comments, corrections, additions, etc. please use the annotation feature at the bottom of this article to add them. Thank you! Recent updates:
Hinting process in summaryThe process described below is a general outline for hinting a font in FontLab. This assumes that you've been drawing your glyphs using PostScript Bézier curves, but want to deliver a hinted TrueType font. Disclaimer: this process seems to work, although I will admit that I don't understand why in every case. There are some steps that mystify me, but they seem to work!
Detailed steps1) Prepare the font for hintingThe pain you will feel in hinting is directly related to how consistently the glyphs have been designed. Care invested in checking stroke widths, heights, depths, etc. will pay off in better autohinting and easier manual tweaking. Be careful, though - you never want to sacrifice an important glyph feature for the sake of consistency. But despite how consistent you are, sometimes the glyphs just look terrible on screen. But that's why you're reading this article. Finish glyph design before starting to hint. Do not attempt to hint a font while you're still adjusting glyph shapes. You can certainly set alignment zones and stem widths during design, but be sure that you don't later depart from those parameters for new glyphs. Most glyph design is done with PostScript curves. Most hinting techniques, however, require your glyphs to be converted to TrueType curves, and it is impossible to convert them back to PostScript without destroying the hints. Note: You can retain the PostScript curves by copying them to the mask layer. 2) Audit and set Alignment ZonesThe purpose of this step is to look at the actual coordinates of your glyph outlines, so you can tell the computer how to draw them at low resolutions. There are features in font design programs (including FontLab) that do this auditing for you, but their guesses are usually very poor. You can do the same in two hours or so and with fantastically better results. This is especially true for non-roman scripts. Alignment zones are ranges of vertical (y) coordinate values. When glyph coordinates (the top of the o, for example) fall within the range they will be hinted to line up with other glyphs who have values in the same range. Alignment zones are actually a PostScript, not TrueType, feature, but FontLab's TrueType autohinting routines are based upon these settings. If zones are set incorrectly it can cause text to look like a cobblestone path. In the example below, the first line in each pair has incorrectly set alignment zones. The second is from an identical font after the zones have been corrected. Example of font with incorrectly set alignment zones (top) and with corrected zones (bottom). FontLab displays alignment zones as blue horizontal stripes in the Glyph Window. To show them, choose . If no zones appear after using this menu selection, the zones may not yet be set. Each blue stripe shows the lower and upper limit of the zone.Alignment zones in FontLab A zone is needed for each vertical level where glyphs ought to align. For example, in a roman font there are typically five zones, as illustrated above. Non-roman fonts may require more or less, depending on the script. Step 1: Choose a representative set of glyphs and analyze their heights. For many fonts, this would include every glyph. Look at each glyph and write down the vertical coordinates for those points that should align, as in the following example. Step 2: Gather the coordinates from all glyphs into appropriate zones. For example, if the set of coordinates near the x-height level is (916, 922, 923, 935, 940, 944), then the zone would be [916, 944]. Resist the temptation to make your alignment zones very wide. If you find an important point at (850), do not add it to the above range, as it might distort that single glyph. It would be better to create a new zone. Note that in the figure above, a zone is set for ascenders, even though the zone consists of a single unit height. This will ensure that all ascenders align well. Step 3: Enter the coordinates into FontLab. Choose . Consult the FontLab manual for information on adding specific zones. "Primary zones" are typically ones that are at or above the baseline zone area. Other zones (including the descender zone) should be added as "Secondary zones". Then you're done! 3) Audit and determine stem valuesThe widths of basic vertical and horizontal strokes (called stems) need to be consistent for a font to be readable. Vertical stem widths in the letters h l m n should appear to be the same width at all resolutions. Careful design will provide this consistency, but identical widths cannot always be achieved (especially in the case of curved strokes). [Note: "Vertical" stems are those that go up and down, but their width is measured as the change in horizontal (X-coordinate) units. Strange, I know. The reverse is true for horizontal stems] The process of auditing stems is similar to that for alignment zones: carefully review each glyph, write down the important measurements, then analyze those widths to determine the optimum stem values. This is the same process whether or not you're using FontLab, but some illustrations from FontLab can be helpful. TrueType hinting stem values Here is an example of a list of vertical stem values from FontLab's TrueType hinting controls. We'll tell you how to get here later. Each defined value has a name (which you set), a standard width, and specifies at which PPM (pixel-per-em) sizes that stems of that width should jump to 2, 3, 4, 5 and six pixels wide. For example, stems that are 86 units wide will appear as a single pixel line until the PPM goes to 36, at which point the stems will become two pixels wide. At 60, the stems become three pixels wide, etc. [Note: PPM is not the same as point size, but you'll have to look elsewhere for an explanation of that.] To make this work you need to know what your stem widths are. This example shows vertical (red) and horizontal (green) stems for a rather inconsistent font. Stems are always measured from point-to-point (never curve to curve), even if the points are not aligned with one another. Remember that the vertical stem widths are measured as changes in the horizontal direction. Even though the points for the right hand (curved) stem on the p are not aligned, measure only the change in the horizontal direction, not the actual distance between the points. In this example the points are 186 units apart, but the horizontal change is only 160 units. Step 1: Start with vertical stem widths. Walk through the glyphs and write down the unit widths you find, and which glyphs use them (and exactly which part of the glyph uses it). The example image shows how I collect this data. I separate the straight stems from the curved, and the upper case from the lower case. This is not necessary, but can help in analyzing the data later. Step 2: Organize the stems into groups. Sorry, but this requires some additional technical information. FontLab's autohinting routines analyze each glyph and try to match each stem width with one of the values that have been set in the TrueType hinting controls. The precision of this matching is controllable through the Autohinting Options dialog. Choose . The Single link attachement precision setting determines how many units of variation FontLab will allow when assigning a stem to a value. For example, if one of the font's preset stem values is 168, and if the precision setting is set to 3, then all stems that are of widths 165-171 will be assigned to that value, but not stems that are 164 or 172 units wide. Clustering of stem widths into values As you trawl through your font, you will hopefully see patterns in stem widths, and how much precision will be necessary. With this in mind, write down the clusters of widths that should appear similar at low resolutions. In the example above, widths of 67-72 units are clustered for hinting purposes and assigned a common value of 69. With precision set at 3, this will assign all stems that have widths of 66-72 units to that value (which is what you want). Whiteboards are great for this! One caveat: I'm not exactly sure what would happen if you created multiple values that overlap ranges, like 96 and 98 (with precision 3). Which value would width 97 be assigned to? I don't know, so I avoid such overlaps. You should now have a list of vertical stem values that cover the important stem widths of your font. You'll use this in Step 4. Step 3: Repeat the process for horizontal stems, including serifs. Now you should have two lists of values, X (for vertical values) and Y (for horizontal values). Here is an extended example: Single link attachement precision = 3 Vertical stems (X values) 36 (33-39) 89 (86-91) 162 (160-164) 169 (167-171) 175 (173-177) 186 (185-187) 193 (190-195) 206 (203-209) 213 (210 - should track with 228) 228 (225-231) Horizontal stems (Y values) 31 (31) 37 (35-38) 48 (47-50) 56 (56-59) 63 (61-65 - should track with 56) 69 (67-72) 76 (73-79) 86 (83-89) 116 (113-118) 123 (120-126 - should track with 116) 141 (139-143) 163 (160-166) 204 (203-205) Here the stems are listed in order, with the stem value on the left and the widths it will need to cover on the right in parentheses. There are a few things to note. Vertical stem 213 is intended for the sole use of stems that are 210 units wide, but I chose the higher number to avoid overlapping precision zones. Again - I'm not sure if this is necessary. Where it says "should track with..." it means that that stem should track with the other one mentioned. Horizontal stem 63 should track with stem 56, meaning that the two should always appear the same width. You'll see how to enforce that later. 4) Set Type 1 valuesEnter your values from the above steps into the FontLab Type 1 hinting information dialog. Choose . Enter the V and H stems here. There is a limit of 12 stems widths for each direction (for Type 1). If you have more than 12 values, you can add them later in the TrueType hinting controls.Now save your font! This should always be kept as your pre-TrueType-hinting version. 5) Convert glyphs to TrueTypeWarning! These next steps change the actual outlines of your glyphs, so please be sure you have saved an archive copy. The next step is to convert your glyphs to TrueType outlines. Wait - You may not even need to do this. First complete the steps above, then generate a font. It will probably look a lot better on screen already. That may be good enough for you. If not, read on. If you do want more control, conversion is necessary. You don't have to convert every glyph, though. If you only wish to adjust the hints on a particular subset of glyphs (such as the basic 26 uc and lc letters), only convert those. One more safety step. For each glyph that you are about to convert, open the glyph window, clear the mask layer ( ) and copy the outline to the mask ( ). This will retain your Bézier curves in the mask.Finally, select the glyphs you wish to convert in the Font window, choose , set the to . Ignore the setting. In the left pane click the triangle beside , scroll down and choose . Press the right arrow button. The right pane should now say (and nothing else). Finally, press .6) Set TrueType stem valuesThe next action is to set the TrueType stem values. Step 1: Reveal the TrueType hinting tools. Open one of your chosen glyphs to show the outline. Press the button to reveal the tools. If you get a dialog that warns you about correcting outline problems, press . Step 2: Find and remove any existing stem values. Find the palette and press the ellipsis button. This will reveal the dialog that was illustrated in an earlier section and is repeated below. If there are stems listed select each one and remove it by pressing the button . Step 3: Import the Type 1 stems and enter in any additional ones. To do this, press the button . It would be a good idea to review what is there, and make sure it is correct. You will also need to add in any extra stem values that went beyond the limit of 12 Type 1 stems. Be careful when adding stems-it can be very easy to add the wrong type (X or Y) of stem. FontLab's button tooltips are confusing here. Finally, press the button to make the PPM values more uniform. You can always change these later, but this gives a pretty good guess. Press to finish the step. Step 4: Generate a test font. It would be a good idea to give the font a unique name in the dialog so you can test it alongside other versions. Also be sure that all the hinting options are checked in the dialog. FontLab Export Options 7) Test resultsHinting is a trial and error process, so this is not really a singular step in itself. Initial feedback on your results can be obtained through FontLab's windows, but the real test is to try the font in a real setting. Here are some basic helps (thanks to Lawrence Penney for some of these). Test in the most common environment (Word and Internet Explorer on Windows), as well as any particular apps/OSes that you care about. The difference between Word and IE is that Word will display text using printer metrics, whereas IE uses screen metrics. They also use different rasterizing systems, so your hints may have different results (and not just in spacing). In other words, you need to look carefully at both in order to be sure that everything is OK. Here's an example of an html file that can be used with IE. Change the font names in the style, add whatever text you want to use and open with IE (or any other browser). You can even add additional styles (.fontthree, .fontfour, etc.). <HTML> <HEAD> <TITLE>Hinting Test</TITLE> <STYLE type='text/css'> .fontone {font-family: "Doulos SIL"} .fonttwo {font-family: "Doulos SIL 0032auto"} </STYLE> </HEAD> <BODY BGCOLOR="#FFFFFF"> <p> <span style='font-size:8 pt' class="fontone"> Sample text goes here</span><BR> <span style='font-size:8 pt' class='fonttwo'> Sample text goes here</span><BR> </p> <p> <span style='font-size:10 pt' class='fontone'> Sample text goes here</span><BR> <span style='font-size:10 pt' class='fonttwo'> Sample text goes here</span><BR> </p> </BODY> </HTML> Test a range of sizes. View sample text at what you consider to be "normal" viewing size, and test at 3-4 sizes above and below. Keep in mind that you may run your machine at much higher (or lower!) resolution than others. Someone with a 1024x768 17" monitor will likely choose a smaller size than someone using the same resolution on a 12" laptop. If you are testing on a Mac, zoom the display to 133% to see the Windows equivalent, or choose a different point size (16pt instead of 12 pt). This is due to the typical difference between Mac and Windows resolution, although this is becoming less and less of an issue. A different technique is to set your document in Word for Windows to 75% zoom. This will synchronize the point size and PPM value, so that 12 point on the screen will be the 12 PPM size. Test even at large sizes, especially if depending on autohinting. FontLab's routines can add in some pretty wild hints that cause problems when the glyph gets big (say, at 48 PPM). Watch out for font smoothing/antialiasing. There are huge debates on the whole "fuzzy letters" issue, but most people will have it on. Test in both, although your hints will be much more relevant to unsmoothed images. Use pixel magnification utilities. On Mac OS X, Pixie (installed with developer tools in Developer/Applications) will give you instant magnification of the region near your pointer. On Windows, use ZoomIn. You can also make screen dumps/snapshots, then view them magnified in an image browser. 8) Manually revise hints on specific glyphsIn order to alter, or even view, the autohinting that FontLab does, you first need to explicitly autohint those glyphs (which gives you Type 1 links), then convert the links to TrueType instructions. This can be done with a single action. Select the glyphs you want to view or edit in the font window. Choose , set the to . Ignore the setting. In the left pane click the triangle beside , scroll down and choose . Press the right arrow button. Then click on . Press the right arrow button. The right pane should now have two (and only two) items under : and . Finally, press . If you already have hints on any of these glyphs that you wish to eliminate, insert the command before the other two items and choose only the hints.Now your glyphs have visible TrueType hints based upon the parameters you set earlier. Yes, you had automatically generated hints before (based on your parameters), but they were created when you generated the font. The difference is that now you can actually see the hints if you open a glyph window and activate the TrueType hinting tools by pressing . The process of making these hints visible will not improve them automatically, but will allow you to tweak them manually. You're now ready to take the plunge into manual hinting. At this point (I hate to say), I don't have any specific advice as to how to hint, or rehint. The documents listed in the Sources for information on hinting, below, are good starting places. I hope to have some illustrated examples here someday, but it would be best if you get familiar with what the experts have written first! Nevertheless, here are some general tips: Pick a subset of glyphs to manually hint, and rely on FontLab to do the rest. Be careful, though, as FontLab's hints can sometimes be too aggressive. One way to manage this is to convert the troublesome glyphs into TrueType curves, then wander through them, deleting hints that don't make sense. This is less work that rehinting the glyphs from scratch, and could give you results that are just as good. Don't fix what ain't broke. If a glyph looks good, don't touch it. Focus on the difficult ones. The only instance where you would want to modify good-looking glyphs is to make their hint behavior similar to the others, and hopefully make them look even better. Hint in a deliberate order. Find a few representative glyphs and experiment. Once you've made basic decisions (such as whether to hint vertical stems left-to-right, right-to-left, or outside-in), then hint similar features for all the glyphs in sequence. For example, hint all the vertical stems (X direction) for all glyphs, then do the horizontal ones. For a non-roman script, such as Thai, hint common features (such as all the 'heads') at the same time. This will help you maintain consistency and all the beauty the script deserves. Pay careful attention to the results of hinting on the outline, not just the pixels. Keep in mind that although the final result (gray dots) is important, you must understand how the renderer is creating the dots. Look carefully at exactly what the hints have done to the outline, not just the dots. How it gets the dots is more important and can give you clues as to how to fix problems. Avoid using delta hints. Try to do everything without them. Then go back and tweak what just doesn't quite look right. Be sure you take advantage of setting the PPM range for deltas - it can save a lot of work if you can share the same delta among more than one PPM size. Consider hinting the alignment zones themselves. If your glyphs seem too short at specific PPM sizes, don't try and use individual deltas to raise them up. Instead, hint the alignment zone itself. This will raise up everything that falls within that zone, so you won't have to tweak each glyph. This hinting is essentially a global delta, so it only affects specific PPM sizes. Normally, you can set deltas to affect a range of PPMs, and even though it looks like you should be able to do this for zones, it doesn't work. Note that this will affect all glyphs that rely on autohinting, not just the ones you have already converted to TrueType curves. Cool! See the FontLab documentation on Hinting Alignment Zones for more information. Avoid unnecessary complexity. It is far too easy to keep adding hints to a glyph until you have them on every point or feature. Generally, fewer hints are better, but do use whatever hints are actually necessary. If your hinting gets too complex it can result in very strange behavior at large sizes. So if you do have a lots of hints on a glyph (not counting deltas, which work only at specific sizes), it would be a good idea to look very carefully at the glyph at all sizes (including printing resolutions). You are writing a computer program, not just designing shapes. Hinting is programming, although FontLab gives you a nice interface for it. Try to think as the computer would. How would this command affect the others? If I align this point in this way, how will that affect linked points? Have fun! Hinting can actually be enjoyable. When it works. :-) Sources for information on hintingIntroductory articlesTrueType hinting [Microsoft] http://www.microsoft.com/typography/hinting/hinting.htm The best summary of why hinting is needed and how it can be used. Excellent! TrueType Hinting [Lawrence Penney] http://www.truetype.demon.co.uk/tthints.htm Brief intro with a good number of links to interesting material. In-depth TutorialsBasic hinting philosophies and TrueType instructions [Vincent Connare, Microsoft] http://www.microsoft.com/typography/hinting/tutorial.htm This is pre-FontLab, and pretty technical, but is useful as a reference to manual hinting strategies. The raster tragedy at low resolution [Beat Stamm, Microsoft] http://www.microsoft.com/typography/tools/trtalr.htm A good description of hinting in general, as well as a walk-through of how to hint troublesome glyphs. Uses examples from Visual TrueType, but most of it works the same way in FontLab Technical ReferenceFontLab documentation [FontLab] http://fontlab.com/html/fontlab.html The best resource for details on hinting with FontLab. Hinting ToolsFontLab http://fontlab.com/html/fontlab.html The most common tool for hinting these days. Does not support full TrueType hinting options, but has few serious limitations. Microsoft Visual TrueType http://www.microsoft.com/typography/tools/vtt.htm A more high-powered tool than FontLab, but probably overkill for most folks. AcknowledgementsThanks to Lawrence Penney, Jonathan Kew and the folks at Apple and Microsoft for their wisdom on this topic. Note: the opinions expressed in submitted contributions below do not necessarily reflect the opinions of our website.
"Robert Lloyd Wheelock", Wed, Dec 31, 2003 01:22 (EST) I\'m familiar with the kerning and metrics adjustment pop-up window in FontLab. When I edit characters for combining (nonspacing) overstruck diactritic and accent marks for a font, how do I adjust the sidebearing lines and centerpoint mark so that the accent automatically goes on the base character(s) it\'s intended to (usually centered, but sometimes right or left)? How do you adjust the red diamette anchor points on characters so they\'ll refer to where a given accent/point would be positioned?
gaultney, Mon, Jan 12, 2004 10:37 (EST) That\'s a bit complicated to get into here. You\'ll need to consult the FontLab documentation on attachment points (or ask someone on the FontLab community at MSN) for the help you need. Victor © 2003-2024 SIL International, all rights reserved, unless otherwise noted elsewhere on this page. |