pub struct FontVerticalMetrics {
pub units_per_em: u16,
pub ascender: i16,
pub descender: i16,
pub line_gap: i16,
}Expand description
Font-wide vertical metrics needed to compute line height, in font design units.
This is a deliberately minimal, font-library-agnostic mirror of the
ascender/descender/line-gap fields found in a font’s hhea/OS/2 tables.
Higher layers (e.g. the oxitext facade) translate their font library’s
richer metrics type into this struct so the layout engine stays free of any
font-parser dependency.
Convert to pixels with value * (font_size_px / units_per_em).
Fields§
§units_per_em: u16Design units per em (typically 1000 for CFF, 2048 for TrueType).
ascender: i16Typographic ascender in design units (positive, above baseline).
descender: i16Typographic descender in design units (negative, below baseline).
line_gap: i16Typographic line gap (extra leading between lines), in design units.
Implementations§
Source§impl FontVerticalMetrics
impl FontVerticalMetrics
Sourcepub fn ascent_px(&self, font_size_px: f32) -> f32
pub fn ascent_px(&self, font_size_px: f32) -> f32
Returns the pixel ascent (always positive) at font_size_px.
Sourcepub fn descent_px(&self, font_size_px: f32) -> f32
pub fn descent_px(&self, font_size_px: f32) -> f32
Returns the pixel descent depth (always positive) at font_size_px.
Sourcepub fn line_gap_px(&self, font_size_px: f32) -> f32
pub fn line_gap_px(&self, font_size_px: f32) -> f32
Returns the pixel line gap at font_size_px.
Trait Implementations§
Source§impl Clone for FontVerticalMetrics
impl Clone for FontVerticalMetrics
Source§fn clone(&self) -> FontVerticalMetrics
fn clone(&self) -> FontVerticalMetrics
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FontVerticalMetrics
impl Debug for FontVerticalMetrics
Source§impl PartialEq for FontVerticalMetrics
impl PartialEq for FontVerticalMetrics
Source§fn eq(&self, other: &FontVerticalMetrics) -> bool
fn eq(&self, other: &FontVerticalMetrics) -> bool
self and other values to be equal, and is used by ==.