pub fn layout(
node: &MathNode,
font: &MathFont,
style: MathStyle,
) -> Result<MathBox, Error>Expand description
Lay out node in style using STIX Two Math metrics.
Every dimension on the returned MathBox is a Dim. Missing
glyphs and unsupported constructs are errors — never a substitute glyph.
§Arguments
node— parsed math tree.font— face providing MATH constants and glyph metrics.style— TeX math style (Display,Text, scripts).
§Returns
A box tree ready for SVG, PNG, or egui emission.
§Errors
Error::Font— glyph missing from the face.Error::Unsupported— construct or MATH table the engine will not fake.Error::Malformed— invalid structure discovered during layout.
§Examples
use latex_rust::{layout, parse, MathFont, MathStyle};
let ast = parse(r"\frac{1}{2}").unwrap();
let font = MathFont::stix_two_math().unwrap();
let boxed = layout(&ast, &font, MathStyle::Text).unwrap();
assert!(!boxed.width.is_zero());