Sha256: ac0b585682afeba18bcf82c7e55a4da56e683880b9c38b9acb448cf38b0fc120
Contents?: true
Size: 1002 Bytes
Versions: 1
Compression:
Stored size: 1002 Bytes
Contents
# frozen_string_literal: true module Thinreports module Generator module PrawnExt module WidthOf # TODO: Remove this path when a version of prawn that includes the following PR is released: # https://github.com/prawnpdf/prawn/pull/1117 # # This PR makes this patch unnecessary. # # # Subtract the width of one character space from the string width calculation result. # # The original Prawn::Document#width_of returns the following result: # # Width of Character is 1 # Width of Character Space is 1 # # width_of('abcd') #=> 4 + 4 = 8 # # In this width_of, returns the following result: # # width_of('abcd') #=> 4 + 3 = 7 # def width_of(*) width = super - character_spacing width > 0 ? width : 0 end end end end end Prawn::Document.prepend Thinreports::Generator::PrawnExt::WidthOf
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
thinreports-0.11.0 | lib/thinreports/generator/pdf/prawn_ext/width_of.rb |