width: T2CharString glyph width optimizer

T2CharString glyph width optimizer.

CFF glyphs whose width equals the CFF Private dictionary’s defaultWidthX value do not need to specify their width in their charstring, saving bytes. This module determines the optimum defaultWidthX and nominalWidthX values for a font, when provided with a list of glyph widths.

fontTools.cffLib.width.main(args=None)[source]

Calculate optimum defaultWidthX/nominalWidthX values

fontTools.cffLib.width.optimizeWidths(widths)[source]

Given a list of glyph widths, or dictionary mapping glyph width to number of glyphs having that, returns a tuple of best CFF default and nominal glyph widths.

This algorithm is linear in UPEM+numGlyphs.