Skip to main content

layout

Function layout 

Source
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

§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());