class TTFunk::Table

SFNT table

Attributes

file[R]

File this table is in. @return [TTFunk::File]

length[R]

This table’s length in byes. @return [Integer, nil]

offset[R]

This table’s offset from the file beginning. @return [Integer]

Public Class Methods

new(file) click to toggle source

@param file [TTFunk::File]

# File lib/ttfunk/table.rb, line 23
def initialize(file)
  @file = file
  @offset = nil
  @length = nil

  info = file.directory_info(tag)

  if info
    @offset = info[:offset]
    @length = info[:length]

    parse_from(@offset) { parse! }
  end
end

Public Instance Methods

exists?() click to toggle source

Does this table exist in the file?

@return [Boolean]

# File lib/ttfunk/table.rb, line 41
def exists?
  !@offset.nil?
end
raw() click to toggle source

Raw bytes of this table in the file.

@return [String, nil]

# File lib/ttfunk/table.rb, line 48
def raw
  if exists?
    parse_from(offset) { io.read(length) }
  end
end
tag() click to toggle source

Table tag.

@return [String]

# File lib/ttfunk/table.rb, line 57
def tag
  self.class.name.split('::').last.downcase
end

Private Instance Methods

parse!() click to toggle source
# File lib/ttfunk/table.rb, line 63
def parse!
  # do nothing, by default
end