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:

  1. Open your font in FontForge.
  2. Double-click the glyph you want to modify to open the Glyph View window.
  3. In the top menu, navigate to Hints > Edit Instructions....
  4. A text window will appear displaying the TrueType assembly mnemonics (such as SVTCA[y], MDAP[rnd], and ALIGNPTS) assigned to that glyph.
  5. Modify or write your bytecode instructions using standard TrueType instruction set mnemonics.
  6. 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.

  1. In either the Font View or Glyph View, open the Hints menu.
  2. Select Edit 'fpgm' table... to edit the global function definitions.
  3. Select Edit 'prep' table... to modify instructions executed whenever the font size or transformation changes.
  4. 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:

  1. Open a glyph in the Glyph View.
  2. Select Hints > Debug....
  3. Specify the point size and rasterization settings (such as grayscale or monochrome) you wish to test.
  4. 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:

  1. Navigate to File > Generate Fonts....
  2. Choose TrueType as the export format.
  3. Click the Options button in the file dialog.
  4. Ensure the TrueType Hints option is checked.
  5. Uncheck any options that automatically strip or regenerate hints upon export.
  6. Click Generate to save your updated TrueType font.