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
impl Glyph
sourcepub fn encode_xml(&self) -> Result<Vec<u8>, GlifWriteError>
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.
sourcepub fn encode_xml_with_options(
&self,
opts: &WriteOptions
) -> Result<Vec<u8>, GlifWriteError>
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
impl Glyph
sourcepub fn load(path: impl AsRef<Path>) -> Result<Self, GlifLoadError>
pub fn load(path: impl AsRef<Path>) -> Result<Self, GlifLoadError>
Attempt to parse a Glyph
from a .glif
at the provided path.
sourcepub fn new(name: &str) -> Self
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.
sourcepub fn has_component(&self) -> bool
pub fn has_component(&self) -> bool
sourcepub fn component_count(&self) -> usize
pub fn component_count(&self) -> usize
Returns the number of Component
s in the Glyph.
sourcepub fn has_component_with_base(&self, basename: &str) -> bool
pub fn has_component_with_base(&self, basename: &str) -> bool
Returns true if the Glyph contains one or more Component
s with base
glyph name basename
.