]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-schrift.mf
patch::: 1.3.141.jcn3
[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 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_diam;
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_diam = 4/3 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 dot_diam;
45   x4 =0;
46   bot y4 = - crook_thinness/2;
47   draw 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 %
61 % Thumbs are used in cello music.
62 % TODO : thumbs should look like the finger-font and should be placed in
63 % the same way in the score.
64 %
65
66 fet_beginchar("Thumb", "thumb", "thumb")
67         save thin, height, width, thick;
68         height# = 5/4 width#;
69         height# = staff_space#;
70         thin = 1.2 stafflinethickness;
71         thick =  2 thin;
72         set_char_box(width#/2, width#/2, height#/2, height#/2);
73         
74         penpos1(thick, 0);
75         penpos2(thin, 90);
76         z1r = (w, 0);
77         z2r = (0, h);
78         penlabels(1,2);
79         penstroke z1e{up} .. {left}z2e;
80         addto currentpicture also currentpicture xscaled -1;
81         addto currentpicture also currentpicture yscaled -1;
82
83         z3 = (0, -h);
84         z4 = (0, -1.5h);
85         penlabels(3,4);
86         draw_brush(z3,1.4*thin, z4,0.9*thick);
87 fet_endchar;
88
89 %
90 % FIXME: rounded endings
91 %
92 % `\accent' is TeX reserved.
93 fet_beginchar("> accent", "sforzato", "sforzatoaccent")
94         set_char_box(.9 staff_space#, .9 staff_space#, .5 staff_space#, .5 staff_space#);
95         save thickness, diminish;
96
97         thickness = 3/2 stafflinethickness;
98         pickup pencircle scaled thickness;
99
100         % prevent blobs at crossing lines
101         diminish = .75;
102
103         top y1 = h;
104         lft x1 = -b;
105         rt x2 = w;
106         y2 = .25 thickness* diminish;
107
108         rt z4 = (w,0);
109         x3 =0;
110         z3 = whatever [z1, z4];
111
112         penpos2(thickness*(2 - diminish)/2 , 90);
113         penpos1(thickness, 90);
114         penpos3(thickness, 90);
115
116         draw z1 .. z3;
117         draw (z1 .. z3) yscaled -1;
118         draw z4;
119         penstroke z3e .. z2e;
120         penstroke (z3e .. z2e) yscaled -1;
121
122         penlabels(1,2,3);
123         labels(4);
124 fet_endchar;
125
126 fet_beginchar("staccato dot", "staccato", "staccato")
127         save radius;
128         radius# = 1.5 stafflinethickness#;
129         define_pixels(radius);
130         pickup pencircle scaled 2 radius;
131         draw (0,0);
132         set_char_box(radius#, radius#, radius#, radius#);
133 fet_endchar;
134
135 def draw_staccatissimo =
136         save radius, height;
137         height# = .8 staff_space#;
138         radius# = 2 stafflinethickness#;
139         define_pixels(radius, height);
140
141         draw_brush((0,0), stafflinethickness, (0, height),2 radius);
142         set_char_box(radius#,radius#, blot_diameter#/2, height# + radius#);
143 enddef;
144
145 fet_beginchar("staccatissimo/martellato up", "ustaccatissimo", 
146                 "ustaccatissimo")
147         draw_staccatissimo;
148 fet_endchar;
149
150 %
151 % FIXEM: scale labels too.
152 %
153 fet_beginchar("staccatissimo/martellato down", "dstaccatissimo", "dstaccatissimo")
154         draw_staccatissimo;
155         y_mirror_char;
156 fet_endchar;
157
158 fet_beginchar("portato/single tenuto", "tenuto", "tenuto")
159         save thick;
160         thick# = 1.4 stafflinethickness#;
161         define_pixels(thick);
162
163         set_char_box(.6 staff_space#, .6 staff_space#, thick#/2,thick#/2);
164         pickup pencircle scaled thick;
165         lft x1 = -b;
166         rt x2 = w;
167         y1 = y2 = 0;
168         draw z1 .. z2;
169 fet_endchar;
170
171
172 def draw_marcato = 
173         save fat_factor, thinness;
174         set_char_box(staff_space#/2, staff_space#/2, 0, 1.1 staff_space#);
175
176         fat_factor = .3;
177         thinness =  stafflinethickness;
178
179         pickup pencircle scaled thinness;
180         rt x2 = w;
181         lft x5 = -b;
182         bot y5 = 0;
183         top y3 = h;
184         y1 = y2 = y5;
185
186         x3 =0;
187         z1 - z4 = whatever * (charwd, -charht);
188         z4 = fat_factor [z3, z5];
189
190         filldraw z1 -- z2 -- z3 -- z4 -- cycle;
191         draw z3 .. z5;
192 enddef;
193
194 fet_beginchar("marcato up", "umarcato", "umarcato")
195         draw_marcato;
196         labels(1,2,3,4,5);
197 fet_endchar;
198
199
200 %
201 % The down marcato char (not very much used). 
202 % Contrary to what some MF/TeX `gurus' believe
203 % it is *point*-symmetric with the "up" version
204 fet_beginchar("marcato down", "dmarcato", "dmarcato")
205         draw_marcato;
206         xy_mirror_char;
207 fet_endchar;
208  
209
210 %
211 % used in french horn music todo
212 %
213 % TODO: too light at 20pt
214 fet_beginchar("open (unstopped)", "open", "ouvert")
215         save thin, height, width, thick;
216         height# = 5/4 width#;
217         height# = staff_space#;
218         thin = 1.2 stafflinethickness;
219         thick =  1.4 thin;
220         set_char_box(width#/2, width#/2, height#/2, height#/2);
221         
222         penpos1(thick, 0);
223         penpos2(thin, 90);
224         z1r = (w, 0);
225         z2r = (0, h);
226         penlabels(1,2);
227         penstroke z1e{up} .. {left}z2e;
228         addto currentpicture also currentpicture xscaled -1;
229         addto currentpicture also currentpicture yscaled -1;
230 fet_endchar;
231
232
233 fet_beginchar("plus (stopped)", "stopped", "plusstop")
234         save thick, size;
235         thick = 2 stafflinethickness;
236         size# = 1.1 staff_space#;
237
238         set_char_box(size#/2, size#/2, size#/2, size#/2);
239         pickup pencircle scaled thick;
240
241         rt x1 = w;
242         y1 = 0;
243         z2 = -z1;
244
245         draw z1 .. z2;
246         draw (z1 .. z2) rotated 90;
247 fet_endchar;
248
249 %
250 % FIXME: blotting 
251 %
252 fet_beginchar("Upbow", "upbow", "upbow")
253         save ht, wd, thick;
254
255         thick = 1.4 stafflinethickness;
256         wd# = 1.3 staff_space#;
257         ht# = 1.6 wd#; 
258
259         
260         set_char_box(wd#/2, wd#/2, 0, ht#);
261         pickup pencircle scaled thick;
262
263         x1 = 0;
264         bot y1 = 0;
265         rt x2 =  w;
266         top y2 = h;
267
268         labels(1,2);
269         draw z2 -- z1 -- (z2 xscaled -1);
270 fet_endchar;
271
272
273 fet_beginchar("Downbow", "downbow", "downbow")
274         save stemthick, beamheight;
275         save wd;
276         define_pixels(wd)
277
278         wd# = 1.5 staff_space#;
279         stemthick = 1.2 stafflinethickness;
280
281         set_char_box(wd#/2, wd#/2, 0, 4/3 staff_space#);
282
283         beamheight = 4/10 h;
284
285
286         pickup pencircle scaled blot_diameter;
287         top y2 - bot y1  = beamheight;
288         top y2 = h;
289         rt x1 = w;
290         x1 = x2;
291         y2 = y3;
292         y1 = y4;
293         x3 = 0;
294         x4 = x3;
295         save p;
296         path p;
297         filldraw z1 -- z2 -- z3 -- z4 --cycle;
298
299         pickup pencircle scaled stemthick;
300
301         bot y5 =0;
302         rt x5 = rt x6 = w;
303         y6 = h - beamheight;
304         draw z6 -- z5;
305         labels(1, 2,3,4,5,6);
306         addto currentpicture also currentpicture xscaled -1;
307 fet_endchar;
308
309 %
310 % Inspired by a computer-set version of Auf dem Strom by Baerenreiter. 
311 %
312
313 def draw_turn =
314         save thin, thick, ball_diam, darkness;
315         save wd, ht, thick_nibangle, ball_nib_thick;
316         save turndir;
317         pair turndir;
318
319         wd# = 35/16 staff_space#;
320         ht# = 18/17 staff_space#;
321         darkness = 1.20 stafflinethickness;
322
323         set_char_box(wd#/2, wd#/2, ht#/2, ht#/2);       
324
325         thick_nibangle = 60;
326         thick = 3 darkness;
327         thin = darkness;
328         ball_nib_thick = 2.7 darkness;
329         ball_diam = ball_nib_thick + (h - ball_nib_thick) / 10;
330
331         
332         x3l = w;
333         y3 = 0;
334         y4l = h;
335         x4 = x2;
336         x2l = w/2;
337         y2l = -d;
338         z1 = (0,0);
339
340         penpos1(1.1 thick, thick_nibangle);
341         penpos2(thick, thick_nibangle);
342         penpos3(thin, 180);
343         penpos4(ball_nib_thick, -90);
344
345         path swoosh, ploop;
346         swoosh :=  z1l{curl 0} .. z2l .. z3l{up} .. {left}z4l 
347           -- z4r .. z3r{down} .. z2r{left} ;
348         fill swoosh .. (swoosh scaled -1) .. cycle;
349
350         x5r = x4;
351         y5r = y4l - ball_diam /2;
352         z6r = z5r;
353
354         penpos5(1.6 ball_diam/2, 10);
355         penpos6(ball_diam/2, 150);
356
357         ploop := z4l{left} .. z5l .. z6l -- cycle;
358         fill ploop;
359         fill ploop scaled -1;
360
361
362 enddef;
363
364 fet_beginchar("Reverse turn","reverseturn","reverseturn")
365         draw_turn;
366         currentpicture := currentpicture yscaled -1;
367         penlabels(5,6,7);
368         penlabels(2,3,4);
369 fet_endchar;
370
371
372 fet_beginchar("Turn","turn","turn")
373         draw_turn;
374                 
375         penlabels(5,6,7);
376         penlabels(1,2,3,4);
377 fet_endchar;
378
379
380
381 %
382 % Inspired by a (by now) PD edition of Durand & C'ie edition of 
383 % Saint-Saens' Celloconcerto no. 1 
384 %
385 % FIXME take out hardcoded vars.
386 % FIXME the two loops on the `t' should be smoother (and the left one bigger).
387 % FIXME generic macros for serifs: top of the t and bottom of r
388 %
389
390
391 fet_beginchar("Trill (`tr')","trill","trill")
392         
393         save start_nib_angle,  ascender_extra, ex, hair_thick, fatness,
394           slant_angle, slant, t_fatness, r_fatness, kerning, t_overshoot, 
395           uitschieter, bulb_size;
396         ;
397         pair slant_vec;
398
399         ascender_extra# = 1/2 ex#;
400         ascender# = ascender_extra# + ex#;
401         ex# = 1.5 staff_space#;
402         kerning# = .75 ex#;
403         start_nib_angle = 20;
404         bulb_size = 0.47;
405         define_pixels(ex, ascender_extra, ascender, kerning);
406
407         t_overshoot = 0.03 ex;
408         fatness = 12/40 ex;
409         t_fatness = 8/10 fatness;
410         r_fatness = .75 fatness;
411         uitschieter = 21/40 ex;
412         hair_thick =  blot_diameter;
413
414         slant = .2;
415
416         local_copy(transform)(currenttransform);
417         currenttransform := currenttransform slanted slant shifted (- staff_space, 0)  ;
418
419         y1 = ascender;
420         x1l = 0;
421         x1r = t_fatness;
422         penpos1(start_nib_wid, start_nib_angle);
423         
424         z2 = (x1, 7/18 ex);
425         penpos2(start_nib_wid, start_nib_angle);
426
427         z3l = (11/10 t_fatness, - t_overshoot);
428
429         z4l = (13/6 t_fatness, 5/16 ex);
430         penpos4(hair_thick, 180);
431
432         1.9 [z3l, z3r] = z4r;
433         z3 = .5 [z3l, z3r];
434         
435         save t_p, krul_p;
436         path t_p, krul_p, r_p;
437
438
439         t_p := z1l -- z2l{down} .. tension (1 + .5 slant)
440                 .. z3l{right} 
441                 
442                 .. z4l{up} -- z4r{down} 
443                 .. z3r{left} .. z2r{up} .. z1r -- cycle;
444         fill t_p ;
445
446         krul_ang = 32;
447
448         pickup pencircle scaled hair_thick;
449
450         z5 = (t_fatness/2, 2/3 ex);
451         
452         lft x6 = - uitschieter;
453         y6 =  y5 - 1/20 ex;
454
455         z7 = z5 + whatever*dir krul_ang;
456         up_angle = krul_ang;
457         % angle (z7-z5)
458         x7 = 5/10 kerning + x5;
459         
460         penpos7(hair_thick, up_angle + 90);
461
462         
463         x8l = .7 [x9r, x7r];
464         y8l = y7l;
465         penpos8(2 hair_thick, (up_angle +90)/2);
466
467         y9 = 3/4 ex;
468         x9 = x1 + kerning;
469         penpos9(r_fatness, 0);
470
471         x10 = x9;
472         y10 = 0;
473         penpos10(r_fatness, 0);
474
475         krul_p := z4{up} .. tension 1.1  .. z5 
476                 .. tension 1 and .75 .. {down}z6
477                 .. tension .85 and 1.1 .. z5 --- z7;
478         draw krul_p;
479         r_p := z7l{z7-z5} .. z8l{right} .. z9l{down} --- z10l -- z10r
480                 --- z9r{up} 
481                 ..  z8r{left} ..  z7r{z5-z7} -- cycle;
482         fill r_p;
483         set_char_box(staff_space# , staff_space#, 0,ascender#);
484
485
486         penpos11(1/4 r_fatness, -20);
487         z11r = z9r;
488         
489         z13 = (x9 + 2 r_fatness, y11 );
490         penpos13(r_fatness, 180);
491         fill z11r{dir 70} .. z13r{down} -- z13l{up} .. z11l{dir 250} -- cycle;
492         penlabels(range 1 thru 15);
493
494
495         draw_bulb(-1, z13r, z13l, bulb_size * r_fatness, 1.5);
496 fet_endchar;
497
498
499 def draw_heel =
500         save radius, thickness, wall;
501
502         radius# := .5 staff_space#;
503
504         define_pixels(radius);
505         set_char_box(radius#, radius#, radius#, 2/3 staff_space#);
506
507         thickness := 1.5 stafflinethickness;    
508         pickup pencircle scaled thickness;
509         rt x1 = b;
510         top y1 = h;
511         
512         x2 =x1;
513         y2 = 0;
514
515         x3 = 0;
516         bot y3 = -d;
517
518         draw z1{down} .. z2{down} .. z3{left};
519         addto currentpicture also currentpicture xscaled -1;
520         
521 enddef;
522
523
524 fet_beginchar("left heel", "upedalheel", "upedalheel")
525         draw_heel;
526         labels(1,2,3);
527 fet_endchar;
528
529 fet_beginchar("right heel", "dpedalheel", "dpedalheel")
530         draw_heel;
531         y_mirror_char;
532 fet_endchar;
533
534 def draw_toe =
535         save ht,wd;
536
537         thickness := 1.5 stafflinethickness;
538         ht# := 1.5 staff_space#;
539         wd# := 1/3 ht#;
540         define_pixels(ht,wd);
541
542
543         set_char_box(wd#, wd#, 0, ht#);
544         
545         pickup pencircle scaled thickness;
546         lft x1 = -b;
547         bot y1 = 0;
548         x2 =0;
549         top y2 = h;
550         z3 = z1 xscaled -1;
551
552
553         draw z1 -- z2 -- z3;
554
555 enddef;
556         
557 fet_beginchar("left toe", "upedaltoe", "upedaltoe")
558         draw_toe;
559         labels(1,2,3);
560 fet_endchar;
561 fet_beginchar("right toe", "dpedaltoe", "dpedaltoe")
562         draw_toe;
563         y_mirror_char;
564 fet_endchar;
565
566 fet_beginchar("Flageolet", "flageolet", "flageolet")
567         save height,width,thickness;
568         height#=4/15 staffsize#;
569         width#=height#;
570         thickness#=blot_diameter#;
571         define_pixels(height,width,thickness);
572         set_char_box(width#/2,width#/2,height#/2,height#/2);
573         
574         pickup pencircle scaled thickness;
575         x1= .5 [x2, x4];
576         x1 = 0;
577         top y1=height/2;
578         rt x4  - lft x2 =width; 
579         y2 = 0;
580         y4=y2;
581         x3=x1;
582         bot y3=-height/2;
583
584         penlabels(1,2,3,4);
585         draw z1..z2..z3..z4..cycle;
586 fet_endchar;
587
588 fet_beginchar("Segno", "segno", "segno")
589         save thin, thick, ball_diam, darkness, pointheight;
590         save wd, ht, thick_nibangle, ball_nib_thick;
591         save turndir;
592         pair turndir;
593
594         ht# = 3 staff_space#;
595         wd# = 2 staff_space#;
596         darkness = 1.20 stafflinethickness;
597
598         set_char_box(wd#/2, wd#/2, ht#/2, ht#/2);       
599
600         thick_nibangle = 30;
601         thick = 3 darkness;
602         thin = darkness;
603         ball_nib_thick = 2.7 darkness;
604         ball_diam = ball_nib_thick + (w - ball_nib_thick) / 10;
605         pointheight = 2 stafflinethickness;
606         
607         y3l = h;
608         2 x3 = x2 + x4;
609         x4 = 0;
610         y4 = y2;
611         y2l = .6 h;
612         x2l = -b;
613         z1 = (0,0);
614
615         penpos1(thick, 2 thick_nibangle);
616         penpos2(thick, thick_nibangle);
617         penpos3(thin, -90);
618         penpos4(ball_nib_thick, 180-thick_nibangle);
619
620         path swoosh, ploop;
621         swoosh :=  z1l{curl 0} .. z2l .. z3l{right} .. {down}z4l 
622           -- z4r .. z3r{left} .. z2r{down} ;
623         fill swoosh .. (swoosh scaled -1) .. cycle;
624         penlabels(1,2,3,4);
625
626         y5r = y4;
627         x5r = x4l - ball_diam /2;
628         z6r = z5r;
629
630         penpos5(1.6 ball_diam/2, 100);
631         penpos6(ball_diam/2, 240);
632
633         ploop := z4l{down} .. z5l .. z6l -- cycle;
634         fill ploop;
635         fill ploop scaled -1;
636         penlabels(4,5,6);
637
638         penpos7(2 thin,0);
639         z7l=(-b,-d);
640         penpos8(2 thin,0);
641         z8r=(w,h);
642         filldraw z7l--z8l{right}--z8r{down}--z7r{right}--cycle;
643         pickup pencircle scaled 2 thin;
644         draw (-x2r,pointheight);
645         draw (x2r,-pointheight);
646 fet_endchar;
647
648 fet_beginchar("Coda", "coda", "coda")
649         save thin, thick, codawidth, codaheight;
650         thin# = 1.2 stafflinethickness#;
651         thick# = 3.5 stafflinethickness#;
652         codawidth# = 2/3 staff_space#;
653         codaheight# = 1 staff_space#;
654         define_pixels(thin, thick, codawidth, codaheight);
655
656         set_char_box(codawidth#+thick#, codawidth#+thick#,
657                 codaheight#+thick#, codaheight#+thick#);
658
659         penpos1(thick,0);
660         penpos2(thin,-90);
661         penpos3(thick,180);
662         x1l=-codawidth;
663         y2l=codaheight;
664         y1=0;
665         x2=0;
666         z3 = - z1;
667         penlabels(1,2,3);
668
669         path halfcoda;
670         halfcoda := z1l{up} .. z2l{right} .. z3l{down} -- 
671                 z3r{up} .. z2r{left} .. z1r{down} .. cycle;
672         fill halfcoda;
673         fill (halfcoda scaled -1);
674
675         pickup pencircle scaled thin;
676         draw (0,-h) -- (0,h);
677         draw (-w,0) -- (w,0);
678
679 fet_endchar;
680
681 thick#:=1/24designsize;
682 define_blacker_pixels(thick);
683
684 rthin:=1/8*staff_space;
685 rthick:=2thick+rthin;
686
687 def draw_arpeggio =
688         save alpha;
689         alpha:=-40;
690         save ne,nw,se,sw; pair ne,nw,se,sw;
691         save x,y;
692         
693         se=dir alpha; nw=dir (alpha+180);
694         ne=dir (alpha+90); sw=dir (alpha-90);
695         penpos1(rthin,alpha+90);
696         penpos2(5/4rthick,alpha);
697         penpos4(5/4rthick,alpha);
698         penpos5(rthin,alpha+90);
699         penpos3(3/4rthick,alpha);
700
701         z1=(width/2, height) - overshoot*se;
702         z2=2[z4,(width/2,height/2)];
703         z3=1/2[z2,z4];
704         x4=2/8staff_space;
705         y4=rthin;
706
707         z5=2[z1,(width/2,height/2)];
708         z6=z2l+1/2rthin*sw;
709         z7=z4l+1/2rthin*sw+1/2rthin*se;
710         z8=2[z6,(width/2,height/2)];
711         z9=2[z7,(width/2,height/2)];
712         
713         fill z1l{se}..{se}z6..z3l..z7{se}..{se}z5l..z5r{nw}..{nw}z8..z3r..z9{nw}..{nw}z1r.. cycle;
714         penlabels(1,2,3,4,5,6,7,8,9);
715         enddef;
716
717 fet_beginchar("Arpeggio","arpeggio","arpeggio");
718         %draw_staff (-2, 2, 0.0);       
719         save height, overshoot, width;
720         height# = staff_space#;
721         width# = 0.8height#;
722         overshoot# = 0.25 staff_space#;
723         define_pixels (height,overshoot,width);
724         set_char_box(0, width#, 0, height#);
725         draw_arpeggio;
726         fet_endchar;
727
728 % Extendable Trill symbol.
729 % Not yet used
730 % Rename me to Trill, rename Trill to Tr?
731 fet_beginchar("Trill-element","trill-element","trill-element");
732         save height, overshoot;
733         height# = staff_space#;
734         width# = 0.8height#;
735         overshoot# = 0.25 staff_space#;
736         define_pixels (height,overshoot,width);
737         set_char_box(0, height#, 0, width#);
738         draw_arpeggio;
739         currentpicture := currentpicture shifted -(width/2, height/2);
740         currentpicture := currentpicture rotated 90;
741         currentpicture := currentpicture shifted (height/2, width/2);
742         fet_endchar;
743
744 % Hmm
745 input feta-slag;
746
747 fet_endgroup("scripts");
748