From: Tony Cook Date: Sat, 30 Apr 2005 00:15:04 +0000 (+0000) Subject: added alignment tests X-Git-Tag: Imager-0.48^2~165 X-Git-Url: http://git.imager.perl.org/imager.git/commitdiff_plain/490aa9aeabbe4df58e442ad61f0ac0872047ce8b added alignment tests --- diff --git a/t/t30t1font.t b/t/t30t1font.t index b36f5d4f..24d3f634 100644 --- a/t/t30t1font.t +++ b/t/t30t1font.t @@ -7,7 +7,7 @@ # Change 1..1 below to 1..last_test_to_print . # (It may become useful if the test is moved to ./t subdirectory.) use strict; -use Test::More tests => 50; +use Test::More tests => 55; BEGIN { use_ok(Imager => ':all') } #$Imager::DEBUG=1; @@ -225,6 +225,30 @@ SKIP: cmp_ok($bbox->display_width, '<', $bbox->advance_width, "display smaller than advance"); } + + SKIP: + { print "# alignment tests\n"; + my $font = Imager::Font->new(file=>$deffont, type=>'t1'); + ok($font, "loaded deffont OO") + or skip("could not load font:".Imager->errstr, 4); + my $im = Imager->new(xsize=>70, ysize=>150); + my %common = + ( + font=>$font, + text=>'Ay', + size=>40, + color=>'white', + x=>5, + aa=>1, + ); + ok($im->string(%common, 'y'=>40), "no alignment"); + ok($im->string(%common, 'y'=>90, align=>1), "align=1"); + ok($im->string(%common, 'y'=>110, align=>0), "align=0"); + $im->line(x1=>0, y1=>40, x2=>69, y2=>40, color=>'blue'); + $im->line(x1=>0, y1=>90, x2=>69, y2=>90, color=>'blue'); + $im->line(x1=>0, y1=>110, x2=>69, y2=>110, color=>'blue'); + ok($im->write(file=>'testout/t30align.ppm'), "save align image"); + } } #malloc_state(); diff --git a/t/t35ttfont.t b/t/t35ttfont.t index e5572d68..8c16c18f 100644 --- a/t/t35ttfont.t +++ b/t/t35ttfont.t @@ -1,7 +1,7 @@ #!perl -w use strict; use lib 't'; -use Test::More tests => 49; +use Test::More tests => 54; BEGIN { use_ok(Imager => ':all') } require "t/testtools.pl"; @@ -194,5 +194,29 @@ SKIP: undef $hcfont; + SKIP: + { print "# alignment tests\n"; + my $font = Imager::Font->new(file=>'fontfiles/ImUgly.ttf', type=>'tt'); + ok($font, "loaded deffont OO") + or skip("could not load font:".Imager->errstr, 4); + my $im = Imager->new(xsize=>70, ysize=>150); + my %common = + ( + font=>$font, + text=>'Ay', + size=>40, + color=>'white', + x=>5, + aa=>1, + ); + ok($im->string(%common, 'y'=>40), "no alignment"); + ok($im->string(%common, 'y'=>90, align=>1), "align=1"); + ok($im->string(%common, 'y'=>110, align=>0), "align=0"); + $im->line(x1=>0, y1=>40, x2=>69, y2=>40, color=>'blue'); + $im->line(x1=>0, y1=>90, x2=>69, y2=>90, color=>'blue'); + $im->line(x1=>0, y1=>110, x2=>69, y2=>110, color=>'blue'); + ok($im->write(file=>'testout/t35align.ppm'), "save align image"); + } + ok(1, "end of code"); } diff --git a/t/t38ft2font.t b/t/t38ft2font.t index 7dcd4490..396a1131 100644 --- a/t/t38ft2font.t +++ b/t/t38ft2font.t @@ -1,6 +1,6 @@ #!perl -w use strict; -use Test::More tests => 144; +use Test::More tests => 149; ++$|; # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' @@ -372,6 +372,30 @@ SKIP: } ok($mmim->write(file=>"testout/t38mm.ppm"), "save MM output"); + + SKIP: + { print "# alignment tests\n"; + my $font = Imager::Font->new(file=>'fontfiles/ImUgly.ttf', type=>'tt'); + ok($font, "loaded deffont OO") + or skip("could not load font:".Imager->errstr, 4); + my $im = Imager->new(xsize=>70, ysize=>150); + my %common = + ( + font=>$font, + text=>'Ay', + size=>40, + color=>'white', + x=>5, + aa=>1, + ); + ok($im->string(%common, 'y'=>40), "no alignment"); + ok($im->string(%common, 'y'=>90, align=>1), "align=1"); + ok($im->string(%common, 'y'=>110, align=>0), "align=0"); + $im->line(x1=>0, y1=>40, x2=>69, y2=>40, color=>'blue'); + $im->line(x1=>0, y1=>90, x2=>69, y2=>90, color=>'blue'); + $im->line(x1=>0, y1=>110, x2=>69, y2=>110, color=>'blue'); + ok($im->write(file=>'testout/t38align.ppm'), "save align image"); + } } sub align_test { @@ -413,6 +437,7 @@ sub align_test { else { SKIP: { skip("couldn't draw text", 8) }; } + } sub okmatchcolor {