Class: HexaPDF::Font::Encoding::DifferenceEncoding

Inherits:
Base
  • Object
show all
Defined in:
lib/hexapdf/font/encoding/difference_encoding.rb

Overview

The difference encoding uses a base encoding that can be overlayed with additional mappings.

See: PDF2.0 s9.6.5.1

Instance Attribute Summary collapse

Attributes inherited from Base

#code_to_name, #encoding_name

Instance Method Summary collapse

Methods inherited from Base

#unicode

Constructor Details

#initialize(base_encoding) ⇒ DifferenceEncoding

Initializes the Differences object with the given base encoding object.



52
53
54
55
# File 'lib/hexapdf/font/encoding/difference_encoding.rb', line 52

def initialize(base_encoding)
  super()
  @base_encoding = base_encoding
end

Instance Attribute Details

#base_encodingObject (readonly)

The base encoding.



49
50
51
# File 'lib/hexapdf/font/encoding/difference_encoding.rb', line 49

def base_encoding
  @base_encoding
end

Instance Method Details

#code(name) ⇒ Object

Returns the code for the given glyph name, either from this object, if a code references the name, or from the base encoding.



65
66
67
# File 'lib/hexapdf/font/encoding/difference_encoding.rb', line 65

def code(name)
  code_to_name.key(name) || base_encoding.code(name)
end

#name(code) ⇒ Object

Returns the name for the given code, either from this object, if it contains the code, or from the base encoding.



59
60
61
# File 'lib/hexapdf/font/encoding/difference_encoding.rb', line 59

def name(code)
  code_to_name[code] || base_encoding.name(code)
end