]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-autometric.mf
* mf/feta-accordion.mf, mf/feta-klef.mf, mf/feta-pendaal.mf,
[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
15 message "******************************************************";
16 message "Using feta Autometric macros.";
17 message "Do not worry about the @ signs in the output, they are not errors.";
18 message "******************************************************";
19 message "";
20
21
22 % font or database?
23 def fet_beginfont (expr name, size, encod) =
24         font_identifier := name & decimal size;
25         font_size size;
26         font_coding_scheme encod;
27         message "@{font@:GNU@:LilyPond@:" & name
28                 & "@:" & decimal size
29                 & "@:" & encod
30                 & "@}";
31         message "";
32 enddef;
33
34
35 def fet_endfont =
36         message "@{tnof@}";
37 enddef;
38
39
40 % group or table?
41 def fet_begingroup (expr name) =
42         message "@{group@:" & name
43                 & "@}";
44         message "";
45 begingroup
46 enddef;
47
48
49 def fet_endgroup (expr name) =
50 endgroup;
51         message "@{puorg@:" & name
52                 & "@}";
53         message "";
54 enddef;
55
56
57 def autometric_parameter (expr name, value) =
58         message "@{parameter@:" & name
59                 & "@:" & decimal value
60                 & "@}";
61 enddef;
62
63
64 def autometric_output_char=
65         message "@{char@:" & charnamestr
66                 & "@:" & decimal charcode
67                 & "@:" & decimal charbp
68                 & "@:" & decimal charwd
69                 & "@:" & decimal chardp
70                 & "@:" & decimal charht
71                 & "@:" & decimal charwx
72                 & "@:" & decimal charwy
73                 & "@:" & idstr
74                 & "@}";
75 enddef;
76
77
78 def hround_pixels (expr sharped) =
79         hround (sharped * hppp)
80 enddef;
81
82
83 def vround_pixels (expr sharped) =
84         vround (sharped * vppp)
85 enddef;
86
87
88 def tand (expr alpha) =
89         (sind alpha / cosd alpha)
90 enddef;
91
92
93 def to_bp (expr num) =
94         decimal (num * bp_per_pixel)
95 enddef;
96
97
98 % breapth, width, depth, height
99 %     breapth   x-depth
100 def set_char_box (expr b_sharp, w_sharp, d_sharp, h_sharp) =
101         save scharbp, scharht, scharwd, schardp;
102
103         % some paranoia if someone calls set_char_box (charwd, charbp, ...)
104         scharbp := b_sharp;
105         scharht := h_sharp;
106         schardp := d_sharp;
107         scharwd := w_sharp;
108
109         charbp := scharbp;
110         charht := scharht;
111         chardp := schardp;
112         charwd := scharwd;
113
114         w := hround (w_sharp * hppp);
115         b := hround (b_sharp * hppp);
116         h := vround (h_sharp * vppp);
117         d := vround (d_sharp * vppp);
118
119         charwx := charwd;
120         charwy := 0;
121
122         % additions for mf2pt1
123         if known bp_per_pixel:
124                 special "% MF2PT1: bbox "
125                         & to_bp (-b) & " "
126                         & to_bp (-d) & " "
127                         & to_bp (w) & " "
128                         & to_bp (h);
129                 special "% MF2PT1: font_size " & decimal designsize;
130                 special "% MF2PT1: font_slant " & decimal font_slant_;
131
132                 for fvar = "font_identifier",
133                            "font_coding_scheme",
134                            "font_version",
135                            "font_comment",
136                            "font_family",
137                            "font_weight",
138                            "font_unique_id",
139                            "font_name":
140                         if known scantokens (fvar & "_"):
141                                 special "% MF2PT1: "
142                                         & fvar & " "
143                                         & scantokens (fvar & "_");
144                         fi;
145                 endfor;
146
147                 for fvar = "font_underline_position",
148                            "font_underline_thickness":
149                         if known scantokens (fvar & "_"):
150                                 special "% MF2PT1: "
151                                         & fvar & " "
152                                         & scantokens ("decimal " & fvar & "_");
153                         fi;
154                 endfor;
155
156                 special "% MF2PT1: font_fixed_pitch "
157                         & (if font_fixed_pitch_: "1" else: "0" fi);
158
159                 % this must come after the `font_size' special
160                 special "% MF2PT1: charwd " & decimal charwd;
161         fi;
162 enddef;
163
164
165 def no_dimen_beginchar (expr c) =
166 begingroup
167         charcode := if known c: byte c else: 0; fi;
168         charic := 0;
169         clearxy;
170         clearit;
171         clearpen;
172         scantokens extra_beginchar;
173 enddef;
174
175
176 %
177 % we leave the ctrl characters alone.
178 %
179 code := 32;
180
181
182 % starts just as plain mf's beginchar:
183 %     charcode,
184 % and then adds:
185 %     charname  see below
186 %     id        index in lily's table
187
188 % The dimensions are uninitialised; you should use set_char_box manually.
189 def fet_beginchar (expr name, id_lit) =
190         save idstr, charnamestr;
191         save charbp;
192         save w, b, h, d;
193         save charwx, charwy;
194
195         string idstr, charnamestr;
196         charnamestr := name;
197         idstr := id_lit;
198
199         no_dimen_beginchar (incr code) name;
200 enddef;
201
202
203 def makebox_with_breapth (text r) =
204         for y = -d, 0, h:
205                 r ((-b, y), (w, y));
206         endfor;
207
208         for x = -b, 0, w:
209                 r ( (x, -d), (x, h));
210         endfor;
211 enddef;
212
213
214 %
215 % override plain endchar.  We want a different box.
216 %
217 def breapth_endchar =
218         scantokens extra_endchar;
219
220         if proofing > 0:
221                 makebox_with_breapth (proofrule);
222         fi;
223
224         chardx := (w + b);      % what the heck is chardx
225         shipit;
226 endgroup
227 enddef;
228
229
230 def fet_endchar=
231         autometric_output_char;
232         breapth_endchar;
233 enddef;