]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-schrift.mf
release: 0.1.30
[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
8
9
10 fet_begingroup("scripts")
11
12
13 def draw_fermata =
14         save alpha, radius, crook_thinness, crook_fatness, dot_diam;
15         
16         % [Wanske] and some  Baerenreiter editions
17         % suggest ca 80 degrees iso half-circle
18         alpha := 10;
19
20         radius# = 1.25 interline#;
21         crook_thinness# = 1.5stafflinethickness#;
22         crook_fatness# = 4 stafflinethickness#;
23
24         radius# + crook_fatness#/2 = h#;
25         radius# + crook_thinness#/2 = w#;
26         set_char_box(w#, w#, crook_thinness#/2, h#);
27         
28         define_pixels(radius, crook_thinness, crook_fatness);
29         dot_diam = 4/3 crook_fatness;
30
31
32         penpos1(crook_thinness, 0);
33         penpos2(crook_fatness, -90);
34         z1 = (-radius,0);
35         z2 = (0, radius);
36
37         fill z1l{dir (-alpha-90)}..{dir (90-alpha)}z1r..
38                 {right}z2r -- z2l{left} .. cycle;
39
40         addto currentpicture also 
41                 currentpicture xscaled -1;
42
43         pickup pencircle scaled dot_diam;
44         x4 =0;
45         bot y4 = - crook_thinness/2;
46         draw z4;
47 enddef;
48
49 fet_beginchar("fermata up", "ufermata", "ufermata")
50         draw_fermata;   
51         penlabels(1,2,4);
52 fet_endchar;
53
54 fet_beginchar("fermata down", "dfermata", "dfermata")
55         draw_fermata;
56         y_mirror_char;
57 fet_endchar;
58
59
60 %
61 % FIXME: rounded endings
62 %
63 % `\accent' is TeX reserved.
64 fet_beginchar("> accent", "sforzato", "sforzatoaccent")
65         set_char_box(.9 interline#, .9 interline#, .5 interline#, .5 interline#);
66         save thickness, diminish;
67
68         thickness = 2 stafflinethickness;
69         pickup pencircle scaled thickness;
70
71         % prevent blobs at crossing lines
72         diminish = .75;
73
74         top y1 = h;
75         lft x1 = -b;
76         rt x2 = w;
77         y2 = .25 thickness* diminish;
78
79         rt z4 = (w,0);
80         x3 =0;
81         z3 = whatever [z1, z4];
82
83         penpos2(thickness*(2 - diminish)/2 , 90);
84         penpos1(thickness, 90);
85         penpos3(thickness, 90);
86
87         draw z1 .. z3;
88         draw (z1 .. z3) yscaled -1;
89         draw z4;
90         penstroke z3e .. z2e;
91         penstroke (z3e .. z2e) yscaled -1;
92
93         penlabels(1,2,3);
94         labels(4);
95 fet_endchar;
96
97 fet_beginchar("staccato dot", "staccato", "staccato")
98         save radius;
99         radius# = 1.5 stafflinethickness#;
100         define_pixels(radius);
101         pickup pencircle scaled 2 radius;
102         draw (0,0);
103         set_char_box(radius#, radius#, radius#, radius#);
104 fet_endchar;
105
106 def draw_staccatissimo =
107         save radius, height;
108         height# = .8 interline#;
109         radius# = 2 stafflinethickness#;
110         define_pixels(radius, height);
111
112         draw_brush((0,0), stafflinethickness, (0, height),2 radius);
113         set_char_box(radius#,radius#, blot_diameter#/2, height# + radius#);
114 enddef;
115
116 fet_beginchar("staccatissimo/martellato up", "ustaccatissimo", 
117                 "ustaccatissimo")
118         draw_staccatissimo;
119 fet_endchar;
120
121 %
122 % FIXEM: scale labels too.
123 %
124 fet_beginchar("staccatissimo/martellato down", "dstaccatissimo", "dstaccatissimo")
125         draw_staccatissimo;
126         y_mirror_char;
127 fet_endchar;
128
129 fet_beginchar("portato/single tenuto", "tenuto", "tenuto")
130         save thick;
131         thick# = 1.2 stafflinethickness#;
132         define_pixels(thick);
133
134         set_char_box(.9 interline#, .9 interline#, thick#/2,thick#/2);
135         pickup pencircle scaled thick;
136         lft x1 = -b;
137         rt x2 = w;
138         y1 = y2 = 0;
139         draw z1 .. z2;
140 fet_endchar;
141
142
143 def draw_marcato = 
144         save fat_factor, thinness;
145         set_char_box(interline#/2, interline#/2, 0, 1.1 interline#);
146
147         fat_factor = .3;
148         thinness =  stafflinethickness;
149
150         pickup pencircle scaled thinness;
151         rt x2 = w;
152         lft x5 = -b;
153         bot y5 = 0;
154         top y3 = h;
155         y1 = y2 = y5;
156
157         x3 =0;
158         z1 - z4 = whatever * (charwd, -charht);
159         z4 = fat_factor [z3, z5];
160
161         filldraw z1 -- z2 -- z3 -- z4 -- cycle;
162         draw z3 .. z5;
163 enddef;
164
165 fet_beginchar("marcato up", "umarcato", "umarcato")
166         draw_marcato;
167         labels(1,2,3,4,5);
168 fet_endchar;
169
170
171 %
172 % The down marcato char (not very much used). 
173 % Contrary to what some MF/TeX `gurus' believe
174 % it is *point*-symmetric with the "up" version; (at least [Chlapik] and 
175 % and [Wanske] agree with us)
176 %
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;
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(0,2 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 fet_beginchar("organ-heel", "pedalheel", "pedalheel")
458         save radius, thickness, wall;
459
460         radius# := .5 interline#;
461
462         define_pixels(radius);
463         set_char_box(radius#, radius#, radius#, 2/3 interline#);
464
465         thickness := 1.5 stafflinethickness;    
466         pickup pencircle scaled thickness;
467         rt x1 = b;
468         top y1 = h;
469         
470         x2 =x1;
471         y2 = 0;
472
473         x3 = 0;
474         bot y3 = -d;
475
476         draw z1{down} .. z2{down} .. z3{left};
477         addto currentpicture also currentpicture xscaled -1;
478         labels(1,2,3);
479 fet_endchar;
480
481 fet_beginchar("organ-toe", "pedaltoe", "pedaltoe")
482         save ht,wd;
483
484         thickness := 1.5 stafflinethickness;
485         ht# := 1.5 interline#;
486         wd# := 1/3 ht#;
487         define_pixels(ht,wd);
488
489
490         set_char_box(wd#, wd#, 0, ht#);
491         
492         pickup pencircle scaled thickness;
493         lft x1 = -b;
494         bot y1 = 0;
495         x2 =0;
496         top y2 = h;
497         z3 = z1 xscaled -1;
498
499
500         draw z1 -- z2 -- z3;
501         labels(1,2,3);
502 fet_endchar;
503
504
505
506
507 fet_endgroup("scripts");