- Imager::Font::Wrap doesn't correctly set savepos
authorTony Cook <tony@develop=help.com>
Fri, 26 Oct 2007 09:18:52 +0000 (09:18 +0000)
committerTony Cook <tony@develop=help.com>
Fri, 26 Oct 2007 09:18:52 +0000 (09:18 +0000)
Changes
TODO
lib/Imager/Font/Wrap.pm
t/t80texttools.t

diff --git a/Changes b/Changes
index 42f352947a5c576c6429812c3ed3640667c93a49..5220500dbaa40be70579f8edf86a2d9b83a5bab0 100644 (file)
--- a/Changes
+++ b/Changes
@@ -21,6 +21,10 @@ Bug fixes:
    directory tests
    http://rt.cpan.org/Ticket/Display.html?id=30203
 
+ - Imager::Font::Wrap doesn't correctly set savepos
+   thanks to Nikita Dedik and Eleneldil G. Arilou for reporting this.
+   http://rt.cpan.org/Ticket/Display.html?id=29771
+
 Imager 0.60 - 30 August 2007
 ===========
 
diff --git a/TODO b/TODO
index 05f323d54afff49899caff302a2650a0cbbd2e51..8879d893deb5f09ba400da66068b3de31f19a2e9 100644 (file)
--- a/TODO
+++ b/TODO
@@ -62,6 +62,8 @@ warning compiling datatypes.c on x64 (#30204) (done)
 dynfilt/t/t60dyntest.t relies on a file that may not exist (#30203)
 (done)
 
+Imager::Font::Wrap doesn't correctly set savepos (#29771) (done)
+
 For 0.60 (hopefully):
 
 RGB file support (#8666) (done)
index 9b15425a41402fa1d33a3c94d1d0fa7089ea3704..4d465a5a31a08b5ef5c7b8f7a1cbbc727e5a8c9c 100644 (file)
@@ -190,7 +190,8 @@ sub wrap_text {
   }
 
   if (length $line && !$state{full}) {
-    _format_line(\%state, 0, $line, 0);
+    $linepos += length $line
+      if _format_line(\%state, 0, $line, 0);
   }
 
   if ($input{savepos}) {
index ae37b98b417a1fc44adfd2eab1e17e111dbc6a05..4a4c323a778b902b94a423e3990f65383c2ea76a 100644 (file)
@@ -1,6 +1,6 @@
 #!perl -w
 use strict;
-use Test::More tests => 11;
+use Test::More tests => 13;
 
 BEGIN { use_ok('Imager') }
 
@@ -37,7 +37,7 @@ my $font = Imager::Font->new(file=>$fontfile);
 SKIP:
 {
   Imager::i_has_format('tt') || Imager::i_has_format('ft2')
-      or skip("Need Freetype 1.x or 2.x to test", 9);
+      or skip("Need Freetype 1.x or 2.x to test", 11);
 
   ok($font, "loading font")
     or skip("Could not load test font", 8);
@@ -78,4 +78,15 @@ SKIP:
   ok(@box == 4, "bounds list count");
   print "# @box\n";
   ok($box[3] == $bbox->font_height, "check height");
+
+  { # regression
+    # http://rt.cpan.org/Ticket/Display.html?id=29771
+    # the length of the trailing line wasn't included in the text consumed
+    my $used;
+    ok(scalar Imager::Font::Wrap->wrap_text
+       ( string => "test", font => $font, image => undef, size => 12,
+        width => 200, savepos => \$used, height => $bbox->font_height),
+       "regression 29771 - call wrap_text");
+    is($used, 4, "all text should be consumed");
+  }
 }