W32/Makefile.PL
W32/README
W32/t/t10win32.t Tests Win32 GDI font support
+W32/t/t90std.t Standard font tests for W32
W32/W32.pm
W32/W32.xs
W32/win32.c Implements font support through Win32 GDI
-Changes\r
-fontfiles/ExistenceTest.ttf\r
-imw32.h\r
-inc/Devel/CheckLib.pm\r
-lib/Imager/Font/Win32.pm\r
-Makefile.PL\r
-MANIFEST This list of files\r
-MANIFEST.SKIP\r
-README\r
-t/t10win32.t\r
-W32.pm\r
-W32.xs\r
-win32.c\r
+Changes
+fontfiles/ExistenceTest.ttf
+imw32.h
+inc/Devel/CheckLib.pm
+lib/Imager/Font/Win32.pm
+Makefile.PL
+MANIFEST This list of files
+MANIFEST.SKIP
+README
+t/t10win32.t
+t/t90std.t Standard font tests for W32
+W32.pm
+W32.xs
+win32.c
@ISA = qw(Imager::Font);
BEGIN {
- $VERSION = "0.85";
+ $VERSION = "0.86";
require XSLoader;
XSLoader::load('Imager::Font::W32', $VERSION);
my ($self, %opts) = @_;
my @bbox = i_wf_bbox($self->{face}, $opts{size}, $opts{string}, $opts{utf8});
+ unless (@bbox) {
+ Imager->_set_error(Imager->_error_as_msg);
+ return;
+ }
+
+ return @bbox;
}
sub _draw {
my %input = @_;
if (exists $input{channel}) {
- i_wf_cp($self->{face}, $input{image}{IMG}, $input{x}, $input{'y'},
+ return i_wf_cp($self->{face}, $input{image}{IMG}, $input{x}, $input{'y'},
$input{channel}, $input{size},
$input{string}, $input{align}, $input{aa}, $input{utf8});
}
else {
- i_wf_text($self->{face}, $input{image}{IMG}, $input{x},
+ return i_wf_text($self->{face}, $input{image}{IMG}, $input{x},
$input{'y'}, $input{color}, $input{size},
$input{string}, $input{align}, $input{aa}, $input{utf8});
}
-
- return 1;
}
return 1;
}
+sub can_glyph_names {
+ return;
+}
+
1;
__END__
--- /dev/null
+#!perl -w
+use strict;
+use Imager::Test qw(std_font_tests std_font_test_count);
+use Imager::Font;
+use Test::More tests => std_font_test_count();
+
+Imager->open_log(log => "testout/t90std.log");
+
+my $font = Imager::Font->new(face => "Times New Roman Bold",
+ type => "w32");
+
+SKIP:
+{
+ $font
+ or skip "Cannot load font", std_font_test_count();
+ std_font_tests
+ ({
+ font => $font,
+ #has_chars => [ 1, 1, 1 ],
+ #files => 1,
+ #glyph_name_font => $name_font,
+ #glyph_names => [ "A", "uni2010", "A" ],
+ });
+}
+Imager->close_log;
\ No newline at end of file
static
LPWSTR
utf8_to_wide_string(char const *text, int text_len, int *wide_chars) {
- int wide_count = MultiByteToWideChar(CP_UTF8, 0, text, text_len, NULL, 0);
+ int wide_count = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, text, text_len, NULL, 0);
LPWSTR result;
if (wide_count < 0) {
}
++wide_count;
result = mymalloc(sizeof(WCHAR) * wide_count);
- if (MultiByteToWideChar(CP_UTF8, 0, text, text_len, result, wide_count) < 0) {
+ if (MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, text, text_len, result, wide_count) < 0) {
i_push_errorf(0, "Could not convert utf8: %ld", GetLastError());
return NULL;
}
$base_cp->write(file => "testout/utf8bcp.ppm");
}
- Imager->log("magic: has_chars");
- is_deeply([ $font->has_chars(string => $text) ], $has_chars,
- "magic: has_chars with normal utf8 text");
- is_deeply([ $font->has_chars(string => $over) ], $has_chars,
- "magic: has_chars with magic utf8 text");
+ SKIP:
+ {
+ Imager->log("magic: has_chars\n");
+ $font->can("has_chars")
+ or skip "No has_chars aupport", 2;
+ is_deeply([ $font->has_chars(string => $text) ], $has_chars,
+ "magic: has_chars with normal utf8 text");
+ is_deeply([ $font->has_chars(string => $over) ], $has_chars,
+ "magic: has_chars with magic utf8 text");
+ }
Imager->log("magic: bounding_box\n");
my @base_bb = $font->bounding_box(string => $text, size => 30);
ok(!$font->bounding_box(string => $bad_utf8, size => 30, utf8 => 1),
"bounding_box() bad utf8 should fail");
is(Imager->errstr, "invalid UTF8 character", "check error message");
- Imager->_set_error("");
- is_deeply([ $font->glyph_names(string => $bad_utf8, utf8 => 1) ],
- [ ],
- "glyph_names returns empty list for bad string");
- is(Imager->errstr, "invalid UTF8 character", "check error message");
- Imager->_set_error("");
- is_deeply([ $font->has_chars(string => $bad_utf8, utf8 => 1) ],
- [ ],
- "has_chars returns empty list for bad string");
- is(Imager->errstr, "invalid UTF8 character", "check error message");
+ SKIP:
+ {
+ $font->can_glyph_names
+ or skip "No glyph_names support", 2;
+ Imager->_set_error("");
+ is_deeply([ $font->glyph_names(string => $bad_utf8, utf8 => 1) ],
+ [ ],
+ "glyph_names returns empty list for bad string");
+ is(Imager->errstr, "invalid UTF8 character", "check error message");
+ }
+ SKIP:
+ {
+ $font->can("has_chars")
+ or skip "No has_chars support", 2;
+ Imager->_set_error("");
+ is_deeply([ $font->has_chars(string => $bad_utf8, utf8 => 1) ],
+ [ ],
+ "has_chars returns empty list for bad string");
+ is(Imager->errstr, "invalid UTF8 character", "check error message");
+ }
}
}