]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-schrift.mf
f0979def1d3338c729781481a147b4f25bc79136
[lilypond.git] / mf / feta-schrift.mf
1 % -*- Fundamental -*-  (emacs-20 mf mode mucks
2 % feta-schrift.mf --  implement scripts
3
4 % source file of the Feta (defintively not an abbreviation for Font-En-Tja)
5 % music font
6
7 % (c)  1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 %       Jan Nieuwenhuizen <janneke@gnu.org>
9
10
11
12 fet_begingroup("scripts")
13
14 def draw_fermata =
15   save alpha, radius, crook_thinness, crook_fatness, dot_radius;
16   
17         % [Wanske] and some  Baerenreiter editions
18         % suggest ca 80 degrees iso half-circle
19   alpha := 10;
20
21   radius# = 1.25 staff_space#;
22   crook_thinness# = 1.5linethickness#;
23   crook_fatness# = 0.25 staff_space# +  1.5 linethickness#;
24
25   radius# + crook_fatness#/2 = h#;
26   radius# + crook_thinness#/2 = w#;
27   set_char_box(w#, w#, crook_thinness#/2, h#);
28   
29   define_pixels(radius, crook_thinness, crook_fatness);
30   dot_radius = round (4/6 crook_fatness);
31
32
33   penpos1(crook_thinness, 0);
34   penpos2(crook_fatness, -90);
35   z1 = (-radius,0);
36   z2 = (0, radius);
37
38   fill z1l{dir (-alpha-90)}..{dir (90-alpha)}z1r..
39   {right}z2r -- z2l{left} .. cycle;
40
41   addto currentpicture also 
42   currentpicture xscaled -1;
43
44   pickup pencircle scaled 2dot_radius;
45   x4 =0;
46   bot y4 = - crook_thinness/2;
47   drawdot z4;
48 enddef;
49
50 fet_beginchar("fermata up", "ufermata", "ufermata")
51         draw_fermata;   
52         penlabels(1,2,4);
53 fet_endchar;
54
55 fet_beginchar("fermata down", "dfermata", "dfermata")
56         draw_fermata;
57         y_mirror_char;
58 fet_endchar;
59
60 def draw_short_fermata =
61         save fat_factor, thinness, dot_radius;
62         set_char_box(staff_space#, staff_space#, 0, 2.2 staff_space#);
63
64         dot_radius# = 0.133 staff_space# + 1.33 linethickness#;
65         define_pixels(dot_radius)
66
67         fat_factor = .11;
68         thinness = 1.5 linethickness;
69
70         pickup pencircle scaled thinness;
71         rt x2 = w;
72         lft x5 = -b;
73         bot y5 = 0;
74         top y3 = h;
75         y1 = y2 = y5;
76
77         x3 = 0;
78         z1 - z4 = whatever * (charwd, -charht);
79         z4 = fat_factor [z3, z5];
80
81         filldraw z1 -- z2 -- z3 -- z4 -- cycle;
82         draw z3 .. z5;
83
84         pickup pencircle scaled 2dot_radius;
85         x1 - 2x6 = x2;
86         bot y6 = -d;
87         drawdot z6;
88 enddef;
89
90 fet_beginchar("short fermata up", "ushortfermata", "ushortfermata")
91         draw_short_fermata;     
92 fet_endchar;
93
94 fet_beginchar("short fermata down", "dshortfermata", "dshortfermata")
95         draw_short_fermata;
96         xy_mirror_char;
97 fet_endchar;
98
99 def draw_long_fermata =
100         save stemthick, beamheight, dot_radius, wd;
101         define_pixels(wd, dot_radius)
102
103         wd# = 2.5 staff_space#;
104         stemthick = 1.5 linethickness;
105         beamheight = 0.3 staff_space+  linethickness;
106         dot_radius# = 0.133 staff_space#+ + 1.333 *linethickness#;
107         set_char_box(wd#/2, wd#/2, 0, 3/2 staff_space#);
108
109         draw_rounded_block((-b, h-beamheight), (w, h), blot_diameter);
110         draw_rounded_block((-b, -d),(-b+stemthick, h-stemthick), stemthick);
111         addto currentpicture also currentpicture xscaled -1;
112
113         pickup pencircle scaled 2dot_radius;
114         x4 = 0;
115         bot y4 = -d;
116         drawdot z4;
117 enddef;
118
119 fet_beginchar("long fermata up", "ulongfermata", "ulongfermata")
120         draw_long_fermata;      
121 fet_endchar;
122
123 fet_beginchar("long fermata down", "dlongfermata", "dlongfermata")
124         draw_long_fermata;
125         y_mirror_char;
126 fet_endchar;
127
128 def draw_very_long_fermata =
129         save ibeamheight, obeamheight;
130         save ihwd, ohwd, iht, oht; % inner/outer half_width/height
131         save stemthick, dot_radius;
132         define_pixels(ihwd, ohwd, iht, oht)
133
134         ihwd# = 1.0 staff_space#;
135         ohwd# = 1.5 staff_space#;
136         iht# = 0.9 staff_space#;
137         oht# = 1.6 staff_space#;
138
139         stemthick = 1.5 linethickness;
140         ibeamheight = 0.3 staff_space;
141         obeamheight = 0.5 staff_space;
142         dot_radius = ((iht - ibeamheight) * 4/10)  ;
143
144         set_char_box(ohwd#, ohwd#, 0, oht#);
145
146         draw_rounded_block((-ohwd, oht-obeamheight), (ohwd, oht), blot_diameter);
147         draw_rounded_block((-ohwd, 0),(-ohwd+stemthick, ohwd-stemthick), stemthick);
148         draw_rounded_block((-ihwd, iht-ibeamheight), (ihwd, iht), blot_diameter);
149         draw_rounded_block((-ihwd, 0),(-ihwd+stemthick, ihwd-stemthick), stemthick);
150         addto currentpicture also currentpicture xscaled -1;
151
152         pickup pencircle scaled 2dot_radius;
153         x4 = 0;
154         bot y4 = -d;
155         drawdot z4;
156 enddef;
157
158 fet_beginchar("very long fermata up", "uverylongfermata", "uverylongfermata")
159         draw_very_long_fermata; 
160 fet_endchar;
161
162 fet_beginchar("very long fermata down", "dverylongfermata", "dverylongfermata")
163         draw_very_long_fermata;
164         y_mirror_char;
165 fet_endchar;
166
167 %
168 % Thumbs are used in cello music.
169 % TODO : thumbs should look like the finger-font and should be placed in
170 % the same way in the score.
171 %
172
173 fet_beginchar("Thumb", "thumb", "thumb")
174         save thin, height, width, thick;
175         height# = 5/4 width#;
176         height# = staff_space#;
177         set_char_box(width#/2, width#/2, height#/2, height#/2);
178         define_pixels (height,width)
179
180         thin = .6  linethickness + 0.06 staff_space;
181         2 thick + 0.5 (height - 2 thin) = width;
182
183         penpos1(thick, 0);
184         penpos2(thin, 90);
185         z1r = (w, 0);
186         z2r = (0, h);
187         penlabels(1,2);
188         penstroke z1e{up} .. {left}z2e;
189         addto currentpicture also currentpicture xscaled -1;
190         addto currentpicture also currentpicture yscaled -1;
191
192         z3 = (0, -h);
193         z4 = (0, -1.5h);
194         penlabels(3,4);
195         draw_brush(z3,1.4*thin, z4,0.9*thick);
196 fet_endchar;
197
198 %
199 % FIXME: rounded endings
200 %
201 % `\accent' is TeX reserved.
202 fet_beginchar("> accent", "sforzato", "sforzatoaccent")
203         set_char_box(.9 staff_space#, .9 staff_space#, .5 staff_space#, .5 staff_space#);
204         save thickness, diminish;
205
206         thickness = 0.05 staff_space + linethickness;
207         pickup pencircle scaled thickness;
208
209         % prevent blobs at crossing lines
210         diminish = .75;
211
212         top y1 = h;
213         lft x1 = -b;
214         rt x2 = w;
215         y2 = .25 thickness* diminish;
216
217         rt z4 = (w,0);
218         x3 = - linethickness + 0.1 staff_space;
219         z3 = whatever [z1, z4];
220
221         penpos2(thickness*(2 - diminish)/2 , 90);
222         penpos1(thickness, 90);
223         penpos3(thickness, 90);
224
225         draw z1 .. z3;
226         draw (z1 .. z3) yscaled -1;
227         draw z4;
228         penstroke z3e .. z2e;
229         penstroke (z3e .. z2e) yscaled -1;
230
231         penlabels(1,2,3);
232         labels(4);
233 fet_endchar;
234
235 fet_beginchar("staccato dot", "staccato", "staccato")
236         save radius;
237         radius# =   0.20 * staff_space#;
238         define_whole_pixels(radius);
239         pickup pencircle scaled 2 radius;
240         drawdot (0,0);
241         set_char_box(radius#, radius#, radius#, radius#);
242 fet_endchar;
243
244 def draw_staccatissimo =
245         save radius, height;
246         height# = .8 staff_space#;
247         radius# = linethickness# + .1 staff_space#;
248         define_whole_pixels(radius);
249         define_pixels(height);
250
251         draw_brush((0,0), linethickness, (0, height),2 radius);
252         set_char_box(radius#,radius#, blot_diameter#/2, height# + radius#);
253 enddef;
254
255 fet_beginchar("staccatissimo/martellato up", "ustaccatissimo", 
256                 "ustaccatissimo")
257         draw_staccatissimo;
258 fet_endchar;
259
260 fet_beginchar("staccatissimo/martellato down", "dstaccatissimo", "dstaccatissimo")
261         draw_staccatissimo;
262         y_mirror_char;
263 fet_endchar;
264
265 fet_beginchar("portato/single tenuto", "tenuto", "tenuto")
266         save thick;
267         thick# = 1.6 linethickness#;
268         define_whole_pixels(thick);
269
270         set_char_box(.6 staff_space#, .6 staff_space#, thick#/2,thick#/2);
271         pickup pencircle scaled thick;
272         draw_rounded_block((-b,-thick/2),(w,thick/2),thick);
273 fet_endchar;
274
275 def draw_portato = 
276         save thick, radius;
277         thick# = 1.4 linethickness#;
278         radius# = 1.4 linethickness#;
279         define_whole_pixels(thick,radius);
280         
281         set_char_box(.6 staff_space#, .6 staff_space#, thick#/2,.5 staff_space#+ radius#);
282         draw_rounded_block((-b,-thick/2),(w,thick/2),thick);
283
284         pickup pencircle scaled 2 radius;
285         drawdot (0,h);
286 enddef;
287
288
289 fet_beginchar("portato/tenuto with staccato", "uportato", 
290                 "uportato")
291         draw_portato;
292 fet_endchar;
293
294
295 fet_beginchar("portato/tenuto with staccato", "dportato", 
296                 "dportato")
297         draw_portato;
298         y_mirror_char
299 fet_endchar;
300
301
302 def draw_marcato = 
303         save fat_factor, thinness;
304         set_char_box(staff_space#/2, staff_space#/2, 0, 1.1 staff_space#);
305
306         fat_factor = .3;
307         thinness =  linethickness;
308
309         pickup pencircle scaled thinness;
310         rt x2 = w;
311         lft x5 = -b;
312         bot y5 = 0;
313         top y3 = h;
314         y1 = y2 = y5;
315
316         x3 =0;
317         z1 - z4 = whatever * (charwd, -charht);
318         z4 = fat_factor [z3, z5];
319
320         filldraw z1 -- z2 -- z3 -- z4 -- cycle;
321         draw z3 .. z5;
322 enddef;
323
324 fet_beginchar("marcato up", "umarcato", "umarcato")
325         draw_marcato;
326         labels(1,2,3,4,5);
327 fet_endchar;
328
329
330 %
331 % The down marcato char (not very much used). 
332 % Contrary to what some MF/TeX `gurus' believe
333 % it is *point*-symmetric with the "up" version
334 %
335 fet_beginchar("marcato down", "dmarcato", "dmarcato")
336         draw_marcato;
337         xy_mirror_char;
338 fet_endchar;
339  
340
341 %
342 % used in french horn music todo
343 %
344 % TODO: too light at 20pt
345 fet_beginchar("open (unstopped)", "open", "ouvert")
346         save thin, height, width, thick;
347         height# = 5/4 width#;
348         height# = staff_space#;
349         thin = .6  linethickness + 0.06 staff_space;
350         set_char_box(width#/2, width#/2, height#/2, height#/2);
351         define_pixels (width,height);
352         2 thick + 0.6 (height - 2 thin) = width;
353         
354         penpos1(thick, 0);
355         penpos2(thin, 90);
356         z1r = (w, 0);
357         z2r = (0, h);
358         penlabels(1,2);
359         penstroke z1e{up} .. {left}z2e;
360         addto currentpicture also currentpicture xscaled -1;
361         addto currentpicture also currentpicture yscaled -1;
362 fet_endchar;
363
364
365 fet_beginchar("plus (stopped)", "stopped", "plusstop")
366         save thick, size;
367         thick = 2 linethickness;
368         size# = 1.1 staff_space#;
369
370         set_char_box(size#/2, size#/2, size#/2, size#/2);
371         draw_rounded_block((-b,-thick/2),(w,thick/2),thick);
372         addto currentpicture also currentpicture rotated 90;
373 fet_endchar;
374
375
376 %
377 % A vee with tapered insides to prevent visual blotting
378 %
379
380 def draw_vee (expr width, height, thickness) =
381 begingroup
382         save diminish;
383
384         diminish = 0.75;
385
386         pickup pencircle scaled thickness;
387         
388         x1 = 0;
389         bot y1 = 0;
390         rt x2 =  w;
391         top y2 = h;
392
393         z3 = whatever [z2, z1];
394         y3 = 0.6 [y2, y1] + thickness;
395
396         penpos3(thickness, 0);
397         penpos4(thickness * diminish, 0);
398         x4r = thickness/2;
399         y4 = thickness/2;
400         labels(1,2);
401         penlabels(3,4);
402
403         draw z1;
404         draw z3 -- z2;
405         penstroke z3e .. z4e;
406         addto currentpicture also currentpicture xscaled -1;
407 endgroup;
408 enddef;
409
410 fet_beginchar("Upbow", "upbow", "upbow")
411         save ht, wd, thick, diminish;
412         
413         thick = 1.4 linethickness;
414         wd# = 1.3 staff_space#;
415         ht# = 1.6 wd#; 
416         set_char_box(wd#/2, wd#/2, 0, ht#);
417         draw_vee (wd, ht, thick);
418 fet_endchar;
419
420
421 fet_beginchar("Downbow", "downbow", "downbow")
422         save stemthick, beamheight;
423         save wd,round;
424         define_pixels(wd)
425
426         wd# = 1.5 staff_space#;
427         stemthick = 1.2 linethickness;
428         set_char_box(wd#/2, wd#/2, 0, 4/3 staff_space#);
429
430         beamheight = 4/10 h;
431
432         draw_rounded_block((-b,h-beamheight),(w,h),blot_diameter);
433         draw_rounded_block((-b,-d),(-b+stemthick,h-stemthick),stemthick);
434         addto currentpicture also currentpicture xscaled -1;
435 fet_endchar;
436
437 %
438 % Inspired by a computer-set version of Auf dem Strom by Baerenreiter. 
439 %
440
441 def draw_turn =
442         save thin, thick, ball_diam, darkness;
443         save wd, ht, thick_nibangle, ball_nib_thick;
444         save turndir;
445         pair turndir;
446
447         wd# = 35/16 staff_space#;
448         ht# = 18/17 staff_space#;
449         darkness = 0.3 linethickness + 0.09 staff_space;
450
451         set_char_box(wd#/2, wd#/2, ht#/2, ht#/2);       
452
453         thick_nibangle = 60;
454         thick = 3 darkness;
455         thin = darkness;
456         ball_nib_thick = 2.7 darkness;
457         ball_diam = ball_nib_thick + (h - ball_nib_thick) / 10;
458
459         
460         x3l = w;
461         y3 = 0;
462         y4l = h;
463         x4 = x2;
464         x2l = w/2;
465         y2l = -d;
466         z1 = (0,0);
467
468         penpos1(1.1 thick, thick_nibangle);
469         penpos2(thick, thick_nibangle);
470         penpos3(thin, 180);
471         penpos4(ball_nib_thick, -90);
472
473         path swoosh, ploop;
474         swoosh :=  z1l{curl 0} .. z2l .. z3l{up} .. {left}z4l 
475           -- z4r .. z3r{down} .. z2r{left} ;
476         fill swoosh .. (swoosh scaled -1) .. cycle;
477
478         x5r = x4;
479         y5r = y4l - ball_diam /2;
480         z6r = z5r;
481
482         penpos5(1.6 ball_diam/2, 10);
483         penpos6(ball_diam/2, 150);
484
485         ploop := z4l{left} .. z5l .. z6l -- cycle;
486         fill ploop;
487         fill ploop scaled -1;
488
489
490 enddef;
491
492 fet_beginchar("Reverse turn","reverseturn","reverseturn")
493         draw_turn;
494         currentpicture := currentpicture yscaled -1;
495 fet_endchar;
496
497
498 fet_beginchar("Turn","turn","turn")
499         draw_turn;
500         penlabels(1,2,3,4,5,6,7);
501 fet_endchar;
502
503
504
505 %
506 % Inspired by a (by now) PD edition of Durand & C'ie edition of 
507 % Saint-Saens' Celloconcerto no. 1 
508 %
509 % FIXME take out hardcoded vars.
510 % FIXME the two loops on the `t' should be smoother (and the left one bigger).
511 % FIXME generic macros for serifs: top of the t and bottom of r
512 %
513
514
515 fet_beginchar("Trill (`tr')","trill","trill")
516         
517         save start_nib_angle,  ascender_extra, ex, hair_thick, fatness,
518           slant_angle, slant, t_fatness, r_fatness, kerning, t_overshoot, 
519           uitschieter, bulb_size;
520         ;
521         pair slant_vec;
522
523         ascender_extra# = 1/2 ex#;
524         ascender# = ascender_extra# + ex#;
525         ex# = 1.4 staff_space#;
526         kerning# = .60 ex#;
527         start_nib_angle = 20;
528         bulb_size = 0.80;
529         define_pixels(ex, ascender_extra, ascender, kerning);
530
531         t_overshoot = 0.03 ex;
532         fatness = 12/40 ex;
533         t_fatness = 0.78 fatness;
534         t_width =  1.9 t_fatness;
535         r_fatness = 0.78 fatness;
536         uitschieter = 0.48 ex;
537         hair_thick =  linethickness;
538         r_flare = .5 hair_thick + 0.25 r_fatness;
539         r_width =  2 r_fatness + 0.25 kerning;
540         slant = .2;
541
542 %       slant = .0;
543
544         local_copy(transform)(currenttransform);
545         currenttransform := currenttransform slanted slant shifted (- staff_space, 0)  ;
546
547         y1 = ascender;
548
549         % try to position in such a way that the center is the visual
550         % center
551
552         x1l = 0.2 staff_space;
553         x1r - x1l = t_fatness;
554         penpos1(start_nib_wid, start_nib_angle);
555         
556         z2 = (x1, 7/18 ex);
557         penpos2(start_nib_wid, start_nib_angle);
558
559         z3l = (x2l + 0.5 t_width, - t_overshoot);
560
561         z4l = (x2l + t_width, 0.23 ex);
562         penpos4(whatever, 200);
563         x4l - x4r = hair_thick;
564
565         x3r = 0.5 [x4r, x2r];
566 %       1.7 [x3l, x3r] = x4r;
567         y3r - y3l = 0.6 t_fatness;
568
569         
570         save t_p, krul_p;
571         path t_p, krul_p, r_p;
572
573         z5 = (x2l + t_fatness/2, 2/3 ex);
574 %       penpos5(hair_thick, ); 
575
576         t_p := z1r{dir (angle(z1l-z1r) + 30)} .. z1l{-dir (angle(z1r-z1l) - 45)}
577                 -- z2l {down}
578                 .. tension (1 + .5 slant)
579                 .. z3l{right} 
580                 
581                 .. z4l{up} -- z4r{down} 
582                 .. z3r{left}
583                 .. tension (1.5 + .7 slant)
584                 .. z2r{up} .. z1r -- cycle;
585         fill t_p ;
586
587         krul_ang = 32;
588
589         pickup pencircle scaled hair_thick;
590         
591         lft x6 = x2l - uitschieter;
592         y6 =  y5 ; % - 1/20 ex;
593
594         z7 = z5 + whatever*dir krul_ang;
595         up_angle = krul_ang;
596         % angle (z7-z5)
597         x7 = 5/10 kerning + x5;
598         
599         penpos7(hair_thick, up_angle + 90);
600
601         
602         y9 = 3/4 ex;
603         x9 = x1 + kerning;
604         penpos9(r_fatness, 0);
605
606         x10 = x9;
607         y10 =  -0.3 linethickness;
608         penpos10(r_fatness, 0);
609
610         krul_p := z4{up}
611                 .. tension 0.98
612                 .. z5
613                 .. z6
614                 .. z5 --- z7;
615         draw krul_p;
616         r_p := z7l{z7-z5} .. z9l{down} --- simple_serif (z10l, z10r, -30)
617                 --- z9r{up} 
618                  ..  z7r{z5-z7} -- cycle;
619         fill r_p;
620
621         set_char_box(.85 staff_space# , .85 staff_space#, 0,ascender#);
622
623
624         penpos11(hair_thick, -4);
625         z11r = z9r;
626         
627         z13l = (x9l + r_width, y11 -  linethickness );
628         penpos13(r_flare, 180);
629
630         z15 = z13r  - ( bulb_size * r_fatness,0);
631         z14 = 0.5 [z13l, z15] - (0,bulb_size* r_fatness);
632         z16 = 0.5 [z13l, z15] + (0,bulb_size* r_fatness);
633
634
635         fill z11r{up} .. tension 0.94 .. z13r{down} -- z15{down}
636                 .. tension 1.0 .. z13l{up}
637                 .. z11l{down} -- cycle;
638
639         fill z15{up} .. tension 1.06 .. z13l{down} .. z14 .. cycle;
640
641
642
643         penlabels(range 1 thru 15);
644
645 fet_endchar;
646
647
648 def draw_heel =
649         save radius, thickness, wall;
650
651         radius# := .5 staff_space#;
652
653         define_pixels(radius);
654         set_char_box(radius#, radius#, radius#, 2/3 staff_space#);
655
656         thickness := 1.5 linethickness; 
657         pickup pencircle scaled thickness;
658         rt x1 = b;
659         top y1 = h;
660         
661         x2 =x1;
662         y2 = 0;
663
664         x3 = 0;
665         bot y3 = -d;
666
667         draw z1{down} .. z2{down} .. z3{left};
668         addto currentpicture also currentpicture xscaled -1;
669         
670 enddef;
671
672
673 fet_beginchar("left heel", "upedalheel", "upedalheel")
674         draw_heel;
675         labels(1,2,3);
676 fet_endchar;
677
678 fet_beginchar("right heel", "dpedalheel", "dpedalheel")
679         draw_heel;
680         y_mirror_char;
681 fet_endchar;
682
683 def draw_toe =
684         save ht,wd;
685
686         thickness := 1.5 linethickness;
687         ht# := 1.5 staff_space#;
688         wd# := 1/3 ht#;
689         define_pixels(ht,wd);
690
691
692         set_char_box(wd#, wd#, 0, ht#);
693         draw_vee (wd, ht, thickness);
694 enddef;
695         
696 fet_beginchar("left toe", "upedaltoe", "upedaltoe")
697         draw_toe;
698         labels(1,2,3);
699 fet_endchar;
700 fet_beginchar("right toe", "dpedaltoe", "dpedaltoe")
701         draw_toe;
702         y_mirror_char;
703 fet_endchar;
704
705 fet_beginchar("Flageolet", "flageolet", "flageolet")
706         save height,width,thickness;
707         height#=4/15 staffsize#;
708         width#=height#;
709         thickness#=blot_diameter#;
710         define_pixels(height,width,thickness);
711         set_char_box(width#/2,width#/2,height#/2,height#/2);
712         
713         pickup pencircle scaled thickness;
714         x1= .5 [x2, x4];
715         x1 = 0;
716         top y1=height/2;
717         rt x4  - lft x2 =width; 
718         y2 = 0;
719         y4=y2;
720         x3=x1;
721         bot y3=-height/2;
722
723         penlabels(1,2,3,4);
724         draw z1..z2..z3..z4..cycle;
725 fet_endchar;
726
727 %%
728 %
729 %TODO:  ARGRGHGH code dup.
730 %
731 %
732
733 fet_beginchar("Segno", "segno", "segno")
734         save thin, thick, ball_diam, darkness, pointheight;
735         save wd, ht, thick_nibangle, ball_nib_thick;
736         save turndir;
737         pair turndir;
738
739         ht# = 3 staff_space#;
740         wd# = 2 staff_space#;
741         darkness = .08 staff_space + 0.4  linethickness;
742
743         set_char_box(wd#/2, wd#/2, ht#/2, ht#/2);       
744
745         thick_nibangle = 30;
746         thick = 3 darkness;
747         thin = darkness;
748         ball_nib_thick = 2.7 darkness;
749         ball_diam = ball_nib_thick + (w - ball_nib_thick) / 10;
750         pointheight = 2 linethickness;
751         
752         y3l = h;
753         2 x3 = x2 + x4;
754         x4 = 0;
755         y4 = y2;
756         y2l = .6 h;
757         x2l = -b;
758         z1 = (0,0);
759
760         penpos1(thick, 2 thick_nibangle);
761         penpos2(thick, thick_nibangle);
762         penpos3(thin, -90);
763         penpos4(ball_nib_thick, 180-thick_nibangle);
764
765         path swoosh, ploop;
766         swoosh :=  z1l{curl 0} .. z2l .. z3l{right} .. {down}z4l 
767           -- z4r .. z3r{left} .. z2r{down} ;
768         fill swoosh .. (swoosh scaled -1) .. cycle;
769         penlabels(1,2,3,4);
770
771         y5r = y4;
772         x5r = x4l - ball_diam /2;
773         z6r = z5r;
774
775         penpos5(1.6 ball_diam/2, 100);
776         penpos6(ball_diam/2, 240);
777
778         ploop := z4l{down} .. z5l .. z6l -- cycle;
779         fill ploop;
780         fill ploop scaled -1;
781         penlabels(4,5,6);
782
783         penpos7(2 thin,0);
784         z7l=(-b,-d);
785         penpos8(2 thin,0);
786         z8r=(w,h);
787         filldraw z7l--z8l{right}--z8r{down}--z7r{right}--cycle;
788         pickup pencircle scaled 2 thin;
789         draw (-x2r,pointheight);
790         draw (x2r,-pointheight);
791 fet_endchar;
792
793 fet_beginchar("Coda", "coda", "coda")
794         save stickout, thin, thick, codawidth, codaheight;
795
796         stickout# = 0.35 staff_space#;
797         codawidth# = 2/3 staff_space#;
798         codaheight# = 1 staff_space#;
799
800         set_char_box(codawidth#+stickout#, codawidth#+stickout#,
801                 codaheight#+stickout#, codaheight#+stickout#);
802
803         define_pixels(codawidth, codaheight);
804         thin = 1.2 linethickness;
805         0.1 (codaheight - 2 thin)  = (codawidth - 2 thick);
806
807         penpos1(thick,0);
808         penpos2(thin,-90);
809         penpos3(thick,180);
810         x1l=-codawidth;
811         y2l=codaheight;
812         y1=0;
813         x2=0;
814         z3 = - z1;
815         penlabels(1,2,3);
816
817         path halfcoda;
818         halfcoda := z1l{up} .. z2l{right} .. z3l{down} -- 
819                 z3r{up} .. z2r{left} .. z1r{down} .. cycle;
820         fill halfcoda;
821         fill (halfcoda scaled -1);
822
823         draw_gridline((0,-h),(0,h),thin);
824         draw_gridline((-w,0),(w,0),thin);
825
826 fet_endchar;
827
828 fet_beginchar("Varied Coda", "varcoda", "varcoda")
829         save thin, thick, codawidth, codaheight;
830         thin# = 1.2 linethickness#;
831         thick# = 1.0 linethickness# + 0.25 staff_space#;
832         codawidth# = 2/3 staff_space#;
833         codaheight# = 1 staff_space#;
834         define_pixels(thin, thick, codawidth, codaheight);
835
836         set_char_box(codawidth#+thick#, codawidth#+thick#,
837                 codaheight#+thick#, codaheight#+thick#);
838
839         x1 = -codawidth;
840         y1 = y2 - thin;
841         x2 = 0;
842         y2 = codaheight;
843         draw_rounded_block(z1, z2, blot_diameter);
844
845         x3 = x1;
846         y3 = -blot_diameter;
847         x4 = x1 + thick;
848         y4 = y2;
849         draw_rounded_block(z3, z4, blot_diameter);
850         labels(1,2,3,4);
851
852         addto currentpicture also currentpicture xscaled -1;
853         addto currentpicture also currentpicture yscaled -1;
854
855         draw_gridline((0,-h),(0,h),thin);
856         draw_gridline((-w,0),(w,0),thin);
857 fet_endchar;
858
859 def draw_comma = 
860         save alpha, thick, thin, ht;
861         alpha:=35;
862         thin# = 1.2 linethickness#;
863         thick# = 3 linethickness#;
864         ht# = .6staff_space#;
865         define_pixels(thin, thick,ht);
866         set_char_box(0, .5staff_space#, ht#, ht#);
867
868         penpos1(thick, alpha);
869         penpos2(thick, alpha+90);
870         penpos3(thin, 180-alpha);
871         penpos4(thin, 90-alpha);
872         x3r=0;
873         x1l=x3l;
874         y2r=-y4l=h;
875         z1=z2;
876         z3=z4;
877         penlabels(1,2,3,4);
878         fill z1l{dir (alpha+90)} .. z2r{dir alpha} .. z1r{dir (alpha-90)} .. 
879         z3l{dir (270-alpha)} .. z4l{dir (alpha+180)} .. 
880         z3r{dir (90-alpha)} .. cycle;
881 enddef;
882
883 fet_beginchar("Right Comma","rcomma","rcomma");
884         draw_comma;
885 fet_endchar;
886
887 fet_beginchar("Left Comma","lcomma","lcomma");
888         draw_comma;
889         xy_mirror_char;
890 fet_endchar;
891
892 def draw_varcomma = 
893         save thick, thin, ht, wd, alpha;
894         alpha:=35;
895         thin# = 1.2 linethickness#;
896         thick# = 3 linethickness#;
897         ht# = .6 staff_space#;
898         wd# = .25 staff_space#;
899         define_pixels(thin, thick, ht, alpha);
900         set_char_box(wd#, wd#, ht#, ht#);
901         z1 = (-b, -d);
902         z2 = (w, h);
903         draw_brush(z1, thin, z2, thick);
904 enddef;
905
906 fet_beginchar("Right Varied Comma","rvarcomma","rvarcomma");
907         draw_varcomma;
908 fet_endchar;
909
910 fet_beginchar("Left Varied Comma","lvarcomma","lvarcomma");
911         draw_varcomma;
912         xy_mirror_char;
913 fet_endchar;
914
915 thick#:=1/24designsize;
916 define_blacker_pixels(thick);
917
918 rthin:= 0.075 *staff_space + 0.5 linethickness;
919 rthick:=2thick+rthin;
920
921 def draw_arpeggio =
922         save alpha;
923         alpha:=-40;
924         save ne,nw,se,sw; pair ne,nw,se,sw;
925         save x,y;
926         
927         se=dir alpha; nw=dir (alpha+180);
928         ne=dir (alpha+90); sw=dir (alpha-90);
929         penpos1(rthin,alpha+90);
930         penpos2(5/4rthick,alpha);
931         penpos4(5/4rthick,alpha);
932         penpos5(rthin,alpha+90);
933         penpos3(3/4rthick,alpha);
934
935         z1=(width/2, height) - overshoot*se;
936         z2=2[z4,(width/2,height/2)];
937         z3=1/2[z2,z4];
938         x4=2/8staff_space;
939         y4=rthin;
940
941         z5=2[z1,(width/2,height/2)];
942         z6=z2l+1/2rthin*sw;
943         z7=z4l+1/2rthin*sw+1/2rthin*se;
944         z8=2[z6,(width/2,height/2)];
945         z9=2[z7,(width/2,height/2)];
946         
947         fill z1l{se}..{se}z6..z3l..z7{se}..{se}z5l..z5r{nw}..{nw}z8..z3r..z9{nw}..{nw}z1r.. cycle;
948         penlabels(1,2,3,4,5,6,7,8,9);
949         enddef;
950
951 fet_beginchar("Arpeggio","arpeggio","arpeggio");
952         %draw_staff (-2, 2, 0.0);       
953         save height, overshoot, width;
954         height# = staff_space#;
955         width# = 0.8height#;
956         overshoot# = 0.25 staff_space#;
957         define_pixels (height,overshoot,width);
958         set_char_box(0, width#, 0, height#);
959         draw_arpeggio;
960         fet_endchar;
961
962 % Extendable Trill symbol.
963 % Not yet used
964 % Rename me to Trill, rename Trill to Tr?
965 fet_beginchar("Trill-element","trill-element","trillelement");
966         save height, overshoot;
967         height# = staff_space#;
968         width# = 0.8height#;
969         overshoot# = 0.25 staff_space#;
970         define_pixels (height,overshoot,width);
971         set_char_box(0, height#, 0, width#);
972         draw_arpeggio;
973         currentpicture := currentpicture shifted -(width/2, height/2);
974         currentpicture := currentpicture rotated 90;
975         currentpicture := currentpicture shifted (height/2, width/2);
976         fet_endchar;
977
978
979
980 %
981 % Arpeggio arrow by Chris Jackson <chris@fluffhouse.org.uk>
982 %
983
984 def draw_arpeggio_arrow =
985         save thinness, height, width, overshoot, se, sw, ne, nw, alpha;
986         pair ne, nw, se, sw;
987         height# = staff_space#;
988         width# = 0.8height#;
989         overshoot# = 0.25 staff_space#;
990         define_pixels (height,overshoot,width);
991         set_char_box(0, width#, 0, height#);
992         alpha := -40;
993         nw = dir (alpha+180);
994         sw = dir (alpha-90); se = dir alpha;
995
996         penpos1(rthin,     alpha+90);
997         penpos2(5/4 rthick, alpha);
998         penpos3(5/4 rthick,     0);
999
1000         z1 = (width/2, height) - overshoot*se; % numbering is consistent with the arpeggio symbol
1001         z2 = 2[z4,(width/2,height/2)];
1002         z3 = (0.5 width, 0.5 height);
1003         z4 = (0.25 staff_space, rthin);
1004         z6 = z2l + 1/2rthin*sw;
1005         z9 = (width/2, height) + overshoot*se;
1006         fill z1l {se}..{se} z6 .. z3l .. z3r.. z9{nw} ..{nw} z1r.. cycle;
1007
1008         bot z10 = ( 0.5w,  0   );
1009         lft z11 = (-0.3w,  0.8h);
1010         rt z12  = ( 1.3w,  0.8h);
1011         pickup pencircle scaled 0.5 rthin;
1012         filldraw z3 -- z12 {dir -130} ..  {dir -110} z10 {dir 110} ..  {dir 130} z11 -- cycle;
1013 enddef;
1014
1015 fet_beginchar("Arpeggio arrow down", "arpeggio-arrow--1", "arpeggioarrowdown");
1016         draw_arpeggio_arrow;
1017 fet_endchar;
1018
1019
1020 fet_beginchar("Arpeggio arrow up", "arpeggio-arrow-1", "arpeggioarrowup");
1021         draw_arpeggio_arrow;
1022         currentpicture := currentpicture scaled -1 shifted (0.8staff_space, staff_space);
1023 fet_endchar;
1024
1025
1026
1027
1028 % Hmm
1029 input feta-slag;
1030
1031 % railroad tracks.
1032 %
1033 % I actually have no clue how they should look, so we use a slightly curvy  
1034 % and tapered shape. 
1035 %
1036 fet_beginchar("Caesura", "caesura", "caesura");
1037   save slant, space_between, clearance;
1038   save alpha, p;
1039   save botthick, topthick;
1040   save krom ;
1041
1042   path p;
1043
1044   botthick = 1.5 linethickness;
1045   topthick = 2.5 linethickness;
1046   pickup pencircle scaled botthick;
1047
1048
1049   slant = 3.5 ;
1050   space_between# = 0.6 staff_space#;
1051   clearance# = 0.2 staff_space#;
1052   height# = 1.2 staff_space#;
1053
1054   set_char_box(0, 2.0 staff_space#, staff_space# - clearance#, height#);
1055   define_pixels (space_between, clearance, height);
1056
1057   bot y1 = -d;
1058   top y2 = h;
1059  
1060   lft x1 = 0;
1061   x2 = (y2 - y1) / slant;
1062
1063   krom = 10;
1064
1065   alpha = angle (z2 - z1);
1066   penpos1 (botthick, alpha - krom);
1067   penpos3 (botthick, alpha - krom + 90);
1068
1069   penpos2 (topthick, alpha + krom );
1070   penpos4 (topthick, alpha + krom + 90);
1071   z3 = z1; z4 = z2; 
1072   penlabels (1,2,3,4);
1073
1074   p  := z3r{(z1r - z1l)} .. z4r{z2r-z2l} .. z2r{z4l-z4r} .. z4l{z2l-z2r} .. z3l{z1l-z1r} .. z1l{z3r-z3l} .. cycle;
1075   fill p;
1076   fill p shifted (space_between , 0);
1077
1078 fet_endchar; 
1079
1080
1081 fet_endgroup("scripts");
1082