Sha256: 6cfa9c9b326c77d340538978f3b83d1c44933b6b9d23703e9d0218f11e480737

Contents?: true

Size: 1.86 KB

Versions: 10

Compression:

Stored size: 1.86 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::StringValue,  :node_name => :u) # ST_UnderlineValues (http://www.datypic.com/sc/ooxml/e-ssml_u-1.html)
    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

10 entries across 10 versions & 1 rubygems

Version Path
rubyXL-3.4.33 lib/rubyXL/objects/font.rb
rubyXL-3.4.32 lib/rubyXL/objects/font.rb
rubyXL-3.4.31 lib/rubyXL/objects/font.rb
rubyXL-3.4.30 lib/rubyXL/objects/font.rb
rubyXL-3.4.29 lib/rubyXL/objects/font.rb
rubyXL-3.4.28 lib/rubyXL/objects/font.rb
rubyXL-3.4.27 lib/rubyXL/objects/font.rb
rubyXL-3.4.26 lib/rubyXL/objects/font.rb
rubyXL-3.4.25 lib/rubyXL/objects/font.rb
rubyXL-3.4.24 lib/rubyXL/objects/font.rb