3 use Test::More tests => 13;
5 BEGIN { use_ok('Imager') }
7 require_ok('Imager::Font::Wrap');
9 my $img = Imager->new(xsize=>400, ysize=>400);
12 This is a test of text wrapping. This is a test of text wrapping. This =
13 is a test of text wrapping. This is a test of text wrapping. This is a =
14 test of text wrapping. This is a test of text wrapping. This is a test =
15 of text wrapping. This is a test of text wrapping. This is a test of =
18 Xxxxxxxxxxxxxxxxxxxxxxxxxxxwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww xxxx.
20 This is a test of text wrapping. This is a test of text wrapping. This =
21 is a test of text wrapping. This is a test of text wrapping. This is a =
22 test of text wrapping. This is a test of text wrapping. This is a test =
23 of text wrapping. This is a test of text wrapping. This is a test of =
24 text wrapping. This is a test of text wrapping. This is a test of text =
25 wrapping. This is a test of text wrapping. This is a test of text =
26 wrapping. This is a test of text wrapping. This is a test of text =
27 wrapping. This is a test of text wrapping. This is a test of text =
33 my $fontfile = $ENV{WRAPTESTFONT} || $ENV{TTFONTTEST} || "fontfiles/ImUgly.ttf";
35 my $font = Imager::Font->new(file=>$fontfile);
39 Imager::i_has_format('tt') || Imager::i_has_format('ft2')
40 or skip("Need Freetype 1.x or 2.x to test", 11);
42 ok($font, "loading font")
43 or skip("Could not load test font", 8);
45 Imager::Font->priorities(qw(t1 ft2 tt));
46 ok(scalar Imager::Font::Wrap->wrap_text(string => $text,
55 ok($img->write(file=>'testout/t80wrapped.ppm'), "save to file");
56 ok(scalar Imager::Font::Wrap->wrap_text(string => $text,
65 my $bbox = $font->bounding_box(string=>"Xx", size=>13);
66 ok($bbox, "get height for check");
69 ok(scalar Imager::Font::Wrap->wrap_text
70 (string=>$text, font=>$font, image=>undef, size=>13, width=>380,
71 savepos=> \$used, height => $bbox->font_height), "savepos call");
72 ok($used > 20 && $used < length($text), "savepos value");
74 my @box = Imager::Font::Wrap->wrap_text
75 (string=>substr($text, 0, $used), font=>$font, image=>undef, size=>13,
78 ok(@box == 4, "bounds list count");
80 ok($box[3] == $bbox->font_height, "check height");
83 # http://rt.cpan.org/Ticket/Display.html?id=29771
84 # the length of the trailing line wasn't included in the text consumed
86 ok(scalar Imager::Font::Wrap->wrap_text
87 ( string => "test", font => $font, image => undef, size => 12,
88 width => 200, savepos => \$used, height => $bbox->font_height),
89 "regression 29771 - call wrap_text");
90 is($used, 4, "all text should be consumed");