Tutorial: Autohinting with FontLab Studio 5

This document describes an example process of generating hinted fonts with PostScript or TrueType outlines using automatic and/or simple manual steps in FontLab Studio 5.

The production of hinted fonts can be primarily divided into three major parts:

  • reading hinting from existing native fonts
  • adding hinting to an existing .vfb document
  • writing hinting into generated native fonts

For more detailed information about hinting in FontLab Studio, please refer to the User’s Manual. We also recommend reading the article Notes on Hinting with FontLab by J. Victor Gaultney.

1. Introduction

There is a fundamental difference in how FontLab Studio (FLS) treats hinting information for PostScript-flavored glyphs and TrueType-flavored glyphs. PostScript-flavored glyphs are those used in OpenType PS (.otf), Type 1 and MultipleMaster fonts. TrueType-flavored glyphs are those used in OpenType TT (.ttf) and TrueType fonts. The native FontLab document format (.vfb) can store both kinds of glyphs.

Hinting in PostScript-flavored glyphs (PS hinting) exists on one level only, so no translation or conversion is necessary. FontLab Studio can losslessly read and write PS hinting, it can also losslessly modify PS hinting as well as generate it. More precisely: FLS supports Type 1 hints natively. When reading OpenType PS (.otf) fonts, FLS converts CFF hinting into Type 1 hinting.

Hinting in TrueType-flavored glyphs (TT hinting) exists on two levels:

  • the low-level TT hinting (native) — assembly code in the TrueType instructions language, compiled into binary form, stored in OpenType TT (.ttf) and TrueType fonts, as well as optionally stored in the FontLab .vfb documents.
  • the high-level TT hinting (visual) — visual instructions in FontLab’s own TTH language, stored in the FontLab .vfb documents.

FontLab Studio can read low-level TT hinting. FLS can also write the stored low-level TT hinting but only for glyphs that had not been modified. If you modify a glyph, the stored low-level TT hinting will be removed.

FontLab Studio can also convert PS hinting into high-level TT hinting, modify the high-level TT hinting, and convert (compile) the high-level TT hinting into the low-level TT hinting. Note that FLS cannot convert (decompile) the low-level TT hinting into the high-level TT hinting.

2. Opening fonts

If you’d like to store the low-level TT hinting when opening a TrueType-flavored font, make sure the Preferences setting Opening OpenType & TrueType / TrueType/OpenType TT (.ttf) / Store TrueType native hinting is enabled. If disabled, the TrueType assembly instructions will not be read from the font. If enabled, they will be read, stored in the .vfb document and written back into a new generated .ttf font — but only for the glyphs which have not been modified within FLS.

A brown “T” mark in the lower-right corner of a glyph cell indicates that low-level TT hints are present in the glyph (either read from the original TrueType-flavored font, or generated using FontLab Studio’s TrueType Hinting tool).

fls5hinting_01_PreferencesOpeningTT

When opening PostScript-flavored fonts, their hinting is always read from the font and stored in the .vfb document.

3. PostScript outlines and PS hinting

3.1. PS hinting UI elements

Preferences

The Preferences dialog box controls some vital aspects of how PostScript-flavored fonts (Type 1 and OpenType PS) are generated. In Preferences / Generating Type 1, the option Autohint unhinted glyphs allows you to automatically autohint the font when it is generated even if you did not perform any specific autohinting tasks. If a glyph does not contain any PS hints and this option is enabled, FLS will automatically generate hints for that glyph.

If you wish to control your hinting manually and there are good reasons why you did not hint some glyphs, disable this option. (This will also allow you to generate PostScript-flavored fonts without hinting if you remove the PS hints from all the glyphs).

Note that if the Autohint unhinted glyphs option is enabled, the rasterized previews in the Type 1 Hinting mode (and in its Preview panel) for glyphs with no PS hints present will be generated after the glyphs have been autohinted in the background, so you will see no hints but a PS-hinted preview. So if you want to reliably preview the rasterization of your actual PS hints, you should disable this option.

fls5hinting_02_PreferencesGeneratingPS

On the Generating Type 1 / Type 1 autohinting page, disable the option Remove all existing hints before autohinting if you wish FLS to add automatically generated hints to existing PS hints.

fls5hinting_03_PreferencesGeneratingPSHinting

Application windows

The most commonly used design source for fonts are fonts (or .vfb documents) with PostScript outlines. An example of such font is Myriad Roman:

fls5hinting_04_FontWindow

When a PostScript-flavored font is open, small green “H” marks in the lower-left corner of the Font Window’s glyph cell will indicate glyphs in which PS replacement hints are present. Glyphs that have PS hints but have no replacements hints are not indicated in any particular way.

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

fls5hinting_05_GlyphWindow

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

fls5hinting_06_PSHintingWindow

The Type 1 Hinting tool allows you to rasterized a preview of how the glyph will be rendered in a variety of rasterizers. Click on the Preview panel button in the Type 1 Hinting toolbar to open the Type 1 Hinting Preview panel. A click on the little rectangle in the top-right corner of the panel allows you to select the rasterizer.

fls5hinting_07_PSHintingPreview

Note that FontLab Studio 5.0.4 on Mac OS X has a bug in how it integrates with the built-in Adobe rasterizers, so FLS may crash or display the wrong rasterized images when any of the Adobe rasterizers is selected. This bug does not affect the quality of hinting written into the font. The Windows version 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 rasterization will be autohinted even if the glyph window does not show any PS hints.

Font Info

While the hints are controlled on the glyph level, there is a number of relevant font-wide hinting settings. 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, controls the primary PS alignments zones (that are typically located above the baseline) as well as the secondary PS alignments zones (typically located below the baseline).

The PS alignment zones will be used in PS hinting, and they will also be converted into TT alignment zones.

By clicking on Auto zones, FLS will automatically rebuild the PS alignment zones for the font. It will do so by analyzing the bounding boxes of a hardcoded list of uppercase and lowercase English letters. If your font contains multiple alphabets (scripts), or if it contains numerals or small caps that are of obviously different height than uppercase or lowercase letters, you should add more PS alignment zones that will control the overshoot suppression.

fls5hinting_08_FontInfoPSHintingZones

The second page, Type 1 hinting: standard stems, controls the vertical PS standard stems that correspond to x-direction hinting, as well as the horizontal PS standard stems that correspond to y-direction hinting.

The PS standard stems will be used in PS hinting, and they will also be converted into TT standard stems which are stored in the CVT table.

Clicking on Auto stems will automatically build a list of PS standard stems found in the font. This will be done by analyzing the PS hint values found in the font — which means that the font needs to have hinting for Auto stems to work.

Also note that quite often, FLS will generate more PS standard stems than really necessary. For example, in Myriad Roman, the original V stem values are 88 92, and the original H stem values are 67 73. After Auto stems, V stem values will be 88 70 97 and H stem values will be 73 55 68. In some cases, stem values will be quite close to each other, and you may want to unify them.

Note: When converting PS hinting into TT hinting, you can control the Single link attachment precision with which FLS will match each stem width with the TT standard stems. If you create fewer standard stems and increase the precision, the stems in the TT font will appear more uniform. If you create more standard stems and decrease the precision, the stems in the TT font will appear more varied.

fls5hinting_09_FontInfoPSHintingStems

The Type 1 hinting: global hinting parameters page only affects PS hinting. It does not affect TT hinting. Please refer to the FLS manual and the Type 1 font format specification for more information about those parameters.

fls5hinting_10_FontInfoPSHintingExtra

The Type 1 autohinting page defines the minimal and maximal distances (in font units) between outline for which PS hints will be automatically generated if glyphs are autohinted. For very thin fonts, lowering the Min width values may be a good idea. For very bold fonts, raising the Max width values may be useful.

fls5hinting_11_FontInfoPSAutohinting

3.2. PS autohinting

If your font already has PS hints, PS standard stems and alignment zones defined, you can skip this step.

If your font does not have PS hints, you should perform the following steps to obtain PS hinting automatically:

    1. Go to Font Info / Hinting Settings and click on Auto zones.
    2. Add and revise the alignment zones as needed.
    3. For each font that has stems that are thinner than 20 units or thicker than 250 units (default values), navigate to Font Info / Hinting Settings / T1 Autohinting and set the Min width or Max width values to match the thickness of your thinnest/thickest stems. Click on OK.
    4. Choose Tools / Action Set.
    5. From the Hints and Guidelines section, add the action Autohint to your action set.
    6. If you’d like to only generate y-direction hints (i.e. horizontal hints) because you plan to generate a TrueType-flavored font that does not need to be hinted in the x-direction (for example because the font will only work in ClearType, or the font is italic and the vertical 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 section, add the action Autoreplace to your action set.

fls5hinting_12_ActionSetT1Autohinting

  1. Choose Apply action to: All glyphs in the font or All opened fonts. Click on Run.
  2. Go to File / Font Info / Hinting Settings / Standard stems (T1 hinting) and click on Auto stems.
  3. Add, revise and merge the PS standard stems as needed.
  4. Click on OK.
  5. If you wish to use the Adobe PS autohinter, from the Macros toolbar choose the Outlines subgroup and pick the Auto-hint macro. Ctrl-click on the Run button to view the macro UI, set the desired parameters and run the autohinting process.

After completing this process, you have a hinted PostScript-flavored font.

Note: the Adobe PS autohinter relies on the presence of standard stems in the font. The FontLab auto-stems algorithm relies on the presence of PS hints in the font. The FontLab PS autohinter analyzes the outlines only. Therefore, the the recommended chain of actions to use Adobe PS autohinting is: auto-zones, FontLab autohint, auto-stems, Adobe autohint.

4. TrueType outlines and TT hinting

Before producing a TrueType-hinted font in FontLab Studio, you should verify that you have the following elements present in the font:

  • PS alignment zones
  • PS standard stems
  • PS hints (with replacement hints)

These three parameters will be used by FLS to automatically generate high-level TT hinting.

4.1. TT hinting UI elements

Preferences

When a TrueType-flavored font is generated (including the situation when the rasterized previews are generated in the TrueType Hinting mode), a number of settings can be controlled in Preferences. In the Preferences section Generating OpenType & TrueType, the TrueType/OpenType TT (.ttf) page controls how TT hinting is written into the generated 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 autohinted in the background so that in the TrueType Hinting mode, you won’t see any high-level TT hints but the previews will be hinted. If you want to use the TrueType Hinting mode to reliably preview the results of the TT autohinting, disable this option.

fls5hinting_13_PreferencesGeneratingTT

The TrueType Autohinting page includes several options that give you fine-grade control in how PS hints are converted into high-level TT hints.

The most important setting here is perhaps Single link attachment precision. This numerical values controls the tolerance in which FLS will match each stem width with the TT standard stems (CVT entries). For example, if one of the TT standard stems is 168, and if the precision setting 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 manual for more detailed explanation of those options.

fls5hinting_14_PreferencesTTAutohinting

Font Info

The Font Info section TrueType-specific settings / Font smoothing controls the ppem sizes at which low-level TT hinting and standard Windows font smoothing should be turned on and off.

fls5hinting_15_FontInfoTTSmoothingGasp

Application windows

To view and modify the high-level TT hinting, open any glyph in a Glyph Window and choose Tools / Hints & Guides / TrueType Hinting.

fls5hinting_16_TTHintingWindow

The TrueType Hinting tool has numerous subpanels 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 system rasterizer to generate the rasterized previews, so the preview results on Mac OS X and Windows will differ. FLS for Windows allows you to select the rasterization mode used to generate the previews (black-and-white, standard Windows smoothing or ClearType). FLS for Mac OS X does not offer this functionality.

Also keep in mind that if the font contains stored low-level TT hints or the option Autohint unhinted glyphs is enabled in the Preferences, the previews generated by the TrueType Preview panel will be autohinted even if no high-level TT hints are present.

Clicking on the icon on the TrueType Options panel opens the TT Hinting Options dialog that allows you to control the TT standard stems and the TT alignment zones. After converting PS hinting to TT hinting, the TT stems and zones correspond to the PS standard stems and alignment zones that have been defined in Font Info, but this can be modified.

fls5hinting_17_TTHintingStems

fls5hinting_18_TTHintingZones

4.2. Outline conversion and TT autohinting

Note: these next steps modify the actual outlines of your glyphs, so please be sure you have saved a backup copy of your original design with PostScript outlines.

Also, please keep in mind that when FLS converts PS outlines into TT outlines, the quality of conversion depends on the UPM size of the font. The smaller the UPM size, the fewer TT outline points FLS will produce. If your UPM size is very high, the number of TT outline points will be large, which may result in less satisfactory TT autohinting results (since FLS may become “confused” as to which outline points would best be controlled by the TT hinting instructions). It’s also possible to reduce the number of TT outline points after outline conversion, using the FLS Optimize feature. As a rule: if possible, try to keep the number of TT outline points at a reasonable minimum.

You should perform the following steps to convert a PS-hinted font into a TT-hinted font with TrueType outlines:

  1. Go to Preferences / Generating OpenType & TrueType / TrueType Autohinting and fine-tune the way PS hinting is converted into TT hinting. In particular, check the Single link attachment precision value.
  2. Close all opened glyph windows.
  3. Choose Tools / Action Set.
  4. From the Contour section, add the action Curves to TrueType.
  5. From the Contour section, 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 number of TT outline points after the conversion (which may result in small adjustments of the glyph shapes), from the Contour section, 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 according to your preference (we recommend Be very precise).
  8. From the Hints and Guidelines section, add the action Convert to instructions.
  9. Choose Apply action to: All glyphs in the font or All opened fonts. Click on Run.

fls5hinting_19_ActionSetTTAutohinting

After completing these steps, you have a basic TT-autohinted font. You can generate your TrueType-flavored font now, or you can proceed to fine-tuning the TT autohinting results.

4.3. Fine-tuning the TT autohinting results

To start fine-tuning the TT autohinting 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 dialog will appear.

In this dialog, you will find TT stems and TT zones that have been copied from the PS standard stems and the PS alignment zones. Editing the TT stems may have significant impact on how consistently different stems look, especially in pure black-and-white rendering. For example, merging some stem values will result in a font in which the slightly different stems will appear more consistent.

One important parameter for TT stems is the ppm2 value. This value indicates the ppem size at which (mostly in black-and-white mode) the stems will turn from 1 pixel width to 2 pixels width. (The ppm3 entry indicates the ppem size at which the stems will turn from 2 pixels to 3 pixels width etc.).

Lowering those ppem values will result in the affected stems appear heavier in small sizes. Raising those ppem values will result in the affected stems appear lighter in small sizes. For example, if you have a Medium style and a Semibold style in your family, and they look too similar at small point sizes, you may choose to decrease the ppm2 and ppm3 entries in the Semibold style (so it will appear heavier), and to increase them in the Medium style.

This concludes the tutorial.

Tags: , , , , , , , , , , , , , , , ,

Trackback from your site.

Adam Twardoch

Adam Twardoch is Director of Products at FontLab, and a font consultant specializing in font technology, multilingual typography, CSS webfonts, Unicode and OpenType. He also works as the glyph wrangler at MyFonts. He regularly teaches workshops in font creation and is a board member of Association Typographique Internationale (ATypI). Originally from Poland, he lives and works in Berlin.

Add a comment