From 6440dced8ff2da027fd4f60f434262ec60191573 Mon Sep 17 00:00:00 2001 From: Stefan Daschek Date: Mon, 27 Feb 2012 12:28:45 +0100 Subject: Add support for underlined text. --- lib/axlsx/stylesheet/font.rb | 7 +++++++ lib/axlsx/stylesheet/styles.rb | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'lib') 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 -- cgit v1.2.3