Module: Thinreports::BasicReport::Generator::PrawnExt::WidthOf

Defined in:
lib/thinreports/basic_report/generator/pdf/prawn_ext/width_of.rb

Instance Method Summary collapse

Instance Method Details

#width_ofObject

This patch fixes the character_spacing effect on text width calculation.

The original #width_of:

width_of('abcd') #=> 4 + 4 = 8

The #width_of in this patch:

width_of('abcd') #=> 4 + 3 = 7


18
19
20
21
# File 'lib/thinreports/basic_report/generator/pdf/prawn_ext/width_of.rb', line 18

def width_of(*)
  width = super - character_spacing
  width > 0 ? width : 0
end