]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-toevallig.mf
Run `make grand-replace'.
[lilypond.git] / mf / feta-toevallig.mf
1 %
2 % feta-toevallig.mf -- implement Accidentals
3 %
4 % (c) 1997--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
5 %
6
7
8 %
9 % also show in other configuration wrt staff lines.
10 %
11 def draw_shifted_too =
12 if test > 0:
13         fet_beginchar ("shifted too", "");
14                 set_char_box (0, 0, 0, 0);
15                 currentpicture := remember_pic;
16
17                 draw_staff (-2, 2, 0.5);
18         fet_endchar;
19 fi;
20 enddef;
21
22
23 %
24 % Accidentals from various sources, notably
25 %
26 %   Baerenreiter edition of Schuberts `Auf dem Strom' (sharp, natural)
27 %   F Hofmeister edition of Muellers `Etueden fuer Horn' (double sharp, flat)
28 %
29
30
31 %
32 % Naming for accidentals (including microtonal variants):
33 %
34 %   SHARPBASE[.SLASHES.STEMS]
35 %   FLATBASE[.MODIFIER]
36 %  
37 % Examples:
38 %
39 %   sharp.slashslash.stem
40 %   mirroredflat.flat
41 %
42 %
43
44
45 fet_begingroup ("accidentals");
46
47
48 save remember_pic;
49 picture remember_pic;
50
51 save sharp_beamheight;
52 sharp_beamheight# := 0.3 staff_space# + stafflinethickness#;
53
54 %
55 % The beams of most sharps have horizontal endings (as if drawn with
56 % a square pen).  [Wanske] does not mention this, so we'll just ignore
57 % this fact.
58 %
59
60 def draw_meta_sharp (expr width, offset) =
61         save beamwidth, beamslope;
62         save ne, nw_dist;
63         pair ne, nw_dist;
64
65         beamwidth := width;
66
67         define_whole_vertical_blacker_pixels (sharp_beamheight);
68
69         clearxy;
70
71         beamslope = sharp_beamheight / beamwidth;
72
73         pickup pencircle scaled 2 blot_diameter;
74
75         rt x2 - lft x1 = beamwidth;
76         z2 = z1 + whatever * (beamwidth, sharp_beamheight);
77         .5 [z1, z3] = (.5 w, offset);
78         x3 = x2;
79         top y2 - bot y3 = sharp_beamheight;
80         x4 = x1;
81         top y1 - bot y4 = sharp_beamheight;
82
83         ne = unitvector (z2 - z1);
84         nw_dist = (ne rotated 90) * blot_diameter;
85
86         fill lft z1{up}
87              ... (z1 + nw_dist){ne}
88              -- (z2 + nw_dist){ne}
89              ... rt z2{down}
90              -- rt z3{down}
91              ... (z3 - nw_dist){-ne}
92              -- (z4 - nw_dist){-ne}
93              ... lft z4{up}
94              -- cycle;
95
96         labels (1, 2, 3, 4);
97 enddef;
98
99
100 fet_beginchar ("Sharp", "sharp");
101         save stem, stemx, stemwidth;
102         save outer_space, interbeam;
103
104         stemwidth# := stafflinethickness# + .05 staff_space#;
105         define_whole_blacker_pixels (stemwidth);
106
107         interbeam := 1.05 staff_space_rounded;
108
109         set_char_box (0, 1.1 staff_space#,
110                       1.5 staff_space#, 1.5 staff_space#);
111
112         stem := 7 / 16 * w;
113         stemx := hround stem;
114         outer_space := hround ((w - stemx - stemwidth) / 2);
115
116         w := 2 outer_space + stemx + stemwidth;
117         d := d - feta_space_shift;
118
119         draw_meta_sharp (w, -.5 interbeam);
120         draw_meta_sharp (w, -.5 interbeam + vround interbeam);
121
122         pickup pencircle scaled stemwidth;
123
124         lft x5 = lft x6 = outer_space;
125         lft x7 = lft x8 = outer_space + stemx;
126         bot y5 = -d;
127         top y6 = vround (1.5 staff_space - stem * beamslope);
128         bot y7 = -top y6 + feta_space_shift;
129         top y8 = h;
130
131         labels (5, 6, 7, 8);    
132
133         draw_gridline (z5, z6, stemwidth);
134         draw_gridline (z7, z8, stemwidth);
135
136         remember_pic := currentpicture;
137
138         draw_staff (-2, 2, 0);
139 fet_endchar;
140
141
142 draw_shifted_too;
143
144
145 fet_beginchar ("1/2 Sharp", "sharp.slashslash.stem");
146         save stem, stemwidth;
147         save outer_space, interbeam;
148
149         stemwidth# := stafflinethickness# + .05 staff_space#;
150         define_whole_blacker_pixels (stemwidth);
151
152         interbeam := 1.05 staff_space_rounded;
153
154         set_char_box (0, 0.7 staff_space#,
155                       1.5 staff_space#, 1.5 staff_space#);
156
157         stem := 7 / 16 * w;
158         outer_space := hround ((w - stemwidth) / 2);
159
160         w := 2 outer_space + stemwidth;
161         d := d - feta_space_shift;
162
163         draw_meta_sharp (w, -.5 interbeam);
164         draw_meta_sharp (w, -.5 interbeam + vround interbeam);
165
166         pickup pencircle scaled stemwidth;
167
168         lft x5 = lft x6 = outer_space;
169         top y6 = vround (1.5 staff_space - .5 stem);
170         bot y5 = -top y6 + feta_space_shift;
171
172         labels (5, 6);
173
174         draw_gridline (z5, z6, stemwidth);
175
176         remember_pic := currentpicture;
177
178         draw_staff (-2, 2, 0);
179 fet_endchar;
180
181
182 draw_shifted_too;
183
184
185 fet_beginchar ("Sharp (3 beams)", "sharp.slashslashslash.stemstem");
186         save stem, stemx, stemwidth;
187         save outer_space, interbeam;
188         save sharp_beamheight;
189
190         sharp_beamheight# := 0.22 staff_space# + stafflinethickness#;
191
192         stemwidth# := stafflinethickness# + .05 staff_space#;
193         define_whole_blacker_pixels (stemwidth);
194
195         interbeam := 1.2 staff_space_rounded;
196
197         set_char_box (0, 1.1 staff_space#,
198                       1.5 staff_space#, 1.5 staff_space#);
199
200         stem := 7 / 16 * w;
201         stemx := hround stem;
202         outer_space := hround ((w - stemx - stemwidth) / 2);
203
204         w := 2 outer_space + stemx + stemwidth;
205         d := d - feta_space_shift;
206
207         draw_meta_sharp (.88 w, -.5 interbeam);
208         draw_meta_sharp (.88 w, -.5 interbeam + vround interbeam);
209         sharp_beamheight# := 1/.88 sharp_beamheight#;
210         draw_meta_sharp (w, 0);
211
212         pickup pencircle scaled stemwidth;
213
214         lft x5 = lft x6 = outer_space;
215         lft x7 = lft x8 = outer_space + stemx;
216         bot y5 = -d;
217         top y6 = vround (1.5 staff_space - stem * beamslope);
218         bot y7 = -top y6 + feta_space_shift;
219         top y8 = h;
220
221         labels (5, 6, 7, 8);    
222
223         draw_gridline (z5, z6, stemwidth);
224         draw_gridline (z7, z8, stemwidth);
225
226         remember_pic := currentpicture;
227
228         draw_staff (-2, 2, 0);
229 fet_endchar;
230
231
232 draw_shifted_too;
233
234
235 fet_beginchar ("1/2 Sharp (3 beams)", "sharp.slashslashslash.stem");
236         save stem, stemx, stemwidth;
237         save outer_space, interbeam;
238         save sharp_beamheight;
239
240         sharp_beamheight# := 0.22 staff_space# + stafflinethickness#;
241
242         stemwidth# := stafflinethickness# + .05 staff_space#;
243         define_whole_blacker_pixels (stemwidth);
244
245         interbeam := 1.2 staff_space_rounded;
246
247         set_char_box (0, 0.95 staff_space#,
248                       1.3 staff_space#, 1.3 staff_space#);
249
250         stem := 7 / 16 * w;
251         outer_space := hround ((w - stemwidth) / 2);
252
253         w := 2 outer_space + stemwidth;
254         d := d - feta_space_shift;
255
256         draw_meta_sharp (.8 w, -.5 interbeam);
257         draw_meta_sharp (.8 w, -.5 interbeam + vround interbeam);
258         sharp_beamheight# := 1/.8 sharp_beamheight#;
259         draw_meta_sharp (w, 0);
260
261         pickup pencircle scaled stemwidth;
262
263         lft x5 = lft x6 = outer_space;
264         top y6 = vround (1.5 staff_space - .5 stem);
265         bot y5 = -top y6 + feta_space_shift;
266         labels (5, 6);
267
268         draw_gridline (z5, z6, stemwidth);
269
270         remember_pic := currentpicture;
271
272         draw_staff (-2, 2, 0);
273 fet_endchar;
274
275
276 draw_shifted_too;
277
278
279 fet_beginchar ("3/4 Sharp", "sharp.slashslash.stemstemstem");
280         save stem, stemx, stemwidth;
281         save outer_space, interbeam;
282
283         stemwidth# := stafflinethickness# + .05 staff_space#;
284         define_whole_blacker_pixels (stemwidth);
285
286         interbeam := 1.05 staff_space_rounded;
287
288         set_char_box (0, 1.6 staff_space#,
289                       1.5 staff_space#, 1.5 staff_space#);
290
291         stem := 9 / 32 * w;
292         stemx := hround stem;
293         outer_space := hround ((w - 2 stemx - stemwidth) / 2);
294
295         w := 2 outer_space + 2 stemx + stemwidth;
296         d := d - feta_space_shift;
297
298         draw_meta_sharp (w, -.5 interbeam);
299         draw_meta_sharp (w, -.5 interbeam + vround interbeam);
300
301         pickup pencircle scaled stemwidth;
302
303         lft x5 = lft x6 = outer_space;
304         lft x7 = lft x8 = outer_space + stemx;
305         lft x9 = lft x10 = outer_space + 2 stemx;
306         bot y5 = -d;
307         top y6 = vround (1.5 staff_space - 2 stem * beamslope);
308         bot y9 = -top y6 + feta_space_shift;
309         top y10 = h;
310         y7 = .5 [y5, y9];
311         y8 = .5 [y6, y10];
312
313         labels (5, 6, 7, 8, 9, 10);
314
315         draw_gridline (z5, z6, stemwidth);
316         draw_gridline (z7, z8, stemwidth);
317         draw_gridline (z9, z10, stemwidth);
318
319         remember_pic := currentpicture;
320
321         draw_staff (-2, 2, 0);
322 fet_endchar;
323
324
325 draw_shifted_too;
326
327
328 %
329 % The stems of the natural are brushed (at least, in Barenreiter SCS)
330 %
331
332 fet_beginchar ("Natural", "natural");
333         save stemwidth, top_stem_thick;
334         save ne, pat_top, pat_bottom;
335         pair ne;
336         path pat_top, pat_bottom;
337
338         top_stem_thick# = stafflinethickness# + .10 staff_space#;
339         stemwidth# = 0.09 staff_space# + .5 stafflinethickness#;
340         define_whole_blacker_pixels (top_stem_thick, stemwidth);
341
342         set_char_box (0, 2/3 staff_space#,
343                       1.5 staff_space#, 1.5 staff_space#);
344
345         d := d - feta_space_shift;
346
347         pickup pencircle scaled stemwidth;
348
349         penpos1 (top_stem_thick, 0);
350         penpos3 (top_stem_thick, 0);
351         penpos2 (stemwidth, 0);
352         penpos4 (stemwidth, 0);
353
354         x2r = w;
355         x4l = 0;
356         x3 = x2;
357         x1 = x4;
358
359         y1 = h;
360         y3 = -d;
361         top y2 = vround (staff_space - 3/2 stafflinethickness);
362         y4 = -y2 + feta_space_shift;
363
364         pat_bottom := z4r{z4r - z1r}
365                       .. bot z4
366                       .. z4l{z1l - z4l};
367         fill simple_serif (z1l, z1r, -30)
368              -- pat_bottom
369              -- cycle;
370
371         pat_top := z2r{z2r - z3r}
372                    .. top z2
373                    .. z2l{z3l - z2l};
374         fill simple_serif (z3l, z3r, 30)
375              -- pat_top
376              -- cycle;
377
378         ne = (x2 - x4, stafflinethickness);
379
380         z11' = z3l + whatever * (z2l - z3l);
381         y11' = vround (.5 (staff_space - stafflinethickness));
382         z11 = z11' + whatever * ne;
383         x11 = x12;
384         z12 = directionpoint -ne of pat_top;
385         z13 = z12 + whatever * ne;
386         x13 = x1;
387         z14 = z11 + whatever * ne;
388         x14 = x1;
389
390         z21' = z4r + whatever * (z1r - z4r);
391         y21' = -y11' + feta_space_shift;
392         z21 = z21' + whatever * ne;
393         x21 = x22;
394         z22 = directionpoint -ne of pat_bottom;
395         z23 = z22 + whatever * ne;
396         x23 = x3;
397         z24 = z21 + whatever * ne;
398         x24 = x3;
399
400         fill z11
401              -- z12
402              -- z13
403              -- z14
404              -- cycle;
405         fill z21
406              -- z22
407              -- z23
408              -- z24
409              -- cycle;
410
411         penlabels (1, 2, 3, 4);
412         labels (11, 11', 12, 13, 14, 21, 21', 22, 23, 24);
413
414         remember_pic := currentpicture;
415
416         draw_staff (-2, 2, 0);
417 fet_endchar;
418
419
420 draw_shifted_too;
421
422
423 %
424 % Dedicated to my mom.    (3/10/97)
425 %
426 % Mamma, ik hou van je; kom je alsjeblieft terug?
427 %    -- HW
428 %
429 %
430 % TODO: remove crook_fatness
431 % TODO: document, simplify!
432 %
433
434 def draw_meta_flat (expr xcenter, w, crook_fatness) =
435         save crook_thinness;
436         save bottom_overshoot, bot_crook_dir;
437         save top_stem_thick, bottom_stem_thick, hair, smaller_hole;
438         save top_crook_thinness;
439         save zwiep;
440         save center;
441         pair center, bot_crook_dir;
442         save clearing;
443
444         clearxy;
445
446         % the stem shouldn't reach the top staff line.
447         %% TODO: should take from height.
448         %
449         % TODO: parameterize this
450         %
451         if w >= 0.75 staff_space:
452                 smaller_hole = 0.35 stafflinethickness;
453         else:
454                 smaller_hole = 0;
455         fi;
456         clearing = 1.7 stafflinethickness;
457         crook_thinness = .7 stafflinethickness + .06 staff_space;
458         top_crook_thinness = 1 stafflinethickness + .065 staff_space;
459         bottom_overshoot = stafflinethickness;
460
461         bottom_stem_thick# = 0.06 staff_space# + 0.6 stafflinethickness#;
462         top_stem_thick# = 0.1 staff_space# + 1.2 stafflinethickness#;
463         define_whole_blacker_pixels (bottom_stem_thick, top_stem_thick);
464
465         if odd (top_stem_thick - bottom_stem_thick):
466                 top_stem_thick := top_stem_thick - 1;
467         fi;
468
469         center = (xcenter, 0);
470
471         x1l = hround (xcenter - .5 top_stem_thick);
472         y1 = vround (2 staff_space - clearing);
473         x2l = hround (xcenter - .5 bottom_stem_thick);
474         y2 = -.5 staff_space - .5 stafflinethickness;
475
476         penpos1 (top_stem_thick, 0);
477         penpos2 (bottom_stem_thick, 0);
478
479         y3l = vfloor ((staff_space - stafflinethickness) / 2);
480         z3l = whatever [z2r, z1r];
481         z3r = .3 [z2r, z1r] + (smaller_hole, 0);
482         x3r := hceiling x3r;
483
484         % we insert z3l to get better conversion with mf2pt1
485         fill simple_serif (z1r, z1l, 30)
486              -- z2l
487              -- z2r
488              -- z3l
489              -- cycle;
490
491         z10 = whatever [z2r, z1r] + (smaller_hole, 0);
492         y10 = -1/10 staff_space;
493         x10 := hceiling x10;
494
495         x11 = xcenter + bottom_overshoot / 3;
496         y11 = -vround (.5 (staff_space + stafflinethickness)
497                        + bottom_overshoot);
498
499         penpos4 (whatever, 53);
500
501         y4l - y4r = top_crook_thinness;
502         y5r = .15 staff_space;
503         x5l = hround (w + xcenter);
504         y4 = staff_space / 2;
505         x4r = .45 [x5r, x3r];
506         y4l := vround y4l;
507
508         penpos5 (crook_fatness, -175);
509
510         bot_crook_dir = unitvector ((x5l, 0) - z11);
511         z8 = z11 + whatever * bot_crook_dir;
512         y8 = -staff_space / 2;
513
514         z7 = z8
515              + whatever * bot_crook_dir
516              + crook_thinness * (bot_crook_dir rotated 90);
517         x7 = .1 [x3r, x8];
518
519         unfill z3r{z3r - z10}
520                .. z4r{right}
521                .. z5r{down}
522                .. z7{-bot_crook_dir}
523                & z7
524                .. z10{z3r - z10}
525                -- cycle;
526
527         fill z2l{down}
528              .. z11{right}
529              .. z8{bot_crook_dir}
530              .. z5l{up}
531              .. z4l{left}
532              .. z3l
533              -- cycle;
534 enddef;
535
536
537 %
538 % unfortunately, 600dpi is not enough to show the brush of the stem.
539 %
540
541 fet_beginchar ("Flat", "flat");
542         set_char_box (1.2 stafflinethickness#, .8 staff_space#,
543                       0.6 staff_space#, 1.9 staff_space#);
544
545         draw_meta_flat (0, w, 0.31 staff_space);
546         penlabels (range 0 thru 11);
547
548         remember_pic := currentpicture;
549
550         draw_staff (-2, 2, 0);
551 fet_endchar;
552
553
554 draw_shifted_too;
555
556
557 fet_beginchar ("Flat (slashed)", "flat.slash");
558         set_char_box (.4 staff_space#, .8 staff_space#,
559                       0.6 staff_space#, 1.9 staff_space#);
560
561         draw_meta_flat (0, w, 0.31 staff_space);
562
563         clearxy;
564
565         save slope, slash_width;
566         slope = 0.5;
567         slash_width = w;
568
569         z11 = (0, h / 2);
570         z12 = z11 - (slash_width, slash_width * slope) / 2;
571         z13 = z11 + (slash_width, slash_width * slope) / 2;
572         penpos12 (1.5 stafflinethickness, angle (z13 - z12) - 90);
573         penpos13 (1.5 stafflinethickness, angle (z13 - z12) - 90);
574
575         z14 = z12 - .75 stafflinethickness * unitvector (z13 - z12);
576         z15 = z13 + .75 stafflinethickness * unitvector (z13 - z12);
577
578         fill z13r
579              .. z15
580              .. z13l
581              -- z12l
582              .. z14
583              .. z12r
584              -- z13r
585              .. cycle;
586
587         penlabels (12, 13);
588         labels (14, 15);
589
590         remember_pic := currentpicture;
591
592         draw_staff (-2, 2, 0);
593 fet_endchar;
594
595
596 fet_beginchar ("Flat (slashed twice)", "flat.slashslash");
597         set_char_box (.4 staff_space#, .8 staff_space#,
598                       0.6 staff_space#, 1.9 staff_space#);
599
600         draw_meta_flat (0, w, 0.31 staff_space);
601
602         clearxy;
603
604         save slope, slash_width;
605         slope = 0.5;
606         slash_width = w;
607
608         z11 = (0, 5/12 h);
609         z12 = z11 - (slash_width, slash_width * slope) / 2;
610         z13 = z11 + (slash_width, slash_width * slope) / 2;
611         penpos12 (1.5 stafflinethickness, angle (z13 - z12) - 90);
612         penpos13 (1.5 stafflinethickness, angle (z13 - z12) - 90);
613
614         z14 = z12 - .75 stafflinethickness * unitvector (z13 - z12);
615         z15 = z13 + .75 stafflinethickness * unitvector (z13 - z12);
616
617         fill z13r
618              .. z15
619              .. z13l
620              -- z12l
621              .. z14
622              .. z12r
623              -- z13r
624              .. cycle;
625
626         penlabels (12, 13);
627         labels (14, 15);
628
629         z21 = (0, 2/3 h);
630         z22 = z21 - (slash_width, slash_width * slope) / 2;
631         z23 = z21 + (slash_width, slash_width * slope) / 2;
632         penpos22 (1.5 stafflinethickness, angle (z23 - z22) - 90);
633         penpos23 (1.5 stafflinethickness, angle (z23 - z22) - 90);
634
635         z24 = z22 - .75 stafflinethickness * unitvector (z23 - z22);
636         z25 = z23 + .75 stafflinethickness * unitvector (z23 - z22);
637
638         fill z23r
639              .. z25
640              .. z23l
641              -- z22l
642              .. z24
643              .. z22r
644              -- z23r
645              .. cycle;
646
647         penlabels (22, 23);
648         labels (24, 25);
649
650         remember_pic := currentpicture;
651
652         draw_staff (-2, 2, 0);
653 fet_endchar;
654
655
656 fet_beginchar ("Flatflat (mirrored)", "mirroredflat.flat");
657         set_char_box (0, 1.6 staff_space#, 
658                       0.6 staff_space#, 1.9 staff_space#);
659
660         % This is a modified version of `draw_meta_flat'.
661
662         save crook_thinness, crook_fatness;
663         save bottom_overshoot, bot_crook_dir;
664         save top_stem_thick, bottom_stem_thick, hair, smaller_hole;
665         save top_crook_thinness;
666         save zwiep;
667         save center;
668         pair center, bot_crook_dir;
669         save clearing, wid;
670         save pat;
671         path pat;
672
673         clearxy;
674
675         wid = w / 2;
676
677         % the stem shouldn't reach the top staff line.
678         %% TODO: should take from height.
679         %
680         % TODO: parameterize this
681         %
682         if wid >= 0.75 staff_space:
683                 smaller_hole = 0.35 stafflinethickness;
684         else:
685                 smaller_hole = 0;
686         fi;
687         clearing = 1.7 stafflinethickness;
688         crook_thinness = .7 stafflinethickness + .06 staff_space;
689         crook_fatness = 0.31 staff_space;
690         top_crook_thinness = 1 stafflinethickness + .065 staff_space;
691         bottom_overshoot = stafflinethickness;
692
693         bottom_stem_thick# = 0.06 staff_space# + 0.6 stafflinethickness#;
694         top_stem_thick# = 0.1 staff_space# + 1.2 stafflinethickness#;
695         define_whole_blacker_pixels (bottom_stem_thick, top_stem_thick);
696
697         if odd (top_stem_thick - bottom_stem_thick):
698                 top_stem_thick := top_stem_thick - 1;
699         fi;
700
701         center = (0, 0);
702
703         x1l = hround (-.5 top_stem_thick);
704         y1 = vround (2 staff_space - clearing);
705         x2l = hround (-.5 bottom_stem_thick);
706         y2 = -.5 staff_space - .5 stafflinethickness;
707
708         penpos1 (top_stem_thick, 0);
709         penpos2 (bottom_stem_thick, 0);
710
711         y3l = vfloor ((staff_space - stafflinethickness) / 2);
712         z3l = whatever [z2r, z1r];
713         z3r = .3 [z2r, z1r] + (smaller_hole, 0);
714         x3r := hceiling x3r;
715
716         z10 = whatever [z2r, z1r] + (smaller_hole, 0);
717         y10 = -1/10 staff_space;
718         x10 := hceiling x10;
719
720         x11 = bottom_overshoot / 3;
721         y11 = -vround (.5 (staff_space + stafflinethickness)
722                        + bottom_overshoot);
723
724         penpos4 (whatever, 53);
725
726         y4l - y4r = top_crook_thinness;
727         y5r = .15 staff_space;
728         x5l = hround (wid);
729         y4 = staff_space / 2;
730         x4r = .45 [x5r, x3r];
731         y4l := vround y4l;
732
733         penpos5 (crook_fatness, -175);
734
735         bot_crook_dir = unitvector ((x5l, 0) - z11);
736         z8 = z11 + whatever * bot_crook_dir;
737         y8 = -staff_space / 2;
738
739         z7 = z8
740              + whatever * bot_crook_dir
741              + crook_thinness * (bot_crook_dir rotated 90);
742         x7 = .1 [x3r, x8];
743
744         pat := z3r{z3r - z10}
745                .. z4r{right}
746                .. z5r{down}
747                .. z7{-bot_crook_dir}
748                & z7
749                .. z10{z3r - z10}
750                -- cycle;
751         unfill pat;
752         unfill pat xscaled -1;
753
754         pat := z11{right}
755                .. z8{bot_crook_dir}
756                .. z5l{up}
757                .. z4l{left}
758                .. z3l;
759         fill pat
760              -- simple_serif (z1r, z1l, 30)
761              -- reverse pat xscaled -1 shifted (-feta_eps, 0)
762              -- cycle;
763
764         currentpicture := currentpicture shifted (w/2, 0);
765
766         remember_pic := currentpicture;
767
768         draw_staff (-2, 2, 0);
769 fet_endchar;
770
771
772 draw_shifted_too;
773
774
775 fet_beginchar ("Semi flat", "mirroredflat");
776         set_char_box (1.2 stafflinethickness#, .8 staff_space#,
777                       0.6 staff_space#, 1.9 staff_space#);
778
779         draw_meta_flat (0, w, 0.31 staff_space);
780         currentpicture := currentpicture xscaled -1 shifted (w - b, 0);
781 fet_endchar;
782
783
784 fet_beginchar ("Semi flat", "mirroredflat.backslash");
785         set_char_box (.4 staff_space#, .8 staff_space#,
786                       0.6 staff_space#, 1.9 staff_space#);
787
788         draw_meta_flat (0, w, 0.31 staff_space);
789
790         clearxy;
791
792         save slope, slash_width;
793         slope = 0.5;
794         slash_width = w;
795
796         z11 = (0, h / 2);
797         z12 = z11 - (slash_width, slash_width * slope) / 2;
798         z13 = z11 + (slash_width, slash_width * slope) / 2;
799         penpos12 (1.5 stafflinethickness, angle (z13 - z12) - 90);
800         penpos13 (1.5 stafflinethickness, angle (z13 - z12) - 90);
801
802         z14 = z12 - .75 stafflinethickness * unitvector (z13 - z12);
803         z15 = z13 + .75 stafflinethickness * unitvector (z13 - z12);
804
805         fill z13r
806              .. z15
807              .. z13l
808              -- z12l
809              .. z14
810              .. z12r
811              -- z13r
812              .. cycle;
813
814         currentpicture := currentpicture xscaled -1 shifted (w - b, 0);
815
816         labels (1, 2, 3);
817 fet_endchar;
818
819
820 fet_beginchar ("Double Flat", "flatflat");
821         save left_wid, overlap, right_wid;
822
823         left_wid = .7;
824         right_wid = .8;
825         overlap = .05;
826
827         set_char_box (1.2 stafflinethickness#,
828                       (left_wid + right_wid - overlap) * staff_space#,
829                       .6 staff_space#, 1.9 staff_space#);
830         draw_meta_flat (0, left_wid * staff_space, 1/3 staff_space);
831         draw_meta_flat (hround ((left_wid - overlap) * staff_space),
832                         right_wid * staff_space, 1/3 staff_space);
833 fet_endchar;
834
835
836 fet_beginchar ("3/4 Flat", "flatflat.slash");
837         save left_wid, overlap, right_wid;
838
839         left_wid = .7;
840         right_wid = .8;
841         overlap = .05;
842
843         set_char_box (1.2 stafflinethickness#,
844                       (left_wid + right_wid - overlap) * staff_space#,
845                       .6 staff_space#, 1.9 staff_space#);
846         draw_meta_flat (0, left_wid * staff_space, 1/3 staff_space);
847         draw_meta_flat (hround ((left_wid - overlap) * staff_space),
848                         right_wid * staff_space, 1/3 staff_space);
849
850         %% maybe we should clip part of the stems?
851         %% or make the 1st flat smaller?
852         %% or reverse it?
853         pickup pencircle scaled 2 stafflinethickness;
854
855         z12 = round (-.25 w - b, .55 staff_space) + feta_offset;
856         z13 = round (.75 w, 1.45 staff_space) + feta_offset;
857         penpos12 (2 stafflinethickness, angle (z13 - z12) - 90);
858         penpos13 (2 stafflinethickness, angle (z13 - z12) - 90);
859
860         z14 = z12 - stafflinethickness * unitvector (z13 - z12);
861         z15 = z13 + stafflinethickness * unitvector (z13 - z12);
862
863         fill z13r
864              .. z15
865              .. z13l
866              -- z12l
867              .. z14
868              .. z12r
869              -- z13r
870              .. cycle;
871
872         penlabels (12, 13);
873         labels (14, 15);
874
875         remember_pic := currentpicture;
876
877         draw_staff (-2, 2, 0);
878 fet_endchar;
879
880
881 draw_shifted_too;
882
883
884 fet_beginchar ("Double Sharp", "doublesharp");
885         save klaverblad, klaversteel;
886         save pat;
887         path pat;
888
889         klaversteel = 1/15 staff_space;
890         klaverblad = .4 staff_space - .5 stafflinethickness;
891
892         set_char_box (0, staff_space#, .5 staff_space#, .5 staff_space#);
893
894         z1 = (klaversteel, 0);
895         z2 = (w / 2 - klaverblad / 10, h - klaverblad);
896         z3 = (w / 2, h);
897         z4 = z2 reflectedabout ((0, 0), (1, 1));
898         z5 = z1 reflectedabout ((0, 0), (1, 1));
899
900         labels (1, 2, 3, 4, 5);
901
902         pickup pencircle scaled blot_diameter;
903
904         x2 := hfloor (rt x2) - blot_diameter / 2;
905         x3 := hfloor (rt x3) - blot_diameter / 2;
906         y3 := vfloor (top y3) - blot_diameter / 2;
907         y4 := vfloor (top y4) - blot_diameter / 2;
908
909         pat = (rt z1){dir45}
910               .. {right}(bot z2)
911               .. rt z2
912               -- rt z3{z3 - z2}
913               .. top z3{z4 - z3}
914               -- top z4{z4 - z3}
915               .. (lft z4){down}
916               .. {dir 225}(top z5);
917         pat := pat
918                -- reverse pat xscaled -1 shifted (-feta_eps, 0);
919
920         % assure symmetry -- it's more important to center the glyph on the
921         % staff line than centering it between staff lines, so we use
922         % feta_shift, not feta_space_shift.
923         h := h + feta_shift;
924
925         fill pat shifted (0, feta_shift)
926              -- reverse pat yscaled -1 shifted (0, -feta_eps)
927              -- cycle;
928
929         % ugh
930         currentpicture := currentpicture shifted (hround (w / 2), 0);
931
932         remember_pic := currentpicture;
933
934         draw_staff (-2, 2, 0);
935 fet_endchar;
936
937
938 draw_shifted_too;
939
940
941 def draw_paren =
942         save leftindent;
943
944         leftindent := .2 staff_space;
945
946         set_char_box (0, .5 staff_space# + stafflinethickness#,
947                       staff_space#, staff_space#);
948
949         d := d - feta_shift;
950
951         z1 = (leftindent, h);
952         z2 = (w - stafflinethickness, .5 (h - d));
953         z3 = (leftindent, -d);
954
955         penpos1 (stafflinethickness, 35);
956         penpos2 (.1 staff_space + stafflinethickness, 0);
957         penpos3 (stafflinethickness, -35);
958
959         fill z2l{down}
960              .. simple_serif (z3l, z3r, 90)
961              .. z2r{up}
962              .. simple_serif (z1r, z1l, 90)
963              .. z2l{down}
964              -- cycle;
965 enddef;
966
967
968 fet_beginchar ("Right Parenthesis", "rightparen");
969         draw_paren;
970         penlabels (1, 2, 3);
971
972         remember_pic := currentpicture;
973
974         draw_staff (-2, 2, 0);
975 fet_endchar;
976
977
978 draw_shifted_too;
979
980
981 fet_beginchar ("Left Parenthesis", "leftparen");
982         draw_paren;
983
984         currentpicture := currentpicture xscaled -1;
985
986         set_char_box (charwd, charbp, chardp, charht);
987 fet_endchar;
988
989 fet_endgroup ("accidentals");