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