Module: HexaPDF::Font::TrueType::Table::CmapSubtable::Format6
- Defined in:
- lib/hexapdf/font/true_type/table/cmap_subtable.rb
Overview
Cmap format 6
Class Method Summary collapse
-
.parse(io, _length) ⇒ Object
:call-seq: Format6.parse(io, length) -> code_map.
Class Method Details
.parse(io, _length) ⇒ Object
:call-seq:
Format6.parse(io, length) -> code_map
Parses the format 6 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.
322 323 324 325 326 327 328 329 330 331 |
# File 'lib/hexapdf/font/true_type/table/cmap_subtable.rb', line 322 def self.parse(io, _length) first_code, entry_count = io.read(4).unpack('n2') code_map = io.read(2 * entry_count).unpack('n*') gid_map = {} code_map = code_map.each_with_index.with_object({}) do |(g, i), hash| hash[first_code + i] = g gid_map[g] = first_code + i end [code_map, gid_map] end |