Class: PDF::Reader::CMap

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf/reader/cmap.rb

Overview

wraps a string containing a PDF CMap and provides convenience methods for extracting various useful information.

Constant Summary collapse

CMAP_KEYWORDS =

:nodoc:

{
  "begincodespacerange" => :noop,
  "endcodespacerange" => :noop,
  "beginbfchar" => :noop,
  "endbfchar" => :noop,
  "beginbfrange" => :noop,
  "endbfrange" => :noop,
  "begin" => :noop,
  "begincmap" => :noop,
  "def" => :noop
}
HIGH_SURROGATE_RANGE =

Indicates the start of a UTF-16 surrogate pair, see en.wikipedia.org/wiki/Universal_Character_Set_characters

(0xD800..0xDBFF)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ CMap

: (String) -> void



57
58
59
60
# File 'lib/pdf/reader/cmap.rb', line 57

def initialize(data)
  @map = {} #: Hash[Integer, Array[Integer]]
  process_data(data)
end

Instance Attribute Details

#mapObject (readonly)

: Hash[Integer, Array]



54
55
56
# File 'lib/pdf/reader/cmap.rb', line 54

def map
  @map
end

Instance Method Details

#decode(c) ⇒ Object

Convert a glyph code into one or more Codepoints.

Returns an array of Integers.

: (Integer) -> Array



72
73
74
# File 'lib/pdf/reader/cmap.rb', line 72

def decode(c)
  @map.fetch(c, [])
end

#sizeObject

: () -> Integer



63
64
65
# File 'lib/pdf/reader/cmap.rb', line 63

def size
  @map.size
end