]> git.donarmstrong.com Git - lilypond.git/blob - mf/autometric.mf
cd924a3aab9412d644e4869020c1c067df0f84d9
[lilypond.git] / mf / autometric.mf
1
2 % autometric.mf -- administrative MF routines
3
4 % source file of the Feta (Font-En-Tja) pretty-but-neat music font
5
6 % (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7
8 % these macros help create ascii logging output
9 % to automate generation of lily tables and tex backend
10 % The output should be parsed by the mf-to-table script
11
12
13
14 % font or database?
15 def fet_beginfont(expr name,size) =
16         font_identifier:=name&decimal size;
17         font_size size;
18         message "@{font:"&name&":"&decimal size&"@}";
19         message "";
20         enddef;
21
22 def fet_endfont(expr name) =
23         message "@{tnof:"&name&"@}";
24         message "";
25         enddef;
26
27 % group or table?
28 def fet_begingroup(expr name) =
29         message "@{group:"&name&"@}";
30         message "";
31         begingroup
32 enddef;
33
34 def fet_endgroup(expr name) =
35         endgroup;
36         message "@{puorg:"&name&"@}";
37         message "";
38 enddef;
39
40 def autometric_output_char=
41         message "@{char:"&charnamestr&":"&decimal charcode&":"&decimal charbp&":"&decimal charwd&":"&decimal chardp&":"&decimal charht&":"&idstr&":"&texstr&"@}";
42 enddef;
43
44
45 %breapth, width, depth, height
46 %     breapth   x-depth
47 def set_char_box(expr b_sharp, w_sharp, d_sharp,h_sharp) = 
48         save scharbp, scharht, scharwd, schardp;
49
50         % some paranoia if someone calls set_char_box(charwd, charbp, .. )
51         scharbp := b_sharp;
52         scharht := h_sharp;
53         schardp := d_sharp;
54         scharwd := w_sharp;
55
56         charbp := scharbp;
57         charht := scharht;
58         chardp := schardp;
59         charwd := scharwd;
60
61         w := hround(w_sharp *hppp);
62         b := hround(b_sharp *hppp);
63         h := hround(h_sharp *vppp);
64         d := hround(d_sharp *vppp);
65 enddef;
66
67 def no_dimen_beginchar(expr c) =
68         begingroup
69         charcode := if known c: byte c else: 0; fi;
70         charic := 0;
71         clearxy;
72         clearit;
73         clearpen;
74         scantokens extra_beginchar;
75 enddef;
76
77 code:=-1;
78
79 % starts just as plain mf's beginchar:
80 %     charcode, 
81 % and then adds:
82 %     charname  see below
83 %     id        index in lily's table
84 %     texstr    name of tex macro in lily's table and tex backend
85
86 % the dims are uninitialised; you should use set_char_box manually.
87 def fet_beginchar(expr name, id_lit, texstr_lit) =
88         save texstr, idstr, charnamestr;
89         save charbp;
90         save w,b,h,d;
91         string texstr, idstr, charnamestr;
92         texstr := texstr_lit;
93         charnamestr := name;
94         idstr := id_lit;
95
96         no_dimen_beginchar(incr code) name;
97         enddef;
98
99
100 def makebox_with_breapth(text r) = 
101         for y = -d, 0, h: r((-b, y),(w,y)); endfor
102         for x = -b, 0, w: r((x, -d),(x, h)); endfor
103 enddef;
104
105 %
106 % override plain endchar.  We want a different box. 
107 %
108 def breapth_endchar =
109         scantokens extra_endchar;
110         if proofing > 0: makebox_with_breapth(proofrule); fi
111         chardx := w + b;
112         shipit;
113         endgroup
114 enddef;
115
116 def fet_endchar=
117         autometric_output_char;
118         breapth_endchar;
119         enddef;