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