Class: TTFunk::Table
- Inherits:
-
Object
- Object
- TTFunk::Table
- Includes:
- Reader
- Defined in:
- lib/ttfunk/table.rb,
lib/ttfunk/table/cff.rb,
lib/ttfunk/table/os2.rb,
lib/ttfunk/table/cmap.rb,
lib/ttfunk/table/dsig.rb,
lib/ttfunk/table/glyf.rb,
lib/ttfunk/table/head.rb,
lib/ttfunk/table/hhea.rb,
lib/ttfunk/table/hmtx.rb,
lib/ttfunk/table/kern.rb,
lib/ttfunk/table/loca.rb,
lib/ttfunk/table/maxp.rb,
lib/ttfunk/table/name.rb,
lib/ttfunk/table/post.rb,
lib/ttfunk/table/sbix.rb,
lib/ttfunk/table/vorg.rb,
lib/ttfunk/table/simple.rb,
lib/ttfunk/table/cff/dict.rb,
lib/ttfunk/table/cff/path.rb,
lib/ttfunk/table/cff/index.rb,
lib/ttfunk/table/cff/header.rb,
lib/ttfunk/table/cff/charset.rb,
lib/ttfunk/table/glyf/simple.rb,
lib/ttfunk/table/cff/charsets.rb,
lib/ttfunk/table/cff/encoding.rb,
lib/ttfunk/table/cff/top_dict.rb,
lib/ttfunk/table/kern/format0.rb,
lib/ttfunk/table/cff/encodings.rb,
lib/ttfunk/table/cff/font_dict.rb,
lib/ttfunk/table/cff/top_index.rb,
lib/ttfunk/table/cmap/format00.rb,
lib/ttfunk/table/cmap/format04.rb,
lib/ttfunk/table/cmap/format06.rb,
lib/ttfunk/table/cmap/format10.rb,
lib/ttfunk/table/cmap/format12.rb,
lib/ttfunk/table/cmap/subtable.rb,
lib/ttfunk/table/glyf/compound.rb,
lib/ttfunk/table/post/format10.rb,
lib/ttfunk/table/post/format20.rb,
lib/ttfunk/table/post/format30.rb,
lib/ttfunk/table/post/format40.rb,
lib/ttfunk/table/cff/charstring.rb,
lib/ttfunk/table/cff/font_index.rb,
lib/ttfunk/table/cff/subr_index.rb,
lib/ttfunk/table/cff/fd_selector.rb,
lib/ttfunk/table/glyf/path_based.rb,
lib/ttfunk/table/cff/private_dict.rb,
lib/ttfunk/table/cff/charsets/expert.rb,
lib/ttfunk/table/cff/one_based_index.rb,
lib/ttfunk/table/cff/encodings/expert.rb,
lib/ttfunk/table/cff/charstrings_index.rb,
lib/ttfunk/table/cff/charsets/iso_adobe.rb,
lib/ttfunk/table/cff/encodings/standard.rb,
lib/ttfunk/table/cff/charsets/expert_subset.rb,
lib/ttfunk/table/cff/charsets/standard_strings.rb
Overview
SFNT table
Direct Known Subclasses
Cff, Cmap, Dsig, Glyf, Head, Hhea, Hmtx, Kern, Loca, Maxp, Name, OS2, Post, Sbix, Simple, Vorg
Defined Under Namespace
Classes: Cff, Cmap, Dsig, Glyf, Head, Hhea, Hmtx, Kern, Loca, Maxp, Name, OS2, Post, Sbix, Simple, Vorg
Instance Attribute Summary collapse
-
#file ⇒ TTFunk::File
readonly
File this table is in.
-
#length ⇒ Integer?
readonly
This table’s length in byes.
-
#offset ⇒ Integer
readonly
This table’s offset from the file beginning.
Instance Method Summary collapse
-
#exists? ⇒ Boolean
Does this table exist in the file?.
-
#initialize(file) ⇒ Table
constructor
A new instance of Table.
-
#raw ⇒ String?
Raw bytes of this table in the file.
-
#tag ⇒ String
Table tag.
Constructor Details
#initialize(file) ⇒ Table
Returns a new instance of Table.
Source Code
lib/ttfunk/table.rb, line 23
23 | def initialize(file) |
24 | @file = file |
25 | @offset = nil |
26 | @length = nil |
27 | |
28 | info = file.directory_info(tag) |
29 | |
30 | if info |
31 | @offset = info[:offset] |
32 | @length = info[:length] |
33 | |
34 | parse_from(@offset) { parse! } |
35 | end
|
36 | end
|
Instance Attribute Details
#file ⇒ TTFunk::File (readonly)
File this table is in.
Source Code
lib/ttfunk/table.rb, line 12
12 | def file |
13 | @file
|
14 | end
|
#length ⇒ Integer? (readonly)
This table’s length in byes.
Source Code
lib/ttfunk/table.rb, line 20
20 | def length |
21 | @length
|
22 | end
|
#offset ⇒ Integer (readonly)
This table’s offset from the file beginning.
Source Code
lib/ttfunk/table.rb, line 16
16 | def offset |
17 | @offset
|
18 | end
|
Instance Method Details
#exists? ⇒ Boolean
Does this table exist in the file?
Source Code
lib/ttfunk/table.rb, line 41
41 | def exists? |
42 | !@offset.nil? |
43 | end
|
#raw ⇒ String?
Raw bytes of this table in the file.
Source Code
lib/ttfunk/table.rb, line 48
48 | def raw |
49 | if exists? |
50 | parse_from(offset) { io.read(length) } |
51 | end
|
52 | end
|
#tag ⇒ String
Table tag.
Source Code
lib/ttfunk/table.rb, line 57
57 | def tag |
58 | self.class.name.split('::').last.downcase |
59 | end
|