class TTFunk::Table::Cmap
Character to Glyph Index Mapping (‘cmap`) table.
Attributes
Encoding tables. @return [Array<TTFunk::Table::Cmap::Subtable>]
Table
version. @return [Integer]
Public Class Methods
Source
# File lib/ttfunk/table/cmap.rb, line 27 def self.encode(charmap, encoding) result = Cmap::Subtable.encode(charmap, encoding) # pack 'version' and 'table-count' result[:table] = [0, 1, result.delete(:subtable)].pack('nnA*') result end
Encode table.
@param charmap [Hash{Integer => Integer}] @param encoding [Symbol] @return [Hash]
* `:charmap` (<tt>Hash{Integer => Hash}</tt>) keys are the characrers in `charset`, values are hashes: * `:old` (<tt>Integer</tt>) - glyph ID in the original font. * `:new` (<tt>Integer</tt>) - glyph ID in the subset font. that maps the characters in charmap to a * `:table` (<tt>String</tt>) - serialized table. * `:max_glyph_id` (<tt>Integer</tt>) - maximum glyph ID in the new font.
Public Instance Methods
Source
# File lib/ttfunk/table/cmap.rb, line 38 def unicode # Because most callers just call .first on the result, put tables with # highest-number format first. Unsupported formats will be ignored. @unicode ||= @tables .select { |table| table.unicode? && table.supported? } .sort { |a, b| b.format <=> a.format } end
Get Unicode encoding records.
@return [Array<TTFunk::Table::Cmap::Subtable>]
Private Instance Methods
Source
# File lib/ttfunk/table/cmap.rb, line 49 def parse! @version, table_count = read(4, 'nn') @tables = Array.new(table_count) do Cmap::Subtable.new(file, offset) end end