Class: C12::PDF::Document

Inherits:
Prawn::Document
  • Object
show all
Defined in:
lib/c12-commons/pdf.rb

Instance Method Summary collapse

Instance Method Details

#change_font(font = :default, size = 10) ⇒ Object

Sets the current font of the document. Font names are predefined. All of them are Georgian-character friendly fonts.

Parameters:

  • font (defaults to: :default)

    name of the font. This may be one of default, serif, sefit-italic, serif-bold, serif-bold-italic. Value nil or any other value is considered as default.

  • size (defaults to: 10)

    size for the font. This parameter defaults to 10pt.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/c12-commons/pdf.rb', line 20

def change_font(font = :default, size = 10)
  case font.to_s
  when 'default'
    ff = 'DejaVuSans'
  when 'bold'
    ff = 'DejaVuSans-Bold'
  when 'italic'
    ff = 'DejaVuSans-Oblique'
  when 'bold-italic'
    ff = 'DejaVuSans-BoldOblique'
  when 'serif'
    ff = 'DejaVuSerif'
  when 'serif-italic'
    ff = 'DejaVuSerif-Italic'
  when 'serif-bold'
    ff = 'DejaVuSerif-Bold'
  when 'serif-bold-italic'
    ff = 'DejaVuSerif-BoldItalic'
  else
    ff = 'DejaVuSans'
  end
  #pdf.font "#{Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf"
  self.font File.expand_path("../pdf-assets/#{ff}.ttf", __FILE__), :size => size
end