diff options
| -rw-r--r-- | lib/axlsx/stylesheet/font.rb | 7 | ||||
| -rw-r--r-- | lib/axlsx/stylesheet/styles.rb | 5 | ||||
| -rw-r--r-- | test/stylesheet/tc_font.rb | 8 |
3 files changed, 18 insertions, 2 deletions
diff --git a/lib/axlsx/stylesheet/font.rb b/lib/axlsx/stylesheet/font.rb index d3eea3b2..1d9bc5d4 100644 --- a/lib/axlsx/stylesheet/font.rb +++ b/lib/axlsx/stylesheet/font.rb @@ -54,6 +54,10 @@ module Axlsx # @return [Boolean] attr_reader :i + # Indicates if the font should be rendered underlined + # @return [Boolean] + attr_reader :u + # Indicates if the font should be rendered with a strikthrough # @return [Boolean] attr_reader :strike @@ -89,6 +93,7 @@ module Axlsx # @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 @@ -111,6 +116,8 @@ module Axlsx def b=(v) Axlsx::validate_boolean v; @b = v end # @see i def i=(v) Axlsx::validate_boolean v; @i = v end + # @see u + def u=(v) Axlsx::validate_boolean v; @u = v end # @see strike def strike=(v) Axlsx::validate_boolean v; @strike = v end # @see outline diff --git a/lib/axlsx/stylesheet/styles.rb b/lib/axlsx/stylesheet/styles.rb index 633fbcad..955a8b1e 100644 --- a/lib/axlsx/stylesheet/styles.rb +++ b/lib/axlsx/stylesheet/styles.rb @@ -125,6 +125,7 @@ module Axlsx # @option options [Integer] sz The text size # @option options [Boolean] b Indicates if the text should be bold # @option options [Boolean] i Indicates if the text should be italicised + # @option options [Boolean] u Indicates if the text should be underlined # @option options [Boolean] strike Indicates if the text should be rendered with a strikethrough # @option options [Boolean] strike Indicates if the text should be rendered with a shadow # @option options [Integer] charset The character set to use. @@ -210,9 +211,9 @@ module Axlsx 0 end - fontId = if (options.values_at(:fg_color, :sz, :b, :i, :strike, :outline, :shadow, :charset, :family, :font_name).length) + fontId = if (options.values_at(:fg_color, :sz, :b, :i, :u, :strike, :outline, :shadow, :charset, :family, :font_name).length) font = Font.new() - [:b, :i, :strike, :outline, :shadow, :charset, :family, :sz].each { |k| font.send("#{k}=", options[k]) unless options[k].nil? } + [:b, :i, :u, :strike, :outline, :shadow, :charset, :family, :sz].each { |k| font.send("#{k}=", options[k]) unless options[k].nil? } font.color = Color.new(:rgb => options[:fg_color]) unless options[:fg_color].nil? font.name = options[:font_name] unless options[:font_name].nil? fonts << font diff --git a/test/stylesheet/tc_font.rb b/test/stylesheet/tc_font.rb index f4b18776..141c285e 100644 --- a/test/stylesheet/tc_font.rb +++ b/test/stylesheet/tc_font.rb @@ -17,6 +17,7 @@ class TestFont < Test::Unit::TestCase assert_equal(@item.family, nil) assert_equal(@item.b, nil) assert_equal(@item.i, nil) + assert_equal(@item.u, nil) assert_equal(@item.strike, nil) assert_equal(@item.outline, nil) assert_equal(@item.shadow, nil) @@ -61,6 +62,13 @@ class TestFont < Test::Unit::TestCase assert_nothing_raised { @item.i = true } assert_equal(@item.i, true) end + + # def u=(v) Axlsx::validate_boolean v; @u = v end + def test_u + assert_raise(ArgumentError) { @item.u = -7 } + assert_nothing_raised { @item.u = true } + assert_equal(@item.u, true) + end # def strike=(v) Axlsx::validate_boolean v; @strike = v end def test_strike |
