Skip to main content

StyleMetrics

Struct StyleMetrics 

Source
pub struct StyleMetrics {
    pub units_per_em: u16,
    pub subscript: Option<ScriptMetrics>,
    pub superscript: Option<ScriptMetrics>,
    pub underline: Option<Decoration>,
    pub strike_through: Option<Decoration>,
    pub italic_angle: Option<Fixed>,
    pub is_fixed_pitch: Option<bool>,
}
Expand description

Font-wide style measurements from OS/2 and post, or Type 1 font info.

Unlike super::Metrics, reading these may require the post table. Each group is None if its source table is missing or unreadable. At a non-default location, MVAR deltas are applied without rounding. The italic angle remains the value in post; normalized coordinates alone do not provide the user-space slnt value needed to adjust it.

Fields§

§units_per_em: u16

Design units per em, which the measurements use.

The same as Metrics::units_per_em.

§subscript: Option<ScriptMetrics>

Suggested subscript em box and placement, from OS/2.

§superscript: Option<ScriptMetrics>

Suggested superscript em box and placement, from OS/2.

§underline: Option<Decoration>

Suggested underline, from post.

§strike_through: Option<Decoration>

Suggested strikethrough, from OS/2.

§italic_angle: Option<Fixed>

Italic angle in degrees, from post. This is not a length.

§is_fixed_pitch: Option<bool>

Whether post reports a fixed pitch.

Implementations§

Source§

impl StyleMetrics

Source

pub fn scaled<S>(&self, scale: S) -> ScaledStyleMetrics<'_, S>
where S: Scale,

Returns these style measurements in the units scale describes.

Source

pub fn scaled_f32(&self, ppem: f32) -> ScaledStyleMetrics<'_, ScaleF32>

Returns these style measurements in pixels at ppem, as f32.

Source

pub fn scaled_26dot6(&self, ppem: f32) -> ScaledStyleMetrics<'_, Scale26Dot6>

Returns these style measurements in pixels at ppem, in 26.6 fixed point.

Source§

impl StyleMetrics

Source

pub fn from_sfnt<'a>( tables: &impl TableProvider<'a>, normalized_coords: &[F2Dot14], ) -> StyleMetrics

Reads style measurements from tables at normalized_coords.

Pass an empty location for the font’s defaults. Missing or unreadable tables leave their measurements unset.

Source

pub fn from_type1(font: &Type1Font) -> StyleMetrics

Reads the style measurements from a Type 1 font.

Its underline center is converted to the top edge used by Decoration. Type 1 has no subscript, superscript or strikethrough.

Source

pub fn from_cff(font: &CffFontRef<'_>) -> StyleMetrics

Reads style measurements from a standalone CFF font.

Trait Implementations§

Source§

impl Clone for StyleMetrics

Source§

fn clone(&self) -> StyleMetrics

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 StyleMetrics

Source§

impl Debug for StyleMetrics

Source§

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

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

impl Default for StyleMetrics

Source§

fn default() -> StyleMetrics

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

impl Eq for StyleMetrics

Source§

impl PartialEq for StyleMetrics

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for StyleMetrics

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> ErasedDestructor for T
where T: 'static,

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.