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