1 % feta-eindelijk.mf -- implement rest symbols -*-Fundamental-*-
3 % part of LilyPond's pretty-but-neat music font
5 % source file of the Feta (not the Font-En-Tja) music font
7 % (c) 1997--2006 Jan Nieuwenhuizen <janneke@gnu.org>
9 fet_begingroup ("rests");
11 save block_rest_y, block_rest_x;
12 save breve_rest_y, breve_rest_x;
14 breve_rest_y# = staff_space#;
15 breve_rest_x# = 3/5 staff_space#;
16 block_rest_y# = 5/8 staff_space#;
17 block_rest_x# = 3/2 staff_space#;
19 define_whole_pixels (block_rest_y, block_rest_x);
20 define_whole_pixels (breve_rest_y, breve_rest_x);
24 draw_block ((0, 0), (block_rest_x, block_rest_y));
28 fet_beginchar ("whole rest", "0");
29 set_char_box (0, block_rest_x#,
33 currentpicture := currentpicture
34 shifted (0, -block_rest_y + feta_space_shift);
36 draw_staff (-2, 2, 0);
40 fet_beginchar ("half rest", "1");
41 set_char_box (0, block_rest_x#, 0, block_rest_y#);
45 draw_staff (-2, 2, 0);
50 % should use ledgerline thickness?
52 fet_beginchar ("whole rest (outside staff)", "0o");
53 set_char_box (0, block_rest_x#,
54 block_rest_y#, ledgerlinethickness# / 2);
57 currentpicture := currentpicture shifted (0, -block_rest_y);
59 pickup pencircle scaled ledgerlinethickness;
62 lft x5 = -b - block_rest_y;
63 rt x6 = w + block_rest_y;
64 draw_gridline (z5, z6, ledgerlinethickness_rounded);
66 draw_staff (-2, 2, -3);
70 fet_beginchar ("half rest (outside staff)", "1o");
71 set_char_box (0, block_rest_x#,
72 ledgerlinethickness# / 2, block_rest_y#);
76 pickup pencircle scaled ledgerlinethickness;
79 lft x5 = -b - block_rest_y;
80 rt x6 = w + block_rest_y;
82 draw_gridline (z5, z6, ledgerlinethickness_rounded);
84 draw_staff (-2, 2, 3);
88 fet_beginchar ("maxima rest", "-3");
89 set_char_box (0, 3 breve_rest_x#, breve_rest_y#, breve_rest_y#);
91 draw_block ((0, -breve_rest_y + feta_shift),
92 (breve_rest_x, breve_rest_y));
94 addto currentpicture also currentpicture shifted (2 breve_rest_x, 0);
96 draw_staff (-2, 2, 0);
100 fet_beginchar ("longa rest", "-2");
101 set_char_box (0, breve_rest_x#, breve_rest_y#, breve_rest_y#);
103 draw_block ((0, -breve_rest_y + feta_shift),
104 (breve_rest_x, breve_rest_y));
106 draw_staff (-2, 2, 0);
110 fet_beginchar ("breve rest", "-1");
111 set_char_box (0, breve_rest_x#, 0, breve_rest_y#);
113 draw_block ((0, 0), (breve_rest_x, breve_rest_y));
115 draw_staff (-2, 2, 0);
119 fet_beginchar ("Quarter rest", "2");
120 save alpha, yshift, height;
123 yshift# := -1.25 staff_space#;
124 height# := 2.8125 staff_space#;
125 define_pixels (yshift, height);
128 thick := 1/4 staff_space;
129 rthin := 1.25 linethickness;
130 xcenter := -0.1 staff_space;
131 rthick := 2 thick + rthin;
133 set_char_box (0, 0.95 staff_space#, -yshift#, yshift# + height#);
139 ne = dir (alpha + 90);
140 nw = dir (alpha + 180);
141 sw = dir (alpha + 270);
143 penpos1 (rthin, alpha + 90);
144 penpos2 (5/4 rthick, alpha);
145 penpos4 (5/4 rthick, alpha);
146 penpos5 (rthin, alpha + 90);
147 penpos3 (3/4 rthick, alpha);
148 % penpos6 (5/8 rthick, alpha);
149 penpos6 (2/3 rthick, alpha);
150 penpos7 (1/2 rthin, alpha + 90);
152 z10 = z2l + 1/2 rthin * sw;
153 % z11 = z4l + 1/2 rthin * sw;
154 z11 = z4l + 1/2 rthin * sw + 1/2 rthin * se;
155 z12 = z4r + 1/2 rthin * ne;
156 % z13 = z2r + 1/2 rthin * ne;
157 z13 = z2r + 1/2 rthin * ne + 1/2 rthin * nw;
160 x1l = xcenter + 1/3 staff_space;
161 z2r = z1 + staff_space * se;
163 x4 = xcenter + 3/8 staff_space;
166 z5 = round (z4l + 1.3 staff_space * se) + feta_offset;
169 x6r := hround x6r + xpart feta_offset;
170 y6r := vround y6r + ypart feta_offset;
171 x7 = hround (xcenter + 2/5 staff_space) + xpart feta_offset;
180 (u, v) = before intersectiontimes after;
185 .. subpath (0, u) of before
186 .. subpath (v, infinity) of after
187 ..tension1.4.. {se}z7l
190 ..tension1.4.. {se}z5l
198 penlabels (1, 2, 3, 4, 5, 6, 7);
199 penlabels (10, 11, 12, 13);
201 draw_staff (-2, 2, 0);
206 % Notes about 8th rest:
208 % * 8th rest should be no wider than the black note head
210 % * The inside corner of the horizontal portion is usually a little blotted.
212 % * The top of the crook chops off the vertical brush
214 % * The crook widens a little
216 % * The bottom of the brush is slightly flat, as it has to align with
217 % stafflines if it is inside the staff.
219 % * The top of the brush usually is a little lower than the top of bulb.
221 % * The bulb can vary. Sometimes it is open (like in the clefs). Sometimes
222 % it is closed, or even a flare.
225 % from an email to Rune Zedeler:
228 % For example, the 8th rest was vaguely based on a book with trumpet
229 % studies by Duhem, and by Baerenreiters cello suites. I included my
230 % findings in a comment in the mf file. One of the things that I tried
231 % to do was make the rest a little lighter and narrower than the black
232 % note head. I think this looks better in polyphonic music, when the
233 % rest is below a head from a different voice.
236 save bulb_diam, thin, thick;
238 bulb_diam# := 0.64 staff_space#;
239 thin# := 1.4 linethickness# - 0.02 staff_space#;
240 thick# := 2.2 linethickness#;
242 crook_thin := 0.5 linethickness + 0.08 staff_space;
243 lower_brush := 1.5 linethickness;
245 define_pixels (bulb_diam);
246 define_whole_blacker_pixels (thin, thick);
250 % PAT is a compact way to pass the brush shape to the routine.
253 def draw_rest_bulb (expr ycenter, ycut, pat, stretch, show_labels) =
257 z1l = point 0 of pat;
258 z2l = point 1 of pat;
259 z2r = point 3 of pat;
260 z1r = point 4 of pat;
264 z10 = whatever [z2, z1] + left * bulb_diam * stretch;
266 % this enforces similar bulb shapes for lower resolutions
269 z3 = z10 + bulb_diam / 2.15 * dir (-72);
271 z5 = z10 + up * bulb_diam / 2 + right * linethickness / 3;
274 z7 = 0.5 [z4, z5] + crook_thin * (0.45, 0.4) / 1.3;
275 x8 = hround (x10 - 0.4 bulb_diam);
276 y8 = y10 + 0.25 linethickness;
278 z6 = whatever [z1l, z2l];
279 z6 = z3 + whatever * dir (12);
281 z4 = z3 + whatever * (z6 - z3)
282 + 1.1 crook_thin * (unitvector (z6 - z3) rotated 90);
283 x4 = x10 + bulb_diam * .62;
286 (pt, whatever) = pat intersectiontimes ((0, ycut) -- (w, ycut));
289 res = point pt of pat {-direction pt of pat}
290 ..tension 2.. z4{left}
298 labels (3, 4, 5, 6, 7, 8, 10);
306 def draw_eighth_rest (expr show_labels) =
311 set_char_box (0, 1.0 staff_space#,
312 1.0 staff_space# + 0.5 linethickness#,
313 0.5 staff_space# + bulb_diam# / 2);
318 y1 = -staff_space_rounded;
319 y2 = h - vround lower_brush;
321 z2 = z1 + whatever * dir (72);
322 z9 = z2 + 0.5 linethickness * dir (angle (z2 - z1) - 10);
340 bulb = draw_rest_bulb (0.5 staff_space, y2r, pat, 1.0, show_labels);
342 fill simple_serif (z1l, z1r, 40)
349 draw_staff (-2, 2, 0);
353 fet_beginchar ("Classical quarter rest", "2classical");
354 draw_eighth_rest (0);
355 currentpicture := currentpicture xscaled -1 shifted (w, 0);
359 fet_beginchar ("8th rest", "3");
360 draw_eighth_rest (1);
365 % TODO: the X dimensions of the rests are fucked up:
366 % they can collide with augmentation dots.
369 fet_beginchar ("16th rest", "4");
371 save pat, bulb_a, bulb_b;
372 path pat, bulb_a, bulb_b;
374 set_char_box (0, 1.2 staff_space#,
375 2.0 staff_space# + 0.5 linethickness#,
376 0.5 staff_space# + bulb_diam# / 2);
381 y1 = -2 staff_space_rounded;
382 y2 = h - vround lower_brush;
384 z2 = z1 + whatever * dir (74);
385 z9 = z2 + 0.5 linethickness * dir (angle (z2 - z1) - 10);
398 bulb_a = draw_rest_bulb (.5 staff_space,
400 bulb_b = draw_rest_bulb (.5 staff_space - staff_space_rounded,
401 hround ((-0.5 + 0.2) * staff_space),
404 fill simple_serif (z1l, z1r, 40)
415 draw_staff (-2, 2, 0);
419 fet_beginchar ("32th rest", "5");
421 save pat, bulb_a, bulb_b, bulb_c;
422 path pat, bulb_a, bulb_b, bulb_c;
424 set_char_box (0, 1.3 staff_space#,
425 2.0 staff_space# + 0.5 linethickness#,
426 1.5 staff_space# + bulb_diam# / 2);
431 y1 = -2 staff_space_rounded;
432 y2 = h - vround lower_brush;
434 z2 = z1 + whatever * dir (76);
435 z9 = z2 + 0.5 linethickness * dir (angle (z2 - z1) - 10);
448 bulb_a = draw_rest_bulb (.5 staff_space + staff_space_rounded,
450 bulb_b = draw_rest_bulb (.5 staff_space,
451 hround ((0.5 + 0.2) * staff_space),
453 bulb_c = draw_rest_bulb (.5 staff_space - staff_space_rounded,
454 hround ((-0.5 + 0.21) * staff_space),
457 fill simple_serif (z1l, z1r, 40)
469 draw_staff (-2, 2, 0);
473 fet_beginchar ("64th rest", "6");
475 save pat, bulb_a, bulb_b, bulb_c, bulb_d;
476 path pat, bulb_a, bulb_b, bulb_c, bulb_d;
478 set_char_box (0, 1.4 staff_space#,
479 3.0 staff_space# + 0.5 linethickness#,
480 1.5 staff_space# + bulb_diam# / 2);
485 y1 = -3 staff_space_rounded;
486 y2 = h - vround lower_brush;
488 z2 = z1 + whatever * dir (78);
489 z9 = z2 + 0.5 linethickness * dir (angle (z2 - z1) - 10);
502 bulb_a = draw_rest_bulb (.5 staff_space + staff_space_rounded,
504 bulb_b = draw_rest_bulb (.5 staff_space,
505 hround ((0.5 + 0.20) * staff_space),
507 bulb_c = draw_rest_bulb (.5 staff_space - staff_space_rounded,
508 hround ((-0.5 + 0.21) * staff_space),
510 bulb_d = draw_rest_bulb (.5 staff_space - 2 staff_space_rounded,
511 hround ((-1.5 + 0.22) * staff_space),
514 fill simple_serif (z1l, z1r, 40)
527 draw_staff (-2, 2, 0);
531 fet_beginchar ("128th rest", "7");
533 save pat, bulb_a, bulb_b, bulb_c, bulb_d, bulb_e;
534 path pat, bulb_a, bulb_b, bulb_c, bulb_d, bulb_e;
536 set_char_box (0, 1.5 staff_space#,
537 3.0 staff_space# + 0.5 linethickness#,
538 2.5 staff_space# + bulb_diam# / 2);
543 y1 = -3 staff_space_rounded;
544 y2 = h - vround lower_brush;
546 z2 = z1 + whatever * dir (80);
547 z9 = z2 + 0.5 linethickness * dir (angle (z2 - z1)- 10);
560 bulb_a = draw_rest_bulb (.5 staff_space + 2 staff_space_rounded,
562 bulb_b = draw_rest_bulb (.5 staff_space + staff_space_rounded,
563 hround ((1.5 + 0.20) * staff_space),
565 bulb_c = draw_rest_bulb (.5 staff_space,
566 hround ((0.5 + 0.21) * staff_space),
568 bulb_d = draw_rest_bulb (.5 staff_space - staff_space_rounded,
569 hround ((-0.5 + 0.22) * staff_space),
571 bulb_e = draw_rest_bulb (.5 staff_space - 2 staff_space_rounded,
572 hround ((-1.5 + 0.23) * staff_space),
575 fill simple_serif (z1l, z1r, 40)
589 draw_staff (-2, 2, 0);
593 fet_endgroup ("rests");