Skip to content

Commit

Permalink
don't pass "0" as the afm filename if it isn't supplied
Browse files Browse the repository at this point in the history
This came up while debugging #510 and prevents one of the tests
from crashing, but doesn't fix the underlying problem that
that build of t1lib is crashing when an afm filename is
supplied.
  • Loading branch information
tonycoz committed Jul 8, 2023
1 parent a58149c commit 4acb818
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
27 changes: 14 additions & 13 deletions T1/T1.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ our @ISA = qw(Imager::Font);
use Scalar::Util ();

BEGIN {
our $VERSION = "1.029";
our $VERSION = "1.030";

require XSLoader;
XSLoader::load('Imager::Font::T1', $VERSION);
Expand Down Expand Up @@ -42,18 +42,19 @@ sub new {
$hsh{file} = './' . $hsh{file};
}

if($hsh{afm}) {
unless (-e $hsh{afm}) {
$Imager::ERRSTR = "Afm file $hsh{afm} not found";
return;
}
unless ($hsh{afm} =~ m!^/!
|| $hsh{afm} =~ m!^\./!
|| $^O =~ /^(MSWin32|cygwin)$/ && $hsh{file} =~ /^[a-z]:/i) {
$hsh{file} = './' . $hsh{file};
}
} else {
$hsh{afm} = 0;
if(defined $hsh{afm} && length $hsh{afm}) {
unless (-e $hsh{afm}) {
$Imager::ERRSTR = "Afm file $hsh{afm} not found";
return;
}
unless ($hsh{afm} =~ m!^/!
|| $hsh{afm} =~ m!^\./!
|| $^O =~ /^(MSWin32|cygwin)$/ && $hsh{file} =~ /^[a-z]:/i) {
$hsh{file} = './' . $hsh{file};
}
}
else {
$hsh{afm} = undef;
}

my $font = Imager::Font::T1xs->new($hsh{file},$hsh{afm});
Expand Down
6 changes: 4 additions & 2 deletions T1/T1.xs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ typedef i_t1_font_t Imager__Font__T1xs;

#define i_t1_DESTROY(font) i_t1_destroy(font)

typedef char * possible_str;

MODULE = Imager::Font::T1 PACKAGE = Imager::Font::T1

undef_int
Expand All @@ -25,8 +27,8 @@ MODULE = Imager::Font::T1 PACKAGE = Imager::Font::T1xs PREFIX = i_t1_

Imager::Font::T1xs
i_t1_new(class,pfb,afm)
char* pfb
char* afm
char* pfb
possible_str afm
C_ARGS:
pfb, afm

Expand Down
7 changes: 7 additions & 0 deletions T1/typemap
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
Imager::Font::T1xs T_PTROBJ
possible_str T_POSSIBLESTR

INPUT

T_POSSIBLESTR
SvGETMAGIC($arg);
$var = SvOK($arg) ? SvPV_nomg_nolen($arg) : NULL;

0 comments on commit 4acb818

Please sign in to comment.