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