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