lilypond-1.5.10
[lilypond.git] / mf / feta-klef.mf
blob6ad17211d68d77a884645ba3ab4329f65241bbde
1 % feta-klef.mf --  implement Clefs -*-Fundamental-*-
2
3 % part of LilyPond's pretty-but-neat music font
5 % source file of the Feta (not the Font-En-Tja) music font
6
7 % (c) 1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>,
8 % Jan Nieuwenhuizen <janneke@gnu.org>,
9 % Juergen Reuter <reuterj@ira.uka.de>
12 fet_begingroup("clefs");
15 % [Ross] says that clefs take 1 staff_space space on the left and right
17 def set_horizontal_spacing =
18         save left_space ,right_space;
19         left_space# = 0;
20         right_space# = 0;
21 enddef;
24 % [Wanske] says the bulbs should be positioned about 1/4 right of the
25 % "arrow"
26 def draw_c_clef (expr reduction) = 
27         save hair, norm, reduced_il, right_edge;
28         reduced_il#=staff_space#*reduction;
29         norm#:=2/3reduced_il#;
30         hair#:=1/6norm#;
32         set_horizontal_spacing;
33         right_edge# = 15/4norm#+2hair#;
35         set_char_box (left_space#, right_edge# + right_space#, 
36                 2 reduced_il#, 2 reduced_il#);
37         define_pixels (hair,norm,reduced_il, right_edge);
39         draw_block ((0,-d), (3/4norm+1/2hair,h));
40         draw_block ((3/4norm+2hair,-d), 
41                 (3/4norm+7/2hair,h));
42         
43         save xoff;
44         xoff=3/4norm+7/2hair;
45         penpos1(hair,-90);
46         z1l=(xoff+norm+hair,h);
47         penpos2(norm-3/2hair,180);
48         z2l=(right_edge,h/2);
49         penpos3(hair,90);
50         z3=(((right_edge -xoff)/2)+xoff,2hair);
52         penpos4(hair,0);
53         z4=(xoff+1/2norm+1/2hair,reduced_il-hair);
54         
55         penpos5(4hair,0);
56         z5=(xoff+5/4hair,0);
58         penpos6(norm-hair,90);
59         z6=(xoff+3/4norm,0);
61         penpos7(hair,-90);
62         z7r=(x1,-d);
64         save t; t=0.833;
65         save p; path p;
66         p = z5l..z4l{up}..z4r{down}..z3r{right}..tension t..z2r{up}
67                 ..tension t..z1r{left}..z1l{right}..tension t..z2l{down}
68                 ..z3l{left}..z6r..z5r{down};
69         pickup pencircle scaled 1pt#;
70         filldraw p..(reverse p yscaled -1)..cycle;
71         penlabels (1,2,3,4,5,6);
73         % ugh, should be bulb, not flare?
74         draw_flare(z1l,180,90,hair,norm-1/2hair);
75         draw_flare(z7r,180,-90,hair,norm-1/2hair);
76         enddef;
78 fet_beginchar ("C clef", "C", "altoclef")
79         if test = 1:
80                 draw_staff (-2,2, 0.0);
81         fi;
82         draw_c_clef (1.0);
83 fet_endchar;
85 fet_beginchar ("C clef", "C_change", "caltoclef")
86         if test = 1:
87                 draw_staff (-2,2, 0.0);
88         fi;
89         draw_c_clef (.8);
90 fet_endchar;
93 % Inspired by Baerenreiter and Breitkopf
94
95 % FIXME: dims
96 % FIXME: right vertical tangent seems to be lower than the F-line
97 % FIXME: bulb curve smoothly into "long curve" on the  inside
100 % [Wanske] says that the extreme x point should be exactly between 
101 % the dots, but her picture shows that the extreme is ~ 0.2 ss lower
103 def draw_bass_clef(expr exact_center, reduction) = 
104         save reduced_il, left_tilt, left_thick, ball_to_right;
105         reduced_il# = staff_space# * reduction;
106         
107         set_horizontal_spacing;
108         ball_to_right# = 2.1 reduced_il#;
109         set_char_box(left_space# +
110                 - xpart exact_center,
111                 right_space# +
112                 xpart exact_center + ball_to_right# + 7/12 reduced_il#, 
113                 - ypart exact_center + 2.5 reduced_il#, 
114                 ypart exact_center +reduced_il#);
116         define_pixels(reduced_il, ball_to_right);
117         left_tilt = 5;
118         left_thick = .25  reduced_il;
120         x1r - x1l = left_thick;
121         z1l = (hround_pixels(xpart exact_center), 
122                 vround_pixels(ypart exact_center));
124         y2 = reduced_il;
126         x3l - x1l =  ball_to_right;
127         x2 = .5 [x1,x3];
128         x3l - x3r = .48 reduced_il;
129         y3l = -0.05 staff_space;
130         x4 = x1l - stafflinethickness;
131         y4 = -2.2  reduced_il;
132         z5 = (x3l +  1/3 reduced_il, .5 reduced_il);
134         penpos1(whatever, left_tilt);
135         penpos2(1.2 stafflinethickness, -90);
136         penpos3(whatever,  185);
137         penpos4(stafflinethickness, 135);
139         draw_bulb(1, z1r,  z1l, .45 reduced_il, 1.0);
142         fill z1r{up} .. z2r{right} .. tension 1.0 .. z3r{down}  .. {curl 0} 
143                 simple_serif(z4r, z4l, 90) {curl 0}
144                 .. z3l{up} .. tension 0.9 .. z2l{left} 
145                 .. z1l{dir (-90 + left_tilt)} -- cycle;
146         labels(2,4);
147         penlabels(1,2,3,4);
149         save dot_diam;
150         2 dot_diam = reduction* (staff_space - stafflinethickness);
151         pickup pencircle scaled dot_diam;
152         draw z5;
153         draw z5 yscaled -1;
154 enddef;
158 fet_beginchar("F clef ", "F", "bassclef")
159         if test = 1:
160                 draw_staff(-3,1, 0.0);
161         fi;
162         draw_bass_clef((.5 staff_space#, 0), 1.0);
163 fet_endchar;
164 fet_beginchar("F clef (reduced)", "F_change", "cbassclef")
165         draw_bass_clef((.4 staff_space#, 0),0.8);
166 fet_endchar;
171 % Inspired by Baerenreiter
173 % FIXME bulb should curve (see bass clef)
174 % FIXME start (inside) should be little thinner
175 % FIXME parametrise.
178 % Beste lezers, kijk,
180 % Een bolletje  hebben we bij toeval allemaal wel eens getekend, maar begint u
181 % toch eenvoudig.   Eerst een eenvoudig kruis of herstellingsteken
182 % en via de dubbelslag naar een voorzichtig vlaggetje, en heb geduld!
183 % Ikzelf heb bijvoorbeeld over mijn eerste gave G-sleutel
184 % 35 kilobyte metafont, 12 patchlevels, 0 vriendinnen en 45 dagen gedaan
186 %  -- vrij naar Van Kooten & De Bie
189 def draw_gclef (expr exact_center, reduction)=
190         save reduced_il, downstroke_dir, downstroke_angle, hair, center;
191         save breapth_factor, inner_thick_end, thinness, thickness, thinnib;
192         save inner_start_angle, thinness, thinpen;
193         reduced_il# = staff_space# * reduction;
194         define_pixels(reduced_il);
195         pair downstroke_dir, center;
197         center := (hround_pixels(xpart exact_center), 
198                 vround_pixels(ypart exact_center));
200         hair =  .3 stafflinethickness;
201         thinness = 1.3 stafflinethickness;
202         downstroke_dir = (14, -75);
203         breapth_factor = 11/7;
204         inner_thick_end = 45;
205         inner_start_angle = downstroke_angle - 43;
206         thickness = .4 reduced_il - hair;
208         thinnib = thinness - hair;
209         thinpen = thinness;
210         set_horizontal_spacing;
211         
212         set_char_box(
213                 left_space# +
214                 -xpart exact_center + 1.0 * breapth_factor* reduced_il#, 
215                 right_space# +
216                 xpart exact_center + .66 breapth_factor* reduced_il#,
217                 -ypart exact_center + 3 * reduced_il#,
218                 ypart exact_center + 5 * reduced_il#);
219         
220         pickup pencircle scaled hair;
221         downstroke_angle = angle downstroke_dir;
223         z1 = center + whatever * dir (inner_start_angle);
224         x1 = xpart center -.28 reduced_il;
225         
226         top z2r = center + (0,reduced_il + stafflinethickness/2);
227         
228         x4 = xpart center - .1 reduced_il;
229         bot y4r = -(reduced_il + .5 stafflinethickness);
231         z3 = (z4 - center) rotated inner_thick_end + center;
232         
233         z5r = (- breapth_factor, .37)* reduced_il + center;
234         penpos5(thickness, 135);
236         z6 = center + whatever * downstroke_dir;
237         y6 = ypart center + 2 reduced_il;
239         z7l - z6 = whatever *(z5- z6) ;
240         y7l = 3.5 reduced_il;
241         z8r = .4 [z9r, z7r] + 1.5 stafflinethickness * dir 52;
243         x9 = .7 [x10, x7r];
244         top y9l = 5 reduced_il;
246         y10 = 3. reduced_il;
247         y11 = -11/7 reduced_il;
249         y12 = ypart center - 18.5/7 reduced_il;
250         x12 = x11 - 5 /7 reduced_il;    
252         z13 = z12 + .6 reduced_il*(-1,1);
254         (z10r - z10l) dotprod (unitvector downstroke_dir rotated 90) = 
255                 thinnib;
257         center - z10= whatever * downstroke_dir;
258         center - z11 =  whatever * downstroke_dir;
259         center - z14 = .8 (center - z11);
260         penpos1(thinnib, inner_start_angle);
261         penpos2(thickness, 90);
262         penpos3(thinnib, -90 + inner_thick_end);
263         penpos4(thinnib, -90);
266         penpos7(thickness, 135);
267         penpos8(1.5 thinnib, - 70 + angle downstroke_dir);
268         penpos9(1.4 thickness, -80);  % ugh
269         penpos10(whatever, downstroke_angle + 10);
270         penpos11(thinnib, downstroke_angle + 90);
271         penpos14(thinnib, downstroke_angle + 90);
272         penpos12(thinnib, -90);
273         penpos13(3 thinnib, 180);
275         filldraw z2l{right}   .. z3l.. z4l{left} .. z5l{up}  .. z7l{up} 
276                 %.. z8l 
277                 .. tension 1.2 
278                 .. z9l & z9l ..
279                 {downstroke_dir}z10l --- z11l -- z11r --- z10r{- downstroke_dir} 
280                 .. tension .8 
281                 .. z9r & z9r{dir (downstroke_angle+ 40)} % ugh
282                 %.. z8r
283                 .. z7r{down} .. z5r{down} .. z4r{right}
284                 .. z3r .. z2r{left} .. 
285                 tension .95 .. 
286                 z1r -- z1l 
287                 .. tension 0.85 ..cycle;
289         filldraw simple_serif(z1r, z1l, 90)  -- cycle;
291         filldraw z12r{left} .. z13r{up} -- z13l{down} .. z12l{right} .. cycle;
293         draw_bulb(-1,  z13l, lft z13r, 6/14 reduced_il, 1.0);
295         pickup pencircle scaled (thinpen);
296         draw z10 --- z14 .. z11  .. tension 0.85 ..  z12{left};
298         penlabels(range 1 thru 15);
299 enddef;
302 fet_beginchar("G clef", "G", "trebleclef")
303         if test = 1:
304                 draw_staff(-1,3, 0.0);
305         fi;
306         draw_gclef((1.7 staff_space#,0), 1.0);
307 fet_endchar;
308 fet_beginchar("G clef", "G_change", "ctrebleclef")
309         draw_gclef((1.3 staff_space#,0), .8);
310 fet_endchar;
312 %%%%%%%%
316 % Editio Vaticana
320 def draw_vaticana_do_clef(expr exact_center, reduction) = 
321         save reduced_il;
323         reduced_il# = staff_space# * reduction;
324         
325         set_char_box(0.4reduced_il#, 0.4reduced_il#, 0, reduced_il#);
327         define_pixels(reduced_il);
329         pickup pencircle xscaled stafflinethickness yscaled 0.6reduced_il;
331         save za, zb, zc, zd, ze, zf;
332         pair za, zb, zc, zd, ze, zf;
334         za = exact_center + (-0.0reduced_il, -.45reduced_il);
335         zb = exact_center + (-0.2reduced_il, -.50reduced_il);
336         zc = exact_center + (-0.4reduced_il, -.25reduced_il);
337         zd = exact_center + (-0.4reduced_il, +.25reduced_il);
338         ze = exact_center + (-0.2reduced_il, +.50reduced_il);
339         zf = exact_center + (-0.0reduced_il, +.45reduced_il);
340         draw za .. zb .. zc --  % lower punctum
341              zd .. ze .. zf;    % upper punctum
342 enddef;
345 fet_beginchar("Ed. Vat. do clef", "vaticana_do", "vatdoclef")
346         if test = 1:
347                 draw_staff(-1,3, 0.0);
348         fi;
349         draw_vaticana_do_clef((0,0), 1.0);
350 fet_endchar;
351 fet_beginchar("Ed. Vat. do clef", "vaticana_do_change", "vatcdoclef")
352         draw_vaticana_do_clef((0,0), 1.0); % no reduction
353 fet_endchar;
356 def draw_vaticana_fa_clef(expr exact_center, reduction) = 
358         save reduced_il, z;
359         reduced_il# = staff_space# * reduction;
360         define_pixels(reduced_il);
362         save za, zb, zc, zd, ze;
363         pair za, zb, zc, zd, ze;
365         %stem
366         pickup pencircle scaled stafflinethickness;
367         xpart za = xpart zb =
368                 xpart exact_center + 0.4reduced_il;
369         ypart za = ypart exact_center = ypart zb + 1.5reduced_il;
370         draw za .. zb;
372         %left-handed punctum
373         pickup pencircle xscaled stafflinethickness yscaled 0.5reduced_il;
374         zc = exact_center +
375                 (+0.4reduced_il, -0.05reduced_il);
376         zd = exact_center +
377                 (+0.2reduced_il, +0.05reduced_il);
378         ze = exact_center +
379                 (+0.0reduced_il, +0.00reduced_il);
380         draw zc .. zd .. ze;
382         %right-handed puncta as in do clef
383         draw_vaticana_do_clef(
384                 exact_center +
385                 (+0.8reduced_il + 1.25stafflinethickness, 0),
386                 reduction);
388         set_char_box(0.5reduced_il#, 1.5reduced_il#, 0, reduced_il#);
389 enddef;
392 fet_beginchar("Ed. Vat. fa clef", "vaticana_fa", "vatfaclef")
393         if test = 1:
394                 draw_staff(-1,3, 0.0);
395         fi;
396         draw_vaticana_fa_clef((0,0), 1.0);
397 fet_endchar;
398 fet_beginchar("Ed. Vat. fa clef", "vaticana_fa_change", "vatcfaclef")
399         draw_vaticana_fa_clef((0,0), 1.0); % no reduction
400 fet_endchar;
402 %%%%%%%%
406 % Editio Medicaea
410 def draw_medicaea_do_clef(expr exact_center, reduction) = 
411         save reduced_il, reduced_slt;
412         reduced_il# = staff_space# * reduction;
413         reduced_slt# = stafflinethickness# * reduction;
414         define_pixels(reduced_il);
415         define_pixels(reduced_slt);
417         save flag_height;
418         flag_height# = 0.5 reduced_il#;
419         define_pixels(flag_height);
421         %lower flag
422         save za, zb;
423         pair za, zb;
424         pickup pencircle xscaled reduced_slt yscaled flag_height;
425         xpart exact_center
426                 = xpart za + 0.5 reduced_il
427                 = xpart zb - 0.5 reduced_il;
428         ypart za = ypart exact_center - 0.5 flag_height
429                         - 0.5 (staff_space - reduced_il);
430         ypart zb = ypart za - reduced_il + flag_height;
431         draw za .. zb;
433         %upper flag
434         save za, zb;
435         pair za, zb;
436         pickup pencircle xscaled reduced_slt yscaled flag_height;
437         xpart exact_center
438                 = xpart za + 0.5 reduced_il
439                 = xpart zb - 0.5 reduced_il;
440         ypart za = ypart exact_center - 0.5 flag_height
441                         - 0.5 (staff_space - reduced_il)
442                         + staff_space;
443         ypart zb = ypart za - reduced_il + flag_height;
444         draw za .. zb;
446         %stem
447         save za, zb;
448         pair za, zb;
449         pickup pencircle scaled reduced_slt;
450         xpart za = xpart zb = xpart exact_center - 0.5 reduced_il;
451         ypart exact_center
452                 = ypart za + 1.5 reduced_il
453                 = ypart zb - 1.5 reduced_il;
454         draw za .. zb;
456         set_char_box(0.5reduced_il#, 1.5reduced_il#,
457                      1.5reduced_il#, 1.5reduced_il#);
458 enddef;
461 fet_beginchar("Ed. Med. do clef", "medicaea_do", "meddoclef")
462         if test = 1:
463                 draw_staff(-1,3, 0.0);
464         fi;
465         draw_medicaea_do_clef((0,0), 1.0);
466 fet_endchar;
467 fet_beginchar("Ed. Med. do clef", "medicaea_do_change", "cmeddoclef")
468         draw_medicaea_do_clef((0,0), .8);
469 fet_endchar;
472 def draw_medicaea_fa_clef(expr exact_center, reduction) = 
473         % inspired by Regensburger Edition of Medicaea (1885/86), in:
474         % MGG, volume 2, col. 1327 ("Choralreform"), fig. 2.
476         save reduced_il, reduced_slt;
477         reduced_il# = staff_space# * reduction;
478         reduced_slt# = stafflinethickness# * reduction;
479         define_pixels(reduced_il);
480         define_pixels(reduced_slt);
482         save za, zb, zc, zd, ze;
483         pair za, zb, zc, zd, ze;
485         %stem
486         pickup pencircle scaled stafflinethickness;
487         xpart za = xpart zb =
488                 xpart exact_center + 0.4reduced_il;
489         ypart za = ypart exact_center = ypart zb + 1.5reduced_il;
490         draw za -- zb;
492         %left-handed punctum
493         pickup pencircle xscaled reduced_slt yscaled reduced_il;
494         zc = exact_center +
495                 (+0.4reduced_il, 0);
496         zd = exact_center +
497                 (+0.0reduced_il, 0);
498         draw zc -- zd;
500         %right-handed puncta as in do clef
501         draw_medicaea_do_clef(
502                 exact_center +
503                 (+1.1reduced_il + 1.25stafflinethickness, 0),
504                 reduction);
506         set_char_box(reduced_il#/2, 2.6reduced_il#, 0, reduced_il#);
507 enddef;
510 fet_beginchar("Ed. Med. fa clef", "medicaea_fa", "medfaclef")
511         if test = 1:
512                 draw_staff(-1,3, 0.0);
513         fi;
514         draw_medicaea_fa_clef((0,0), 1.0);
515 fet_endchar;
516 fet_beginchar("Ed. Med. fa clef", "medicaea_fa_change", "cmedfaclef")
517         draw_medicaea_fa_clef((0,0), .8);
518 fet_endchar;
521 %%%%%%%%
525 % Mensural Notation
529 brevis_wid# := 2 staff_space#;
531 def draw_brevis(expr exact_center, reduction, small_width, small_height) =
532         %
533         % inspired by function draw_brevis of
534         % feta-bolletjes.mf
535         %
536         save reduced_slt, reduced_nht;
537         save stem_width, head_width;
538         save serif_size, serif_protrude;
539         save holeheight, beamheight;
541         reduced_slt# = stafflinethickness# * reduction;
542         reduced_nht# = noteheight# * reduction;
543         stem_width# = 1.4 reduced_slt#;
544         if small_width:
545                 head_width# = 0.5brevis_wid# * reduction;
546         else:
547                 head_width# = brevis_wid# * reduction;
548         fi;
549         if small_height:
550                 serif_size# = 0.64 reduced_slt#;
551                 serif_protrude# = 0.96 serif_size#;
552                 holeheight# = 3 reduced_slt#;
553                 beamheight# = 0.32(reduced_nht# - holeheight#);
554         else:
555                 serif_size# = 1.0 reduced_slt#;
556                 serif_protrude# = 1.5 serif_size#;
557                 holeheight# = 3 reduced_slt#;
558                 beamheight# = 0.5(reduced_nht# - holeheight#);
559         fi;
560         define_pixels(reduced_slt);
561         define_pixels(stem_width);
562         define_pixels(head_width);
563         define_pixels(serif_size);
564         define_pixels(serif_protrude);
565         define_pixels(beamheight);
567         penpos1(stem_width, 0);
568         penpos2(stem_width, 0);
569         penpos3(beamheight, 90);
570         penpos4(beamheight, 90);
571         penpos5(stem_width, 180);
573         z1l = exact_center;
574         z2l = z1l + (0, -reduced_slt/2);
575         z3r = z2r + serif_size*(1,-1);
576         y4r = y3r;
577         x4l = x1l + head_width/2;
578         z5l = z3l + (-serif_size, -serif_protrude);
580         penlabels(1,2,3,4,5);
581         fill z1r -- z1l -- z5r{down} .. z5l{up} .. z3l{right}
582                 -- z4l -- z4r -- z3r{left} .. z2r{up} -- cycle;
583 enddef;
586 def draw_neo_mensural_c_clef(expr exact_center, reduction) = 
587         draw_brevis(exact_center, reduction, false, false);
589         save reduced_il, reduced_slt;
590         save stem_width;
592         reduced_il# = staff_space# * reduction;
593         reduced_slt# = stafflinethickness# * reduction;
594         stem_width# = 1.4 reduced_slt#;
596         define_pixels(reduced_il);
597         define_pixels(reduced_slt);
598         define_pixels(stem_width);
600         penpos6(stem_width, 0);
601         penpos7(stem_width, 0);
602         z6l = exact_center;
603         z7l = z6l + (0, -2reduced_il);
604         fill z6l -- z7l -- z7r -- z6r -- cycle;
605         penpos8(stem_width, 0);
606         penpos9(stem_width, 0);
607         z8l = z6l + (-3reduced_slt, 0);
608         z9l = z8l + (0, -2reduced_il);
609         fill z8l -- z9l -- z9r -- z8r -- cycle;
611         addto currentpicture also currentpicture
612                 yscaled -1 shifted (0, 2*(ypart exact_center));
613         addto currentpicture also currentpicture 
614                 xscaled -1 shifted (2x4l,0);
616         set_char_box(0, 2head_width#,
617                      6reduced_slt#*reduction, 6reduced_slt#*reduction);
618 enddef;
621 fet_beginchar("neo-mensural c clef", "neo_mensural_c", "neomenscclef")
622         if test = 1:
623                 draw_staff(-1,3, 0.0);
624         fi;
625         draw_neo_mensural_c_clef((0,0), 1.0);
626 fet_endchar;
627 fet_beginchar("neo-mensural c clef", "neo_mensural_c_change", "cneomenscclef")
628         draw_neo_mensural_c_clef((1.3 staff_space#,0), .8);
629 fet_endchar;
632 def draw_petrucci_c_clef(expr exact_center, reduction) = 
633         % inspired by Josquin Desprez, "Stabat Mater", Libro tertio,
634         % 1519, printed by Petrucci, in: MGG, volume 7, Table 11.
635         draw_brevis(exact_center, reduction, true, true);
637         save reduced_il, reduced_slt;
638         save stem_width, interline;
640         reduced_il# = staff_space# * reduction;
641         reduced_slt# = stafflinethickness# * reduction;
642         stem_width# = 1.4 reduced_slt#;
643         interline# = staff_space#;
645         define_pixels(reduced_il);
646         define_pixels(reduced_slt);
647         define_pixels(stem_width);
648         define_pixels(interline);
650         addto currentpicture also currentpicture
651                 yscaled -1 shifted (0, 2*(ypart exact_center) - interline);
653         penpos6(stem_width, 0);
654         penpos7(stem_width, 0);
655         z6l = exact_center + (0, 0);
656         z7l = z6l + (0, -2.2reduced_il);
657         fill z6l -- z7l -- z7r -- z6r -- cycle;
659         addto currentpicture also currentpicture 
660                 xscaled -1 shifted (2x4l,0);
662         penpos8(stem_width, 0);
663         penpos9(stem_width, 0);
664         z8l = exact_center + (0, 0);
665         z9l = z8l + (0, -3.2reduced_il);
666         fill z8l -- z9l -- z9r -- z8r -- cycle;
668         addto currentpicture also currentpicture
669                 yscaled -1 shifted (0, 4*(ypart exact_center));
671         set_char_box(0, 2head_width#,
672                      noteheight#*4*reduction, noteheight#*4*reduction);
673 enddef;
676 fet_beginchar("petrucci c clef", "petrucci_c", "petruccicclef")
677         if test = 1:
678                 draw_staff(-1,3, 0.0);
679         fi;
680         draw_petrucci_c_clef((0,0), 1.0);
681 fet_endchar;
682 fet_beginchar("petrucci c clef", "petrucci_c_change", "cpetruccicclef")
683         draw_petrucci_c_clef((1.3 staff_space#,0), .8);
684 fet_endchar;
687 def draw_mensural_c_clef(expr exact_center, reduction) =
688         % inspired by Ockeghem, "Missa Prolationum", in: MGG, volume
689         % 9, table 94.
690         draw_petrucci_c_clef(exact_center, reduction);
692         addto currentpicture also currentpicture
693                 shifted (0, -interline);
695         set_char_box(0, 2head_width#,
696                      noteheight#*6*reduction, noteheight#*6*reduction);
697 enddef;
700 fet_beginchar("mensural c clef", "mensural_c", "menscclef")
701         if test = 1:
702                 draw_staff(-1,3, 0.0);
703         fi;
704         draw_mensural_c_clef((0,0), 1.0);
705 fet_endchar;
706 fet_beginchar("mensural c clef", "mensural_c_change", "cmenscclef")
707         draw_mensural_c_clef((0,0), .8);
708 fet_endchar;
710 def draw_diamond(expr exact_center, reduction) =
711         save stem_width, reduced_il, reduced_nht, holeheight, beamheight;
712         save rh_height, rh_width;
714         stem_width# = 1.4 reduced_slt#;
715         reduced_il# = staff_space# * reduction;
716         reduced_nht# = noteheight# * reduction;
717         holeheight# = 3 reduced_slt#;
718         beamheight# = 0.4(reduced_nht# - holeheight#);
720         rh_height# = 1.2reduced_il#;
721         rh_width# / rh_height# = 0.58; % tan(30)
723         define_pixels(beamheight);
724         define_pixels(stem_width);
725         define_pixels(rh_height);
726         define_pixels(rh_width);
728         pickup pencircle
729                 xscaled beamheight
730                 yscaled stem_width
731                 rotated 45;
733         draw
734                 exact_center + (-rh_width/2, 0) --
735                 exact_center + (0, rh_height/2) --
736                 exact_center + (+rh_width/2, 0) --
737                 exact_center + (0, -rh_height/2) --
738                 cycle;
739 enddef;
741 def draw_petrucci_f_clef(expr exact_center, reduction) =
742         % inspired by L'homme arme super voces musicales in Misse
743         % Josquin, 1502, Petrucci, in: MGG, volume 7, col. 200; also
744         % inspired by Gaspar van Weerbeke, "Virgo Maria" (1502), in:
745         % MGG, volume 9, col. 653 ("Motette"), fig. 3.; also by Andr'e
746         % Campra, "Entr'ee des s'er'enades" (1710), in: MGG, volume 2,
747         % col. 1649 ("Contredanse"), fig. 2.
748         %
749         draw_brevis(exact_center, reduction, true, false);
751         save reduced_il, reduced_slt;
752         save stem_width, interline;
754         reduced_il# = staff_space# * reduction;
755         reduced_slt# = stafflinethickness# * reduction;
756         stem_width# = 1.4 reduced_slt#;
757         interline# = staff_space#;
759         define_pixels(reduced_il);
760         define_pixels(reduced_slt);
761         define_pixels(stem_width);
762         define_pixels(interline);
764         addto currentpicture also currentpicture
765                 yscaled -1 shifted (0, 2*(ypart exact_center));
766         addto currentpicture also currentpicture 
767                 xscaled -1 shifted (2x4l,0);
769         penpos6(stem_width, 0);
770         penpos7(stem_width, 0);
771         z6r = exact_center + (2x4l, 0);
772         z7r = z6r + (0, -4reduced_il);
773         fill z6l -- z7l -- z7r -- z6r -- cycle;
775         draw_diamond(exact_center +
776                      (1.6interline*reduction, interline/2), reduction);
778         % upper stem
779         penpos8(stem_width, 0);
780         penpos9(stem_width, 0);
781         z8l = exact_center + (1.6interline*reduction, interline*reduction);
782         z9l = z8l + (0, 1.5interline*reduction);
783         fill z8l -- z9l -- z9r -- z8r -- cycle;
785         draw_diamond(exact_center +
786                      (1.6interline*reduction, -interline/2), reduction);
787         penpos10(stem_width, 0);
788         penpos11(stem_width, 0);
789         z10r = exact_center + (1.6interline*reduction, -interline*reduction);
790         z11r = z10r + (0, -3.5interline*reduction);
791         fill z10l -- z11l -- z11r -- z10r -- cycle;
793         set_char_box(0, 3head_width#,
794                      3.5noteheight#*reduction, 1.5noteheight#*reduction);
795 enddef;
798 fet_beginchar("petrucci f clef", "petrucci_f", "petruccifclef")
799         if test = 1:
800                 draw_staff(-1,3, 0.0);
801         fi;
802         draw_petrucci_f_clef((0,0), 1.0);
803 fet_endchar;
804 fet_beginchar("petrucci f clef", "petrucci_f_change", "cpetruccifclef")
805         draw_petrucci_f_clef((0,0), .8);
806 fet_endchar;
809 def draw_mensural_f_clef(expr exact_center, reduction) =
810         %
811         % inspired by Philippe le Duc, "Dite Signori" (1590), in: MGG,
812         % volume 3, col. 848 ("Duc"); also by John Dowland, "The First
813         % Booke of Songes" (1597), in: MGG, volume 3, col. 721
814         % ("Dowland"), fig. 3.
816         save reduced_slt, stem_width, reduced_nht, holeheight, beamheight;
818         reduced_slt# = stafflinethickness# * reduction;
819         stem_width# = 1.4 reduced_slt#;
820         reduced_nht# = noteheight# * reduction;
821         holeheight# = 3 reduced_slt#;
822         beamheight# = 0.4(reduced_nht# - holeheight#);
824         define_pixels(beamheight, stem_width, staff_space);
826         pickup pencircle
827                 xscaled beamheight
828                 yscaled stem_width
829                 rotated 45;
831         draw
832                 exact_center + (1.0 staff_space, 0.6 staff_space) --
833                 exact_center + (1.25 staff_space, 0.4 staff_space);
835         draw
836                 exact_center + (1.0 staff_space, -0.4 staff_space) --
837                 exact_center + (1.25 staff_space, -0.6 staff_space);
839         draw    halfcircle scaled 1.2 staff_space rotated -90
840                 shifted (-exact_center + (+0.1 staff_space, 0));
842         set_char_box(0, 3staff_space#, 3staff_space#, 0);
843 enddef;
845 fet_beginchar("mensural f clef", "mensural_f", "mensfclef")
846         if test = 1:
847                 draw_staff(-1,3, 0.0);
848         fi;
849         draw_mensural_f_clef((0,0), 1.0);
850 fet_endchar;
851 fet_beginchar("mensural f clef", "mensural_f_change", "cmensfclef")
852         draw_mensural_f_clef((0,0), .8);
853 fet_endchar;
856 def draw_mensural_g_clef(expr exact_center, reduction) =
857         %
858         % inspired by Francisco Guerrero, "Lib. 1.  Missarum" (1566),
859         % in: MGG, volume 3, col. 858 ("Ducis"); also by Stefano
860         % Fabri, "Quam speciosa veteranis" (1611), in: MGG, volume 3,
861         % col. 1698 ("Fabri"); also by Philippus Dulichius,
862         % "Fasciculus novus ..." (1598), in: MGG, volume 3, col. 919
863         % ("Dulichius"), fig. 1; also by Noe Faignient, "Ic sal de
864         % Heer myn God gebenedye" (1568), in: MGG, volume 3, col. 1735
865         % ("Faignient").
866         %
867         % Metafont code partially inspired by Schwabacher 'G' of yswab
868         % font.
870         save reduced_il, stem_width, height, width, apex_o, hair;
872         reduced_il#=staff_space#*reduction;
874         set_char_box(0.5reduced_il#, 1.5reduced_il#,
875                      1.5reduced_il#, 1.5reduced_il#);
877         stem_width# = 0.17 reduced_il#;
878         height# = 1.5 reduced_il#;
879         width# = 1.13 reduced_il#;
880         apex_o# = 0.02 reduced_il#;
881         hair# =  3 stafflinethickness#;
882         define_pixels(reduced_il, stem_width, height, width, apex_o, hair);
884         penpos1(2 stem_width, -142);
885         z1l = (0.715 width, 0.742 height);
886         penpos1'(hair, -90);
887         z1'l = z1r;
888         penpos2(1.179 stem_width, -142);
889         z2l = (width, 0.466 height);
890         penpos3(hair, 77);
891         z3 = (0.764 width, 0.067 height); 
892         z4 = (0.59 width, -apex_o);
893         penpos5(1.179 stem_width, 32);
894         z5l=(0, 0.457 height);
895         penpos6(hair, -56.5);
896         z7 = (x4 - 0.843 stem_width, height + apex_o);
897         z7 - z6l = whatever * dir33.5;
898         penpos8(1.286 stem_width, -130);
899         z8r = (0.715 width, 0.742 height) + (-apex_o, apex_o);
900         z6r - z8r = whatever * (z7 - z8l);
901         filldraw
902                 z1'r{dir45} .. z2r{down} .. z3r{dir207} .. z5r{up} ..
903                 z6r{z7-z6l} & z6r -- z8r -- z8l -- z7 --- z6l ...
904                 z5l{down} .. z4{right} .. z3l{dir27} .. z2l{up} ..
905                 z1l{1/3[z6l,z7]-z1l} & z1l -- z1r -- z1'r & cycle
906                 shifted (-exact_center + (0, -0.75reduced_il));
908         penpos9(stem_width, 0);
909         x9r = x4; y9 = 0.3 height;
911         pickup pencircle
912                 scaled stem_width
913                 rotated 45;
914         draw    z9 -- (z9 + (0, -0.4reduced_il))
915                 shifted (-exact_center + (0, -0.75reduced_il));
917         pickup pencircle
918                 xscaled stem_width
919                 yscaled hair
920                 rotated 30;
922         draw halfcircle
923                 scaled 0.5 reduced_il
924                 rotated -90
925                 shifted z8
926                 shifted (0, 0.25reduced_il)
927                 shifted (-exact_center + (0, -0.75reduced_il));
929         draw halfcircle
930                 scaled 0.4 reduced_il
931                 rotated 90
932                 shifted (z8 + (0, 0.45 reduced_il))
933                 shifted (0, 0.25reduced_il)
934                 shifted (-exact_center + (0, -0.75reduced_il));
935 enddef;
938 fet_beginchar("mensural g clef", "mensural_g", "mensgclef")
939         if test = 1:
940                 draw_staff(-1,3, 0.0);
941         fi;
942         draw_mensural_g_clef((0,0), 1.0);
943 fet_endchar;
944 fet_beginchar("mensural g clef", "mensural_g_change", "cmensgclef")
945         draw_mensural_g_clef((0,0), .8);
946 fet_endchar;
950 def draw_petrucci_g_clef(expr exact_center, reduction) =
951         % inspired by Josquin Desprez, "Stabat Mater", Libro tertio,
952         % 1519, printed by Petrucci, in: MGG, volume 7, Table 11.
954         set_char_box(0.6 staff_space#, 0.8 staff_space#, 0.6 staff_space#, 
955           4.0 staff_space#);
957         save reduced_il, reduced_slt;
959         reduced_il# = staff_space# * reduction;
960         reduced_slt# = stafflinethickness# * reduction;
961         define_pixels(reduced_il, reduced_slt);
963         save za, zb, zc, zd, ze, zf, zg, zh, zi, zj;
964         pair za, zb, zc, zd, ze, zf, zg, zh, zi, zj;
966         pickup pencircle
967                 xscaled 0.50 reduced_slt
968                 yscaled 0.22 reduced_il
969                 rotated -35;
971         za = exact_center + (+0.00 reduced_il, +0.00 reduced_il);
972         zb = exact_center + (+0.20 reduced_il, +1.20 reduced_il);
973         zc = exact_center + (-0.10 reduced_il, +2.00 reduced_il);
974         zd = exact_center + (-0.50 reduced_il, +3.00 reduced_il);
975         ze = exact_center + (+0.00 reduced_il, +3.70 reduced_il);
976         zf = exact_center + (+0.20 reduced_il, +3.00 reduced_il);
977         zg = exact_center + (-0.20 reduced_il, +2.00 reduced_il);
978         zh = exact_center + (-0.50 reduced_il, +1.70 reduced_il);
979         zi = exact_center + (-0.80 reduced_il, +0.75 reduced_il);
980         zj = exact_center + (-0.60 reduced_il, +0.60 reduced_il);
982         draw za{-1,2} .. zb .. zc .. zd .. ze .. zf .. zg .. zh .. zi .. zj;
984         save za, zb, zc, zd, ze, zf;
985         pair za, zb, zc, zd, ze, zf;
987         pickup pencircle
988                 xscaled 0.75 reduced_slt
989                 yscaled 0.33 reduced_il
990                 rotated -35;
992         za = exact_center + (+0.25 reduced_il, +0.45 reduced_il);
993         zb = exact_center + (-0.25 reduced_il, +0.45 reduced_il);
994         zc = exact_center + (-0.25 reduced_il, -0.45 reduced_il);
995         zd = exact_center + (+0.25 reduced_il, -0.45 reduced_il);
996         ze = exact_center + (+0.30 reduced_il, +0.00 reduced_il);
997         zf = exact_center + (+0.00 reduced_il, +0.00 reduced_il);
999         draw za .. zb .. zc .. zd .. {up}ze -- zf;
1000 enddef;
1003 fet_beginchar("petrucci g clef", "petrucci_g", "petruccigclef")
1004         if test = 1:
1005                 draw_staff(-1,3, 0.0);
1006         fi;
1007         draw_petrucci_g_clef((0,0), 1.0);
1008 fet_endchar;
1009 fet_beginchar("petrucci g clef", "petrucci_g_change", "cpetruccigclef")
1010         draw_petrucci_g_clef((0,0), .8);
1011 fet_endchar;
1015 %%%%%%%%
1019 % Hufnagel
1023 def draw_hufnagel_do_clef(expr exact_center, reduction) =
1024         %
1025         % inspired by Graduale of Friedrich Zollner (1442), in: MGG,
1026         % volume 9, col. 1413 ("Neustift"), fig. 1.
1027         %
1028         save reduced_il;
1030         reduced_il# = staff_space# * reduction;
1032         define_pixels(reduced_il);
1034         pickup pencircle
1035                 xscaled (0.60reduced_il)
1036                 yscaled (0.10reduced_il)
1037                 rotated 40;
1038         save za, zb, zc, zd, ze, zf;
1039         pair za, zb, zc, zd, ze, zf;
1041         za = exact_center + (+0.30reduced_il, +.45reduced_il);
1042         zb = exact_center + (+0.20reduced_il, +.45reduced_il);
1043         zc = exact_center + (-0.10reduced_il, +.60reduced_il);
1044         zd = exact_center + (-0.40reduced_il, +.45reduced_il);
1045         ze = exact_center + (-0.40reduced_il, -.45reduced_il);
1046         zf = exact_center + (-0.20reduced_il, -.55reduced_il);
1047         draw za .. zb .. zc -- zd -- ze -- zf;
1049         set_char_box(0.5reduced_il#, 0.5reduced_il#, 0, reduced_il#);
1050 enddef;
1053 fet_beginchar("Hufnagel do clef", "hufnagel_do", "hufnageldoclef")
1054         if test = 1:
1055                 draw_staff(-1,3, 0.0);
1056         fi;
1057         draw_hufnagel_do_clef((0,0), 1.0);
1058 fet_endchar;
1059 fet_beginchar("Hufnagel do clef", "hufnagel_do_change", "chufnageldoclef")
1060         draw_hufnagel_do_clef((1.3 staff_space#,0), .8);
1061 fet_endchar;
1064 def draw_hufnagel_fa_clef(expr exact_center, reduction) =
1065         %
1066         % inspired by Bamberger Manuscript (15th century), in:
1067         % MGG, volume 2, table 59.
1068         %
1069         save reduced_il;
1071         reduced_il# = staff_space# * reduction;
1073         define_pixels(reduced_il);
1075         pickup pencircle
1076                 xscaled (0.60reduced_il)
1077                 yscaled (0.10reduced_il)
1078                 rotated 40;
1079         save za, zb, zc, zd, ze, zf;
1080         pair za, zb, zc, zd, ze, zf;
1082         za = exact_center + (+0.30reduced_il, +0.70reduced_il);
1083         zb = exact_center + (+0.20reduced_il, +0.70reduced_il);
1084         zc = exact_center + (-0.10reduced_il, +0.85reduced_il);
1085         zd = exact_center + (-0.40reduced_il, +0.70reduced_il);
1086         ze = exact_center + (-0.40reduced_il, -1.10reduced_il);
1087         draw za .. zb .. zc -- zd -- ze;
1089         save zg, zh, zi, zj;
1090         pair zg, zh, zi, zj;
1092         zg = exact_center + (+0.30reduced_il, -0.05reduced_il);
1093         zh = exact_center + (+0.20reduced_il, -0.05reduced_il);
1094         zi = exact_center + (-0.10reduced_il, +0.10reduced_il);
1095         zj = exact_center + (-0.40reduced_il, -0.05reduced_il);
1096         draw zg .. zh .. zi -- zj;
1098         set_char_box(0.5reduced_il#, 0.5reduced_il#, 0, reduced_il#);
1099 enddef;
1102 fet_beginchar("Hufnagel fa clef", "hufnagel_fa", "hufnagelfaclef")
1103         if test = 1:
1104                 draw_staff(-1,3, 0.0);
1105         fi;
1106         draw_hufnagel_fa_clef((0,0), 1.0);
1107 fet_endchar;
1108 fet_beginchar("Hufnagel fa clef", "hufnagel_fa_change", "chufnagelfaclef")
1109         draw_hufnagel_fa_clef((0,0), .8);
1110 fet_endchar;
1113 def draw_hufnagel_do_fa_clef(expr exact_center, reduction) =
1114         draw_hufnagel_do_clef(exact_center, reduction);
1115         draw_hufnagel_fa_clef(exact_center + (0, -2staff_space), reduction);
1116 enddef;
1119 fet_beginchar("Hufnagel do/fa clef", "hufnagel_do_fa", "hufnageldofaclef")
1120         if test = 1:
1121                 draw_staff(-1,3, 0.0);
1122         fi;
1123         draw_hufnagel_do_fa_clef((0,0), 1.0);
1124 fet_endchar;
1125 fet_beginchar("Hufnagel do/fa clef", "hufnagel_do_fa_change",
1126               "chufnageldofaclef")
1127         draw_hufnagel_do_fa_clef((0,0), .8);
1128 fet_endchar;
1130 def draw_percussion_clef(expr reduction) =
1131         save reduced_il;
1132         reduced_il# = staff_space# * reduction;
1133         define_pixels(reduced_il);
1134         set_char_box(-.67reduced_il#,2.0reduced_il#,reduced_il#,reduced_il#);
1135         razt := 0.45reduced_il;
1136         pickup penrazor scaled razt;
1137         draw (-b+razt/2,h) -- (-b+razt/2,-d);
1138         draw (w-razt/2,h) -- (w-razt/2,-d);
1139 enddef;
1141 fet_beginchar("percussion clef", "percussion", "percussionclef")
1142         draw_percussion_clef(1.0);
1143 fet_endchar;
1145 fet_beginchar("percussion clef", "percussion_change", "cpercussionclef")
1146         draw_percussion_clef(.8);
1147 fet_endchar;
1149 def draw_tab_clef(expr reduction) =
1150         save reduced_il;
1151         reduced_il# = staff_space# * reduction;
1152         define_pixels(reduced_il);
1153         set_char_box(-.5reduced_il#,1.8reduced_il#,2.25reduced_il#,2.25reduced_il#);
1154         bs := -d+0.65reduced_il;
1155         cx := 0.5(-b+w);
1156         xp := 0.32 reduced_il;
1157         yp := 0.25reduced_il;
1158         pickup pensquare xscaled xp yscaled yp;
1160         draw (-b,h) -- (w,h);
1161         draw (cx,h) -- (cx,h-1.2reduced_il);
1163         pickup penrazor scaled yp rotated 90;
1164         draw (-0.85b+0.15w,-0.25reduced_il) -- (-0.15b+0.85w,-0.25reduced_il);
1165         pickup penrazor scaled xp;
1166         draw (-b,-0.6reduced_il-yp/2) -- (cx,0.6reduced_il+yp/2) -- (w,-0.6reduced_il-yp/2);
1169         pickup pensquare xscaled xp yscaled yp;
1170         draw (-b,-d+1.2reduced_il) -- (-b,-d);
1171         pickup pencircle xscaled xp yscaled yp;
1172         draw (-b,-d) --- (cx,-d) .. (w,0.5(bs-d)) .. (cx,bs) --- (-b,bs) --- (cx,bs)
1173              .. (0.3cx+0.7w,0.5(bs-d+1.2reduced_il)) .. (cx,-d+1.2reduced_il) --- (-b,-d+1.2reduced_il)
1174 enddef;
1176 fet_beginchar("tab clef", "tab", "tabclef")
1177         draw_tab_clef(1.0);
1178 fet_endchar;
1180 fet_beginchar("tab clef", "tab_change", "ctabclef")
1181         draw_tab_clef(.8);
1182 fet_endchar;
1184 fet_endgroup("clefs");