Skip to main content

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_TYPOGRAPHIC_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: &FontRef<'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 duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Metrics

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 (const: unstable) · 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 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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.