]> 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&"@:"&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
89 %
90 % we leave the ctrl characters alone.
91 %
92 code:=32;
93
94 % starts just as plain mf's beginchar:
95 %     charcode, 
96 % and then adds:
97 %     charname  see below
98 %     id        index in lily's table
99 %     texstr    name of tex macro in lily's table and tex backend
100
101 % the dims are uninitialised; you should use set_char_box manually.
102 def fet_beginchar(expr name, id_lit, texstr_lit) =
103         save texstr, idstr, charnamestr;
104         save charbp;
105         save w,b,h,d;
106         string texstr, idstr, charnamestr;
107         texstr := texstr_lit;
108         charnamestr := name;
109         idstr := id_lit;
110
111         no_dimen_beginchar(incr code) name;
112         enddef;
113
114
115 def makebox_with_breapth(text r) = 
116         for y = -d, 0, h: r((-b, y),(w,y)); endfor
117         for x = -b, 0, w: r((x, -d),(x, h)); endfor
118 enddef;
119
120 %
121 % override plain endchar.  We want a different box. 
122 %
123 def breapth_endchar =
124         scantokens extra_endchar;
125         if proofing > 0: makebox_with_breapth(proofrule); fi
126         chardx := (w + b);      %what the hack is chardx
127         shipit;
128         endgroup
129 enddef;
130
131 def fet_endchar=
132         autometric_output_char;
133         breapth_endchar;
134         enddef;