Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix rogue issue by breaking a fix. Will revisit [#73 state:open]

  • Loading branch information...
commit 3abb5fc0a05a7618d405f5fb3f4f5b3d7f5e2af4 1 parent 69e47e8
Gregory Brown sandal authored
5 lib/prawn/font.rb
@@ -173,8 +173,9 @@ def width_of(string)
173 173 # Gets height of text in PDF points at current font size.
174 174 # Text +:line_width+ must be specified in PDF points.
175 175 #
176   - def height_of(text,options={})
177   - @metrics.string_height( text, options.merge(:font_size => @size) )
  176 + def height_of(text,options={})
  177 + @metrics.string_height( text, :font_size => @size,
  178 + :line_width => options[:line_width] )
178 179 end
179 180
180 181 # Gets height of current font in PDF points at current font size
13 lib/prawn/font/metrics.rb
@@ -23,18 +23,9 @@ def self.data
23 23 @data ||= {}
24 24 end
25 25
26   - def string_height(string,options={})
27   - Prawn.verify_options [:font_size, :spacing, :line_width], options do
28   - unless options[:line_width]
29   - raise ArgumentError, ":line_width must be specified."
30   - end
31   - end
32   -
33   - line_count = string.lines.to_a.length
34   - spacing = (options[:spacing] || 0) * line_count
35   -
  26 + def string_height(string,options={})
36 27 string = naive_wrap(string, options[:line_width], options[:font_size])
37   - line_count * font_height(options[:font_size]) + spacing
  28 + string.lines.to_a.length * font_height(options[:font_size])
38 29 end
39 30
40 31 def font_height(size)
30 spec/font_spec.rb
... ... @@ -1,6 +1,6 @@
1 1 # encoding: utf-8
2 2
3   -require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
  3 +require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
4 4
5 5 describe "Font Metrics" do
6 6
@@ -21,34 +21,6 @@
21 21
22 22 end
23 23
24   -
25   -describe "Font size calculations" do
26   - before(:each) do
27   - create_pdf
28   - @font = @pdf.font
29   - end
30   -
31   - it "should require a line width option" do
32   - assert_raises(ArgumentError) do
33   - @font.height_of("Foo")
34   - end
35   - end
36   -
37   - it "should equal the number of lines * font.height by default" do
38   - actual_height = @pdf.font.height_of("Foo\nBar\nBaz", :line_width => 200)
39   - actual_height.should == 3 * @pdf.font.height
40   - end
41   -
42   - it "should consider spacing when provided" do
43   - spacing = 10
44   - actual_height = @pdf.font.height_of("Foo\nBar\nBaz",
45   - :line_width => 200, :spacing => spacing)
46   - actual_height.should == 3 * @pdf.font.height + 3 * spacing
47   - end
48   -
49   -end
50   -
51   -
52 24 describe "font style support" do
53 25 before(:each) { create_pdf }
54 26

0 comments on commit 3abb5fc

Please sign in to comment.
Something went wrong with that request. Please try again.