class Axlsx::Font

The Font class details a font instance for use in styling cells. @note The recommended way to manage fonts, and other styles is Styles#add_style @see Styles#add_style

Attributes

b[R]

Indicates if the font should be rendered in bold @return [Boolean]

charset[R]

The charset of the font @return [Integer] @note

The following values are defined in the OOXML specification and are OS dependant values
 0   ANSI_CHARSET
 1   DEFAULT_CHARSET
 2   SYMBOL_CHARSET
 77  MAC_CHARSET
 128 SHIFTJIS_CHARSET
 129 HANGUL_CHARSET
 130 JOHAB_CHARSET
 134 GB2312_CHARSET
 136 CHINESEBIG5_CHARSET
 161 GREEK_CHARSET
 162 TURKISH_CHARSET
 163 VIETNAMESE_CHARSET
 177 HEBREW_CHARSET
 178 ARABIC_CHARSET
 186 BALTIC_CHARSET
 204 RUSSIAN_CHARSET
 222 THAI_CHARSET
 238 EASTEUROPE_CHARSET
 255 OEM_CHARSET
color[R]

The color of the font @return [Color]

condense[R]

Indicates if the font should be condensed @return [Boolean]

extend[R]

The font's extend property @return [Boolean]

family[R]

The font's family @note

The following are defined OOXML specification
 0 Not applicable.
 1 Roman
 2 Swiss
 3 Modern
 4 Script
 5 Decorative
 6..14 Reserved for future use

@return [Integer]

i[R]

Indicates if the font should be rendered italicized @return [Boolean]

name[R]

The name of the font @return [String]

outline[R]

Indicates if the font should be rendered with an outline @return [Boolean]

shadow[R]

Indicates if the font should be rendered with a shadow @return [Boolean]

strike[R]

Indicates if the font should be rendered with a strikthrough @return [Boolean]

sz[R]

The size of the font. @return [Integer]

u[R]

Indicates if the font should be rendered underlined It must be one of :none, :single, :double, :singleAccounting, :doubleAccounting, true, false @return [String] @note

true or false is for backwards compatibility and is reassigned to :single or :none respectively

Public Class Methods

new(options={}) click to toggle source

Creates a new Font @option options [String] name @option options [Integer] charset @option options [Integer] family @option options [Integer] family @option options [Boolean] b @option options [Boolean] i @option options [Boolean] u @option options [Boolean] strike @option options [Boolean] outline @option options [Boolean] shadow @option options [Boolean] condense @option options [Boolean] extend @option options [Color] color @option options [Integer] sz

# File lib/axlsx/stylesheet/font.rb, line 24
def initialize(options={})
  parse_options options
end

Public Instance Methods

b=(v) click to toggle source

@see b

# File lib/axlsx/stylesheet/font.rb, line 120
def b=(v) Axlsx::validate_boolean v; @b = v end
charset=(v) click to toggle source

@see charset

# File lib/axlsx/stylesheet/font.rb, line 116
def charset=(v) Axlsx::validate_unsigned_int v; @charset = v end
color=(v) click to toggle source

@see color

# File lib/axlsx/stylesheet/font.rb, line 141
def color=(v) DataTypeValidator.validate "Font.color", Color, v; @color=v end
condense=(v) click to toggle source

@see condense

# File lib/axlsx/stylesheet/font.rb, line 137
def condense=(v) Axlsx::validate_boolean v; @condense = v end
extend=(v) click to toggle source

@see extend

# File lib/axlsx/stylesheet/font.rb, line 139
def extend=(v) Axlsx::validate_boolean v; @extend = v end
family=(v) click to toggle source

@see family

# File lib/axlsx/stylesheet/font.rb, line 118
def family=(v) Axlsx::validate_unsigned_int v; @family = v end
i=(v) click to toggle source

@see i

# File lib/axlsx/stylesheet/font.rb, line 122
def i=(v) Axlsx::validate_boolean v; @i = v end
name=(v) click to toggle source

@see name

# File lib/axlsx/stylesheet/font.rb, line 114
def name=(v) Axlsx::validate_string v; @name = v end
outline=(v) click to toggle source

@see outline

# File lib/axlsx/stylesheet/font.rb, line 133
def outline=(v) Axlsx::validate_boolean v; @outline = v end
shadow=(v) click to toggle source

@see shadow

# File lib/axlsx/stylesheet/font.rb, line 135
def shadow=(v) Axlsx::validate_boolean v; @shadow = v end
strike=(v) click to toggle source

@see strike

# File lib/axlsx/stylesheet/font.rb, line 131
def strike=(v) Axlsx::validate_boolean v; @strike = v end
sz=(v) click to toggle source

@see sz

# File lib/axlsx/stylesheet/font.rb, line 143
def sz=(v) Axlsx::validate_unsigned_int v; @sz=v end
to_xml_string(str = '') click to toggle source

Serializes the object @param [String] str @return [String]

# File lib/axlsx/stylesheet/font.rb, line 148
def to_xml_string(str = '')
  str << '<font>'
  instance_values.each do |k, v|
    v.is_a?(Color) ? v.to_xml_string(str) : (str << ('<' << k.to_s << ' val="' << Axlsx.booleanize(v).to_s << '"/>'))
  end
  str << '</font>'
end
u=(v) click to toggle source

@see u

# File lib/axlsx/stylesheet/font.rb, line 124
def u=(v)
  v = :single if (v == true || v == 1 || v == :true || v == 'true')
  v = :none if (v == false || v == 0 || v == :false || v == 'false')
  Axlsx::validate_cell_u v
  @u = v
end