Class: TTFunk::Table::Cmap
- Inherits:
-
TTFunk::Table
- Object
- TTFunk::Table
- TTFunk::Table::Cmap
- Defined in:
- lib/ttfunk/table/cmap.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
Overview
Character to Glyph Index Mapping (cmap
) table.
Defined Under Namespace
Modules: Format00, Format04, Format06, Format10, Format12 Classes: Subtable
Instance Attribute Summary collapse
-
#tables ⇒ Array<TTFunk::Table::Cmap::Subtable>
readonly
Encoding tables.
-
#version ⇒ Integer
readonly
Table version.
Attributes inherited from TTFunk::Table
Class Method Summary collapse
-
.encode(charmap, encoding) ⇒ Hash
Encode table.
Instance Method Summary collapse
-
#unicode ⇒ Array<TTFunk::Table::Cmap::Subtable>
Get Unicode encoding records.
Methods inherited from TTFunk::Table
#exists?, #initialize, #raw, #tag
Constructor Details
This class inherits a constructor from TTFunk::Table
Instance Attribute Details
#tables ⇒ Array<TTFunk::Table::Cmap::Subtable> (readonly)
Encoding tables.
Source Code
lib/ttfunk/table/cmap.rb, line 13
13 | def tables |
14 | @tables
|
15 | end
|
#version ⇒ Integer (readonly)
Table version.
Source Code
lib/ttfunk/table/cmap.rb, line 9
9 | def version |
10 | @version
|
11 | end
|
Class Method Details
.encode(charmap, encoding) ⇒ Hash
Encode table.
Source Code
lib/ttfunk/table/cmap.rb, line 27
27 | def self.encode(charmap, encoding) |
28 | result = Cmap::Subtable.encode(charmap, encoding) |
29 | |
30 | # pack 'version' and 'table-count'
|
31 | result[:table] = [0, 1, result.delete(:subtable)].pack('nnA*') |
32 | result
|
33 | end
|
Instance Method Details
#unicode ⇒ Array<TTFunk::Table::Cmap::Subtable>
Get Unicode encoding records.
Source Code
lib/ttfunk/table/cmap.rb, line 38
38 | def unicode |
39 | # Because most callers just call .first on the result, put tables with
|
40 | # highest-number format first. Unsupported formats will be ignored.
|
41 | @unicode ||= |
42 | @tables
|
43 | .select { |table| table.unicode? && table.supported? } |
44 | .sort { |a, b| b.format <=> a.format } |
45 | end
|