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