Debian Codegraph @

tools/utility/KerningNumerals.pl

raw
1 #!/usr/bin/perl
2 =pod
3
4 =head1 KerningNumerals.pl
5
6 Move kerning information from ASCII numerals (U+0030...) to characters in
7 the Adobe corporate use area (U+F6xx).
8
9 By: Primož Peterlin, 2003
10
11 $Id: KerningNumerals.pl,v 1.2 2003-05-15 12:04:41 peterlin Exp $
12
13 =cut
14
15 sub numerically { $a <=> $b; }
16
17 if ($#ARGV != 0) {
18 print $#ARGV;
19 die "Usage: $0 file.sfd\n";
20 }
21
22 open(INFILE, $ARGV[0]) || die "Failed to open file: $ARGV[0]\n";
23
24 while (<INFILE>) {
25 if (/^Kerns:/) {
26 # Old-style kerning information
27 chomp;
28 # Cut off the first seven characters ("Kerns: ")
29 substr($_,0,7) = "";
30 @values = split;
31 # Construct the hash $kern{$code}
32 for ($i = 0; $i <= $#values; $i += 2) {
33 $code = $values[$i];
34 # Recode ASCII numerals to Adobe corporate use values
35 if ($code == 48) {
36 $code = 63033;
37 } elsif ($code == 49) {
38 $code = 63196;
39 } elsif ($code == 50) {
40 $code = 63034;
41 } elsif ($code == 51) {
42 $code = 63035;
43 } elsif ($code == 52) {
44 $code = 63036;
45 } elsif ($code == 53) {
46 $code = 63037;
47 } elsif ($code == 54) {
48 $code = 63038;
49 } elsif ($code == 55) {
50 $code = 63039;
51 } elsif ($code == 56) {
52 $code = 63040;
53 } elsif ($code == 57) {
54 $code = 63041;
55 }
56 $kern{$code} = $values[$i+1];
57 }
58 print "Kerns:";
59 foreach $code (sort numerically keys(%kern)) {
60 print " ",$code," ",$kern{$code};
61 }
62 print "\n";
63 # Clean-up
64 foreach $code (keys(%kern)) {
65 delete $kern{$code};
66 }
67 } elsif (/^KernsSLIF:/) {
68 # New-style kerning information
69 chomp;
70 # Cut off the first eleven characters ("KernsSLIF: ")
71 substr($_,0,11) = "";
72 @values = split;
73 # Construct the hash $kern{$code}
74 for ($i = 0; $i <= $#values; $i += 4) {
75 $code = $values[$i];
76 # Recode ASCII numerals to Adobe corporate use values
77 if ($code == 48) {
78 $code = 63033;
79 } elsif ($code == 49) {
80 $code = 63196;
81 } elsif ($code == 50) {
82 $code = 63034;
83 } elsif ($code == 51) {
84 $code = 63035;
85 } elsif ($code == 52) {
86 $code = 63036;
87 } elsif ($code == 53) {
88 $code = 63037;
89 } elsif ($code == 54) {
90 $code = 63038;
91 } elsif ($code == 55) {
92 $code = 63039;
93 } elsif ($code == 56) {
94 $code = 63040;
95 } elsif ($code == 57) {
96 $code = 63041;
97 }
98 $kern{$code} = $values[$i+1];
99 $unx{$code} = $values[$i+2];
100 $uny{$code} = $values[$i+3];
101 }
102 print "KernsSLIF:";
103 foreach $code (sort numerically keys(%kern)) {
104 print " ",$code," ",$kern{$code}," ",$unx{$code}," ",$uny{$code};
105 }
106 print "\n";
107 # Clean-up
108 foreach $code (keys(%kern)) {
109 delete $kern{$code};
110 }
111 } else {
112 # All other lines
113 print;
114 }
115 }
116
117 close(INFILE);