class TTFunk::Table::Cmap

Attributes

tables[R]
version[R]

Public Class Methods

encode(charmap, encoding) click to toggle source
# File lib/ttfunk/table/cmap.rb, line 7
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

Public Instance Methods

unicode() click to toggle source
# File lib/ttfunk/table/cmap.rb, line 15
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

Private Instance Methods

parse!() click to toggle source
# File lib/ttfunk/table/cmap.rb, line 25
def parse!
  @version, table_count = read(4, 'nn')
  @tables = []

  table_count.times do
    @tables << Cmap::Subtable.new(file, offset)
  end
end