]> git.donarmstrong.com Git - lilypond.git/blob - mf/parmesan-flags.mf
Adapting parmesan-flags.mf to mf2pt1.
[lilypond.git] / mf / parmesan-flags.mf
1 % -%-Fundamental-%- -*-Metafont-*-
2 % parmesan-flags.mf -- implement ancient flags
3
4 % source file of LilyPond's pretty-but-neat music font
5
6 % (c) 2001--2006 Juergen Reuter <reuter@ipd.uka.de>
7
8
9 fet_begingroup ("flags");
10
11 save between_staff_lines, on_staff_line, anywhere;
12
13 between_staff_lines := 0;
14 on_staff_line := 1;
15 anywhere := 2;
16
17 save dir_up, dir_down;
18
19 dir_up := 1;
20 dir_down := -1;
21
22
23 %%%%%%%%
24 %
25 %
26 %
27 % Mensural Notation
28 %
29 %
30 %
31
32 def draw_mensural_outermost_flare (expr staffline_adjustment, d_) =
33         define_pixels (linethickness, staff_space);
34
35         save ellipse, pat;
36         path ellipse, pat;
37
38         pickup pencircle xscaled 1.00 linethickness
39                          yscaled 0.22 staff_space
40                          rotated -35;
41
42         ellipse := fullcircle xscaled 1.00 linethickness
43                               yscaled 0.22 staff_space
44                               rotated -35;
45         
46         z11 = (+0.00 staff_space, -0.00 staff_space);
47         z12 = (+0.15 staff_space, -0.00 staff_space);
48
49         if staffline_adjustment = between_staff_lines:
50                 z13 = (+0.45 staff_space, -0.35 staff_space);
51                 z14 = (+0.45 staff_space, -0.85 staff_space);
52                 z15 = (+0.00 staff_space, -2.00 staff_space);
53         elseif staffline_adjustment = on_staff_line:
54                 z13 = (+0.20 staff_space, -0.05 staff_space);
55                 z14 = (+0.20 staff_space, -1.15 staff_space);
56                 z15 = (+0.00 staff_space, -1.40 staff_space);
57         else: % staffline_adjustment = anywhere
58                 z13 = (+0.33 staff_space, -0.20 staff_space);
59                 z14 = (+0.33 staff_space, -1.00 staff_space);
60                 z15 = (+0.00 staff_space, -1.70 staff_space);
61         fi;
62
63         pat := z13{z13 - z12}
64                .. {z15 - z14}z14;
65
66         fill get_subpath (ellipse, z11 - z12, z12 - z11, z11)
67              -- get_subpoint (ellipse, z12 - z11, z12)
68              -- get_subpoint (ellipse, z13 - z12, z12)
69              -- get_subpoint (ellipse, direction 0 of pat, z13)
70                   {direction 0 of pat}
71              .. {direction 1 of pat}
72                   get_subpoint (ellipse, direction 1 of pat, z14)
73              -- get_subpath (ellipse, z15 - z14, z14 - z15, z15)
74              -- get_subpoint (ellipse, -direction 1 of pat, z14)
75                   {-direction 1 of pat}
76              .. {-direction 0 of pat}
77                   get_subpoint (ellipse, -direction 0 of pat, z13)
78              -- get_subpath (ellipse, z12 - z13, z11 - z12, z12)
79              -- cycle;
80
81         if d_ = dir_up:
82                 labels (11, 12, 13, 14, 15);
83         fi;
84 enddef;
85
86
87 def draw_mensural_inner_flare (expr il_shift, idx, d_) =
88         define_pixels (linethickness, staff_space);
89
90         save ellipse, pat;
91         path ellipse, pat;
92
93         pickup pencircle xscaled 1.00 linethickness
94                          yscaled 0.22 staff_space
95                          rotated -35;
96
97         ellipse := fullcircle xscaled 1.00 linethickness
98                               yscaled 0.22 staff_space
99                               rotated -35;
100
101         save i;
102         numeric i[];
103
104         i0 := idx * 10;
105         i1 := idx * 10 + 1;
106         i2 := idx * 10 + 2;
107         i3 := idx * 10 + 3;
108         i4 := idx * 10 + 4;
109
110         z[i0] = (0, -il_shift * staff_space);
111         z[i1] = z[i0] + (+0.00 staff_space, -0.10 staff_space);
112         z[i2] = z[i0] + (+0.33 staff_space, -0.30 staff_space);
113         z[i3] = z[i0] + (+0.33 staff_space, -0.70 staff_space);
114         z[i4] = z[i0] + (+0.00 staff_space, -0.90 staff_space);
115
116         pat := z[i1]{2, 1}
117                .. z[i2]
118                .. z[i3]
119                .. {-2, -1}z[i4];
120
121         % we avoid cusps originally present in `draw pat'
122         fill get_subpath (ellipse,
123                           -direction 0 of pat, direction 0 of pat, z[i1])
124              .. get_subpoint (ellipse, direction 1 of pat, z[i2])
125                   {direction 1 of pat}
126              .. get_subpoint (ellipse, direction 2 of pat, z[i3])
127                   {direction 2 of pat}
128              .. get_subpath (ellipse,
129                              direction 3 of pat, -direction 3 of pat, z[i4])
130              .. get_subpoint (ellipse, -direction 2 of pat, z[i3])
131                   {-direction 2 of pat}
132              .. get_subpoint (ellipse, -direction 1 of pat, z[i2])
133                   {-direction 1 of pat}
134              .. cycle;
135
136         if d_ = dir_up:
137                 labels ([i0], [i1], [i2], [i3], [i4]);
138         fi;
139 enddef;
140
141
142 def draw_mensural_flag (expr staffline_adjustment, flares, d_) =
143         save char_box_adjust, flare_shift;
144
145         if staffline_adjustment = between_staff_lines:
146                 flare_shift := 0.5;
147         elseif staffline_adjustment = on_staff_line:
148                 flare_shift := 0.0;
149         else: % staffline_adjustment = anywhere
150                 flare_shift := 0.25;
151         fi;
152
153         char_box_adjust := flare_shift + 0.5;
154
155         if d_ = dir_up:
156                 set_char_box (0,
157                               0.60 staff_space#,
158                               (flares + char_box_adjust) * staff_space#,
159                               0.10 staff_space#);
160         else: % d_ = dir_down
161                 set_char_box (0.60 staff_space#,
162                               0,
163                               0.10 staff_space#,
164                               (flares + char_box_adjust) * staff_space#);
165         fi;
166
167         draw_mensural_outermost_flare (staffline_adjustment, d_);
168
169         for flare_count := 2 step 1 until 4:
170                 if flares >= flare_count:
171                         draw_mensural_inner_flare (flare_shift
172                                                    + flare_count - 0.5,
173                                                    flare_count, d_);
174                 fi;
175         endfor;
176
177         if d_ = dir_down:
178                 currentpicture := currentpicture xscaled -1
179                                                  yscaled -1;
180         fi;
181 enddef;
182
183
184 % 8th mensural flag, upwards, between staff lines
185 fet_beginchar ("8th Mensural Flag (up)", "mensuralu03");
186         draw_mensural_flag (between_staff_lines, 1, dir_up);
187 fet_endchar;
188
189
190 % 8th mensural flag, upwards, on staff line
191 fet_beginchar ("8th Mensural Flag (up)", "mensuralu13");
192         draw_mensural_flag (on_staff_line, 1, dir_up);
193 fet_endchar;
194
195
196 % 8th mensural flag, upwards, anywhere
197 fet_beginchar ("8th Mensural Flag (up)", "mensuralu23");
198         draw_mensural_flag (anywhere, 1, dir_up);
199 fet_endchar;
200
201
202 % 8th mensural flag, downwards, between staff lines
203 fet_beginchar ("8th Mensural Flag (down)", "mensurald03");
204         draw_mensural_flag (between_staff_lines, 1, dir_down);
205 fet_endchar;
206
207
208 % 8th mensural flag, downwards, on staff line
209 fet_beginchar ("8th Mensural Flag (down)", "mensurald13");
210         draw_mensural_flag (on_staff_line, 1, dir_down);
211 fet_endchar;
212
213
214 % 8th mensural flag, downwards, anywhere
215 fet_beginchar ("8th Mensural Flag (down)", "mensurald23");
216         draw_mensural_flag (anywhere, 1, dir_down);
217 fet_endchar;
218
219
220 % 16th mensural flag, upwards, between staff lines
221 fet_beginchar ("16th Mensural Flag (up)", "mensuralu04");
222         draw_mensural_flag (between_staff_lines, 2, dir_up);
223 fet_endchar;
224
225
226 % 16th mensural flag, upwards, on staff line
227 fet_beginchar ("16th Mensural Flag (up)", "mensuralu14");
228         draw_mensural_flag (on_staff_line, 2, dir_up);
229 fet_endchar;
230
231
232 % 16th mensural flag, upwards, anywhere
233 fet_beginchar ("16th Mensural Flag (up)", "mensuralu24");
234         draw_mensural_flag (anywhere, 2, dir_up);
235 fet_endchar;
236
237
238 % 16th mensural flag, downwards, between staff lines
239 fet_beginchar ("16th Mensural Flag (down)", "mensurald04");
240         draw_mensural_flag (between_staff_lines, 2, dir_down);
241 fet_endchar;
242
243
244 % 16th mensural flag, downwards, on staff line
245 fet_beginchar ("16th Mensural Flag (down)", "mensurald14");
246         draw_mensural_flag (on_staff_line, 2, dir_down);
247 fet_endchar;
248
249
250 % 16th mensural flag, downwards, anywhere
251 fet_beginchar ("16th Mensural Flag (down)", "mensurald24");
252         draw_mensural_flag (anywhere, 2, dir_down);
253 fet_endchar;
254
255
256 % 32th mensural flag, upwards, between staff lines
257 fet_beginchar ("32th Mensural Flag (up)", "mensuralu05");
258         draw_mensural_flag (between_staff_lines, 3, dir_up);
259 fet_endchar;
260
261
262 % 32th mensural flag, upwards, on staff line
263 fet_beginchar ("32th Mensural Flag (up)", "mensuralu15");
264         draw_mensural_flag (on_staff_line, 3, dir_up);
265 fet_endchar;
266
267
268 % 32th mensural flag, upwards, anywhere
269 fet_beginchar ("32th Mensural Flag (up)", "mensuralu25");
270         draw_mensural_flag (anywhere, 3, dir_up);
271 fet_endchar;
272
273
274 % 32th mensural flag, downwards, between staff lines
275 fet_beginchar ("32th Mensural Flag (down)", "mensurald05");
276         draw_mensural_flag (between_staff_lines, 3, dir_down);
277 fet_endchar;
278
279
280 % 32th mensural flag, downwards, on staff line
281 fet_beginchar ("32th Mensural Flag (down)", "mensurald15");
282         draw_mensural_flag (on_staff_line, 3, dir_down);
283 fet_endchar;
284
285
286 % 32th mensural flag, downwards, anywhere
287 fet_beginchar ("32th Mensural Flag (down)", "mensurald25");
288         draw_mensural_flag (anywhere, 3, dir_down);
289 fet_endchar;
290
291
292 % 64th mensural flag, upwards, between staff lines
293 fet_beginchar ("64th Mensural Flag (up)", "mensuralu06");
294         draw_mensural_flag (between_staff_lines, 4, dir_up);
295 fet_endchar;
296
297
298 % 64th mensural flag, upwards, on staff line
299 fet_beginchar ("64th Mensural Flag (up)", "mensuralu16");
300         draw_mensural_flag (on_staff_line, 4, dir_up);
301 fet_endchar;
302
303
304 % 64th mensural flag, upwards, anywhere
305 fet_beginchar ("64th Mensural Flag (up)", "mensuralu26");
306         draw_mensural_flag (anywhere, 4, dir_up);
307 fet_endchar;
308
309
310 % 64th mensural flag, downwards, between staff lines
311 fet_beginchar ("64th Mensural Flag (down)", "mensurald06");
312         draw_mensural_flag (between_staff_lines, 4, dir_down);
313 fet_endchar;
314
315
316 % 64th mensural flag, downwards, on staff line
317 fet_beginchar ("64th Mensural Flag (down)", "mensurald16");
318         draw_mensural_flag (on_staff_line, 4, dir_down);
319 fet_endchar;
320
321
322 % 64th mensural flag, downwards, anywhere
323 fet_beginchar ("64th Mensural Flag (down)", "mensurald26");
324         draw_mensural_flag (anywhere, 4, dir_down);
325 fet_endchar;
326
327
328 fet_endgroup ("flags");