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.
Source Code
lib/ttfunk/sub_table.rb, line 29
29 | def initialize(file, offset, length = nil) |
30 | @file = file |
31 | @table_offset = offset |
32 | @length = length |
33 | parse_from(@table_offset) { parse! } |
34 | end
|
Instance Attribute Details
#file ⇒ IO (readonly)
File or IO this sub-table is in.
Source Code
lib/ttfunk/sub_table.rb, line 16
16 | def file |
17 | @file
|
18 | end
|
#length ⇒ Integer? (readonly)
This sub-table’s length in byes.
Source Code
lib/ttfunk/sub_table.rb, line 24
24 | def length |
25 | @length
|
26 | end
|
#table_offset ⇒ Integer (readonly)
This sub-table’s offset from the file beginning.
Source Code
lib/ttfunk/sub_table.rb, line 20
20 | def table_offset |
21 | @table_offset
|
22 | end
|
Instance Method Details
#eot? ⇒ Boolean
End of sub-table?
Source Code
lib/ttfunk/sub_table.rb, line 39
39 | def eot? |
40 | # if length isn't set yet there's no way to know if we're at the end of
|
41 | # the sub-table or not
|
42 | return false unless length |
43 | |
44 | io.pos > table_offset + length |
45 | end
|
#read(bytes, format) ⇒ Array
Read a series of values.
Source Code
lib/ttfunk/sub_table.rb, line 55
55 | def read(*args) |
56 | if eot? |
57 | raise EOTError, 'attempted to read past the end of the table' |
58 | end
|
59 | |
60 | super
|
61 | end
|