—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.
Table of Contents
- 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