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