Struct norad::Glyph

source ·
pub struct Glyph {
    pub height: f64,
    pub width: f64,
    pub codepoints: Codepoints,
    pub note: Option<String>,
    pub guidelines: Vec<Guideline>,
    pub anchors: Vec<Anchor>,
    pub components: Vec<Component>,
    pub contours: Vec<Contour>,
    pub image: Option<Image>,
    pub lib: Plist,
    /* private fields */
}
Expand description

A glyph, loaded from a .glif file.

Norad can load glif version 1.0 and 2.0, and can save 2.0 only.

Fields§

§height: f64

Glyph height.

§width: f64

Glyph width.

§codepoints: Codepoints

A collection of glyph Unicode code points.

The first entry defines the primary Unicode value for this glyph.

§note: Option<String>

Arbitrary glyph note.

§guidelines: Vec<Guideline>

A collection of glyph guidelines.

§anchors: Vec<Anchor>

A collection of glyph anchors.

§components: Vec<Component>

A collection of glyph components.

§contours: Vec<Contour>

A collection of glyph contours.

§image: Option<Image>

Glyph image data.

§lib: Plist

Glyph library data.

Implementations§

source§

impl Glyph

source

pub fn encode_xml(&self) -> Result<Vec<u8>, GlifWriteError>

Serialize the glyph into an XML byte stream.

The order of elements and attributes follows ufonormalizer where possible.

source

pub fn encode_xml_with_options( &self, opts: &WriteOptions ) -> Result<Vec<u8>, GlifWriteError>

Serialize the glyph into an XML byte stream with custom string formatting.

The order of elements and attributes follows ufonormalizer where possible.

source§

impl Glyph

source

pub fn load(path: impl AsRef<Path>) -> Result<Self, GlifLoadError>

Attempt to parse a Glyph from a .glif at the provided path.

source

pub fn new(name: &str) -> Self

Returns a new, “empty” Glyph with the given name.

§Panics

panics if name is empty or if it contains any control characters.

source

pub fn name(&self) -> &Name

Returns the name of the glyph.

source

pub fn has_component(&self) -> bool

Returns true if Glyph contains one or more Components.

source

pub fn component_count(&self) -> usize

Returns the number of Components in the Glyph.

source

pub fn has_component_with_base(&self, basename: &str) -> bool

Returns true if the Glyph contains one or more Components with base glyph name basename.

source

pub fn get_components_with_base<'b, 'a: 'b>( &'a self, basename: &'b str ) -> impl Iterator<Item = &'a Component> + 'b

Returns an iterator over immutable Component references filtered by base glyph name.

Trait Implementations§

source§

impl Clone for Glyph

source§

fn clone(&self) -> Glyph

Returns a copy 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 Debug for Glyph

source§

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

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

impl PartialEq for Glyph

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for Glyph

Auto Trait Implementations§

§

impl Freeze for Glyph

§

impl RefUnwindSafe for Glyph

§

impl Send for Glyph

§

impl Sync for Glyph

§

impl Unpin for Glyph

§

impl UnwindSafe for Glyph

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> 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,

§

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>,

§

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>,

§

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.