properly test UTF8 handling for FT1, and fix it
authorTony Cook <tony@develop-help.com>
Mon, 25 Feb 2013 12:20:17 +0000 (23:20 +1100)
committerTony Cook <tony@develop-help.com>
Mon, 25 Feb 2013 12:20:17 +0000 (23:20 +1100)
Imager.xs
lib/Imager/Font/Truetype.pm

index 5a458d381bb320c60d68ed0b17fb4c0eac30e8df..602d2f526d8c755cfb06e67a5f1757846a4e4fcd 100644 (file)
--- a/Imager.xs
+++ b/Imager.xs
@@ -2235,7 +2235,7 @@ MODULE = Imager         PACKAGE = Imager
 
 
 undef_int
-i_tt_text(handle,im,xb,yb,cl,points,str_sv,len_ignored,smooth,utf8,align=1)
+i_tt_text(handle,im,xb,yb,cl,points,str_sv,smooth,utf8,align=1)
   Imager::Font::TT     handle
     Imager::ImgRaw     im
               i_img_dim     xb
@@ -2250,11 +2250,11 @@ i_tt_text(handle,im,xb,yb,cl,points,str_sv,len_ignored,smooth,utf8,align=1)
                char *str;
                STRLEN len;
              CODE:
+               str = SvPV(str_sv, len);
 #ifdef SvUTF8
                if (SvUTF8(str_sv))
                  utf8 = 1;
 #endif
-               str = SvPV(str_sv, len);
                RETVAL = i_tt_text(handle, im, xb, yb, cl, points, str, 
                                   len, smooth, utf8, align);
              OUTPUT:
@@ -2262,7 +2262,7 @@ i_tt_text(handle,im,xb,yb,cl,points,str_sv,len_ignored,smooth,utf8,align=1)
 
 
 undef_int
-i_tt_cp(handle,im,xb,yb,channel,points,str_sv,len_ignored,smooth,utf8,align=1)
+i_tt_cp(handle,im,xb,yb,channel,points,str_sv,smooth,utf8,align=1)
   Imager::Font::TT     handle
     Imager::ImgRaw     im
               i_img_dim     xb
@@ -2277,11 +2277,11 @@ i_tt_cp(handle,im,xb,yb,channel,points,str_sv,len_ignored,smooth,utf8,align=1)
                char *str;
                STRLEN len;
              CODE:
+               str = SvPV(str_sv, len);
 #ifdef SvUTF8
                if (SvUTF8(str_sv))
                  utf8 = 1;
 #endif
-               str = SvPV(str_sv, len);
                RETVAL = i_tt_cp(handle, im, xb, yb, channel, points, str, len,
                                 smooth, utf8, align);
              OUTPUT:
index 8a4f3908c6c93a558c298e3c8367ac2d2bff9a17..68e1520879f5b6d6c3b927518cbe6274a81e03f7 100644 (file)
@@ -3,7 +3,7 @@ use strict;
 use vars qw(@ISA $VERSION);
 @ISA = qw(Imager::Font);
 
-$VERSION = "1.011";
+$VERSION = "1.012";
 
 *_first = \&Imager::Font::_first;
 
@@ -44,21 +44,16 @@ sub _draw {
   my $self = shift;
   my %input = @_;
 
-  # note that the string length parameter is ignored and calculated in
-  # XS with SvPV(), since we want the number of bytes rather than the
-  # number of characters, which is what we'd get in perl for a UTF8
-  # encoded string in 5.6 and later
-
   if ( exists $input{channel} ) {
     Imager::i_tt_cp($self->{id},$input{image}{IMG},
                    $input{'x'}, $input{'y'}, $input{channel}, $input{size},
-                   $input{string}, length($input{string}),$input{aa},
+                   $input{string}, $input{aa},
                     $input{utf8}, $input{align}); 
   } else {
     Imager::i_tt_text($self->{id}, $input{image}{IMG}, 
                      $input{'x'}, $input{'y'}, $input{color},
                      $input{size}, $input{string}, 
-                     length($input{string}), $input{aa}, $input{utf8},
+                     $input{aa}, $input{utf8},
                       $input{align}); 
   }
 }