Skip to main content

Crate lightweight_pdf_fonts

Crate lightweight_pdf_fonts 

Source
Expand description

Font data and metrics for lightweight-pdf. Knows nothing about the document model or PDF types (plan/00a-contracts-and-artifacts.md, point 3).

Structs§

EmbeddedFontMetrics
Metrics for a font, keyed by Unicode character rather than a fixed 256-code table (Phase 4 lifts the WinAnsi-only limitation from Phase 0-2’s simple-font text path — Type-0/CID text has no such limit). Advances are computed lazily via cmap+hmtx lookups and cached per character, since the same handful of glyphs typically repeat often in one document (invoice/report text, not novel-scale volume — this simplicity/performance trade-off is accepted explicitly for V1: “kein Kerning … zunächst ignorierbar”).
FontData
Owns font bytes; a skrifa::FontRef is only ever created transiently on access, never stored self-referentially (ADR-010 / contract point 3).
FontSubset
Result of subsetting: a standalone, valid sfnt binary plus the mapping from each requested character to its new glyph ID in that binary (used both to encode PDF content-stream CIDs and to build the ToUnicode CMap — CID space equals the subset’s own glyph-index space, so CIDToGIDMap can stay /Identity).

Enums§

FontError

Functions§

subset_font
Subsets font down to .notdef plus exactly the glyphs needed for chars (including the full composite-glyph closure). Characters the font has no glyph for are silently omitted from the result — the caller decides how to handle that (see the facade’s ? fallback).