summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-09-14 16:01:01 +0900
committerRandy Morgan <[email protected]>2012-09-14 16:01:01 +0900
commitbcf38488906554162d1ec6dc04837f802873b567 (patch)
treef089c6d608bfa5e64401060bdccb2bdcf3a62059 /lib
parent397af756fc7ff412dd7472e845143a5223a81a83 (diff)
downloadcaxlsx-bcf38488906554162d1ec6dc04837f802873b567.tar.gz
caxlsx-bcf38488906554162d1ec6dc04837f802873b567.zip
incorporate deeper check for cell size and adjust for bold
Diffstat (limited to 'lib')
-rw-r--r--lib/axlsx/workbook/worksheet/cell.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/axlsx/workbook/worksheet/cell.rb b/lib/axlsx/workbook/worksheet/cell.rb
index 2846225f..621a51f6 100644
--- a/lib/axlsx/workbook/worksheet/cell.rb
+++ b/lib/axlsx/workbook/worksheet/cell.rb
@@ -330,7 +330,7 @@ module Axlsx
font_scale = (font_size/10.0).to_f
((value.to_s.count(Worksheet.thin_chars) * mdw + 5) / mdw * 256) / 256.0 * font_scale
end
-
+
# returns the absolute or relative string style reference for
# this cell.
# @param [Boolean] absolute -when false a relative reference will be
@@ -338,12 +338,17 @@ module Axlsx
# @return [String]
def reference(absolute=true)
absolute ? r_abs : r
- end
-
+ end
+
private
+ # we scale the font size if bold style is applied to either the style font or
+ # the cell itself. Yes, it is a bit of a hack, but it is much better than using
+ # imagemagick and loading metrics for every character.
def font_size
- sz || @styles.fonts[@styles.cellXfs[style].fontId].sz || @styles.fonts[0].sz
+ font = @styles.fonts[@styles.cellXfs[style].fontId] || @styles.fonts[0]
+ size_from_styles = (font.b || b) ? font.sz * 1.5 : font.sz
+ sz || size_from_styles
end
# Utility method for setting inline style attributes