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