Class: Tipo::Font

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/tipo/font.rb

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Font

Returns a new instance of Font.



9
10
11
# File 'lib/tipo/font.rb', line 9

def initialize file
  @file = File.open file, 'rb:ASCII-8BIT'
end

Instance Method Details

#chunk(options) ⇒ Object



17
18
19
20
# File 'lib/tipo/font.rb', line 17

def chunk options
  @file.seek options[:seek] if options[:seek]
  @file.read options.fetch :bytes
end

#encodingObject



13
14
15
# File 'lib/tipo/font.rb', line 13

def encoding
  @file.read(5).encoding
end

#unpack(options) ⇒ Object



22
23
24
25
# File 'lib/tipo/font.rb', line 22

def unpack options
  tmpl = options.delete :tmpl
  chunk(options).unpack tmpl
end