Class: Spreadsheet::Font

Inherits:
Object
  • Object
show all
Includes:
Datatypes, Encodings
Defined in:
lib/spreadsheet/font.rb

Overview

Font formatting data

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from Datatypes

append_features

Methods included from Compatibility

#ivar_name, #method_name

Constructor Details

- (Font) initialize(name, opts = {})

A new instance of Font



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/spreadsheet/font.rb', line 64

def initialize name, opts={}
  self.name = name
  @color = :text
  @previous_fast_key = nil
  @size = nil
  @weight = nil
  @italic = nil
  @strikeout = nil
  @outline = nil
  @shadow = nil
  @escapement = nil
  @underline = nil
  @family = nil
  @encoding = nil
  opts.each do |key, val|
    self.send "#{key}=", val
  end
end

Instance Attribute Details

- (Object) name

Returns the value of attribute name



11
12
13
# File 'lib/spreadsheet/font.rb', line 11

def name
  @name
end

Instance Method Details

- (Object) bold=(bool)

Sets #weight to :bold if(bool), :normal otherwise.



84
85
86
# File 'lib/spreadsheet/font.rb', line 84

def bold= bool
  self.weight = bool ? :bold : nil
end

- (Object) color

Font color



21
# File 'lib/spreadsheet/font.rb', line 21

colors :color

- (Object) escapement

Escapement Valid values: :normal, :superscript or :subscript. Default: :normal



35
36
37
# File 'lib/spreadsheet/font.rb', line 35

enum :escapement, :normal, :superscript, :subscript,
:subscript   => :sub,
:superscript => :super

- (Object) italic

You can set the following boolean Font attributes

  • #italic

  • #strikeout

  • #outline

  • #shadow



18
# File 'lib/spreadsheet/font.rb', line 18

boolean :italic, :strikeout, :outline, :shadow

- (Object) key

:nodoc:



87
88
89
90
91
92
# File 'lib/spreadsheet/font.rb', line 87

def key # :nodoc:
  fk = fast_key
  return @key if @previous_fast_key == fk
  @previous_fast_key = fk
  @key = build_key
end

- (Object) weight

Font weight Valid values: :normal, :bold or any positive Integer. In Excel:

100 <= weight <= 1000
:bold   => 700
:normal => 400

Default: :normal



30
# File 'lib/spreadsheet/font.rb', line 30

enum :weight, :normal, :bold, Integer, :bold => :b