pub trait MathFont {
// Required methods
fn units_per_em(&self) -> u32;
fn constant(&self, c: MathConstant) -> i32;
fn shape(&self, text: &str, options: ShapeOptions) -> Vec<MathGlyph>;
fn glyph(&self, glyph: GlyphCode, options: ShapeOptions) -> MathGlyph;
fn is_stretchable(&self, glyph: GlyphCode, horizontal: bool) -> bool;
fn stretch(
&self,
glyph: GlyphCode,
horizontal: bool,
target_size: i32,
options: ShapeOptions,
) -> Vec<(Vector<i32>, MathGlyph)>;
fn math_kerning(
&self,
glyph: GlyphCode,
corner: CornerPosition,
correction_height: i32,
) -> i32;
}Expand description
A font with an OpenType MATH table.
All lengths are in font design units (units_per_em per em).
Required Methods§
fn units_per_em(&self) -> u32
Sourcefn constant(&self, c: MathConstant) -> i32
fn constant(&self, c: MathConstant) -> i32
The value of a MATH table constant. Most are lengths in font units; the *Percent*
constants are percentages.
Sourcefn shape(&self, text: &str, options: ShapeOptions) -> Vec<MathGlyph>
fn shape(&self, text: &str, options: ShapeOptions) -> Vec<MathGlyph>
Shapes text with the math script.
Sourcefn glyph(&self, glyph: GlyphCode, options: ShapeOptions) -> MathGlyph
fn glyph(&self, glyph: GlyphCode, options: ShapeOptions) -> MathGlyph
Metrics for a glyph by index (no cmap lookup).
Sourcefn is_stretchable(&self, glyph: GlyphCode, horizontal: bool) -> bool
fn is_stretchable(&self, glyph: GlyphCode, horizontal: bool) -> bool
Whether the font has size variants or a glyph assembly for glyph in the given
direction.
Sourcefn stretch(
&self,
glyph: GlyphCode,
horizontal: bool,
target_size: i32,
options: ShapeOptions,
) -> Vec<(Vector<i32>, MathGlyph)>
fn stretch( &self, glyph: GlyphCode, horizontal: bool, target_size: i32, options: ShapeOptions, ) -> Vec<(Vector<i32>, MathGlyph)>
Returns a variant or assembly of glyph that covers target_size font units in the
given direction, as glyphs with offsets relative to the first one, following the
algorithm to shape a stretchy glyph of MathML Core (5.3.2): the base glyph if its advance
is at least the target, else the first size variant that is, else a glyph assembly, else
the largest variant. Falls back to the base glyph, so the result is never empty.
Sourcefn math_kerning(
&self,
glyph: GlyphCode,
corner: CornerPosition,
correction_height: i32,
) -> i32
fn math_kerning( &self, glyph: GlyphCode, corner: CornerPosition, correction_height: i32, ) -> i32
The MATH table kerning of glyph at corner for the given correction height.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".