Export Kerning Data from FontForge to Text
FontForge allows you to export kerning information into plain text formats, enabling designers to inspect, backup, or transfer metric data between type design applications. This guide explains how to extract kerning pairs and kerning classes from FontForge into Adobe Feature files (.fea), Adobe Font Metrics files (.afm), or custom delimited text files using Python scripting.
Method 1: Exporting as an Adobe Feature File (.fea)
The most comprehensive way to export modern OpenType kerning pairs and classes into a plain text format is via an Adobe OpenType Feature file.
- Open your font file in FontForge.
- Go to File > Merge Feature Info... or directly open Element > Font Info.
- In the Font Info window, navigate to Lookups on the left menu, then select the GPOS (Glyph Positioning) tab.
- Select your kerning lookup table (usually labeled
kernorHorizontal Kerning). - Click Save Feature File... on the right-hand panel.
- Choose a file name with the
.feaextension and click Save.
The resulting .fea file is a plain text file readable by
any standard text editor. It contains definitions of all your kerning
pairs, class-to-class kerning groups, and value offsets formatted
according to the Adobe OpenType feature specification.
Method 2: Exporting as an AFM (Adobe Font Metrics) File
If you only need traditional pair-wise kerning without complex OpenType classes, the AFM format stores kerning values in clean, human-readable ASCII text.
- Open your font in FontForge.
- Go to File > Generate Fonts....
- Choose PostScript Type 1 or OpenType (CFF) from the format dropdown.
- Click the Options button in the dialog.
- Check the box for AFM (Adobe Font Metrics) to ensure an AFM file is generated alongside the font file.
- Click Generate.
Open the generated .afm file in a text editor and locate
the StartKernPairs section. Each kerning pair will be
listed in a clear format:
KPX glyph1 glyph2 offset
Method 3: Exporting to CSV or TXT via Python Scripting
For tailored exports directly to plain text or spreadsheet-compatible formats like CSV, you can run a script via FontForge's built-in Python interpreter.
- Open your font in FontForge.
- Go to File > Execute Script....
- Paste the following script to export all flat pair kerning to a comma-separated text file:
import fontforge
font = fontforge.activeFont()
output_path = "kerning_export.csv"
with open(output_path, "w") as f:
f.write("First,Second,Offset\n")
for glyph in font.glyphs():
subtable_list = glyph.getPosSub("*")
for entry in subtable_list:
# Check for pair kerning types
if entry[1] == "Pair":
f.write(f"{glyph.glyphname},{entry[2]},{entry[5]}\n")
print("Kerning data exported successfully.")- Click OK.
FontForge will generate a kerning_export.csv file in
your working directory containing all detected pairs in a plain, easily
readable row-by-row structure.