Reduces the size and coverage of OpenType fonts.
open sourceMIT OR Apache-2.0self-hostablefree
subsetter is a Rust crate from the Typst project that cuts an OpenType font down to the glyphs a document uses, for embedding in a PDF. It handles fonts with TrueType (glyf) or CFF outlines and removes everything a PDF doesn't need, so the subsets are very small. That focus is deliberate: the README says the output will most likely be unusable anywhere but a PDF, and points to skera in Google's fontations for general-purpose subsetting. It forbids unsafe code and depends only on rustc-hash.
Problems it solves
- embed only the glyphs my document uses so generated PDFs stay small
- my Rust PDF output is megabytes because whole CJK fonts get embedded
- subset a CFF-flavoured OpenType font for PDF embedding without shelling out to fontTools
- shrink TrueType fonts to the used glyph IDs before writing them into a PDF from Rust
- font subsetting with no C dependencies and no unsafe code for a Rust document generator
- remap glyph IDs after subsetting so my PDF content streams point at the right glyphs
Features
- subsets OpenType fonts with TrueType (glyf) or CFF outlines
- removes tables and data a PDF doesn't need for very small subsets
- glyph remapping so content streams can use the new glyph IDs
- unsafe code forbidden; a single dependency (rustc-hash)
Limitations
- Doesn't make subsets usable outside PDFs: it strips data that other uses of a font need, on purpose1
- Doesn't instance variable fonts at chosen variation coordinates: listed only as possible future work1
Capabilities
| Has official SDKs | plan not known |
|---|
