Skip to main content

FontMetrics

Struct FontMetrics 

Source
pub struct FontMetrics<'a> {
Show 30 fields pub afm_version: Cow<'a, str>, pub font_name: Cow<'a, str>, pub font_bbox: BBox, pub metrics_sets: Option<MetricsSets>, pub full_name: Option<Cow<'a, str>>, pub family_name: Option<Cow<'a, str>>, pub weight: Option<Cow<'a, str>>, pub version: Option<Cow<'a, str>>, pub notice: Option<Cow<'a, str>>, pub encoding_scheme: Option<Cow<'a, str>>, pub character_set: Option<Cow<'a, str>>, pub mapping_scheme: Option<u32>, pub esc_char: Option<u8>, pub characters: Option<u32>, pub is_base_font: Option<bool>, pub is_cid_font: Option<bool>, pub v_vector: Option<Vector>, pub is_fixed_v: Option<bool>, pub cap_height: Option<f32>, pub x_height: Option<f32>, pub ascender: Option<f32>, pub descender: Option<f32>, pub std_hw: Option<f32>, pub std_vw: Option<f32>, pub directions: [DirectionMetrics; 2], pub character_metrics: Cow<'a, [CharacterMetric<'a>]>, pub kerning_pairs: Cow<'a, [KerningPair<'a>]>, pub track_kerns: Cow<'a, [TrackKern]>, pub composites: Cow<'a, [Composite<'a>]>, pub source_records: Cow<'a, [SourceRecord<'a>]>,
}
Expand description

Parsed AFM metric data. Optional authored fields retain absence; accessors resolve defaults.

Fields§

§afm_version: Cow<'a, str>

AFM format version from the header.

§font_name: Cow<'a, str>

Required font program name.

§font_bbox: BBox

Required font bounding box.

§metrics_sets: Option<MetricsSets>

Declared writing directions; absence implies direction 0.

§full_name: Option<Cow<'a, str>>

Full display name.

§family_name: Option<Cow<'a, str>>

Typeface family.

§weight: Option<Cow<'a, str>>

Weight description.

§version: Option<Cow<'a, str>>

Font program version, distinct from the AFM format version.

§notice: Option<Cow<'a, str>>

Font notice or copyright text.

§encoding_scheme: Option<Cow<'a, str>>

Default encoding description.

§character_set: Option<Cow<'a, str>>

Glyph complement description.

§mapping_scheme: Option<u32>

Encoding mapping selector.

§esc_char: Option<u8>

Escape byte for an escape-mapped font.

§characters: Option<u32>

Declared total glyph count, independent of the character-metric section count.

§is_base_font: Option<bool>

Authored base-font flag; absence implies true.

§is_cid_font: Option<bool>

Authored CID-keyed font flag.

§v_vector: Option<Vector>

Global displacement between writing origins.

§is_fixed_v: Option<bool>

Authored fixed-origin-vector flag.

§cap_height: Option<f32>

Capital height.

§x_height: Option<f32>

Lowercase x height.

§ascender: Option<f32>

Ascender height.

§descender: Option<f32>

Descender depth, typically negative.

§std_hw: Option<f32>

Dominant horizontal stem width.

§std_vw: Option<f32>

Dominant vertical stem width.

§directions: [DirectionMetrics; 2]

Metrics for directions 0 and 1; shared blocks populate both.

§character_metrics: Cow<'a, [CharacterMetric<'a>]>

All character records in source order.

§kerning_pairs: Cow<'a, [KerningPair<'a>]>

All named/hexadecimal pairs in source order, with direction identity.

§track_kerns: Cow<'a, [TrackKern]>

Track-kerning records in source order.

§composites: Cow<'a, [Composite<'a>]>

Composite construction recipes in source order.

§source_records: Cow<'a, [SourceRecord<'a>]>

Comments and uninterpreted records, including unmodeled multiple-master arrays.

Implementations§

Source§

impl FontMetrics<'_>

Source

pub const fn direction(&self, direction: Direction) -> &DirectionMetrics

Metrics for one writing direction.

Source

pub fn advance( &self, character: &CharacterMetric<'_>, direction: Direction, ) -> Option<Vector>

Resolve a character advance against the direction’s global CharWidth. Returns None if neither was specified; an explicit zero remains Some.

Source

pub fn vertical_origin(&self, character: &CharacterMetric<'_>) -> Option<Vector>

Resolve a character’s vertical origin vector against the global VVector.

Source

pub fn fixed_v(&self) -> bool

Effective IsFixedV, inferred from global VVector when absent.

Source

pub fn into_owned(self) -> OwnedFontMetrics

Detach all borrowed strings and nested records from the source.

Trait Implementations§

Source§

impl<'a> Clone for FontMetrics<'a>

Source§

fn clone(&self) -> FontMetrics<'a>

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<'a> Debug for FontMetrics<'a>

Source§

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

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

impl<'a> Default for FontMetrics<'a>

Source§

fn default() -> FontMetrics<'a>

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

impl<'a> PartialEq for FontMetrics<'a>

Source§

fn eq(&self, other: &FontMetrics<'a>) -> 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<'a> StructuralPartialEq for FontMetrics<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for FontMetrics<'a>

§

impl<'a> RefUnwindSafe for FontMetrics<'a>

§

impl<'a> Send for FontMetrics<'a>

§

impl<'a> Sync for FontMetrics<'a>

§

impl<'a> Unpin for FontMetrics<'a>

§

impl<'a> UnsafeUnpin for FontMetrics<'a>

§

impl<'a> UnwindSafe for FontMetrics<'a>

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.