Skip to main content

FontMetrics

Struct FontMetrics 

Source
pub struct FontMetrics<'a> {
Show 16 fields pub font_name: Cow<'a, str>, pub full_name: Cow<'a, str>, pub family_name: Cow<'a, str>, pub weight: Cow<'a, str>, pub italic_angle: f32, pub is_fixed_pitch: bool, pub font_bbox: BBox, pub underline_position: f32, pub underline_thickness: f32, pub cap_height: f32, pub x_height: f32, pub ascender: f32, pub descender: f32, pub encoding_scheme: Cow<'a, str>, pub character_metrics: Cow<'a, [CharacterMetric<'a>]>, pub kerning_pairs: Cow<'a, [KerningPair<'a>]>,
}
Expand description

All public AFM data extracted from a single .adobe-font-metrics file.

Cow everywhere so a single type serves both runtime parsing (Cow::Borrowed slices of the source) and compile-time baked statics (Cow::Borrowed of &'static).

§Examples

use adobe_font_metrics::{FontMetrics, parse};

let src = "StartFontMetrics 4.1\nFontName Demo\nFontBBox 0 0 1000 1000\nEndFontMetrics\n";
let metrics: FontMetrics<'_> = parse(src)?;

assert_eq!(metrics.font_name, "Demo");

Fields§

§font_name: Cow<'a, str>

PostScript FontName (e.g. "Helvetica").

§full_name: Cow<'a, str>

Human-readable FullName (e.g. "Helvetica Bold Oblique").

§family_name: Cow<'a, str>

PostScript FamilyName (e.g. "Helvetica").

§weight: Cow<'a, str>

Weight token, free-form per the spec ("Medium", "Bold", etc.).

§italic_angle: f32

Italic angle in degrees, counter-clockwise from vertical.

§is_fixed_pitch: bool

true if every glyph has the same advance width.

§font_bbox: BBox

Bounding box that contains every glyph in the font.

§underline_position: f32

Recommended y position of the underline, in 1/1000 em.

§underline_thickness: f32

Recommended thickness of the underline, in 1/1000 em.

§cap_height: f32

Height of an unaccented capital, in 1/1000 em.

§x_height: f32

Height of a lowercase x, in 1/1000 em.

§ascender: f32

Ascender height, in 1/1000 em.

§descender: f32

Descender depth (negative for descents below the baseline).

§encoding_scheme: Cow<'a, str>

Encoding scheme name (e.g. "AdobeStandardEncoding").

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

Per-glyph metrics. parse always returns this as Cow::Owned; Cow::Borrowed(&'static [...]) is reserved for compile-time-baked statics in downstream crates (e.g. pdf-base14-metrics).

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

Kerning pairs. parse always returns this as Cow::Owned; Cow::Borrowed(&'static [...]) is reserved for compile-time-baked statics in downstream crates (e.g. pdf-base14-metrics).

Implementations§

Source§

impl<'a> FontMetrics<'a>

Source

pub fn into_owned(self) -> OwnedFontMetrics

Lift to 'static, cloning every borrowed slice. Intended for callers who need to outlive the source &str (caches, baked statics, cross-thread sends).

§Examples
use adobe_font_metrics::{OwnedFontMetrics, parse};

let src = "StartFontMetrics 4.1\nFontName Demo\nFontBBox 0 0 1000 1000\nEndFontMetrics\n";
let owned: OwnedFontMetrics = parse(src)?.into_owned();

assert_eq!(owned.font_bbox.urx, 1000.0);

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 · 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> 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 · 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.