Skip to main content

MathFont

Struct MathFont 

Source
pub struct MathFont { /* private fields */ }
Expand description

Loaded math face.

§Examples

use latex_rust::MathFont;

let font = MathFont::stix_two_math().unwrap();
assert_eq!(font.units_per_em(), 1000);

Implementations§

Source§

impl MathFont

Source

pub fn stix_two_math() -> Result<Self, Error>

Load the embedded STIX Two Math Regular face.

§Errors

crate::FontError::InvalidFace if the embedded bytes are not a usable OpenType face.

§Examples
use latex_rust::MathFont;
assert!(MathFont::stix_two_math().is_ok());
Source

pub fn from_bytes(raw: &'static [u8]) -> Result<Self, Error>

Parse OpenType bytes. Lifetime is 'static for the embedded font only; this constructor requires a static buffer so the face can be rebuilt.

Source

pub fn bytes(&self) -> &'static [u8]

OpenType bytes this face was parsed from.

Source

pub fn units_per_em(&self) -> u16

unitsPerEm from the head table.

Source

pub fn ascender_fu(&self) -> i16

hhea ascender in font units.

Source

pub fn descender_fu(&self) -> i16

hhea descender in font units (typically negative).

Source

pub fn ascender(&self) -> Dim

Ascender in em.

Source

pub fn descender(&self) -> Dim

Depth below baseline from hhea descender, in em (non-negative).

Source

pub fn glyph(&self, ch: char) -> Result<GlyphMetrics, Error>

Metrics for ch, or FontError::MissingGlyph.

Source

pub fn glyph_id(&self, ch: char, gid: u16) -> Result<GlyphMetrics, Error>

Metrics for OpenType glyph id gid, tagged with ch for the box payload.

Source

pub fn italic_correction(&self, glyph_id: u16) -> Dim

MATH italic correction for glyph_id, or zero.

Source

pub fn top_accent_attachment(&self, glyph_id: u16) -> Option<Dim>

MATH top-accent attachment (em from glyph left), if present.

Source

pub fn horizontal_assembly_parts( &self, glyph_id: u16, ) -> Vec<(u16, u16, u16, u16, bool)>

Horizontal glyph-assembly parts: (gid, start_connector, end_connector, advance, extender). Lengths are font units.

Source

pub fn horizontal_variants(&self, glyph_id: u16) -> Vec<u16>

Horizontal MATH variants of glyph_id, including the base glyph first.

Source

pub fn vertical_variants(&self, glyph_id: u16) -> Vec<u16>

Vertical MATH variants of glyph_id, including the base glyph first.

Source

pub fn sha256_hex(bytes: &[u8]) -> String

SHA-256 hex of the raw face bytes (zenith-float SHA-256).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.