skrifa::metrics

Struct Metrics

source
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 the USE_TYPOGRAPHIC_METRICS flag is set or the hhea 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 the USE_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

source

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§

source§

impl Clone for Metrics

source§

fn clone(&self) -> Metrics

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Metrics

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Metrics

source§

fn default() -> Metrics

Returns the “default value” for a type. Read more
source§

impl PartialEq for Metrics

source§

fn eq(&self, other: &Metrics) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Metrics

source§

impl StructuralPartialEq for Metrics

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<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
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> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.