Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add support for underlined text.

  • Loading branch information...
commit 6440dced8ff2da027fd4f60f434262ec60191573 1 parent dc1f292
Stefan Daschek noniq authored
7 lib/axlsx/stylesheet/font.rb
View
@@ -54,6 +54,10 @@ class Font
# @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 @@ class Font
# @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 @@ def family=(v) Axlsx::validate_unsigned_int v; @family = v end
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
5 lib/axlsx/stylesheet/styles.rb
View
@@ -125,6 +125,7 @@ def initialize()
# @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 @@ def add_style(options={})
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
8 test/stylesheet/tc_font.rb
View
@@ -17,6 +17,7 @@ def test_initialiation
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 @@ def test_i
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

2 comments on commit 6440dce

Randy Morgan (@morgan_randy)
Owner

Very well done sir!

Stefan Daschek
Collaborator

Thanks! :)

Please sign in to comment.
Something went wrong with that request. Please try again.