]> git.donarmstrong.com Git - lilypond.git/blob - mf/parmesan-clefs.mf
Merge branch 'master' of ssh://hanwen@git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / mf / parmesan-clefs.mf
1 % -%-Fundamental-%- -*-Metafont-*-
2 % parmesan-clefs.mf -- implement ancient clefs
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 ("clefs");
10
11 %
12 % character aligment:
13 %
14 %   Each clef is associated with a particular pitch: the treble clef
15 %   with the `g', the alto clef with the `c', the bass clef with the
16 %   `f', etc.  The shape of each clef character defines a vertical
17 %   position that is assumed to represent this pitch.  For the treble
18 %   clef, it is the vertical position of the center of the spiral
19 %   ending that represents the `g' pitch.  For the bass clef, it is
20 %   the center between the two fat dots that define the vertical
21 %   position of the `f' pitch.  For the alto clef, it is the vertical
22 %   center of the clef that is aligned with the `c' pitch.  For each
23 %   clef character, this center should be vertically aligned with the
24 %   point (0, 0).  The horizontal alignment of each clef character
25 %   should be such that the vertical line through the point (0, 0)
26 %   touches the left-most edge of the clef.
27 %
28 %   TODO: document exact_center
29 %
30 % set_char_box() conventions:
31 %
32 % * breapth: Ignored (as far as I know).  Should be set to 0.
33 %
34 % * width: Should match the clef's width.
35 %
36 % * depth: Should match the bottom edge of the clef.  Affects vertical
37 %   collision handling.
38 %
39 % * height: Should match the top edge of the clef.  Affects vertical
40 %   collision handling.
41 %
42
43
44 %%%%%%%%
45 %
46 %
47 %
48 % Editio Vaticana
49 %
50 %
51 %
52 def draw_vaticana_do_clef (expr exact_center, reduction) = 
53         save reduced_il;
54
55         reduced_il# = staff_space# * reduction;
56
57         set_char_box (0 - xpart exact_center,
58                       0.5 reduced_il# + xpart exact_center,
59                       0.8 reduced_il# - ypart exact_center,
60                       0.8 reduced_il# + ypart exact_center);
61
62         define_pixels (reduced_il);
63
64         save pat, ellipse, clef;
65         path pat, ellipse, clef;
66
67         pickup pencircle xscaled 0.6 linethickness
68                          yscaled 0.6 reduced_il;
69
70         ellipse := reverse fullcircle xscaled 0.6 linethickness
71                                       yscaled 0.6 reduced_il;
72
73         save xoffs, yoffs;
74
75         xoffs# = xpart exact_center;
76         yoffs# = ypart exact_center;
77
78         define_pixels (xoffs, yoffs);
79
80         rt z11 = (xoffs + 0.50 reduced_il, yoffs - .45 reduced_il);
81         z12 = (xoffs + 0.25 reduced_il, yoffs - .50 reduced_il);
82         lft z13 = (xoffs + 0.00 reduced_il, yoffs - .28 reduced_il);
83         lft z14 = (xoffs, yoffs);
84
85         pat := z11
86                .. z12
87                .. z13
88                -- z14;
89
90         save shift;
91         pair shift;
92
93         % adjust vertically to fit into bounding box
94         shift = find_tangent_shift (((0, -d + 0.3 reduced_il)
95                                      -- (w, -d + 0.3 reduced_il)), pat,
96                                     (0, -d / 2), (0, d / 2));
97         pat := pat shifted shift;
98
99         clef := rt z14{down}
100                 .. top (point 1 of pat)
101                 .. get_subpath (ellipse,
102                                 -direction 0 of pat, direction 0 of pat,
103                                 point 0 of pat)
104                 .. bot (point 1 of pat)
105                 .. get_subpath (ellipse,
106                                 direction 2 of pat, up,
107                                 point 2 of pat);
108
109         fill clef
110              -- reverse clef yscaled -1
111              -- cycle;
112
113         labels (11, 12, 13, 14);
114 enddef;
115
116
117 fet_beginchar ("Ed. Vat. do clef", "vaticana.do");
118         if test = 1:
119                 draw_staff (-1, 3, 0.0);
120         fi;
121         draw_vaticana_do_clef ((0, 0), 1.0);
122 fet_endchar;
123
124
125 fet_beginchar ("Ed. Vat. do clef", "vaticana.do_change");
126         draw_vaticana_do_clef ((0, 0), 1.0); % no reduction
127 fet_endchar;
128
129
130 def draw_vaticana_fa_clef (expr exact_center, reduction) = 
131         save reduced_il, xoffs, yoffs;
132
133         reduced_il# = staff_space# * reduction;
134         xoffs# = xpart exact_center;
135         yoffs# = ypart exact_center;
136
137         define_pixels (reduced_il, xoffs, yoffs);
138
139         % left-handed punctum
140         pickup pencircle xscaled 0.6 linethickness
141                          yscaled 0.5 reduced_il;
142
143         save ellipse, pat;
144         path ellipse, pat;
145
146         ellipse := reverse fullcircle xscaled 0.6 linethickness
147                                       yscaled 0.5 reduced_il;
148
149         lft z21 = (xoffs + 0.00 reduced_il, yoffs + 0.00 reduced_il);
150         z22 = (xoffs + 0.25 reduced_il, yoffs + 0.05 reduced_il);
151         rt z23 = (xoffs + 0.50 reduced_il, yoffs - 0.05 reduced_il);
152
153         pat := z21
154                .. z22
155                .. z23;  
156
157         fill get_subpath (ellipse,
158                           -direction 0 of pat, direction 0 of pat, z21)
159              .. top z22
160              .. get_subpath (ellipse,
161                              direction 2 of pat, -direction 2 of pat, z23)
162              .. bot z22
163              .. cycle;
164
165         % stem
166         pickup pencircle scaled 0.6 linethickness;
167
168         x23 = x24;
169         yoffs = bot y24 + 1.5 reduced_il;
170
171         draw_rounded_block (bot lft z24, top rt z23, 0.6 linethickness);
172
173         labels (21, 22, 23, 24);
174
175         % right-handed puncta as in do clef
176         draw_vaticana_do_clef (exact_center + (0.55 reduced_il#, 0),
177                                reduction);
178
179         set_char_box (0 - xpart exact_center,
180                       1.05 reduced_il# + xpart exact_center,
181                       1.5 reduced_il# - ypart exact_center,
182                       0.8 reduced_il# + ypart exact_center);
183 enddef;
184
185
186 fet_beginchar ("Ed. Vat. fa clef", "vaticana.fa");
187         if test = 1:
188                 draw_staff (-1, 3, 0.0);
189         fi;
190         draw_vaticana_fa_clef ((0, 0), 1.0);
191 fet_endchar;
192
193
194 fet_beginchar ("Ed. Vat. fa clef", "vaticana.fa_change");
195         draw_vaticana_fa_clef ((0, 0), 1.0); % no reduction
196 fet_endchar;
197
198
199 %%%%%%%%
200 %
201 %
202 %
203 % Editio Medicaea
204 %
205 %
206 %
207 def draw_medicaea_do_clef (expr exact_center, reduction) = 
208         save reduced_il, reduced_slt;
209
210         reduced_il# = staff_space# * reduction;
211         reduced_slt# = linethickness# * reduction;
212
213         define_pixels (reduced_il);
214         define_pixels (reduced_slt);
215
216         set_char_box (0 - xpart exact_center,
217                       1.0 reduced_il# + xpart exact_center,
218                       1.5 reduced_il# - ypart exact_center,
219                       1.5 reduced_il# + ypart exact_center);
220
221         save flag_height;
222
223         flag_height# = 0.5 reduced_il#;
224
225         define_pixels (flag_height);
226
227         save xoffs, yoffs;
228
229         xoffs# = xpart exact_center;
230         yoffs# = ypart exact_center;
231
232         define_pixels (xoffs, yoffs);
233
234         % flags
235         pickup pencircle xscaled reduced_slt
236                          yscaled flag_height;
237
238         save ellipse;
239         path ellipse;
240
241         ellipse := reverse fullcircle xscaled reduced_slt
242                                       yscaled flag_height;
243
244         xoffs = lft x1 = rt x2 - reduced_il;
245         y1 = yoffs + 0.5 (reduced_il - flag_height - staff_space);
246         y2 = y1 - reduced_il + flag_height;
247
248         fill top z1
249              -- get_subpath (ellipse, z2 - z1, z1 - z2, z2)
250              -- bot z1
251              -- cycle;
252
253         xoffs = lft x3 = rt x4 - reduced_il;
254         y3 = yoffs + 0.5 (reduced_il - flag_height + staff_space);
255         y4 = y3 - reduced_il + flag_height;
256
257         fill top z3
258              -- get_subpath (ellipse, z4 - z3, z3 - z4, z4)
259              -- bot z3
260              -- cycle;
261
262         % stem
263         pickup pencircle scaled reduced_slt;
264
265         lft x5 = lft x6 = xoffs;
266         yoffs = top y6 - 1.5 reduced_il = bot y5 + 1.5 reduced_il;
267
268         draw_rounded_block (bot lft z5, top rt z6, reduced_slt);
269
270         labels (1, 2, 3, 4, 5, 6);
271 enddef;
272
273
274 fet_beginchar ("Ed. Med. do clef", "medicaea.do");
275         if test = 1:
276                 draw_staff (-1, 3, 0.0);
277         fi;
278         draw_medicaea_do_clef ((0, 0), 1.0);
279 fet_endchar;
280
281
282 fet_beginchar ("Ed. Med. do clef", "medicaea.do_change");
283         draw_medicaea_do_clef ((0, 0), .8);
284 fet_endchar;
285
286
287 def draw_medicaea_fa_clef (expr exact_center, reduction) = 
288         % inspired by Regensburger Edition of Medicaea (1885/86), in:
289         % MGG, volume 2, col. 1327 ("Choralreform"), fig. 2.
290
291         save reduced_il, reduced_slt;
292
293         reduced_il# = staff_space# * reduction;
294         reduced_slt# = linethickness# * reduction;
295
296         define_pixels (reduced_il);
297         define_pixels (reduced_slt);
298
299         save xoffs, yoffs;
300
301         xoffs# = xpart exact_center;
302         yoffs# = ypart exact_center;
303
304         define_pixels (xoffs, yoffs);
305
306         % stem
307         pickup pencircle scaled linethickness;
308
309         x11 = x12 = xoffs + 0.4 reduced_il;
310         y11 = yoffs = bot y12 + 1.5 reduced_il;
311
312         draw_rounded_block (bot lft z12, top rt z11, linethickness);
313
314         % left-handed punctum
315
316         pickup pencircle xscaled reduced_slt
317                          yscaled reduced_il;
318
319         save ellipse;
320         path ellipse;
321
322         ellipse := reverse fullcircle xscaled reduced_slt
323                                       yscaled reduced_il;
324
325         lft z13 = (xoffs, yoffs);
326         rt z14 = z11 + (linethickness / 2, 0);
327
328         fill get_subpath (ellipse, left, right, z13)
329              -- get_subpath (ellipse, right, left, z14)
330              -- cycle;
331
332         labels (11, 12, 13, 14);
333
334         % right-handed puncta as in do clef
335         draw_medicaea_do_clef (exact_center + (0.7 reduced_il#, 0),
336                                reduction);
337
338         set_char_box (0 - xpart exact_center,
339                       1.7 reduced_il# + xpart exact_center,
340                       1.5 reduced_il# - ypart exact_center,
341                       1.5 reduced_il# + ypart exact_center);
342 enddef;
343
344
345 fet_beginchar ("Ed. Med. fa clef", "medicaea.fa");
346         if test = 1:
347                 draw_staff (-1, 3, 0.0);
348         fi;
349         draw_medicaea_fa_clef ((0, 0), 1.0);
350 fet_endchar;
351
352
353 fet_beginchar ("Ed. Med. fa clef", "medicaea.fa_change");
354         draw_medicaea_fa_clef ((0, 0), .8);
355 fet_endchar;
356
357
358 %%%%%%%%
359 %
360 %
361 %
362 % Mensural Notation
363 %
364 %
365 %
366
367 %
368 % width:        interval from left end to right end
369 % height:       interval from bottom of lower beam to top of upper beam
370 % exact_center: the coordinates of the vertical center point of the
371 %               left edge.
372 %
373 def draw_brevis (expr exact_center, bwidth, bheight, blinethickness) =
374         save brevis_width, brevis_height, linethickness;
375
376         brevis_width# = bwidth;
377         brevis_height# = bheight;
378         linethickness# = blinethickness;
379
380         save beam_width, beam_height;
381         save serif_size, serif_protrude, hole_height;
382
383         beam_width# = 1.4 linethickness#;
384         hole_height# = 3 linethickness#;
385         2 beam_height# + hole_height# = brevis_height#;
386         serif_size# = (hole_height# - linethickness#) / 2;
387         serif_protrude# = 1.5 serif_size#;
388
389         save xoffs, yoffs;
390
391         xoffs# = xpart exact_center;
392         yoffs# = ypart exact_center;
393
394         define_pixels (xoffs, yoffs);
395         define_pixels (brevis_width, brevis_height, linethickness);
396         define_pixels (beam_width, beam_height, serif_size, serif_protrude);
397
398         z1l = (xoffs, yoffs - linethickness);
399         z2r = z1r + serif_size * (1, -1);
400         z3l = z2l + (-serif_size, -serif_protrude);
401
402         penpos1 (beam_width, 0);
403         penpos2 (beam_height, 90);
404         penpos3 (beam_width, 180);
405
406         save pat_in, pat_out;
407         path pat_in, pat_out;
408
409         pat_out := z3r{down}
410                    .. z3l{up}
411                    .. z2l{right};
412         pat_out := pat_out
413                    -- reverse pat_out xscaled -1
414                                       shifted (2 xoffs + brevis_width, 0);
415         pat_out := pat_out
416                    -- reverse pat_out yscaled -1
417                                       shifted (0, 2 yoffs)
418                    -- cycle;
419
420         pat_in := z1r{down}
421                   .. z2r{right};
422         pat_in := pat_in
423                   -- reverse pat_in xscaled -1
424                                     shifted (2 xoffs + brevis_width, 0);
425         pat_in := pat_in
426                   -- reverse pat_in yscaled -1
427                                     shifted (0, 2 yoffs)
428                   -- cycle;
429
430         fill pat_out;
431         unfill pat_in;
432
433         penlabels (1, 2, 3);
434 enddef;
435
436 %
437 % Draw two brevis notes; the second one shifted down by `shift'.
438 % The other parameters are the same as with `draw_brevis'.
439 %
440 def draw_double_brevis (expr exact_center, bwidth, bheight,
441                              blinethickness, shift) =
442         save brevis_width, brevis_height, linethickness;
443
444         brevis_width# = bwidth;
445         brevis_height# = bheight;
446         linethickness# = blinethickness;
447
448         save beam_width, beam_height;
449         save serif_size, serif_protrude, hole_height;
450
451         beam_width# = 1.4 linethickness#;
452         hole_height# = 3 linethickness#;
453         2 beam_height# + hole_height# = brevis_height#;
454         serif_size# = (hole_height# - linethickness#) / 2;
455         serif_protrude# = 1.5 serif_size#;
456
457         save xoffs, yoffs;
458
459         xoffs# = xpart exact_center;
460         yoffs# = ypart exact_center;
461
462         define_pixels (xoffs, yoffs);
463         define_pixels (brevis_width, brevis_height, linethickness);
464         define_pixels (beam_width, beam_height, serif_size, serif_protrude);
465
466         z1l = (xoffs, yoffs - linethickness);
467         z2r = z1r + serif_size * (1, -1);
468         z3l = z2l + (-serif_size, -serif_protrude);
469
470         penpos1 (beam_width, 0);
471         penpos2 (beam_height, 90);
472         penpos3 (beam_width, 180);
473
474         z4 = z1 shifted (0, -shift);
475         z5 = z2 shifted (0, -shift);
476         z6 = z3 shifted (0, -shift);
477         
478         penpos4 (beam_width, 0);
479         penpos5 (beam_height, 90);
480         penpos6 (beam_width, 180);
481
482         save pat_in, pat_out;
483         path pat_in, pat_out;
484
485         pat_out := z6r{down}
486                    .. z6l{up}
487                    .. z5l{right};
488         pat_out := pat_out
489                    -- reverse pat_out xscaled -1
490                                       shifted (2 xoffs + brevis_width, 0);
491         pat_out := pat_out
492                    -- reverse pat_out yscaled -1
493                                       shifted (0, shift - 2 yoffs)
494                    -- cycle;
495
496         fill pat_out;
497
498         pat_in := z1r{down}
499                   .. z2r{right};
500         pat_in := pat_in
501                   -- reverse pat_in xscaled -1
502                                     shifted (2 xoffs + brevis_width, 0);
503         pat_in := pat_in
504                   -- reverse pat_in yscaled -1
505                                     shifted (0, 2 yoffs)
506                   -- cycle;
507
508         unfill pat_in;
509         unfill pat_in shifted (0, -shift);
510
511         penlabels (1, 2, 3, 4, 5, 6);
512 enddef;
513
514
515 %
516 % Draw three brevis notes; the second one shifted down by `shift',
517 % the third one by `2 shift'.
518 % The other parameters are the same as with `draw_brevis'.
519 %
520 def draw_triple_brevis (expr exact_center, bwidth, bheight,
521                              blinethickness, shift) =
522         save brevis_width, brevis_height, linethickness;
523
524         brevis_width# = bwidth;
525         brevis_height# = bheight;
526         linethickness# = blinethickness;
527
528         save beam_width, beam_height;
529         save serif_size, serif_protrude, hole_height;
530
531         beam_width# = 1.4 linethickness#;
532         hole_height# = 3 linethickness#;
533         2 beam_height# + hole_height# = brevis_height#;
534         serif_size# = (hole_height# - linethickness#) / 2;
535         serif_protrude# = 1.5 serif_size#;
536
537         save xoffs, yoffs;
538
539         xoffs# = xpart exact_center;
540         yoffs# = ypart exact_center;
541
542         define_pixels (xoffs, yoffs);
543         define_pixels (brevis_width, brevis_height, linethickness);
544         define_pixels (beam_width, beam_height, serif_size, serif_protrude);
545
546         z1l = (xoffs, yoffs - linethickness);
547         z2r = z1r + serif_size * (1, -1);
548         z3l = z2l + (-serif_size, -serif_protrude);
549
550         penpos1 (beam_width, 0);
551         penpos2 (beam_height, 90);
552         penpos3 (beam_width, 180);
553
554         z7 = z1 shifted (0, -2 shift);
555         z8 = z2 shifted (0, -2 shift);
556         z9 = z3 shifted (0, -2 shift);
557         
558         penpos7 (beam_width, 0);
559         penpos8 (beam_height, 90);
560         penpos9 (beam_width, 180);
561
562         save pat_in, pat_out;
563         path pat_in, pat_out;
564
565         pat_out := z9r{down}
566                    .. z9l{up}
567                    .. z8l{right};
568         pat_out := pat_out
569                    -- reverse pat_out xscaled -1
570                                       shifted (2 xoffs + brevis_width, 0);
571         pat_out := pat_out
572                    -- reverse pat_out yscaled -1
573                                       shifted (0, -2 yoffs)
574                    -- cycle;
575
576         fill pat_out;
577
578         pat_in := z1r{down}
579                   .. z2r{right};
580         pat_in := pat_in
581                   -- reverse pat_in xscaled -1
582                                     shifted (2 xoffs + brevis_width, 0);
583         pat_in := pat_in
584                   -- reverse pat_in yscaled -1
585                                     shifted (0, 2 yoffs)
586                   -- cycle;
587
588         unfill pat_in;
589         unfill pat_in shifted (0, -shift);
590         unfill pat_in shifted (0, -2 shift);
591
592         penlabels (1, 2, 3, 7, 8, 9);
593 enddef;
594
595
596 def draw_neomensural_c_clef (expr exact_center, reduction) = 
597         save reduced_il, reduced_slt, stem_width;
598
599         reduced_il# = staff_space# * reduction;
600         reduced_slt# = linethickness# * reduction;
601         stem_width# = 1.4 reduced_slt#;
602
603         define_pixels (reduced_il, reduced_slt, stem_width);
604
605         set_char_box (0 - xpart exact_center,
606                       2 reduced_il# + 6 reduced_slt# + xpart exact_center,
607                       2 reduced_il# - ypart exact_center,
608                       2 reduced_il# + ypart exact_center);
609
610         draw_brevis (exact_center + (3 reduced_slt#, 0),
611                      2 reduced_il#, reduced_il#, reduced_slt#);
612
613         save xoffs, yoffs;
614
615         xoffs# = xpart exact_center;
616         yoffs# = ypart exact_center;
617
618         define_pixels (xoffs, yoffs);
619
620         pickup pencircle xscaled stem_width
621                          yscaled blot_diameter;
622
623         save ellipse, pat;
624         path ellipse, pat;
625
626         ellipse := fullcircle xscaled stem_width
627                               yscaled blot_diameter;
628
629         lft x11 = lft x12 = xoffs;
630         top y12 - bot y11 = 4 reduced_il;
631         top y12 + bot y11 = 2 yoffs;
632         x13 = x3;
633         y13 = y11;
634         rt x14 = rt x15 = w;
635         y14 = y11;
636         y15 = y12;
637
638         pat := get_subpath (ellipse, down, up, z13)
639                -- z3l
640                -- z3r
641                -- cycle;
642
643         fill get_subpath (ellipse, down, up, z11)
644              -- get_subpath (ellipse, up, down, z12)
645              -- cycle;
646         fill get_subpath (ellipse, down, up, z14)
647              -- get_subpath (ellipse, up, down, z15)
648              -- cycle;
649
650         fill pat;
651         fill pat xscaled -1
652                  shifted (w, 0);
653         fill pat yscaled -1
654                  shifted (0, 2 yoffs);
655         fill pat scaled -1
656                  shifted (w, 2 yoffs);
657
658         labels (11, 12, 13, 14, 15);
659 enddef;
660
661
662 fet_beginchar ("neo-mensural c clef", "neomensural.c");
663         if test = 1:
664                 draw_staff (-1, 3, 0.0);
665         fi;
666         draw_neomensural_c_clef ((0, 0), 1.0);
667 fet_endchar;
668
669
670 fet_beginchar ("neo-mensural c clef", "neomensural.c_change");
671         draw_neomensural_c_clef ((0, 0), .8);
672 fet_endchar;
673
674
675 def draw_petrucci_c_clef (expr exact_center, flare_align, reduction) = 
676         % inspired by Josquin Desprez, "Stabat Mater", Libro tertio,
677         % 1519, printed by Petrucci, in: MGG, volume 7, Table 11.
678         % Also by Petrucci's Canti C, Venedig 1503.  In: MGG, volume
679         % 9, p. 1681/1682.
680
681         save reduced_il, reduced_slt;
682
683         reduced_il# = staff_space# * reduction;
684         reduced_slt# = linethickness# * reduction;
685
686         define_pixels (reduced_il);
687
688         draw_double_brevis (exact_center + (0, 0.5 staff_space#),
689                             reduced_il#, reduced_il#, reduced_slt#,
690                             staff_space);
691
692         save half_reduced_il, left_depth, left_height;
693
694         half_reduced_il# = staff_space# * sqrt (reduction);
695         left_height# = half_reduced_il# * min (3.2, 3.2 + 0.2 + flare_align);
696         left_depth# = half_reduced_il# * min (3.2, 3.2 + 0.2 - flare_align);
697
698         define_pixels (half_reduced_il);
699         define_pixels (left_depth, left_height);
700
701         set_char_box (0 - xpart exact_center,
702                       reduced_il# + xpart exact_center,
703                       left_depth# - ypart exact_center,
704                       left_height# + ypart exact_center);
705
706         save xoffs, yoffs;
707
708         xoffs# = xpart exact_center;
709         yoffs# = ypart exact_center;
710
711         define_pixels (xoffs, yoffs);
712
713         pickup pencircle xscaled 1.4 linethickness
714                          yscaled blot_diameter;
715
716         save ellipse;
717         path ellipse;
718
719         ellipse := fullcircle xscaled 1.4 linethickness
720                               yscaled blot_diameter;
721
722         lft x11 = lft x13 = xoffs;
723         top y11 = yoffs + left_height;
724         bot y13 = yoffs - left_depth;
725         rt x15 = rt x17 = xoffs + brevis_width;
726         y15 = min (y11 - 0.2 half_reduced_il, yoffs + 2.2 half_reduced_il);
727         y17 = max (y13 + 0.2 half_reduced_il, yoffs - 2.2 half_reduced_il);
728
729         z12 = z14 yscaled -1;
730         z14 = z6;
731         z16 = z18 yscaled -1;
732         rt z18 = lft z14 shifted (brevis_width, 0);
733
734         penpos12 (1.4 linethickness, 0);
735         penpos14 (1.4 linethickness, 0);
736         penpos16 (1.4 linethickness, 0);
737         penpos18 (1.4 linethickness, 0);
738
739         if top y11 > -y6 + 0.7 linethickness:
740                 fill get_subpath (ellipse, up, down, z11)
741                      -- z12l
742                      -- z12r
743                      -- cycle;
744         fi;
745         if bot y13 < y6 - 0.7 linethickness:
746                 fill get_subpath (ellipse, down, up, z13)
747                      -- z14r
748                      -- z14l
749                      -- cycle;
750         fi;
751         if top y15 > -y6 + 0.7 linethickness:
752                 fill get_subpath (ellipse, up, down, z15)
753                      -- z16l
754                      -- z16r
755                      -- cycle;
756         fi;
757         if bot y17 < y6 - 0.7 linethickness:
758                 fill get_subpath (ellipse, down, up, z17)
759                      -- z18r
760                      -- z18l
761                      -- cycle;
762         fi;
763
764         labels (11, 13, 15, 17);
765         penlabels (12, 14, 16, 18);
766 enddef;
767
768
769 fet_beginchar ("petrucci c1 clef", "petrucci.c1");
770         if test = 1:
771                 draw_staff (-1, 3, 0.0);
772         fi;
773         draw_petrucci_c_clef ((0, 0), +2, 1.0);
774 fet_endchar;
775
776
777 fet_beginchar ("petrucci c1 clef", "petrucci.c1_change");
778         draw_petrucci_c_clef ((0, 0), +2, .8);
779 fet_endchar;
780
781
782 fet_beginchar ("petrucci c2 clef", "petrucci.c2");
783         if test = 1:
784                 draw_staff (-1, 3, 0.0);
785         fi;
786         draw_petrucci_c_clef ((0, 0), +1, 1.0);
787 fet_endchar;
788
789
790 fet_beginchar ("petrucci c2 clef", "petrucci.c2_change");
791         draw_petrucci_c_clef ((0, 0), +1, .8);
792 fet_endchar;
793
794
795 fet_beginchar ("petrucci c3 clef", "petrucci.c3");
796         if test = 1:
797                 draw_staff (-1, 3, 0.0);
798         fi;
799         draw_petrucci_c_clef ((0, 0), 0, 1.0);
800 fet_endchar;
801
802
803 fet_beginchar ("petrucci c3 clef", "petrucci.c3_change");
804         draw_petrucci_c_clef ((0, 0), 0, .8);
805 fet_endchar;
806
807
808 fet_beginchar ("petrucci c4 clef", "petrucci.c4");
809         if test = 1:
810                 draw_staff (-1, 3, 0.0);
811         fi;
812         draw_petrucci_c_clef ((0, 0), -1, 1.0);
813 fet_endchar;
814
815
816 fet_beginchar ("petrucci c4 clef", "petrucci.c4_change");
817         draw_petrucci_c_clef ((0, 0), -1, .8);
818 fet_endchar;
819
820
821 fet_beginchar ("petrucci c5 clef", "petrucci.c5");
822         if test = 1:
823                 draw_staff (-1, 3, 0.0);
824         fi;
825         draw_petrucci_c_clef ((0, 0), -2, 1.0);
826 fet_endchar;
827
828
829 fet_beginchar ("petrucci c5 clef", "petrucci.c5_change");
830         draw_petrucci_c_clef ((0, 0), -2, .8);
831 fet_endchar;
832
833
834 def draw_mensural_c_clef (expr exact_center, reduction) =
835         % inspired by Ockeghem, "Missa Prolationum", in: MGG, volume
836         % 9, table 94.
837
838         save reduced_il;
839
840         reduced_il# = staff_space# * reduction;
841
842         define_pixels (reduced_il);
843
844         draw_triple_brevis (exact_center + (0, 0.5 staff_space#),
845                             2 reduced_il#, 0.8 staff_space#,
846                             0.8 linethickness#, staff_space);
847
848         save half_reduced_il;
849
850         half_reduced_il# = staff_space# * sqrt (reduction);
851
852         define_pixels (half_reduced_il);
853
854         set_char_box (0 - xpart exact_center,
855                       2 reduced_il# + xpart exact_center,
856                       2.2 half_reduced_il# + staff_space# -
857                         2 ypart exact_center,
858                       2.2 half_reduced_il# + 2 ypart exact_center);
859
860         save xoffs, yoffs;
861
862         xoffs# = xpart exact_center;
863         yoffs# = ypart exact_center;
864
865         define_pixels (xoffs, yoffs);
866
867         pickup pencircle xscaled 1.4 linethickness
868                          yscaled blot_diameter;
869
870         save ellipse;
871         path ellipse;
872
873         ellipse := fullcircle xscaled 1.4 linethickness
874                               yscaled blot_diameter;
875
876         lft x11 = lft x13 = xoffs;
877         top y11 = yoffs + 2.2 half_reduced_il;
878         bot y13 = yoffs - 2.2 half_reduced_il - staff_space;
879         rt x15 = rt x17 = xoffs + brevis_width;
880         y15 = yoffs + 1.4 half_reduced_il;
881         y17 = yoffs - 1.4 half_reduced_il - staff_space;
882
883         z12 = z14 yscaled -1 shifted (0, -staff_space);
884         z14 = z9;
885         z16 = z18 yscaled -1 shifted (0, -staff_space);
886         rt z18 = lft z14 shifted (brevis_width, 0);
887
888         penpos12 (1.4 linethickness, 0);
889         penpos14 (1.4 linethickness, 0);
890         penpos16 (1.4 linethickness, 0);
891         penpos18 (1.4 linethickness, 0);
892
893         fill get_subpath (ellipse, up, down, z11)
894              -- z12l
895              -- z12r
896              -- cycle;
897         fill get_subpath (ellipse, down, up, z13)
898              -- z14r
899              -- z14l
900              -- cycle;
901         fill get_subpath (ellipse, up, down, z15)
902              -- z16l
903              -- z16r
904              -- cycle;
905         fill get_subpath (ellipse, down, up, z17)
906              -- z18r
907              -- z18l
908              -- cycle;
909
910         labels (11, 13, 15, 17);
911         penlabels (12, 14, 16, 18);
912 enddef;
913
914
915 fet_beginchar ("mensural c clef", "mensural.c");
916         if test = 1:
917                 draw_staff (-1, 3, 0.0);
918         fi;
919         draw_mensural_c_clef ((0, 0), 1.0);
920 fet_endchar;
921
922
923 fet_beginchar ("mensural c clef", "mensural.c_change");
924         draw_mensural_c_clef ((0, 0), .8);
925 fet_endchar;
926
927
928 def draw_diamond (expr exact_center, reduction) =
929         save stem_width, reduced_nht, holeheight, beamheight;
930         save rh_height, rh_width;
931
932         stem_width# = 1.4 reduced_slt#;
933         reduced_nht# = noteheight# * reduction;
934         holeheight# = 3 reduced_slt#;
935         beamheight# = 0.4 (reduced_nht# - holeheight#);
936
937         rh_height# = 1.2 staff_space# * reduction;
938         rh_width# / rh_height# = tand (30);
939
940         define_pixels (beamheight, stem_width);
941         define_pixels (rh_height, rh_width);
942
943         save xoffs, yoffs;
944
945         xoffs# = xpart exact_center;
946         yoffs# = ypart exact_center;
947
948         define_pixels (xoffs, yoffs);
949
950         pickup pencircle xscaled beamheight
951                          yscaled stem_width
952                          rotated 45;
953
954         save ellipse;
955         path ellipse;
956
957         ellipse := reverse fullcircle xscaled beamheight
958                                       yscaled stem_width
959                                       rotated 45;
960
961         x21 := xoffs - rh_width / 2;
962         y21 := yoffs;
963         x22 := xoffs;
964         y22 := yoffs + rh_height / 2;
965         x23 := xoffs + rh_width / 2;
966         y23 := yoffs;
967         x24 := xoffs;
968         y24 := yoffs - rh_height / 2;
969
970         fill get_subpath (ellipse, z21 - z24, z22 - z21, z21)
971              -- get_subpath (ellipse, z22 - z21, z23 - z22, z22)
972              -- get_subpath (ellipse, z23 - z22, z24 - z23, z23)
973              -- get_subpath (ellipse, z24 - z23, z21 - z24, z24)
974              -- cycle;
975
976         save l;
977         path l[];
978
979         l2122 := (directionpoint (z21 - z22) of ellipse) shifted z21
980                  -- (directionpoint (z21 - z22) of ellipse) shifted z22;
981         l2223 := (directionpoint (z22 - z23) of ellipse) shifted z22
982                  -- (directionpoint (z22 - z23) of ellipse) shifted z23;
983         l2324 := (directionpoint (z23 - z24) of ellipse) shifted z23
984                  -- (directionpoint (z23 - z24) of ellipse) shifted z24;
985         l2421 := (directionpoint (z24 - z21) of ellipse) shifted z24
986                  -- (directionpoint (z24 - z21) of ellipse) shifted z21;
987
988         unfill l2122 intersectionpoint l2223
989                -- l2223 intersectionpoint l2324
990                -- l2324 intersectionpoint l2421
991                -- l2421 intersectionpoint l2122
992                -- cycle;
993
994         labels (21, 22, 23, 24);
995 enddef;
996
997
998 def draw_petrucci_f_clef (expr exact_center, reduction) =
999         % inspired by L'homme arme super voces musicales in Misse
1000         % Josquin, 1502, Petrucci, in: MGG, volume 7, col. 200; also
1001         % inspired by Gaspar van Weerbeke, "Virgo Maria" (1502), in:
1002         % MGG, volume 9, col. 653 ("Motette"), fig. 3.; also by Andr'e
1003         % Campra, "Entr'ee des s'er'enades" (1710), in: MGG, volume 2,
1004         % col. 1649 ("Contredanse"), fig. 2.
1005
1006         save interline, reduced_il, reduced_slt;
1007
1008         interline# = staff_space#;
1009         reduced_il# = staff_space# * reduction;
1010         reduced_slt# = linethickness# * reduction;
1011
1012         draw_brevis (exact_center, reduced_il#, reduced_il#, reduced_slt#);
1013         draw_diamond (exact_center +
1014                         (1.6 interline# * reduction, interline# / 2),
1015                      reduction);
1016         draw_diamond (exact_center +
1017                         (1.6 interline# * reduction, -interline# / 2),
1018                      reduction);
1019
1020         define_pixels (interline, reduced_il, reduced_slt);
1021
1022         save stem_width;
1023
1024         stem_width# = 1.4 reduced_slt#;
1025
1026         define_pixels (stem_width);
1027
1028         save xoffs, yoffs;
1029
1030         xoffs# = xpart exact_center;
1031         yoffs# = ypart exact_center;
1032
1033         define_pixels (xoffs, yoffs);
1034
1035         % brevis stem
1036         pickup pencircle xscaled stem_width
1037                          yscaled blot_diameter;
1038
1039         save ellipse;
1040         path ellipse;
1041
1042         ellipse := fullcircle xscaled stem_width
1043                               yscaled blot_diameter;
1044
1045         rt z8 = (xoffs + reduced_il, yoffs - 4 reduced_slt);
1046         rt z9 = (xoffs + reduced_il, yoffs - 4 reduced_il);
1047
1048         penpos8 (stem_width, 0);
1049
1050         fill get_subpath (ellipse, down, up, z9)
1051              -- z8r
1052              -- z8l
1053              -- cycle;
1054
1055         % upper diamond's stem
1056         z10 = (xoffs + 1.6 interline * reduction + stem_width / 2,
1057                yoffs + interline * reduction);
1058         top z11 = z10 + (0, 1.5 interline * reduction);
1059
1060         penpos10 (stem_width, 0);
1061
1062         fill get_subpath (ellipse, up, down, z11)
1063              -- z10l
1064              -- z10r
1065              -- cycle;
1066
1067         % lower diamond's stem
1068         z12 = (xoffs + 1.6 interline * reduction - stem_width / 2,
1069                yoffs - interline * reduction);
1070         bot z13 = z12 + (0, -3.5 interline * reduction);
1071
1072         penpos12 (stem_width, 0);
1073
1074         fill get_subpath (ellipse, down, up, z13)
1075              -- z12r
1076              -- z12l
1077              -- cycle;
1078
1079         save reduced_il, rh_height, rh_width;
1080
1081         reduced_il# = staff_space# * reduction;
1082         rh_height# = 1.2 reduced_il#;
1083         rh_width# / rh_height# = tand (30);
1084
1085         set_char_box (0 - xpart exact_center,
1086                       1.6 interline# * reduction + 0.5 rh_width# +
1087                         xpart exact_center,
1088                       4.5 interline# * reduction - ypart exact_center,
1089                       2.5 interline# * reduction + ypart exact_center);
1090
1091         labels (9, 11, 13);
1092         penlabels (8, 10, 12);
1093 enddef;
1094
1095
1096 fet_beginchar ("petrucci f clef", "petrucci.f");
1097         if test = 1:
1098                 draw_staff (-1, 3, 0.0);
1099         fi;
1100         draw_petrucci_f_clef ((0, 0), 1.0);
1101 fet_endchar;
1102
1103
1104 fet_beginchar ("petrucci f clef", "petrucci.f_change");
1105         draw_petrucci_f_clef ((0, 0), .8);
1106 fet_endchar;
1107
1108
1109 def draw_mensural_f_clef (expr exact_center, reduction) =
1110         % inspired by Philippe le Duc, "Dite Signori" (1590), in: MGG,
1111         % volume 3, col. 848 ("Duc"); also by John Dowland, "The First
1112         % Booke of Songes" (1597), in: MGG, volume 3, col. 721
1113         % ("Dowland"), fig. 3.
1114
1115         save width, reduced_slt, stem_width, dot_diameter;
1116
1117         width# = 1.2 staff_space# * reduction;
1118         reduced_slt# = linethickness# * reduction;
1119         stem_width# = 1.4 reduced_slt#;
1120         dot_diameter# = 0.1 reduction * staff_space#;
1121
1122         define_pixels (width, stem_width, staff_space, dot_diameter);
1123
1124         save xoffs, yoffs;
1125
1126         xoffs# = xpart exact_center;
1127         yoffs# = ypart exact_center;
1128
1129         define_pixels (xoffs, yoffs);
1130
1131         pickup pencircle xscaled 0.2 width
1132                          yscaled stem_width
1133                          rotated 45;
1134
1135         save ellipse;
1136         path ellipse;
1137
1138         ellipse := fullcircle xscaled 0.2 width
1139                               yscaled stem_width
1140                               rotated 45;
1141
1142         % half circle
1143         lft z10 = (0, 0);
1144
1145         save pat;
1146         path pat;
1147
1148         pat := halfcircle scaled width
1149                           rotated -90
1150                           shifted (z10 - (xoffs, yoffs));
1151
1152         z5 = point 0 of pat;
1153         z6 = point 1 of pat;
1154         z7 = point 2 of pat;
1155         z8 = point 3 of pat;
1156         z9 = point 4 of pat;
1157
1158         save dirs;
1159         pair dirs[];
1160
1161         dirs5 := direction 0 of pat;
1162         dirs6 := direction 1 of pat;
1163         dirs7 := direction 2 of pat;
1164         dirs8 := direction 3 of pat;
1165         dirs9 := direction 4 of pat;
1166
1167         % we approximate `draw pat'
1168         fill get_subpath (ellipse, -dirs5, dirs5, z5)
1169              .. get_subpoint (ellipse, dirs6, z6)
1170              .. get_subpoint (ellipse, dirs7, z7)
1171              .. get_subpoint (ellipse, dirs8, z8)
1172              .. get_subpath (ellipse, dirs9, -dirs9, z9)
1173              .. get_subpoint (ellipse, -dirs8, z8)
1174              .. get_subpoint (ellipse, -dirs7, z7)
1175              .. get_subpoint (ellipse, -dirs6, z6)
1176              .. cycle;
1177
1178         % upper dot
1179         rt x2 = xoffs + width;
1180         top y1 = yoffs + 0.5 width;
1181         z2 - z1 = (dot_diameter, -dot_diameter);
1182
1183         fill get_subpath (ellipse, z1 - z2, z2 - z1, z1)
1184              -- get_subpath (ellipse, z2 - z1, z1 - z2, z2)
1185              -- cycle;
1186
1187         % lower dot
1188         x3 = x1;
1189         top y1 - bot y4 = width;
1190         z4 - z3 = (dot_diameter, -dot_diameter);
1191
1192         fill get_subpath (ellipse, z3 - z4, z4 - z3, z3)
1193              -- get_subpath (ellipse, z4 - z3, z3 - z4, z4)
1194              -- cycle;
1195
1196         set_char_box (0 - xpart exact_center,
1197                       width# + xpart exact_center,
1198                       0.5 width# - ypart exact_center,
1199                       0.5 width# + ypart exact_center);
1200
1201         labels (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
1202 enddef;
1203
1204
1205 fet_beginchar ("mensural f clef", "mensural.f");
1206         if test = 1:
1207                 draw_staff (-1, 3, 0.0);
1208         fi;
1209         draw_mensural_f_clef ((0, 0), 1.0);
1210 fet_endchar;
1211
1212
1213 fet_beginchar ("mensural f clef", "mensural.f_change");
1214         draw_mensural_f_clef ((0, 0), .8);
1215 fet_endchar;
1216
1217
1218 def draw_petrucci_g_clef (expr exact_center, reduction) =
1219         % inspired by Josquin Desprez, "Stabat Mater", Libro tertio,
1220         % 1519, printed by Petrucci, in: MGG, volume 7, Table 11.
1221
1222         save reduced_il, reduced_slt;
1223
1224         reduced_il# = staff_space# * reduction;
1225         reduced_slt# = linethickness# * reduction;
1226         define_pixels (reduced_il, reduced_slt);
1227
1228         set_char_box (0 - xpart exact_center,
1229                       1.25 reduced_il# + xpart exact_center,
1230                       0.65 reduced_il# - ypart exact_center,
1231                       3.80 reduced_il# + ypart exact_center);
1232
1233         save xoffs, yoffs;
1234
1235         xoffs# = xpart exact_center;
1236         yoffs# = ypart exact_center;
1237
1238         define_pixels (xoffs, yoffs);
1239
1240         pickup pencircle xscaled 0.50 reduced_slt
1241                          yscaled 0.22 reduced_il
1242                          rotated -35;
1243
1244         save ellipse, paths, sub_path, outlines, sub_outlines;
1245         path ellipse, paths[], sub_path, outlines[], sub_outlines[];
1246
1247         ellipse := fullcircle xscaled 0.5 reduced_slt
1248                               yscaled 0.22 reduced_il
1249                               rotated -35;
1250
1251         lft z1 = (xoffs + 0.80 reduced_il, yoffs + 0.00 reduced_il);
1252         lft z2 = (xoffs + 1.00 reduced_il, yoffs + 1.20 reduced_il);
1253         lft z3 = (xoffs + 0.70 reduced_il, yoffs + 2.00 reduced_il);
1254         lft z4 = (xoffs + 0.30 reduced_il, yoffs + 3.00 reduced_il);
1255         lft z5 = (xoffs + 0.80 reduced_il, yoffs + 3.70 reduced_il);
1256         lft z6 = (xoffs + 1.00 reduced_il, yoffs + 3.00 reduced_il);
1257         lft z7 = (xoffs + 0.60 reduced_il, yoffs + 2.00 reduced_il);
1258         lft z8 = (xoffs + 0.30 reduced_il, yoffs + 1.70 reduced_il);
1259         lft z9 = (xoffs + 0.00 reduced_il, yoffs + 0.75 reduced_il);
1260         lft z10 = (xoffs + 0.20 reduced_il, yoffs + 0.60 reduced_il);
1261
1262         paths1 := z1{-1, 2}
1263                   .. z2
1264                   .. z3
1265                   .. z4
1266                   .. z5
1267                   .. z6
1268                   .. z7
1269                   .. z8
1270                   .. z9
1271                   .. z10;
1272
1273         save dirs, s;
1274         pair dirs[];
1275
1276         s := 1/4;
1277
1278         % we approximate `draw paths1'
1279         for i = 1 step s until (length paths1 + 1):
1280                 dirs[i] := direction (i - 1) of paths1;
1281         endfor;
1282
1283         outlines1 := get_subpath (ellipse, -dirs1, dirs1, z1)
1284                      for i = (1 + s) step s until (length paths1 + 1 - s):
1285                              .. get_subpoint (ellipse, dirs[i],
1286                                               point (i - 1) of paths1)
1287                      endfor
1288                      .. get_subpath (ellipse, dirs10, -dirs10, z10)
1289                      for i = (length paths1 + 1 - s) step -s until (1 + s):
1290                              .. get_subpoint (ellipse, -dirs[i],
1291                                               point (i - 1) of paths1)
1292                      endfor
1293                      .. cycle;
1294
1295         save len;
1296
1297         len := length outlines1;
1298
1299         sub_outlines1 := subpath (0,
1300                                   floor (1/4 len)) of outlines1;
1301         sub_outlines2 := subpath (floor (1/4 len),
1302                                   floor (2/4 len)) of outlines1;
1303         sub_outlines3 := subpath (floor (2/4 len),
1304                                   floor (3/4 len)) of outlines1;
1305         sub_outlines4 := subpath (floor (3/4 len),
1306                                   len) of outlines1;
1307
1308         save times;
1309         numeric times[];
1310
1311         (times12, times21) = sub_outlines1 intersectiontimes sub_outlines2;
1312         (times13, times31) = sub_outlines1 intersectiontimes sub_outlines3;
1313         (times42, times24) = sub_outlines4 intersectiontimes sub_outlines2;
1314         (times43, times34) = sub_outlines4 intersectiontimes sub_outlines3;
1315
1316         pickup pencircle xscaled 0.75 reduced_slt
1317                          yscaled 0.33 reduced_il
1318                          rotated -35;
1319
1320         ellipse := fullcircle xscaled 0.75 reduced_slt
1321                               yscaled 0.33 reduced_il
1322                               rotated -35;
1323
1324         lft z21 = (xoffs + 1.05 reduced_il, yoffs + 0.45 reduced_il);
1325         lft z22 = (xoffs + 0.55 reduced_il, yoffs + 0.45 reduced_il);
1326         lft z23 = (xoffs + 0.55 reduced_il, yoffs - 0.45 reduced_il);
1327         lft z24 = (xoffs + 1.05 reduced_il, yoffs - 0.45 reduced_il);
1328         lft z25 = (xoffs + 1.10 reduced_il, yoffs + 0.00 reduced_il);
1329         lft z26 = (xoffs + 0.80 reduced_il, yoffs + 0.00 reduced_il);
1330
1331         paths2 := z21
1332                   .. z22
1333                   .. z23
1334                   .. z24
1335                   .. {up}z25
1336                   -- z26;
1337
1338         sub_path := subpath (0, 1) of paths2;
1339
1340         times1 = xpart (sub_outlines1 intersectiontimes sub_path);
1341         times4 = xpart (sub_outlines4 intersectiontimes sub_path);
1342
1343         % we have to find the envelope intersections (if any)
1344         save t;
1345         numeric t[];
1346
1347         t1 = find_envelope_cusp (reverse ellipse,
1348                                  subpath (1, 2) of paths2,
1349                                  1/256) + 1;
1350         if t1 < 1:
1351                 t1 := 1;
1352                 t2 := 1;
1353         else:
1354                 t2 = find_envelope_cusp (ellipse,
1355                                          subpath (3, 4) of reverse paths2,
1356                                          1/256) + 3;
1357                 t2 := length paths2 - t2;
1358         fi;
1359
1360         t3 = find_envelope_cusp (reverse ellipse,
1361                                  subpath (2, 4 - epsilon) of paths2,
1362                                  1/256) + 2;
1363         if t3 < 2:
1364                 t3 := 3;
1365                 t4 := 3;
1366         else:
1367                 t4 = find_envelope_cusp (ellipse,
1368                                          subpath (1 + epsilon, 3)
1369                                            of reverse paths2,
1370                                          1/256) + 1;
1371                 t4 := length paths2 - t4;
1372         fi;
1373
1374         fill subpath (times1 + s / 4, times13) of sub_outlines1
1375              -- subpath (times31, infinity) of sub_outlines3
1376              & subpath (0, times42) of sub_outlines4
1377              -- subpath (times24, infinity) of sub_outlines2
1378              & subpath (0, times34) of sub_outlines3
1379              -- subpath (times43, times4 - s / 4) of sub_outlines4
1380              -- cycle;
1381         unfill subpath (times12, infinity) of sub_outlines1
1382                & subpath (0, times21) of sub_outlines2
1383                -- cycle;
1384         fill subpath (times4 + s / 4, infinity) of sub_outlines4
1385              & subpath (0, times1 - s / 4) of sub_outlines1
1386              -- cycle;
1387
1388         % we approximate `draw paths2'
1389         for i = 1 step s until (length paths2 - s):
1390                 dirs[i + 20] := direction (i - 1) of paths2;
1391         endfor;
1392
1393         fill get_subpath (ellipse, -dirs21, dirs21, z21)
1394              for i = (1 + s) step s until (length paths2 - s):
1395                      .. get_subpoint (ellipse, dirs[i + 20],
1396                                       point (i - 1) of paths2)
1397              endfor
1398              .. get_subpath (ellipse, up, z26 - z25, z25)
1399              -- get_subpath (ellipse, z26 - z25, z25 - z26, z26)
1400              -- get_subpoint (ellipse, z25 - z26, z25)
1401              -- get_subpoint (ellipse, down, z25)
1402              for i = (length paths2 - s) step -s until (t4 + 1):
1403                      .. get_subpoint (ellipse, -dirs[i + 20],
1404                                       point (i - 1) of paths2)
1405              endfor
1406              .. get_subpoint (ellipse, -direction t4 of paths2,
1407                               point t4 of paths2)
1408              -- get_subpoint (ellipse, -direction t3 of paths2,
1409                               point t3 of paths2)
1410              for i = (floor (t3 / s) * s + 1) step -s until (t2 + 1):
1411                      .. get_subpoint (ellipse, -dirs[i + 20],
1412                                       point (i - 1) of paths2)
1413              endfor
1414              .. get_subpoint (ellipse, -direction t2 of paths2,
1415                               point t2 of paths2)
1416              -- get_subpoint (ellipse, -direction t1 of paths2,
1417                               point t1 of paths2)
1418              for i = (floor (t1 / s) * s + 1) step -s until (1 + s):
1419                      .. get_subpoint (ellipse, -dirs[i + 20],
1420                                       point (i - 1) of paths2)
1421              endfor
1422              .. cycle;
1423
1424         labels (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
1425         labels (21, 22, 23, 24, 25, 26);
1426 enddef;
1427
1428
1429 fet_beginchar ("petrucci g clef", "petrucci.g");
1430         if test = 1:
1431                 draw_staff (-1, 3, 0.0);
1432         fi;
1433         draw_petrucci_g_clef ((0, 0), 1.0);
1434 fet_endchar;
1435
1436
1437 fet_beginchar ("petrucci g clef", "petrucci.g_change");
1438         draw_petrucci_g_clef ((0, 0), .8);
1439 fet_endchar;
1440
1441
1442 def draw_mensural_g_clef (expr exact_center, reduction) =
1443   % TODO: Rewrite me.  The former mensural g clef looked ugly, and the
1444   % code was removed when it broke for small font sizes after some
1445   % global changes in the font.  Currently, the character is mapped to
1446   % a copy of the petrucci g clef (which, after all, *is* a mensural g
1447   % clef, but not the one that we have in mind here). -- jr
1448   %
1449   % Possible sources of inspiration for this clef include: Francisco
1450   % Guerrero, "Lib. 1.  Missarum" (1566), in: MGG, volume 3, col. 858
1451   % ("Ducis"); Stefano Fabri, "Quam speciosa veteranis" (1611), in:
1452   % MGG, volume 3, col. 1698 ("Fabri"); Philippus Dulichius,
1453   % "Fasciculus novus ..."  (1598), in: MGG, volume 3, col. 919
1454   % ("Dulichius"), fig. 1; Noe Faignient, "Ic sal de Heer myn God
1455   % gebenedye" (1568), in: MGG, volume 3, col. 1735 ("Faignient").
1456 enddef;
1457
1458
1459 %
1460 % FIXME: This clef is preliminarily mapped to the petrucci g clef
1461 % until the code for the mensural g clef will be rewritten.
1462 %
1463 fet_beginchar ("mensural g clef", "mensural.g");
1464         if test = 1:
1465                 draw_staff (-1, 3, 0.0);
1466         fi;
1467         draw_petrucci_g_clef ((0, 0), 1.0);
1468 fet_endchar;
1469
1470
1471 fet_beginchar ("mensural g clef", "mensural.g_change");
1472         draw_petrucci_g_clef ((0, 0), .8);
1473 fet_endchar;
1474
1475
1476
1477 %%%%%%%%
1478 %
1479 %
1480 %
1481 % Hufnagel
1482 %
1483 %
1484 %
1485 def draw_hufnagel_do_clef (expr exact_center, reduction) =
1486         % inspired by Graduale of Friedrich Zollner (1442), in: MGG,
1487         % volume 9, col. 1413 ("Neustift"), fig. 1.
1488
1489         save reduced_il;
1490
1491         reduced_il# = staff_space# * reduction;
1492
1493         define_pixels (reduced_il);
1494
1495         set_char_box (0 - xpart exact_center,
1496                       1.10 reduced_il# + xpart exact_center,
1497                       0.70 reduced_il# - ypart exact_center,
1498                       0.75 reduced_il# + ypart exact_center);
1499
1500         save xoffs, yoffs;
1501
1502         xoffs# = xpart exact_center;
1503         yoffs# = ypart exact_center;
1504
1505         define_pixels (xoffs, yoffs);
1506
1507         pickup pencircle xscaled (0.60 reduced_il)
1508                          yscaled (0.10 reduced_il)
1509                          rotated 40;
1510
1511         save ellipse, pat;
1512         path ellipse, pat;
1513
1514         ellipse := fullcircle xscaled (0.60 reduced_il)
1515                               yscaled (0.10 reduced_il)
1516                               rotated 40;
1517
1518         z1 = (xoffs + 0.90 reduced_il, yoffs + .45 reduced_il);
1519         z2 = (xoffs + 0.80 reduced_il, yoffs + .45 reduced_il);
1520         z3 = (xoffs + 0.50 reduced_il, yoffs + .60 reduced_il);
1521         z4 = (xoffs + 0.20 reduced_il, yoffs + .45 reduced_il);
1522         z5 = (xoffs + 0.20 reduced_il, yoffs - .45 reduced_il);
1523         z6 = (xoffs + 0.40 reduced_il, yoffs - .55 reduced_il);
1524
1525         pat := z1
1526                .. z2
1527                .. z3
1528                -- z4
1529                -- z5
1530                -- z6;
1531
1532         fill get_subpath (ellipse,
1533                           -direction 0 of pat, direction 0 of pat, z1)
1534              .. get_subpoint (ellipse, direction 1 of pat, z2)
1535              .. get_subpath (ellipse,
1536                              direction (2 - epsilon) of pat, z4 - z3, z3)
1537              -- get_subpath (ellipse,
1538                              z4 - z3, z5 - z4, z4)
1539              -- get_subpath (ellipse,
1540                              z5 - z4, z6 - z5, z5)
1541              -- get_subpath (ellipse,
1542                              z6 - z5, z5 - z6, z6)
1543              -- get_subpoint (ellipse, z5 - z6, z5)
1544              -- get_subpoint (ellipse, z4 - z5, z5)
1545              -- get_subpoint (ellipse, z4 - z5, z4)
1546              -- get_subpoint (ellipse, -direction (2 - epsilon) of pat, z3)
1547              .. get_subpath (ellipse,
1548                              -direction 1 of pat, -direction 1 of pat, z2)
1549              .. cycle;
1550
1551         labels (1, 2, 3, 4, 5, 6);
1552 enddef;
1553
1554
1555 fet_beginchar ("Hufnagel do clef", "hufnagel.do");
1556         if test = 1:
1557                 draw_staff (-1, 3, 0.0);
1558         fi;
1559         draw_hufnagel_do_clef ((0, 0), 1.0);
1560 fet_endchar;
1561
1562
1563 fet_beginchar ("Hufnagel do clef", "hufnagel.do_change");
1564         draw_hufnagel_do_clef ((0, 0), .8);
1565 fet_endchar;
1566
1567
1568 def draw_hufnagel_fa_clef (expr exact_center, reduction) =
1569         % inspired by Bamberger Manuscript (15th century), in:
1570         % MGG, volume 2, table 59.
1571
1572         save reduced_il;
1573
1574         reduced_il# = staff_space# * reduction;
1575
1576         define_pixels (reduced_il);
1577
1578         set_char_box (0 - xpart exact_center,
1579                       1.20 reduced_il# + xpart exact_center,
1580                       1.15 reduced_il# - ypart exact_center,
1581                       1.00 reduced_il# + ypart exact_center);
1582
1583         pickup pencircle xscaled (0.60 reduced_il)
1584                          yscaled (0.10 reduced_il)
1585                          rotated 40;
1586
1587         save xoffs, yoffs;
1588
1589         xoffs# = xpart exact_center;
1590         yoffs# = ypart exact_center;
1591
1592         define_pixels (xoffs, yoffs);
1593
1594         save ellipse, pat;
1595         path ellipse, pat;
1596
1597         ellipse := fullcircle xscaled (0.60 reduced_il)
1598                               yscaled (0.10 reduced_il)
1599                               rotated 40;
1600
1601         z11 = (xoffs + 0.90 reduced_il, yoffs + 0.70 reduced_il);
1602         z12 = (xoffs + 0.80 reduced_il, yoffs + 0.70 reduced_il);
1603         z13 = (xoffs + 0.50 reduced_il, yoffs + 0.85 reduced_il);
1604         z14 = (xoffs + 0.20 reduced_il, yoffs + 0.70 reduced_il);
1605         z15 = (xoffs + 0.20 reduced_il, yoffs - 1.10 reduced_il);
1606
1607         pat := z11
1608                .. z12
1609                .. z13
1610                -- z14
1611                -- z15;
1612
1613         fill get_subpath (ellipse,
1614                           -direction 0 of pat, direction 0 of pat, z11)
1615              .. get_subpoint (ellipse, direction 1 of pat, z12)
1616              .. get_subpath (ellipse,
1617                              direction (2 - epsilon) of pat, z14 - z13, z13)
1618              -- get_subpath (ellipse,
1619                              z14 - z13, z15 - z14, z14)
1620              -- get_subpath (ellipse,
1621                              z15 - z14, z14 - z15, z15)
1622              -- get_subpoint (ellipse, z14 - z15, z14)
1623              -- get_subpoint (ellipse, -direction (2 - epsilon) of pat, z13)
1624              .. get_subpath (ellipse,
1625                              -direction 1 of pat, -direction 1 of pat, z12)
1626              .. cycle;
1627
1628         z16 = (xoffs + 0.90 reduced_il, yoffs - 0.05 reduced_il);
1629         z17 = (xoffs + 0.80 reduced_il, yoffs - 0.05 reduced_il);
1630         z18 = (xoffs + 0.50 reduced_il, yoffs + 0.10 reduced_il);
1631         z19 = (xoffs + 0.20 reduced_il, yoffs - 0.05 reduced_il);
1632
1633         pat := z16
1634                .. z17
1635                .. z18
1636                -- z19;
1637
1638         fill get_subpath (ellipse,
1639                           -direction 0 of pat, direction 0 of pat, z16)
1640              .. get_subpoint (ellipse, direction 1 of pat, z17)
1641              .. get_subpath (ellipse,
1642                              direction (2 - epsilon) of pat, z19 - z18, z18)
1643              -- get_subpoint (ellipse, z19 - z18, z19)
1644              -- get_subpoint (ellipse, -direction (2 - epsilon) of pat, z18)
1645              .. get_subpoint (ellipse, -direction 1 of pat, z17)
1646              .. cycle;
1647
1648         labels (11, 12, 13, 14, 15, 16, 17, 18, 19);
1649 enddef;
1650
1651
1652 fet_beginchar ("Hufnagel fa clef", "hufnagel.fa");
1653         if test = 1:
1654                 draw_staff (-1, 3, 0.0);
1655         fi;
1656         draw_hufnagel_fa_clef ((0, 0), 1.0);
1657 fet_endchar;
1658
1659
1660 fet_beginchar ("Hufnagel fa clef", "hufnagel.fa_change");
1661         draw_hufnagel_fa_clef ((0, 0), .8);
1662 fet_endchar;
1663
1664
1665 def draw_hufnagel_do_fa_clef (expr exact_center, reduction) =
1666         draw_hufnagel_do_clef (exact_center, reduction);
1667         draw_hufnagel_fa_clef (exact_center + (0, -2 staff_space#), reduction);
1668
1669         set_char_box (0 - xpart exact_center,
1670                       1.20 reduced_il# + xpart exact_center,
1671                       1.15 reduced_il# + 2 staff_space# - ypart exact_center,
1672                       0.75 reduced_il# + ypart exact_center);
1673 enddef;
1674
1675
1676 fet_beginchar ("Hufnagel do/fa clef", "hufnagel.do.fa");
1677         if test = 1:
1678                 draw_staff (-1, 3, 0.0);
1679         fi;
1680         draw_hufnagel_do_fa_clef ((0, 0), 1.0);
1681 fet_endchar;
1682
1683
1684 fet_beginchar ("Hufnagel do/fa clef", "hufnagel.do.fa_change");
1685         draw_hufnagel_do_fa_clef ((0, 0), .8);
1686 fet_endchar;
1687
1688
1689 fet_endgroup ("clefs");