From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Thu, 18 Sep 1997 14:48:13 +0000 (+0200)
Subject: patch::: 0.1.15.jcn2: leesvoer
X-Git-Tag: release/0.1.16~1
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=bc35d071a32034237584eb5bc06c8432271a88ac;p=lilypond.git

patch::: 0.1.15.jcn2: leesvoer

pl 15.jcn2
	- mf-to-table.in: generate mozarella metric info tables
	- autometric.mf: write metric info to mf logfile
---

diff --git a/NEWS b/NEWS
index 811d918554..7f22d8a840 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+pl 15.jcn2
+	- mf-to-table.in: generate mozarella metric info tables
+	- autometric.mf: write metric info to mf logfile
+
 pl 15.jcn1
 	- bf: typos whole and half notehead
 	- de-uglyfied bolletjes.mf
diff --git a/VERSION b/VERSION
index 9c1970c8a2..b85f15066a 100644
--- a/VERSION
+++ b/VERSION
@@ -3,4 +3,4 @@ TOPLEVEL_MINOR_VERSION = 1
 TOPLEVEL_PATCH_LEVEL = 15
 
 # use to send patches, always empty for released version:
-TOPLEVEL_MY_PATCH_LEVEL = .jcn1
+TOPLEVEL_MY_PATCH_LEVEL = .jcn2
diff --git a/bin/mf-to-table.in b/bin/mf-to-table.in
new file mode 100644
index 0000000000..17a7c2f7a8
--- /dev/null
+++ b/bin/mf-to-table.in
@@ -0,0 +1,127 @@
+#!@PERL@ -w
+# -*-perl-*-
+
+=head1 TODO
+
+rename me!
+
+Ugh . Perl sux. Anybody for Python?
+    
+=cut    
+
+$mf_to_table_version = 0.1;
+
+use Getopt::Long;
+
+sub last_conversion
+{
+    my @v = &versions;
+    return pop @v;
+}
+sub identify
+{
+    
+    print STDERR "This is mf-to-table " . $mf_to_table_version . "\n";
+}
+  
+sub usage
+{
+    print STDERR "Usage: mf-to-table [options] LOG..\n"
+    . "Generate mozarella metrics table from preparated metafont log\n\n"
+    . "Options:\n"
+    . "  -h, --help             print this help\n"
+    . "  -o, --output=FILE      name output file\n"
+}
+
+sub make_table
+{
+    my $line;
+    my $indent = 0;
+    while ($line = <IN>) {
+	if ($line =~ /^@@/) {
+	    $line =~ s/^@@(.*)@@/$1/;
+	    chop ($line);
+	    my @fields = split (/:/,$line);
+	    my $label = $fields [0];
+	    my $name = $fields [1];
+	    print OUT "\t" x $indent;
+	    if ($label eq "font") {
+		print OUT "% $name=\\symboltables {\n";
+		$indent++;
+	    } elsif ($label eq "group") {
+		print OUT "\"$name\" = \\table {\n";
+		$indent++;
+	    } elsif ($label eq "puorg") {
+		print OUT "}\n";
+		$indent--;
+	    } elsif ($label eq "tnof") {
+		print OUT "%  } % $name\n";
+		$indent--;
+	    } elsif ($label eq "char") {
+		my $c = $fields [2];
+		my $w = $fields [3];
+		my $h = $fields [4];
+		my $d = $fields [5];
+		my $id = $fields [6];
+		my $texstr = $fields [7];
+		print OUT sprintf( "\"%s\"\t\"\\%s\"\t%.2f\\pt\t%.2f\\pt\t%.2f\\pt\t%.2f\\pt\n", $id, $texstr, 0, $w, $h, $d );
+	    } else {
+	    	print STDERR "mf-to-table: unknown label: \`$label\'\n";
+	    }
+	}
+    }
+}
+      
+sub  set_files 
+{
+    $infile = "-";
+    $outfile = "-";
+    $outfile = $opt_output if (defined($opt_output));
+
+    if ($ARGV [0])  {
+	$infile = $ARGV[0];
+    } 
+    if (( ! -f $infile) && (! $infile =~ /\\.log$/s ) ){
+	$infile .= ".log";
+    }
+    print STDERR "Input ", (($infile eq "-") ?"STDIN" : $infile), " .. \n";
+}
+
+sub do_one_arg
+{
+    set_files;
+
+    die "can't open \`$infile\'" unless open IN,$infile ;
+    die "can't open \`$outfile\'" unless open OUT, ">$outfile";
+    print OUT "% generated at " . localtime() . " from $infile\n";
+    print OUT "% changes will be lost\n";
+    
+    make_table;
+
+    close IN;
+    close OUT;
+}
+
+## "main"
+
+identify;
+
+#GetOptions ("help", "output=s", "from=i", "to=i", "minor=i", "edit", "show-rules");
+GetOptions ("help", "output=s");
+
+if ($opt_help) {
+    usage();
+    $opt_help = 0;	# to extinguish typo check.
+    exit 0;
+}
+
+local ($infile,$outfile);
+my $processed_one=0;
+
+while (defined($ARGV[0])) {
+    do_one_arg;
+    shift @ARGV;
+    $processed_one = 1;
+}
+do_one_arg unless ($processed_one);
+
diff --git a/init/table16.ly b/init/table16.ly
index 5097530ac8..3869d070ad 100644
--- a/init/table16.ly
+++ b/init/table16.ly
@@ -75,18 +75,14 @@ table_sixteen=
 	"tenor_change"	"\caltoclef" 	0.0\pt	11.2\pt	0.0\pt	16.0\pt
      }
 
-     "balls" = \table {
-	"-2"	"\longaball"	0.0\pt	6.0\pt	-2.0\pt	2.0\pt
-	"-1"	"\breveball"	0.0\pt	6.0\pt	-2.0\pt	2.0\pt
-	"0"	"\wholeball"	0.0\pt	8.0\pt	0.0\pt	4.4\pt
-	"1"	"\halfball"	0.0\pt	5.4\pt	0.0\pt	4.4\pt
-	"2"	"\quartball"	0.0\pt	5.5\pt	0.0\pt	4.4\pt
-     }
+     % ugh what's our outdir called?
+     \include "mf/out/font-en-tja16.ly"
 
      "slur" = \table {
 	"whole"	"\slurchar%{%}"
 	"half"	"\hslurchar%{%}"
      }
+
      "accidentals" = \table {
 	"-2"	"\flatflat"	0.0\pt 	8.16\pt	-2.5\pt 7.5\pt
 	"-1"	"\flat"		0.0\pt	4.8\pt	-2.5\pt 7.5\pt
diff --git a/init/table20.ly b/init/table20.ly
index bc20a550ff..0abf1ac4b9 100644
--- a/init/table20.ly
+++ b/init/table20.ly
@@ -78,12 +78,8 @@ table_twenty =
 	"tenor_change"	"\caltoclef" 	0.0\pt	16.0\pt	0.0\pt	20.0\pt
     }
 
-    "balls" = \table {
-	"-1"	"\breveball" 	0.0\pt	7.5\pt	-2.5\pt	2.5\pt
-	"0"	"\wholeball"	0.0\pt	10.2\pt	0.0\pt	5.4\pt
-	"1"	"\halfball"	0.0\pt	6.8\pt	0.0\pt	5.4\pt
-	"2"	"\quartball"	0.0\pt	6.6\pt	0.0\pt	5.4\pt
-    }
+    % ugh what's our outdir called?
+    \include "mf/out/font-en-tja20.ly"
 
     "slur" = \table {
 	"whole"	"\slurchar%{%}"	0.0\pt	0.0\pt	0.0\pt	0.0\pt
diff --git a/mf/Makefile b/mf/Makefile
index f3523f04c1..6bca9f001f 100644
--- a/mf/Makefile
+++ b/mf/Makefile
@@ -15,6 +15,23 @@ MFFILES = $(wildcard *.mf)
 EXTRA_DISTFILES = $(MFFILES) $(TEXFILES) TODO
 #
 
+FONT_FILES = $(wildcard *[0-9].mf)
+TABLES = $(addprefix $(outdir)/, $(FONT_FILES:.mf=.ly))
+#
+
+all: $(TABLES)
+
+localclean:
+	rm -f $(TABLES)
+
+$(outdir)/%.log: %.mf
+	mf $<
+	mv $(@F) $@
+	rm $(shell basename $< .mf).*gf
+
+$(outdir)/%.ly: $(outdir)/%.log
+	mf-to-table -o $@ $<
+	
 localinstall:
 	$(INSTALL) -d $(MFDIR)/lilypond
 	$(INSTALL) -m 644 $(MFFILES) $(MFDIR)/lilypond/
diff --git a/mf/autometric.mf b/mf/autometric.mf
index ae9a8edc85..4bdf68cf94 100644
--- a/mf/autometric.mf
+++ b/mf/autometric.mf
@@ -1,13 +1,30 @@
-% metric.mf
+% autometric.mf
 % part of LilyPond's pretty-but-neat music font
 
+% font or database?
 def fet_beginfont(expr name,size) =
 	message "@@font:"&name&":"&decimal size&"@@";
 	message "";
 	enddef;
+
+def fet_endfont(expr name) =
+	message "@@tnof:"&name&"@@";
+	message "";
+	enddef;
+
+% group or table?
+def fet_begingroup(expr name) =
+	message "@@group:"&name&"@@";
+	message "";
+	enddef;
+
+def fet_endgroup(expr name) =
+	message "@@puorg:"&name&"@@";
+	message "";
+	enddef;
 	
-def fet_beginchar(expr code,w,h,d,name) =
-	message "@@char:"&name&":"&decimal code&":"&decimal w&":"&decimal h&":"&decimal d&"@@";
+def fet_beginchar(expr code,w,h,d,name,id,texstr) =
+	message "@@char:"&name&":"&decimal code&":"&decimal w&":"&decimal h&":"&decimal d&":"&id&":"&texstr&"@@";
 	beginchar(code,w,h,d) name;
 	enddef;
 
diff --git a/mf/bolletjes.mf b/mf/bolletjes.mf
index 849c9f9b6f..c5b32625e2 100644
--- a/mf/bolletjes.mf
+++ b/mf/bolletjes.mf
@@ -31,7 +31,7 @@ def begin_notehead =
 	save b_h,a_w;
 	enddef;
 
-def end_notehead(expr code,interline,name) =
+def end_notehead(expr code,interline,name,id,texstr) =
 	save a,b,h,w,ai,bi;
 	h#=interline;
 	2b#=h#*b_h;
@@ -42,7 +42,7 @@ def end_notehead(expr code,interline,name) =
 	define_pixels(a,b);
 	define_pixels(w,h);
 	define_pixels(ai,bi);
- 	fet_beginchar(code,w#,h#,0,name);
+ 	fet_beginchar(code,w#,h#,0,name,id,texstr);
 		path black,white;
 		black=distorted_ellipse(a,b,a*err_y_a,0,super);
 		white=distorted_ellipse(ai,bi,ai*err_y_ai,bi*err_x_bi,superi);
@@ -65,6 +65,8 @@ fi
 		endgroup;
 	enddef;
 		
+% fet_begingroup("noteheads");
+fet_begingroup("balls");
 % whole note
 % Wanske, p.38
 % begin_notehead(incr code,interline#,"Whole notehead");
@@ -83,7 +85,7 @@ begin_notehead;
 	superi:=0.69;
 	b_h:=1; %no rotate-> no height correction
 	a_w:=1; % no rotate-> no width correction
-	end_notehead(incr code,interline#,"Whole notehead");
+	end_notehead(incr code,interline#,"Whole notehead","0","wholeball");
 
 % half note
 % Wanske, p.39
@@ -101,7 +103,7 @@ begin_notehead;
 	superi:=0.80;
 	b_h:=0.935;
 	a_w:=1.12;
-	end_notehead(incr code,interline#,"Half notehead");
+	end_notehead(incr code,interline#,"Half notehead","1","halfball");
 
 % quarter note
 % Wanske p.38
@@ -119,7 +121,13 @@ begin_notehead;
 	superi:=0.707;
 	b_h:=0.85;
 	a_w:=1.09;
-	end_notehead(incr code,interline#,"Quarter notehead");
+	end_notehead(incr code,interline#,"Quarter notehead","2","quartball");
 
-end.
+% silly tableXX.ly fillers, for now
+fet_beginchar(incr code,2interline#,interline#,0,"Longa notehead","-2","longaball");
+endchar;
+fet_beginchar(incr code,2interline#,interline#,0,"Brevis notehead","-1","breveball");
+endchar;
+
+fet_endgroup("noteheads");
 
diff --git a/mf/dyn10.mf b/mf/dyn10.mf
index 64ea7c7af2..8ff51a1813 100644
--- a/mf/dyn10.mf
+++ b/mf/dyn10.mf
@@ -112,6 +112,9 @@ flare#:=52/36pt#;    % diameter of bulbs or breadth of terminals
 mode_setup;
 font_setup;
 
+input autometric;
+fet_beginfont("dyn", 10);
+
 num=-1;
 input ital-f;
 
@@ -149,4 +152,6 @@ input ital-s;
 input ital-z;
 
 font_slant slant; font_x_height x_height#;
-bye.
+
+fet_endfont("dyn");
+end.
diff --git a/mf/font-en-tja16.mf b/mf/font-en-tja16.mf
index 1e15311273..5fc5cd8bfd 100644
--- a/mf/font-en-tja16.mf
+++ b/mf/font-en-tja16.mf
@@ -3,9 +3,6 @@
 
 mode_setup;
 
-font_name:="font-en-tja";
-font_size:=16;
-
 test:=0;
 
 staffsize#:=16pt#;
@@ -14,9 +11,11 @@ stafflinethickness#:=0.4pt#;
 code:=-1;
 
 input autometric;
-fet_beginfont;
+fet_beginfont("font-en-tja", 16);
 
 input bolletjes;
 
+fet_endfont("font-en-tja");
+
 end.
 
diff --git a/mf/font-en-tja20.mf b/mf/font-en-tja20.mf
index 744133d7fe..c5f7b39e5d 100644
--- a/mf/font-en-tja20.mf
+++ b/mf/font-en-tja20.mf
@@ -12,9 +12,11 @@ stafflinethickness#:=0.4pt#;
 code:=-1;
 
 input autometric;
-fet_beginfont("font-en-tja", 16);
+fet_beginfont("font-en-tja", 20);
 
 input bolletjes;
 
+fet_endfont("font-en-tja");
+
 end.