Class: Docxer::Word::Fonts

Inherits:
Object
  • Object
show all
Defined in:
lib/docxer/word/fonts.rb,
lib/docxer/word/fonts/font.rb

Defined Under Namespace

Classes: Font

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFonts

Returns a new instance of Fonts.



9
10
11
12
13
14
# File 'lib/docxer/word/fonts.rb', line 9

def initialize
  @fonts = []
  add('Calibri', :panose => '020F0502020204030204', :charset => '00', :family => 'swiss', :pitch => 'variable', :sig => { 'w:usb0' => "E00002FF", 'w:usb1' => "4000ACFF", 'w:usb2' => "00000001", 'w:usb3' => "00000000", 'w:csb0' => "0000019F", 'w:csb1' => "00000000"})
  add('Times New Roman', :panose => '02020603050405020304', :charset => '00', :family => 'roman', :pitch => 'variable', :sig => { 'w:usb0' => "E0002AFF", 'w:usb1' => "C0007841", 'w:usb2' => "00000009", 'w:usb3' => "00000000", 'w:csb0' => "000001FF", 'w:csb1' => "00000000"})
  add('Cambria', :panose => '02040503050406030204', :charset => '00', :family => 'roman', :pitch => 'variable', :sig => { 'w:usb0' => "E00002FF", 'w:usb1' => "400004FF", 'w:usb2' => "00000000", 'w:usb3' => "00000000", 'w:csb0' => "0000019F", 'w:csb1' => "00000000"})
end

Instance Attribute Details

#fontsObject

Returns the value of attribute fonts.



7
8
9
# File 'lib/docxer/word/fonts.rb', line 7

def fonts
  @fonts
end

Instance Method Details

#add(name, options) ⇒ Object



16
17
18
19
20
# File 'lib/docxer/word/fonts.rb', line 16

def add(name, options)
  font = Font.new(name, options)
  @fonts << font if font
  font
end

#render(zip) ⇒ Object



22
23
24
25
# File 'lib/docxer/word/fonts.rb', line 22

def render(zip)
  zip.put_next_entry('word/fontTable.xml')
  zip.write(Docxer.to_xml(document))
end