FontTools

Python library for manipulating TrueType, OpenType, and other font formats

Library
PyPI
v4.63.0
5,207stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
95/100Excellent
Development Activity96
Maintenance96
Community88
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
83/100Excellent
Architecture86
Code Quality88
Innovation85
Learning Curve72

FontTools is a Python library for reading, manipulating, and writing font files, supporting TrueType, OpenType, AFM, and to some extent Type 1 and Mac-specific formats. It includes the TTX tool, which converts binary TrueType/OpenType fonts into a readable XML text representation and back, making it possible to diff, script, and hand-edit font internals like glyph outlines, hinting, and OpenType layout tables.

Beyond format conversion, the library provides submodules for variable font construction (varLib), font merging and subsetting, UFO/designspace source handling, pen-based glyph drawing abstractions, and Unicode/OpenType layout utilities. It is the foundational library underneath much of the modern font-tooling ecosystem, used by font foundries, type designers, and other libraries (such as fontmake and glyphsLib) to build production font pipelines in Python.

What You Get

  • A TTFont object model (ttLib) for parsing, editing, and writing TrueType/OpenType font binaries
  • The ttx command-line tool to convert fonts to/from an XML text representation
  • varLib for building and manipulating variable fonts (OpenType Font Variations)
  • Subsetting (subset) and merging (merge) modules for producing smaller or combined font files
  • Pen-based glyph drawing abstractions (pens), UFO/designspace source support (ufoLib, designspaceLib), and OpenType feature compilation (feaLib)

Common Use Cases

  • Building production font pipelines that generate static or variable fonts from design sources (used by tools like fontmake)
  • Subsetting web fonts to reduce file size by keeping only the glyphs a page actually uses
  • Inspecting or hand-editing OpenType layout tables (kerning, ligatures, variable axes) via the TTX XML round-trip
  • Writing custom font QA/validation scripts that check glyph coverage, metrics, or table structure programmatically

Under The Hood

Architecture: The library is organized under Lib/fontTools/ into focused subpackages — ttLib (the core TTFont binary reader/writer and per-table classes), varLib (variable font construction/merging), subset and merge (font reduction/combination), pens (a shared glyph-outline drawing protocol used across the codebase), feaLib (OpenType feature language compiler), and ufoLib/designspaceLib (UFO source format support) — each independently importable, letting consumers pull in only the pieces they need.

Tech Stack: Pure Python 3.10+ with no required external dependencies beyond the standard library; optional extras (numpy for faster math in some modules, brotli for WOFF2, lz4, zopfli) are pulled in only when relevant features are used. Tooling includes mypy for type checking and black/tox for formatting and multi-version test matrices.

Code Quality: The extensive Tests/ directory mirrors the Lib/fontTools/ structure with per-subpackage test suites and numerous binary/XML fixtures, run across supported Python versions via tox.ini; mypy.ini enforces static typing on parts of the codebase, and the project has been continuously maintained since 1999 with active, frequent commits.

API Design: Core object access follows a consistent pattern — TTFont(path) then table access via dict-like font['glyf'] / font['GSUB'] syntax — while higher-level tasks (subsetting, variable font building, feature compilation) are exposed as dedicated modules with their own documented entry points. The TTX round-trip (font.saveXML() / TTFont(xml_path)) gives a text-diffable escape hatch into binary font internals without requiring users to understand the raw binary format.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search