Skip to main content

MathFont

Trait MathFont 

Source
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§

Source

fn units_per_em(&self) -> u32

Source

fn constant(&self, c: MathConstant) -> i32

The value of a MATH table constant. Most are lengths in font units; the *Percent* constants are percentages.

Source

fn shape(&self, text: &str, options: ShapeOptions) -> Vec<MathGlyph>

Shapes text with the math script.

Source

fn glyph(&self, glyph: GlyphCode, options: ShapeOptions) -> MathGlyph

Metrics for a glyph by index (no cmap lookup).

Source

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.

Source

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.

Source

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".

Implementations on Foreign Types§

Source§

impl<F: MathFont + ?Sized> MathFont for &F

Source§

fn units_per_em(&self) -> u32

Source§

fn constant(&self, c: MathConstant) -> i32

Source§

fn shape(&self, text: &str, options: ShapeOptions) -> Vec<MathGlyph>

Source§

fn glyph(&self, glyph: GlyphCode, options: ShapeOptions) -> MathGlyph

Source§

fn is_stretchable(&self, glyph: GlyphCode, horizontal: bool) -> bool

Source§

fn stretch( &self, glyph: GlyphCode, horizontal: bool, target_size: i32, options: ShapeOptions, ) -> Vec<(Vector<i32>, MathGlyph)>

Source§

fn math_kerning( &self, glyph: GlyphCode, corner: CornerPosition, correction_height: i32, ) -> i32

Source§

impl<F: MathFont + ?Sized> MathFont for Arc<F>

Source§

fn units_per_em(&self) -> u32

Source§

fn constant(&self, c: MathConstant) -> i32

Source§

fn shape(&self, text: &str, options: ShapeOptions) -> Vec<MathGlyph>

Source§

fn glyph(&self, glyph: GlyphCode, options: ShapeOptions) -> MathGlyph

Source§

fn is_stretchable(&self, glyph: GlyphCode, horizontal: bool) -> bool

Source§

fn stretch( &self, glyph: GlyphCode, horizontal: bool, target_size: i32, options: ShapeOptions, ) -> Vec<(Vector<i32>, MathGlyph)>

Source§

fn math_kerning( &self, glyph: GlyphCode, corner: CornerPosition, correction_height: i32, ) -> i32

Source§

impl<F: MathFont + ?Sized> MathFont for Box<F>

Source§

fn units_per_em(&self) -> u32

Source§

fn constant(&self, c: MathConstant) -> i32

Source§

fn shape(&self, text: &str, options: ShapeOptions) -> Vec<MathGlyph>

Source§

fn glyph(&self, glyph: GlyphCode, options: ShapeOptions) -> MathGlyph

Source§

fn is_stretchable(&self, glyph: GlyphCode, horizontal: bool) -> bool

Source§

fn stretch( &self, glyph: GlyphCode, horizontal: bool, target_size: i32, options: ShapeOptions, ) -> Vec<(Vector<i32>, MathGlyph)>

Source§

fn math_kerning( &self, glyph: GlyphCode, corner: CornerPosition, correction_height: i32, ) -> i32

Source§

impl<F: MathFont + ?Sized> MathFont for Rc<F>

Source§

fn units_per_em(&self) -> u32

Source§

fn constant(&self, c: MathConstant) -> i32

Source§

fn shape(&self, text: &str, options: ShapeOptions) -> Vec<MathGlyph>

Source§

fn glyph(&self, glyph: GlyphCode, options: ShapeOptions) -> MathGlyph

Source§

fn is_stretchable(&self, glyph: GlyphCode, horizontal: bool) -> bool

Source§

fn stretch( &self, glyph: GlyphCode, horizontal: bool, target_size: i32, options: ShapeOptions, ) -> Vec<(Vector<i32>, MathGlyph)>

Source§

fn math_kerning( &self, glyph: GlyphCode, corner: CornerPosition, correction_height: i32, ) -> i32

Implementors§

Source§

impl<'a> MathFont for Shaper<'a>