Class: Fontisan::Ufo::Font
- Inherits:
-
Object
- Object
- Fontisan::Ufo::Font
- Defined in:
- lib/fontisan/ufo/font.rb
Overview
Top-level container for a UFO source directory.
A Fontisan::Ufo::Font corresponds to one .ufo directory. It
exposes typed access to the font's metadata, layers, kerning,
features, and any custom data.
The class is the read/write API; serialization is handled by Fontisan::Ufo::Reader and Fontisan::Ufo::Writer.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#features ⇒ Object
Returns the value of attribute features.
-
#images ⇒ Object
readonly
Returns the value of attribute images.
-
#info ⇒ Object
Returns the value of attribute info.
-
#kerning ⇒ Object
Returns the value of attribute kerning.
-
#layers ⇒ Object
readonly
Returns the value of attribute layers.
-
#lib ⇒ Object
Returns the value of attribute lib.
-
#path ⇒ Object
Returns the value of attribute path.
-
#ufo_version ⇒ Object
Returns the value of attribute ufo_version.
Class Method Summary collapse
-
.open(path) ⇒ Fontisan::Ufo::Font
The parsed font.
Instance Method Summary collapse
-
#each_glyph ⇒ Object
Convenience: iterate every glyph in every layer.
-
#family_name ⇒ Object
Convenience: read family name through the Info model.
-
#glyph(name) ⇒ Object
Convenience: lookup a glyph in the default layer by name.
-
#glyphs ⇒ Object
Convenience accessor for the default layer's glyphs.
-
#initialize ⇒ Font
constructor
A new instance of Font.
Constructor Details
#initialize ⇒ Font
Returns a new instance of Font.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fontisan/ufo/font.rb', line 17 def initialize @path = nil @ufo_version = nil @info = Info.new @layers = LayerSet.new @features = Features.new @kerning = Kerning.new @lib = Lib.new @data = nil # DataSet needs the Font ref, set by Reader @images = ImageSet.new end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
15 16 17 |
# File 'lib/fontisan/ufo/font.rb', line 15 def data @data end |
#features ⇒ Object
Returns the value of attribute features.
14 15 16 |
# File 'lib/fontisan/ufo/font.rb', line 14 def features @features end |
#images ⇒ Object (readonly)
Returns the value of attribute images.
15 16 17 |
# File 'lib/fontisan/ufo/font.rb', line 15 def images @images end |
#info ⇒ Object
Returns the value of attribute info.
14 15 16 |
# File 'lib/fontisan/ufo/font.rb', line 14 def info @info end |
#kerning ⇒ Object
Returns the value of attribute kerning.
14 15 16 |
# File 'lib/fontisan/ufo/font.rb', line 14 def kerning @kerning end |
#layers ⇒ Object (readonly)
Returns the value of attribute layers.
15 16 17 |
# File 'lib/fontisan/ufo/font.rb', line 15 def layers @layers end |
#lib ⇒ Object
Returns the value of attribute lib.
14 15 16 |
# File 'lib/fontisan/ufo/font.rb', line 14 def lib @lib end |
#path ⇒ Object
Returns the value of attribute path.
14 15 16 |
# File 'lib/fontisan/ufo/font.rb', line 14 def path @path end |
#ufo_version ⇒ Object
Returns the value of attribute ufo_version.
14 15 16 |
# File 'lib/fontisan/ufo/font.rb', line 14 def ufo_version @ufo_version end |
Class Method Details
.open(path) ⇒ Fontisan::Ufo::Font
Returns the parsed font.
53 54 55 56 57 58 |
# File 'lib/fontisan/ufo/font.rb', line 53 def self.open(path) font = new font.path = path.to_s Reader.new(font).read font end |
Instance Method Details
#each_glyph ⇒ Object
Convenience: iterate every glyph in every layer.
45 46 47 48 49 |
# File 'lib/fontisan/ufo/font.rb', line 45 def each_glyph(&) @layers.each do |layer| layer.each(&) end end |
#family_name ⇒ Object
Convenience: read family name through the Info model.
40 41 42 |
# File 'lib/fontisan/ufo/font.rb', line 40 def family_name @info.family_name end |
#glyph(name) ⇒ Object
Convenience: lookup a glyph in the default layer by name.
35 36 37 |
# File 'lib/fontisan/ufo/font.rb', line 35 def glyph(name) @layers.default_layer[name] end |
#glyphs ⇒ Object
Convenience accessor for the default layer's glyphs.
30 31 32 |
# File 'lib/fontisan/ufo/font.rb', line 30 def glyphs @layers.default_layer.glyphs end |