[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Problems with AFM::Font




The Font::AFM module included in MacPerl 5.1.9r4 doesn't work.


(1) Attempting to 'use' the module fails with a compilation error:

    use Font::AFM;

The error is in the following AFM.pm code:

    if (!$ENV{METRICS} && $^O eq "MacOS") {
        eval <<END;
    use Mac::Files;

    $ENV{METRICS} = FindFolder kOnSystemDisk, kFontsFolderType;
    END
    }

The variable $ENV{METRICS} is interpolated in the here-document because the
END is not within single quotes.


(2) AFM.pm assumes colon-separated paths in $ENV{METRICS}; this
conflicts with the Mac's use of the colon in paths:

    my $metrics_path = $ENV{METRICS} ||
        "/usr/lib/afm:/usr/local/lib/afm:/usr/openwin/lib/fonts/afm/:.";
    my @metrics_path = split(/:/, $metrics_path);


(3) The AFM.pm code that searches for the afm file assumes slash is the
directory deliminter in paths, and that a path is relative if it doesn't
start with a slash:

    $file = "$fontname.afm";
    unless ($file =~ m,^/,) {
        # not absolute, search the metrics path for the file
        foreach (@metrics_path) {
            if (-f "$_/$file") {
                $file = "$_/$file";
               last;
            }
        }
    }


Changes that fix these problems follow.

Jim

------OLD----- (lines 193..206)
# The metrics_path is used to locate metrics files
#
if (!$ENV{METRICS} && $^O eq "MacOS") {
    eval <<END;
use Mac::Files;

$ENV{METRICS} = FindFolder kOnSystemDisk, kFontsFolderType;
END
}

my $metrics_path = $ENV{METRICS} ||
    "/usr/lib/afm:/usr/local/lib/afm:/usr/openwin/lib/fonts/afm/:.";
my @metrics_path = split(/:/, $metrics_path);
foreach (@metrics_path) { s,/$,, }    # reove trailing slashes
------NEW-----
# The metrics_path is used to locate metrics files
#
my @metrics_path;
if ($^O eq "MacOS") {
    if (!$ENV{METRICS}) { eval <<'END'
        use Mac::Files;
        $ENV{METRICS} = FindFolder kOnSystemDisk, kFontsFolderType;
END
    }
    @metrics_path = ($ENV{METRICS}); # not a colon-separated list of paths!
} else {
    my $metrics_path = $ENV{METRICS} ||
        "/usr/lib/afm:/usr/local/lib/afm:/usr/openwin/lib/fonts/afm/:.";
    @metrics_path = split(/:/, $metrics_path);
    foreach (@metrics_path) { s,/$,, }    # reove trailing slashes
}


------OLD----- (lines 250..263)
   if ($^O eq 'VMS') {
       $file = "sys\$ps_font_metrics:$fontname.afm";
   } else {
       $file = "$fontname.afm";
       unless ($file =~ m,^/,) {
           # not absolute, search the metrics path for the file
           foreach (@metrics_path) {
               if (-f "$_/$file") {
                   $file = "$_/$file";
                   last;
               }
           }
       }
   }
------NEW-----
   if ($^O eq 'VMS') {
       $file = "sys\$ps_font_metrics:$fontname.afm";
   } elsif ($^O eq 'MacOS') {
       $file = "$fontname.afm";
       if ($file =~ s,^:,, || $file !~ m,:,) {
           # not absolute, search the metrics path for the file
           foreach (@metrics_path) {
               if (-f "$_:$file") {
                   $file = "$_:$file";
                   last;
               }
           }
       }
   } else {
       $file = "$fontname.afm";
       unless ($file =~ m,^/,) {
           # not absolute, search the metrics path for the file
           foreach (@metrics_path) {
               if (-f "$_/$file") {
                   $file = "$_/$file";
                   last;
               }
           }
       }
   }


--
Jim Miner          jfm@winternet.com           +1 612 729 1667



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch