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
impl MathFont
Sourcepub fn stix_two_math() -> Result<Self, Error>
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());Sourcepub fn from_bytes(raw: &'static [u8]) -> Result<Self, Error>
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.
Sourcepub fn units_per_em(&self) -> u16
pub fn units_per_em(&self) -> u16
unitsPerEm from the head table.
Sourcepub fn ascender_fu(&self) -> i16
pub fn ascender_fu(&self) -> i16
hhea ascender in font units.
Sourcepub fn descender_fu(&self) -> i16
pub fn descender_fu(&self) -> i16
hhea descender in font units (typically negative).
Sourcepub fn glyph(&self, ch: char) -> Result<GlyphMetrics, Error>
pub fn glyph(&self, ch: char) -> Result<GlyphMetrics, Error>
Metrics for ch, or FontError::MissingGlyph.
Sourcepub fn glyph_id(&self, ch: char, gid: u16) -> Result<GlyphMetrics, Error>
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.
Sourcepub fn italic_correction(&self, glyph_id: u16) -> Dim
pub fn italic_correction(&self, glyph_id: u16) -> Dim
MATH italic correction for glyph_id, or zero.
Sourcepub fn top_accent_attachment(&self, glyph_id: u16) -> Option<Dim>
pub fn top_accent_attachment(&self, glyph_id: u16) -> Option<Dim>
MATH top-accent attachment (em from glyph left), if present.
Sourcepub fn horizontal_assembly_parts(
&self,
glyph_id: u16,
) -> Vec<(u16, u16, u16, u16, bool)>
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.
Sourcepub fn horizontal_variants(&self, glyph_id: u16) -> Vec<u16>
pub fn horizontal_variants(&self, glyph_id: u16) -> Vec<u16>
Horizontal MATH variants of glyph_id, including the base glyph first.
Sourcepub fn vertical_variants(&self, glyph_id: u16) -> Vec<u16>
pub fn vertical_variants(&self, glyph_id: u16) -> Vec<u16>
Vertical MATH variants of glyph_id, including the base glyph first.
Sourcepub fn sha256_hex(bytes: &[u8]) -> String
pub fn sha256_hex(bytes: &[u8]) -> String
SHA-256 hex of the raw face bytes (zenith-float SHA-256).
Auto Trait Implementations§
impl Freeze for MathFont
impl RefUnwindSafe for MathFont
impl Send for MathFont
impl Sync for MathFont
impl Unpin for MathFont
impl UnsafeUnpin for MathFont
impl UnwindSafe for MathFont
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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