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