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