fonttools
Manipulate font files
TLDR
Subset a TTF font file to the Basic Latin Unicode block
Display help
SYNOPSIS
The `fonttools` project provides a collection of specialized command-line utilities rather than a single dispatcher command. The most commonly used tools include ttx (for converting fonts to/from XML), pyftsubset (for subsetting fonts), pyftmerge (for merging fonts), pyftcompile (for compiling fonts), pyftdecompile (for decompiling fonts), pyftinfo (for displaying font information), and pyftstrip (for stripping data from fonts).
General syntax for many `fonttools` commands:
command_name [options] input_file(s) [output_file]
Example for `ttx` (decompiling/compiling fonts to/from XML):
ttx [options] input.ttf
ttx [options] input.ttx
PARAMETERS
-h, --help
Display a help message and exit for the specific command.
-v, --verbose
Increase verbosity of output during execution.
-o FILE, --output FILE
Specify the output file name or directory. If omitted, a default name is often used.
-i FILE, --input FILE
Specify the input font file. This is often a positional argument rather than an option.
--version
Show program's version number and exit.
-t TAG
(Specific to `ttx`) Dump only the specified font table(s) to XML.
--unicodes RANGES
(Specific to `pyftsubset`) Define Unicode code point ranges to include in the subsetted font (e.g., 'U+0000-007F').
DESCRIPTION
`fonttools` is a powerful, open-source Python library and suite of command-line tools for manipulating font files. It provides deep access to the internal structures of OpenType and TrueType fonts, allowing users and developers to inspect, modify, and create font data. Key capabilities include decompiling fonts into an XML representation (TTX format) for human readability and editing, and then compiling them back into binary font files. It also supports subsetting fonts (reducing their size by removing unused glyphs or features), merging fonts, converting between different font formats (e.g., WOFF, WOFF2), and inspecting font metadata. Widely used in font development, web typography, and internationalization workflows, `fonttools` is an essential utility for anyone working with digital fonts.
CAVEATS
While powerful, `fonttools` operates at a low level of font data. Incorrect modifications to TTX files or inappropriate use of subsetting options can easily corrupt font files, rendering them unusable or causing rendering issues. Users should always back up original fonts before making changes. Advanced features often require a good understanding of OpenType and TrueType font specifications.
<B>PYTHON LIBRARY USAGE</B>
Beyond its command-line tools, `fonttools` is primarily a Python library. It can be imported and used directly in Python scripts to programmatically manipulate font objects, tables, and glyphs, offering granular control for complex font processing tasks. This makes it highly versatile for custom automation and integration into larger systems.
<B>FONT FORMATS SUPPORTED</B>
`fonttools` natively supports a wide array of font formats including TrueType (TTF), OpenType (OTF with CFF or TrueType outlines), WOFF (Web Open Font Format), WOFF2, SFNT-wrapped EOT, and SVG fonts. It provides robust mechanisms for parsing, modifying, and writing these formats, ensuring broad compatibility across different font ecosystems.
HISTORY
The `fonttools` project was originally started by Just van Rossum in 1999, making it one of the earliest and most mature Python libraries for font manipulation. It was developed to provide a robust and flexible way to work with OpenType and TrueType fonts programmatically. Over the years, it has gained significant contributions from the Google Fonts team and the wider open-source community, becoming an essential component in many font-related pipelines, including Google Fonts, Adobe, and various web development tools. Its core functionality, particularly `ttx` (TrueType eXchange), revolutionized how font developers could inspect and modify fonts using a human-readable XML format.
SEE ALSO
ttx(1) (Part of the fonttools suite, for XML conversion), pyftsubset(1) (Part of the fonttools suite, for font subsetting), pyftmerge(1) (Part of the fonttools suite, for merging fonts), otfinfo(1) (Utility for printing OpenType font information), sfnttool (Java-based tool for manipulating SFNT fonts, often used for WOFF conversion), fontforge (Powerful graphical font editor, also has scripting capabilities)