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