Export Font Tables to XML or Text in FontForge

This guide explains how to extract font tables as raw text or XML using FontForge. While FontForge is primarily an outline editor, you can export font table data into human-readable formats by saving the font as a native Spline Font Database (SFD) text file, exporting OpenType tables as feature text files, or using FontForge's built-in Python scripting environment to dump raw table bytes directly to disk.

Method 1: Export Complete Font Data as Text (.sfd)

FontForge’s native file format is the Spline Font Database (.sfd), which stores every font table, glyph outline, metadata field, and metric in plain, human-readable ASCII text.

  1. Open your font in FontForge via File > Open.
  2. Navigate to File > Save As....
  3. In the file format dropdown, select **Spline Font Database (*.sfd)**.
  4. Choose a destination and click Save.
  5. Open the resulting .sfd file in any text editor to view or parse raw table definitions, such as the head, hhea, OS/2, and lookup tables.

Method 2: Export OpenType Layout Tables as Feature Text (.fea)

If you need layout tables such as GSUB (substitutions) or GPOS (positioning) in an editable text format, you can export them using Adobe Feature File syntax.

  1. Go to Element > Font Info (or press Ctrl+Shift+F / Cmd+Shift+F).
  2. Select Lookups from the left-hand sidebar.
  3. Click the Save Feature File... button at the bottom of the window.
  4. Choose a file name ending in .fea and click Save.

The generated file contains the raw OpenType layout table rules represented as standardized plain text.

Method 3: Export Raw Table Data via FontForge Python

FontForge includes an integrated Python engine capable of reading any binary TrueType or OpenType table using the getTableData() method. You can dump tables as raw binary, hex text, or XML.

  1. Open your font in FontForge.
  2. Navigate to File > Execute Script....
  3. Select Python as the scripting language.
  4. Enter the following script to dump a specific table (e.g., the name table or OS/2 table) as hex-encoded text:
import fontforge

# Reference the active font
font = fontforge.activeFont()

# Specify the 4-character table tag you want to extract
table_tag = "OS/2"

try:
    # Retrieve the raw binary data
    raw_data = font.getTableData(table_tag)
    
    # Save as plain hex text
    with open(f"{font.fontname}_{table_tag}.txt", "w") as f:
        f.write(raw_data.hex())
        
    print(f"Table '{table_tag}' successfully exported to text.")
except Exception as e:
    print(f"Error extracting table: {e}")
  1. Click OK to run the script. The output file will be written to your working directory.

Method 4: Export Tables as Raw XML Using FontTools (TTX)

FontForge does not contain an internal native XML serializer for all binary tables. To convert raw font tables directly into formatted XML, run the FontTools ttx utility alongside FontForge:

  1. Open your terminal or command prompt.

  2. Use FontTools to dump all tables to an XML file:

    ttx -o font_tables.xml input_font.ttf
  3. To extract only a specific table as raw XML, pass the -t flag:

    ttx -t name -t "OS/2" -o specific_tables.xml input_font.ttf