]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-eindelijk.mf
(tracingvariables): add TODO.
[lilypond.git] / mf / feta-eindelijk.mf
1 % feta-eindelijk.mf -- implement rest symbols -*-Fundamental-*-
2 %
3 % part of LilyPond's pretty-but-neat music font
4 %
5 % source file of the Feta (not the Font-En-Tja) music font
6
7 % (c)  1997--2003 Jan Nieuwenhuizen <janneke@gnu.org>
8
9 fet_begingroup("rests");
10
11 begingroup
12
13 thick#:=1/16designsize;
14 define_blacker_pixels(thick);
15
16 rthin:=1/8*staff_space;
17 % rthick:=2rthin;
18 rthick:=2thick+rthin;
19
20 def shift_pic (expr pone, ptwo) =
21   currentpicture:=currentpicture shifted (round(pone),round(ptwo))
22 enddef;
23
24 % stuff for     8th,16th etc rests
25 %
26 save stem, ball_crook_stem, ball_crook_balldiam, flare;
27
28 % stem#:=1/8*staff_space#;
29 stem# = 1/5staff_space#;
30 % flare# = 2/3staff_space#;
31 flare# = 2/3staff_space# - 1/8stafflinethickness#;
32
33 define_pixels(stem,flare);
34
35 ball_crook_stem = stem;
36 ball_crook_balldiam =flare;
37
38
39 save block_rest_y, block_rest_x;
40
41 save breve_rest_y, breve_rest_x;
42
43 breve_rest_y# =  staff_space#;
44 breve_rest_x# = 3/5 staff_space#;
45 block_rest_y# = 5/8 staff_space#;
46 block_rest_x# = 3/2 staff_space#;
47
48 define_pixels(block_rest_y, block_rest_x);
49
50 def block_rest =
51         draw_block ((0,0), (block_rest_x, block_rest_y));
52         enddef;
53
54 fet_beginchar( "whole rest", "0", "wholerest");
55         set_char_box(0, block_rest_x#,
56                 block_rest_y#,  0);
57         block_rest;
58         currentpicture := currentpicture shifted (0,- block_rest_y);
59 fet_endchar;
60
61 fet_beginchar("half rest", "1", "halfrest");
62         set_char_box(0, block_rest_x#, 0, block_rest_y#);
63         block_rest;
64 fet_endchar;
65
66
67 %
68 % should use ledgerline thickness?
69 %
70 fet_beginchar( "whole rest (outside staff)", "0o", "outsidewholerest");
71         set_char_box(0, block_rest_x#,
72                 block_rest_y#, ledgerlinethickness#/2);
73         block_rest;
74         currentpicture := currentpicture shifted (0, - block_rest_y);
75         pickup pencircle scaled ledgerlinethickness;
76
77         y5 = y6 = 0;
78         lft x5 = - b - block_rest_y;
79         rt x6 = w + block_rest_y;
80         draw_gridline(z5,z6,ledgerlinethickness);
81 fet_endchar;
82
83 fet_beginchar("half rest (outside staff)", "1o", "outsidehalfrest");
84         set_char_box(0, block_rest_x#,
85                 ledgerlinethickness#/2, block_rest_y#);
86         block_rest;
87         pickup pencircle scaled ledgerlinethickness;
88         y5 = y6 = 0;
89         lft x5 = - b - block_rest_y ;  
90         rt x6 = w + block_rest_y;
91         draw_gridline (z5,z6,ledgerlinethickness);
92 fet_endchar;
93
94
95
96 define_pixels(breve_rest_y, breve_rest_x, multi_rest_x, multi_beam_height);
97
98 fet_beginchar("maxima rest", "-3", "maximarest");
99         set_char_box(0, 3 breve_rest_x#, breve_rest_y#, breve_rest_y#);
100         draw_block ((0,-floor (breve_rest_y)), (breve_rest_x, floor (breve_rest_y)));
101         addto currentpicture also currentpicture shifted (2 breve_rest_x, 0);
102 fet_endchar;
103
104 fet_beginchar("longa rest", "-2", "longarest");
105         set_char_box(0, breve_rest_x#, breve_rest_y#, breve_rest_y#);
106         draw_block ((0,-floor (breve_rest_y)), (breve_rest_x, floor (breve_rest_y)));
107 fet_endchar;
108
109 fet_beginchar("breve rest", "-1", "breverest");
110         set_char_box(0, breve_rest_x#, 0, breve_rest_y#);
111         draw_block ((0,0), (breve_rest_x, floor (breve_rest_y)));
112 fet_endchar;
113
114
115 tracingvariables := 1;
116
117 fet_beginchar("Quarter rest","2","quartrest");
118 %       draw_staff (-2, 2, 0.0);        
119         save alpha, yshift, height;
120         alpha:=-50;
121         yshift# = -1.25 staff_space#;
122         height# = 2.8125 staff_space#;
123         define_pixels (yshift, height);
124         save xcenter;
125         xcenter = -0.1 staff_space;
126         
127         set_char_box(0, 0.95 staff_space#,
128           -yshift#,
129           yshift# + height#);
130         
131         save ne,nw,se,sw; pair ne,nw,se,sw;
132         
133         se=dir alpha; nw=dir (alpha+180);
134         ne=dir (alpha+90); sw=dir (alpha-90);
135         penpos1(rthin,alpha+90);
136         penpos2(5/4rthick,alpha);
137         penpos4(5/4rthick,alpha);
138         penpos5(rthin,alpha+90);
139         penpos3(3/4rthick,alpha);
140 %       penpos6(5/8rthick,alpha);
141         penpos6(2/3rthick,alpha);
142         penpos7(1/2rthin,alpha+90);
143
144         z10=z2l+1/2rthin*sw;
145 %       z11=z4l+1/2rthin*sw;
146         z11=z4l+1/2rthin*sw+1/2rthin*se;
147         z12=z4r+1/2rthin*ne;
148 %       z13=z2r+1/2rthin*ne;
149         z13=z2r+1/2rthin*ne+1/2rthin*nw;
150
151         y1r = h;
152         x1l=xcenter +  1/3staff_space;
153         z2r=z1+staff_space*se;
154         z3=1/2[z2,z4];
155         x4= xcenter + 3/8staff_space;
156         y4= 0;
157         z5=z4l+1.3staff_space*se;
158         x6l=x4l;
159         y6l=y4r;
160         x7= xcenter + 2/5staff_space;
161         y7= -d;
162         
163         fill z1l{se}..{se}z10..z3l..z11{se}..{se}z5l..z5r{nw}..{nw}z12..z3r..z13{nw}..{nw}z1r.. cycle;
164         fill z5r{nw}..tension1.4..z6l..tension1.4..{se}z7l..z7r{nw}..tension1.4..z6r..tension1.4..{se}z5l..cycle;
165         penlabels(1,2,3,4,5,6,7);
166         penlabels(10,11,12,13);
167         
168 %         3/4 staff_space# + yshift#,
169 %         18/5staff_space# + yshift#)
170
171         fet_endchar;
172
173 def rest_crook(expr a, w) =
174         balled_crook(a, w, ball_crook_balldiam, ball_crook_stem)
175 enddef;
176
177 %
178 % Notes about 8th rest:  
179
180 % * 8th rest should be no wider than the black note head
181 %
182 % * The inside corner of the horizontal portion is usually a little blotted.
183 %
184 % * The top of the crook chops off the vertical brush
185
186 % * The crook widens a little
187 %
188 % * The bottom of the brush is slightly flat, as it has to align with
189 % stafflines if it is inside the staff.
190 %
191 % * The top of the brush usually is a little lower than the top of bulb.
192 %
193 % * The bulb can vary. Sometimes it is open (like in the clefs). Sometimes 
194 % it is closed, or even a flare.
195
196
197 % from an email to Rune Zedeler:
198 %
199
200 % For example, the 8th rest was vaguely based on a book with trumpet
201 % studies by Duhem, and by Baerenreiters cello suites. I included my
202 % findings in a comment in the mf file.  One of the things that I tried
203 % to do was make the rest a little lighter and narrower than the black
204 % note head. I think this looks better in polyphonic music, when the
205 % rest is below a head from a different voice.
206 %
207 %
208
209
210 def draw_rest_bulb(expr ycenter, ycut, pat, stretch) =
211 begingroup;
212         save x,y,pt;
213         z1l = point 0 of pat;
214         z2l = point 1 of pat;
215         z2r = point 3 of pat;
216         z1r = point 4 of pat;
217         z1 = 0.5[z1l,z1r];
218         z2 = 0.5[z2l,z2r];
219         y10 = ycenter;
220         z10 = whatever[z2, z1] + left*bulb_diam*stretch;
221
222
223         z3 = z10+bulb_diam/2.15*dir(-72) ;
224
225
226         x4 = x10+bulb_diam*.62 ;
227         y4 := ceiling (y10 - 2 stafflinethickness + crook_thin);
228
229         z5 = z10 + up*bulb_diam/2 + right*stafflinethickness/3;
230         
231
232         z7 = 0.5 [z4, z5] + (0.45 stafflinethickness,0.4 stafflinethickness);
233         x8 = x10-0.4bulb_diam;
234         y8 = y10 + 0.25 stafflinethickness;
235
236         z6 = whatever [z1l, z2l];
237         z6 = z3+whatever * dir(12);
238
239         (pt,whatever) = pat intersectiontimes ((0,ycut)--(w,ycut));
240
241         fill point pt of pat {-direction pt of pat} .. tension 2
242                 .. z4{left} .. tension 0.9 .. z7
243                 .. z5{left} .. z8 .. z3{right}
244                 .. {curl 0.2} z6 {right} .. tension 10 .. {left} point pt of pat -- cycle;
245
246         labels(3, 4, 5, 6, 7, 8, 9, 10);
247
248 endgroup;
249 enddef;
250
251 def draw_eighth_rest =
252         save width, bulb_diam, thin, thick;
253         save ycenter, crook_thick, crook_thin;
254         save crook_dir, lower_brush, pat;
255         pair crook_dir;
256         path pat;
257
258         width# := 1.0 staff_space#;
259         bulb_diam# := 0.64 staff_space#;
260         thin# := 1.2 stafflinethickness#;
261         thick# :=  2.2 stafflinethickness#;
262         crook_thick# := 1.8 stafflinethickness#;
263         crook_thin := 1.3 stafflinethickness;
264
265         lower_brush := 1.5 stafflinethickness;
266
267         define_pixels (width, bulb_diam, thin, thick, crook_thick);
268         set_char_box (0, width#,
269                 1.0 staff_space# + 0.5 stafflinethickness#, 0.5 staff_space# + bulb_diam#/2);
270
271         penpos1 (thick, 0);
272         penpos2 (thin, 10);
273
274         y1 = - staff_space ;
275         y2 = h -  lower_brush;
276         x2r = width;
277         z2 = z1 + whatever*dir(72);
278         z9 = z2 + 0.5 stafflinethickness * dir (angle(z2 - z1)- 10);
279         pat = z1l --- z2l .. z9 .. z2r --- simple_serif (z1r, z1l, -40) .. cycle;
280         fill pat;
281         
282
283         draw_rest_bulb(0.5 staff_space , y2r , pat , 1.0);
284         penlabels (1, 2);
285         labels(9);
286
287         % draw_staff (-2,2,0.0);
288
289         enddef;
290
291 fet_beginchar("Classical quarter rest","2classical","clasquartrest");
292         draw_eighth_rest;
293         currentpicture := currentpicture xscaled -1 shifted (w,0);
294         fet_endchar;
295
296 fet_beginchar("8th rest","3","eighthrest");
297         draw_eighth_rest;
298         fet_endchar;
299
300
301 %
302 % TODO: the X dimensions of the rests are fucked up:
303 % they can collide with augmentation dots. 
304 %
305
306 fet_beginchar("16th rest","4","sixteenthrest");
307         save width, bulb_diam, thin, thick;
308         save ycenter, crook_thick, crook_thin;
309         save crook_dir, lower_brush, pat;
310         pair crook_dir;
311         path pat;
312
313         width# := 1.2 staff_space#;
314         bulb_diam# := 0.64 staff_space#;
315         thin# := 1.2 stafflinethickness#;
316         thick# :=  2.2 stafflinethickness#;
317         crook_thick# := 1.8 stafflinethickness#;
318         crook_thin := 1.3 stafflinethickness;
319
320         lower_brush := 1.5 stafflinethickness;
321
322         define_pixels (width, bulb_diam, thin, thick, crook_thick);
323         set_char_box (0, width#,
324                 2.0 staff_space# + 0.5 stafflinethickness#, 0.5 staff_space# + bulb_diam#/2);
325
326         penpos1 (thick, 0);
327         penpos2 (thin, 10);
328
329         y1 = -2 staff_space ;
330         y2 = h -  lower_brush;
331         x2r = width;
332         z2 = z1 + whatever*dir(74);
333         z9 = z2 + 0.5 stafflinethickness * dir (angle(z2 - z1)- 10);
334         pat = z1l --- z2l .. z9 .. z2r --- simple_serif (z1r, z1l, -40) .. cycle;
335         fill pat;
336         
337
338         draw_rest_bulb(0.5 staff_space , y2r , pat , 0.98);
339         draw_rest_bulb(-0.5 staff_space , (-0.5+0.2)*staff_space , pat , 1.02);
340         penlabels (1, 2);
341         labels(9);
342
343         % draw_staff (-2,2,0.0);
344         fet_endchar;
345
346 fet_beginchar("32th rest","5","thirtysecondrest");
347         save width, bulb_diam, thin, thick;
348         save ycenter, crook_thick, crook_thin;
349         save crook_dir, lower_brush, pat;
350         pair crook_dir;
351         path pat;
352
353         width# := 1.3 staff_space#;
354         bulb_diam# := 0.64 staff_space#;
355         thin# := 1.2 stafflinethickness#;
356         thick# :=  2.2 stafflinethickness#;
357         crook_thick# := 1.8 stafflinethickness#;
358         crook_thin := 1.3 stafflinethickness;
359
360         lower_brush := 1.5 stafflinethickness;
361
362         define_pixels (width, bulb_diam, thin, thick, crook_thick);
363         set_char_box (0, width#,
364                 2.0 staff_space# + 0.5 stafflinethickness#, 1.5 staff_space# + bulb_diam#/2);
365
366         penpos1 (thick, 0);
367         penpos2 (thin, 10);
368
369         y1 = -2 staff_space ;
370         y2 = h -  lower_brush;
371         x2r = width;
372         z2 = z1 + whatever*dir(76);
373         z9 = z2 + 0.5 stafflinethickness * dir (angle(z2 - z1)- 10);
374         pat = z1l --- z2l .. z9 .. z2r --- simple_serif (z1r, z1l, -40) .. cycle;
375         fill pat;
376         
377
378         draw_rest_bulb(1.5 staff_space , y2r , pat , 0.96);
379         draw_rest_bulb(0.5 staff_space , (0.5+0.2)*staff_space , pat , 1.00);
380         draw_rest_bulb(-0.5 staff_space , (-0.5+0.21)*staff_space , pat , 1.04);
381         penlabels (1, 2);
382         labels(9);
383
384         % draw_staff (-2,2,0.0);
385         fet_endchar;
386
387 fet_beginchar("64th rest","6","sixtyfourthrest");
388         save width, bulb_diam, thin, thick;
389         save ycenter, crook_thick, crook_thin;
390         save crook_dir, lower_brush, pat;
391         pair crook_dir;
392         path pat;
393
394         width# := 1.4 staff_space#;
395         bulb_diam# := 0.64 staff_space#;
396         thin# := 1.2 stafflinethickness#;
397         thick# :=  2.2 stafflinethickness#;
398         crook_thick# := 1.8 stafflinethickness#;
399         crook_thin := 1.3 stafflinethickness;
400
401         lower_brush := 1.5 stafflinethickness;
402
403         define_pixels (width, bulb_diam, thin, thick, crook_thick);
404         set_char_box (0, width#,
405                 3.0 staff_space# + 0.5 stafflinethickness#, 1.5 staff_space# + bulb_diam#/2);
406
407         penpos1 (thick, 0);
408         penpos2 (thin, 10);
409
410         y1 = -3 staff_space ;
411         y2 = h -  lower_brush;
412         x2r = width;
413         z2 = z1 + whatever*dir(78);
414         z9 = z2 + 0.5 stafflinethickness * dir (angle(z2 - z1)- 10);
415         pat = z1l --- z2l .. z9 .. z2r --- simple_serif (z1r, z1l, -40) .. cycle;
416         fill pat;
417         
418
419         draw_rest_bulb(1.5 staff_space , y2r , pat , 0.94);
420         draw_rest_bulb(0.5 staff_space , (0.5+0.20)*staff_space , pat , 0.98);
421         draw_rest_bulb(-0.5 staff_space , (-0.5+0.21)*staff_space , pat , 1.02);
422         draw_rest_bulb(-1.5 staff_space , (-1.5+0.22)*staff_space , pat , 1.06);
423         penlabels (1, 2);
424         labels(9);
425
426         % draw_staff (-2,2,0.0);
427         fet_endchar;
428
429 fet_beginchar("128th rest","7","hundredtwentyeighthrest");
430         save width, bulb_diam, thin, thick;
431         save ycenter, crook_thick, crook_thin;
432         save crook_dir, lower_brush, pat;
433         pair crook_dir;
434         path pat;
435
436         width# = 1.5 staff_space#;
437         bulb_diam# := 0.64 staff_space#;
438         thin# := 1.2 stafflinethickness#;
439         thick# :=  2.2 stafflinethickness#;
440         crook_thick# := 1.8 stafflinethickness#;
441         crook_thin := 1.3 stafflinethickness;
442
443         lower_brush := 1.5 stafflinethickness;
444
445         define_pixels (width, bulb_diam, thin, thick, crook_thick);
446         set_char_box (0, width#,
447                 3.0 staff_space# + 0.5 stafflinethickness#, 2.5 staff_space# + bulb_diam#/2);
448
449         penpos1 (thick, 0);
450         penpos2 (thin, 10);
451
452         y1 = -3 staff_space ;
453         y2 = h -  lower_brush;
454         x2r = width;
455         z2 = z1 + whatever*dir(80);
456         z9 = z2 + 0.5 stafflinethickness * dir (angle(z2 - z1)- 10);
457         pat = z1l --- z2l .. z9 .. z2r --- simple_serif (z1r, z1l, -40) .. cycle;
458         fill pat;
459         
460
461         draw_rest_bulb(2.5 staff_space , y2r , pat , 0.92);
462         draw_rest_bulb(1.5 staff_space , (1.5+0.20)*staff_space , pat , 0.96);
463         draw_rest_bulb(0.5 staff_space , (0.5+0.21)*staff_space , pat , 1.0);
464         draw_rest_bulb(-0.5 staff_space , (-0.5+0.22)*staff_space , pat , 1.04);
465         draw_rest_bulb(-1.5 staff_space , (-1.5+0.23)*staff_space , pat , 1.08);
466         penlabels (1, 2);
467         labels(9);
468
469         % draw_staff (-2,2,0.0);
470         fet_endchar;
471
472
473 endgroup;
474
475 fet_endgroup("rests")