]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-autometric.mf
release: 1.5.29
[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--2002 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) =
21         font_identifier:=name&decimal size;
22         font_size size;
23         message "@{font@:"&name&"@:"&decimal size&"@}";
24         message "";
25         enddef;
26
27 def fet_endfont(expr name) =
28         message "@{tnof@:"&name&"@}";
29         message "";
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_output_char=
46         message "@{char@:"&charnamestr&"@:"&decimal charcode&"@:"&decimal charbp&"@:"&decimal charwd&"@:"&decimal chardp&"@:"&decimal charht&"@:"&idstr&"@:"&texstr&"@}";
47 enddef;
48
49 def hround_pixels(expr sharped) = hround(sharped * hppp) enddef;
50 def vround_pixels(expr sharped) = vround(sharped * vppp) enddef;
51
52 def tand(expr alpha) = 
53         (sind alpha/cosd alpha)
54         enddef;
55
56 %breapth, width, depth, height
57 %     breapth   x-depth
58 def set_char_box(expr b_sharp, w_sharp, d_sharp,h_sharp) = 
59         save scharbp, scharht, scharwd, schardp;
60
61         % some paranoia if someone calls set_char_box(charwd, charbp, .. )
62         scharbp := b_sharp;
63         scharht := h_sharp;
64         schardp := d_sharp;
65         scharwd := w_sharp;
66
67         charbp := scharbp;
68         charht := scharht;
69         chardp := schardp;
70         charwd := scharwd;
71
72         w := hround(w_sharp *hppp);
73         b := hround(b_sharp *hppp);
74         h := hround(h_sharp *vppp);
75         d := hround(d_sharp *vppp);
76 enddef;
77
78 def no_dimen_beginchar(expr c) =
79         begingroup
80         charcode := if known c: byte c else: 0; fi;
81         charic := 0;
82         clearxy;
83         clearit;
84         clearpen;
85         scantokens extra_beginchar;
86 enddef;
87
88 code:=-1;
89
90 % starts just as plain mf's beginchar:
91 %     charcode, 
92 % and then adds:
93 %     charname  see below
94 %     id        index in lily's table
95 %     texstr    name of tex macro in lily's table and tex backend
96
97 % the dims are uninitialised; you should use set_char_box manually.
98 def fet_beginchar(expr name, id_lit, texstr_lit) =
99         save texstr, idstr, charnamestr;
100         save charbp;
101         save w,b,h,d;
102         string texstr, idstr, charnamestr;
103         texstr := texstr_lit;
104         charnamestr := name;
105         idstr := id_lit;
106
107         no_dimen_beginchar(incr code) name;
108         enddef;
109
110
111 def makebox_with_breapth(text r) = 
112         for y = -d, 0, h: r((-b, y),(w,y)); endfor
113         for x = -b, 0, w: r((x, -d),(x, h)); endfor
114 enddef;
115
116 %
117 % override plain endchar.  We want a different box. 
118 %
119 def breapth_endchar =
120         scantokens extra_endchar;
121         if proofing > 0: makebox_with_breapth(proofrule); fi
122         chardx := (w + b);      %what the hack is chardx
123         shipit;
124         endgroup
125 enddef;
126
127 def fet_endchar=
128         autometric_output_char;
129         breapth_endchar;
130         enddef;