]> git.donarmstrong.com Git - lilypond.git/blob - mf/parmesan-custodes.mf
Merge commit 'd77d089' into jneeman
[lilypond.git] / mf / parmesan-custodes.mf
1 % -%-Fundamental-%- -*-Metafont-*-
2 % parmesan-custodes.mf -- implement ancient custodes
3
4 % source file of LilyPond's pretty-but-neat music font
5
6 % (c) 2000--2006 Juergen Reuter <reuter@ipd.uka.de>
7
8
9 save black_notehead_width;
10 numeric black_notehead_width;
11
12 fet_begingroup ("custodes");
13
14 %
15 % character aligment:
16 %
17 %   The custos is assumed to be vertically centered around (0, 0).
18 %   The left-most edge of the custos should touch the vertical line
19 %   that goes though the point (0, 0).
20 %
21 % set_char_box() conventions:
22 %
23 % * breapth: Ignored (as far as I know).  Should be set to 0.
24 %
25 % * width: Should cover the horizontal range of the custos that is to
26 %   be printed in the staff.  If the custos has an appendage that is
27 %   supposed to reach beyond the right end of the staff, the width
28 %   should be set such that the appendage is outside of the char box.
29 %
30 % * depth: Should match the bottom edge of the custos.  Affects
31 %   vertical collision handling.
32 %
33 % * height: Should match the top edge of the custos.  Affects vertical
34 %   collision handling.
35 %
36
37 save between_staff_lines, on_staff_line, anywhere;
38
39 between_staff_lines := 0;
40 on_staff_line := 1;
41 anywhere := 2;
42
43 save dir_up, dir_down;
44
45 dir_up := 1;
46 dir_down := -1;
47
48
49 %%%%%%%%
50 %
51 %
52 % Hufnagel style
53 %
54 %
55
56 % parameterized hufnagel custos
57 def custos_hufnagel (expr verbose_name, internal_name, 
58                           direction, staffline_adjustment) =
59
60         fet_beginchar (verbose_name, internal_name);
61                 save alpha, dalpha, ht, wd, stem_ht, pen_size;
62
63                 ht# = noteheight#;
64                 wd# / ht# = 0.6;
65                 alpha = 35;
66                 dalpha = direction * alpha;
67
68                 if staffline_adjustment = between_staff_lines:
69                         stem_ht# = 1.00 staff_space#;
70                 elseif staffline_adjustment = on_staff_line:
71                         stem_ht# = 1.50 staff_space#;
72                 else: % staffline_adjustment = anywhere
73                         stem_ht# = 1.25 staff_space#;
74                 fi;
75
76                 pen_size# = 0.5 (wd# ++ ht#);
77
78                 define_pixels (ht, wd, pen_size, stem_ht);
79
80                 save ellipse, pat;
81                 path ellipse, pat;
82
83                 pickup pencircle xscaled linethickness
84                                  yscaled pen_size
85                                  rotated -dalpha;
86
87                 ellipse := fullcircle xscaled linethickness
88                                       yscaled pen_size
89                                       rotated -dalpha;
90
91                 if direction = dir_up:
92                         top y1 = ht / 2;
93                         bot y2 = -ht / 2;
94                 else:
95                         bot y1 = -ht / 2;
96                         top y2 = ht / 2;
97                 fi;
98
99                 lft x1 = 0;
100                 rt  x2 = wd;
101                 y3 - y2 = direction * stem_ht;
102                 (y3 - y2) = (x3 - x2) * tand (90 - dalpha);
103
104                 fill get_subpath (ellipse, z1 - z2, z2 - z1, z1)
105                      if direction > 0:
106                              -- get_subpath (ellipse, z2 - z1, z3 - z2, z2)
107                      else:
108                              -- get_subpoint (ellipse, z2 - z1, z2)
109                              -- get_subpoint (ellipse, z3 - z2, z2)
110                      fi
111                      -- get_subpath (ellipse, z3 - z2, z2 - z3, z3)
112                      if direction > 0:
113                              -- get_subpoint (ellipse, z2 - z3, z2)
114                              -- get_subpoint (ellipse, z1 - z2, z2)
115                      else:
116                              -- get_subpath (ellipse, z2 - z3, z1 - z2, z2)
117                      fi
118                      -- cycle;
119
120                 % The stem is intentionally outside of the char box.
121                 if direction > 0:
122                         set_char_box (0, wd#, ht# / 2, stem_ht#);
123                 else:
124                         set_char_box (0, wd#, stem_ht#, ht# / 2);
125                 fi;
126
127                 labels (1, 2, 3);
128         fet_endchar;
129 enddef;
130
131
132 % custos hufnagel, stem up, between staff lines
133 custos_hufnagel ("Custos Hufnagel", "hufnagel.u0", 
134                  dir_up, between_staff_lines);
135
136
137 % custos hufnagel, stem up, on staff line
138 custos_hufnagel ("Custos Hufnagel", "hufnagel.u1", 
139                  dir_up, on_staff_line);
140
141
142 % custos hufnagel, stem up, anywhere
143 custos_hufnagel ("Custos Hufnagel", "hufnagel.u2", 
144                  dir_up, anywhere);
145
146
147 % custos hufnagel, stem down, between staff lines
148 custos_hufnagel ("Reverse Custos Hufnagel", "hufnagel.d0",
149                  dir_down, between_staff_lines);
150
151
152 % custos hufnagel, stem down, on staff line
153 custos_hufnagel ("Reverse Custos Hufnagel", "hufnagel.d1",
154                  dir_down, on_staff_line);
155
156
157 % custos hufnagel, stem down, anywhere
158 custos_hufnagel ("Reverse Custos Hufnagel", "hufnagel.d2",
159                  dir_down, anywhere);
160
161
162 %%%%%%%%
163 %
164 %
165 % Medicaea style
166 %
167 %
168
169 def custos_medicaea (expr verbose_name, internal_name, 
170                           direction, staffline_adjustment) =
171         fet_beginchar (verbose_name, internal_name);
172                 save ht, wd, stem_ht;
173
174                 ht# = noteheight#;
175                 wd# / ht# = 0.25;
176
177                 if staffline_adjustment = between_staff_lines:
178                         stem_ht# = 1.00 staff_space#;
179                 elseif staffline_adjustment = on_staff_line:
180                         stem_ht# = 1.50 staff_space#;
181                 else: % staffline_adjustment = anywhere
182                         stem_ht# = 1.25 staff_space#;
183                 fi;
184
185                 define_pixels (ht, wd, stem_ht);
186
187                 save ellipse;
188                 path ellipse;
189
190                 pickup pencircle xscaled 0.6 linethickness
191                                  yscaled ht;
192
193                 ellipse := fullcircle xscaled 0.6 linethickness
194                                       yscaled ht;
195
196                 lft x1 = 0;
197                 y1 = 0;
198                 rt x2 = wd;
199                 y2 = y1;
200
201                 fill get_subpath (ellipse, left, right, z1)
202                      -- get_subpath (ellipse, right, left, z2)
203                      -- cycle;
204
205                 pickup pencircle scaled 0.6 linethickness;
206
207                 rt x3 = wd;
208                 y3 = 0;
209                 x4 = x3;
210                 if direction > 0:
211                         top y4 = stem_ht;
212                         draw_rounded_block (bot lft z3, top rt z4,
213                                             0.6 linethickness);
214                 else:
215                         bot y4 = -stem_ht;
216                         draw_rounded_block (bot lft z4, top rt z3,
217                                             0.6 linethickness);
218                 fi;
219
220
221                 if direction > 0:
222                         set_char_box (0, wd#, ht# / 2, stem_ht#);
223                 else:
224                         set_char_box (0, wd#, stem_ht#, ht# / 2);
225                 fi;
226
227                 labels (1, 2, 3, 4);
228         fet_endchar;
229 enddef;
230
231
232 % custos medicaea, stem up, between staff lines
233 custos_medicaea ("Custos Med.", "medicaea.u0", 
234                  dir_up, between_staff_lines);
235
236
237 % custos medicaea, stem up, on staff line
238 custos_medicaea ("Custos Med.", "medicaea.u1", 
239                  dir_up, on_staff_line);
240
241
242 % custos medicaea, stem up, anywhere
243 custos_medicaea ("Custos Med.", "medicaea.u2", 
244                  dir_up, anywhere);
245
246
247 % custos medicaea, stem down, between staff lines
248 custos_medicaea ("Reverse Custos Med.", "medicaea.d0", 
249                 dir_down, between_staff_lines);
250
251
252 % custos medicaea, stem down, on staff line
253 custos_medicaea ("Reverse Custos Med.", "medicaea.d1", 
254                  dir_down, on_staff_line);
255
256
257 % custos medicaea, stem down, anywhere
258 custos_medicaea ("Reverse Custos Med.", "medicaea.d2", 
259                  dir_down, anywhere);
260
261
262 %%%%%%%%
263 %
264 %
265 % Editio Vaticana style
266 %
267 %
268
269 def custos_vaticana (expr verbose_name, internal_name, 
270                           direction, staffline_adjustment) =
271         fet_beginchar (verbose_name, internal_name);
272                 save ht, wd, u_offs, l_offs, stem_size, stem_end;
273                 save pen_ht, l_shift, curve_ht, bend_ht;
274
275                 ht# = noteheight#;
276                 wd# = 0.24 ht#;
277
278                 if staffline_adjustment = between_staff_lines:
279                         stem_size# = 1.00;
280                 elseif staffline_adjustment = on_staff_line:
281                         stem_size# = 1.50;
282                 else: % staffline_adjustment = anywhere
283                         stem_size# = 1.25;
284                 fi;
285
286                 curve_ht# = 0.6 ht#;
287                 bend_ht# = 0.10 ht#;
288                 l_shift# = 0.04 ht#;
289                 u_offs# = +direction * 0.5 * (bend_ht# + l_shift#);
290                 l_offs# = -direction * 0.5 * (bend_ht# - l_shift#);
291                 stem_end# = direction * stem_size# * staff_space#;
292                 pen_ht# = curve_ht# - l_shift#;
293
294                 define_pixels (u_offs, l_offs, stem_end, ht, wd, pen_ht);
295
296                 pickup pencircle scaled 0.6 linethickness;
297
298                 z1 = (0, u_offs);
299                 z2 = (0.7 wd, l_offs);
300                 z3 = (wd, l_offs);
301
302                 penpos1 (pen_ht, 90);
303                 penpos2 (pen_ht, 90);
304                 penpos3 (pen_ht, 90);
305
306                 penstroke z1e{z2 - z1}
307                           .. {right}z2e
308                           .. z3e;
309
310                 rt x4 = wd;
311                 x5 = x4;
312
313                 if direction > 0:
314                         y4 = y3r;
315                         top y5 = stem_end;
316                         draw_rounded_block (bot lft z4, top rt z5,
317                                             0.6 linethickness);
318                 else:
319                         y4 = y3l;
320                         bot y5 = stem_end;
321                         draw_rounded_block (bot lft z5, top rt z4,
322                                             0.6 linethickness);
323                 fi;
324
325                 if direction > 0:
326                         set_char_box (0, wd#,
327                                       -l_offs# + 0.5 pen_ht#, stem_end#);
328                 else:
329                         set_char_box (0, wd#,
330                                       -stem_end#, +l_offs# + 0.5 pen_ht#);
331                 fi;
332
333                 penlabels (1, 2, 3);
334                 labels (4, 5);
335         fet_endchar;
336 enddef;
337
338
339 % custos vaticana, stem up, between staff lines
340 custos_vaticana ("Custos Ed. Vat.", "vaticana.u0", 
341                  dir_up, between_staff_lines);
342
343
344 % custos vaticana, stem up, on staff line
345 custos_vaticana ("Custos Ed. Vat.", "vaticana.u1", 
346                  dir_up, on_staff_line);
347
348
349 % custos vaticana, stem up, anywhere
350 custos_vaticana ("Custos Ed. Vat.", "vaticana.u2", 
351                  dir_up, anywhere);
352
353
354 % custos vaticana, stem down, between staff lines
355 custos_vaticana ("Reverse Custos Ed. Vat.", "vaticana.d0", 
356                  dir_down, between_staff_lines);
357
358
359 % custos vaticana, stem down, on_staff_line
360 custos_vaticana ("Reverse Custos Ed. Vat.", "vaticana.d1", 
361                  dir_down, on_staff_line);
362
363
364 % custos vaticana, stem down, anywhere
365 custos_vaticana ("Reverse Custos Ed. Vat.", "vaticana.d2", 
366                  dir_down, anywhere);
367
368
369 %%%%%%%%
370 %
371 %
372 % Mensural style
373 %
374 %
375
376 def custos_mensural (expr verbose_name, internal_name, 
377                           direction, staffline_adjustment) =
378         fet_beginchar (verbose_name, internal_name);
379                 save alpha, dalpha, ht, wd, stem_ht;
380
381                 ht# = noteheight#;
382                 wd# / ht# = 1.2;
383                 alpha = 35;
384                 dalpha = direction * alpha;
385
386                 if staffline_adjustment = between_staff_lines:
387                         stem_ht# = 1.00 staff_space#;
388                 elseif staffline_adjustment = on_staff_line:
389                         stem_ht# = 1.50 staff_space#;
390                 else: % staffline_adjustment = anywhere
391                         stem_ht# = 1.25 staff_space#;
392                 fi;
393
394                 define_pixels (ht, wd, stem_ht);
395
396                 save ellipse;
397                 path ellipse;
398
399                 pickup pencircle xscaled linethickness
400                                  yscaled 0.4ht
401                                  rotated -dalpha;
402
403                 ellipse := fullcircle xscaled linethickness
404                                       yscaled 0.4ht
405                                       rotated -dalpha;
406
407                 if direction > 0:
408                         bot y1 = bot y3 = bot y5 = -direction * 0.33 ht;
409                         top y2 = top y4 = +direction * 0.33 ht;
410                 else:
411                         top y1 = top y3 = top y5 = -direction * 0.33 ht;
412                         bot y2 = bot y4 = +direction * 0.33 ht;
413                 fi;
414
415                 lft x1 = 0.0 wd;
416                 lft x2 = 0.2 wd;
417                 lft x3 = 0.4 wd;
418                 lft x4 = 0.6 wd;
419                 lft x5 = 0.8 wd;
420
421                 y6 - y5 = direction * stem_ht;
422                 y6 - y5 = (x6 - x5) * tand (90 - dalpha);
423
424                 if direction > 0:
425                         fill get_subpath (ellipse, z1 - z2, z2 - z1, z1)
426                              -- get_subpoint (ellipse, z2 - z1, z2)
427                              -- get_subpoint (ellipse, z3 - z2, z2)
428                              -- get_subpath (ellipse, z3 - z2, z4 - z3, z3)
429                              -- get_subpoint (ellipse, z4 - z3, z4)
430                              -- get_subpoint (ellipse, z5 - z4, z4)
431                              -- get_subpath (ellipse, z5 - z4, z6 - z5, z5)
432                              -- get_subpath (ellipse, z6 - z5, z5 - z6, z6)
433                              -- get_subpoint (ellipse, z5 - z6, z5)
434                              -- get_subpoint (ellipse, z4 - z5, z5)
435                              -- get_subpath (ellipse, z4 - z5, z3 - z4, z4)
436                              -- get_subpoint (ellipse, z3 - z4, z3)
437                              -- get_subpoint (ellipse, z2 - z3, z3)
438                              -- get_subpath (ellipse, z2 - z3, z1 - z2, z2)
439                              -- cycle;
440                 else:
441                         fill get_subpath (ellipse, z1 - z2, z2 - z1, z1)
442                              -- get_subpath (ellipse, z2 -z1, z3 - z2, z2)
443                              -- get_subpoint (ellipse, z3 - z2, z3)
444                              -- get_subpoint (ellipse, z4 - z3, z3)
445                              -- get_subpath (ellipse, z4 -z3, z5 - z4, z4)
446                              -- get_subpoint (ellipse, z5 - z4, z5)
447                              -- get_subpoint (ellipse, z6 - z5, z5)
448                              -- get_subpath (ellipse, z6 - z5, z5 - z6, z6)
449                              -- get_subpath (ellipse, z5 - z6, z4 - z5, z5)
450                              -- get_subpoint (ellipse, z4 - z5, z4)
451                              -- get_subpoint (ellipse, z3 - z4, z4)
452                              -- get_subpath (ellipse, z3 - z4, z2 - z3, z3)
453                              -- get_subpoint (ellipse, z2 - z3, z2)
454                              -- get_subpoint (ellipse, z1 - z2, z2)
455                              -- cycle;
456                 fi;
457
458                 % The stem is intentionally outside of the char box.
459                 if direction > 0:
460                         set_char_box (0, wd#,
461                                       +direction * 0.33 ht#, stem_ht#);
462                 else:
463                         set_char_box (0, wd#,
464                                       stem_ht#, -direction * 0.33 ht#);
465                 fi;
466
467                 labels (1, 2, 3, 4, 5, 6);
468         fet_endchar;
469 enddef;
470
471
472 % custos mensural, stem up, between staff lines
473 custos_mensural ("Custos Mensural", "mensural.u0", 
474                  dir_up, between_staff_lines);
475
476
477 % custos mensural, stem up, on staff line
478 custos_mensural ("Custos Mensural", "mensural.u1", 
479                  dir_up, on_staff_line);
480
481
482 % custos mensural, stem up, anywhere
483 custos_mensural ("Custos Mensural", "mensural.u2", 
484                  dir_up, anywhere);
485
486
487 % custos mensural, stem down, between staff lines
488 custos_mensural ("Reverse Custos Mensural", "mensural.d0", 
489                  dir_down, between_staff_lines);
490
491
492 % custos mensural, stem down, on staff line
493 custos_mensural ("Reverse Custos Mensural", "mensural.d1", 
494                  dir_down, on_staff_line);
495
496
497 % custos mensural, stem down, anywhere
498 custos_mensural ("Reverse Custos Mensural", "mensural.d2", 
499                  dir_down, anywhere);
500
501
502 fet_endgroup ("custodes");