module HexaPDF::Font::TrueType::Table::CmapSubtable::Format0

Cmap format 0

Public Class Methods

parse(io, length) → code_map click to toggle source

Parses the format 0 cmap subtable from the given IO at the current position and returns the contained code map.

It is assumed that the first six bytes of the subtable have already been consumed.

# File lib/hexapdf/font/true_type/table/cmap_subtable.rb, line 176
def self.parse(io, length)
  raise HexaPDF::Error, "Invalid length #{length} for cmap format 0" if length != 262
  code_map = io.read(256).unpack('C*')
  gid_map = {}
  code_map.each_with_index {|glyph, index| gid_map[glyph] = index }
  [code_map, gid_map]
end