
—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
Library
- afmLib: Read and write Adobe Font Metrics files
- agl: Interface to the Adobe Glyph List
- cffLib: Read and write Adobe CFF fonts
- CFFToCFF2: convert CFF to CFF2
- CFF2ToCFF: convert CFF2 to CFF
- specializer: T2CharString operator specializer and generalizer
- width: T2CharString glyph width optimizer
CFFFontSet
CFFWriter
calcOffSize()
IndexCompiler
IndexedStringsCompiler
TopDictIndexCompiler
FDArrayIndexCompiler
GlobalSubrsCompiler
SubrsCompiler
CharStringsCompiler
Index
GlobalSubrsIndex
SubrsIndex
TopDictIndex
FDArrayIndex
VarStoreData
FDSelect
CharStrings
readCard8()
readCard16()
readCard32()
writeCard8()
writeCard16()
writeCard32()
packCard8()
packCard16()
packCard32()
buildOperatorDict()
buildOpcodeDict()
buildOrder()
buildDefaults()
buildConverters()
SimpleConverter
ASCIIConverter
Latin1Converter
parseNum()
parseBlendList()
NumberConverter
ArrayConverter
TableConverter
PrivateDictConverter
SubrsConverter
CharStringsConverter
CharsetConverter
CharsetCompiler
getStdCharSet()
getCIDfromName()
getSIDfromName()
packCharset0()
packCharset()
parseCharset0()
parseCharset()
EncodingCompiler
EncodingConverter
parseEncoding0()
parseEncoding1()
packEncoding0()
packEncoding1()
FDArrayConverter
FDSelectConverter
VarStoreConverter
packFDSelect0()
packFDSelect3()
packFDSelect4()
FDSelectCompiler
VarStoreCompiler
ROSConverter
addConverters()
TopDictDecompiler
PrivateDictDecompiler
DictCompiler
encodeNumber()
TopDictCompiler
FontDictCompiler
PrivateDictCompiler
BaseDict
TopDict
FontDict
PrivateDict
IndexedStrings
- colorLib.builder: Build COLR/CPAL tables from scratch
- config: Configure fontTools
- cu2qu: Convert cubic curves to quadratic
- designspaceLib: Read, write, and edit designspace files
- encodings: Support for OpenType-specific character encodings
- feaLib: Read and 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: Inspect and manipulate glyph outlines
- subset: Generate subsets of fonts or optimize file sizes
- 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()
save_font()
parse_gids()
parse_glyphs()
parse_unicodes()
main()
- svgLib: Read and write SVG-in-OpenType fonts
- t1Lib: Read and write PostScript Type 1 fonts
- tfmLib: Read TeX Font Metrics files
- ttLib: Read and write OpenType and TrueType fonts
- ttx: Convert fonts to XML and back
- ufoLib: Read and write Unified Font Object files
- converters: Conversion functions for kerning and groups
- errors: Exceptions for handling UFO-specific errors
- filenames: Functions to convert between file names and user-facing strings
- glifLib: Read and write UFO .glif files
- kerning: Support for accessing kerning data
- utils: Miscellaneous helper functions
- validators: Data-validation functions
- plistlib: Support for reading and writing .plist files [deprecated]
- pointPen: A pen for accessing points in a glyph contour [deprecated]
makeUFOPath()
UFOLibError
UFOReader
UFOWriter
UFOReaderWriter
UFOFileStructure
validateFontInfoVersion2ValueForAttribute()
validateFontInfoVersion3ValueForAttribute()
convertFontInfoValueForAttributeFromVersion1ToVersion2()
convertFontInfoValueForAttributeFromVersion2ToVersion1()
fontInfoAttributesVersion1
fontInfoAttributesVersion2
fontInfoAttributesVersion3
deprecatedFontInfoAttributesVersion2
- unicode
- unicodedata
- Blocks
- OTTags
- ScriptExtensions
- Scripts
lookup()
name()
decimal()
digit()
numeric()
category()
bidirectional()
combining()
east_asian_width()
mirrored()
decomposition()
normalize()
block()
script()
script_extension()
script_name()
script_code()
script_horizontal_direction()
ot_tags_from_script()
ot_tag_to_script()
- varLib: Support for OpenType Variations
- voltLib: Read and write MS VOLT projects