]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-rests.mf
feta accidentals: split into several files
[lilypond.git] / mf / feta-rests.mf
1 % Feta (not the Font-En-Tja) music font --  rest symbols -*-Fundamental-*-
2 % This file is part of LilyPond, the GNU music typesetter.
3 %
4 % Copyright (C) 1997--2012 Jan Nieuwenhuizen <janneke@gnu.org>
5 %
6 % The LilyPond font is free software: you can redistribute it and/or modify
7 % it under the terms of the GNU General Public License as published by
8 % the Free Software Foundation, either version 3 of the License, or
9 % (at your option) any later version, or under the SIL Open Font License.
10 %
11 % LilyPond is distributed in the hope that it will be useful,
12 % but WITHOUT ANY WARRANTY; without even the implied warranty of
13 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 % GNU General Public License for more details.
15 %
16 % You should have received a copy of the GNU General Public License
17 % along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18
19 fet_begingroup ("rests");
20
21 save block_rest_y, block_rest_x;
22 save breve_rest_y, breve_rest_x;
23
24 breve_rest_y# = staff_space#;
25 breve_rest_x# = 3/5 staff_space#;
26 block_rest_y# = 5/8 staff_space#;
27 block_rest_x# = 3/2 staff_space#;
28
29 define_whole_pixels (block_rest_y, block_rest_x);
30 define_whole_pixels (breve_rest_y, breve_rest_x);
31
32
33 def block_rest =
34         draw_block ((0, 0), (block_rest_x, block_rest_y));
35 enddef;
36
37
38 fet_beginchar ("whole rest", "0");
39         set_char_box (0, block_rest_x#,
40                       block_rest_y#, 0);
41
42         block_rest;
43         currentpicture := currentpicture
44                             shifted (0, -block_rest_y + feta_space_shift);
45
46         draw_staff (-2, 2, 0);
47 fet_endchar;
48
49
50 fet_beginchar ("half rest", "1");
51         set_char_box (0, block_rest_x#, 0, block_rest_y#);
52
53         block_rest;
54
55         draw_staff (-2, 2, 0);
56 fet_endchar;
57
58
59 %
60 % should use ledgerline thickness?
61 %
62 fet_beginchar ("whole rest (outside staff)", "0o");
63         set_char_box (0, block_rest_x#,
64                       block_rest_y#, ledgerlinethickness# / 2);
65
66         block_rest;
67         currentpicture := currentpicture shifted (0, -block_rest_y);
68
69         pickup pencircle scaled ledgerlinethickness;
70
71         y5 = y6 = 0;
72         lft x5 = -b - block_rest_y;
73         rt x6 = w + block_rest_y;
74         draw_gridline (z5, z6, ledgerlinethickness_rounded);
75
76         draw_staff (-2, 2, -3);
77 fet_endchar;
78
79
80 fet_beginchar ("half rest (outside staff)", "1o");
81         set_char_box (0, block_rest_x#,
82                       ledgerlinethickness# / 2, block_rest_y#);
83
84         block_rest;
85
86         pickup pencircle scaled ledgerlinethickness;
87
88         y5 = y6 = 0;
89         lft x5 = -b - block_rest_y;
90         rt x6 = w + block_rest_y;
91
92         draw_gridline (z5, z6, ledgerlinethickness_rounded);
93
94         draw_staff (-2, 2, 3);
95 fet_endchar;
96
97
98 fet_beginchar ("maxima rest", "M3");
99         set_char_box (0, 3 breve_rest_x#, breve_rest_y#, breve_rest_y#);
100
101         draw_block ((0, -breve_rest_y + feta_shift),
102                     (breve_rest_x, breve_rest_y));
103
104         addto currentpicture also currentpicture shifted (2 breve_rest_x, 0);
105
106         draw_staff (-2, 2, 0);
107 fet_endchar;
108
109
110 fet_beginchar ("longa rest", "M2");
111         set_char_box (0, breve_rest_x#, breve_rest_y#, breve_rest_y#);
112
113         draw_block ((0, -breve_rest_y + feta_shift),
114                     (breve_rest_x, breve_rest_y));
115
116         draw_staff (-2, 2, 0);
117 fet_endchar;
118
119
120 fet_beginchar ("breve rest", "M1");
121         set_char_box (0, breve_rest_x#, 0, breve_rest_y#);
122
123         draw_block ((0, 0), (breve_rest_x, breve_rest_y));
124
125         draw_staff (-2, 2, 0);
126 fet_endchar;
127
128 fet_beginchar ("breve rest (outside staff)", "M1o");
129         set_char_box (0, breve_rest_x#,
130                       ledgerlinethickness# / 2, breve_rest_y#);
131
132         draw_block ((0, 0), (breve_rest_x, breve_rest_y));
133
134         pickup pencircle scaled ledgerlinethickness;
135
136         y5 = y6 = breve_rest_y;
137         lft x5 = -b - breve_rest_y / 2;
138         rt x6 = w + breve_rest_y / 2;
139
140         draw_gridline (z5, z6, ledgerlinethickness_rounded);
141         draw_gridline ((x5, 0), (x6, 0), ledgerlinethickness_rounded);
142
143         draw_staff (-2, 2, 3);
144 fet_endchar;
145
146
147 fet_beginchar ("Quarter rest", "2");
148         save alpha, yshift, height;
149         save xcenter;
150
151         yshift# := -1.25 staff_space#;
152         height# := 2.8125 staff_space#;
153         define_pixels (yshift, height);
154
155         alpha := -50;
156         thick := 1/4 staff_space;
157         rthin := 1.25 linethickness;
158         xcenter := -0.1 staff_space;
159         rthick := 2 thick + rthin;
160
161         set_char_box (0, 0.95 staff_space#, -yshift#, yshift# + height#);
162
163         save ne, nw, se, sw;
164         pair ne, nw, se, sw;
165
166         se = dir alpha;
167         ne = dir (alpha + 90);
168         nw = dir (alpha + 180);
169         sw = dir (alpha + 270);
170
171         penpos1 (rthin, alpha + 90);
172         penpos2 (5/4 rthick, alpha);
173         penpos4 (5/4 rthick, alpha);
174         penpos5 (rthin, alpha + 90);
175         penpos3 (3/4 rthick, alpha);
176 %       penpos6 (5/8 rthick, alpha);
177         penpos6 (2/3 rthick, alpha);
178         penpos7 (1/2 rthin, alpha + 90);
179
180         z10 = z2l + 1/2 rthin * sw;
181 %       z11 = z4l + 1/2 rthin * sw;
182         z11 = z4l + 1/2 rthin * sw + 1/2 rthin * se;
183         z12 = z4r + 1/2 rthin * ne;
184 %       z13 = z2r + 1/2 rthin * ne;
185         z13 = z2r + 1/2 rthin * ne + 1/2 rthin * nw;
186
187         y1r = h;
188         x1l = xcenter + 1/3 staff_space;
189         z2r = z1 + staff_space * se;
190         z3 = 1/2 [z2, z4];
191         x4 = xcenter + 3/8 staff_space;
192         y4 = 0;
193         y4l := vround y4l;
194         z5 = round (z4l + 1.3 staff_space * se) + feta_offset;
195         x6l = x4l;
196         y6l = vround y4r;
197         x6r := hround x6r + xpart feta_offset;
198         y6r := vround y6r + ypart feta_offset;
199         x7 = hround (xcenter + 2/5 staff_space) + xpart feta_offset;
200         y7 = -d;
201
202         save before, after;
203         path before, after;
204         before = z11{se}
205                  .. {se}z5l;
206         after = z5r{nw}
207                 ..tension1.4.. z6l;
208         (u, v) = before intersectiontimes after;
209
210         fill z1l{se}
211              .. {se}z10
212              .. z3l
213              .. subpath (0, u) of before
214              .. subpath (v, infinity) of after
215              ..tension1.4.. {se}z7l
216              .. z7r{nw}
217              ..tension1.4.. z6r
218              ..tension1.4.. {se}z5l
219              .. z5r{nw}
220              .. {nw}z12
221              .. z3r
222              .. z13{nw}
223              .. {nw}z1r
224              .. cycle;
225
226         penlabels (1, 2, 3, 4, 5, 6, 7);
227         penlabels (10, 11, 12, 13);
228
229         draw_staff (-2, 2, 0);
230 fet_endchar;
231
232
233 %
234 % Notes about 8th rest:
235 %
236 % * 8th rest should be no wider than the black note head
237 %
238 % * The inside corner of the horizontal portion is usually a little blotted.
239 %
240 % * The top of the crook chops off the vertical brush
241 %
242 % * The crook widens a little
243 %
244 % * The bottom of the brush is slightly flat, as it has to align with
245 % stafflines if it is inside the staff.
246 %
247 % * The top of the brush usually is a little lower than the top of bulb.
248 %
249 % * The bulb can vary. Sometimes it is open (like in the clefs). Sometimes
250 % it is closed, or even a flare.
251 %
252
253 % from an email to Rune Zedeler:
254 %
255 %
256 % For example, the 8th rest was vaguely based on a book with trumpet
257 % studies by Duhem, and by Baerenreiters cello suites. I included my
258 % findings in a comment in the mf file.  One of the things that I tried
259 % to do was make the rest a little lighter and narrower than the black
260 % note head. I think this looks better in polyphonic music, when the
261 % rest is below a head from a different voice.
262 %
263
264 save bulb_diam, thin, thick;
265
266 bulb_diam# := 0.64 staff_space#;
267 thin# := 1.4 linethickness# - 0.02 staff_space#;
268 thick# := 2.2 linethickness#;
269
270 crook_thin := 0.5 linethickness + 0.08 staff_space;
271 lower_brush := 1.5 linethickness;
272
273 define_pixels (bulb_diam);
274 define_whole_blacker_pixels (thin, thick);
275
276
277 %
278 % PAT is a compact way to pass the brush shape to the routine.
279 %
280
281 def draw_rest_bulb (expr ycenter, ycut, pat, stretch, show_labels) =
282 begingroup;
283         save x, y, pt, res;
284
285         z1l = point 0 of pat;
286         z2l = point 1 of pat;
287         z2r = point 3 of pat;
288         z1r = point 4 of pat;
289         z1 = 0.5 [z1l, z1r];
290         z2 = 0.5 [z2l, z2r];
291         y10 = ycenter;
292         z10 = whatever [z2, z1] + left * bulb_diam * stretch;
293
294         % this enforces similar bulb shapes for lower resolutions
295         x10 := hround x10;
296
297         z3 = z10 + bulb_diam / 2.15 * dir (-72);
298         y3 := hround y3;
299         z5 = z10 + up * bulb_diam / 2 + right * linethickness / 3;
300         y5 := hround y5;
301
302         z7 = 0.5 [z4, z5] + crook_thin * (0.45, 0.4) / 1.3;
303         x8 = hround (x10 - 0.4 bulb_diam);
304         y8 = y10 + 0.25 linethickness;
305
306         z6 = whatever [z1l, z2l];
307         z6 = z3 + whatever * dir (12);
308
309         z4 = z3 + whatever * (z6 - z3)
310              + 1.1 crook_thin * (unitvector (z6 - z3) rotated 90);
311         x4 = x10 + bulb_diam * .62;
312         y4 := vround y4;
313
314         (pt, whatever) = pat intersectiontimes ((0, ycut) -- (w, ycut));
315
316         path res;
317         res = point pt of pat {-direction pt of pat}
318               ..tension 2.. z4{left}
319               ..tension 0.9.. z7
320               .. z5{left}
321               .. z8
322               .. z3{right}
323               .. {curl 0.2}z6;
324
325         if show_labels = 1:
326                 labels (3, 4, 5, 6, 7, 8, 10);
327         fi;
328
329 res
330 endgroup;
331 enddef;
332
333
334 def draw_eighth_rest (expr show_labels) =
335         save ycenter;
336         save pat, bulb;
337         path pat, bulb;
338
339         set_char_box (0, 1.0 staff_space#,
340                       1.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 = -staff_space_rounded;
347         y2 = h - vround lower_brush;
348         x2r = w;
349         z2 = z1 + whatever * dir (72);
350         z9 = z2 + 0.5 linethickness * dir (angle (z2 - z1) - 10);
351         y9 := vround y9;
352
353         x1l := hround x1l;
354         x1r := hround x1r;
355         x1 := .5 [x1l, x1r];
356
357         if show_labels = 1:
358                 penlabels (1, 2);
359                 labels (9);
360         fi;
361
362         pat = z1l
363               -- z2l
364               .. z9
365               .. z2r
366               -- z1r
367               .. cycle;
368         bulb = draw_rest_bulb (0.5 staff_space, y2r, pat, 1.0, show_labels);
369
370         fill simple_serif (z1l, z1r, 40)
371              -- z2r
372              .. z9
373              .. bulb
374              -- z1l
375              .. cycle;
376
377         draw_staff (-2, 2, 0);
378 enddef;
379
380
381 fet_beginchar ("Classical quarter rest", "2classical");
382         draw_eighth_rest (0);
383         currentpicture := currentpicture xscaled -1 shifted (w, 0);
384 fet_endchar;
385
386
387 fet_beginchar ("8th rest", "3");
388         draw_eighth_rest (1);
389 fet_endchar;
390
391
392 %
393 % TODO: the X dimensions of the rests are fucked up:
394 % they can collide with augmentation dots.
395 %
396
397 fet_beginchar ("16th rest", "4");
398         save ycenter;
399         save pat, bulb_a, bulb_b;
400         path pat, bulb_a, bulb_b;
401
402         set_char_box (0, 1.2 staff_space#,
403                       2.0 staff_space# + 0.5 linethickness#,
404                       0.5 staff_space# + bulb_diam# / 2);
405
406         penpos1 (thick, 0);
407         penpos2 (thin, 10);
408
409         y1 = -2 staff_space_rounded;
410         y2 = h - vround lower_brush;
411         x2r = w;
412         z2 = z1 + whatever * dir (74);
413         z9 = z2 + 0.5 linethickness * dir (angle (z2 - z1) - 10);
414         y9 := vround y9;
415
416         x1l := hround x1l;
417         x1r := hround x1r;
418         x1 := .5 [x1l, x1r];
419
420         pat = z1l
421               -- z2l
422               .. z9
423               .. z2r
424               -- z1r
425               .. cycle;
426         bulb_a = draw_rest_bulb (.5 staff_space,
427                                  y2r, pat, 0.98, 1);
428         bulb_b = draw_rest_bulb (.5 staff_space - staff_space_rounded,
429                                  hround ((-0.5 + 0.2) * staff_space),
430                                  pat, 1.02, 1);
431
432         fill simple_serif (z1l, z1r, 40)
433              -- z2r
434              .. z9
435              .. bulb_a
436              -- bulb_b
437              -- z1l
438              .. cycle;
439
440         penlabels (1, 2);
441         labels (9);
442
443         draw_staff (-2, 2, 0);
444 fet_endchar;
445
446
447 fet_beginchar ("32th rest", "5");
448         save ycenter;
449         save pat, bulb_a, bulb_b, bulb_c;
450         path pat, bulb_a, bulb_b, bulb_c;
451
452         set_char_box (0, 1.3 staff_space#,
453                       2.0 staff_space# + 0.5 linethickness#,
454                       1.5 staff_space# + bulb_diam# / 2);
455
456         penpos1 (thick, 0);
457         penpos2 (thin, 10);
458
459         y1 = -2 staff_space_rounded;
460         y2 = h - vround lower_brush;
461         x2r = w;
462         z2 = z1 + whatever * dir (76);
463         z9 = z2 + 0.5 linethickness * dir (angle (z2 - z1) - 10);
464         y9 := vround y9;
465
466         x1l := hround x1l;
467         x1r := hround x1r;
468         x1 := .5 [x1l, x1r];
469
470         pat = z1l
471               -- z2l
472               .. z9
473               .. z2r
474               -- z1r
475               .. cycle;
476         bulb_a = draw_rest_bulb (.5 staff_space + staff_space_rounded,
477                                  y2r, pat, 0.96, 1);
478         bulb_b = draw_rest_bulb (.5 staff_space,
479                                  hround ((0.5 + 0.2) * staff_space),
480                                  pat, 1.00, 1);
481         bulb_c = draw_rest_bulb (.5 staff_space - staff_space_rounded,
482                                  hround ((-0.5 + 0.21) * staff_space),
483                                  pat, 1.04, 1);
484
485         fill simple_serif (z1l, z1r, 40)
486              -- z2r
487              .. z9
488              .. bulb_a
489              -- bulb_b
490              -- bulb_c
491              -- z1l
492              .. cycle;
493
494         penlabels (1, 2);
495         labels (9);
496
497         draw_staff (-2, 2, 0);
498 fet_endchar;
499
500
501 fet_beginchar ("64th rest", "6");
502         save ycenter;
503         save pat, bulb_a, bulb_b, bulb_c, bulb_d;
504         path pat, bulb_a, bulb_b, bulb_c, bulb_d;
505
506         set_char_box (0, 1.4 staff_space#,
507                       3.0 staff_space# + 0.5 linethickness#,
508                       1.5 staff_space# + bulb_diam# / 2);
509
510         penpos1 (thick, 0);
511         penpos2 (thin, 10);
512
513         y1 = -3 staff_space_rounded;
514         y2 = h - vround lower_brush;
515         x2r = w;
516         z2 = z1 + whatever * dir (78);
517         z9 = z2 + 0.5 linethickness * dir (angle (z2 - z1) - 10);
518         y9 := vround y9;
519
520         x1l := hround x1l;
521         x1r := hround x1r;
522         x1 := .5 [x1l, x1r];
523
524         pat = z1l
525               -- z2l
526               .. z9
527               .. z2r
528               -- z1r
529               .. cycle;
530         bulb_a = draw_rest_bulb (.5 staff_space + staff_space_rounded,
531                                  y2r, pat, 0.94, 1);
532         bulb_b = draw_rest_bulb (.5 staff_space,
533                                  hround ((0.5 + 0.20) * staff_space),
534                                  pat, 0.98, 1);
535         bulb_c = draw_rest_bulb (.5 staff_space - staff_space_rounded,
536                                  hround ((-0.5 + 0.21) * staff_space),
537                                  pat, 1.02, 1);
538         bulb_d = draw_rest_bulb (.5 staff_space - 2 staff_space_rounded,
539                                  hround ((-1.5 + 0.22) * staff_space),
540                                  pat, 1.06, 1);
541
542         fill simple_serif (z1l, z1r, 40)
543              -- z2r
544              .. z9
545              .. bulb_a
546              -- bulb_b
547              -- bulb_c
548              -- bulb_d
549              -- z1l
550              .. cycle;
551
552         penlabels (1, 2);
553         labels (9);
554
555         draw_staff (-2, 2, 0);
556 fet_endchar;
557
558
559 fet_beginchar ("128th rest", "7");
560         save ycenter;
561         save pat, bulb_a, bulb_b, bulb_c, bulb_d, bulb_e;
562         path pat, bulb_a, bulb_b, bulb_c, bulb_d, bulb_e;
563
564         set_char_box (0, 1.5 staff_space#,
565                       3.0 staff_space# + 0.5 linethickness#,
566                       2.5 staff_space# + bulb_diam# / 2);
567
568         penpos1 (thick, 0);
569         penpos2 (thin, 10);
570
571         y1 = -3 staff_space_rounded;
572         y2 = h - vround lower_brush;
573         x2r = w;
574         z2 = z1 + whatever * dir (80);
575         z9 = z2 + 0.5 linethickness * dir (angle (z2 - z1)- 10);
576         y9 := vround y9;
577
578         x1l := hround x1l;
579         x1r := hround x1r;
580         x1 := .5 [x1l, x1r];
581
582         pat = z1l
583               -- z2l
584               .. z9
585               .. z2r
586               -- z1r
587               .. cycle;
588         bulb_a = draw_rest_bulb (.5 staff_space + 2 staff_space_rounded,
589                                  y2r, pat, 0.92, 1);
590         bulb_b = draw_rest_bulb (.5 staff_space + staff_space_rounded,
591                                  hround ((1.5 + 0.20) * staff_space),
592                                  pat, 0.96, 1);
593         bulb_c = draw_rest_bulb (.5 staff_space,
594                                  hround ((0.5 + 0.21) * staff_space),
595                                  pat, 1.0, 1);
596         bulb_d = draw_rest_bulb (.5 staff_space - staff_space_rounded,
597                                  hround ((-0.5 + 0.22) * staff_space),
598                                  pat, 1.04, 1);
599         bulb_e = draw_rest_bulb (.5 staff_space - 2 staff_space_rounded,
600                                  hround ((-1.5 + 0.23) * staff_space),
601                                  pat, 1.08, 1);
602
603         fill simple_serif (z1l, z1r, 40)
604              -- z2r
605              .. z9
606              .. bulb_a
607              -- bulb_b
608              -- bulb_c
609              -- bulb_d
610              -- bulb_e
611              -- z1l
612              .. cycle;
613
614         penlabels (1, 2);
615         labels (9);
616
617         draw_staff (-2, 2, 0);
618 fet_endchar;
619
620
621 fet_endgroup ("rests");