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

/^FontName/	{ FontName[++NFontName] = $2 }


/^C /		{
		    if (NFontName == 1)
			CharName1[$8]++
		    if (NFontName == 2)
			CharName2[$8]++
		}


/^C /		{
		    name = $8
		    if (name in WX)
		    {
			if (WX[name] != $5)
			    WXDIFF[name] = WX[name] - $5
		    }
		    else
			WX[name] = $5
		}


/^C /		{
		    name = $8
		    bx = $13 - $11
		    if (name in BX)
		    {
			if (BX[name] != bx)
			    BXDIFF[name] = BX[name] - bx
		    }
		    else
			BX[name] = bx
		}


/^C /		{
		    name = $8
		    by = $14 - $12
		    if (name in BY)
		    {
			if (BY[name] != by)
			    BYDIFF[name] = BY[name] - by
		    }
		    else
			BY[name] = by
		}


END		{
		    Sortpipe = "sort -f | pr -3 -w80 -l1 -t"
		    print "Comparison of AFM metrics in files:", ARGV[1], ARGV[2]
		    print "Font names:", FontName[1], FontName[2]
		    show_name_diffs(FontName[2],CharName2, FontName[1],CharName1)
		    show_name_diffs(FontName[1],CharName1, FontName[2],CharName2)
		    show_num_diffs("WX width differences", WXDIFF)
		    show_num_diffs("Bounding box width differences", BXDIFF)
		    show_num_diffs("Bounding box height differences",BYDIFF)
		}

function show_name_diffs(font1,array1,font2,array2, name)
{
    print "\nChars from", font2, "missing from", font1 ":"
    for (name in array2)
    {
	if (!(name in array1))
	    printf("%s\n", name) | Sortpipe
    }
    close(Sortpipe)
}

function show_num_diffs(title,array, name)
{
    printf("\n%s:\n", title)
    for (name in array)
	printf("%-15s\t%4d\n", name, array[name]) | Sortpipe
    close(Sortpipe)
}