Skip to main content

Module host

Module host 

Source
Expand description

Math layout on behalf of a host HTML/CSS layout engine.

The host exposes its document through MathTree: the structure, the computed CSS of each node (MathComputedStyle) and fonts (MathFont). layout_math then runs the MathML layout algorithms directly over that tree. Every node’s result (border box, baseline, and the glyphs and rules it paints) goes back through MathLayoutHost::set_layout.

CSS is the source of truth: font-size (including font-size: math), math-depth, math-style, math-shift, padding, border and margin are all read from the host and never derived by mlayout. All lengths are CSS px.

Structs§

Edges
Values for the four sides of a box, e.g. padding, border widths or margins.
Extents
The ink extents of a glyph, in font units.
ForeignMetrics
The margin-box metrics of foreign content, measured from its baseline.
LayoutCollector
Wraps a MathTree and collects the layout results in a map, for hosts that would rather not implement MathLayoutHost themselves.
MathComputedStyle
Computed style of a node, as resolved by the host’s CSS engine.
MathGlyph
A structure that describes an individual glyph in a font.
NodeLayout
The layout of one node.
OperatorOverrides
Operator properties that override the MathML operator dictionary.
Point
A point (or offset) in CSS pixels. The y coordinate increases downwards.
PositionedGlyph
A glyph positioned relative to the origin of its Fragment::Glyphs run.
Rect
An axis-aligned rectangle in CSS pixels.
ShapeOptions
Options that affect glyph selection when shaping.
Size
A size in CSS pixels.
Vector
A point or offset in font units. The y coordinate increases downwards.

Enums§

CornerPosition
Possible positions of multiscripts relative to the base. The values match HarfBuzz’ hb_ot_math_kern_t.
Direction
The CSS direction property.
Form
The form of an operator: its position relative to its operands.
Fragment
One painted item.
MathConstant
The constants of the OpenType MATH table, in table order.
MathElement
The MathML elements mlayout knows how to lay out.
MathShift
The CSS math-shift property.
MathStyle
The CSS math-style property.
NodeKind
What kind of box a node is.

Traits§

MathFont
A font with an OpenType MATH table.
MathLayoutHost
A host that can lay out foreign content and receive the results.
MathTree
Read access to the host’s tree: structure, computed style and fonts.

Functions§

axis_height
The height of the math axis above the baseline of node, in px: the font’s AxisHeight at the node’s font-size. Fractions, stretchy operators and tables are centered on it.
default_operator_overrides
The default implementation of MathTree::operator_overrides, for hosts that override it but still want the attribute-based values for some properties.
intrinsic_inline_size
The inline size (width of the border box) of node. Math content has no line breaks, so this is both the min-content and the max-content size. Nothing is reported to MathLayoutHost::set_layout.
layout_math
Lays out the MathML subtree rooted at root, usually a <math> element.
parse_math_length
Parses a MathML/CSS length such as "0.5em", "3px" or "thinmathspace" into px.
script_scale_factor
The factor by which font-size: math scales the font size when math-depth changes from parent_depth to depth (CSS Fonts 4 / MathML Core).

Type Aliases§

GlyphCode
An identifier of a glyph inside a font.