# -*- perl -*- # based on `vfinst.cmn' sub match_line { # if first string is in line, the remainder of line is stored my ($searchstr) = $_[0]; if (/^$searchstr (.+)/) { $_[1] = $1; $_[1] =~ s/\s//g; } } sub get_afm_data { my ($afm) = @_; my ($fontname, $fullname, $familyname, $weight, $encoding, $italicangle, $monowidth) = (); open(CURRAFM, $afm) || die "Cannot open $afm."; my $sign = ; die "$afm is not an AFM file\n" unless $sign && $sign =~ /^StartFontMetrics/; while () { s/\r//g; # for DOS files chomp; last if /StartCharMetrics/; &match_line ("FontName", $fontname); &match_line ("FullName", $fullname); &match_line ("FamilyName", $familyname); &match_line ("Weight", $weight); &match_line ("EncodingScheme", $encoding); &match_line ("ItalicAngle", $italicangle); &match_line ("IsFixedPitch", $monowidth); } close CURRAFM; return [$fontname, $fullname, $familyname, $weight, $encoding, $italicangle, $monowidth]; } 1;