]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-schrift.mf
patch::: 1.1.3.tca1
[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, 1998 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 =  1.4 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         pickup pencircle scaled thin;
85         save x,y;
86         z3r = (0, -h);
87         z4 = (0, -2h);
88         penlabels(3,4);
89         draw z3r -- z4;
90 fet_endchar;
91
92
93 %
94 % FIXME: rounded endings
95 %
96 % `\accent' is TeX reserved.
97 fet_beginchar("> accent", "sforzato", "sforzatoaccent")
98         set_char_box(.9 interline#, .9 interline#, .5 interline#, .5 interline#);
99         save thickness, diminish;
100
101         thickness = 3/2 stafflinethickness;
102         pickup pencircle scaled thickness;
103
104         % prevent blobs at crossing lines
105         diminish = .75;
106
107         top y1 = h;
108         lft x1 = -b;
109         rt x2 = w;
110         y2 = .25 thickness* diminish;
111
112         rt z4 = (w,0);
113         x3 =0;
114         z3 = whatever [z1, z4];
115
116         penpos2(thickness*(2 - diminish)/2 , 90);
117         penpos1(thickness, 90);
118         penpos3(thickness, 90);
119
120         draw z1 .. z3;
121         draw (z1 .. z3) yscaled -1;
122         draw z4;
123         penstroke z3e .. z2e;
124         penstroke (z3e .. z2e) yscaled -1;
125
126         penlabels(1,2,3);
127         labels(4);
128 fet_endchar;
129
130 fet_beginchar("staccato dot", "staccato", "staccato")
131         save radius;
132         radius# = 1.5 stafflinethickness#;
133         define_pixels(radius);
134         pickup pencircle scaled 2 radius;
135         draw (0,0);
136         set_char_box(radius#, radius#, radius#, radius#);
137 fet_endchar;
138
139 def draw_staccatissimo =
140         save radius, height;
141         height# = .8 interline#;
142         radius# = 2 stafflinethickness#;
143         define_pixels(radius, height);
144
145         draw_brush((0,0), stafflinethickness, (0, height),2 radius);
146         set_char_box(radius#,radius#, blot_diameter#/2, height# + radius#);
147 enddef;
148
149 fet_beginchar("staccatissimo/martellato up", "ustaccatissimo", 
150                 "ustaccatissimo")
151         draw_staccatissimo;
152 fet_endchar;
153
154 %
155 % FIXEM: scale labels too.
156 %
157 fet_beginchar("staccatissimo/martellato down", "dstaccatissimo", "dstaccatissimo")
158         draw_staccatissimo;
159         y_mirror_char;
160 fet_endchar;
161
162 fet_beginchar("portato/single tenuto", "tenuto", "tenuto")
163         save thick;
164         thick# = 1.4 stafflinethickness#;
165         define_pixels(thick);
166
167         set_char_box(.6 interline#, .6 interline#, thick#/2,thick#/2);
168         pickup pencircle scaled thick;
169         lft x1 = -b;
170         rt x2 = w;
171         y1 = y2 = 0;
172         draw z1 .. z2;
173 fet_endchar;
174
175
176 def draw_marcato = 
177         save fat_factor, thinness;
178         set_char_box(interline#/2, interline#/2, 0, 1.1 interline#);
179
180         fat_factor = .3;
181         thinness =  stafflinethickness;
182
183         pickup pencircle scaled thinness;
184         rt x2 = w;
185         lft x5 = -b;
186         bot y5 = 0;
187         top y3 = h;
188         y1 = y2 = y5;
189
190         x3 =0;
191         z1 - z4 = whatever * (charwd, -charht);
192         z4 = fat_factor [z3, z5];
193
194         filldraw z1 -- z2 -- z3 -- z4 -- cycle;
195         draw z3 .. z5;
196 enddef;
197
198 fet_beginchar("marcato up", "umarcato", "umarcato")
199         draw_marcato;
200         labels(1,2,3,4,5);
201 fet_endchar;
202
203
204 %
205 % The down marcato char (not very much used). 
206 % Contrary to what some MF/TeX `gurus' believe
207 % it is *point*-symmetric with the "up" version
208 fet_beginchar("marcato down", "dmarcato", "dmarcato")
209         draw_marcato;
210         xy_mirror_char;
211 fet_endchar;
212  
213
214 %
215 % used in french horn music todo
216 %
217 % TODO: too light at 20pt
218 fet_beginchar("open (unstopped)", "open", "ouvert")
219         save thin, height, width, thick;
220         height# = 5/4 width#;
221         height# = interline#;
222         thin = 1.2 stafflinethickness;
223         thick =  1.4 thin;
224         set_char_box(width#/2, width#/2, height#/2, height#/2);
225         
226         penpos1(thick, 0);
227         penpos2(thin, 90);
228         z1r = (w, 0);
229         z2r = (0, h);
230         penlabels(1,2);
231         penstroke z1e{up} .. {left}z2e;
232         addto currentpicture also currentpicture xscaled -1;
233         addto currentpicture also currentpicture yscaled -1;
234 fet_endchar;
235
236
237 fet_beginchar("plus (stopped)", "stopped", "plusstop")
238         save thick, size;
239         thick = 2 stafflinethickness;
240         size# = 1.1 interline#;
241
242         set_char_box(size#/2, size#/2, size#/2, size#/2);
243         pickup pencircle scaled thick;
244
245         rt x1 = w;
246         y1 = 0;
247         z2 = -z1;
248
249         draw z1 .. z2;
250         draw (z1 .. z2) rotated 90;
251 fet_endchar;
252
253 %
254 % FIXME: blotting 
255 %
256 fet_beginchar("Upbow", "upbow", "upbow")
257         save ht, wd, thick;
258
259         thick = 1.4 stafflinethickness;
260         wd# = 1.3 interline#;
261         ht# = 1.6 wd#; 
262
263         
264         set_char_box(wd#/2, wd#/2, 0, ht#);
265         pickup pencircle scaled thick;
266
267         x1 = 0;
268         bot y1 = 0;
269         rt x2 =  w;
270         top y2 = h;
271
272         labels(1,2);
273         draw z2 -- z1 -- (z2 xscaled -1);
274 fet_endchar;
275
276
277 fet_beginchar("Downbow", "downbow", "downbow")
278         save stemthick, beamheight;
279         save wd;
280         define_pixels(wd)
281
282         wd# = 1.5 interline#;
283         stemthick = 1.2 stafflinethickness;
284
285         set_char_box(wd#/2, wd#/2, 0, 4/3 interline#);
286
287         beamheight = 4/10 h;
288
289
290         pickup pencircle scaled blot_diameter;
291         top y2 - bot y1  = beamheight;
292         top y2 = h;
293         rt x1 = w;
294         x1 = x2;
295         y2 = y3;
296         y1 = y4;
297         x3 = 0;
298         x4 = x3;
299         save p;
300         path p;
301         filldraw z1 -- z2 -- z3 -- z4 --cycle;
302
303         pickup pencircle scaled stemthick;
304
305         bot y5 =0;
306         rt x5 = rt x6 = w;
307         y6 = h - beamheight;
308         draw z6 -- z5;
309         labels(1, 2,3,4,5,6);
310         addto currentpicture also currentpicture xscaled -1;
311 fet_endchar;
312
313 %
314 % Inspired by a computer-set version of Auf dem Strom by Baerenreiter. 
315 %
316
317 def draw_turn =
318         save thin, thick, ball_diam, darkness;
319         save wd, ht, thick_nibangle, ball_nib_thick;
320         save turndir;
321         pair turndir;
322
323         wd# = 35/16 interline#;
324         ht# = 18/17 interline#;
325         darkness = 1.20 stafflinethickness;
326
327         set_char_box(wd#/2, wd#/2, ht#/2, ht#/2);       
328
329         thick_nibangle = 60;
330         thick = 3 darkness;
331         thin = darkness;
332         ball_nib_thick = 2.7 darkness;
333         ball_diam = ball_nib_thick + (h - ball_nib_thick) / 10;
334
335         
336         x3l = w;
337         y3 = 0;
338         y4l = h;
339         x4 = x2;
340         x2l = w/2;
341         y2l = -d;
342         z1 = (0,0);
343
344         penpos1(1.1 thick, thick_nibangle);
345         penpos2(thick, thick_nibangle);
346         penpos3(thin, 180);
347         penpos4(ball_nib_thick, -90);
348
349         path swoosh, ploop;
350         swoosh :=  z1l{curl 0} .. z2l .. z3l{up} .. {left}z4l 
351           -- z4r .. z3r{down} .. z2r{left} ;
352         fill swoosh .. (swoosh scaled -1) .. cycle;
353
354         x5r = x4;
355         y5r = y4l - ball_diam /2;
356         z6r = z5r;
357
358         penpos5(1.6 ball_diam/2, 10);
359         penpos6(ball_diam/2, 150);
360
361         ploop := z4l{left} .. z5l .. z6l -- cycle;
362         fill ploop;
363         fill ploop scaled -1;
364
365
366 enddef;
367
368 fet_beginchar("Reverse turn","reverseturn","reverseturn")
369         draw_turn;
370         currentpicture := currentpicture yscaled -1;
371         penlabels(5,6,7);
372         penlabels(2,3,4);
373 fet_endchar;
374
375
376 fet_beginchar("Turn","turn","turn")
377         draw_turn;
378                 
379         penlabels(5,6,7);
380         penlabels(2,3,4);
381 fet_endchar;
382
383
384
385 %
386 % Inspired by a (by now) PD edition of Durand & C'ie edition of 
387 % Saint-Saens' Celloconcerto no. 1 
388 %
389 % FIXME take out hardcoded vars.
390 % FIXME the two loops on the `t' should be smoother (and the left one bigger).
391 % FIXME generic macros for serifs: top of the t and bottom of r
392 %
393
394
395 fet_beginchar("Trill (`tr')","trill","trill")
396         
397         save start_nib_angle,  ascender_extra, ex, hair_thick, fatness,
398           slant_angle, slant, t_fatness, r_fatness, kerning, t_overshoot, 
399           uitschieter, bulb_size;
400         ;
401         pair slant_vec;
402
403         ascender_extra# = 1/2 ex#;
404         ascender# = ascender_extra# + ex#;
405         ex# = 1.5 interline#;
406         kerning# = .75 ex#;
407         start_nib_angle = 20;
408         bulb_size = 0.47;
409         define_pixels(ex, ascender_extra, ascender, kerning);
410
411         t_overshoot = 0.03 ex;
412         fatness = 12/40 ex;
413         t_fatness = 8/10 fatness;
414         r_fatness = .75 fatness;
415         uitschieter = 21/40 ex;
416         hair_thick =  blot_diameter;
417
418         slant = .2;
419
420         local_copy(transform)(currenttransform);
421         currenttransform := currenttransform slanted slant shifted (- interline, 0)  ;
422
423         y1 = ascender;
424         x1l = 0;
425         x1r = t_fatness;
426         penpos1(start_nib_wid, start_nib_angle);
427         
428         z2 = (x1, 7/18 ex);
429         penpos2(start_nib_wid, start_nib_angle);
430
431         z3l = (11/10 t_fatness, - t_overshoot);
432
433         z4l = (13/6 t_fatness, 5/16 ex);
434         penpos4(hair_thick, 180);
435
436         1.9 [z3l, z3r] = z4r;
437         z3 = .5 [z3l, z3r];
438         
439         save t_p, krul_p;
440         path t_p, krul_p, r_p;
441
442
443         t_p := z1l -- z2l{down} .. tension (1 + .5 slant)
444                 .. z3l{right} 
445                 
446                 .. z4l{up} -- z4r{down} 
447                 .. z3r{left} .. z2r{up} .. z1r -- cycle;
448         fill t_p ;
449
450         krul_ang = 32;
451
452         pickup pencircle scaled hair_thick;
453
454         z5 = (t_fatness/2, 2/3 ex);
455         
456         lft x6 = - uitschieter;
457         y6 =  y5 - 1/20 ex;
458
459         z7 = z5 + whatever*dir krul_ang;
460         up_angle = krul_ang;
461         % angle (z7-z5)
462         x7 = 5/10 kerning + x5;
463         
464         penpos7(hair_thick, up_angle + 90);
465
466         
467         x8l = .7 [x9r, x7r];
468         y8l = y7l;
469         penpos8(2 hair_thick, (up_angle +90)/2);
470
471         y9 = 3/4 ex;
472         x9 = x1 + kerning;
473         penpos9(r_fatness, 0);
474
475         x10 = x9;
476         y10 = 0;
477         penpos10(r_fatness, 0);
478
479         krul_p := z4{up} .. tension 1.1  .. z5 
480                 .. tension 1 and .75 .. {down}z6
481                 .. tension .85 and 1.1 .. z5 --- z7;
482         draw krul_p;
483         r_p := z7l{z7-z5} .. z8l{right} .. z9l{down} --- z10l -- z10r
484                 --- z9r{up} 
485                 ..  z8r{left} ..  z7r{z5-z7} -- cycle;
486         fill r_p;
487         set_char_box(interline# , interline#, 0,ascender#);
488
489
490         penpos11(1/4 r_fatness, -20);
491         z11r = z9r;
492         
493         z13 = (x9 + 2 r_fatness, y11 );
494         penpos13(r_fatness, 180);
495         fill z11r{dir 70} .. z13r{down} -- z13l{up} .. z11l{dir 250} -- cycle;
496         penlabels(range 1 thru 15);
497
498
499         draw_bulb(-1, z13r, z13l, bulb_size * r_fatness, 1.5);
500 fet_endchar;
501
502
503 def draw_heel =
504         save radius, thickness, wall;
505
506         radius# := .5 interline#;
507
508         define_pixels(radius);
509         set_char_box(radius#, radius#, radius#, 2/3 interline#);
510
511         thickness := 1.5 stafflinethickness;    
512         pickup pencircle scaled thickness;
513         rt x1 = b;
514         top y1 = h;
515         
516         x2 =x1;
517         y2 = 0;
518
519         x3 = 0;
520         bot y3 = -d;
521
522         draw z1{down} .. z2{down} .. z3{left};
523         addto currentpicture also currentpicture xscaled -1;
524         
525 enddef;
526
527
528 fet_beginchar("left heel", "upedalheel", "upedalheel")
529         draw_heel;
530         labels(1,2,3);
531 fet_endchar;
532
533 fet_beginchar("right heel", "dpedalheel", "dpedalheel")
534         draw_heel;
535         y_mirror_char;
536 fet_endchar;
537
538 def draw_toe =
539         save ht,wd;
540
541         thickness := 1.5 stafflinethickness;
542         ht# := 1.5 interline#;
543         wd# := 1/3 ht#;
544         define_pixels(ht,wd);
545
546
547         set_char_box(wd#, wd#, 0, ht#);
548         
549         pickup pencircle scaled thickness;
550         lft x1 = -b;
551         bot y1 = 0;
552         x2 =0;
553         top y2 = h;
554         z3 = z1 xscaled -1;
555
556
557         draw z1 -- z2 -- z3;
558
559 enddef;
560         
561 fet_beginchar("left toe", "upedaltoe", "upedaltoe")
562         draw_toe;
563         labels(1,2,3);
564 fet_endchar;
565 fet_beginchar("right toe", "dpedaltoe", "dpedaltoe")
566         draw_toe;
567         y_mirror_char;
568 fet_endchar;
569
570 fet_beginchar("Flageolet", "flageolet", "flageolet")
571         save height,width,thickness;
572         height#=4/15 staffsize#;
573         width#=height#;
574         thickness#=blot_diameter#;
575         define_pixels(height,width,thickness);
576         set_char_box(width#/2,width#/2,height#/2,height#/2);
577         
578         pickup pencircle scaled thickness;
579         x1= .5 [x2, x4];
580         x1 = 0;
581         top y1=height/2;
582         rt x4  - lft x2 =width; 
583         y2 = 0;
584         y4=y2;
585         x3=x1;
586         bot y3=-height/2;
587
588         penlabels(1,2,3,4);
589         draw z1..z2..z3..z4..cycle;
590 fet_endchar;
591
592 input feta-slag;
593 input feta-accordion;
594
595 fet_endgroup("scripts");
596