8 Ugh . Perl sux. Anybody for Python?
12 $mf_to_table_version = 0.2;
24 print STDERR "This is mf-to-table " . $mf_to_table_version . "\n";
29 print STDERR "Usage: mf-to-table [options] LOG..\n"
30 . "Generate mozarella metrics table from preparated metafont log\n\n"
32 . " -h, --help print this help\n"
33 . " -l, --ly=FILE name output table\n"
34 . " -t, --tex=FILE name output tex chardefs\n"
42 while ($line = <IN>) {
45 $line =~ s/^@@(.*)@@/$1/;
47 my @fields = split (/:/,$line);
48 my $label = $fields [0];
49 my $name = $fields [1];
50 print OUTLY "\t" x $indent;
51 if ($label eq "font") {
52 print OUTLY "% $name=\\symboltables {\n";
53 print OUTTEX "% $name\n";
55 } elsif ($label eq "group") {
56 print OUTLY "\"$name\" = \\table {\n";
57 print OUTTEX "% $name\n";
59 } elsif ($label eq "puorg") {
63 } elsif ($label eq "tnof") {
64 print OUTLY "% } % $name\n";
66 } elsif ($label eq "char") {
73 my $texstr = $fields [8];
74 print OUTLY sprintf( "\"%s\"\t\"\\%s\"\t%.2f\\pt\t%.2f\\pt\t%.2f\\pt\t%.2f\\pt\n", $id, $texstr, -$b, $w, $h, -$d );
75 # remove % from generic chars, and save start charcode
76 my $defstr = "\\fetdef";
77 if ($texstr =~ /{%/) {
82 print OUTTEX sprintf( "%s\\%s{%d}\n", $defstr, $texstr, $c);
84 print STDERR "mf-to-table: $lineno: unknown label: \`$label\'\n";
95 if (!(-f $infile) && !($infile =~ /\.log$/s )) {
99 if (defined($opt_ly)) {
104 $lyfile =~ s/\.log$/.ly/;
106 if (defined($opt_tex)) {
111 $texfile =~ s/\.log$/.tex/;
114 print STDERR "Input ", (($infile eq "-") ?"STDIN" : $infile), " .. \n";
121 die "can't open \`$infile\'" unless open IN,$infile ;
123 die "can't open \`$lyfile\'" unless open OUTLY, ">$lyfile";
124 print OUTLY "% generated at " . localtime() . " from $infile\n";
125 print OUTLY "% changes will be lost\n\n";
127 die "can't open \`$texfile\'" unless open OUTTEX, ">$texfile";
128 print OUTTEX "% generated at " . localtime() . " from $infile\n";
129 print OUTTEX "% changes will be lost\n\n";
142 #GetOptions ("help", "output=s", "from=i", "to=i", "minor=i", "edit", "show-rules");
143 GetOptions ("help", "ly=s", "tex=s");
147 $opt_help = 0; # to extinguish typo check.
151 local ($infile,$lyfile,$texfile);
154 while (defined($ARGV[0])) {
159 do_one_arg unless ($processed_one);