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