pub struct Layer {
pub color: Option<Color>,
pub lib: Plist,
/* private fields */
}
Expand description
A UFO layer, corresponding to a ‘glyphs’ sub-directory.
Conceptually, a layer is just a collection of glyphs.
Fields§
§color: Option<Color>
An optional color, specified in the layer’s layerinfo.plist
.
lib: Plist
Optional lib data for this layer.
An empty lib is not serialized.
Implementations§
source§impl Layer
impl Layer
sourcepub fn is_default(&self) -> bool
pub fn is_default(&self) -> bool
Returns true
if this layer is the default layer.
The default layer can have any name, but always uses the “glyphs” directory.
sourcepub fn name(&self) -> &Name
pub fn name(&self) -> &Name
Returns the name of the layer.
This can only be mutated through the LayerContents
.
sourcepub fn path(&self) -> &Path
pub fn path(&self) -> &Path
Returns the directory path of this layer.
This cannot be mutated; it is either provided when the layer is loaded, or we will create it for you. Maybe this is bad? We can talk about it, if you like.
sourcepub fn entry(&mut self, glyph: Name) -> Entry<'_, Name, Glyph>
pub fn entry(&mut self, glyph: Name) -> Entry<'_, Name, Glyph>
Gets the given key’s corresponding entry in the map for in-place manipulation.
sourcepub fn get_glyph(&self, glyph: &str) -> Option<&Glyph>
pub fn get_glyph(&self, glyph: &str) -> Option<&Glyph>
Returns a reference to the glyph with the given name, if it exists.
sourcepub fn get_glyph_mut(&mut self, glyph: &str) -> Option<&mut Glyph>
pub fn get_glyph_mut(&mut self, glyph: &str) -> Option<&mut Glyph>
Returns a mutable reference to the glyph with the given name, if it exists.
sourcepub fn contains_glyph(&self, name: &str) -> bool
pub fn contains_glyph(&self, name: &str) -> bool
Returns true
if this layer contains a glyph with this name
.
sourcepub fn insert_glyph(&mut self, glyph: impl Into<Glyph>)
pub fn insert_glyph(&mut self, glyph: impl Into<Glyph>)
Adds or updates the given glyph.
If the glyph does not previously exist, the filename is calculated from the glyph’s name.
sourcepub fn remove_glyph(&mut self, name: &str) -> Option<Glyph>
pub fn remove_glyph(&mut self, name: &str) -> Option<Glyph>
Remove the named glyph from this layer and return it, if it exists.
sourcepub fn rename_glyph(
&mut self,
old: &str,
new: &str,
overwrite: bool
) -> Result<(), NamingError>
pub fn rename_glyph( &mut self, old: &str, new: &str, overwrite: bool ) -> Result<(), NamingError>
Rename a glyph.
If overwrite
is true, and a glyph with the new name exists, it will
be replaced.
Returns an error if overwrite
is false but a glyph with the new
name exists, or if no glyph with the old name exists, or if the new
name is not a valid Name
.
sourcepub fn iter(&self) -> impl Iterator<Item = &Glyph> + '_
pub fn iter(&self) -> impl Iterator<Item = &Glyph> + '_
Returns an iterator over the glyphs in this layer.
sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Glyph>
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Glyph>
Returns an iterator over the glyphs in this layer, mutably.