—fontTools Documentation—
About
fontTools is a family of libraries and utilities for manipulating fonts in Python.
The project is licensed under the MIT open-source license, allowing free usage.
Installation
Note
fontTools requires Python 3.8 or later.
To install fontTools, use pip:
pip install fonttools
Utilities
fontTools includes the following command-line utilities:
pyftmerge
: Tool for merging fonts; seefontTools.merge
pyftsubset
: Tool for subsetting fonts; seefontTools.subset
ttx
: Tool for converting between OTF and XML representation; seefontTools.ttx
fonttools
: Meta-tool for accessing other fontTools components.
For fonttools
, you can use subcommands like:
cffLib.width
: Calculate optimum defaultWidthX/nominalWidthX valuescu2qu
: Convert a UFO font from cubic to quadratic curvesfeaLib
: Add features from a feature file (.fea) into a OTF fontmerge
: Merge multiple fonts into onesubset
: OpenType font subsetter and optimizerttx
: Convert OpenType fonts to XML and backvarLib
: Build a variable font from a designspace file and mastersvarLib.instancer
: Partially instantiate a variable fontvoltLib.voltToFea
: Convert MS VOLT to AFDKO feature files.
Libraries
The main library for font engineering is fontTools.ttLib.ttFont
, which handles TrueType/OpenType fonts. Other libraries include:
fontTools.afmLib
: Read and write AFM filesfontTools.agl
: Access the Adobe Glyph ListfontTools.cffLib
: Tools for Adobe CFF fontsfontTools.colorLib
: Handle colors in CPAL/COLR fontsfontTools.cu2qu
: Convert cubic to quadratic curvesfontTools.designspaceLib
: Read and write designspace filesfontTools.encodings
: Support for font-related encodingsfontTools.feaLib
: Read and write AFDKO feature filesfontTools.fontBuilder
: Construct TTF/OTF fonts from scratchfontTools.merge
: Tools for merging font filesfontTools.subset
: OpenType font subsetting and optimizationfontTools.svgLib.path
: Draw SVG paths onto glyphsfontTools.ttLib
: Read/write OpenType and TrueType fontsfontTools.ttx
: Convert between OTF and XML representationfontTools.ufoLib
: Read and write UFO filesfontTools.unicodedata
: Convert between Unicode and OpenType script infofontTools.varLib
: Deal with ‘gvar’-style font variationsfontTools.voltLib
: Deal with Visual OpenType Layout Tool (VOLT) files
Optional Dependencies
fontTools has no external dependencies besides the Python Standard Library. Some optional features require additional modules; see the optional requirements page for details.
Developer Information
For developer resources, refer to the developer information.
License
fontTools is licensed under the MIT license. Refer to the full text of the license for details.