- font surgery - http://www.fontsurgery.com -

Autohinting with FontLab Studio 5

Posted By Adam Twardoch On 2011-05-11 @ 23:54 In Hinting | No Comments

This doc­u­ment describes an exam­ple process of gen­er­at­ing hinted fonts with Post­Script or True­Type out­lines using auto­matic and/or sim­ple man­ual steps in Font­Lab Stu­dio 5.

The pro­duc­tion of hinted fonts can be pri­mar­ily divided into three major parts:

  • read­ing hint­ing from exist­ing native fonts
  • adding hint­ing to an exist­ing .vfb document
  • writ­ing hint­ing into gen­er­ated native fonts

For more detailed infor­ma­tion about hint­ing in Font­Lab Stu­dio, please refer to the User’s Man­ual. We also rec­om­mend read­ing the arti­cle Notes on Hint­ing with Font­Lab [9] by J. Vic­tor Gaultney.

1. Intro­duc­tion

There is a fun­da­men­tal dif­fer­ence in how Font­Lab Stu­dio (FLS) treats hint­ing infor­ma­tion for Post­Script–fla­vored glyphs and True­Type–fla­vored glyphs. PostScript-flavored glyphs are those used in Open­Type PS (.otf), Type 1 and Mul­ti­ple­Mas­ter fonts. TrueType-flavored glyphs are those used in Open­Type TT (.ttf) and True­Type fonts. The native Font­Lab doc­u­ment for­mat (.vfb) can store both kinds of glyphs.

Hint­ing in PostScript-flavored glyphs (PS hint­ing) exists on one level only, so no trans­la­tion or con­ver­sion is nec­es­sary. Font­Lab Stu­dio can loss­lessly read and write PS hint­ing, it can also loss­lessly mod­ify PS hint­ing as well as gen­er­ate it. More pre­cisely: FLS sup­ports Type 1 hints natively. When read­ing Open­Type PS (.otf) fonts, FLS con­verts CFF hint­ing into Type 1 hinting.

Hint­ing in TrueType-flavored glyphs (TT hint­ing) exists on two lev­els:

  • the low-level TT hint­ing (native) — assem­bly code in the True­Type instruc­tions lan­guage, com­piled into binary form, stored in Open­Type TT (.ttf) and True­Type fonts, as well as option­ally stored in the Font­Lab .vfb documents.
  • the high-level TT hint­ing (visual) — visual instruc­tions in FontLab’s own TTH lan­guage, stored in the Font­Lab .vfb documents.

Font­Lab Stu­dio can read low-level TT hint­ing. FLS can also write the stored low-level TT hint­ing but only for glyphs that had not been mod­i­fied. If you mod­ify a glyph, the stored low-level TT hint­ing will be removed.

Font­Lab Stu­dio can also con­vert PS hint­ing into high-level TT hint­ing, mod­ify the high-level TT hint­ing, and con­vert (com­pile) the high-level TT hint­ing into the low-level TT hint­ing. Note that FLS can­not con­vert (decom­pile) the low-level TT hint­ing into the high-level TT hinting.

2. Open­ing fonts

If you’d like to store the low-level TT hint­ing when open­ing a TrueType-flavored font, make sure the Pref­er­ences set­ting Opening OpenType & TrueType / TrueType/OpenType TT (.ttf) / Store TrueType native hinting is enabled. If dis­abled, the True­Type assem­bly instruc­tions will not be read from the font. If enabled, they will be read, stored in the .vfb doc­u­ment and writ­ten back into a new gen­er­ated .ttf font — but only for the glyphs which have not been mod­i­fied within FLS.

A brown “T” mark in the lower-right cor­ner of a glyph cell indi­cates that low-level TT hints are present in the glyph (either read from the orig­i­nal TrueType-flavored font, or gen­er­ated using Font­Lab Studio’s True­Type Hint­ing tool).

[sin­glepic w=645 id=1]

When open­ing PostScript-flavored fonts, their hint­ing is always read from the font and stored in the .vfb document.

3. Post­Script out­lines and PS hinting

3.1. PS hint­ing UI elements

Pref­er­ences

The Preferences dia­log box con­trols some vital aspects of how PostScript-flavored fonts (Type 1 and Open­Type PS) are gen­er­ated. In Preferences / Generating Type 1, the option Autohint unhinted glyphs allows you to auto­mat­i­cally auto­hint the font when it is gen­er­ated even if you did not per­form any spe­cific auto­hint­ing tasks. If a glyph does not con­tain any PS hints and this option is enabled, FLS will auto­mat­i­cally gen­er­ate hints for that glyph.

If you wish to con­trol your hint­ing man­u­ally and there are good rea­sons why you did not hint some glyphs, dis­able this option. (This will also allow you to gen­er­ate PostScript-flavored fonts with­out hint­ing if you remove the PS hints from all the glyphs).

Note that if the Autohint unhinted glyphs option is enabled, the ras­ter­ized pre­views in the Type 1 Hinting mode (and in its Pre­view panel) for glyphs with no PS hints present will be gen­er­ated after the glyphs have been auto­hinted in the back­ground, so you will see no hints but a PS-hinted pre­view. So if you want to reli­ably pre­view the ras­ter­i­za­tion of your actual PS hints, you should dis­able this option.

[sin­glepic w=645 id=2]

On the Generating Type 1 / Type 1 autohinting page, dis­able the option Remove all existing hints before autohinting if you wish FLS to add auto­mat­i­cally gen­er­ated hints to exist­ing PS hints.

[sin­glepic w=645 id=3]

Appli­ca­tion windows

The most com­monly used design source for fonts are fonts (or .vfb doc­u­ments) with Post­Script out­lines. An exam­ple of such font is Myr­iad Roman:

[sin­glepic w=645 id=4]

When a PostScript-flavored font is open, small green “H” marks in the lower-left cor­ner of the Font Window’s glyph cell will indi­cate glyphs in which PS replace­ment hints are present. Glyphs that have PS hints but have no replace­ments hints are not indi­cated in any par­tic­u­lar way.

Double-clicking on a glyph cell will open the Glyph Win­dow. To view the PS hints present in the glyph, enable View / Show Layers / Hints. To view the PS align­ment zones (blue zones), enable View / Show Layers / Alignment Zones.

[sin­glepic w=645 id=5]

For a more detailed view of the PS hint­ing for a glyph, choose Tools / Hints & Guides / Type 1 Hinting.

[sin­glepic w=645 id=6]

The Type 1 Hinting tool allows you to ras­ter­ized a pre­view of how the glyph will be ren­dered in a vari­ety of ras­ter­iz­ers. Click on the Preview panel but­ton in the Type 1 Hinting tool­bar to open the Type 1 Hinting Preview panel. A click on the lit­tle rec­tan­gle in the top-right cor­ner of the panel allows you to select the rasterizer.

[sin­glepic w=645 id=7]

Note that Font­Lab Stu­dio 5.0.4 on Mac OS X has a bug in how it inte­grates with the built-in Adobe ras­ter­iz­ers, so FLS may crash or dis­play the wrong ras­ter­ized images when any of the Adobe ras­ter­iz­ers is selected. This bug does not affect the qual­ity of hint­ing writ­ten into the font. The Win­dows ver­sion of FLS is more stable.

Also keep in mind that if the option Autohint unhinted glyphs is enabled in Preferences, then the Type 1 Preview ras­ter­i­za­tion will be auto­hinted even if the glyph win­dow does not show any PS hints.

Font Info

While the hints are con­trolled on the glyph level, there is a num­ber of rel­e­vant font-wide hint­ing set­tings. To view and edit them, open File / Font Info and open the Hinting Settings subsection.

The first page, Type 1 and TrueType hinting: alignment zones, con­trols the pri­mary PS align­ments zones (that are typ­i­cally located above the base­line) as well as the sec­ondary PS align­ments zones (typ­i­cally located below the baseline).

The PS align­ment zones will be used in PS hint­ing, and they will also be con­verted into TT align­ment zones.

By click­ing on Auto zones, FLS will auto­mat­i­cally rebuild the PS align­ment zones for the font. It will do so by ana­lyz­ing the bound­ing boxes of a hard­coded list of upper­case and low­er­case Eng­lish let­ters. If your font con­tains mul­ti­ple alpha­bets (scripts), or if it con­tains numer­als or small caps that are of obvi­ously dif­fer­ent height than upper­case or low­er­case let­ters, you should add more PS align­ment zones that will con­trol the over­shoot suppression.

[sin­glepic w=645 id=8]

The sec­ond page, Type 1 hinting: standard stems, con­trols the ver­ti­cal PS stan­dard stems that cor­re­spond to x-direction hint­ing, as well as the hor­i­zon­tal PS stan­dard stems that cor­re­spond to y-direction hinting.

The PS stan­dard stems will be used in PS hint­ing, and they will also be con­verted into TT stan­dard stems which are stored in the CVT table.

Click­ing on Auto stems will auto­mat­i­cally build a list of PS stan­dard stems found in the font. This will be done by ana­lyz­ing the PS hint val­ues found in the font — which means that the font needs to have hint­ing for Auto stems to work.

Also note that quite often, FLS will gen­er­ate more PS stan­dard stems than really nec­es­sary. For exam­ple, in Myr­iad Roman, the orig­i­nal V stem val­ues are 88 92, and the orig­i­nal H stem val­ues are 67 73. After Auto stems, V stem val­ues will be 88 70 97 and H stem val­ues will be 73 55 68. In some cases, stem val­ues will be quite close to each other, and you may want to unify them.

Note: When con­vert­ing PS hint­ing into TT hint­ing, you can con­trol the Single link attachment precision with which FLS will match each stem width with the TT stan­dard stems. If you cre­ate fewer stan­dard stems and increase the pre­ci­sion, the stems in the TT font will appear more uni­form. If you cre­ate more stan­dard stems and decrease the pre­ci­sion, the stems in the TT font will appear more varied.

[sin­glepic w=645 id=9]

The Type 1 hinting: global hinting parameters page only affects PS hint­ing. It does not affect TT hint­ing. Please refer to the FLS man­ual and the Type 1 font for­mat spec­i­fi­ca­tion for more infor­ma­tion about those parameters.

[sin­glepic w=645 id=10]

The Type 1 autohinting page defines the min­i­mal and max­i­mal dis­tances (in font units) between out­line for which PS hints will be auto­mat­i­cally gen­er­ated if glyphs are auto­hinted. For very thin fonts, low­er­ing the Min width val­ues may be a good idea. For very bold fonts, rais­ing the Max width val­ues may be useful.

[sin­glepic w=645 id=11]

3.2. PS autohinting

If your font already has PS hints, PS stan­dard stems and align­ment zones defined, you can skip this step.

If your font does not have PS hints, you should per­form the fol­low­ing steps to obtain PS hint­ing automatically:

  1. Go to Font Info / Hinting Settings and click on Auto zones.
  2. Add and revise the align­ment zones as needed.
  3. For each font that has stems that are thin­ner than 20 units or thicker than 250 units (default val­ues), nav­i­gate to Font Info / Hinting Settings / T1 Autohinting and set the Min width or Max width val­ues to match the thick­ness of your thinnest/thickest stems. Click on OK.
  4. Choose Tools / Action Set.
  5. From the Hints and Guidelines sec­tion, add the action Autohint to your action set.
  6. If you’d like to only gen­er­ate y-direction hints (i.e. hor­i­zon­tal hints) because you plan to gen­er­ate a TrueType-flavored font that does not need to be hinted in the x-direction (for exam­ple because the font will only work in ClearType, or the font is italic and the ver­ti­cal hints to not make much sense), add the action Remove hints/guides to your action set, and in the action’s options check Remove vertical hints and uncheck all the other options.
  7. From the Hints and Guidelines sec­tion, add the action Autoreplace to your action set.
  8. [sin­glepic w=645 id=12]

  9. Choose Apply action to: All glyphs in the font or All opened fonts. Click on Run.
  10. Go to File / Font Info / Hinting Settings / Standard stems (T1 hinting) and click on Auto stems.
  11. Add, revise and merge the PS stan­dard stems as needed.
  12. Click on OK.
  13. If you wish to use the Adobe PS auto­hin­ter, from the Macros tool­bar choose the Outlines sub­group and pick the Auto-hint macro. Ctrl-click on the Run but­ton to view the macro UI, set the desired para­me­ters and run the auto­hint­ing process.

After com­plet­ing this process, you have a hinted PostScript-flavored font.

Note: the Adobe PS auto­hin­ter relies on the pres­ence of stan­dard stems in the font. The Font­Lab auto-stems algo­rithm relies on the pres­ence of PS hints in the font. The Font­Lab PS auto­hin­ter ana­lyzes the out­lines only. There­fore, the the rec­om­mended chain of actions to use Adobe PS auto­hint­ing is: auto-zones, Font­Lab auto­hint, auto-stems, Adobe autohint.

4. True­Type out­lines and TT hinting

Before pro­duc­ing a TrueType-hinted font in Font­Lab Stu­dio, you should ver­ify that you have the fol­low­ing ele­ments present in the font:

  • PS align­ment zones
  • PS stan­dard stems
  • PS hints (with replace­ment hints)

These three para­me­ters will be used by FLS to auto­mat­i­cally gen­er­ate high-level TT hinting.

4.1. TT hint­ing UI elements

Pref­er­ences

When a TrueType-flavored font is gen­er­ated (includ­ing the sit­u­a­tion when the ras­ter­ized pre­views are gen­er­ated in the TrueType Hinting mode), a num­ber of set­tings can be con­trolled in Preferences. In the Pref­er­ences sec­tion Generating OpenType & TrueType, the TrueType/OpenType TT (.ttf) page con­trols how TT hint­ing is writ­ten into the gen­er­ated font.

The options Write stored TrueType native hinting and Export visual TrueType hints should be enabled.

Note: if the Autohint unhinted glyphs option is enabled, then glyphs with no high-level TT hints are being auto­hinted in the back­ground so that in the TrueType Hinting mode, you won’t see any high-level TT hints but the pre­views will be hinted. If you want to use the True­Type Hint­ing mode to reli­ably pre­view the results of the TT auto­hint­ing, dis­able this option.

[sin­glepic w=645 id=13]

The TrueType Autohinting page includes sev­eral options that give you fine-grade con­trol in how PS hints are con­verted into high-level TT hints.

The most impor­tant set­ting here is per­haps Single link attachment precision. This numer­i­cal val­ues con­trols the tol­er­ance in which FLS will match each stem width with the TT stan­dard stems (CVT entries). For exam­ple, if one of the TT stan­dard stems is 168, and if the pre­ci­sion set­ting is set to 3, then all stems that are of widths 165171 will be linked to that value, but not stems that are 164 or 172 units wide.

Please refer to the FLS man­ual for more detailed expla­na­tion of those options.

[sin­glepic w=645 id=14]

Font Info

The Font Info sec­tion TrueType-specific settings / Font smoothing con­trols the ppem sizes at which low-level TT hint­ing and stan­dard Win­dows font smooth­ing should be turned on and off.

[sin­glepic w=645 id=15]

Appli­ca­tion windows

To view and mod­ify the high-level TT hint­ing, open any glyph in a Glyph Win­dow and choose Tools / Hints & Guides / TrueType Hinting.

[sin­glepic w=645 id=16]

The TrueType Hinting tool has numer­ous sub­pan­els that you can open: the TrueType Options panel, the TrueType Program panel and the TrueType Preview panel.

Note that the TrueType Preview panel uses the sys­tem ras­ter­izer to gen­er­ate the ras­ter­ized pre­views, so the pre­view results on Mac OS X and Win­dows will dif­fer. FLS for Win­dows allows you to select the ras­ter­i­za­tion mode used to gen­er­ate the pre­views (black-and-white, stan­dard Win­dows smooth­ing or ClearType). FLS for Mac OS X does not offer this functionality.

Also keep in mind that if the font con­tains stored low-level TT hints or the option Autohint unhinted glyphs is enabled in the Pref­er­ences, the pre­views gen­er­ated by the TrueType Preview panel will be auto­hinted even if no high-level TT hints are present.

Click­ing on the icon on the TrueType Options panel opens the TT Hinting Options dia­log that allows you to con­trol the TT stan­dard stems and the TT align­ment zones. After con­vert­ing PS hint­ing to TT hint­ing, the TT stems and zones cor­re­spond to the PS stan­dard stems and align­ment zones that have been defined in Font Info, but this can be modified.

[sin­glepic w=645 id=17]

[sin­glepic w=645 id=18]

4.2. Out­line con­ver­sion and TT autohinting

Note: these next steps mod­ify the actual out­lines of your glyphs, so please be sure you have saved a backup copy of your orig­i­nal design with Post­Script outlines.

Also, please keep in mind that when FLS con­verts PS out­lines into TT out­lines, the qual­ity of con­ver­sion depends on the UPM size of the font. The smaller the UPM size, the fewer TT out­line points FLS will pro­duce. If your UPM size is very high, the num­ber of TT out­line points will be large, which may result in less sat­is­fac­tory TT auto­hint­ing results (since FLS may become “con­fused” as to which out­line points would best be con­trolled by the TT hint­ing instruc­tions). It’s also pos­si­ble to reduce the num­ber of TT out­line points after out­line con­ver­sion, using the FLS Optimize fea­ture. As a rule: if pos­si­ble, try to keep the num­ber of TT out­line points at a rea­son­able minimum.

You should per­form the fol­low­ing steps to con­vert a PS-hinted font into a TT-hinted font with True­Type outlines:

  1. Go to Preferences / Generating OpenType & TrueType / TrueType Autohinting and fine-tune the way PS hint­ing is con­verted into TT hint­ing. In par­tic­u­lar, check the Single link attachment precision value.
  2. Close all opened glyph windows.
  3. Choose Tools / Action Set.
  4. From the Contour sec­tion, add the action Curves to TrueType.
  5. From the Contour sec­tion, add the action Contour direction.
  6. Click on the added Contour direction action in the Action set list and click on the option Set direction to TrueType.
  7. If you decided to reduce the num­ber of TT out­line points after the con­ver­sion (which may result in small adjust­ments of the glyph shapes), from the Contour sec­tion, add the action Optimize. Click on the added action and in the action’s options, set Auto-alignment level to Do not align, and set Outline simplification level accord­ing to your pref­er­ence (we rec­om­mend Be very precise).
  8. From the Hints and Guidelines sec­tion, add the action Convert to instructions.[sin­glepic w=645 id=19]
  9. Choose Apply action to: All glyphs in the font or All opened fonts. Click on Run.

After com­plet­ing these steps, you have a basic TT-autohinted font. You can gen­er­ate your TrueType-flavored font now, or you can pro­ceed to fine-tuning the TT auto­hint­ing results.

4.3. Fine-tuning the TT auto­hint­ing results

To start fine-tuning the TT auto­hint­ing results:

  1. Open any glyph in the Glyph Window.
  2. Choose Tools / Hints & Guides / TrueType Hinting.
  3. In the TrueType Options panel, click on the icon so the TT Hinting Options dia­log will appear.

In this dia­log, you will find TT stems and TT zones that have been copied from the PS stan­dard stems and the PS align­ment zones. Edit­ing the TT stems may have sig­nif­i­cant impact on how con­sis­tently dif­fer­ent stems look, espe­cially in pure black-and-white ren­der­ing. For exam­ple, merg­ing some stem val­ues will result in a font in which the slightly dif­fer­ent stems will appear more consistent.

One impor­tant para­me­ter for TT stems is the ppm2 value. This value indi­cates the ppem size at which (mostly in black-and-white mode) the stems will turn from 1 pixel width to 2 pix­els width. (The ppm3 entry indi­cates the ppem size at which the stems will turn from 2 pix­els to 3 pix­els width etc.).

Low­er­ing those ppem val­ues will result in the affected stems appear heav­ier in small sizes. Rais­ing those ppem val­ues will result in the affected stems appear lighter in small sizes. For exam­ple, if you have a Medium style and a Semi­bold style in your fam­ily, and they look too sim­i­lar at small point sizes, you may choose to decrease the ppm2 and ppm3 entries in the Semi­bold style (so it will appear heav­ier), and to increase them in the Medium style.

This con­cludes the tutorial.


Article printed from font surgery: http://www.fontsurgery.com

URL to article: http://www.fontsurgery.com/fonts/font-dev/hinting/autohinting-with-fontlab-studio-5/

URLs in this post:

[1] Con­tents:: http://www.fontsurgery.comjavascript:;

[2] 1. Intro­duc­tion: #1-introduction

[3] 2. Open­ing fonts: #2-opening-fonts

[4] 3. Post­Script out­lines and PS hinting: #3-postscript-outlines-and-ps-hinting

[5] 4. True­Type out­lines and TT hinting: #4-truetype-outlines-and-tt-hinting

[6] 2. Open­ing fonts: http://www.fontsurgery.com/fonts/font-dev/hinting/autohinting-with-fontlab-studio-5/2/#2-opening-fonts

[7] 3. Post­Script out­lines and PS hinting: http://www.fontsurgery.com/fonts/font-dev/hinting/autohinting-with-fontlab-studio-5/3/#3-postscript-outlines-and-ps-hinting

[8] 4. True­Type out­lines and TT hinting: http://www.fontsurgery.com/fonts/font-dev/hinting/autohinting-with-fontlab-studio-5/4/#4-truetype-outlines-and-tt-hinting

[9] Notes on Hint­ing with Font­Lab: http://scripts.sil.org/NotesOnHintingWithFL

Copyright © 2011 blog.fontatlas.com. All rights reserved.