Class: PDF::Reader::CMap
- Inherits:
-
Object
- Object
- PDF::Reader::CMap
- 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 https://en.wikipedia.org/wiki/Universal_Character_Set_characters
(0xD800..0xDBFF)
- EMPTY_CODEPOINTS =
[].freeze
Instance Attribute Summary collapse
- #map ⇒ Object readonly
Instance Method Summary collapse
-
#decode(c) ⇒ Object
Convert a glyph code into one or more Codepoints.
-
#initialize(data) ⇒ CMap
constructor
A new instance of CMap.
- #size ⇒ Object
Constructor Details
#initialize(data) ⇒ CMap
Returns a new instance of CMap.
59 60 61 62 |
# File 'lib/pdf/reader/cmap.rb', line 59 def initialize(data) @map = {} #: Hash[Integer, Array[Integer]] process_data(data) end |
Instance Attribute Details
#map ⇒ Object (readonly)
56 57 58 |
# File 'lib/pdf/reader/cmap.rb', line 56 def map @map end |
Instance Method Details
#decode(c) ⇒ Object
Convert a glyph code into one or more Codepoints.
Returns an array of Integers.
74 75 76 |
# File 'lib/pdf/reader/cmap.rb', line 74 def decode(c) @map.fetch(c, EMPTY_CODEPOINTS) end |
#size ⇒ Object
65 66 67 |
# File 'lib/pdf/reader/cmap.rb', line 65 def size @map.size end |