pub fn text_width(font: Font, size: f32, text: &str) -> f32Expand description
Advance width of text rendered in font at size points.
Input is normalized through crate::nfc_text before any width
calculation. Decomposed sequences such as S\u{0326} therefore
measure as their precomposed NFC form (Ș) in both the Base14
per-character AFM path and the embedded-font shaping path.
glyph_width delegates here for a one-character string, so it
inherits the same normalization behavior.
For Base14 faces this sums per-character AFM widths (WinAnsi
natives + extended Latin reachable via [extended_glyph_name]).
Characters outside both tiers: Cyrillic, CJK, emoji: get the
width of ? (the substitution glyph the PDF emit path also uses
for those characters in Base14 runs). No diagnostic; callers wanting
real coverage should pick an embedded family.
For embedded faces this shapes via rustybuzz for glyph selection
and sums the resulting PDF-emittable glyph advances. Positioning
offsets are currently normalized away so layout matches PDF output.
§Examples
use mos_fonts::{Base14Font, Font, text_width};
let width = text_width(Font::Base14(Base14Font::Helvetica), 10.0, "A");
assert_eq!(width, 6.67);