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