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*")
  return 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.
  # (Tables with higher format numbers tend to be more complete, especially in higher/astral Unicode ranges.)
  @unicode ||= @tables.select { |table| table.unicode? }.sort{|a,b| b.format <=> a.format }
end

Private Instance Methods

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

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