Class: PDF::Reader::CMap

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

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ CMap

Returns a new instance of CMap.



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/pdf/reader/cmap.rb', line 29

def initialize(data)
  @map = {}
  inmap = false
  data.each_line do |l|
    inmap = true if l.include?("beginbfchar")
    if inmap
      m, find, replace = *l.match(/<([0-9a-fA-F]+)> <([0-9a-fA-F]+)>/)
      @map["0x#{find}".hex] = "0x#{replace}".hex if find && replace
    end
  end
end

Instance Method Details

#decode(c) ⇒ Object



41
42
43
44
45
# File 'lib/pdf/reader/cmap.rb', line 41

def decode(c)
  # TODO: implement the conversion
  Error.assert_equal(c.class, Fixnum)
  @map[c]
end