How to Edit TrueType Instructions in FontForge
This guide explains how to view, modify, and compile TrueType
bytecode instructions (hinting) directly within FontForge. FontForge
provides built-in tools to edit both glyph-level instructions and global
font programs (fpgm and prep tables), allowing
you to precisely control how glyphs are rendered on low-resolution
screens.
Accessing Glyph-Level Bytecode
To edit instructions associated with an individual glyph:
- Open your font in FontForge.
- Double-click the glyph you want to modify to open the Glyph View window.
- In the top menu, navigate to Hints > Edit Instructions....
- A text window will appear displaying the TrueType assembly mnemonics
(such as
SVTCA[y],MDAP[rnd], andALIGNPTS) assigned to that glyph. - Modify or write your bytecode instructions using standard TrueType instruction set mnemonics.
- Click OK to compile the bytecode back into the glyph. If there is a syntax error, FontForge will alert you to the problematic line.
Editing Global Tables
(fpgm and prep)
TrueType fonts often rely on global routines and pre-programs stored
in the Font Program (fpgm) and Control Value Program
(prep) tables.
- In either the Font View or Glyph View, open the Hints menu.
- Select Edit 'fpgm' table... to edit the global function definitions.
- Select Edit 'prep' table... to modify instructions executed whenever the font size or transformation changes.
- Make your modifications in the assembly editor window and click OK to apply the changes.
Debugging TrueType Instructions
FontForge includes an interactive debugger to inspect instruction execution step-by-step:
- Open a glyph in the Glyph View.
- Select Hints > Debug....
- Specify the point size and rasterization settings (such as grayscale or monochrome) you wish to test.
- Use the debugger window to step through instructions one line at a time, watching point coordinates and the graphics state update in real time.
Generating the Font with Preserved Instructions
To ensure your custom bytecode is saved into the exported file:
- Navigate to File > Generate Fonts....
- Choose TrueType as the export format.
- Click the Options button in the file dialog.
- Ensure the TrueType Hints option is checked.
- Uncheck any options that automatically strip or regenerate hints upon export.
- Click Generate to save your updated TrueType font.