Sha256: 80f28f8dca76116f9deb4d5b916ad38d361c67726c73919072c389f16d447dfc

Contents?: true

Size: 746 Bytes

Versions: 3

Compression:

Stored size: 746 Bytes

Contents

# coding: utf-8

# @private
module Prawn
  # @private
  class Document
    # Create around alias.
    alias_method :original_width_of, :width_of
    
    def width_of(string, options={})
      font.compute_width_of(string, options) +
        (character_spacing * (font.character_count(string) - 1))
    end
    
  private
    # Create around alias.
    alias_method :original_calc_image_dimensions, :calc_image_dimensions
    
    def calc_image_dimensions(info, options)
      if options[:auto_fit]
        w, h = info.width, info.height
        sw, sh = options.delete(:auto_fit)
        
        if w > sw || h > sh
          options[:fit] = [sw, sh]
        end
      end
      original_calc_image_dimensions(info, options)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
thinreports-0.7.6 lib/thinreports/generator/pdf/prawn_ext.rb
thinreports-0.7.5 lib/thinreports/generator/pdf/prawn_ext.rb
thinreports-0.7.0 lib/thinreports/generator/pdf/prawn_ext.rb