2 ## --------------------------------------------------------------------------
4 ## Copyright 1996-2009 The NASM Authors - All Rights Reserved
5 ## See the file AUTHORS included with the NASM distribution for
6 ## the specific copyright holders.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted provided that the following
10 ## conditions are met:
12 ## * Redistributions of source code must retain the above copyright
13 ## notice, this list of conditions and the following disclaimer.
14 ## * Redistributions in binary form must reproduce the above
15 ## copyright notice, this list of conditions and the following
16 ## disclaimer in the documentation and/or other materials provided
17 ## with the distribution.
19 ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
20 ## CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
21 ## INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 ## DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 ## NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 ## LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 ## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 ## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 ## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31 ## EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 ## --------------------------------------------------------------------------
36 # Parse AFM metric files
39 @widths = ((undef)x256
);
41 while ( $line = <STDIN
> ) {
42 if ( $line =~ /^\s*FontName\s+(.*)\s*$/ ) {
44 } elsif ( $line =~ /^\s*StartCharMetrics\b/ ) {
46 } elsif ( $line =~ /^\s*EndCharMetrics\b/ ) {
48 } elsif ( $line =~ /^\s*StartKernPairs\b/ ) {
50 } elsif ( $line =~ /^\s*EndKernPairs\b/ ) {
52 } elsif ( $charmetrics ) {
53 @data = split(/\s*;\s*/, $line);
54 undef $charcode, $width, $name;
55 foreach $d ( @data ) {
56 @dd = split(/\s+/, $d);
57 if ( $dd[0] eq 'C' ) {
59 } elsif ( $dd[0] eq 'WX' ) {
61 } elsif ( $dd[0] eq 'W' ) {
63 } elsif ( $dd[0] eq 'N' ) {
67 if ( defined($name) && defined($width) ) {
68 $charwidth{$name} = $width;
70 } elsif ( $kerndata ) {
71 @data = split(/\s+/, $line);
72 if ( $data[0] eq 'KPX' ) {
73 if ( defined($charcodes{$data[1]}) &&
74 defined($charcodes{$data[2]}) &&
76 $kernpairs{chr($charcodes{$data[1]}).
77 chr($charcodes{$data[2]})} = $data[3];
87 for ( $i = 0 ; $i < length($s) ; $i++ ) {
89 if ( $c lt ' ' || $c gt '~' ) {
90 $o .= sprintf("\\%03o", ord($c));
91 } elsif ( $c eq "\'" || $c eq "\"" || $c eq "\\" ) {
101 $psfont =~ s/[^A-Za-z0-9]/_/g;
103 print "%PS_${psfont} = (\n";
104 print " name => \'$fontname\',\n";
105 print " widths => {";
107 foreach $cc ( keys(%charwidth) ) {
108 $ss = sprintf('%s => %d, ', qstr
($cc), $charwidth{$cc});
112 $lw = 4 + length($ss);
119 #foreach $kp ( keys(%kernpairs) ) {
120 # $ss = sprintf('%s => %d, ', qstr($kp), $kernpairs{$kp});
121 # $lw += length($ss);
124 # $lw = 4 + length($ss);