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: f32Italic angle in degrees, counter-clockwise from vertical.
is_fixed_pitch: booltrue if every glyph has the same advance width.
font_bbox: BBoxBounding box that contains every glyph in the font.
underline_position: f32Recommended y position of the underline, in 1/1000 em.
underline_thickness: f32Recommended thickness of the underline, in 1/1000 em.
cap_height: f32Height of an unaccented capital, in 1/1000 em.
x_height: f32Height of a lowercase x, in 1/1000 em.
ascender: f32Ascender height, in 1/1000 em.
descender: f32Descender 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>
impl<'a> FontMetrics<'a>
Sourcepub fn into_owned(self) -> OwnedFontMetrics
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>
impl<'a> Clone for FontMetrics<'a>
Source§fn clone(&self) -> FontMetrics<'a>
fn clone(&self) -> FontMetrics<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more