Class: PDF::Writer::Object::FontEncoding

Inherits:
PDF::Writer::Object show all
Defined in:
lib/extensions/pdf-writer/pdf/writer/object/fontencoding.rb

Overview

The font encoding

Instance Attribute Summary collapse

Attributes inherited from PDF::Writer::Object

#oid

Instance Method Summary collapse

Constructor Details

#initialize(parent, encoding, differences) ⇒ FontEncoding

Returns a new instance of FontEncoding.



13
14
15
16
17
18
# File 'lib/extensions/pdf-writer/pdf/writer/object/fontencoding.rb', line 13

def initialize(parent, encoding, differences)
  super(parent)

  @differences  = differences
  @encoding     = encoding
end

Instance Attribute Details

#differencesObject

Returns the value of attribute differences.



20
21
22
# File 'lib/extensions/pdf-writer/pdf/writer/object/fontencoding.rb', line 20

def differences
  @differences
end

#encodingObject

Returns the value of attribute encoding.



21
22
23
# File 'lib/extensions/pdf-writer/pdf/writer/object/fontencoding.rb', line 21

def encoding
  @encoding
end

Instance Method Details

#to_sObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/extensions/pdf-writer/pdf/writer/object/fontencoding.rb', line 23

def to_s
  res = "\n#{@oid} 0 obj\n<< /Type /Encoding\n"
  enc = @encoding || 'WinAnsiEncoding'
  res << "/BaseEncoding /#{enc}\n" unless enc == 'none'
  unless @differences.nil? or @differences.empty?
    res << "/Differences \n["
    n = nil
    @differences.keys.sort.each do |k|
        # Cannot make use of consecutive numbering
      res << "\n#{k} " if n.nil? or k != (n + 1)
      res << " /#{@differences[k]}"
      n = k
    end
    res << "\n]"
  end
  res << "\n>>\nendobj"
end