Registry / serialization / fonttools

fonttools

JSON →
library4.62.1pypypi✓ verified 49d ago

fonttools is a Python library for manipulating font files, currently at version 4.62.1, with a release cadence of approximately every few months.

serialization
pip install fonttools
Install & Compatibility
Where this runs
tested against v4.63.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.925 runs
installs and imports cleanly · install 0.0s · import 0.093s · 39.6MB
glibc
py 3.103.925 runs
installs and imports cleanly · install 2.5s · import 0.082s · 43MB
40MB installed
● package 40MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TTFont
from fontTools.ttLib import TTFont
Ensure correct import path to avoid ImportError.

This script demonstrates loading a TrueType font, accessing its tables, and saving changes.

from fontTools.ttLib import TTFont # Load a TrueType font file font = TTFont('path_to_font.ttf') # Access font tables print(font.keys()) # Save changes to the font font.save('path_to_new_font.ttf')
pyftsubset --version
Debug
Known issues
breakingfonttools 4.60.0 dropped support for Python 3.9.
fix
Upgrade to Python 3.10 or later.
affects: >=4.60.0
deprecatedThe 'fonttools[ufo]' extra now uses 'fontTools.misc.filesystem' instead of 'pyfilesystem2'.
fix
Update your imports to 'from fontTools.misc.filesystem import ...'.
affects: >=4.59.0
gotchaEnsure 'setuptools' is installed to avoid build errors during installation.
fix
Install 'setuptools' using 'pip install setuptools'.
affects: All versions
gotchaThe 'TTFont' constructor received a path to a font file that does not exist. Ensure the specified font file path is correct and the file is accessible.
fix
Verify that the path provided to 'TTFont' (e.g., 'path_to_font.ttf') correctly points to an existing font file on your system.
affects: All versions
gotchaThe TTFont() constructor failed because the specified font file could not be found.
fix
Ensure the font file specified in the TTFont() constructor (e.g., 'path_to_font.ttf') exists at the given path and that the application has the necessary read permissions.
affects: All versions
Errors
Common errors & fixes
ImportError: No module named fontTools
The 'fonttools' library is not installed in the Python environment being used, or the Python environment is not correctly configured to find it.
fix
pip install fonttools
AttributeError: 'tuple' object has no attribute 'minimum'
When calling 'fontTools.varLib.instancer.instantiateSTAT' or related variable font functions, axis limits are provided as plain tuples (e.g., '(500, 900)'), but the functions expect 'AxisTriple' objects.
fix
from fontTools.varLib.instancer import AxisTriple; instantiateSTAT(font, {"wght":AxisTriple(500,500,900)})
ImportError: No module named brotli
The 'brotli' compression library, a required dependency for processing WOFF2 font files, is not installed in the Python environment.
fix
pip install brotli
SyntaxError: invalid syntax (when trying to run 'ttx' command directly in Python script)
The 'ttx' command is a command-line utility provided by 'fonttools' and cannot be executed directly as a Python statement within a script; it must be run via the operating system's shell.
fix
import os; os.system("ttx /path/to/font.ttf") OR import subprocess; subprocess.run(["ttx", "/path/to/font.ttf"])
Upgrade
Version history
4.63.0latest on PyPI
Audit
Dependencies
setuptoolsrequiredRequired for building and installing fonttools
Agent activity
12 hits · last 30 days
seranking-bot
4
ahrefsbot
3
node
2
Amazon
1
amazonbot
1
Resources