Skip to content
Browse files

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

  • Loading branch information...
1 parent 69e47e8 commit 3abb5fc0a05a7618d405f5fb3f4f5b3d7f5e2af4 @practicingruby practicingruby committed Oct 2, 2008
Showing with 6 additions and 42 deletions.
  1. +3 −2 lib/prawn/font.rb
  2. +2 −11 lib/prawn/font/metrics.rb
  3. +1 −29 spec/font_spec.rb
View
5 lib/prawn/font.rb
@@ -173,8 +173,9 @@ def width_of(string)
# Gets height of text in PDF points at current font size.
# Text +:line_width+ must be specified in PDF points.
#
- def height_of(text,options={})
- @metrics.string_height( text, options.merge(:font_size => @size) )
+ def height_of(text,options={})
+ @metrics.string_height( text, :font_size => @size,
+ :line_width => options[:line_width] )
end
# Gets height of current font in PDF points at current font size
View
13 lib/prawn/font/metrics.rb
@@ -23,18 +23,9 @@ def self.data
@data ||= {}
end
- def string_height(string,options={})
- Prawn.verify_options [:font_size, :spacing, :line_width], options do
- unless options[:line_width]
- raise ArgumentError, ":line_width must be specified."
- end
- end
-
- line_count = string.lines.to_a.length
- spacing = (options[:spacing] || 0) * line_count
-
+ def string_height(string,options={})
string = naive_wrap(string, options[:line_width], options[:font_size])
- line_count * font_height(options[:font_size]) + spacing
+ string.lines.to_a.length * font_height(options[:font_size])
end
def font_height(size)
View
30 spec/font_spec.rb
@@ -1,6 +1,6 @@
# encoding: utf-8
-require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
+require File.join(File.expand_path(File.dirname(__FILE__)), "spec_helper")
describe "Font Metrics" do
@@ -21,34 +21,6 @@
end
-
-describe "Font size calculations" do
- before(:each) do
- create_pdf
- @font = @pdf.font
- end
-
- it "should require a line width option" do
- assert_raises(ArgumentError) do
- @font.height_of("Foo")
- end
- end
-
- it "should equal the number of lines * font.height by default" do
- actual_height = @pdf.font.height_of("Foo\nBar\nBaz", :line_width => 200)
- actual_height.should == 3 * @pdf.font.height
- end
-
- it "should consider spacing when provided" do
- spacing = 10
- actual_height = @pdf.font.height_of("Foo\nBar\nBaz",
- :line_width => 200, :spacing => spacing)
- actual_height.should == 3 * @pdf.font.height + 3 * spacing
- end
-
-end
-
-
describe "font style support" do
before(:each) { create_pdf }

0 comments on commit 3abb5fc

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