Skip to main content

CharacterMetric

Struct CharacterMetric 

Source
pub struct CharacterMetric<'a> {
    pub code: i32,
    pub name: Cow<'a, str>,
    pub width_x: f32,
    pub bbox: Option<BBox>,
}
Expand description

One entry from a StartCharMetrics block.

§Examples

use std::borrow::Cow;

use adobe_font_metrics::{BBox, CharacterMetric};

let metric = CharacterMetric {
    code: 65,
    name: Cow::Borrowed("A"),
    width_x: 667.0,
    bbox: Some(BBox {
        llx: 8.0,
        lly: 0.0,
        urx: 660.0,
        ury: 718.0,
    }),
};

assert_eq!(metric.name, "A");

Fields§

§code: i32

Encoding-table code, or -1 if the glyph is unencoded. i32 to accommodate multi-byte CH <hex> codes (e.g. CJK fonts where values exceed i16::MAX).

§name: Cow<'a, str>

PostScript glyph name (e.g. "A", "section").

§width_x: f32

Horizontal advance in 1/1000 em.

§bbox: Option<BBox>

Glyph bounding box if the AFM provided one.

Implementations§

Source§

impl<'a> CharacterMetric<'a>

Source

pub fn into_owned(self) -> CharacterMetric<'static>

Lift to 'static by cloning any borrowed strings.

§Examples
use std::borrow::Cow;

use adobe_font_metrics::CharacterMetric;

let metric = CharacterMetric {
    code: 65,
    name: Cow::Borrowed("A"),
    width_x: 667.0,
    bbox: None,
};
let owned = metric.into_owned();

assert_eq!(owned.name, "A");

Trait Implementations§

Source§

impl<'a> Clone for CharacterMetric<'a>

Source§

fn clone(&self) -> CharacterMetric<'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 CharacterMetric<'a>

Source§

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

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

impl<'a> PartialEq for CharacterMetric<'a>

Source§

fn eq(&self, other: &CharacterMetric<'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 CharacterMetric<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for CharacterMetric<'a>

§

impl<'a> RefUnwindSafe for CharacterMetric<'a>

§

impl<'a> Send for CharacterMetric<'a>

§

impl<'a> Sync for CharacterMetric<'a>

§

impl<'a> Unpin for CharacterMetric<'a>

§

impl<'a> UnsafeUnpin for CharacterMetric<'a>

§

impl<'a> UnwindSafe for CharacterMetric<'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.