]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-rests.mf
Add '-dcrop' option to ps and svg backends
[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--2015 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 ("Z-shaped quarter rest", "2z");
382         save ycenter;
383         save pat, bulb, rest;
384         path pat, bulb, rest;
385         show_labels := 0;
386
387         set_char_box (0, 1.125 staff_space#,
388                       0.5 staff_space# + bulb_diam# / 2,
389                       0.5 staff_space# + bulb_diam# / 2);
390
391         % The brushes on other rests taper from thin to thick,
392         % but because this rest has a bulb on both ends, use
393         % a constant thickness somewhere in between.
394         slash_thickness := (7 thin + 3 thick) / 10;
395
396         x1 = 0 + hround 0.5 slash_thickness;
397         y1 = -(d - vround 0.5 slash_thickness);
398         x2 = w - hround 0.5 slash_thickness;
399         y2 = h - vround 0.5 slash_thickness;
400
401         penpos1 (slash_thickness, angle(z2 - z1) - 90);
402         penpos2 (slash_thickness, angle(z2 - z1) - 90);
403
404         z9 = z2 + 0.5 slash_thickness * dir (angle (z2 - z1));
405         z12 = z1 + 0.5 slash_thickness * dir (angle (z1 - z2));
406         y9 := vround y9;
407
408         x1l := hround x1l;
409         x1r := hround x1r;
410         x1 := .5 [x1l, x1r];
411
412         x2l := hround x2l;
413         x2r := hround x2r;
414         x2 := .5 [x2l, x2r];
415
416         if show_labels = 1:
417                 penlabels (1, 2);
418                 labels (9, 12);
419         fi;
420
421         pat = z1l
422               -- z2l
423               .. z9
424               .. z2r
425               -- z1r
426               .. cycle;
427         bulb = draw_rest_bulb (0.5 staff_space, y2r, pat, 1.0, show_labels);
428
429         rest = z12
430                .. bulb rotatedaround ((0.5 w, 0), 180)
431                -- z2r
432                .. z9
433                .. bulb
434                -- z1l
435                .. cycle;
436
437         if show_labels = 0:
438                 rest := rest xscaled -1 shifted (w, 0);
439         fi;
440
441         fill rest;
442
443         draw_staff_if_debugging (-2, 2);
444 fet_endchar;
445
446
447 fet_beginchar ("8th rest", "3");
448         draw_eighth_rest (1);
449 fet_endchar;
450
451
452 %
453 % TODO: the X dimensions of the rests are fucked up:
454 % they can collide with augmentation dots.
455 %
456
457 fet_beginchar ("16th rest", "4");
458         save ycenter;
459         save pat, bulb_a, bulb_b;
460         path pat, bulb_a, bulb_b;
461
462         set_char_box (0, 1.2 staff_space#,
463                       2.0 staff_space# + 0.5 linethickness#,
464                       0.5 staff_space# + bulb_diam# / 2);
465
466         penpos1 (thick, 0);
467         penpos2 (thin, 10);
468
469         y1 = -2 staff_space_rounded;
470         y2 = h - vround lower_brush;
471         x2r = w;
472         z2 = z1 + whatever * dir (74);
473         z9 = z2 + 0.5 linethickness * dir (angle (z2 - z1) - 10);
474         y9 := vround y9;
475
476         x1l := hround x1l;
477         x1r := hround x1r;
478         x1 := .5 [x1l, x1r];
479
480         pat = z1l
481               -- z2l
482               .. z9
483               .. z2r
484               -- z1r
485               .. cycle;
486         bulb_a = draw_rest_bulb (.5 staff_space,
487                                  y2r, pat, 0.98, 1);
488         bulb_b = draw_rest_bulb (.5 staff_space - staff_space_rounded,
489                                  hround ((-0.5 + 0.2) * staff_space),
490                                  pat, 1.02, 1);
491
492         fill simple_serif (z1l, z1r, 40)
493              -- z2r
494              .. z9
495              .. bulb_a
496              -- bulb_b
497              -- z1l
498              .. cycle;
499
500         penlabels (1, 2);
501         labels (9);
502
503         draw_staff_if_debugging (-2, 2);
504 fet_endchar;
505
506
507 fet_beginchar ("32th rest", "5");
508         save ycenter;
509         save pat, bulb_a, bulb_b, bulb_c;
510         path pat, bulb_a, bulb_b, bulb_c;
511
512         set_char_box (0, 1.3 staff_space#,
513                       2.0 staff_space# + 0.5 linethickness#,
514                       1.5 staff_space# + bulb_diam# / 2);
515
516         penpos1 (thick, 0);
517         penpos2 (thin, 10);
518
519         y1 = -2 staff_space_rounded;
520         y2 = h - vround lower_brush;
521         x2r = w;
522         z2 = z1 + whatever * dir (76);
523         z9 = z2 + 0.5 linethickness * dir (angle (z2 - z1) - 10);
524         y9 := vround y9;
525
526         x1l := hround x1l;
527         x1r := hround x1r;
528         x1 := .5 [x1l, x1r];
529
530         pat = z1l
531               -- z2l
532               .. z9
533               .. z2r
534               -- z1r
535               .. cycle;
536         bulb_a = draw_rest_bulb (.5 staff_space + staff_space_rounded,
537                                  y2r, pat, 0.96, 1);
538         bulb_b = draw_rest_bulb (.5 staff_space,
539                                  hround ((0.5 + 0.2) * staff_space),
540                                  pat, 1.00, 1);
541         bulb_c = draw_rest_bulb (.5 staff_space - staff_space_rounded,
542                                  hround ((-0.5 + 0.21) * staff_space),
543                                  pat, 1.04, 1);
544
545         fill simple_serif (z1l, z1r, 40)
546              -- z2r
547              .. z9
548              .. bulb_a
549              -- bulb_b
550              -- bulb_c
551              -- z1l
552              .. cycle;
553
554         penlabels (1, 2);
555         labels (9);
556
557         draw_staff_if_debugging (-2, 2);
558 fet_endchar;
559
560
561 fet_beginchar ("64th rest", "6");
562         save ycenter;
563         save pat, bulb_a, bulb_b, bulb_c, bulb_d;
564         path pat, bulb_a, bulb_b, bulb_c, bulb_d;
565
566         set_char_box (0, 1.4 staff_space#,
567                       3.0 staff_space# + 0.5 linethickness#,
568                       1.5 staff_space# + bulb_diam# / 2);
569
570         penpos1 (thick, 0);
571         penpos2 (thin, 10);
572
573         y1 = -3 staff_space_rounded;
574         y2 = h - vround lower_brush;
575         x2r = w;
576         z2 = z1 + whatever * dir (78);
577         z9 = z2 + 0.5 linethickness * dir (angle (z2 - z1) - 10);
578         y9 := vround y9;
579
580         x1l := hround x1l;
581         x1r := hround x1r;
582         x1 := .5 [x1l, x1r];
583
584         pat = z1l
585               -- z2l
586               .. z9
587               .. z2r
588               -- z1r
589               .. cycle;
590         bulb_a = draw_rest_bulb (.5 staff_space + staff_space_rounded,
591                                  y2r, pat, 0.94, 1);
592         bulb_b = draw_rest_bulb (.5 staff_space,
593                                  hround ((0.5 + 0.20) * staff_space),
594                                  pat, 0.98, 1);
595         bulb_c = draw_rest_bulb (.5 staff_space - staff_space_rounded,
596                                  hround ((-0.5 + 0.21) * staff_space),
597                                  pat, 1.02, 1);
598         bulb_d = draw_rest_bulb (.5 staff_space - 2 staff_space_rounded,
599                                  hround ((-1.5 + 0.22) * staff_space),
600                                  pat, 1.06, 1);
601
602         fill simple_serif (z1l, z1r, 40)
603              -- z2r
604              .. z9
605              .. bulb_a
606              -- bulb_b
607              -- bulb_c
608              -- bulb_d
609              -- z1l
610              .. cycle;
611
612         penlabels (1, 2);
613         labels (9);
614
615         draw_staff_if_debugging (-2, 2);
616 fet_endchar;
617
618
619 fet_beginchar ("128th rest", "7");
620         save ycenter;
621         save pat, bulb_a, bulb_b, bulb_c, bulb_d, bulb_e;
622         path pat, bulb_a, bulb_b, bulb_c, bulb_d, bulb_e;
623
624         set_char_box (0, 1.5 staff_space#,
625                       3.0 staff_space# + 0.5 linethickness#,
626                       2.5 staff_space# + bulb_diam# / 2);
627
628         penpos1 (thick, 0);
629         penpos2 (thin, 10);
630
631         y1 = -3 staff_space_rounded;
632         y2 = h - vround lower_brush;
633         x2r = w;
634         z2 = z1 + whatever * dir (80);
635         z9 = z2 + 0.5 linethickness * dir (angle (z2 - z1)- 10);
636         y9 := vround y9;
637
638         x1l := hround x1l;
639         x1r := hround x1r;
640         x1 := .5 [x1l, x1r];
641
642         pat = z1l
643               -- z2l
644               .. z9
645               .. z2r
646               -- z1r
647               .. cycle;
648         bulb_a = draw_rest_bulb (.5 staff_space + 2 staff_space_rounded,
649                                  y2r, pat, 0.92, 1);
650         bulb_b = draw_rest_bulb (.5 staff_space + staff_space_rounded,
651                                  hround ((1.5 + 0.20) * staff_space),
652                                  pat, 0.96, 1);
653         bulb_c = draw_rest_bulb (.5 staff_space,
654                                  hround ((0.5 + 0.21) * staff_space),
655                                  pat, 1.0, 1);
656         bulb_d = draw_rest_bulb (.5 staff_space - staff_space_rounded,
657                                  hround ((-0.5 + 0.22) * staff_space),
658                                  pat, 1.04, 1);
659         bulb_e = draw_rest_bulb (.5 staff_space - 2 staff_space_rounded,
660                                  hround ((-1.5 + 0.23) * staff_space),
661                                  pat, 1.08, 1);
662
663         fill simple_serif (z1l, z1r, 40)
664              -- z2r
665              .. z9
666              .. bulb_a
667              -- bulb_b
668              -- bulb_c
669              -- bulb_d
670              -- bulb_e
671              -- z1l
672              .. cycle;
673
674         penlabels (1, 2);
675         labels (9);
676
677         draw_staff_if_debugging (-2, 2);
678 fet_endchar;
679
680
681 fet_endgroup ("rests");