4 require "t/testtools.pl";
5 $| = 1; print "1..11\n";
7 END { okx(0, "loading") unless $loaded; }
13 requireokx("Imager/Font/Wrap.pm", "load basic wrapping");
15 my $img = Imager->new(xsize=>400, ysize=>400);
18 This is a test of text wrapping. This is a test of text wrapping. This =
19 is a test of text wrapping. This is a test of text wrapping. This is a =
20 test of text wrapping. This is a test of text wrapping. This is a test =
21 of text wrapping. This is a test of text wrapping. This is a test of =
24 Xxxxxxxxxxxxxxxxxxxxxxxxxxxwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww xxxx.
26 This is a test of text wrapping. This is a test of text wrapping. This =
27 is a test of text wrapping. This is a test of text wrapping. This is a =
28 test of text wrapping. This is a test of text wrapping. This is a test =
29 of text wrapping. This is a test of text wrapping. This is a test of =
30 text wrapping. This is a test of text wrapping. This is a test of text =
31 wrapping. This is a test of text wrapping. This is a test of text =
32 wrapping. This is a test of text wrapping. This is a test of text =
33 wrapping. This is a test of text wrapping. This is a test of text =
39 my $fontfile = $ENV{WRAPTESTFONT} || $ENV{TTFONTTEST} || "fontfiles/ImUgly.ttf";
41 my $font = Imager::Font->new(file=>$fontfile);
43 unless (Imager::i_has_format('tt') || Imager::i_has_format('ft2')) {
44 skipx(9, "Need Freetype 1.x or 2.x to test");
48 if (okx($font, "loading font")) {
49 Imager::Font->priorities(qw(t1 ft2 tt));
50 okx(scalar Imager::Font::Wrap->wrap_text(string => $text,
59 okx($img->write(file=>'testout/t80wrapped.ppm'), "save to file");
60 okx(scalar Imager::Font::Wrap->wrap_text(string => $text,
69 my $bbox = $font->bounding_box(string=>"Xx", size=>13);
70 okx($bbox, "get height for check");
73 okx(scalar Imager::Font::Wrap->wrap_text
74 (string=>$text, font=>$font, image=>undef, size=>13, width=>380,
75 savepos=> \$used, height => $bbox->font_height), "savepos call");
76 okx($used > 20 && $used < length($text), "savepos value");
78 my @box = Imager::Font::Wrap->wrap_text
79 (string=>substr($text, 0, $used), font=>$font, image=>undef, size=>13,
82 okx(@box == 4, "bounds list count");
84 okx($box[3] == $bbox->font_height, "check height");
87 skipx(8, "Could not load test font");