]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-eindelijk.mf
Run `make grand-replace'.
[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--2008 Jan Nieuwenhuizen <janneke@gnu.org>
8
9 fet_begingroup ("rests");
10
11 save block_rest_y, block_rest_x;
12 save breve_rest_y, breve_rest_x;
13
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#;
18
19 define_whole_pixels (block_rest_y, block_rest_x);
20 define_whole_pixels (breve_rest_y, breve_rest_x);
21
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
32         block_rest;
33         currentpicture := currentpicture
34                             shifted (0, -block_rest_y + feta_space_shift);
35
36         draw_staff (-2, 2, 0);
37 fet_endchar;
38
39
40 fet_beginchar ("half rest", "1");
41         set_char_box (0, block_rest_x#, 0, block_rest_y#);
42
43         block_rest;
44
45         draw_staff (-2, 2, 0);
46 fet_endchar;
47
48
49 %
50 % should use ledgerline thickness?
51 %
52 fet_beginchar ("whole rest (outside staff)", "0o");
53         set_char_box (0, block_rest_x#,
54                       block_rest_y#, ledgerlinethickness# / 2);
55
56         block_rest;
57         currentpicture := currentpicture shifted (0, -block_rest_y);
58
59         pickup pencircle scaled ledgerlinethickness;
60
61         y5 = y6 = 0;
62         lft x5 = -b - block_rest_y;
63         rt x6 = w + block_rest_y;
64         draw_gridline (z5, z6, ledgerlinethickness_rounded);
65
66         draw_staff (-2, 2, -3);
67 fet_endchar;
68
69
70 fet_beginchar ("half rest (outside staff)", "1o");
71         set_char_box (0, block_rest_x#,
72                       ledgerlinethickness# / 2, block_rest_y#);
73
74         block_rest;
75
76         pickup pencircle scaled ledgerlinethickness;
77
78         y5 = y6 = 0;
79         lft x5 = -b - block_rest_y;
80         rt x6 = w + block_rest_y;
81
82         draw_gridline (z5, z6, ledgerlinethickness_rounded);
83
84         draw_staff (-2, 2, 3);
85 fet_endchar;
86
87
88 fet_beginchar ("maxima rest", "M3");
89         set_char_box (0, 3 breve_rest_x#, breve_rest_y#, breve_rest_y#);
90
91         draw_block ((0, -breve_rest_y + feta_shift),
92                     (breve_rest_x, breve_rest_y));
93
94         addto currentpicture also currentpicture shifted (2 breve_rest_x, 0);
95
96         draw_staff (-2, 2, 0);
97 fet_endchar;
98
99
100 fet_beginchar ("longa rest", "M2");
101         set_char_box (0, breve_rest_x#, breve_rest_y#, breve_rest_y#);
102
103         draw_block ((0, -breve_rest_y + feta_shift),
104                     (breve_rest_x, breve_rest_y));
105
106         draw_staff (-2, 2, 0);
107 fet_endchar;
108
109
110 fet_beginchar ("breve rest", "M1");
111         set_char_box (0, breve_rest_x#, 0, breve_rest_y#);
112
113         draw_block ((0, 0), (breve_rest_x, breve_rest_y));
114
115         draw_staff (-2, 2, 0);
116 fet_endchar;
117
118
119 fet_beginchar ("Quarter rest", "2");
120         save alpha, yshift, height;
121         save xcenter;
122
123         yshift# := -1.25 staff_space#;
124         height# := 2.8125 staff_space#;
125         define_pixels (yshift, height);
126
127         alpha := -50;
128         thick := 1/4 staff_space;
129         rthin := 1.25 linethickness;
130         xcenter := -0.1 staff_space;
131         rthick := 2 thick + rthin;
132
133         set_char_box (0, 0.95 staff_space#, -yshift#, yshift# + height#);
134
135         save ne, nw, se, sw;
136         pair ne, nw, se, sw;
137
138         se = dir alpha;
139         ne = dir (alpha + 90);
140         nw = dir (alpha + 180);
141         sw = dir (alpha + 270);
142
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);
151
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;
158
159         y1r = h;
160         x1l = xcenter + 1/3 staff_space;
161         z2r = z1 + staff_space * se;
162         z3 = 1/2 [z2, z4];
163         x4 = xcenter + 3/8 staff_space;
164         y4 = 0;
165         y4l := vround y4l;
166         z5 = round (z4l + 1.3 staff_space * se) + feta_offset;
167         x6l = x4l;
168         y6l = vround y4r;
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;
172         y7 = -d;
173
174         save before, after;
175         path before, after;
176         before = z11{se}
177                  .. {se}z5l;
178         after = z5r{nw}
179                 ..tension1.4.. z6l;
180         (u, v) = before intersectiontimes after;
181
182         fill z1l{se}
183              .. {se}z10
184              .. z3l
185              .. subpath (0, u) of before
186              .. subpath (v, infinity) of after
187              ..tension1.4.. {se}z7l
188              .. z7r{nw}
189              ..tension1.4.. z6r
190              ..tension1.4.. {se}z5l
191              .. z5r{nw}
192              .. {nw}z12
193              .. z3r
194              .. z13{nw}
195              .. {nw}z1r
196              .. cycle;
197
198         penlabels (1, 2, 3, 4, 5, 6, 7);
199         penlabels (10, 11, 12, 13);
200
201         draw_staff (-2, 2, 0);
202 fet_endchar;
203
204
205 %
206 % Notes about 8th rest:
207 %
208 % * 8th rest should be no wider than the black note head
209 %
210 % * The inside corner of the horizontal portion is usually a little blotted.
211 %
212 % * The top of the crook chops off the vertical brush
213 %
214 % * The crook widens a little
215 %
216 % * The bottom of the brush is slightly flat, as it has to align with
217 % stafflines if it is inside the staff.
218 %
219 % * The top of the brush usually is a little lower than the top of bulb.
220 %
221 % * The bulb can vary. Sometimes it is open (like in the clefs). Sometimes
222 % it is closed, or even a flare.
223 %
224
225 % from an email to Rune Zedeler:
226 %
227 %
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.
234 %
235
236 save bulb_diam, thin, thick;
237
238 bulb_diam# := 0.64 staff_space#;
239 thin# := 1.4 linethickness# - 0.02 staff_space#;
240 thick# := 2.2 linethickness#;
241
242 crook_thin := 0.5 linethickness + 0.08 staff_space;
243 lower_brush := 1.5 linethickness;
244
245 define_pixels (bulb_diam);
246 define_whole_blacker_pixels (thin, thick);
247
248
249 %
250 % PAT is a compact way to pass the brush shape to the routine.
251 %
252
253 def draw_rest_bulb (expr ycenter, ycut, pat, stretch, show_labels) =
254 begingroup;
255         save x, y, pt, res;
256
257         z1l = point 0 of pat;
258         z2l = point 1 of pat;
259         z2r = point 3 of pat;
260         z1r = point 4 of pat;
261         z1 = 0.5 [z1l, z1r];
262         z2 = 0.5 [z2l, z2r];
263         y10 = ycenter;
264         z10 = whatever [z2, z1] + left * bulb_diam * stretch;
265
266         % this enforces similar bulb shapes for lower resolutions
267         x10 := hround x10;
268
269         z3 = z10 + bulb_diam / 2.15 * dir (-72);
270         y3 := hround y3;
271         z5 = z10 + up * bulb_diam / 2 + right * linethickness / 3;
272         y5 := hround y5;
273
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;
277
278         z6 = whatever [z1l, z2l];
279         z6 = z3 + whatever * dir (12);
280
281         z4 = z3 + whatever * (z6 - z3)
282              + 1.1 crook_thin * (unitvector (z6 - z3) rotated 90);
283         x4 = x10 + bulb_diam * .62;
284         y4 := vround y4;
285
286         (pt, whatever) = pat intersectiontimes ((0, ycut) -- (w, ycut));
287
288         path res;
289         res = point pt of pat {-direction pt of pat}
290               ..tension 2.. z4{left}
291               ..tension 0.9.. z7
292               .. z5{left}
293               .. z8
294               .. z3{right}
295               .. {curl 0.2}z6;
296
297         if show_labels = 1:
298                 labels (3, 4, 5, 6, 7, 8, 10);
299         fi;
300
301 res
302 endgroup;
303 enddef;
304
305
306 def draw_eighth_rest (expr show_labels) =
307         save ycenter;
308         save pat, bulb;
309         path pat, bulb;
310
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);
314
315         penpos1 (thick, 0);
316         penpos2 (thin, 10);
317
318         y1 = -staff_space_rounded;
319         y2 = h - vround lower_brush;
320         x2r = w;
321         z2 = z1 + whatever * dir (72);
322         z9 = z2 + 0.5 linethickness * dir (angle (z2 - z1) - 10);
323         y9 := vround y9;
324
325         x1l := hround x1l;
326         x1r := hround x1r;
327         x1 := .5 [x1l, x1r];
328
329         if show_labels = 1:
330                 penlabels (1, 2);
331                 labels (9);
332         fi;
333
334         pat = z1l
335               -- z2l
336               .. z9
337               .. z2r
338               -- z1r
339               .. cycle;
340         bulb = draw_rest_bulb (0.5 staff_space, y2r, pat, 1.0, show_labels);
341
342         fill simple_serif (z1l, z1r, 40)
343              -- z2r
344              .. z9
345              .. bulb
346              -- z1l
347              .. cycle;
348
349         draw_staff (-2, 2, 0);
350 enddef;
351
352
353 fet_beginchar ("Classical quarter rest", "2classical");
354         draw_eighth_rest (0);
355         currentpicture := currentpicture xscaled -1 shifted (w, 0);
356 fet_endchar;
357
358
359 fet_beginchar ("8th rest", "3");
360         draw_eighth_rest (1);
361 fet_endchar;
362
363
364 %
365 % TODO: the X dimensions of the rests are fucked up:
366 % they can collide with augmentation dots.
367 %
368
369 fet_beginchar ("16th rest", "4");
370         save ycenter;
371         save pat, bulb_a, bulb_b;
372         path pat, bulb_a, bulb_b;
373
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);
377
378         penpos1 (thick, 0);
379         penpos2 (thin, 10);
380
381         y1 = -2 staff_space_rounded;
382         y2 = h - vround lower_brush;
383         x2r = w;
384         z2 = z1 + whatever * dir (74);
385         z9 = z2 + 0.5 linethickness * dir (angle (z2 - z1) - 10);
386         y9 := vround y9;
387
388         x1l := hround x1l;
389         x1r := hround x1r;
390         x1 := .5 [x1l, x1r];
391
392         pat = z1l
393               -- z2l
394               .. z9
395               .. z2r
396               -- z1r
397               .. cycle;
398         bulb_a = draw_rest_bulb (.5 staff_space,
399                                  y2r, pat, 0.98, 1);
400         bulb_b = draw_rest_bulb (.5 staff_space - staff_space_rounded,
401                                  hround ((-0.5 + 0.2) * staff_space),
402                                  pat, 1.02, 1);
403
404         fill simple_serif (z1l, z1r, 40)
405              -- z2r
406              .. z9
407              .. bulb_a
408              -- bulb_b
409              -- z1l
410              .. cycle;
411
412         penlabels (1, 2);
413         labels (9);
414
415         draw_staff (-2, 2, 0);
416 fet_endchar;
417
418
419 fet_beginchar ("32th rest", "5");
420         save ycenter;
421         save pat, bulb_a, bulb_b, bulb_c;
422         path pat, bulb_a, bulb_b, bulb_c;
423
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);
427
428         penpos1 (thick, 0);
429         penpos2 (thin, 10);
430
431         y1 = -2 staff_space_rounded;
432         y2 = h - vround lower_brush;
433         x2r = w;
434         z2 = z1 + whatever * dir (76);
435         z9 = z2 + 0.5 linethickness * dir (angle (z2 - z1) - 10);
436         y9 := vround y9;
437
438         x1l := hround x1l;
439         x1r := hround x1r;
440         x1 := .5 [x1l, x1r];
441
442         pat = z1l
443               -- z2l
444               .. z9
445               .. z2r
446               -- z1r
447               .. cycle;
448         bulb_a = draw_rest_bulb (.5 staff_space + staff_space_rounded,
449                                  y2r, pat, 0.96, 1);
450         bulb_b = draw_rest_bulb (.5 staff_space,
451                                  hround ((0.5 + 0.2) * staff_space),
452                                  pat, 1.00, 1);
453         bulb_c = draw_rest_bulb (.5 staff_space - staff_space_rounded,
454                                  hround ((-0.5 + 0.21) * staff_space),
455                                  pat, 1.04, 1);
456
457         fill simple_serif (z1l, z1r, 40)
458              -- z2r
459              .. z9
460              .. bulb_a
461              -- bulb_b
462              -- bulb_c
463              -- z1l
464              .. cycle;
465
466         penlabels (1, 2);
467         labels (9);
468
469         draw_staff (-2, 2, 0);
470 fet_endchar;
471
472
473 fet_beginchar ("64th rest", "6");
474         save ycenter;
475         save pat, bulb_a, bulb_b, bulb_c, bulb_d;
476         path pat, bulb_a, bulb_b, bulb_c, bulb_d;
477
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);
481
482         penpos1 (thick, 0);
483         penpos2 (thin, 10);
484
485         y1 = -3 staff_space_rounded;
486         y2 = h - vround lower_brush;
487         x2r = w;
488         z2 = z1 + whatever * dir (78);
489         z9 = z2 + 0.5 linethickness * dir (angle (z2 - z1) - 10);
490         y9 := vround y9;
491
492         x1l := hround x1l;
493         x1r := hround x1r;
494         x1 := .5 [x1l, x1r];
495
496         pat = z1l
497               -- z2l
498               .. z9
499               .. z2r
500               -- z1r
501               .. cycle;
502         bulb_a = draw_rest_bulb (.5 staff_space + staff_space_rounded,
503                                  y2r, pat, 0.94, 1);
504         bulb_b = draw_rest_bulb (.5 staff_space,
505                                  hround ((0.5 + 0.20) * staff_space),
506                                  pat, 0.98, 1);
507         bulb_c = draw_rest_bulb (.5 staff_space - staff_space_rounded,
508                                  hround ((-0.5 + 0.21) * staff_space),
509                                  pat, 1.02, 1);
510         bulb_d = draw_rest_bulb (.5 staff_space - 2 staff_space_rounded,
511                                  hround ((-1.5 + 0.22) * staff_space),
512                                  pat, 1.06, 1);
513
514         fill simple_serif (z1l, z1r, 40)
515              -- z2r
516              .. z9
517              .. bulb_a
518              -- bulb_b
519              -- bulb_c
520              -- bulb_d
521              -- z1l
522              .. cycle;
523
524         penlabels (1, 2);
525         labels (9);
526
527         draw_staff (-2, 2, 0);
528 fet_endchar;
529
530
531 fet_beginchar ("128th rest", "7");
532         save ycenter;
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;
535
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);
539
540         penpos1 (thick, 0);
541         penpos2 (thin, 10);
542
543         y1 = -3 staff_space_rounded;
544         y2 = h - vround lower_brush;
545         x2r = w;
546         z2 = z1 + whatever * dir (80);
547         z9 = z2 + 0.5 linethickness * dir (angle (z2 - z1)- 10);
548         y9 := vround y9;
549
550         x1l := hround x1l;
551         x1r := hround x1r;
552         x1 := .5 [x1l, x1r];
553
554         pat = z1l
555               -- z2l
556               .. z9
557               .. z2r
558               -- z1r
559               .. cycle;
560         bulb_a = draw_rest_bulb (.5 staff_space + 2 staff_space_rounded,
561                                  y2r, pat, 0.92, 1);
562         bulb_b = draw_rest_bulb (.5 staff_space + staff_space_rounded,
563                                  hround ((1.5 + 0.20) * staff_space),
564                                  pat, 0.96, 1);
565         bulb_c = draw_rest_bulb (.5 staff_space,
566                                  hround ((0.5 + 0.21) * staff_space),
567                                  pat, 1.0, 1);
568         bulb_d = draw_rest_bulb (.5 staff_space - staff_space_rounded,
569                                  hround ((-0.5 + 0.22) * staff_space),
570                                  pat, 1.04, 1);
571         bulb_e = draw_rest_bulb (.5 staff_space - 2 staff_space_rounded,
572                                  hround ((-1.5 + 0.23) * staff_space),
573                                  pat, 1.08, 1);
574
575         fill simple_serif (z1l, z1r, 40)
576              -- z2r
577              .. z9
578              .. bulb_a
579              -- bulb_b
580              -- bulb_c
581              -- bulb_d
582              -- bulb_e
583              -- z1l
584              .. cycle;
585
586         penlabels (1, 2);
587         labels (9);
588
589         draw_staff (-2, 2, 0);
590 fet_endchar;
591
592
593 fet_endgroup ("rests");