
fontTools Docs
About
fontTools is a family of libraries and utilities for manipulating fonts in Python.
The project has an MIT open-source license. Among other things this means you can use it free of charge.
Installation
Note
fontTools requires Python 3.8 or later.
The package is listed in the Python Package Index (PyPI), so you can install it with pip:
pip install fonttools
See the Optional Requirements section below for details about module-specific dependencies that must be installed in select cases.
Utilities
fontTools installs four command-line utilities:
pyftmerge
, a tool for merging fonts; seefontTools.merge
pyftsubset
, a tool for subsetting fonts; seefontTools.subset
ttx
, a tool for converting between OpenType binary fonts (OTF) and an XML representation (TTX); seefontTools.ttx
fonttools
, a “meta-tool” for accessing other components of the fontTools family.
This last utility takes a subcommand, which could be one of:
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 fonthelp
: Show this helpmerge
: Merge multiple fonts into onemtiLib
: Convert a FontDame OTL file to TTX XMLsubset
: OpenType font subsetter and optimizerttLib.woff2
: Compress and decompress WOFF2 fontsttx
: Convert OpenType fonts to XML and backvarLib
: Build a variable font from a designspace file and mastersvarLib.instancer
: Partially instantiate a variable font.varLib.interpolatable
: Test for interpolatability issues between fontsvarLib.interpolate_layout
: Interpolate GDEF/GPOS/GSUB tables for a point on a designspacevarLib.models
: Normalize locations on a given designspacevarLib.mutator
: Instantiate a variation fontvarLib.varStore
: Optimize a font’s GDEF variation storevoltLib.voltToFea
: Convert MS VOLT to AFDKO feature files.
Libraries
The main library you will want to access when using fontTools for font
engineering is likely to be fontTools.ttLib.ttFont
, which is the module
for handling TrueType/OpenType fonts. However, there are many other
libraries in the fontTools suite:
fontTools.afmLib
: Module for reading and writing AFM filesfontTools.agl
: Access to the Adobe Glyph ListfontTools.cffLib
: Read/write tools for Adobe CFF fontsfontTools.colorLib
: Module for handling colors in CPAL/COLR fontsfontTools.config
: Configure fontToolsfontTools.cu2qu
: Module for cubic to quadratic conversionfontTools.designspaceLib
: Read and write designspace filesfontTools.encodings
: Support for font-related character encodingsfontTools.feaLib
: Read and read AFDKO feature filesfontTools.fontBuilder
: Construct TTF/OTF fonts from scratchfontTools.merge
: Tools for merging font filesfontTools.pens
: Various classes for manipulating glyph outlinesfontTools.subset
: OpenType font subsetting and optimizationfontTools.svgLib.path
: Library for drawing SVG paths onto glyphsfontTools.t1Lib
: Tools for PostScript Type 1 fonts (Python2 only)fontTools.tfmLib
: Module for reading TFM filesfontTools.ttLib
: Module for reading/writing OpenType and Truetype fontsfontTools.ttx
: Module for converting between OTF and XML representationfontTools.ufoLib
: Module for reading and writing UFO filesfontTools.unicodedata
: Convert between Unicode and OpenType script informationfontTools.varLib
: Module for dealing with ‘gvar’-style font variationsfontTools.voltLib
: Module for dealing with Visual OpenType Layout Tool (VOLT) files
A selection of sample Python programs using these libaries can be found in the Snippets directory of the fontTools repository.
Optional Dependencies
The fontTools package currently has no (required) external dependencies besides the modules included in the Python Standard Library. However, a few extra dependencies are required to unlock optional features in some of the library modules. See the optional requirements page for more information.
Developer information
Information for developers can be found here.
License
MIT license. See the full text of the license for details.
Table of Contents
Library
- afmLib: Read/write Adobe Font Metrics files
- agl: Interface to the Adobe Glyph List
- cffLib: read/write Adobe CFF fonts
CFFFontSet
CFFWriter
CharStrings
CharStringsCompiler
FDArrayIndex
FDArrayIndexCompiler
GlobalSubrsCompiler
GlobalSubrsIndex
Index
IndexCompiler
IndexedStrings
IndexedStringsCompiler
StopHintCountEvent
SubrsCompiler
SubrsIndex
TopDict
TopDictIndex
TopDictIndexCompiler
- specializer: T2CharString operator specializer and generalizer
- width: T2CharString glyph width optimizer
- colorLib.builder: Build COLR/CPAL tables from scratch
- config: configure fontTools
- cu2qu: Cubic to quadratic curve conversion
- designspaceLib: Read, write, and edit designspace files
- encodings: Support for OpenType-specific encodings
- feaLib: Read/write OpenType feature files
- merge: Merge multiple fonts into one
- misc: Miscellaneous libraries helpful for font engineering
- arrayTools: Various array and rectangle tools
- bezierTools: Routines for working with Bezier curves
- classifyTools
- cliTools: Utilities for command-line interfaces and console scripts
- configTools
- eexec: PostScript charstring encryption and decryption routines
- encodingTools
- etree
- filenames: Implements UFO User Name to File Name Algorithm
- fixedTools: Tools for working with fixed-point numbers
- intTools: Tools for working with integer values
- loggingTools: tools for interfacing with the Python logging package
- macCreatorType: Functions for working with Mac file attributes
- macRes: Tools for reading Mac resource forks
- plistlib: Tools for handling .plist files
- psCharStrings
- psLib
- psOperators
- sstruct
- symfont
- testTools
- textTools
- timeTools
- transform
- xmlReader
- xmlWriter
- mtiLib: Read Monotype FontDame source files
- otlLib: Routines for working with OpenType Layout
- pens
- subset
- cff
- Initial glyph set specification
- Other options
- Output options
- Glyph set expansion
- Hinting options
- Optimization options
- Font table options
- Font naming options
- Glyph naming and encoding options
- Other font-specific options
- Application options
Options
Subsetter
load_font()
main()
parse_gids()
parse_glyphs()
parse_unicodes()
save_font()
- svgLib
- t1Lib
- tfmLib: Read TeX Font Metrics files
- ttLib: Read/write OpenType and TrueType fonts
- ttx
- ufoLib
- converters
- errors
- filenames
- glifLib
- kerning
- plistlib
- pointPen
- utils
- validators
UFOFileStructure
UFOLibError
UFOReader
UFOReaderWriter
UFOWriter
convertFontInfoValueForAttributeFromVersion1ToVersion2()
convertFontInfoValueForAttributeFromVersion2ToVersion1()
makeUFOPath()
validateFontInfoVersion2ValueForAttribute()
validateFontInfoVersion3ValueForAttribute()
- unicode
- unicodedata
- Blocks
- OTTags
- ScriptExtensions
- Scripts
bidirectional()
block()
category()
combining()
decimal()
decomposition()
digit()
east_asian_width()
lookup()
mirrored()
name()
normalize()
numeric()
ot_tag_to_script()
ot_tags_from_script()
script()
script_code()
script_extension()
script_horizontal_direction()
script_name()
- varLib: OpenType Variation Support
- voltLib: Read/write MS VOLT projects