]> git.imager.perl.org - imager.git/blob - t/t30t1font.t
forgot to change this one after fixing t105gif.t
[imager.git] / t / t30t1font.t
1 # Before `make install' is performed this script should be runnable with
2 # `make test'. After `make install' it should work as `perl test.pl'
3
4 ######################### We start with some black magic to print on failure.
5
6 # Change 1..1 below to 1..last_test_to_print .
7 # (It may become useful if the test is moved to ./t subdirectory.)
8
9 BEGIN { $| = 1; print "1..4\n"; }
10 END {print "not ok 1\n" unless $loaded;}
11 use Imager qw(:all);
12 use Imager::Color;
13
14 $loaded = 1;
15 print "ok 1\n";
16
17 #$Imager::DEBUG=1;
18
19 init_log("testout/t30t1font.log",1);
20
21 if (!(i_has_format("t1")) ) {
22   print "ok 2 # skip\n";
23   print "ok 3 # skip\n";
24   print "ok 4 # skip\n";
25 } else {
26
27   print "# has t1\n";
28   
29   $fontname_pfb=$ENV{'T1FONTTESTPFB'}||'./fontfiles/dcr10.pfb';
30   $fontname_afm=$ENV{'T1FONTTESTAFM'}||'./fontfiles/dcr10.afm';
31
32   if (! -f $fontname_pfb) {
33     print "# cannot find fontfile for truetype test $fontname_pfb\n";
34     skip();     
35   }
36
37   if (! -f $fontname_afm) {
38     print "# cannot find fontfile for truetype test $fontname_afm\n";
39     skip();
40   }
41
42   i_init_fonts();
43   i_t1_set_aa(1);
44   
45   $fnum=Imager::i_t1_new($fontname_pfb,$fontname_afm); # this will load the pfb font
46   if ($fnum<0) { die "Couldn't load font $fontname_pfb"; }
47  
48   $bgcolor=Imager::Color->new(255,0,0,0);
49   $overlay=Imager::ImgRaw::new(200,70,3);
50   
51   i_t1_cp($overlay,5,50,1,$fnum,50.0,'XMCLH',5,1);
52   i_draw($overlay,0,50,100,50,$bgcolor);
53   
54   @bbox=i_t1_bbox(0,50.0,'XMCLH',5);
55   print "bbox: ($bbox[0], $bbox[1]) - ($bbox[2], $bbox[3])\n";
56   
57   open(FH,">testout/t30t1font.ppm") || die "cannot open testout/t35t1font.ppm\n";
58   binmode(FH); # for os2
59   i_writeppm($overlay,fileno(FH));
60   close(FH);
61
62   print "ok 2\n";
63   
64   $bgcolor=Imager::Color::set($bgcolor,200,200,200,0);
65   $backgr=Imager::ImgRaw::new(280,150,3);
66
67   i_t1_set_aa(2);
68   i_t1_text($backgr,10,100,$bgcolor,$fnum,150.0,'test',4,1);
69   
70   open(FH,">testout/t30t1font2.ppm") || die "cannot open testout/t35t1font.ppm\n";
71   binmode(FH);
72   i_writeppm($backgr,fileno(FH));
73   close(FH);
74   
75   print "ok 3\n";
76   
77   $rc=i_t1_destroy($fnum);
78   if ($fnum <0) { die "i_t1_destroy failed: rc=$rc\n"; }
79
80   print "ok 4\n";
81
82   print "# debug: ",join(" x ",i_t1_bbox(0,50,"eses",4) ),"\n";
83   print "# debug: ",join(" x ",i_t1_bbox(0,50,"llll",4) ),"\n";
84 }
85
86 #malloc_state();