Skip to main content

Module host

Module host 

Source
Expand description

Helpers for using formel embedded in a host application which provides its own DOM representation of the MathML.

The host exposes its DOM structure through the MathTree trait. An implementor of that trait will have to supply the relevant subset of CSS values for MathML (MathComputedStyle) for every node.

layout_math then runs the MathML layout algorithms directly over the host DOM tree.

The results are communicated back via the MathLayoutHost trait. Hosts can either implement this trait themselves or use the provided LayoutCollector implementation which provides a HashMap mapping from a DOM node to its layout results.

All lengths are CSS px.

In the guide submodule there is more extensive documentation for the host integration.

Modules§

guide
How to integrate formel into a host application

Structs§

Accents
Which scripts of an under/over element are accents.
CompositeFont
A MathFont made of several fonts. See the module documentation.
DecodedGlyph
A glyph of a CompositeFont found in its face.
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.
FontFace
A font and what it is to be used for in a CompositeFont.
FontFeatures
A small list of OpenType feature settings, as in CSS font-feature-settings (for example ss03 or cv01 with value 2).
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, using CSS terminology.
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.
SizeVariants
The size variants of a glyph in one direction and whether it also has a glyph assembly, as the MathGlyphConstruction of the font’s MathVariants table says.
TokenText
The text of a token element after text-transform, as MathTree::text returns it.
UnicodeRanges
A set of Unicode codepoints, as the unicode-range descriptor of CSS. Ranges may overlap.
Vector
A point or offset in font units. The y coordinate increases downwards.

Enums§

CompositeFontError
Why a CompositeFont could not be made.
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.
TokenSegment
One piece of the content of a token element that mixes text and foreign content, in document order. See MathTree::token_content.

Traits§

MathFont
A font with an OpenType MATH table.
MathLayoutHost
A host that can lay out foreign content and receive the results.
MathStructure
Read access to the markup of the document, without style or fonts.
MathTree
Read access to the host’s tree: structure, computed style and fonts.
UaStyleHost
Receives the styles from resolve_ua_styles and may change them.

Functions§

accents
The effective accentunder and accent of element, resolved as in script_is_accent. Both are false for an element that is not <munder>, <mover> or <munderover>.
axis_height
The height of the math axis above the baseline of node.
core_operator
The <mo> at the core of node if it is an embellished operator (MathML Core 3.2.4.1).
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.
is_space_like
Whether node is space-like (MathML Core 3.2.5.1). Space-like elements don’t count when deciding whether a row is an embellished operator, or an operator’s form.
layout_math
Lays out the MathML subtree rooted at root, usually a <math> element.
resolve_ua_styles
Computes the user agent style of root and every MathML element below it, top-down, and hands each to host (see UaStyleHost).
script_is_accent
Whether the child at index of parent is an accent: the overscript of <mover> or <munderover> (accent), or the underscript of <munder> or <munderover> (accentunder). false for any other child, and for a script that is missing.
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).
token_text
The text of the token element element with the raw content text, after the text-transform that its mathvariant maps to.

Type Aliases§

GlyphCode
An identifier of a glyph inside a font.