pub struct Metrics {Show 14 fields
pub units_per_em: u16,
pub glyph_count: u16,
pub is_monospace: bool,
pub italic_angle: f32,
pub ascent: f32,
pub descent: f32,
pub leading: f32,
pub cap_height: Option<f32>,
pub x_height: Option<f32>,
pub average_width: Option<f32>,
pub max_width: Option<f32>,
pub underline: Option<Decoration>,
pub strikeout: Option<Decoration>,
pub bounds: Option<BoundingBox>,
}
Expand description
Metrics that apply to all glyphs in a font.
These are retrieved for a specific position in the design space.
This metrics here are derived from the following tables:
- head:
units_per_em
,bounds
- maxp:
glyph_count
- post:
is_monospace
,italic_angle
,underline
- OS/2:
average_width
,cap_height
,x_height
,strikeout
, as well as the line metrics:ascent
,descent
,leading
if theUSE_TYPOGRAPHIC_METRICS
flag is set or thehhea
line metrics are zero (the Windows metrics are used as a last resort). - hhea:
max_width
, as well as the line metrics:ascent
,descent
,leading
if they are non-zero and theUSE_TYPOGRAHIC_METRICS
flag is not set in the OS/2 table
For variable fonts, deltas are computed using the MVAR table.
Fields§
§units_per_em: u16
Number of font design units per em unit.
glyph_count: u16
Number of glyphs in the font.
is_monospace: bool
True if the font is not proportionally spaced.
italic_angle: f32
Italic angle in counter-clockwise degrees from the vertical. Zero for upright text, negative for text that leans to the right.
ascent: f32
Distance from the baseline to the top of the alignment box.
descent: f32
Distance from the baseline to the bottom of the alignment box.
leading: f32
Recommended additional spacing between lines.
cap_height: Option<f32>
Distance from the baseline to the top of a typical English capital.
x_height: Option<f32>
Distance from the baseline to the top of the lowercase “x” or similar character.
average_width: Option<f32>
Average width of all non-zero width characters in the font.
max_width: Option<f32>
Maximum advance width of all characters in the font.
underline: Option<Decoration>
Metrics for an underline decoration.
strikeout: Option<Decoration>
Metrics for a strikeout decoration.
bounds: Option<BoundingBox>
Union of minimum and maximum extents for all glyphs in the font.
Implementations§
source§impl Metrics
impl Metrics
sourcepub fn new<'a>(
font: &impl TableProvider<'a>,
size: Size,
location: impl Into<LocationRef<'a>>,
) -> Self
pub fn new<'a>( font: &impl TableProvider<'a>, size: Size, location: impl Into<LocationRef<'a>>, ) -> Self
Creates new metrics for the given font, size, and location in normalized variation space.
Trait Implementations§
impl Copy for Metrics
impl StructuralPartialEq for Metrics
Auto Trait Implementations§
impl Freeze for Metrics
impl RefUnwindSafe for Metrics
impl Send for Metrics
impl Sync for Metrics
impl Unpin for Metrics
impl UnwindSafe for Metrics
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)