Module: HexaPDF::Font::TrueType::Table::CmapSubtable::Format0

Defined in:
lib/hexapdf/font/true_type/table/cmap_subtable.rb

Overview

Cmap format 0

Class Method Summary collapse

Class Method Details

.parse(io, length) ⇒ Object

:call-seq:

Format0.parse(io, length)    -> code_map

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.

Raises:



177
178
179
180
181
182
183
# File 'lib/hexapdf/font/true_type/table/cmap_subtable.rb', line 177

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