Class: HexaPDF::Font::CMap
- Inherits:
-
Object
- Object
- HexaPDF::Font::CMap
- Defined in:
- lib/hexapdf/font/cmap.rb,
lib/hexapdf/font/cmap/parser.rb,
lib/hexapdf/font/cmap/writer.rb
Overview
Represents a CMap, a mapping from character codes to CIDs (character IDs) or to their Unicode value.
Currently, only the mapping to the Unicode values is supported.
See: PDF1.7 s9.7.5, s9.10.3; Adobe Technical Note #5411
Defined Under Namespace
Instance Attribute Summary collapse
-
#name ⇒ Object
The name of the CMap.
-
#ordering ⇒ Object
The ordering part of the CMap version.
-
#registry ⇒ Object
The registry part of the CMap version.
-
#supplement ⇒ Object
The supplement part of the CMap version.
-
#unicode_mapping ⇒ Object
The mapping from character codes to Unicode values.
Class Method Summary collapse
-
.create_to_unicode_cmap(mapping) ⇒ Object
Returns a string containing a ToUnicode CMap that represents the given code to Unicode codepoint mapping.
-
.parse(string) ⇒ Object
Creates a new CMap object from the given string which needs to contain a valid CMap file.
Instance Method Summary collapse
-
#initialize ⇒ CMap
constructor
Creates a new CMap object.
-
#to_unicode(code) ⇒ Object
Returns the Unicode string in UTF-8 encoding for the given character code, or an empty string if no mapping was found.
Constructor Details
#initialize ⇒ CMap
Creates a new CMap object.
77 78 79 |
# File 'lib/hexapdf/font/cmap.rb', line 77 def initialize @unicode_mapping = Hash.new("".freeze) end |
Instance Attribute Details
#name ⇒ Object
The name of the CMap.
71 72 73 |
# File 'lib/hexapdf/font/cmap.rb', line 71 def name @name end |
#ordering ⇒ Object
The ordering part of the CMap version.
65 66 67 |
# File 'lib/hexapdf/font/cmap.rb', line 65 def ordering @ordering end |
#registry ⇒ Object
The registry part of the CMap version.
62 63 64 |
# File 'lib/hexapdf/font/cmap.rb', line 62 def registry @registry end |
#supplement ⇒ Object
The supplement part of the CMap version.
68 69 70 |
# File 'lib/hexapdf/font/cmap.rb', line 68 def supplement @supplement end |
#unicode_mapping ⇒ Object
The mapping from character codes to Unicode values.
74 75 76 |
# File 'lib/hexapdf/font/cmap.rb', line 74 def unicode_mapping @unicode_mapping end |
Class Method Details
.create_to_unicode_cmap(mapping) ⇒ Object
Returns a string containing a ToUnicode CMap that represents the given code to Unicode codepoint mapping.
See: Writer#create_to_unicode_cmap
57 58 59 |
# File 'lib/hexapdf/font/cmap.rb', line 57 def self.create_to_unicode_cmap(mapping) Writer.new.create_to_unicode_cmap(mapping) end |
Instance Method Details
#to_unicode(code) ⇒ Object
Returns the Unicode string in UTF-8 encoding for the given character code, or an empty string if no mapping was found.
83 84 85 |
# File 'lib/hexapdf/font/cmap.rb', line 83 def to_unicode(code) unicode_mapping[code] end |