Class: Fontisan::Ufo::Font

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFont

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

#dataObject (readonly)

Returns the value of attribute data.



15
16
17
# File 'lib/fontisan/ufo/font.rb', line 15

def data
  @data
end

#featuresObject

Returns the value of attribute features.



14
15
16
# File 'lib/fontisan/ufo/font.rb', line 14

def features
  @features
end

#imagesObject (readonly)

Returns the value of attribute images.



15
16
17
# File 'lib/fontisan/ufo/font.rb', line 15

def images
  @images
end

#infoObject

Returns the value of attribute info.



14
15
16
# File 'lib/fontisan/ufo/font.rb', line 14

def info
  @info
end

#kerningObject

Returns the value of attribute kerning.



14
15
16
# File 'lib/fontisan/ufo/font.rb', line 14

def kerning
  @kerning
end

#layersObject (readonly)

Returns the value of attribute layers.



15
16
17
# File 'lib/fontisan/ufo/font.rb', line 15

def layers
  @layers
end

#libObject

Returns the value of attribute lib.



14
15
16
# File 'lib/fontisan/ufo/font.rb', line 14

def lib
  @lib
end

#pathObject

Returns the value of attribute path.



14
15
16
# File 'lib/fontisan/ufo/font.rb', line 14

def path
  @path
end

#ufo_versionObject

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.

Parameters:

  • path (String, Pathname)

    directory containing the UFO

Returns:



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_glyphObject

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_nameObject

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

#glyphsObject

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