unicode character when it should have used unsigned long.
- the XS code for i_t1_glyph_name() used unsigned char to store a
unicode character when it should have used unsigned long.
- resolves https://rt.cpan.org/Ticket/Display.html?id=7949
- the type 1 glyph_names() method didn't do correct error handling
when the string parameter wasn't supplied
names
- added reliable_only optional parameter to the glyph_names()
method so you can ignore theresult of FT_Has_PS_Glyph_Names()
-- partly resolves https://rt.cpan.org/Ticket/Display.html?id=7949
- handle errors given by i_ft2_glyph_name() a bit more
correctly
- the FT1 glyph_names() method didn't do correct error handling
wasn't being released (detected with valgrind)
- the testtools.pl match[nx]() functions escapes the test string on
test failure a bit better
+- the XS code for i_tt_glyph_name() used unsigned char to store a
+ unicode character when it should have used unsigned long.
+- the XS code for i_t1_glyph_name() used unsigned char to store a
+ unicode character when it should have used unsigned long.
+- resolves https://rt.cpan.org/Ticket/Display.html?id=7949
+- the type 1 glyph_names() method didn't do correct error handling
+ when the string parameter wasn't supplied
=================================================================
text = SvPV(text_sv, work_len);
len = work_len;
while (len) {
- unsigned char ch;
+ unsigned long ch;
if (utf8) {
ch = i_utf8_advance(&text, &len);
if (ch == ~0UL) {
text = SvPV(text_sv, work_len);
len = work_len;
while (len) {
- unsigned char ch;
+ unsigned long ch;
if (utf8) {
ch = i_utf8_advance(&text, &len);
if (ch == ~0UL) {
my $string = $input{string};
defined $string
- or return Imager->_seterror("no string parameter passed to glyph_names");
+ or return Imager->_set_error("no string parameter passed to glyph_names");
my $utf8 = _first($input{utf8} || 0);
Imager::i_t1_glyph_name($self->{id}, $string, $utf8);
# (It may become useful if the test is moved to ./t subdirectory.)
use strict;
my $loaded;
-BEGIN { $| = 1; print "1..38\n"; }
+BEGIN { $| = 1; print "1..41\n"; }
END {print "not ok 1\n" unless $loaded;}
use Imager qw(:all);
use Imager::Color;
if (!(i_has_format("t1")) ) {
- skipx(37, "t1lib unavailable or disabled");
+ skipx(40, "t1lib unavailable or disabled");
}
elsif (! -f $fontname_pfb) {
- skipx(37, "cannot find fontfile for type 1 test $fontname_pfb");
+ skipx(40, "cannot find fontfile for type 1 test $fontname_pfb");
}
elsif (! -f $fontname_afm) {
- skipx(37, "cannot find fontfile for type 1 test $fontname_afm");
+ skipx(40, "cannot find fontfile for type 1 test $fontname_afm");
} else {
print "# has t1\n";
okx($face_name eq 'ExistenceTest', "face name");
my @glyph_names = $font->glyph_names(string=>"!J/");
- okx($glyph_names[0] eq 'exclam', "check exclam name OO");
+ isx($glyph_names[0], 'exclam', "check exclam name OO");
okx(!defined($glyph_names[1]), "check for no J name OO");
- okx($glyph_names[2] eq 'slash', "check slash name OO");
+ isx($glyph_names[2], 'slash', "check slash name OO");
+
+ # this character chosen since when it's truncated to one byte it
+ # becomes 0x21 or '!' which the font does define
+ my $text = pack("C*", 0xE2, 0x80, 0xA1); # "\x{2021}" as utf-8
+ @glyph_names = $font->glyph_names(string=>$text, utf8=>1);
+ isx($glyph_names[0], undef, "expect no glyph_name for \\x{20A1}");
+
+ # make sure a missing string parameter is handled correctly
+ eval {
+ $font->glyph_names();
+ };
+ isx($@, "", "correct error handling");
+ matchx(Imager->errstr, qr/no string parameter/, "error message");
}
else {
- skipx(12, "Could not load test font");
+ skipx(15, "Could not load test font");
}
}
# (It may become useful if the test is moved to ./t subdirectory.)
use strict;
my $loaded;
-BEGIN { $| = 1; print "1..35\n"; }
+BEGIN { $| = 1; print "1..39\n"; }
END {print "not ok 1\n" unless $loaded;}
use Imager qw(:all);
require "t/testtools.pl";
init_log("testout/t35ttfont.log",2);
unless (i_has_format("tt")) {
- skipx(34, "freetype 1.x unavailable or disabled");
+ skipx(38, "freetype 1.x unavailable or disabled");
malloc_state();
exit;
}
if (! -f $fontname) {
print "# cannot find fontfile for truetype test $fontname\n";
- skipx(34, 'Cannot load test font');
+ skipx(38, 'Cannot load test font');
exit;
}
}
undef $hcfont;
+my $name_font = "fontfiles/NameTest.ttf";
+$hcfont = Imager::Font->new(file=>$name_font);
+if (okx($hcfont, "loading name font")) {
+ # make sure a missing string parameter is handled correctly
+ eval {
+ $hcfont->glyph_names();
+ };
+ isx($@, "", "correct error handling");
+ matchx(Imager->errstr, qr/no string parameter/, "error message");
+
+ my $text = pack("C*", 0xE2, 0x80, 0x90); # "\x{2010}" as utf-8
+ my @names = $hcfont->glyph_names(string=>$text, utf8=>1);
+ isx($names[0], "hyphentwo", "check utf8 glyph name");
+}
+else {
+ skipx(3, "could not load name font $name_font");
+}
+
+undef $hcfont;
+
okx(1, "end of code");
init_log("testout/t38ft2font.log",2);
if (!(i_has_format("ft2")) ) {
- skipx(115, "No freetype2 library found");
+ skipx(119, "No freetype2 library found");
exit;
}
print "# has ft2\n";
$fontname=$ENV{'TTFONTTEST'}||'./fontfiles/dodge.ttf';
if (! -f $fontname) {
- skipx(124, "cannot find fontfile $fontname");
+ skipx(119, "cannot find fontfile $fontname");
malloc_state();
exit;
}
$TESTNUM += $count;
}
-sub okx {
+sub okx ($$) {
my ($ok, $comment) = @_;
return okn($TESTNUM++, $ok, $comment);
}
-sub okn {
+sub okn ($$$) {
my ($num, $ok, $comment) = @_;
defined $num or confess "No \$num supplied";