Skip to main content

Crate fmd_font

Crate fmd_font 

Source
Expand description

Clean-room TrueType / OpenType font reader.

Parses the sfnt table directory plus the metric, character-map, outline, and layout tables we need to lay out and embed text: head (units per em), maxp (glyph count), hhea/hmtx (vertical metrics + advance widths), cmap (character → glyph, formats 4 and 12), glyf/loca (TrueType outlines for subsetting), legacy kern format-0 pair kerning, focused GPOS pair positioning, GSUB standard ligatures, and optional fvar/avar font variation axes (named instances + clamped axis mapping). Latin-first, zero-dependency, and free of unsafe/unwrap/panic — every read is bounds-checked.

Additive strict subset APIs also support name-keyed CFF1 with explicit embedding metadata; see cff. shaping provides bounded Latin/Arabic shaping with UTF-8 source clusters and typed unsupported/malformed errors. Existing renderer shaping and TrueType subset output remain unchanged.

Factored out of franken_markdown’s src/text.rs into this standalone fmd-font workspace crate so the wider Franken suite can consume the font subsystem directly (franken_manim’s Scribe is the first external consumer). The outline module is the piece added with the factoring: a decoder from glyf point data to quadratic-Bézier contours with phantom-point-correct metrics.

Re-exports§

pub use macos::DEFAULT_MAC_CONTEXT_BUDGET;
pub use macos::MAX_MAC_RASTER_BYTES;
pub use macos::MAX_MAC_RASTER_DIMENSION;
pub use macos::MacBridgeDriver;
pub use macos::MacFontAdapter;
pub use macos::MacFontAdapterConfig;
pub use macos::MacFontAdapterError;
pub use macos::RawCoreGraphicsRaster;
pub use macos::RawCoreTextGlyph;
pub use macos::RawCoreTextLine;
pub use macos::SimulatedMacBridge;
pub use native_route::FallbackFace;
pub use native_route::NativeShapingError;
pub use native_route::NativeShapingRequest;
pub use native_route::NativeShapingRoute;
pub use native_route::PlatformRunGlyph;
pub use native_route::PlatformShapedOutput;
pub use native_route::ShapingRouteCapabilities;
pub use native_route::ShapingRouteKind;
pub use native_route::SimulatedFallbackRule;
pub use native_route::SimulatedNativeRoute;
pub use native_route::assemble_platform_run;
pub use shaping::Direction;
pub use text_run::CaretAffinity;
pub use text_run::CaretPosition;
pub use text_run::FontId;
pub use text_run::FontOrigin;
pub use text_run::HitTestResult;
pub use text_run::OwnedTextRun;
pub use text_run::RunGlyph;
pub use text_run::SelectionRect;
pub use text_run::TextCluster;
pub use text_run::TextRunContext;
pub use text_run::byte_to_utf16;
pub use text_run::utf16_to_byte;

Modules§

cff
Bounded CFF1 Type 2 decoding and deterministic, unhinted CFF subsetting. CID-keyed CFF, CFF2, seac and computational charstring operators are explicitly refused. Drawing, hints, flex and local/global subroutines are supported. Coordinates and advances are font design units.
macos
Optional safe Mac font adapter contract and CoreText/CoreGraphics bridge interface (FCB-075.B).
native_route
Safe native shaping route contract and platform adapter interface (FCB-016.B).
outline
Glyph outline decoding: glyf point data → quadratic-Bézier contours.
shaping
Deterministic shaping of caller-segmented runs. No bidi segmentation, normalization, font fallback, or host discovery occurs here. Coverage is Latin and basic Arabic (U+0620..U+064A plus declared combining marks). GSUB single/ligature and GPOS single/pair/mark-to-base/mark-to-mark are supported; selected unsupported lookups are refused rather than silently skipped.
text_run
Shared owned text/font/run contract (FCB-016.A).

Structs§

AxisBounds
User-space (min, default, max) for one variation axis.
Font
A parsed font, owning its backing bytes.
Kerning
Parsed GPOS kern-feature pair positioning for a font.
Ligatures
Parsed GSUB liga standard ligatures for a font. Built once via Font::gsub_ligatures; Ligatures::substitute applies them.
NamedInstance
One named instance from fvar (a designer-authored location in axis space).
Subset
A compact font and its original-glyph to subset-glyph mapping.
SubsetError
Bounded failure context. Offsets identify the failing table structure (or glyph charstring when glyph is present), never a host file path.
VariationAxis
One fvar variation axis (wght, wdth, opsz, …).

Enums§

EmbeddingFormat
Font program encoding; never infer a PDF dictionary from the filename.
FontError
Why a font failed to parse.
SubsetErrorKind
Stable categories independent of host paths and diagnostic prose.

Constants§

MISSING_GLYPH_REMAP
Sentinel in the dense glyph remap returned by Font::subset_glyphs_with_lookup: lookup[old] == MISSING_GLYPH_REMAP means glyph old is not part of the subset (glyph 0, .notdef, is always kept and always remaps to 0).

Functions§

variable_triangle_fixture
Tiny OFL variable-font fixture (one glyph, wght 100..=900, gvar peak +50 x on point 0). Host-font / CLI / WASM tests use this; it is not a design face. ASCII U+0020..=U+007E map to glyph 0.