cffsubr

raw JSON →
0.4.0 verified Mon Apr 27 auth: no python

A standalone CFF (Compact Font Format) subroutinizer based on the AFDKO tx tool. It converts CFF fonts to their subroutinized form, reducing file size. Version 0.4.0 requires Python >=3.10. Releases are irregular; maintained by Adobe Type Tools.

pip install cffsubr
error AttributeError: module 'cffsubr' has no attribute 'subroutinize'
cause Importing from the wrong path or using an old version where the function was named differently.
fix
Use from cffsubr import subroutinize and ensure cffsubr >= 0.2.0.
error TypeError: subroutinize() missing 1 required positional argument: 'font'
cause Called without passing a TTFont object.
fix
Pass a loaded TTFont instance: subroutinize(font).
error fontTools.ttLib.TTLibError: Unknown font format
cause Input file is not a valid OpenType font (e.g., .ttf, .woff, or corrupt file).
fix
Verify the font is a CFF-based .otf file.
breaking In cffsubr 0.4.0, the `subroutinize` function must be called on a TTFont object; it no longer accepts raw bytes or file paths.
fix Use fontTools to load the font first: TTFont('path.otf').
gotcha Only CFF-flavored OpenType fonts (.otf) are supported. TrueType-flavored fonts (.ttf) will not be processed.
fix Ensure the input font has CFF outlines (check with TTFont.sfVersion == 'OTTO').
gotcha The `subroutinize` function modifies the font object in place; it does not return a new font or any status code.
fix After calling, the original font object is modified. Save a copy first if needed.

Load a CFF font, subroutinize it, and save.

from cffsubr import subroutinize
from fontTools.ttLib import TTFont

font = TTFont('input.otf')
subroutinize(font)
font.save('output.otf')