]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-autometric.mf
* scm/output-lib.scm (note-head-style->attachment-coordinates):
[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--2003 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@:GNU@:LilyPond@:"&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&"@:"&decimal charwx&"@:"&decimal charwy&"@:"&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
77         charwx := charwd;
78         charwy := 0;
79 enddef;
80
81 def no_dimen_beginchar(expr c) =
82         begingroup
83         charcode := if known c: byte c else: 0; fi;
84         charic := 0;
85         clearxy;
86         clearit;
87         clearpen;
88         scantokens extra_beginchar;
89 enddef;
90
91
92 %
93 % we leave the ctrl characters alone.
94 %
95 code:=32;
96
97 % starts just as plain mf's beginchar:
98 %     charcode, 
99 % and then adds:
100 %     charname  see below
101 %     id        index in lily's table
102 %     texstr    name of tex macro in lily's table and tex backend
103
104 % the dims are uninitialised; you should use set_char_box manually.
105 def fet_beginchar(expr name, id_lit, texstr_lit) =
106         save texstr, idstr, charnamestr;
107         save charbp;
108         save w,b,h,d;
109         save charwx, charwy;
110
111         string texstr, idstr, charnamestr;
112         texstr := texstr_lit;
113         charnamestr := name;
114         idstr := id_lit;
115
116         no_dimen_beginchar(incr code) name;
117         enddef;
118
119
120 def makebox_with_breapth(text r) = 
121         for y = -d, 0, h: r((-b, y),(w,y)); endfor
122         for x = -b, 0, w: r((x, -d),(x, h)); endfor
123 enddef;
124
125 %
126 % override plain endchar.  We want a different box. 
127 %
128 def breapth_endchar =
129         scantokens extra_endchar;
130         if proofing > 0: makebox_with_breapth(proofrule); fi
131         chardx := (w + b);      %what the hack is chardx
132         shipit;
133         endgroup
134 enddef;
135
136 def fet_endchar=
137         autometric_output_char;
138         breapth_endchar;
139         enddef;