2 |
- |
1 |
###=====================================================================
|
|
|
2 |
### Read two Adobe Font Metric files, and compute tables of the
|
|
|
3 |
### differences in character repertoire, declared widths (WX), and
|
|
|
4 |
### bounding boxes.
|
|
|
5 |
###
|
|
|
6 |
### Usage:
|
|
|
7 |
### awk -f afmdiff.awk file1.afm file2.afm
|
|
|
8 |
###
|
|
|
9 |
### Author:
|
|
|
10 |
### Nelson H. F. Beebe
|
|
|
11 |
### Center for Scientific Computing
|
|
|
12 |
### University of Utah
|
|
|
13 |
### Department of Mathematics, 322 INSCC
|
|
|
14 |
### 155 S 1400 E RM 233
|
|
|
15 |
### Salt Lake City, UT 84112-0090
|
|
|
16 |
### USA
|
|
|
17 |
### Email: beebe@math.utah.edu, beebe@acm.org, beebe@computer.org,
|
|
|
18 |
### beebe@ieee.org (Internet)
|
|
|
19 |
### WWW URL: http://www.math.utah.edu/~beebe
|
|
|
20 |
### Telephone: +1 801 581 5254
|
|
|
21 |
### FAX: +1 801 585 1640, +1 801 581 4148
|
|
|
22 |
###
|
|
|
23 |
########################################################################
|
|
|
24 |
########################################################################
|
|
|
25 |
########################################################################
|
|
|
26 |
### ###
|
|
|
27 |
### awkdiff.awk: compare two Adobe Font Metric files ###
|
|
|
28 |
### ###
|
|
|
29 |
### Copyright (C) 2000 Nelson H. F. Beebe ###
|
|
|
30 |
### ###
|
|
|
31 |
### This program is covered by the GNU General Public License (GPL), ###
|
|
|
32 |
### version 2 or later, available as the file COPYING in the program ###
|
|
|
33 |
### source distribution, and on the Internet at ###
|
|
|
34 |
### ###
|
|
|
35 |
### ftp://ftp.gnu.org/gnu/GPL ###
|
|
|
36 |
### ###
|
|
|
37 |
### http://www.gnu.org/copyleft/gpl.html ###
|
|
|
38 |
### ###
|
|
|
39 |
### This program is free software; you can redistribute it and/or ###
|
|
|
40 |
### modify it under the terms of the GNU General Public License as ###
|
|
|
41 |
### published by the Free Software Foundation; either version 2 of ###
|
|
|
42 |
### the License, or (at your option) any later version. ###
|
|
|
43 |
### ###
|
|
|
44 |
### This program is distributed in the hope that it will be useful, ###
|
|
|
45 |
### but WITHOUT ANY WARRANTY; without even the implied warranty of ###
|
|
|
46 |
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ###
|
|
|
47 |
### GNU General Public License for more details. ###
|
|
|
48 |
### ###
|
|
|
49 |
### You should have received a copy of the GNU General Public ###
|
|
|
50 |
### License along with this program; if not, write to the Free ###
|
|
|
51 |
### Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, ###
|
|
|
52 |
### MA 02111-1307 USA ###
|
|
|
53 |
### ###
|
|
|
54 |
### This program may also be distributed as part of AFPL ###
|
|
|
55 |
### Ghostscript, under the terms of the Aladdin Free Public License ###
|
|
|
56 |
### (the "License"). ###
|
|
|
57 |
### ###
|
|
|
58 |
### Every copy of AFPL Ghostscript must include a copy of the ###
|
|
|
59 |
### License, normally in a plain ASCII text file named PUBLIC. The ###
|
|
|
60 |
### License grants you the right to copy, modify and redistribute ###
|
|
|
61 |
### AFPL Ghostscript, but only under certain conditions ###
|
|
|
62 |
### described in the License. Among other things, the License ###
|
|
|
63 |
### requires that the copyright notice and this notice be preserved ###
|
|
|
64 |
### on all copies. ###
|
|
|
65 |
### ###
|
|
|
66 |
########################################################################
|
|
|
67 |
########################################################################
|
|
|
68 |
########################################################################
|
|
|
69 |
#
|
|
|
70 |
# [29-Apr-2000]
|
|
|
71 |
#=======================================================================
|
|
|
72 |
|
|
|
73 |
/^FontName/ { FontName[++NFontName] = $2 }
|
|
|
74 |
|
|
|
75 |
|
|
|
76 |
/^C / {
|
|
|
77 |
if (NFontName == 1)
|
|
|
78 |
CharName1[$8]++
|
|
|
79 |
if (NFontName == 2)
|
|
|
80 |
CharName2[$8]++
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
|
|
|
84 |
/^C / {
|
|
|
85 |
name = $8
|
|
|
86 |
if (name in WX)
|
|
|
87 |
{
|
|
|
88 |
if (WX[name] != $5)
|
|
|
89 |
WXDIFF[name] = WX[name] - $5
|
|
|
90 |
}
|
|
|
91 |
else
|
|
|
92 |
WX[name] = $5
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
|
|
|
96 |
/^C / {
|
|
|
97 |
name = $8
|
|
|
98 |
bx = $13 - $11
|
|
|
99 |
if (name in BX)
|
|
|
100 |
{
|
|
|
101 |
if (BX[name] != bx)
|
|
|
102 |
BXDIFF[name] = BX[name] - bx
|
|
|
103 |
}
|
|
|
104 |
else
|
|
|
105 |
BX[name] = bx
|
|
|
106 |
}
|
|
|
107 |
|
|
|
108 |
|
|
|
109 |
/^C / {
|
|
|
110 |
name = $8
|
|
|
111 |
by = $14 - $12
|
|
|
112 |
if (name in BY)
|
|
|
113 |
{
|
|
|
114 |
if (BY[name] != by)
|
|
|
115 |
BYDIFF[name] = BY[name] - by
|
|
|
116 |
}
|
|
|
117 |
else
|
|
|
118 |
BY[name] = by
|
|
|
119 |
}
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
END {
|
|
|
123 |
Sortpipe = "sort -f | pr -c3 -w80 -l1 -t"
|
|
|
124 |
print "Comparison of AFM metrics in files:", ARGV[1], ARGV[2]
|
|
|
125 |
print "Font names:", FontName[1], FontName[2]
|
|
|
126 |
show_name_diffs(FontName[2],CharName2, FontName[1],CharName1)
|
|
|
127 |
show_name_diffs(FontName[1],CharName1, FontName[2],CharName2)
|
|
|
128 |
show_num_diffs("WX width differences", WXDIFF)
|
|
|
129 |
show_num_diffs("Bounding box width differences", BXDIFF)
|
|
|
130 |
show_num_diffs("Bounding box height differences",BYDIFF)
|
|
|
131 |
}
|
|
|
132 |
|
|
|
133 |
function show_name_diffs(font1,array1,font2,array2, name)
|
|
|
134 |
{
|
|
|
135 |
print "\nChars from", font2, "missing from", font1 ":"
|
|
|
136 |
for (name in array2)
|
|
|
137 |
{
|
|
|
138 |
if (!(name in array1))
|
|
|
139 |
printf("%s\n", name) | Sortpipe
|
|
|
140 |
}
|
|
|
141 |
close(Sortpipe)
|
|
|
142 |
}
|
|
|
143 |
|
|
|
144 |
function show_num_diffs(title,array, name)
|
|
|
145 |
{
|
|
|
146 |
printf("\n%s:\n", title)
|
|
|
147 |
for (name in array)
|
|
|
148 |
printf("%-15s\t%4d\n", name, array[name]) | Sortpipe
|
|
|
149 |
close(Sortpipe)
|
|
|
150 |
}
|