Skip to main content

mos_fonts/
lib.rs

1//! Font discovery, shaping, and metrics (manifest ยง22.1).
2//!
3//! Two font-emission paths live behind one [`Font`] enum:
4//!
5//! - [`Font::Base14`]; the 14 standard PDF base fonts. No glyph data
6//!   ships; the PDF reader supplies outlines. Advance widths come from
7//!   bundled Adobe AFMs, addressed through [`pdf_base14_metrics`].
8//!   `WinAnsi` natives go out as their canonical byte; the small set
9//!   of extended Latin glyphs each face carries (Latin Extended-A
10//!   beyond `WinAnsi`, the math operators, `fi`/`fl` ligatures) goes
11//!   out through a per-document `/Differences` remap that
12//!   `mos-pdf` plans. Characters outside both tiers: Cyrillic,
13//!   CJK, emoji: silently substitute to `?` in both the width and
14//!   emit paths (no warning, no panic; callers that want non-Latin
15//!   should pick the embedded family).
16//! - [`Font::Embedded`]: a bundled Noto Sans cut shaped with
17//!   `rustybuzz` (`HarfBuzz` Rust port). The PDF backend embeds a
18//!   subset of the actual `TrueType` outlines as a Type 0 CID font
19//!   with a `/ToUnicode` `CMap`, so the output is a real
20//!   Unicode-aware document: copy/paste round-trips through Cyrillic,
21//!   Greek, accented Latin, and anything else Noto Sans covers.
22//!
23//! Six cuts ship in this crate's `data/` directory: four Noto Sans
24//! style cuts (Regular, Bold, Italic, `BoldItalic`) for proportional
25//! body text, one Noto Sans Mono Regular cut for `` `raw` `` runs, and
26//! one Noto Sans Math cut for per-glyph fallback (see `SOURCES.md`
27//! under the crate root). Style selection happens through [`FontFamily`],
28//! which the layout engine receives from the eval lowerer.
29
30#![doc(
31    html_logo_url = "https://mosaic.kjanat.dev/assets/A4.svg",
32    html_favicon_url = "https://mosaic.kjanat.dev/assets/A4.svg"
33)]
34#![deny(missing_docs)]
35
36mod embedded;
37mod family;
38mod font;
39mod metrics;
40mod normalize;
41mod resources;
42mod shape;
43
44pub use embedded::{EmbeddedFont, ShapedGlyph, shape, subset};
45pub use family::FontFamily;
46pub use font::{EmbeddedFontId, Font};
47pub use metrics::{advance_units_to_pt, ascent, descent, glyph_width, text_width};
48pub use normalize::nfc_text;
49pub use pdf_base14_metrics::{Base14Font, extended_glyph_name, winansi_byte};
50pub use shape::{ShapedRun, WordSubRun, shape_text, shape_with_fallback};