Expand description
§TrueType Font Subsetter
Strips a TrueType font to only the glyphs actually used in the document. This dramatically reduces PDF size — a typical font is 50-200KB but a subset with ~100 glyphs is usually 5-15KB.
The subsetter rebuilds a valid TrueType file with remapped glyph IDs (contiguous starting from 0). This is important because PDF CIDFont width arrays and content stream glyph references must use the new IDs.
§Approach
- Collect all needed glyphs (used glyphs + composite glyph dependencies)
- Remap old GIDs to new contiguous GIDs
- Rebuild required TrueType tables (glyf, loca, hmtx, cmap, etc.)
- Write a valid TrueType file with correct checksums and alignment
Structs§
- Subset
Result - Result of subsetting a font.
Functions§
- subset_
ttf - Subset a TrueType font to only include the given glyph IDs.