pub struct OpenTypeFont {Show 16 fields
pub units_per_em: u16,
pub ascender: i16,
pub descender: i16,
pub line_gap: i16,
pub typo_ascender: i16,
pub typo_descender: i16,
pub typo_line_gap: i16,
pub x_height: Option<i16>,
pub cap_height: Option<i16>,
pub weight_class: u16,
pub is_italic: bool,
pub is_monospace: bool,
pub num_glyphs: u16,
pub number_of_h_metrics: u16,
pub gsub_offset: Option<usize>,
pub supported_features: Vec<[u8; 4]>,
/* private fields */
}Expand description
Parsed OpenType / TrueType font face.
Fields§
§units_per_em: u16§ascender: i16§descender: i16§line_gap: i16§typo_ascender: i16§typo_descender: i16§typo_line_gap: i16§x_height: Option<i16>§cap_height: Option<i16>§weight_class: u16§is_italic: bool§is_monospace: bool§num_glyphs: u16§number_of_h_metrics: u16§gsub_offset: Option<usize>§supported_features: Vec<[u8; 4]>Implementations§
Source§impl OpenTypeFont
impl OpenTypeFont
Sourcepub fn parse(bytes: &[u8]) -> Result<Self, OpenTypeParseError>
pub fn parse(bytes: &[u8]) -> Result<Self, OpenTypeParseError>
Parses an OpenType or TrueType font from memory.
Sourcepub fn has_feature(&self, tag: &[u8; 4]) -> bool
pub fn has_feature(&self, tag: &[u8; 4]) -> bool
Checks whether this font supports a specific OpenType feature tag (e.g. *b"liga", *b"calt", *b"dlig", *b"smcp").
Sourcepub fn glyph_advance_units(&self, gid: u16) -> u16
pub fn glyph_advance_units(&self, gid: u16) -> u16
Retrieves glyph advance width in font design units from hmtx.
Sourcepub fn glyph_advance_em(&self, gid: u16) -> f32
pub fn glyph_advance_em(&self, gid: u16) -> f32
Advance width in ems (fraction of font size).
Sourcepub fn glyph_advance(&self, gid: u16, font_size: f32) -> f32
pub fn glyph_advance(&self, gid: u16, font_size: f32) -> f32
Advance width in CSS pixels for a given font size.
Sourcepub fn char_advance(&self, c: char, font_size: f32) -> f32
pub fn char_advance(&self, c: char, font_size: f32) -> f32
Computes advance width in CSS pixels for a character.
Sourcepub fn pair_kerning_units(&self, left_gid: u16, right_gid: u16) -> i16
pub fn pair_kerning_units(&self, left_gid: u16, right_gid: u16) -> i16
Retrieves pair kerning adjustment between two glyphs in font design units.
Sourcepub fn pair_kerning_em(&self, left_gid: u16, right_gid: u16) -> f32
pub fn pair_kerning_em(&self, left_gid: u16, right_gid: u16) -> f32
Pair kerning adjustment in ems.
Sourcepub fn pair_kerning(&self, left_gid: u16, right_gid: u16, font_size: f32) -> f32
pub fn pair_kerning(&self, left_gid: u16, right_gid: u16, font_size: f32) -> f32
Pair kerning adjustment in CSS pixels for a given font size.
Sourcepub fn font_metrics(&self, font_size: f32) -> FontMetrics
pub fn font_metrics(&self, font_size: f32) -> FontMetrics
Generates exact FontMetrics scaled to CSS pixels.
Trait Implementations§
Source§impl Clone for OpenTypeFont
impl Clone for OpenTypeFont
Auto Trait Implementations§
impl Forget for OpenTypeFont
impl Freeze for OpenTypeFont
impl Move for OpenTypeFont
impl RefUnwindSafe for OpenTypeFont
impl Send for OpenTypeFont
impl Sync for OpenTypeFont
impl Unpin for OpenTypeFont
impl UnsafeUnpin for OpenTypeFont
impl UnwindSafe for OpenTypeFont
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
Mutably borrows from an owned value. Read more