]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-autometric.mf
* lily/open-type-font.cc (attachment_point): new function.
[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&"@:"&texstr&"@}";
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 %     texstr    name of tex macro in lily's table and tex backend
108
109 % the dims are uninitialised; you should use set_char_box manually.
110 def fet_beginchar(expr name, id_lit, texstr_lit) =
111         save texstr, idstr, charnamestr;
112         save charbp;
113         save w,b,h,d;
114         save charwx, charwy;
115
116         string texstr, idstr, charnamestr;
117         texstr := texstr_lit;
118         charnamestr := name;
119         idstr := id_lit;
120
121         no_dimen_beginchar(incr code) name;
122         enddef;
123
124
125 def makebox_with_breapth(text r) = 
126         for y = -d, 0, h: r((-b, y),(w,y)); endfor
127         for x = -b, 0, w: r((x, -d),(x, h)); endfor
128 enddef;
129
130 %
131 % override plain endchar.  We want a different box. 
132 %
133 def breapth_endchar =
134         scantokens extra_endchar;
135         if proofing > 0: makebox_with_breapth(proofrule); fi
136         chardx := (w + b);      %what the hack is chardx
137         shipit;
138         endgroup
139 enddef;
140
141 def fet_endchar=
142         autometric_output_char;
143         breapth_endchar;
144         enddef;