Skip to main content

Module embedded

Module embedded 

Source
Expand description

Embedded TrueType faces + shaping.

EmbeddedFont holds a bundled TTF’s bytes plus a pre-parsed rustybuzz::Face and the FontDescriptor-relevant metrics the PDF emit path needs. shape runs rustybuzz over a UTF-8 string and returns a ShapedGlyph stream with GPOS advances and offsets preserved. subset reduces a face to just the glyph IDs used in one document and returns the trimmed bytes suitable for a /FontFile2 stream.

Structs§

EmbeddedFont
A bundled TrueType face: the raw bytes plus the metrics and parsed rustybuzz::Face needed to shape text and emit a PDF FontDescriptor.
ShapedGlyph
One glyph in a shaped run. Cluster values are byte offsets into the source UTF-8 string.
SubsetError
Wraps [subsetter::Error] without exposing the dependency in the public API. The PDF emit path bails on this error with a Diagnostic. The inner variant is private: callers debug via the Display/Debug impls, not pattern matching on subsetter::Error directly.

Functions§

shape
Shape text against font using rustybuzz. Returns the glyph stream in visual order (LTR for this slice). Glyph IDs, advances, and offsets come from rustybuzz, so substitutions, kerning, and combining-mark positioning are preserved. An empty text returns an empty Vec without invoking the shaper.
subset
Subset font to just the glyph IDs in gids (always include GID 0, .notdef, which the PDF spec mandates). Returns the trimmed TTF bytes suitable for embedding as a /FontFile2 stream.

Type Aliases§

ShapePlanCache 🔒
Per-face cache of compiled rustybuzz shape plans, keyed by the (script, language) a buffer resolves to after segment-property guessing. Arc so the hit path can clone the handle out and shape with the lock released.