Class: Fontisan::Ufo::Layer
- Inherits:
-
Object
- Object
- Fontisan::Ufo::Layer
- Defined in:
- lib/fontisan/ufo/layer.rb
Overview
A single layer in a UFO source. A Layer holds a set of glyphs
keyed by name. The default layer is public.default per UFO 3.
glyphs is mutated in place by Reader and Writer; the Layer does not own serialization concerns.
Constant Summary collapse
- DEFAULT_NAME =
"public.default"
Instance Attribute Summary collapse
-
#glyphs ⇒ Object
readonly
Returns the value of attribute glyphs.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #[](glyph_name) ⇒ Object
- #add(glyph) ⇒ Object
- #each ⇒ Object
-
#initialize(name = DEFAULT_NAME) ⇒ Layer
constructor
A new instance of Layer.
- #size ⇒ Object
Constructor Details
#initialize(name = DEFAULT_NAME) ⇒ Layer
Returns a new instance of Layer.
15 16 17 18 |
# File 'lib/fontisan/ufo/layer.rb', line 15 def initialize(name = DEFAULT_NAME) @name = name @glyphs = {} end |
Instance Attribute Details
#glyphs ⇒ Object (readonly)
Returns the value of attribute glyphs.
13 14 15 |
# File 'lib/fontisan/ufo/layer.rb', line 13 def glyphs @glyphs end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/fontisan/ufo/layer.rb', line 13 def name @name end |
Instance Method Details
#[](glyph_name) ⇒ Object
20 21 22 |
# File 'lib/fontisan/ufo/layer.rb', line 20 def [](glyph_name) @glyphs[glyph_name.to_s] end |
#add(glyph) ⇒ Object
24 25 26 27 |
# File 'lib/fontisan/ufo/layer.rb', line 24 def add(glyph) @glyphs[glyph.name.to_s] = glyph glyph end |
#each ⇒ Object
29 30 31 |
# File 'lib/fontisan/ufo/layer.rb', line 29 def each(&) @glyphs.each_value(&) end |
#size ⇒ Object
33 34 35 |
# File 'lib/fontisan/ufo/layer.rb', line 33 def size @glyphs.size end |