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