changed alignment tests a bit
authorTony Cook <tony@develop=help.com>
Mon, 2 May 2005 12:44:31 +0000 (12:44 +0000)
committerTony Cook <tony@develop=help.com>
Mon, 2 May 2005 12:44:31 +0000 (12:44 +0000)
t/t30t1font.t
t/t35ttfont.t
t/t38ft2font.t

index 24d3f634591684093c3e9397c9f48faa45a5fc47..b0cfbc759c2aba9561d7dd8e2be079957288b8ea 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 => 55;
+use Test::More tests => 58;
 BEGIN { use_ok(Imager => ':all') }
 
 #$Imager::DEBUG=1;
@@ -22,13 +22,13 @@ my $fontname_afm=$ENV{'T1FONTTESTAFM'}||'./fontfiles/dcr10.afm';
 SKIP:
 {
   if (!(i_has_format("t1")) ) {
-    skip("t1lib unavailable or disabled", 49);
+    skip("t1lib unavailable or disabled", 57);
   }
   elsif (! -f $fontname_pfb) {
-    skip("cannot find fontfile for type 1 test $fontname_pfb", 49);
+    skip("cannot find fontfile for type 1 test $fontname_pfb", 57);
   }
   elsif (! -f $fontname_afm) {
-    skip("cannot find fontfile for type 1 test $fontname_afm", 49);
+    skip("cannot find fontfile for type 1 test $fontname_afm", 57);
   }
 
   print "# has t1\n";
@@ -232,21 +232,33 @@ SKIP:
     ok($font, "loaded deffont OO")
       or skip("could not load font:".Imager->errstr, 4);
     my $im = Imager->new(xsize=>70, ysize=>150);
-    my %common = 
+    my %common1 = 
       (
        font=>$font, 
-       text=>'Ay', 
+       text=>'A', 
        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");
+    my %common2 = 
+      (
+       font=>$font, 
+       text=>'y', 
+       size=>40, 
+       color=>'white',
+       x=>40,
+       aa=>1,
+      );
     $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->string(%common1, 'y'=>40), "no alignment A");
+    ok($im->string(%common2, 'y'=>40), "no alignment y");
+    ok($im->string(%common1, 'y'=>90, align=>1), "align=1");
+    ok($im->string(%common2, 'y'=>90, align=>1), "align=1");
+    ok($im->string(%common1, 'y'=>110, align=>0), "align=0");
+    ok($im->string(%common2, 'y'=>110, align=>0), "align=0");
     ok($im->write(file=>'testout/t30align.ppm'), "save align image");
   }
 }
index 8c16c18f992961361002f3b9791e78341c78a5c3..b4ec97f8a7a46d532cdb3520c5a6d557b395dc34 100644 (file)
@@ -1,7 +1,7 @@
 #!perl -w
 use strict;
 use lib 't';
-use Test::More tests => 54;
+use Test::More tests => 57;
 
 BEGIN { use_ok(Imager => ':all') }
 require "t/testtools.pl";
@@ -10,7 +10,7 @@ init_log("testout/t35ttfont.log",2);
 
 SKIP:
 {
-  skip("freetype 1.x unavailable or disabled", 48
+  skip("freetype 1.x unavailable or disabled", 56
     unless i_has_format("tt");
   print "# has tt\n";
   
@@ -19,7 +19,7 @@ SKIP:
 
   if (!ok(-f $fontname, "check test font file exists")) {
     print "# cannot find fontfile for truetype test $fontname\n";
-    skip('Cannot load test font', 47);
+    skip('Cannot load test font', 55);
   }
 
   i_init_fonts();
@@ -175,7 +175,7 @@ SKIP:
   undef $hcfont;
   
   my $name_font = "fontfiles/NameTest.ttf";
-  $hcfont = Imager::Font->new(file=>$name_font);
+  $hcfont = Imager::Font->new(file=>$name_font, type=>'tt');
  SKIP:
   {
     ok($hcfont, "loading name font")
@@ -200,21 +200,33 @@ SKIP:
     ok($font, "loaded deffont OO")
       or skip("could not load font:".Imager->errstr, 4);
     my $im = Imager->new(xsize=>70, ysize=>150);
-    my %common = 
+    my %common1 = 
       (
        font=>$font, 
-       text=>'Ay', 
+       text=>'A', 
        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");
+    my %common2 = 
+      (
+       font=>$font, 
+       text=>'y', 
+       size=>40, 
+       color=>'white',
+       x=>40,
+       aa=>1,
+      );
     $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->string(%common1, 'y'=>40), "A no alignment");
+    ok($im->string(%common2, 'y'=>40), "y no alignment");
+    ok($im->string(%common1, 'y'=>90, align=>1), "A align=1");
+    ok($im->string(%common2, 'y'=>90, align=>1), "y align=1");
+    ok($im->string(%common1, 'y'=>110, align=>0), "A align=0");
+    ok($im->string(%common2, 'y'=>110, align=>0), "y align=0");
     ok($im->write(file=>'testout/t35align.ppm'), "save align image");
   }
 
index 396a1131cc96e56cd1c54872bff98c5f35f1ab94..eaadb340b1dc9b4d887fc8be56664aa5f7b5b142 100644 (file)
@@ -1,6 +1,6 @@
 #!perl -w
 use strict;
-use Test::More tests => 149;
+use Test::More tests => 152;
 ++$|;
 # Before `make install' is performed this script should be runnable with
 # `make test'. After `make install' it should work as `perl test.pl'
@@ -18,13 +18,13 @@ my @base_color = (64, 255, 64);
 
 SKIP:
 {
-  i_has_format("ft2") or skip("no freetype2 library found", 137);
+  i_has_format("ft2") or skip("no freetype2 library found", 151);
 
   print "# has ft2\n";
   
   my $fontname=$ENV{'TTFONTTEST'}||'./fontfiles/dodge.ttf';
 
-  -f $fontname or skip("cannot find fontfile $fontname", 137);
+  -f $fontname or skip("cannot find fontfile $fontname", 151);
 
 
   my $bgcolor=i_color_new(255,0,0,0);
@@ -375,25 +375,37 @@ SKIP:
 
  SKIP:
   { print "# alignment tests\n";
-    my $font = Imager::Font->new(file=>'fontfiles/ImUgly.ttf', type=>'tt');
+    my $font = Imager::Font->new(file=>'fontfiles/ImUgly.ttf', type=>'ft2');
     ok($font, "loaded deffont OO")
       or skip("could not load font:".Imager->errstr, 4);
     my $im = Imager->new(xsize=>70, ysize=>150);
-    my %common = 
+    my %common1 = 
       (
        font=>$font, 
-       text=>'Ay', 
+       text=>'A', 
        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");
+    my %common2 = 
+      (
+       font=>$font, 
+       text=>'y', 
+       size=>40, 
+       color=>'white',
+       x=>40,
+       aa=>1,
+      );
     $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->string(%common1, 'y'=>40), "A no alignment");
+    ok($im->string(%common2, 'y'=>40), "y no alignment");
+    ok($im->string(%common1, 'y'=>90, align=>1), "A align=1");
+    ok($im->string(%common2, 'y'=>90, align=>1), "y align=1");
+    ok($im->string(%common1, 'y'=>110, align=>0), "A align=0");
+    ok($im->string(%common2, 'y'=>110, align=>0), "y align=0");
     ok($im->write(file=>'testout/t38align.ppm'), "save align image");
   }
 }