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