Subject: | Imager .45 and earlier bounding_box not calculated correctly for non-latin UTF strings |
Fedora Core 1
perl v5.8.3 built for i386-linux-thread-multi
Linux 2.4.22-1.2174.nptl
sample:
#!/usr/bin/perl
use Text::Iconv;
use Imager;
my $enc2utf = new Text::Iconv('windows-1253', 'utf8');
my $img=Imager->new(xsize=>100,ysize=>22,channels=>3);
my $font=Imager::Font->new(file => '/usr/local/share/ttf-fonts/Trebucbd.ttf', color=>$blue, size=>13, aa=>1);
$text=$enc2utf->convert($ARGV[0]);
my @metrics = $font->bounding_box(string => $text);
print "$metrics[2], $text\n";
$img->string(font=>$font, text=>$text, x=>1, utf8=>1, y=>19);
$img->write(file=>'test.png");
use with ./scriptname "Some greek text"
(sample with written greek text may be provided if needed).
The UTF-8 strings' width is miscalculated but written correctly.
If you use latin text, it's calculated correctly
For usage over a UTF-enabled console, replace the line
$text=$enc2utf->convert($ARGV[0]);
with
$text=$ARGV[0];
The result is the same