]> git.imager.perl.org - imager.git/commitdiff
added alignment tests
authorTony Cook <tony@develop=help.com>
Sat, 30 Apr 2005 00:15:04 +0000 (00:15 +0000)
committerTony Cook <tony@develop=help.com>
Sat, 30 Apr 2005 00:15:04 +0000 (00:15 +0000)
t/t30t1font.t
t/t35ttfont.t
t/t38ft2font.t

index b36f5d4fdf1c3c27e13e9de7f96360629068de2b..24d3f634591684093c3e9397c9f48faa45a5fc47 100644 (file)
@@ -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();
index e5572d68a2aa6a72b1199a4b4982f2ffd343a08b..8c16c18f992961361002f3b9791e78341c78a5c3 100644 (file)
@@ -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");
 }
index 7dcd4490c5e0386a2e5dac88c87faa7791cbc380..396a1131cc96e56cd1c54872bff98c5f35f1ab94 100644 (file)
@@ -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 {