Fixes Issue 1504, allowing feather beam line breaking.
[lilypond/patrick.git] / mf / parmesan-clefs.mf
blob2f605f736adfe3cf11d1f44346b99a620affafbe
1 % Feta (not the Font-En-Tja) music font --  ancient clefs
2 % This file is part of LilyPond, the GNU music typesetter.
4 % Copyright (C) 2001--2011 Juergen Reuter <reuter@ipd.uka.de>
7 % LilyPond is free software: you can redistribute it and/or modify
8 % it under the terms of the GNU General Public License as published by
9 % the Free Software Foundation, either version 3 of the License, or
10 % (at your option) any later version.
12 % LilyPond is distributed in the hope that it will be useful,
13 % but WITHOUT ANY WARRANTY; without even the implied warranty of
14 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 % GNU General Public License for more details.
17 % You should have received a copy of the GNU General Public License
18 % along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
20 fet_begingroup ("clefs");
23 % character aligment:
25 %   Each clef is associated with a particular pitch: the treble clef
26 %   with the `g', the alto clef with the `c', the bass clef with the
27 %   `f', etc.  The shape of each clef character defines a vertical
28 %   position that is assumed to represent this pitch.  For the treble
29 %   clef, it is the vertical position of the center of the spiral
30 %   ending that represents the `g' pitch.  For the bass clef, it is
31 %   the center between the two fat dots that define the vertical
32 %   position of the `f' pitch.  For the alto clef, it is the vertical
33 %   center of the clef that is aligned with the `c' pitch.  For each
34 %   clef character, this center should be vertically aligned with the
35 %   point (0, 0).  The horizontal alignment of each clef character
36 %   should be such that the vertical line through the point (0, 0)
37 %   touches the left-most edge of the clef.
39 %   TODO: document exact_center
41 % set_char_box() conventions:
43 % * breapth: Ignored (as far as I know).  Should be set to 0.
45 % * width: Should match the clef's width.
47 % * depth: Should match the bottom edge of the clef.  Affects vertical
48 %   collision handling.
50 % * height: Should match the top edge of the clef.  Affects vertical
51 %   collision handling.
55 %%%%%%%%
59 % Editio Vaticana
63 def draw_vaticana_do_clef (expr exact_center, reduction) = 
64         save reduced_il;
66         reduced_il# = staff_space# * reduction;
68         set_char_box (0 - xpart exact_center,
69                       0.5 reduced_il# + xpart exact_center,
70                       0.8 reduced_il# - ypart exact_center,
71                       0.8 reduced_il# + ypart exact_center);
73         define_pixels (reduced_il);
75         save pat, ellipse, clef, T;
76         path pat, ellipse, clef;
77         transform T;
79         T := identity xscaled 0.6 linethickness
80                       yscaled 0.6 reduced_il;
81         pickup pencircle transformed T;
82         ellipse := reverse fullcircle transformed T;
84         save xoffs, yoffs;
86         xoffs# = xpart exact_center;
87         yoffs# = ypart exact_center;
89         define_pixels (xoffs, yoffs);
91         rt z11 = (xoffs + 0.50 reduced_il, yoffs - .45 reduced_il);
92         z12 = (xoffs + 0.25 reduced_il, yoffs - .50 reduced_il);
93         lft z13 = (xoffs + 0.00 reduced_il, yoffs - .28 reduced_il);
94         lft z14 = (xoffs, yoffs);
96         pat := z11
97                .. z12
98                .. z13
99                -- z14;
101         save shift;
102         pair shift;
104         % adjust vertically to fit into bounding box
105         shift = find_tangent_shift (((0, -d + 0.3 reduced_il)
106                                      -- (w, -d + 0.3 reduced_il)), pat,
107                                     (0, -d / 2), (0, d / 2));
108         pat := pat shifted shift;
110         clef := rt z14{down}
111                 .. top (point 1 of pat)
112                 .. get_subpath (ellipse,
113                                 -direction 0 of pat, direction 0 of pat,
114                                 point 0 of pat)
115                 .. bot (point 1 of pat)
116                 .. get_subpath (ellipse,
117                                 direction 2 of pat, up,
118                                 point 2 of pat);
120         fill clef
121              -- reverse clef yscaled -1
122              -- cycle;
124         labels (11, 12, 13, 14);
125 enddef;
128 fet_beginchar ("Ed. Vat. do clef", "vaticana.do");
129         if test = 1:
130                 draw_staff (-1, 3, 0.0);
131         fi;
132         draw_vaticana_do_clef ((0, 0), 1.0);
133 fet_endchar;
136 fet_beginchar ("Ed. Vat. do clef", "vaticana.do_change");
137         draw_vaticana_do_clef ((0, 0), 1.0); % no reduction
138 fet_endchar;
141 def draw_vaticana_fa_clef (expr exact_center, reduction) = 
142         save reduced_il, xoffs, yoffs;
144         reduced_il# = staff_space# * reduction;
145         xoffs# = xpart exact_center;
146         yoffs# = ypart exact_center;
148         define_pixels (reduced_il, xoffs, yoffs);
150         % left-handed punctum
151         save ellipse, pat, T;
152         path ellipse, pat;
153         transform T;
155         T := identity xscaled 0.6 linethickness
156                       yscaled 0.5 reduced_il;
157         pickup pencircle transformed T;
158         ellipse := reverse fullcircle transformed T;
160         lft z21 = (xoffs + 0.00 reduced_il, yoffs + 0.00 reduced_il);
161         z22 = (xoffs + 0.25 reduced_il, yoffs + 0.05 reduced_il);
162         rt z23 = (xoffs + 0.50 reduced_il, yoffs - 0.05 reduced_il);
164         pat := z21
165                .. z22
166                .. z23;  
168         fill get_subpath (ellipse,
169                           -direction 0 of pat, direction 0 of pat, z21)
170              .. top z22
171              .. get_subpath (ellipse,
172                              direction 2 of pat, -direction 2 of pat, z23)
173              .. bot z22
174              .. cycle;
176         % stem
177         pickup pencircle scaled 0.6 linethickness;
179         x23 = x24;
180         yoffs = bot y24 + 1.5 reduced_il;
182         draw_rounded_block (bot lft z24, top rt z23, 0.6 linethickness);
184         labels (21, 22, 23, 24);
186         % right-handed puncta as in do clef
187         draw_vaticana_do_clef (exact_center + (0.55 reduced_il#, 0),
188                                reduction);
190         set_char_box (0 - xpart exact_center,
191                       1.05 reduced_il# + xpart exact_center,
192                       1.5 reduced_il# - ypart exact_center,
193                       0.8 reduced_il# + ypart exact_center);
194 enddef;
197 fet_beginchar ("Ed. Vat. fa clef", "vaticana.fa");
198         if test = 1:
199                 draw_staff (-1, 3, 0.0);
200         fi;
201         draw_vaticana_fa_clef ((0, 0), 1.0);
202 fet_endchar;
205 fet_beginchar ("Ed. Vat. fa clef", "vaticana.fa_change");
206         draw_vaticana_fa_clef ((0, 0), 1.0); % no reduction
207 fet_endchar;
210 %%%%%%%%
214 % Editio Medicaea
218 def draw_medicaea_do_clef (expr exact_center, reduction) = 
219         save reduced_il, reduced_slt;
221         reduced_il# = staff_space# * reduction;
222         reduced_slt# = linethickness# * reduction;
224         define_pixels (reduced_il);
225         define_pixels (reduced_slt);
227         set_char_box (0 - xpart exact_center,
228                       1.0 reduced_il# + xpart exact_center,
229                       1.5 reduced_il# - ypart exact_center,
230                       1.5 reduced_il# + ypart exact_center);
232         save flag_height;
234         flag_height# = 0.5 reduced_il#;
236         define_pixels (flag_height);
238         save xoffs, yoffs;
240         xoffs# = xpart exact_center;
241         yoffs# = ypart exact_center;
243         define_pixels (xoffs, yoffs);
245         % flags
246         save ellipse, T;
247         path ellipse;
248         transform T;
250         T := identity xscaled reduced_slt
251                       yscaled flag_height;
252         pickup pencircle transformed T;
253         ellipse := reverse fullcircle transformed T;
255         xoffs = lft x1 = rt x2 - reduced_il;
256         y1 = yoffs + 0.5 (reduced_il - flag_height - staff_space);
257         y2 = y1 - reduced_il + flag_height;
259         fill top z1
260              -- get_subpath (ellipse, z2 - z1, z1 - z2, z2)
261              -- bot z1
262              -- cycle;
264         xoffs = lft x3 = rt x4 - reduced_il;
265         y3 = yoffs + 0.5 (reduced_il - flag_height + staff_space);
266         y4 = y3 - reduced_il + flag_height;
268         fill top z3
269              -- get_subpath (ellipse, z4 - z3, z3 - z4, z4)
270              -- bot z3
271              -- cycle;
273         % stem
274         pickup pencircle scaled reduced_slt;
276         lft x5 = lft x6 = xoffs;
277         yoffs = top y6 - 1.5 reduced_il = bot y5 + 1.5 reduced_il;
279         draw_rounded_block (bot lft z5, top rt z6, reduced_slt);
281         labels (1, 2, 3, 4, 5, 6);
282 enddef;
285 fet_beginchar ("Ed. Med. do clef", "medicaea.do");
286         if test = 1:
287                 draw_staff (-1, 3, 0.0);
288         fi;
289         draw_medicaea_do_clef ((0, 0), 1.0);
290 fet_endchar;
293 fet_beginchar ("Ed. Med. do clef", "medicaea.do_change");
294         draw_medicaea_do_clef ((0, 0), .8);
295 fet_endchar;
298 def draw_medicaea_fa_clef (expr exact_center, reduction) = 
299         % inspired by Regensburger Edition of Medicaea (1885/86), in:
300         % MGG, volume 2, col. 1327 ("Choralreform"), fig. 2.
302         save reduced_il, reduced_slt;
304         reduced_il# = staff_space# * reduction;
305         reduced_slt# = linethickness# * reduction;
307         define_pixels (reduced_il);
308         define_pixels (reduced_slt);
310         save xoffs, yoffs;
312         xoffs# = xpart exact_center;
313         yoffs# = ypart exact_center;
315         define_pixels (xoffs, yoffs);
317         % stem
318         pickup pencircle scaled reduced_slt;
320         x11 = x12 = xoffs + 0.4 reduced_il;
321         y11 = yoffs = bot y12 + 1.5 reduced_il;
323         draw_rounded_block (bot lft z12, top rt z11, reduced_slt);
325         % left-handed punctum
326         save ellipse, T;
327         path ellipse;
328         transform T;
330         T := identity xscaled reduced_slt
331                       yscaled reduced_il;
332         pickup pencircle transformed T;
333         ellipse := reverse fullcircle transformed T;
335         lft z13 = (xoffs, yoffs);
336         rt z14 = z11 + (reduced_slt / 2, 0);
338         fill get_subpath (ellipse, left, right, z13)
339              -- get_subpath (ellipse, right, left, z14)
340              -- cycle;
342         labels (11, 12, 13, 14);
344         % right-handed puncta as in do clef
345         draw_medicaea_do_clef (exact_center + (0.7 reduced_il#, 0),
346                                reduction);
348         set_char_box (0 - xpart exact_center,
349                       1.7 reduced_il# + xpart exact_center,
350                       1.5 reduced_il# - ypart exact_center,
351                       1.5 reduced_il# + ypart exact_center);
352 enddef;
355 fet_beginchar ("Ed. Med. fa clef", "medicaea.fa");
356         if test = 1:
357                 draw_staff (-1, 3, 0.0);
358         fi;
359         draw_medicaea_fa_clef ((0, 0), 1.0);
360 fet_endchar;
363 fet_beginchar ("Ed. Med. fa clef", "medicaea.fa_change");
364         draw_medicaea_fa_clef ((0, 0), .8);
365 fet_endchar;
368 %%%%%%%%
372 % Mensural Notation
378 % width:        interval from left end to right end
379 % height:       interval from bottom of lower beam to top of upper beam
380 % exact_center: the coordinates of the vertical center point of the
381 %               left edge.
383 def draw_brevis (expr exact_center, bwidth, bheight, blinethickness) =
384         save brevis_width, brevis_height, linethickness;
386         brevis_width# = bwidth;
387         brevis_height# = bheight;
388         linethickness# = blinethickness;
390         save beam_width, beam_height;
391         save serif_size, serif_protrude, hole_height;
393         beam_width# = 1.4 linethickness#;
394         hole_height# = 3 linethickness#;
395         2 beam_height# + hole_height# = brevis_height#;
396         serif_size# = (hole_height# - linethickness#) / 2;
397         serif_protrude# = 1.5 serif_size#;
399         save xoffs, yoffs;
401         xoffs# = xpart exact_center;
402         yoffs# = ypart exact_center;
404         define_pixels (xoffs, yoffs);
405         define_pixels (brevis_width, brevis_height, linethickness);
406         define_pixels (beam_width, beam_height, serif_size, serif_protrude);
408         z1l = (xoffs, yoffs - linethickness);
409         z2r = z1r + serif_size * (1, -1);
410         z3l = z2l + (-serif_size, -serif_protrude);
412         penpos1 (beam_width, 0);
413         penpos2 (beam_height, 90);
414         penpos3 (beam_width, 180);
416         save pat_in, pat_out;
417         path pat_in, pat_out;
419         pat_out := z3r{down}
420                    .. z3l{up}
421                    .. z2l{right};
422         pat_out := pat_out
423                    -- reverse pat_out xscaled -1
424                                       shifted (2 xoffs + brevis_width, 0);
425         pat_out := pat_out
426                    -- reverse pat_out yscaled -1
427                                       shifted (0, 2 yoffs)
428                    -- cycle;
430         pat_in := z1r{down}
431                   .. z2r{right};
432         pat_in := pat_in
433                   -- reverse pat_in xscaled -1
434                                     shifted (2 xoffs + brevis_width, 0);
435         pat_in := pat_in
436                   -- reverse pat_in yscaled -1
437                                     shifted (0, 2 yoffs)
438                   -- cycle;
440         fill pat_out;
441         unfill pat_in;
443         penlabels (1, 2, 3);
444 enddef;
447 % Draw two brevis notes; the second one shifted down by `shift'.
448 % The other parameters are the same as with `draw_brevis'.
450 def draw_double_brevis (expr exact_center, bwidth, bheight,
451                              blinethickness, shift) =
452         save brevis_width, brevis_height, linethickness;
454         brevis_width# = bwidth;
455         brevis_height# = bheight;
456         linethickness# = blinethickness;
458         save beam_width, beam_height;
459         save serif_size, serif_protrude, hole_height;
461         beam_width# = 1.4 linethickness#;
462         hole_height# = 3 linethickness#;
463         2 beam_height# + hole_height# = brevis_height#;
464         serif_size# = (hole_height# - linethickness#) / 2;
465         serif_protrude# = 1.5 serif_size#;
467         save xoffs, yoffs;
469         xoffs# = xpart exact_center;
470         yoffs# = ypart exact_center;
472         define_pixels (xoffs, yoffs);
473         define_pixels (brevis_width, brevis_height, linethickness);
474         define_pixels (beam_width, beam_height, serif_size, serif_protrude);
476         z1l = (xoffs, yoffs - linethickness);
477         z2r = z1r + serif_size * (1, -1);
478         z3l = z2l + (-serif_size, -serif_protrude);
480         penpos1 (beam_width, 0);
481         penpos2 (beam_height, 90);
482         penpos3 (beam_width, 180);
484         z4 = z1 shifted (0, -shift);
485         z5 = z2 shifted (0, -shift);
486         z6 = z3 shifted (0, -shift);
487         
488         penpos4 (beam_width, 0);
489         penpos5 (beam_height, 90);
490         penpos6 (beam_width, 180);
492         save pat_in, pat_out;
493         path pat_in, pat_out;
495         pat_out := z6r{down}
496                    .. z6l{up}
497                    .. z5l{right};
498         pat_out := pat_out
499                    -- reverse pat_out xscaled -1
500                                       shifted (2 xoffs + brevis_width, 0);
501         pat_out := pat_out
502                    -- reverse pat_out yscaled -1
503                                       shifted (0, shift - 2 yoffs)
504                    -- cycle;
506         fill pat_out;
508         pat_in := z1r{down}
509                   .. z2r{right};
510         pat_in := pat_in
511                   -- reverse pat_in xscaled -1
512                                     shifted (2 xoffs + brevis_width, 0);
513         pat_in := pat_in
514                   -- reverse pat_in yscaled -1
515                                     shifted (0, 2 yoffs)
516                   -- cycle;
518         unfill pat_in;
519         unfill pat_in shifted (0, -shift);
521         penlabels (1, 2, 3, 4, 5, 6);
522 enddef;
526 % Draw three brevis notes; the second one shifted down by `shift',
527 % the third one by `2 shift'.
528 % The other parameters are the same as with `draw_brevis'.
530 def draw_triple_brevis (expr exact_center, bwidth, bheight,
531                              blinethickness, shift) =
532         save brevis_width, brevis_height, linethickness;
534         brevis_width# = bwidth;
535         brevis_height# = bheight;
536         linethickness# = blinethickness;
538         save beam_width, beam_height;
539         save serif_size, serif_protrude, hole_height;
541         beam_width# = 1.4 linethickness#;
542         hole_height# = 3 linethickness#;
543         2 beam_height# + hole_height# = brevis_height#;
544         serif_size# = (hole_height# - linethickness#) / 2;
545         serif_protrude# = 1.5 serif_size#;
547         save xoffs, yoffs;
549         xoffs# = xpart exact_center;
550         yoffs# = ypart exact_center;
552         define_pixels (xoffs, yoffs);
553         define_pixels (brevis_width, brevis_height, linethickness);
554         define_pixels (beam_width, beam_height, serif_size, serif_protrude);
556         z1l = (xoffs, yoffs - linethickness);
557         z2r = z1r + serif_size * (1, -1);
558         z3l = z2l + (-serif_size, -serif_protrude);
560         penpos1 (beam_width, 0);
561         penpos2 (beam_height, 90);
562         penpos3 (beam_width, 180);
564         z7 = z1 shifted (0, -2 shift);
565         z8 = z2 shifted (0, -2 shift);
566         z9 = z3 shifted (0, -2 shift);
567         
568         penpos7 (beam_width, 0);
569         penpos8 (beam_height, 90);
570         penpos9 (beam_width, 180);
572         save pat_in, pat_out;
573         path pat_in, pat_out;
575         pat_out := z9r{down}
576                    .. z9l{up}
577                    .. z8l{right};
578         pat_out := pat_out
579                    -- reverse pat_out xscaled -1
580                                       shifted (2 xoffs + brevis_width, 0);
581         pat_out := pat_out
582                    -- reverse pat_out yscaled -1
583                                       shifted (0, -2 yoffs)
584                    -- cycle;
586         fill pat_out;
588         pat_in := z1r{down}
589                   .. z2r{right};
590         pat_in := pat_in
591                   -- reverse pat_in xscaled -1
592                                     shifted (2 xoffs + brevis_width, 0);
593         pat_in := pat_in
594                   -- reverse pat_in yscaled -1
595                                     shifted (0, 2 yoffs)
596                   -- cycle;
598         unfill pat_in;
599         unfill pat_in shifted (0, -shift);
600         unfill pat_in shifted (0, -2 shift);
602         penlabels (1, 2, 3, 7, 8, 9);
603 enddef;
606 def draw_neomensural_c_clef (expr exact_center, reduction) = 
607         save reduced_il, reduced_slt, stem_width;
609         reduced_il# = staff_space# * reduction;
610         reduced_slt# = linethickness# * reduction;
611         stem_width# = 1.4 reduced_slt#;
613         define_pixels (reduced_il, reduced_slt, stem_width);
615         set_char_box (0 - xpart exact_center,
616                       2 reduced_il# + 6 reduced_slt# + xpart exact_center,
617                       2 reduced_il# - ypart exact_center,
618                       2 reduced_il# + ypart exact_center);
620         draw_brevis (exact_center + (3 reduced_slt#, 0),
621                      2 reduced_il#, reduced_il#, reduced_slt#);
623         save xoffs, yoffs;
625         xoffs# = xpart exact_center;
626         yoffs# = ypart exact_center;
628         define_pixels (xoffs, yoffs);
630         save ellipse, pat, T;
631         path ellipse, pat;
632         transform T;
634         T := identity xscaled stem_width
635                       yscaled blot_diameter;
636         pickup pencircle transformed T;
637         ellipse := fullcircle transformed T;
639         lft x11 = lft x12 = xoffs;
640         top y12 - bot y11 = 4 reduced_il;
641         top y12 + bot y11 = 2 yoffs;
642         x13 = x3;
643         y13 = y11;
644         rt x14 = rt x15 = w;
645         y14 = y11;
646         y15 = y12;
648         pat := get_subpath (ellipse, down, up, z13)
649                -- z3l
650                -- z3r
651                -- cycle;
653         fill get_subpath (ellipse, down, up, z11)
654              -- get_subpath (ellipse, up, down, z12)
655              -- cycle;
656         fill get_subpath (ellipse, down, up, z14)
657              -- get_subpath (ellipse, up, down, z15)
658              -- cycle;
660         fill pat;
661         fill pat xscaled -1
662                  shifted (w, 0);
663         fill pat yscaled -1
664                  shifted (0, 2 yoffs);
665         fill pat scaled -1
666                  shifted (w, 2 yoffs);
668         labels (11, 12, 13, 14, 15);
669 enddef;
672 fet_beginchar ("neo-mensural c clef", "neomensural.c");
673         if test = 1:
674                 draw_staff (-1, 3, 0.0);
675         fi;
676         draw_neomensural_c_clef ((0, 0), 1.0);
677 fet_endchar;
680 fet_beginchar ("neo-mensural c clef", "neomensural.c_change");
681         draw_neomensural_c_clef ((0, 0), .8);
682 fet_endchar;
685 def draw_petrucci_c_clef (expr exact_center, flare_align, reduction) = 
686         % inspired by Josquin Desprez, "Stabat Mater", Libro tertio,
687         % 1519, printed by Petrucci, in: MGG, volume 7, Table 11.
688         % Also by Petrucci's Canti C, Venedig 1503.  In: MGG, volume
689         % 9, p. 1681/1682.
691         save reduced_il, reduced_slt;
693         reduced_il# = staff_space# * reduction;
694         reduced_slt# = linethickness# * reduction;
696         define_pixels (reduced_il);
698         draw_double_brevis (exact_center + (0, 0.5 staff_space#),
699                             reduced_il#, reduced_il#, reduced_slt#,
700                             staff_space);
702         save half_reduced_il, left_depth, left_height;
704         half_reduced_il# = staff_space# * sqrt (reduction);
705         left_height# = half_reduced_il# * min (3.2, 3.2 + 0.2 + flare_align);
706         left_depth# = half_reduced_il# * min (3.2, 3.2 + 0.2 - flare_align);
708         define_pixels (half_reduced_il);
709         define_pixels (left_depth, left_height);
711         set_char_box (0 - xpart exact_center,
712                       reduced_il# + xpart exact_center,
713                       left_depth# - ypart exact_center,
714                       left_height# + ypart exact_center);
716         save xoffs, yoffs;
718         xoffs# = xpart exact_center;
719         yoffs# = ypart exact_center;
721         define_pixels (xoffs, yoffs);
723         save ellipse, T;
724         path ellipse;
725         transform T;
727         T := identity xscaled 1.4 linethickness
728                       yscaled blot_diameter;
729         pickup pencircle transformed T;
730         ellipse := fullcircle transformed T;
732         lft x11 = lft x13 = xoffs;
733         top y11 = yoffs + left_height;
734         bot y13 = yoffs - left_depth;
735         rt x15 = rt x17 = xoffs + brevis_width;
736         y15 = min (y11 - 0.2 half_reduced_il, yoffs + 2.2 half_reduced_il);
737         y17 = max (y13 + 0.2 half_reduced_il, yoffs - 2.2 half_reduced_il);
739         z12 = z14 yscaled -1;
740         z14 = z6;
741         z16 = z18 yscaled -1;
742         rt z18 = lft z14 shifted (brevis_width, 0);
744         penpos12 (1.4 linethickness, 0);
745         penpos14 (1.4 linethickness, 0);
746         penpos16 (1.4 linethickness, 0);
747         penpos18 (1.4 linethickness, 0);
749         if top y11 > -y6 + 0.7 linethickness:
750                 fill get_subpath (ellipse, up, down, z11)
751                      -- z12l
752                      -- z12r
753                      -- cycle;
754         fi;
755         if bot y13 < y6 - 0.7 linethickness:
756                 fill get_subpath (ellipse, down, up, z13)
757                      -- z14r
758                      -- z14l
759                      -- cycle;
760         fi;
761         if top y15 > -y6 + 0.7 linethickness:
762                 fill get_subpath (ellipse, up, down, z15)
763                      -- z16l
764                      -- z16r
765                      -- cycle;
766         fi;
767         if bot y17 < y6 - 0.7 linethickness:
768                 fill get_subpath (ellipse, down, up, z17)
769                      -- z18r
770                      -- z18l
771                      -- cycle;
772         fi;
774         labels (11, 13, 15, 17);
775         penlabels (12, 14, 16, 18);
776 enddef;
779 fet_beginchar ("petrucci c1 clef", "petrucci.c1");
780         if test = 1:
781                 draw_staff (-1, 3, 0.0);
782         fi;
783         draw_petrucci_c_clef ((0, 0), +2, 1.0);
784 fet_endchar;
787 fet_beginchar ("petrucci c1 clef", "petrucci.c1_change");
788         draw_petrucci_c_clef ((0, 0), +2, .8);
789 fet_endchar;
792 fet_beginchar ("petrucci c2 clef", "petrucci.c2");
793         if test = 1:
794                 draw_staff (-1, 3, 0.0);
795         fi;
796         draw_petrucci_c_clef ((0, 0), +1, 1.0);
797 fet_endchar;
800 fet_beginchar ("petrucci c2 clef", "petrucci.c2_change");
801         draw_petrucci_c_clef ((0, 0), +1, .8);
802 fet_endchar;
805 fet_beginchar ("petrucci c3 clef", "petrucci.c3");
806         if test = 1:
807                 draw_staff (-1, 3, 0.0);
808         fi;
809         draw_petrucci_c_clef ((0, 0), 0, 1.0);
810 fet_endchar;
813 fet_beginchar ("petrucci c3 clef", "petrucci.c3_change");
814         draw_petrucci_c_clef ((0, 0), 0, .8);
815 fet_endchar;
818 fet_beginchar ("petrucci c4 clef", "petrucci.c4");
819         if test = 1:
820                 draw_staff (-1, 3, 0.0);
821         fi;
822         draw_petrucci_c_clef ((0, 0), -1, 1.0);
823 fet_endchar;
826 fet_beginchar ("petrucci c4 clef", "petrucci.c4_change");
827         draw_petrucci_c_clef ((0, 0), -1, .8);
828 fet_endchar;
831 fet_beginchar ("petrucci c5 clef", "petrucci.c5");
832         if test = 1:
833                 draw_staff (-1, 3, 0.0);
834         fi;
835         draw_petrucci_c_clef ((0, 0), -2, 1.0);
836 fet_endchar;
839 fet_beginchar ("petrucci c5 clef", "petrucci.c5_change");
840         draw_petrucci_c_clef ((0, 0), -2, .8);
841 fet_endchar;
844 def draw_mensural_c_clef (expr exact_center, reduction) =
845         % inspired by Ockeghem, "Missa Prolationum", in: MGG, volume
846         % 9, table 94.
848         save reduced_il;
850         reduced_il# = staff_space# * reduction;
852         define_pixels (reduced_il);
854         draw_triple_brevis (exact_center + (0, 0.5 staff_space#),
855                             2 reduced_il#, 0.8 staff_space#,
856                             0.8 linethickness#, staff_space);
858         save half_reduced_il;
860         half_reduced_il# = staff_space# * sqrt (reduction);
862         define_pixels (half_reduced_il);
864         set_char_box (0 - xpart exact_center,
865                       2 reduced_il# + xpart exact_center,
866                       2.2 half_reduced_il# + staff_space# -
867                         2 ypart exact_center,
868                       2.2 half_reduced_il# + 2 ypart exact_center);
870         save xoffs, yoffs;
872         xoffs# = xpart exact_center;
873         yoffs# = ypart exact_center;
875         define_pixels (xoffs, yoffs);
877         save ellipse, T;
878         path ellipse;
879         transform T;
881         T := identity xscaled 1.4 linethickness
882                       yscaled blot_diameter;
883         pickup pencircle transformed T;
884         ellipse := fullcircle transformed T;
886         lft x11 = lft x13 = xoffs;
887         top y11 = yoffs + 2.2 half_reduced_il;
888         bot y13 = yoffs - 2.2 half_reduced_il - staff_space;
889         rt x15 = rt x17 = xoffs + brevis_width;
890         y15 = yoffs + 1.4 half_reduced_il;
891         y17 = yoffs - 1.4 half_reduced_il - staff_space;
893         z12 = z14 yscaled -1 shifted (0, -staff_space);
894         z14 = z9;
895         z16 = z18 yscaled -1 shifted (0, -staff_space);
896         rt z18 = lft z14 shifted (brevis_width, 0);
898         penpos12 (1.4 linethickness, 0);
899         penpos14 (1.4 linethickness, 0);
900         penpos16 (1.4 linethickness, 0);
901         penpos18 (1.4 linethickness, 0);
903         fill get_subpath (ellipse, up, down, z11)
904              -- z12l
905              -- z12r
906              -- cycle;
907         fill get_subpath (ellipse, down, up, z13)
908              -- z14r
909              -- z14l
910              -- cycle;
911         fill get_subpath (ellipse, up, down, z15)
912              -- z16l
913              -- z16r
914              -- cycle;
915         fill get_subpath (ellipse, down, up, z17)
916              -- z18r
917              -- z18l
918              -- cycle;
920         labels (11, 13, 15, 17);
921         penlabels (12, 14, 16, 18);
922 enddef;
925 fet_beginchar ("mensural c clef", "mensural.c");
926         if test = 1:
927                 draw_staff (-1, 3, 0.0);
928         fi;
929         draw_mensural_c_clef ((0, 0), 1.0);
930 fet_endchar;
933 fet_beginchar ("mensural c clef", "mensural.c_change");
934         draw_mensural_c_clef ((0, 0), .8);
935 fet_endchar;
938 def draw_diamond (expr exact_center, reduction) =
939         save stem_width, reduced_nht, holeheight, beamheight;
940         save rh_height, rh_width;
942         stem_width# = 1.4 reduced_slt#;
943         reduced_nht# = noteheight# * reduction;
944         holeheight# = 3 reduced_slt#;
945         beamheight# = 0.4 (reduced_nht# - holeheight#);
947         rh_height# = 1.2 staff_space# * reduction;
948         rh_width# / rh_height# = tand (30);
950         define_pixels (beamheight, stem_width);
951         define_pixels (rh_height, rh_width);
953         save xoffs, yoffs;
955         xoffs# = xpart exact_center;
956         yoffs# = ypart exact_center;
958         define_pixels (xoffs, yoffs);
960         save ellipse, T;
961         path ellipse;
962         transform T;
964         T := identity xscaled beamheight
965                       yscaled stem_width
966                       rotated 45;
967         pickup pencircle transformed T;
968         ellipse := reverse fullcircle transformed T;
970         x21 := xoffs - rh_width / 2;
971         y21 := yoffs;
972         x22 := xoffs;
973         y22 := yoffs + rh_height / 2;
974         x23 := xoffs + rh_width / 2;
975         y23 := yoffs;
976         x24 := xoffs;
977         y24 := yoffs - rh_height / 2;
979         fill get_subpath (ellipse, z21 - z24, z22 - z21, z21)
980              -- get_subpath (ellipse, z22 - z21, z23 - z22, z22)
981              -- get_subpath (ellipse, z23 - z22, z24 - z23, z23)
982              -- get_subpath (ellipse, z24 - z23, z21 - z24, z24)
983              -- cycle;
985         save l;
986         path l[];
988         l2122 := (directionpoint (z21 - z22) of ellipse) shifted z21
989                  -- (directionpoint (z21 - z22) of ellipse) shifted z22;
990         l2223 := (directionpoint (z22 - z23) of ellipse) shifted z22
991                  -- (directionpoint (z22 - z23) of ellipse) shifted z23;
992         l2324 := (directionpoint (z23 - z24) of ellipse) shifted z23
993                  -- (directionpoint (z23 - z24) of ellipse) shifted z24;
994         l2421 := (directionpoint (z24 - z21) of ellipse) shifted z24
995                  -- (directionpoint (z24 - z21) of ellipse) shifted z21;
997         unfill l2122 intersectionpoint l2223
998                -- l2223 intersectionpoint l2324
999                -- l2324 intersectionpoint l2421
1000                -- l2421 intersectionpoint l2122
1001                -- cycle;
1003         labels (21, 22, 23, 24);
1004 enddef;
1007 def draw_petrucci_f_clef (expr exact_center, reduction) =
1008         % inspired by L'homme arme super voces musicales in Misse
1009         % Josquin, 1502, Petrucci, in: MGG, volume 7, col. 200; also
1010         % inspired by Gaspar van Weerbeke, "Virgo Maria" (1502), in:
1011         % MGG, volume 9, col. 653 ("Motette"), fig. 3.; also by Andr'e
1012         % Campra, "Entr'ee des s'er'enades" (1710), in: MGG, volume 2,
1013         % col. 1649 ("Contredanse"), fig. 2.
1015         save interline, reduced_il, reduced_slt;
1017         interline# = staff_space#;
1018         reduced_il# = staff_space# * reduction;
1019         reduced_slt# = linethickness# * reduction;
1021         draw_brevis (exact_center, reduced_il#, reduced_il#, reduced_slt#);
1022         draw_diamond (exact_center +
1023                         (1.6 interline# * reduction, interline# / 2),
1024                      reduction);
1025         draw_diamond (exact_center +
1026                         (1.6 interline# * reduction, -interline# / 2),
1027                      reduction);
1029         define_pixels (interline, reduced_il, reduced_slt);
1031         save stem_width;
1033         stem_width# = 1.4 reduced_slt#;
1035         define_pixels (stem_width);
1037         save xoffs, yoffs;
1039         xoffs# = xpart exact_center;
1040         yoffs# = ypart exact_center;
1042         define_pixels (xoffs, yoffs);
1044         % brevis stem
1045         save ellipse, T;
1046         path ellipse;
1047         transform T;
1049         T := identity xscaled stem_width
1050                       yscaled blot_diameter;
1051         pickup pencircle transformed T;
1052         ellipse := fullcircle transformed T;
1054         rt x8 = xoffs + reduced_il;
1055         y8 = y3;
1056         rt z9 = (xoffs + reduced_il, yoffs - 4 reduced_il);
1058         penpos8 (stem_width, 0);
1060         fill get_subpath (ellipse, down, up, z9)
1061              -- z8r
1062              -- z8l
1063              -- cycle;
1065         % upper diamond's stem
1066         z10 = (xoffs + 1.6 interline * reduction + stem_width / 2,
1067                yoffs + interline * reduction);
1068         top z11 = z10 + (0, 1.5 interline * reduction);
1070         penpos10 (stem_width, 0);
1072         fill get_subpath (ellipse, up, down, z11)
1073              -- z10l
1074              -- z10r
1075              -- cycle;
1077         % lower diamond's stem
1078         z12 = (xoffs + 1.6 interline * reduction - stem_width / 2,
1079                yoffs - interline * reduction);
1080         bot z13 = z12 + (0, -3.5 interline * reduction);
1082         penpos12 (stem_width, 0);
1084         fill get_subpath (ellipse, down, up, z13)
1085              -- z12r
1086              -- z12l
1087              -- cycle;
1089         save reduced_il, rh_height, rh_width;
1091         reduced_il# = staff_space# * reduction;
1092         rh_height# = 1.2 reduced_il#;
1093         rh_width# / rh_height# = tand (30);
1095         set_char_box (0 - xpart exact_center,
1096                       1.6 interline# * reduction + 0.5 rh_width# +
1097                         xpart exact_center,
1098                       4.5 interline# * reduction - ypart exact_center,
1099                       2.5 interline# * reduction + ypart exact_center);
1101         labels (9, 11, 13);
1102         penlabels (8, 10, 12);
1103 enddef;
1106 fet_beginchar ("petrucci f clef", "petrucci.f");
1107         if test = 1:
1108                 draw_staff (-1, 3, 0.0);
1109         fi;
1110         draw_petrucci_f_clef ((0, 0), 1.0);
1111 fet_endchar;
1114 fet_beginchar ("petrucci f clef", "petrucci.f_change");
1115         draw_petrucci_f_clef ((0, 0), .8);
1116 fet_endchar;
1119 def draw_mensural_f_clef (expr exact_center, reduction) =
1120         % inspired by Philippe le Duc, "Dite Signori" (1590), in: MGG,
1121         % volume 3, col. 848 ("Duc"); also by John Dowland, "The First
1122         % Booke of Songes" (1597), in: MGG, volume 3, col. 721
1123         % ("Dowland"), fig. 3.
1125         save width, reduced_slt, stem_width, dot_diameter;
1127         width# = 1.2 staff_space# * reduction;
1128         reduced_slt# = linethickness# * reduction;
1129         stem_width# = 1.4 reduced_slt#;
1130         dot_diameter# = 0.1 reduction * staff_space#;
1132         define_pixels (width, stem_width, staff_space, dot_diameter);
1134         save xoffs, yoffs;
1136         xoffs# = xpart exact_center;
1137         yoffs# = ypart exact_center;
1139         define_pixels (xoffs, yoffs);
1141         save ellipse, T;
1142         path ellipse;
1143         transform T;
1145         T := identity xscaled 0.2 width
1146                       yscaled stem_width
1147                       rotated 45;
1148         pickup pencircle transformed T;
1149         ellipse := fullcircle transformed T;
1151         % half circle
1152         lft z10 = (0, 0);
1154         save pat;
1155         path pat;
1157         pat := halfcircle scaled width
1158                           rotated -90
1159                           shifted (z10 - (xoffs, yoffs));
1161         z5 = point 0 of pat;
1162         z6 = point 1 of pat;
1163         z7 = point 2 of pat;
1164         z8 = point 3 of pat;
1165         z9 = point 4 of pat;
1167         save dirs;
1168         pair dirs[];
1170         dirs5 := direction 0 of pat;
1171         dirs6 := direction 1 of pat;
1172         dirs7 := direction 2 of pat;
1173         dirs8 := direction 3 of pat;
1174         dirs9 := direction 4 of pat;
1176         % we approximate `draw pat'
1177         fill get_subpath (ellipse, -dirs5, dirs5, z5)
1178              .. get_subpoint (ellipse, dirs6, z6)
1179              .. get_subpoint (ellipse, dirs7, z7)
1180              .. get_subpoint (ellipse, dirs8, z8)
1181              .. get_subpath (ellipse, dirs9, -dirs9, z9)
1182              .. get_subpoint (ellipse, -dirs8, z8)
1183              .. get_subpoint (ellipse, -dirs7, z7)
1184              .. get_subpoint (ellipse, -dirs6, z6)
1185              .. cycle;
1187         % upper dot
1188         rt x2 = xoffs + width;
1189         top y1 = yoffs + 0.5 width;
1190         z2 - z1 = (dot_diameter, -dot_diameter);
1192         fill get_subpath (ellipse, z1 - z2, z2 - z1, z1)
1193              -- get_subpath (ellipse, z2 - z1, z1 - z2, z2)
1194              -- cycle;
1196         % lower dot
1197         x3 = x1;
1198         top y1 - bot y4 = width;
1199         z4 - z3 = (dot_diameter, -dot_diameter);
1201         fill get_subpath (ellipse, z3 - z4, z4 - z3, z3)
1202              -- get_subpath (ellipse, z4 - z3, z3 - z4, z4)
1203              -- cycle;
1205         set_char_box (0 - xpart exact_center,
1206                       width# + xpart exact_center,
1207                       0.5 width# - ypart exact_center,
1208                       0.5 width# + ypart exact_center);
1210         labels (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
1211 enddef;
1214 fet_beginchar ("mensural f clef", "mensural.f");
1215         if test = 1:
1216                 draw_staff (-1, 3, 0.0);
1217         fi;
1218         draw_mensural_f_clef ((0, 0), 1.0);
1219 fet_endchar;
1222 fet_beginchar ("mensural f clef", "mensural.f_change");
1223         draw_mensural_f_clef ((0, 0), .8);
1224 fet_endchar;
1227 def draw_petrucci_g_clef (expr exact_center, reduction) =
1228         % inspired by Josquin Desprez, "Stabat Mater", Libro tertio,
1229         % 1519, printed by Petrucci, in: MGG, volume 7, Table 11.
1231         save reduced_il, reduced_slt;
1233         reduced_il# = staff_space# * reduction;
1234         reduced_slt# = linethickness# * reduction;
1235         define_pixels (reduced_il, reduced_slt);
1237         set_char_box (0 - xpart exact_center,
1238                       1.25 reduced_il# + xpart exact_center,
1239                       0.65 reduced_il# - ypart exact_center,
1240                       3.80 reduced_il# + ypart exact_center);
1242         save xoffs, yoffs;
1244         xoffs# = xpart exact_center;
1245         yoffs# = ypart exact_center;
1247         define_pixels (xoffs, yoffs);
1249         save ellipse, paths, sub_path, outlines, sub_outlines, T;
1250         path ellipse, paths[], sub_path, outlines[], sub_outlines[];
1251         transform T;
1253         T := identity xscaled 0.5 reduced_slt
1254                       yscaled 0.22 reduced_il
1255                       rotated -35;
1256         pickup pencircle transformed T;
1257         ellipse := fullcircle transformed T;
1259         lft z1 = (xoffs + 0.80 reduced_il, yoffs + 0.00 reduced_il);
1260         lft z2 = (xoffs + 1.00 reduced_il, yoffs + 1.20 reduced_il);
1261         lft z3 = (xoffs + 0.70 reduced_il, yoffs + 2.00 reduced_il);
1262         lft z4 = (xoffs + 0.30 reduced_il, yoffs + 3.00 reduced_il);
1263         lft z5 = (xoffs + 0.80 reduced_il, yoffs + 3.70 reduced_il);
1264         lft z6 = (xoffs + 1.00 reduced_il, yoffs + 3.00 reduced_il);
1265         lft z7 = (xoffs + 0.60 reduced_il, yoffs + 2.00 reduced_il);
1266         lft z8 = (xoffs + 0.30 reduced_il, yoffs + 1.70 reduced_il);
1267         lft z9 = (xoffs + 0.00 reduced_il, yoffs + 0.75 reduced_il);
1268         lft z10 = (xoffs + 0.20 reduced_il, yoffs + 0.60 reduced_il);
1270         paths1 := z1{-1, 2}
1271                   .. z2
1272                   .. z3
1273                   .. z4
1274                   .. z5
1275                   .. z6
1276                   .. z7
1277                   .. z8
1278                   .. z9
1279                   .. z10;
1281         save dirs, s;
1282         pair dirs[];
1284         s := 1/4;
1286         % we approximate `draw paths1'
1287         for i = 1 step s until (length paths1 + 1):
1288                 dirs[i] := direction (i - 1) of paths1;
1289         endfor;
1291         outlines1 := get_subpath (ellipse, -dirs1, dirs1, z1)
1292                      for i = (1 + s) step s until (length paths1 + 1 - s):
1293                              .. get_subpoint (ellipse, dirs[i],
1294                                               point (i - 1) of paths1)
1295                      endfor
1296                      .. get_subpath (ellipse, dirs10, -dirs10, z10)
1297                      for i = (length paths1 + 1 - s) step -s until (1 + s):
1298                              .. get_subpoint (ellipse, -dirs[i],
1299                                               point (i - 1) of paths1)
1300                      endfor
1301                      .. cycle;
1303         save len;
1305         len := length outlines1;
1307         sub_outlines1 := subpath (0,
1308                                   floor (1/4 len)) of outlines1;
1309         sub_outlines2 := subpath (floor (1/4 len),
1310                                   floor (2/4 len)) of outlines1;
1311         sub_outlines3 := subpath (floor (2/4 len),
1312                                   floor (3/4 len)) of outlines1;
1313         sub_outlines4 := subpath (floor (3/4 len),
1314                                   len) of outlines1;
1316         save times;
1317         numeric times[];
1319         (times12, times21) = sub_outlines1 intersectiontimes sub_outlines2;
1320         (times13, times31) = sub_outlines1 intersectiontimes sub_outlines3;
1321         (times42, times24) = sub_outlines4 intersectiontimes sub_outlines2;
1322         (times43, times34) = sub_outlines4 intersectiontimes sub_outlines3;
1324         T := identity xscaled 0.75 reduced_slt
1325                       yscaled 0.33 reduced_il
1326                       rotated -35;
1327         pickup pencircle transformed T;
1328         ellipse := fullcircle transformed T;
1330         lft z21 = (xoffs + 1.05 reduced_il, yoffs + 0.45 reduced_il);
1331         lft z22 = (xoffs + 0.55 reduced_il, yoffs + 0.45 reduced_il);
1332         lft z23 = (xoffs + 0.55 reduced_il, yoffs - 0.45 reduced_il);
1333         lft z24 = (xoffs + 1.05 reduced_il, yoffs - 0.45 reduced_il);
1334         lft z25 = (xoffs + 1.10 reduced_il, yoffs + 0.00 reduced_il);
1335         lft z26 = (xoffs + 0.80 reduced_il, yoffs + 0.00 reduced_il);
1337         paths2 := z21
1338                   .. z22
1339                   .. z23
1340                   .. z24
1341                   .. {up}z25
1342                   -- z26;
1344         sub_path := subpath (0, 1) of paths2;
1346         times1 = xpart (sub_outlines1 intersectiontimes sub_path);
1347         times4 = xpart (sub_outlines4 intersectiontimes sub_path);
1349         % we have to find the envelope intersections (if any)
1350         save t;
1351         numeric t[];
1353         t1 = find_envelope_cusp (reverse ellipse,
1354                                  subpath (1, 2) of paths2,
1355                                  1/256) + 1;
1356         if t1 < 1:
1357                 t1 := 1;
1358                 t2 := 1;
1359         else:
1360                 t2 = find_envelope_cusp (ellipse,
1361                                          subpath (3, 4) of reverse paths2,
1362                                          1/256) + 3;
1363                 t2 := length paths2 - t2;
1364         fi;
1366         t3 = find_envelope_cusp (reverse ellipse,
1367                                  subpath (2, 4 - epsilon) of paths2,
1368                                  1/256) + 2;
1369         if t3 < 2:
1370                 t3 := 3;
1371                 t4 := 3;
1372         else:
1373                 t4 = find_envelope_cusp (ellipse,
1374                                          subpath (1 + epsilon, 3)
1375                                            of reverse paths2,
1376                                          1/256) + 1;
1377                 t4 := length paths2 - t4;
1378         fi;
1380         fill subpath (times1 + s / 4, times13) of sub_outlines1
1381              -- subpath (times31, infinity) of sub_outlines3
1382              & subpath (0, times42) of sub_outlines4
1383              -- subpath (times24, infinity) of sub_outlines2
1384              & subpath (0, times34) of sub_outlines3
1385              -- subpath (times43, times4 - s / 4) of sub_outlines4
1386              -- cycle;
1387         unfill subpath (times12, infinity) of sub_outlines1
1388                & subpath (0, times21) of sub_outlines2
1389                -- cycle;
1390         fill subpath (times4 + s / 4, infinity) of sub_outlines4
1391              & subpath (0, times1 - s / 4) of sub_outlines1
1392              -- cycle;
1395         % we approximate `draw paths2'
1396         for i = 1 step s until (length paths2 - s):
1397                 dirs[i + 20] := direction (i - 1) of paths2;
1398         endfor;
1400         sub_outlines21 := get_subpath (ellipse, -dirs21, dirs21, z21)
1401                           for i = (1 + s) step s until (length paths2 - s):
1402                                   .. get_subpoint (ellipse, dirs[i + 20],
1403                                                    point (i - 1) of paths2)
1404                           endfor
1405                           .. get_subpath (ellipse, up, z26 - z25, z25);
1406         sub_outlines22 := get_subpath (ellipse, z26 - z25, z25 - z26, z26)
1407                           -- get_subpoint (ellipse, z25 - z26, z25);
1408         sub_outlines23 := get_subpoint (ellipse, down, z25)
1409                           for i = (length paths2 - s) step -s until (t4 + 1):
1410                                   .. get_subpoint (ellipse, -dirs[i + 20],
1411                                                    point (i - 1) of paths2)
1412                           endfor
1413                           .. get_subpoint (ellipse, -direction t4 of paths2,
1414                                            point t4 of paths2);
1415         sub_outlines24 := get_subpoint (ellipse, -direction t3 of paths2,
1416                                         point t3 of paths2)
1417                           for i = (floor (t3 / s) * s + 1) step -s until (t2 + 1):
1418                                   .. get_subpoint (ellipse, -dirs[i + 20],
1419                                                    point (i - 1) of paths2)
1420                           endfor
1421                           .. get_subpoint (ellipse, -direction t2 of paths2,
1422                                            point t2 of paths2);
1423         sub_outlines25 := get_subpoint (ellipse, -direction t1 of paths2,
1424                                         point t1 of paths2)
1425                           for i = (floor (t1 / s) * s + 1) step -s until (1 + s):
1426                                   .. get_subpoint (ellipse, -dirs[i + 20],
1427                                                    point (i - 1) of paths2)
1428                           endfor;
1430         (times2223, times2322) = sub_outlines22 intersectiontimes sub_outlines23;
1431         (times2324, times2423) = sub_outlines23 intersectiontimes sub_outlines24;
1432         (times2425, times2524) = sub_outlines24 intersectiontimes sub_outlines25;
1434         fill sub_outlines21
1435              -- subpath (0, times2223) of sub_outlines22
1436              -- subpath (times2322, times2324) of sub_outlines23
1437              -- subpath (times2423, times2425) of sub_outlines24
1438              -- subpath (times2524, infinity) of sub_outlines25
1439              .. cycle;
1441         labels (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
1442         labels (21, 22, 23, 24, 25, 26);
1443 enddef;
1446 fet_beginchar ("petrucci g clef", "petrucci.g");
1447         if test = 1:
1448                 draw_staff (-1, 3, 0.0);
1449         fi;
1450         draw_petrucci_g_clef ((0, 0), 1.0);
1451 fet_endchar;
1454 fet_beginchar ("petrucci g clef", "petrucci.g_change");
1455         draw_petrucci_g_clef ((0, 0), .8);
1456 fet_endchar;
1459 def draw_mensural_g_clef (expr exact_center, reduction) =
1460   % TODO: Rewrite me.  The former mensural g clef looked ugly, and the
1461   % code was removed when it broke for small font sizes after some
1462   % global changes in the font.  Currently, the character is mapped to
1463   % a copy of the petrucci g clef (which, after all, *is* a mensural g
1464   % clef, but not the one that we have in mind here). -- jr
1465   %
1466   % Possible sources of inspiration for this clef include: Francisco
1467   % Guerrero, "Lib. 1.  Missarum" (1566), in: MGG, volume 3, col. 858
1468   % ("Ducis"); Stefano Fabri, "Quam speciosa veteranis" (1611), in:
1469   % MGG, volume 3, col. 1698 ("Fabri"); Philippus Dulichius,
1470   % "Fasciculus novus ..."  (1598), in: MGG, volume 3, col. 919
1471   % ("Dulichius"), fig. 1; Noe Faignient, "Ic sal de Heer myn God
1472   % gebenedye" (1568), in: MGG, volume 3, col. 1735 ("Faignient").
1473 enddef;
1477 % FIXME: This clef is preliminarily mapped to the petrucci g clef
1478 % until the code for the mensural g clef will be rewritten.
1480 fet_beginchar ("mensural g clef", "mensural.g");
1481         if test = 1:
1482                 draw_staff (-1, 3, 0.0);
1483         fi;
1484         draw_petrucci_g_clef ((0, 0), 1.0);
1485 fet_endchar;
1488 fet_beginchar ("mensural g clef", "mensural.g_change");
1489         draw_petrucci_g_clef ((0, 0), .8);
1490 fet_endchar;
1494 %%%%%%%%
1498 % Hufnagel
1502 def draw_hufnagel_do_clef (expr exact_center, reduction) =
1503         % inspired by Graduale of Friedrich Zollner (1442), in: MGG,
1504         % volume 9, col. 1413 ("Neustift"), fig. 1.
1506         save reduced_il;
1508         reduced_il# = staff_space# * reduction;
1510         define_pixels (reduced_il);
1512         set_char_box (0 - xpart exact_center,
1513                       1.10 reduced_il# + xpart exact_center,
1514                       0.70 reduced_il# - ypart exact_center,
1515                       0.75 reduced_il# + ypart exact_center);
1517         save xoffs, yoffs;
1519         xoffs# = xpart exact_center;
1520         yoffs# = ypart exact_center;
1522         define_pixels (xoffs, yoffs);
1524         save ellipse, pat, T;
1525         path ellipse, pat;
1526         transform T;
1528         T := identity xscaled 0.6 reduced_il
1529                       yscaled 0.1 reduced_il
1530                       rotated 40;
1531         pickup pencircle transformed T;
1532         ellipse := fullcircle transformed T;
1534         z1 = (xoffs + 0.90 reduced_il, yoffs + .45 reduced_il);
1535         z2 = (xoffs + 0.80 reduced_il, yoffs + .45 reduced_il);
1536         z3 = (xoffs + 0.50 reduced_il, yoffs + .60 reduced_il);
1537         z4 = (xoffs + 0.20 reduced_il, yoffs + .45 reduced_il);
1538         z5 = (xoffs + 0.20 reduced_il, yoffs - .45 reduced_il);
1539         z6 = (xoffs + 0.40 reduced_il, yoffs - .55 reduced_il);
1541         pat := z1
1542                .. z2
1543                .. z3
1544                -- z4
1545                -- z5
1546                -- z6;
1548         fill get_subpath (ellipse,
1549                           -direction 0 of pat, direction 0 of pat, z1)
1550              .. get_subpoint (ellipse, direction 1 of pat, z2)
1551              .. get_subpath (ellipse,
1552                              direction (2 - epsilon) of pat, z4 - z3, z3)
1553              -- get_subpath (ellipse,
1554                              z4 - z3, z5 - z4, z4)
1555              -- get_subpath (ellipse,
1556                              z5 - z4, z6 - z5, z5)
1557              -- get_subpath (ellipse,
1558                              z6 - z5, z5 - z6, z6)
1559              -- get_subpoint (ellipse, z5 - z6, z5)
1560              -- get_subpoint (ellipse, z4 - z5, z5)
1561              -- get_subpoint (ellipse, z4 - z5, z4)
1562              -- get_subpoint (ellipse, -direction (2 - epsilon) of pat, z3)
1563              .. get_subpath (ellipse,
1564                              -direction 1 of pat, -direction 1 of pat, z2)
1565              .. cycle;
1567         labels (1, 2, 3, 4, 5, 6);
1568 enddef;
1571 fet_beginchar ("Hufnagel do clef", "hufnagel.do");
1572         if test = 1:
1573                 draw_staff (-1, 3, 0.0);
1574         fi;
1575         draw_hufnagel_do_clef ((0, 0), 1.0);
1576 fet_endchar;
1579 fet_beginchar ("Hufnagel do clef", "hufnagel.do_change");
1580         draw_hufnagel_do_clef ((0, 0), .8);
1581 fet_endchar;
1584 def draw_hufnagel_fa_clef (expr exact_center, reduction) =
1585         % inspired by Bamberger Manuscript (15th century), in:
1586         % MGG, volume 2, table 59.
1588         save reduced_il;
1590         reduced_il# = staff_space# * reduction;
1592         define_pixels (reduced_il);
1594         set_char_box (0 - xpart exact_center,
1595                       1.20 reduced_il# + xpart exact_center,
1596                       1.15 reduced_il# - ypart exact_center,
1597                       1.00 reduced_il# + ypart exact_center);
1599         save xoffs, yoffs;
1601         xoffs# = xpart exact_center;
1602         yoffs# = ypart exact_center;
1604         define_pixels (xoffs, yoffs);
1606         save ellipse, pat, T;
1607         path ellipse, pat;
1608         transform T;
1610         T := identity xscaled 0.6 reduced_il
1611                       yscaled 0.1 reduced_il
1612                       rotated 40;
1613         pickup pencircle transformed T;
1614         ellipse := fullcircle transformed T;
1616         z11 = (xoffs + 0.90 reduced_il, yoffs + 0.70 reduced_il);
1617         z12 = (xoffs + 0.80 reduced_il, yoffs + 0.70 reduced_il);
1618         z13 = (xoffs + 0.50 reduced_il, yoffs + 0.85 reduced_il);
1619         z14 = (xoffs + 0.20 reduced_il, yoffs + 0.70 reduced_il);
1620         z15 = (xoffs + 0.20 reduced_il, yoffs - 1.10 reduced_il);
1622         pat := z11
1623                .. z12
1624                .. z13
1625                -- z14
1626                -- z15;
1628         fill get_subpath (ellipse,
1629                           -direction 0 of pat, direction 0 of pat, z11)
1630              .. get_subpoint (ellipse, direction 1 of pat, z12)
1631              .. get_subpath (ellipse,
1632                              direction (2 - epsilon) of pat, z14 - z13, z13)
1633              -- get_subpath (ellipse,
1634                              z14 - z13, z15 - z14, z14)
1635              -- get_subpath (ellipse,
1636                              z15 - z14, z14 - z15, z15)
1637              -- get_subpoint (ellipse, z14 - z15, z14)
1638              -- get_subpoint (ellipse, -direction (2 - epsilon) of pat, z13)
1639              .. get_subpath (ellipse,
1640                              -direction 1 of pat, -direction 1 of pat, z12)
1641              .. cycle;
1643         z16 = (xoffs + 0.90 reduced_il, yoffs - 0.05 reduced_il);
1644         z17 = (xoffs + 0.80 reduced_il, yoffs - 0.05 reduced_il);
1645         z18 = (xoffs + 0.50 reduced_il, yoffs + 0.10 reduced_il);
1646         z19 = (xoffs + 0.20 reduced_il, yoffs - 0.05 reduced_il);
1648         pat := z16
1649                .. z17
1650                .. z18
1651                -- z19;
1653         fill get_subpath (ellipse,
1654                           -direction 0 of pat, direction 0 of pat, z16)
1655              .. get_subpoint (ellipse, direction 1 of pat, z17)
1656              .. get_subpath (ellipse,
1657                              direction (2 - epsilon) of pat, z19 - z18, z18)
1658              -- get_subpoint (ellipse, z19 - z18, z19)
1659              -- get_subpoint (ellipse, -direction (2 - epsilon) of pat, z18)
1660              .. get_subpoint (ellipse, -direction 1 of pat, z17)
1661              .. cycle;
1663         labels (11, 12, 13, 14, 15, 16, 17, 18, 19);
1664 enddef;
1667 fet_beginchar ("Hufnagel fa clef", "hufnagel.fa");
1668         if test = 1:
1669                 draw_staff (-1, 3, 0.0);
1670         fi;
1671         draw_hufnagel_fa_clef ((0, 0), 1.0);
1672 fet_endchar;
1675 fet_beginchar ("Hufnagel fa clef", "hufnagel.fa_change");
1676         draw_hufnagel_fa_clef ((0, 0), .8);
1677 fet_endchar;
1680 def draw_hufnagel_do_fa_clef (expr exact_center, reduction) =
1681         draw_hufnagel_do_clef (exact_center, reduction);
1682         draw_hufnagel_fa_clef (exact_center + (0, -2 staff_space#), reduction);
1684         set_char_box (0 - xpart exact_center,
1685                       1.20 reduced_il# + xpart exact_center,
1686                       1.15 reduced_il# + 2 staff_space# - ypart exact_center,
1687                       0.75 reduced_il# + ypart exact_center);
1688 enddef;
1691 fet_beginchar ("Hufnagel do/fa clef", "hufnagel.do.fa");
1692         if test = 1:
1693                 draw_staff (-1, 3, 0.0);
1694         fi;
1695         draw_hufnagel_do_fa_clef ((0, 0), 1.0);
1696 fet_endchar;
1699 fet_beginchar ("Hufnagel do/fa clef", "hufnagel.do.fa_change");
1700         draw_hufnagel_do_fa_clef ((0, 0), .8);
1701 fet_endchar;
1704 fet_endgroup ("clefs");