From: Tony Cook Date: Fri, 14 Oct 2011 11:11:08 +0000 (+1100) Subject: [rt #69879] various T1 improvments X-Git-Tag: v0.85_02~16 X-Git-Url: http://git.imager.perl.org/imager.git/commitdiff_plain/73e3ff553db21593d26f9b0f8042ab30d8fae42c?ds=sidebyside [rt #69879] various T1 improvments --- diff --git a/Changes b/Changes index 541c8af0..57576c29 100644 --- a/Changes +++ b/Changes @@ -32,6 +32,15 @@ Bug fixes: - add overloaded eq to Imager::Matrix2d, since older perls don't seem to synthesize it from overloaded "". + - use T1_StrError() for error messages on modern libt1 + https://rt.cpan.org/Ticket/Display.html?id=69879 + + - actually load the font rather than just adding it to the catalog on + creation. + + - Imager::Font->new now produces better error messages for the T1 + engine. + Imager 0.85_01 - 10 Oct 2011 ============== diff --git a/T1/Changes b/T1/Changes index 4fd2a438..91802392 100644 --- a/T1/Changes +++ b/T1/Changes @@ -1,3 +1,15 @@ +Imager::Font::T1 1.015 +====================== + + - use T1_StrError() for error messages on modern libt1 + https://rt.cpan.org/Ticket/Display.html?id=69879 + + - actually load the font rather than just adding it to the catalog on + creation. + + - Imager::Font->new now produces better error messages for the T1 + engine. + Imager::Font::T1 1.014 ====================== diff --git a/T1/T1.pm b/T1/T1.pm index 80663ba9..89dd12eb 100644 --- a/T1/T1.pm +++ b/T1/T1.pm @@ -74,7 +74,7 @@ sub new { my $id = i_t1_new($hsh{file},$hsh{afm}); unless ($id >= 0) { # the low-level code may miss some error handling - $Imager::ERRSTR = "Could not load font ($id)"; + Imager->_set_error(Imager->_error_as_msg); return; } return bless { diff --git a/T1/imt1.c b/T1/imt1.c index 9c19c53b..3027e424 100644 --- a/T1/imt1.c +++ b/T1/imt1.c @@ -93,6 +93,7 @@ i_t1_new(char *pfb,char *afm) { font_id = T1_AddFont(pfb); if (font_id<0) { mm_log((1,"i_t1_new: Failed to load pfb file '%s' - return code %d.\n",pfb,font_id)); + t1_push_error(); return font_id; } @@ -101,8 +102,18 @@ i_t1_new(char *pfb,char *afm) { if (T1_SetAfmFileName(font_id,afm)<0) mm_log((1,"i_t1_new: afm loading of '%s' failed.\n",afm)); } + if (T1_LoadFont(font_id)) { + mm_log((1, "i_t1_new() -> -1 - T1_LoadFont failed (%d)\n", T1_errno)); + t1_push_error(); + i_push_error(0, "loading font"); + T1_DeleteFont(font_id); + return -1; + } + ++t1_active_fonts; + mm_log((1, "i_t1_new() -> %d\n", font_id)); + return font_id; } @@ -572,6 +583,10 @@ i_t1_glyph_name(int font_num, unsigned long ch, char *name_buf, static void t1_push_error(void) { +#if T1LIB_VERSION > 5 || T1LIB_VERSION == 5 && T1LIB_VERSION >= 1 + /* I don't know when T1_StrError() was introduced, be conservative */ + i_push_error(T1_errno, T1_StrError(T1_errno)); +#else switch (T1_errno) { case 0: i_push_error(0, "No error"); @@ -682,5 +697,6 @@ t1_push_error(void) { default: i_push_errorf(T1_errno, "unknown error %d", (int)T1_errno); } +#endif } diff --git a/T1/t/t20oo.t b/T1/t/t20oo.t index 16935c41..273743e5 100644 --- a/T1/t/t20oo.t +++ b/T1/t/t20oo.t @@ -2,7 +2,7 @@ use strict; use Imager; use Imager::Test qw(isnt_image); -use Test::More tests => 13; +use Test::More tests => 14; # extracted from t/t36oofont.t @@ -80,6 +80,14 @@ ok($img->write(file=>"testout/t36oofont1.ppm", type=>'pnm'), } } +{ # open a non-font as a font (test open failure) + local $ENV{LANG} = "C"; + local $ENV{LC_ALL} = "C"; + my $font = Imager::Font->new(file => "t/t20oo.t", type => "t1"); + ok(!$font, "should fail to open test script as a font"); + print "# ", Imager->errstr, "\n"; +} + unless ($ENV{IMAGER_KEEP_FILES}) { unlink "testout/t36oofont1.ppm"; }