class TTFunk::SubTable

SFNT sub-table

Attributes

file[R]

File or IO this sub-table is in. @return [IO]

length[R]

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

table_offset[R]

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

Public Class Methods

new(file, offset, length = nil) click to toggle source

@param file [IO] @param offset [Integer] @param length [Integer]

# File lib/ttfunk/sub_table.rb, line 29
def initialize(file, offset, length = nil)
  @file = file
  @table_offset = offset
  @length = length
  parse_from(@table_offset) { parse! }
end

Public Instance Methods

eot?() click to toggle source

End of sub-table?

@return [Boolean]

# File lib/ttfunk/sub_table.rb, line 39
def eot?
  # if length isn't set yet there's no way to know if we're at the end of
  # the sub-table or not
  return false unless length

  io.pos > table_offset + length
end
read(*args) click to toggle source

Read a series of values.

@overload read(bytes, format)

@param bytes [Integer] number of bytes to read.
@param format [String] format to parse the bytes.
@return [Array]
@raise [EOTError]
@see # Ruby Packed data
Calls superclass method TTFunk::Reader#read
# File lib/ttfunk/sub_table.rb, line 55
def read(*args)
  if eot?
    raise EOTError, 'attempted to read past the end of the table'
  end

  super
end