Sha256: 88dc4ce66d49fe9eb41e319e58b2f05f66411b271b8a7b9b977e93049418d4c6

Contents?: true

Size: 1.79 KB

Versions: 18

Compression:

Stored size: 1.79 KB

Contents

require 'rubyXL/objects/ooxml_object'
require 'rubyXL/objects/container_nodes'
require 'rubyXL/objects/color'

module RubyXL

  # http://www.datypic.com/sc/ooxml/e-ssml_font-1.html
  class Font < OOXMLObject
    # Since we have no capability to load the actual fonts, we'll have to live with the default.
    MAX_DIGIT_WIDTH = 7 # Calibri 11 pt @ 96 dpi

    define_child_node(RubyXL::StringValue,  :node_name => :name)
    define_child_node(RubyXL::IntegerValue, :node_name => :charset)
    define_child_node(RubyXL::IntegerValue, :node_name => :family)
    define_child_node(RubyXL::BooleanValue, :node_name => :b)
    define_child_node(RubyXL::BooleanValue, :node_name => :i)
    define_child_node(RubyXL::BooleanValue, :node_name => :strike)
    define_child_node(RubyXL::BooleanValue, :node_name => :outline)
    define_child_node(RubyXL::BooleanValue, :node_name => :shadow)
    define_child_node(RubyXL::BooleanValue, :node_name => :condense)
    define_child_node(RubyXL::BooleanValue, :node_name => :extend)
    define_child_node(RubyXL::Color)
    define_child_node(RubyXL::FloatValue,   :node_name => :sz)
    define_child_node(RubyXL::BooleanValue, :node_name => :u)
    define_child_node(RubyXL::StringValue,  :node_name => :vertAlign)
    define_child_node(RubyXL::StringValue,  :node_name => :scheme)
    define_element_name 'font'

    def self.default(size = 10)
      self.new(:name => RubyXL::StringValue.new(:val => 'Verdana'),
               :sz   => RubyXL::FloatValue.new(:val => size) )
    end
  end

  # http://www.datypic.com/sc/ooxml/e-ssml_fonts-1.html
  class Fonts < OOXMLContainerObject
    define_child_node(RubyXL::Font, :collection => :with_count)
    define_element_name 'fonts'

    def self.default
      self.new(:_ => [ RubyXL::Font.default(10), RubyXL::Font.default(8) ])
    end
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
rubyXL-3.4.20 lib/rubyXL/objects/font.rb
rubyXL-3.4.18 lib/rubyXL/objects/font.rb
rubyXL-3.4.17 lib/rubyXL/objects/font.rb
rubyXL-3.4.16 lib/rubyXL/objects/font.rb
rubyXL-3.4.15 lib/rubyXL/objects/font.rb
rubyXL-3.4.14 lib/rubyXL/objects/font.rb
rubyXL-3.4.12 lib/rubyXL/objects/font.rb
rubyXL-3.4.11 lib/rubyXL/objects/font.rb
rubyXL-3.4.10 lib/rubyXL/objects/font.rb
rubyXL-3.4.9 lib/rubyXL/objects/font.rb
rubyXL-3.4.8 lib/rubyXL/objects/font.rb
rubyXL-3.4.6 lib/rubyXL/objects/font.rb
rubyXL-3.4.5 lib/rubyXL/objects/font.rb
rubyXL-3.4.4 lib/rubyXL/objects/font.rb
rubyXL-3.4.3 lib/rubyXL/objects/font.rb
rubyXL-3.4.2 lib/rubyXL/objects/font.rb
rubyXL-3.4.1 lib/rubyXL/objects/font.rb
rubyXL-3.4.0 lib/rubyXL/objects/font.rb