Expand description
Pure-Rust parsers for Type 1, CFF / Type 2, and TrueType fonts, plus the shared geometry primitives they produce.
This crate has no stet-specific dependencies, so it is usable on its own for font-parsing workflows that don’t need a PostScript interpreter or a PDF renderer. The rest of the stet workspace uses it as the foundational font/geometry layer.
§What’s here
geometry—Matrix(affine transforms),PathSegment,PsPathtype1_parser/charstring— Adobe Type 1 parsing and charstring interpretation (eexec decryption included)cff_parser/type2_charstring— Compact Font Format parser and Type 2 charstring interpretertruetype— TrueType table accessors, simple + composite glyph resolution,glyf→PsPathconversionencoding— StandardEncoding, ISOLatin1Encoding, SymbolEncoding, MacRoman, etc.agl— Adobe Glyph List (glyph name ↔ Unicode)system_fonts— platform font directory discovery and 35-standard PostScript → URW substitution
§Quick example
Parse a Type 1 font and inspect its glyph dictionary:
use stet_fonts::type1_parser::parse_type1;
let data = std::fs::read("NimbusRoman-Regular.t1")?;
let font = parse_type1(&data)?;
println!("font: {} ({} glyphs)", font.font_name, font.charstrings.len());§Scope and non-goals
The surface is shaped around what stet needs to render PDFs and run a
PostScript Level 3 interpreter — whole-font parsing with glyph
outlines as PsPath. There is no text layout, no shaping, no colour
fonts, no variable-font interpolation, and no OpenType
GSUB/GPOS/BASE/GDEF tables. For a general-purpose font-layout
library, consider ttf-parser, rustybuzz, or skrifa.
Re-exports§
pub use geometry::Matrix;pub use geometry::PathSegment;pub use geometry::PsPath;
Modules§
- agl
- Adobe Glyph List (AGL) — glyph name → Unicode mapping.
- cff_
parser - CFF (Compact Font Format) binary parser.
- charstring
- Type 1 charstring interpreter.
- encoding
- PostScript standard encoding tables.
- geometry
- Geometry types: affine transform matrices, path segments, and paths.
- system_
fonts - System font discovery and caching.
- truetype
- TrueType (Type 42) glyph parser and path converter.
- type1_
parser - Type 1 font file (.t1) parser.
- type2_
charstring - Type 2 charstring interpreter for CFF fonts.
Constants§
- FONT_
SUBSTITUTIONS - Standard PostScript font name → URW replacement filename.
Functions§
- find_
substitution - Look up a font substitution: “Helvetica” → “NimbusSans-Regular”.