From: Tony Cook Date: Wed, 14 Mar 2007 10:54:25 +0000 (+0000) Subject: sanity test new ft2 rendering X-Git-Tag: Imager-0.56~11 X-Git-Url: http://git.imager.perl.org/imager.git/commitdiff_plain/a4947da7346fb0eb86f54b2cfb3b602c93bbc4f9 sanity test new ft2 rendering --- diff --git a/TODO b/TODO index b24ce19e..7d2658c8 100644 --- a/TODO +++ b/TODO @@ -8,7 +8,7 @@ not commitments. For 0.56: -checking testing of new ft2 rendering +checking testing of new ft2 rendering (done) possibly: use renderer on other fonts diff --git a/t/t38ft2font.t b/t/t38ft2font.t index fc471cd3..722cc133 100644 --- a/t/t38ft2font.t +++ b/t/t38ft2font.t @@ -1,6 +1,6 @@ #!perl -w use strict; -use Test::More tests => 178; +use Test::More tests => 182; ++$|; # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' @@ -12,7 +12,7 @@ use Test::More tests => 178; BEGIN { use_ok(Imager => ':all') } -use Imager::Test qw(diff_text_with_nul); +use Imager::Test qw(diff_text_with_nul is_color3); init_log("testout/t38ft2font.log",2); @@ -20,13 +20,13 @@ my @base_color = (64, 255, 64); SKIP: { - i_has_format("ft2") or skip("no freetype2 library found", 177); + i_has_format("ft2") or skip("no freetype2 library found", 181); print "# has ft2\n"; my $fontname=$ENV{'TTFONTTEST'}||'./fontfiles/dodge.ttf'; - -f $fontname or skip("cannot find fontfile $fontname", 177); + -f $fontname or skip("cannot find fontfile $fontname", 181); my $bgcolor=i_color_new(255,0,0,0); @@ -449,6 +449,24 @@ SKIP: diff_text_with_nul("utf8 dash\0dash vs dash", "$dash\0$dash", $dash, font => $font, channel => 1, utf8 => 1); } + + { # RT 11972 + # when rendering to a transparent image the coverage should be + # expressed in terms of the alpha channel rather than the color + my $font = Imager::Font->new(file=>'fontfiles/ImUgly.ttf', type=>'ft2'); + my $im = Imager->new(xsize => 40, ysize => 20, channels => 4); + ok($im->string(string => "AB", size => 20, aa => 1, color => '#F00', + x => 0, y => 15, font => $font), + "draw to transparent image"); + $im->write(file => "foo.png"); + my $im_noalpha = $im->convert(preset => 'noalpha'); + my $im_pal = $im->to_paletted(make_colors => 'mediancut'); + my @colors = $im_pal->getcolors; + is(@colors, 2, "should be only 2 colors"); + @colors = sort { ($a->rgba)[0] <=> ($b->rgba)[0] } @colors; + is_color3($colors[0], 0, 0, 0, "check we got black"); + is_color3($colors[1], 255, 0, 0, "and red"); + } } sub align_test {