"i_wf_cp smoke test");
i_line($overlay,0,50,100,50,$bgcolor, 1);
- open(FH,">testout/t10font.ppm") || die "cannot open testout/t10font.ppm\n";
- binmode(FH);
- my $io = Imager::io_new_fd(fileno(FH));
- i_writeppm_wiol($overlay,$io);
- close(FH);
+ if (open(FH,">testout/t10font.ppm")) {
+ binmode(FH);
+ my $io = Imager::io_new_fd(fileno(FH));
+ i_writeppm_wiol($overlay,$io);
+ close(FH);
+ }
+ else {
+ diag "cannot open testout/t10font.ppm: $!";
+ }
$bgcolor=i_color_set($bgcolor,200,200,200,0);
my $backgr=Imager::ImgRaw::new(500,300,3);
"i_wf_text smoke test");
i_line($backgr,0, 100, 499, 100, NC(0, 0, 255), 1);
- open(FH,">testout/t10font2.ppm") || die "cannot open testout/t10font2.ppm\n";
- binmode(FH);
- $io = Imager::io_new_fd(fileno(FH));
- i_writeppm_wiol($backgr,$io);
- close(FH);
-
+ if (open(FH,">testout/t10font2.ppm")) {
+ binmode(FH);
+ my $io = Imager::io_new_fd(fileno(FH));
+ i_writeppm_wiol($backgr,$io);
+ close(FH);
+ }
+ else {
+ diag "cannot open testout/t10font2.ppm: $!";
+ }
+
my $img = Imager->new(xsize=>200, ysize=>200);
my $font = Imager::Font->new(face=>$fontname, size=>20);
ok($img->string('x'=>30, 'y'=>30, string=>"Imager", color=>NC(255, 0, 0),
font=>$font),
"string with win32 smoke test")
- or print "# ",$img->errstr,"\n";
- $img->write(file=>'testout/t10_oo.ppm') or print "not ";
+ or diag "simple string output: ",$img->errstr;
+ $img->write(file=>'testout/t10_oo.ppm')
+ or diag "Cannot save t10_oo.ppm: ", $img->errstr;
my @bbox2 = $font->bounding_box(string=>'Imager');
is(@bbox2, 8, "got 8 values from bounding_box");
SKIP:
{
$^O eq 'cygwin' and skip("Too hard to get correct directory for test font on cygwin", 13);
- ok(Imager::Font::W32::i_wf_addfont("fontfiles/ExistenceTest.ttf"), "add test font")
- or print "# ",Imager::_error_as_msg(),"\n";
+ my $extra_font = "fontfiles/ExistenceTest.ttf";
+ unless (ok(Imager::Font::W32::i_wf_addfont($extra_font), "add test font")) {
+ diag "adding font resource: ",Imager::_error_as_msg();
+ skip("Could not add font resource", 12);
+ }
my $namefont = Imager::Font->new(face=>"ExistenceTest");
ok($namefont, "create font based on added font");
is(@bbox, 8, "should be 8 entries");
isnt($bbox[6], $bbox[2], "different advance width");
$bbox = $namefont->bounding_box(string=>"/", size=>100);
- ok($bbox->pos_width != $bbox->advance_width, "OO check");
+ isnt($bbox->pos_width, $bbox->advance_width, "OO check");
cmp_ok($bbox->right_bearing, '<', 0, "check right bearing");
$im->line(color=>'blue', x1=>0, y1 => 100, x2=>199, y2 => 100);
ok($im->string(font=>$namefont, text=>"/", x=>20, y=>100, color=>'white', size=>100),
"draw / from ExistenceText")
- or print "# ", $im->errstr, "\n";
+ or diag "draw / from ExistenceTest:", $im->errstr;
$im->setpixel(x => 20+$bbox->neg_width, y => 100-$bbox->ascent, color => 'red');
$im->setpixel(x => 20+$bbox->advance_width - $bbox->right_bearing, y => 100-$bbox->descent, color => 'red');
$im->write(file=>'testout/t10_slash.ppm');
$im->line(color=>'blue', x1=>0, y1 => 100, x2=>199, y2 => 100);
ok($im->string(font=>$namefont, text=>"!", x=>20, y=>100, color=>'white', size=>100),
"draw / from ExistenceText")
- or print "# ", $im->errstr, "\n";
+ or diag "draw / from ExistenceTest: ", $im->errstr;
$im->setpixel(x => 20+$bbox->neg_width, y => 100-$bbox->ascent, color => 'red');
$im->setpixel(x => 20+$bbox->advance_width - $bbox->right_bearing, y => 100-$bbox->descent, color => 'red');
$im->write(file=>'testout/t10_bang.ppm');
ok($im->string(string => "\xE2\x98\xBA", size => 80, aa => 1, utf8 => 1,
color => "white", font => $font, x => 5, y => 80),
"draw in utf8 (hand encoded)")
- or print "# ", $im->errstr, "\n";
- ok($im->write(file=>'testout/t10utf8.ppm'), "save utf8 image");
+ or diag "draw utf8 hand-encoded ", $im->errstr;
+ ok($im->write(file=>'testout/t10utf8.ppm'), "save utf8 image")
+ or diag "save t10utf8.ppm: ", $im->errstr;
# native perl utf8
# Win32 only supported on 5.6+
ok($im2->string(string => $text, size => 80, aa => 1,
color => 'white', font => $font, x => 5, y => 80),
"draw in utf8 (perl utf8)")
- or print "# ", $im->errstr, "\n";
+ or diag "draw in utf8: ", $im->errstr;
ok($im2->write(file=>'testout/t10utf8b.ppm'), "save utf8 image");
is(Imager::i_img_diff($im->{IMG}, $im2->{IMG}), 0,
"check result is the same");
ok($im->string(text => "T", font => $font, y => 15),
"draw with default color")
- or print "# ", $im->errstr, "\n";
+ or diag "draw with default color: ", $im->errstr;
my $work = Imager->new(xsize => 20, ysize => 20);
my $cmp = $work->copy;
$work->rubthrough(src => $im);
i_wf_addfont(char const *filename) {
i_clear_error();
+ mm_log((1, "i_wf_addfont(%s)\n", filename));
if (!gdi_dll) {
gdi_dll = GetModuleHandle("GDI32");
if (gdi_dll) {
AddFontResourceExAp = (AddFontResourceExA_t)GetProcAddress(gdi_dll, "AddFontResourceExA");
RemoveFontResourceExAp = (RemoveFontResourceExA_t)GetProcAddress(gdi_dll, "RemoveFontResourceExA");
+ mm_log((1, "i_wf_addfont: AddFontResourceExA %p RemoveFontResourceExA %p\n",
+ AddFontResourceExAp, RemoveFontResourceExAp));
}
}
- if (AddFontResourceExAp && RemoveFontResourceExAp
- && AddFontResourceExAp(filename, FR_PRIVATE, 0)) {
- return 1;
- }
- else if (AddFontResource(filename)) {
- return 1;
+ if (AddFontResourceExAp && RemoveFontResourceExAp) {
+ mm_log((1, "i_wf_addfont: adding via AddFontResourceEx()\n"));
+ if (AddFontResourceExAp(filename, FR_PRIVATE, 0)) {
+ return 1;
+ }
}
else {
- i_push_errorf(0, "Could not add resource: %ld", GetLastError());
- return 0;
+ mm_log((1, "i_wf_addfont: adding via AddFontResource()\n"));
+ if (AddFontResource(filename)) {
+ return 1;
+ }
}
+
+ mm_log((1, "i_wf_addfont failed: %ld\n", GetLastError()));
+ i_push_errorf(0, "Could not add resource: %ld", GetLastError());
+ return 0;
}
/*
i_wf_delfont(char const *filename) {
i_clear_error();
- if (AddFontResourceExAp && RemoveFontResourceExAp
- && RemoveFontResourceExAp(filename, FR_PRIVATE, 0)) {
- return 1;
- }
- else if (RemoveFontResource(filename)) {
- return 1;
+ mm_log((1, "i_wf_delfont(%s)\n", filename));
+
+ if (AddFontResourceExAp && RemoveFontResourceExAp) {
+ mm_log((1, "i_wf_delfont: removing via RemoveFontResourceEx()\n"));
+ if (RemoveFontResourceExAp(filename, FR_PRIVATE, 0))
+ return 1;
}
else {
- i_push_errorf(0, "Could not remove resource: %ld", GetLastError());
- return 0;
+ mm_log((1, "i_wf_delfont: adding via RemoveFontResourceEx()\n"));
+ if (RemoveFontResource(filename))
+ return 1;
}
+
+ mm_log((1, "i_wf_delfont failed: %ld\n", GetLastError()));
+ i_push_errorf(0, "Could not remove resource: %ld", GetLastError());
+ return 0;
}
/*