fonttools-subset
Subset fonts to reduce file size
TLDR
Subset a TTF font file to the Basic Latin Unicode block
Change the file type to WOFF2
Keep only the onum (oldstyle figures) and kern (kerning) OpenType font features
Set the output file's name
SYNOPSIS
fonttools subset [options] input_font [output_font]
PARAMETERS
--unicodes=U+0041,U+0042
Specify Unicode codepoints (hex) to include.
--unicodes-from-file=FILE
Read Unicode codepoints from text file.
--glyphs=G1,G2
Include specific glyphs by name.
--glyphs-from-file=FILE
Read glyph names from text file.
--layout-features=kern,liga
Retain OpenType layout features.
--name-languages=ENG,DEU
Keep name table entries for languages.
--name-IDs=1,2,3
Retain specific name table IDs.
--flavor=woff2|woff|variable
Set output format (default: input extension).
--no-hinting
Remove bytecode hinting instructions.
--oblique
Add PostScript oblique angle.
--no-notdef-outline
Omit .notdef glyph outline.
--truncate-glyph-names
Shorten glyph names for legacy tools.
--quiet
Suppress non-error messages.
--help-all
Show all options.
DESCRIPTION
The fonttools subset command creates optimized, smaller font files by removing unused glyphs, characters, and tables from input OpenType, TrueType, WOFF, or variable fonts. It supports specifying content via Unicode codepoints, glyph names, text files, or OpenType layout features like kerning (kern) and ligatures (liga).
Ideal for web fonts, mobile apps, and embedded uses, it reduces file sizes significantly—often by 90%—improving load times without losing rendering quality for specified text. Output supports flavors like WOFF2, variable fonts, and collections. It preserves essential tables (e.g., names, metadata) customizable via options, handles hinting, and supports advanced features like glyph name truncation for PDF compatibility.
Developed as part of the FontTools Python library, it processes fonts programmatically with high precision, supporting complex scripts and GSUB/GPOS tables.
CAVEATS
Requires Python FontTools (>=4.0); some options incompatible with variable fonts. Always test output rendering. Large inputs may be memory-intensive.
EXAMPLES
fonttools subset input.ttf output.woff2 --unicodes=U+0041,U+0042,U+0061 --flavor=woff2
fonttools subset NotoSans-Regular.ttf --text="Hello World" --layout-features=kern,liga --flavor=woff2 output.woff2
INPUT/OUTPUT
Input: .ttf, .otf, .woff, .woff2, .ttc. Output extension or --flavor sets type; defaults to input if unspecified.
HISTORY
Part of FontTools library since v4.0.0 (2017); replaced legacy pyftsubset. Developed by Behdad Esfahbod/Google, actively maintained for modern font standards.
SEE ALSO
pyftsubset(1), woff2_compress(1), fontforge(1)


