blob: 1b294ade43164af10de7f004439367aac34d4420 (
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
|
#############################################################
##
## This is the file newmtx.prl, part of the MathInst package
## (version 1.0, August, 1998) for math font
## generation. (Author: Alan Hoenig, ajhjj@cunyvm.cuny.edu)
##
#############################################################
# perl script to read to mtx files and relate bad and good names.
# perl mtex.prl MTEX
die "Wrong number of params, boss..." if $#ARGV != 0;
$File = $ARGV[0];
$file = $File;
$file =~ tr/A-Z/a-z/;
$goodfile = "${File}good.mtx";
$baddfile = "${File}bad.mtx";
open (GOOD, $goodfile) || die "Can't open good file $goodfile...";
open (BAD, $baddfile) || die "Can't open bad file $baddfile...";
$newfile = "new${file}.mtx";
open (OUT, ">$newfile");
sub min{
local($i);
local($Min_) = $_[0];
foreach $i (1 .. $#_) {
$Min_ = $_[$i] if $_[$i] < $Min_;
}
$Min_;
}
## &readmtxfile(*good);
sub readmtxfile{
local(*foo) = @_;
while ($_ = <$fh>) {
last if /setrawglyph/;
}
while ($_ = <$fh>) {
last unless /setrawglyph/;
$_ =~ /^\\setrawglyph{([A-Za-z]+)}{$ARGV[0][a-z]*}{10[\.0]*pt}{([-0-9]+)}/;
$foo[$2] = $1;
}
}
$fh = "GOOD";
&readmtxfile(*good);
$fh = "BAD";
&readmtxfile(*bad);
$diffs = 0;
$m = &min($#good, $#bad);
foreach $i (0 .. $m) {
next if $bad[$i] eq $good[$i];
$A = "\\renameas{$bad[$i]}{$good[$i]}";
$A .= ' ' x (50-length($A))."% glyph $i\n";
$diff[$j] = $A; $j++; $diffs = 1;
}
if ($diffs == 1) {
print OUT "\\relax\n\n\\metrics\n\n";
print OUT "\\setcommand\\renameas\#1\#2{\n";
print OUT " \\ifisglyph{\#1}\\then\n";
print OUT " \\setglyph{\#2}\n";
print OUT " \\glyph{\#1}{1000}\n";
print OUT " \\endsetglyph\n";
print OUT " \\fi\n";
print OUT "}\n\n";
foreach $i (0 .. $#diff) {
print OUT $diff[$i];
}
print OUT "\n\\endmetrics\n";
}
close OUT;
|