3 # Parse AFM metric files
6 @widths = ((undef)x256);
8 while ( $line = <STDIN> ) {
9 if ( $line =~ /^\s*FontName\s+(.*)\s*$/ ) {
11 } elsif ( $line =~ /^\s*StartCharMetrics\b/ ) {
13 } elsif ( $line =~ /^\s*EndCharMetrics\b/ ) {
15 } elsif ( $line =~ /^\s*StartKernPairs\b/ ) {
17 } elsif ( $line =~ /^\s*EndKernPairs\b/ ) {
19 } elsif ( $charmetrics ) {
20 @data = split(/\s*;\s*/, $line);
21 undef $charcode, $width, $name;
22 foreach $d ( @data ) {
23 @dd = split(/\s+/, $d);
24 if ( $dd[0] eq 'C' ) {
26 } elsif ( $dd[0] eq 'WX' ) {
28 } elsif ( $dd[0] eq 'W' ) {
30 } elsif ( $dd[0] eq 'N' ) {
34 if ( defined($name) && defined($width) ) {
35 $charwidth{$name} = $width;
37 } elsif ( $kerndata ) {
38 @data = split(/\s+/, $line);
39 if ( $data[0] eq 'KPX' ) {
40 if ( defined($charcodes{$data[1]}) &&
41 defined($charcodes{$data[2]}) &&
43 $kernpairs{chr($charcodes{$data[1]}).
44 chr($charcodes{$data[2]})} = $data[3];
54 for ( $i = 0 ; $i < length($s) ; $i++ ) {
56 if ( $c lt ' ' || $c gt '~' ) {
57 $o .= sprintf("\\%03o", ord($c));
58 } elsif ( $c eq "\'" || $c eq "\"" || $c eq "\\" ) {
68 $psfont =~ s/[^A-Za-z0-9]/_/g;
70 print "%PS_${psfont} = (\n";
71 print " name => \'$fontname\',\n";
74 foreach $cc ( keys(%charwidth) ) {
75 $ss = sprintf('%s => %d, ', qstr($cc), $charwidth{$cc});
79 $lw = 4 + length($ss);
86 #foreach $kp ( keys(%kernpairs) ) {
87 # $ss = sprintf('%s => %d, ', qstr($kp), $kernpairs{$kp});
91 # $lw = 4 + length($ss);