Class: Fontisan::Ufo::Layer

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#glyphsObject (readonly)

Returns the value of attribute glyphs.



13
14
15
# File 'lib/fontisan/ufo/layer.rb', line 13

def glyphs
  @glyphs
end

#nameObject (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

#eachObject



29
30
31
# File 'lib/fontisan/ufo/layer.rb', line 29

def each(&)
  @glyphs.each_value(&)
end

#sizeObject



33
34
35
# File 'lib/fontisan/ufo/layer.rb', line 33

def size
  @glyphs.size
end