Font Tools

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.6 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; see fontTools.merge

  • pyftsubset, a tool for subsetting fonts; see fontTools.subset

  • ttx, a tool for converting between OpenType binary fonts (OTF) and an XML representation (TTX); see fontTools.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 values

  • cu2qu: Convert a UFO font from cubic to quadratic curves

  • feaLib: Add features from a feature file (.fea) into a OTF font

  • help: Show this help

  • merge: Merge multiple fonts into one

  • mtiLib: Convert a FontDame OTL file to TTX XML

  • subset: OpenType font subsetter and optimizer

  • ttLib.woff2: Compress and decompress WOFF2 fonts

  • ttx: Convert OpenType fonts to XML and back

  • varLib: Build a variable font from a designspace file and masters

  • varLib.instancer: Partially instantiate a variable font.

  • varLib.interpolatable: Test for interpolatability issues between fonts

  • varLib.interpolate_layout: Interpolate GDEF/GPOS/GSUB tables for a point on a designspace

  • varLib.models: Normalize locations on a given designspace

  • varLib.mutator: Instantiate a variation font

  • varLib.varStore: Optimize a font’s GDEF variation store

Libraries

The main library you will want to access when using fontTools for font engineering is likely to be fontTools.ttLib, which is the package for handling TrueType/OpenType fonts. However, there are many other libraries in the fontTools suite:

  • fontTools.afmLib: Module for reading and writing AFM files

  • fontTools.agl: Access to the Adobe Glyph List

  • fontTools.cffLib: Read/write tools for Adobe CFF fonts

  • fontTools.colorLib: Module for handling colors in CPAL/COLR fonts

  • fontTools.cu2qu: Module for cubic to quadratic conversion

  • fontTools.designspaceLib: Read and write designspace files

  • fontTools.encodings: Support for font-related character encodings

  • fontTools.feaLib: Read and read AFDKO feature files

  • fontTools.fontBuilder: Construct TTF/OTF fonts from scratch

  • fontTools.merge: Tools for merging font files

  • fontTools.pens: Various classes for manipulating glyph outlines

  • fontTools.subset: OpenType font subsetting and optimization

  • fontTools.svgLib.path: Library for drawing SVG paths onto glyphs

  • fontTools.t1Lib: Tools for PostScript Type 1 fonts (Python2 only)

  • fontTools.ttx: Module for converting between OTF and XML representation

  • fontTools.ufoLib: Module for reading and writing UFO files

  • fontTools.unicodedata: Convert between Unicode and OpenType script information

  • fontTools.varLib: Module for dealing with ‘gvar’-style font variations

  • fontTools.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