ttx
Convert font files to XML
SYNOPSIS
ttx [options] <fontfile_or_xmlfile>
PARAMETERS
-h, --help
Display a help message and exit.
-V, --verbose
Increase the verbosity of the output, showing more details about the conversion process.
-q, --quiet
Decrease the verbosity of the output, suppressing most messages.
-o <file>, --output-file <file>
Specify the name of the output file. By default, ttx generates a file name based on the input.
-d <dir>, --output-dir <dir>
Specify the directory where the output file(s) should be written.
-f, --force
Force overwriting of an existing output file without prompting.
-z <table>, --sfnt-tables <table>
Export only the specified SFNT tables. This option can be used multiple times to include several tables (e.g., -z glyf -z head).
-x <table>, --exclude-sfnt-tables <table>
Exclude specified SFNT tables from export. This option can be used multiple times.
-i, --import
Explicitly convert a TTX (XML) file back into a binary font file. This is the default action if the input file has a .ttx extension.
-e, --export
Explicitly convert a binary font file into a TTX (XML) file. This is the default action if the input file is not .ttx.
-s, --split-tables
Split individual font tables into separate TTX XML files, one for each table, rather than a single large XML file.
--flavor <flavour>
When importing, specify the output SFNT flavor, such as WOFF or WOFF2.
DESCRIPTION
ttx is a command-line utility from the FontTools library, primarily used for converting font files between their binary formats (like TrueType, OpenType, WOFF) and an XML-based representation. This XML format, also known as TTX, makes it significantly easier for developers and font designers to inspect, modify, and manipulate font data using standard text editors and XML tools. It supports various font tables, including glyph outlines, kerning, hinting, and metadata.
The conversion process is fully reversible, allowing users to convert an XML file back into a binary font file. This capability is invaluable for debugging font issues, automating font modifications, and integrating font development into version control systems. ttx is a fundamental tool for anyone working deeply with font specifications and development, providing a powerful bridge between human-readable text and complex binary font data.
CAVEATS
ttx relies on the FontTools Python library, meaning it must be installed (typically via pip) and is not a core utility found on all Linux systems by default.
Converting large font files can generate extremely large XML output files, potentially consuming significant disk space and memory during both export and import operations. Modifying the generated TTX XML requires a thorough understanding of OpenType and TrueType font specifications to ensure that the font remains valid and functional after re-import.
USAGE MODES
ttx operates in two primary modes based on the input file type: if the input is a binary font file (e.g., .ttf, .otf), it defaults to exporting it to TTX (XML). If the input is a TTX (.ttx) XML file, it defaults to importing it back into a binary font. These modes can also be explicitly set using the -e and -i options.
XML STRUCTURE
The generated TTX XML closely mirrors the internal structure of TrueType and OpenType fonts. Each major font table (e.g., <glyf>, <cmap>, <head>, <name>) is represented as a distinct XML element, containing detailed and human-readable information about the font's data, including glyph definitions, character mappings, and metadata.
HISTORY
ttx is a fundamental component of the FontTools library, an open-source Python library for manipulating fonts. FontTools was originally developed by Just van Rossum in 1999 and has since grown into an essential toolkit for font developers, type designers, and anyone working with low-level font data. The ttx command specifically provides the crucial functionality of converting fonts to and from an XML representation, making them accessible for text-based editing, version control, and automated processing.
Its development has closely tracked the evolution of font technologies, including robust support for OpenType variations and WOFF formats, establishing ttx as a de-facto standard for font introspection and modification within the open-source typography community.


