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