Class: TTFunk::Table::Loca
- Inherits:
-
TTFunk::Table
- Object
- TTFunk::Table
- TTFunk::Table::Loca
- Defined in:
- lib/ttfunk/table/loca.rb
Overview
Index to Location table.
Instance Attribute Summary collapse
-
#offsets ⇒ Array<Integer>
readonly
Glyph ofsets.
Attributes inherited from TTFunk::Table
Class Method Summary collapse
-
.encode(offsets) ⇒ Hash
Encode table.
Instance Method Summary collapse
-
#index_of(glyph_id) ⇒ Integer
Glyph offset by ID.
-
#size_of(glyph_id) ⇒ Integer
Size of encoded glyph.
Methods inherited from TTFunk::Table
#exists?, #initialize, #raw, #tag
Constructor Details
This class inherits a constructor from TTFunk::Table
Instance Attribute Details
#offsets ⇒ Array<Integer> (readonly)
Glyph ofsets
Source Code
lib/ttfunk/table/loca.rb, line 11
11 | def offsets |
12 | @offsets
|
13 | end
|
Class Method Details
.encode(offsets) ⇒ Hash
Encode table.
Source Code
lib/ttfunk/table/loca.rb, line 22
22 | def self.encode(offsets) |
23 | long_offsets = |
24 | offsets.any? { |offset| |
25 | short_offset = offset / 2 |
26 | short_offset * 2 != offset || short_offset > 0xffff |
27 | }
|
28 | |
29 | if long_offsets |
30 | { type: 1, table: offsets.pack('N*') } |
31 | else
|
32 | { type: 0, table: offsets.map { |o| o / 2 }.pack('n*') } |
33 | end
|
34 | end
|
Instance Method Details
#index_of(glyph_id) ⇒ Integer
Glyph offset by ID.
Source Code
lib/ttfunk/table/loca.rb, line 40
40 | def index_of(glyph_id) |
41 | @offsets[glyph_id] |
42 | end
|
#size_of(glyph_id) ⇒ Integer
Size of encoded glyph.
Source Code
lib/ttfunk/table/loca.rb, line 48
48 | def size_of(glyph_id) |
49 | @offsets[glyph_id + 1] - @offsets[glyph_id] |
50 | end
|