############################################################# ## ## 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;