Class: TTFunk::SubTable
- Inherits:
-
Object
- Object
- TTFunk::SubTable
- Includes:
- Reader
- Defined in:
- lib/ttfunk/sub_table.rb
Overview
SFNT sub-table
Direct Known Subclasses
Table::Cff::Charset, Table::Cff::Dict, Table::Cff::Encoding, Table::Cff::FdSelector, Table::Cff::Header, Table::Cff::Index
Defined Under Namespace
Classes: EOTError
Instance Attribute Summary collapse
-
#file ⇒ IO
readonly
File or IO this sub-table is in.
-
#length ⇒ Integer?
readonly
This sub-table’s length in byes.
-
#table_offset ⇒ Integer
readonly
This sub-table’s offset from the file beginning.
Instance Method Summary collapse
-
#eot? ⇒ Boolean
End of sub-table?.
-
#initialize(file, offset, length = nil) ⇒ SubTable
constructor
A new instance of SubTable.
-
#read(bytes, format) ⇒ Array
Read a series of values.
Constructor Details
#initialize(file, offset, length = nil) ⇒ SubTable
Returns a new instance of SubTable.
29 30 31 32 33 34 |
# 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 |
Instance Attribute Details
#file ⇒ IO (readonly)
File or IO this sub-table is in.
16 17 18 |
# File 'lib/ttfunk/sub_table.rb', line 16 def file @file end |
#length ⇒ Integer? (readonly)
This sub-table’s length in byes.
24 25 26 |
# File 'lib/ttfunk/sub_table.rb', line 24 def length @length end |
#table_offset ⇒ Integer (readonly)
This sub-table’s offset from the file beginning.
20 21 22 |
# File 'lib/ttfunk/sub_table.rb', line 20 def table_offset @table_offset end |
Instance Method Details
#eot? ⇒ Boolean
End of sub-table?
39 40 41 42 43 44 45 |
# 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(bytes, format) ⇒ Array
Read a series of values.
55 56 57 58 59 60 61 |
# 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 |