class PDF::Writer::Object::Font
An object to hold the font description
Constants
- Details
Attributes
encoding[R]
Valid values: WinAnsiEncoding, MacRomanEncoding, MacExpertEncoding, none, nil
, or an instance of PDF::Writer::Object::FontEncoding
.
font_id[R]
subtype[R]
The type of the font: Type1 and TrueType are the only values supported by
Public Class Methods
new(parent, name, encoding = 'WinAnsiEncoding', subtype = 'Type1')
click to toggle source
Calls superclass method
PDF::Writer::Object::new
# File lib/pdf/writer/object/font.rb 15 def initialize(parent, name, encoding = 'WinAnsiEncoding', subtype = 'Type1') 16 super(parent) 17 18 @name = name 19 @subtype = subtype 20 @font_id = @parent.__send__(:generate_font_id) 21 22 if encoding.kind_of?(PDF::Writer::Object::FontEncoding) 23 @encoding = encoding 24 elsif encoding == 'none' or encoding.nil? 25 @encoding = nil 26 else 27 @encoding = encoding 28 end 29 30 @parent.pages << self 31 32 @firstchar = nil 33 @lastchar = nil 34 @widths = nil 35 @fontdescriptor = nil 36 end
Public Instance Methods
to_s()
click to toggle source
# File lib/pdf/writer/object/font.rb 58 def to_s 59 res = "\n#{@oid} 0 obj\n<< /Type /Font\n/Subtype /#{@subtype}\n" 60 res << "/Name /F#{@font_id}\n/BaseFont /#{@name}\n" 61 if @encoding.kind_of?(PDF::Writer::Object::FontEncoding) 62 res << "/Encoding #{@encoding.oid} 0 R\n" 63 elsif @encoding 64 res << "/Encoding /#{@encoding}\n" if @encoding 65 end 66 res << "/FirstChar #{@firstchar}\n" unless @firstchar.nil? 67 res << "/LastChar #{@lastchar}\n" unless @lastchar.nil? 68 res << "/Widths #{@widths} 0 R\n" unless @widths.nil? 69 res << "/FontDescriptor #{@fontdescriptor} 0 R\n" unless @fontdescriptor.nil? 70 res << ">>\nendobj" 71 end