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