Class: TTFunk::Directory

Inherits:
Object
  • Object
show all
Defined in:
lib/ttfunk/directory.rb

Overview

SFNT table directory.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io, offset = 0) ⇒ Directory

Returns a new instance of Directory.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ttfunk/directory.rb', line 14

def initialize(io, offset = 0)
  io.seek(offset)

  # https://www.microsoft.com/typography/otspec/otff.htm#offsetTable
  # We're ignoring searchRange, entrySelector, and rangeShift here, but
  # skipping past them to get to the table information.
  @scaler_type, table_count = io.read(12).unpack('Nn')

  @tables = {}
  table_count.times do
    tag, checksum, offset, length = io.read(16).unpack('a4N*')
    @tables[tag] = {
      tag: tag,
      checksum: checksum,
      offset: offset,
      length: length,
    }
  end
end

Instance Attribute Details

#scaler_typeInteger (readonly)

Scaler type

Returns:

  • (Integer)


12
13
14
# File 'lib/ttfunk/directory.rb', line 12

def scaler_type
  @scaler_type
end

#tablesHash{String => Hash} (readonly)

Table descriptors

Returns:

  • (Hash{String => Hash})


8
9
10
# File 'lib/ttfunk/directory.rb', line 8

def tables
  @tables
end