]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-schrift.mf
release: 0.1.37
[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
175 fet_beginchar("marcato down", "dmarcato", "dmarcato")
176         draw_marcato;
177         xy_mirror_char;
178 fet_endchar;
179  
180 %
181 % used in french horn music todo
182 %
183 % TODO: too light at 20pt
184 fet_beginchar("open (unstopped)", "open", "ouvert")
185         save thin, height, width, thick;
186         height# = 5/4 width#;
187         height# = interline#;
188         thin = 1.2 stafflinethickness;
189         thick =  1.4 thin;
190         set_char_box(width#/2, width#/2, height#/2, height#/2);
191         
192         penpos1(thick, 0);
193         penpos2(thin, 90);
194         z1r = (w, 0);
195         z2r = (0, h);
196         penlabels(1,2);
197         penstroke z1e{up} .. {left}z2e;
198         addto currentpicture also currentpicture xscaled -1;
199         addto currentpicture also currentpicture yscaled -1;
200 fet_endchar;
201
202
203 fet_beginchar("plus (stopped)", "stopped", "plusstop")
204         save thick, size;
205         thick = 2 stafflinethickness;
206         size# = 1.1 interline#;
207
208         set_char_box(size#/2, size#/2, size#/2, size#/2);
209         pickup pencircle scaled thick;
210
211         rt x1 = w;
212         y1 = 0;
213         z2 = -z1;
214
215         draw z1 .. z2;
216         draw (z1 .. z2) rotated 90;
217 fet_endchar;
218
219 %
220 % FIXME: blotting 
221 %
222 fet_beginchar("Upbow", "upbow", "upbow")
223         save ht, wd, thick;
224
225         thick = 1.4 stafflinethickness;
226         wd# = 1.3 interline#;
227         ht# = 1.6 wd#; 
228
229         
230         set_char_box(wd#/2, wd#/2, 0, ht#);
231         pickup pencircle scaled thick;
232
233         x1 = 0;
234         bot y1 = 0;
235         rt x2 =  w;
236         top y2 = h;
237
238         labels(1,2);
239         draw z2 -- z1 -- (z2 xscaled -1);
240 fet_endchar;
241
242
243 fet_beginchar("Downbow", "downbow", "downbow")
244         save stemthick, beamheight;
245         save wd;
246         define_pixels(wd)
247
248         wd# = 1.5 interline#;
249         stemthick = 1.2 stafflinethickness;
250
251         set_char_box(wd#/2, wd#/2, 0, 4/3 interline#);
252
253         beamheight = 4/10 h;
254
255
256         pickup pencircle scaled blot_diameter;
257         top y2 - bot y1  = beamheight;
258         top y2 = h;
259         rt x1 = w;
260         x1 = x2;
261         y2 = y3;
262         y1 = y4;
263         x3 = 0;
264         x4 = x3;
265         save p;
266         path p;
267         filldraw z1 -- z2 -- z3 -- z4 --cycle;
268
269         pickup pencircle scaled stemthick;
270
271         bot y5 =0;
272         rt x5 = rt x6 = w;
273         y6 = h - beamheight;
274         draw z6 -- z5;
275         labels(1, 2,3,4,5,6);
276         addto currentpicture also currentpicture xscaled -1;
277 fet_endchar;
278
279 %
280 % Inspired by a computer-set version of Auf dem Strom by Baerenreiter. 
281 %
282 fet_beginchar("Turn","turn","turn")
283         save thin, thick, ball_diam, darkness;
284         save wd, ht, thick_nibangle, ball_nib_thick;
285         save turndir;
286         pair turndir;
287
288         wd# = 35/16 interline#;
289         ht# = 18/17 interline#;
290         darkness = 1.20 stafflinethickness;
291
292         set_char_box(wd#/2, wd#/2, ht#/2, ht#/2);
293
294         thick_nibangle = 60;
295         thick = 3 darkness;
296         thin = darkness;
297         ball_nib_thick = 2.7 darkness;
298         ball_diam = ball_nib_thick + (h - ball_nib_thick) / 10;
299
300         
301         x3l = w;
302         y3 = 0;
303         y4l = h;
304         x4 = x2;
305         x2l = w/2;
306         y2l = -d;
307         z1 = (0,0);
308
309         penpos1(1.1 thick, thick_nibangle);
310         penpos2(thick, thick_nibangle);
311         penpos3(thin, 180);
312         penpos4(ball_nib_thick, -90);
313
314         path swoosh, ploop;
315         swoosh :=  z1l{curl 0} .. z2l .. z3l{up} .. {left}z4l 
316           -- z4r .. z3r{down} .. z2r{left} ;
317         fill swoosh .. (swoosh scaled -1) .. cycle;
318         penlabels(2,3,4);
319
320         x5r = x4;
321         y5r = y4l - ball_diam /2;
322         z6r = z5r;
323
324         penpos5(1.6 ball_diam/2, 10);
325         penpos6(ball_diam/2, 150);
326
327         ploop := z4l{left} .. z5l .. z6l -- cycle;
328         fill ploop;
329         fill ploop scaled -1;
330
331
332         penlabels(5,6,7);
333         
334 fet_endchar;
335
336
337
338 %
339 % Inspired by a (by now) PD edition of Durand & C'ie edition of 
340 % Saint-Saens' Celloconcerto no. 1 
341 %
342 % FIXME take out hardcoded vars.
343 % FIXME the two loops on the `t' should be smoother (and the left one bigger).
344 % FIXME generic macros for serifs: top of the t and bottom of r
345 %
346
347
348 fet_beginchar("Trill (`tr')","trill","trill")
349         
350         save start_nib_angle,  ascender_extra, ex, hair_thick, fatness,
351           slant_angle, slant, t_fatness, r_fatness, kerning, t_overshoot, 
352           uitschieter, bulb_size;
353         ;
354         pair slant_vec;
355
356         ascender_extra# = 1/2 ex#;
357         ascender# = ascender_extra# + ex#;
358         ex# = 1.5 interline#;
359         kerning# = .75 ex#;
360         start_nib_angle = 20;
361         bulb_size = 0.47;
362         define_pixels(ex, ascender_extra, ascender, kerning);
363
364         t_overshoot = 0.03 ex;
365         fatness = 12/40 ex;
366         t_fatness = 8/10 fatness;
367         r_fatness = .75 fatness;
368         uitschieter = 21/40 ex;
369         hair_thick =  blot_diameter;
370
371         slant = .2;
372
373         local_copy(transform)(currenttransform);
374         currenttransform := currenttransform slanted slant;
375
376         y1 = ascender;
377         x1l = 0;
378         x1r = t_fatness;
379         penpos1(start_nib_wid, start_nib_angle);
380         
381         z2 = (x1, 7/18 ex);
382         penpos2(start_nib_wid, start_nib_angle);
383
384         z3l = (11/10 t_fatness, - t_overshoot);
385
386         z4l = (13/6 t_fatness, 5/16 ex);
387         penpos4(hair_thick, 180);
388
389         1.9 [z3l, z3r] = z4r;
390         z3 = .5 [z3l, z3r];
391         
392         save t_p, krul_p;
393         path t_p, krul_p, r_p;
394
395
396         t_p := z1l -- z2l{down} .. tension (1 + .5 slant)
397                 .. z3l{right} 
398                 
399                 .. z4l{up} -- z4r{down} 
400                 .. z3r{left} .. z2r{up} .. z1r -- cycle;
401         fill t_p ;
402
403         krul_ang = 32;
404
405         pickup pencircle scaled hair_thick;
406
407         z5 = (t_fatness/2, 2/3 ex);
408         
409         lft x6 = - uitschieter;
410         y6 =  y5 - 1/20 ex;
411
412         z7 = z5 + whatever*dir krul_ang;
413         up_angle = krul_ang;
414         % angle (z7-z5)
415         x7 = 5/10 kerning + x5;
416         
417         penpos7(hair_thick, up_angle + 90);
418
419         
420         x8l = .7 [x9r, x7r];
421         y8l = y7l;
422         penpos8(2 hair_thick, (up_angle +90)/2);
423
424         y9 = 3/4 ex;
425         x9 = x1 + kerning;
426         penpos9(r_fatness, 0);
427
428         x10 = x9;
429         y10 = 0;
430         penpos10(r_fatness, 0);
431
432         krul_p := z4{up} .. tension 1.1  .. z5 
433                 .. tension 1 and .75 .. {down}z6
434                 .. tension .85 and 1.1 .. z5 --- z7;
435         draw krul_p;
436         r_p := z7l{z7-z5} .. z8l{right} .. z9l{down} --- z10l -- z10r
437                 --- z9r{up} 
438                 ..  z8r{left} ..  z7r{z5-z7} -- cycle;
439         fill r_p;
440         set_char_box(0,2 interline#, 0,ascender#);
441
442
443         penpos11(1/4 r_fatness, -20);
444         z11r = z9r;
445         
446         z13 = (x9 + 2 r_fatness, y11 );
447         penpos13(r_fatness, 180);
448         fill z11r{dir 70} .. z13r{down} -- z13l{up} .. z11l{dir 250} -- cycle;
449         penlabels(range 1 thru 15);
450
451
452         draw_bulb(-1, z13r, z13l, bulb_size * r_fatness, 1.5);
453 fet_endchar;
454
455 fet_beginchar("organ-heel", "pedalheel", "pedalheel")
456         save radius, thickness, wall;
457
458         radius# := .5 interline#;
459
460         define_pixels(radius);
461         set_char_box(radius#, radius#, radius#, 2/3 interline#);
462
463         thickness := 1.5 stafflinethickness;    
464         pickup pencircle scaled thickness;
465         rt x1 = b;
466         top y1 = h;
467         
468         x2 =x1;
469         y2 = 0;
470
471         x3 = 0;
472         bot y3 = -d;
473
474         draw z1{down} .. z2{down} .. z3{left};
475         addto currentpicture also currentpicture xscaled -1;
476         labels(1,2,3);
477 fet_endchar;
478
479 fet_beginchar("organ-toe", "pedaltoe", "pedaltoe")
480         save ht,wd;
481
482         thickness := 1.5 stafflinethickness;
483         ht# := 1.5 interline#;
484         wd# := 1/3 ht#;
485         define_pixels(ht,wd);
486
487
488         set_char_box(wd#, wd#, 0, ht#);
489         
490         pickup pencircle scaled thickness;
491         lft x1 = -b;
492         bot y1 = 0;
493         x2 =0;
494         top y2 = h;
495         z3 = z1 xscaled -1;
496
497
498         draw z1 -- z2 -- z3;
499         labels(1,2,3);
500 fet_endchar;
501
502
503
504
505 fet_endgroup("scripts");