Sha256: 107bf08486fa0bc781672e22ea24599716230c4047ab5173ce71b0cb037d59c8

Contents?: true

Size: 779 Bytes

Versions: 5

Compression:

Stored size: 779 Bytes

Contents

# coding: utf-8

module Prawn
  class Document
    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
  end

  module Images
    class Image
      alias_method :original_calc_image_dimensions, :calc_image_dimensions

      def calc_image_dimensions(options)
        if options[:auto_fit]
          w = options[:width] || width
          h = options[:height] || height

          box_width, box_height = options.delete(:auto_fit)

          if w > box_width || h > box_height
            options[:fit] = [box_width, box_height]
          end
        end
        original_calc_image_dimensions(options)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
thinreports-0.9.1 lib/thinreports/generator/pdf/prawn_ext.rb
thinreports-0.9.0 lib/thinreports/generator/pdf/prawn_ext.rb
thinreports-0.8.2 lib/thinreports/generator/pdf/prawn_ext.rb
thinreports-0.8.1 lib/thinreports/generator/pdf/prawn_ext.rb
thinreports-0.8.0 lib/thinreports/generator/pdf/prawn_ext.rb