Class: Tipo::Header

Inherits:
Object
  • Object
show all
Defined in:
lib/tipo/header.rb

Defined Under Namespace

Classes: OffsetTable, TableRecord

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(font) ⇒ Header

Returns a new instance of Header.



11
12
13
# File 'lib/tipo/header.rb', line 11

def initialize font 
  @font = font 
end

Instance Attribute Details

#fontObject (readonly)

Returns the value of attribute font.



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

def font
  @font
end

Instance Method Details

#offset_tableObject



15
16
17
# File 'lib/tipo/header.rb', line 15

def offset_table
  OffsetTable.new *(font.unpack seek: 0, bytes: 12, tmpl: 'a4n')
end

#table_recordsObject



19
20
21
22
23
24
# File 'lib/tipo/header.rb', line 19

def table_records
  font.seek 13 
  offset_table.tables_count.times.map do
    TableRecord.new *(font.unpack bytes: 16, tmpl: 'a4N2')
  end
end