]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-bolletjes.mf
* scm/paper.scm (set-staff-size): new function: set default
[lilypond.git] / mf / feta-bolletjes.mf
1 %  -*-Fundamental-*-
2 % feta-bolletjes.mf --  implement noteheads
3
4 % source file of LilyPond's pretty-but-neat music font
5
6 % (c)  1997--2003 Jan Nieuwenhuizen <janneke@gnu.org>
7 % & Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 % & Juergen Reuter <reuter@ipd.uka.de>
9
10
11 test_outlines := 0;
12
13
14 % most beautiful noteheads are pronounced, not circular, 
15 % and not even symmetric.
16 % These examples are inspired by [Wanske], see literature list
17
18
19
20 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21 % NOTE HEAD VARIABLES
22 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
23 save black_notehead_width, noteheight,
24         slash_thick, slash_slope, overdone_heads;
25 numeric black_notehead_width, noteheight, slash_thick;
26
27 fet_begingroup("noteheads");
28
29
30
31 % slope of slash. From scm/grob-description.scm. How to auto-copy?
32 slash_slope := 1.7; 
33
34 % thickness of slash lines. quarter notes get 1.5slt width.
35 slash_thick# := 2/3*0.48staff_space#;
36
37
38 %
39 % Hand-engraved music often has balls extending above and below
40 % the lines.  If you like that, modify overdone heads (unit:
41 % stafflinethickness)
42 %
43 overdone_heads = 0.0;
44 noteheight#:=staff_space#+ (1 + overdone_heads) *stafflinethickness#;
45
46 define_pixels(slash_thick, noteheight);
47
48
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 %
51 % SLANT moves both extremes on the long axis (by SLANT * ELLIPSIDITY,
52 % so SLANT = -1, puts the extreme on the long axis next to the short axis one.)
53 %
54
55 def draw_outside_ellipse (expr ellipsidity, tilt, superness,
56                         slant) =
57         save attachment_y;
58         save p;
59         path p;
60
61         p := superellipse ((ellipsidity, 0), (-slant * ellipsidity, 1.0),
62                         (- ellipsidity, 0), (slant * ellipsidity, -1.0), superness);
63
64         p := p rotated tilt;
65
66         save top_point, right_point;
67         pair top_point, right_point;
68
69         top_point := directionpoint left of p;
70         right_point := directionpoint up of p;
71
72         save scaling, width, height;
73
74         scaling# = noteheight# /(2 ypart (top_point));
75         width# := 2 xpart (right_point) * scaling#;
76
77         define_pixels (width, scaling);
78         
79         set_char_box (0, width#, noteheight#/2, noteheight#/2);
80
81         % attachment Y
82         charwy := ypart (right_point) * scaling#;
83         charwx := width# ;
84
85         p := p scaled scaling shifted (width/2, 0) ;
86         if test_outlines = 1:
87                 pickup pencircle scaled 1 ; draw p;
88         else:
89                 fill p;
90         fi;
91 enddef;
92
93
94 def undraw_inside_ellipse (expr ellipsidity, tilt, superness, clearance,
95                         center) =
96 begingroup
97         save p;
98         path p;
99
100         p := superellipse ((ellipsidity, 0), (0, 1.0),
101                         (- ellipsidity, 0), (0, -1.0), superness);
102
103         p := p rotated tilt;
104
105         save top_point, right_point;
106         pair top_point, right_point;
107
108         top_point := directionpoint left of p;
109         right_point := directionpoint up of p;
110
111         save height, scaling;
112
113         height# = staff_space# + stafflinethickness# - clearance;
114         scaling# = height# /(2 ypart (top_point));
115
116         define_pixels (scaling);
117         p := (p scaled scaling) shifted center;
118
119         if test_outlines = 1:
120                 pickup pencircle scaled 1; draw p;
121         else:
122                 unfill p;
123         fi
124 endgroup;
125 enddef;
126
127
128
129
130
131 %
132 % dimensions aren't entirely right.
133 %
134 fet_beginchar ("Brevis notehead", "-1", "brevishead");
135         save stemthick, fudge;
136         define_pixels (stemthick);
137         fudge = blot_diameter /2;
138         stemthick# = 2 stafflinethickness#;
139
140         draw_outside_ellipse (1.80, 0, 0.707, 0);
141         undraw_inside_ellipse (1.30, 125, 0.68, 2 stafflinethickness#,
142                                 (w /2, 0));
143
144         pickup pencircle scaled stemthick;
145
146         bot y1 = -d;
147         top y2 = h;
148         rt x1 - fudge = 0;
149         x1 = x2;
150
151         fudge + lft x3 = w;
152         x4 = x3;
153         y4 = y2;
154         y3 = y1;
155
156         draw_gridline(z1,z2,stemthick);
157         draw_gridline(z3,z4,stemthick);
158
159 fet_endchar;
160
161
162
163 fet_beginchar("Whole notehead", "0", "wholehead")
164         draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0, 0.707, 0);
165         undraw_inside_ellipse (1.30, 125 - puff_up_factor *10,
166                         0.68, 2 stafflinethickness#,
167                         (w /2, 0));
168
169 %       draw_staff_outline (-2, 2, 0.5);
170
171 fet_endchar;
172
173
174 fet_beginchar("Half notehead", "1", "halfhead")
175         draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34, 0.66, 0.17);
176         undraw_inside_ellipse (3.25, 33, 0.81,
177                 2.5 stafflinethickness#, (w/2, 0));
178
179 fet_endchar;
180         
181 fet_beginchar("Quart notehead", "2", "quarthead")
182         draw_outside_ellipse (1.42 - puff_up_factor / 3.0, 32, 0.707, 0);
183         black_notehead_width# := charwd;
184 fet_endchar;
185
186 %%%%%%%%%%%%%%%%
187
188 %% testing shapes.
189
190 if 0 = 1 : 
191
192
193 fet_beginchar("Quart noteheadPQ", "2PQ", "quartheadPQ")
194         draw_outside_ellipse (1.0 - puff_up_factor / 2.0, 32, 0.707, 0);
195 fet_endchar;
196
197 fet_beginchar("Quart noteheadAA", "2AA", "quartheadAA")
198         draw_outside_ellipse (1.35 - puff_up_factor / 2.0, 32, 0.707, 0);
199 fet_endchar;
200
201 fet_beginchar("Quart noteheadAB", "2AB", "quartheadAB")
202         draw_outside_ellipse (1.4 - puff_up_factor / 2.0, 32, 0.707, 0);
203         
204 fet_endchar;
205 fet_beginchar("Quart noteheadAC", "2AC", "quartheadAC")
206         draw_outside_ellipse (1.45 - puff_up_factor / 2.0, 32, 0.707, 0);
207 fet_endchar;
208
209 fet_beginchar("Quart noteheadAD", "2AD", "quartheadAD")
210         draw_outside_ellipse (1.5 - puff_up_factor / 2.0, 32, 0.707, 0);
211 fet_endchar;
212
213 fet_beginchar("Quart noteheadAD", "2AE", "quartheadAD")
214         draw_outside_ellipse (1.55 - puff_up_factor / 2.0, 32, 0.707, 0);
215 fet_endchar;
216
217 fet_beginchar("Quart noteheadAD", "2AF", "quartheadAD")
218         draw_outside_ellipse (1.6 - puff_up_factor / 2.0, 32, 0.707, 0);
219 fet_endchar;
220 fet_beginchar("Quart noteheadAD", "2AG", "quartheadAD")
221         draw_outside_ellipse (1.65 - puff_up_factor / 2.0, 32, 0.707, 0);
222 fet_endchar;
223
224
225 fet_beginchar("Quart noteheadBA", "2BA", "quartheadBA")
226         draw_outside_ellipse (1.35 - puff_up_factor / 2.0, 35, 0.707, 0);
227 fet_endchar;
228 fet_beginchar("Quart noteheadBB", "2BB", "quartheadBB")
229         draw_outside_ellipse (1.4 - puff_up_factor / 2.0, 35, 0.707, 0);
230         
231 fet_endchar;
232 fet_beginchar("Quart noteheadBC", "2BC", "quartheadBC")
233         draw_outside_ellipse (1.45 - puff_up_factor / 2.0, 35, 0.707, 0);
234 fet_endchar;
235 fet_beginchar("Quart noteheadBD", "2BD", "quartheadBD")
236         draw_outside_ellipse (1.5 - puff_up_factor / 2.0, 35, 0.707, 0);
237 fet_endchar;
238 fet_beginchar("Quart noteheadBD", "2BE", "quartheadBD")
239         draw_outside_ellipse (1.55 - puff_up_factor / 2.0, 35, 0.707, 0);
240 fet_endchar;
241 fet_beginchar("Quart noteheadBD", "2BF", "quartheadBD")
242         draw_outside_ellipse (1.6 - puff_up_factor / 2.0, 35, 0.707, 0);
243 fet_endchar;
244 fet_beginchar("Quart noteheadBD", "2BG", "quartheadBD")
245         draw_outside_ellipse (1.65 - puff_up_factor / 2.0, 35, 0.707, 0);
246 fet_endchar;
247
248
249
250 fet_beginchar("Quart noteheadCA", "2CA", "quartheadCA")
251         draw_outside_ellipse (1.35 - puff_up_factor / 2.0, 40, 0.707, 0);
252 fet_endchar;
253 fet_beginchar("Quart noteheadCB", "2CB", "quartheadCB")
254         draw_outside_ellipse (1.4 - puff_up_factor / 2.0, 40, 0.707, 0);
255 fet_endchar;
256 fet_beginchar("Quart noteheadCC", "2CC", "quartheadCC")
257         draw_outside_ellipse (1.45 - puff_up_factor / 2.0, 40, 0.707, 0);
258 fet_endchar;
259 fet_beginchar("Quart noteheadCD", "2CD", "quartheadCD")
260         draw_outside_ellipse (1.5 - puff_up_factor / 2.0, 40, 0.707, 0);
261 fet_endchar;
262 fet_beginchar("Quart noteheadCD", "2CE", "quartheadCD")
263         draw_outside_ellipse (1.55 - puff_up_factor / 2.0, 40, 0.707, 0);
264 fet_endchar;
265 fet_beginchar("Quart noteheadCD", "2CF", "quartheadCD")
266         draw_outside_ellipse (1.6 - puff_up_factor / 2.0, 40, 0.707, 0);
267 fet_endchar;
268 fet_beginchar("Quart noteheadCD", "2CG", "quartheadCD")
269         draw_outside_ellipse (1.65 - puff_up_factor / 2.0, 40, 0.707, 0);
270 fet_endchar;
271
272 fi
273
274 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
275
276
277 fet_beginchar("Whole diamondhead", "0diamond", "wholediamondhead")
278         draw_outside_ellipse (1.80, 0, 0.495, 0);
279         undraw_inside_ellipse (1.30, 125, 0.6,
280                         .4 staff_space# +  stafflinethickness#,
281                                 (w /2, 0));
282
283 fet_endchar;
284
285 fet_beginchar("Half diamondhead", "1diamond", 
286         "halfdiamondhead")
287
288         draw_outside_ellipse (1.50, 34, 0.49, 0.17);
289         undraw_inside_ellipse (3.5, 33, 0.80,
290                 .3 staff_space# + 1.5 stafflinethickness#, (w/2, 0));
291
292 fet_endchar;
293
294 fet_beginchar("Quart diamondheadh", "2diamondh", "diamondheadh")
295         draw_outside_ellipse (1.80, 35, 0.495, -0.25);
296 fet_endchar;
297
298 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
299
300
301
302
303
304 def def_triangle =
305         save triangle,kern; path triangle;
306         save left_point, height, width;
307         pair exact_left_point;
308         save pen_thick;
309         pen_thick# = stafflinethickness#  + .1 staff_space#;
310         define_pixels(pen_thick);
311
312         exact_left_point := llap# * dir (90 + tilt);
313         height# = max (ypart exact_left_point,
314                         -ypart  (exact_left_point rotated 120)) + pen_thick#/2;
315
316         kern# = 1/3 xpart (exact_left_point - (exact_left_point rotated 120));
317         width# = xpart (-exact_left_point + (exact_left_point rotated 240));
318         define_pixels (kern);   
319         z1 = (hround_pixels (xpart exact_left_point), vround_pixels  (ypart exact_left_point));
320         z2 = z1 rotated 120;
321         z3 = z1 rotated 240;
322
323         z12 = caveness[.5[z1,z2],z3];
324         z23 = z12 rotated 120;
325         z31 = z12 rotated 240;
326         triangle = z1 .. z12 .. z2 ..
327                     z2 .. z23 .. z3 ..
328                     z3 .. z31 .. z1 ..
329                     cycle;
330         triangle := triangle shifted (-x1+pen_thick/2-kern,0) xscaled xs;
331         pickup pencircle scaled pen_thick xscaled xs;
332 %       labels(1,2,12,23,31,3);
333         set_char_box(0, width# - kern#+ pen_thick#, height#, height#);
334 enddef;
335
336 fet_beginchar("Whole trianglehead", "0triangle", "wholetrianglehead")
337         save hei,xs;
338         save llap;
339         save tilt;
340
341         tilt = 40;
342         llap# = 3/4noteheight#;
343
344         xs = 1.5;
345         caveness:=0.1;
346         def_triangle;
347         draw triangle;
348 fet_endchar;
349
350 fet_beginchar("Half trianglehead", "1triangle", "halftrianglehead")
351         save hei,xs;
352         save llap;
353         save tilt;
354
355         tilt = 40;
356         llap# = 2/3noteheight#;
357         xs = 1.2;
358         caveness:=0.1;
359         def_triangle;
360         draw triangle;
361 fet_endchar;
362
363 fet_beginchar("Quart trianglehead", "2triangle", "trianglehead")
364         save hei,xs;
365         save llap;
366         save tilt;
367         tilt = 40;
368         llap# = 2/3noteheight#;
369         xs = 1.0;
370         caveness:=0.1;
371         def_triangle;
372         filldraw triangle;
373 fet_endchar;
374
375 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
376 %
377 % slash heads are for indicating improvisation. They are  
378 % twice as high as normal heads.
379 %
380 def draw_slash(expr hwid_hash) =
381         save exact_height;
382         save ne_dir;
383         pair ne_dir;
384         exact_height =  staff_space# + stafflinethickness#/2;
385
386         set_char_box (0, 2 exact_height / slash_slope + hwid_hash,
387                         exact_height, exact_height);
388
389         charwx := charwd;
390         charwy := charht;
391
392         clearxy;
393         pickup pencircle scaled blot_diameter;
394
395         bot y1 = - d;
396         top y2 = h;
397         lft x1 = 0;
398         lft x2 = 2 h / slash_slope;
399         
400         rt x3 = w;
401         y3 = y2;
402         y4 = y1;
403         x3- x2 = x4 - x1;
404
405         ne_dir := unitvector( z3  - z4);
406         filldraw z1 --- z2 --- z3 --- z4 --- cycle;
407
408         if hwid_hash > 2 slash_thick#:
409                 save th;
410
411                 th = slash_thick - blot_diameter;
412                 y6 = y7;
413                 y5 = y8;
414                 y3 - y7 = th;
415                 y5 - y1 = th;
416                 z6 - z5 = whatever * ne_dir;
417                 z8 - z7 = whatever * ne_dir;
418
419                 z5  = z1 + whatever * ne_dir + th * (ne_dir rotated -90);
420                 z8  = z4 + whatever * ne_dir + th * (ne_dir rotated 90);
421
422                 unfill
423                         z5 -- z6 -- z7 -- z8 -- cycle;
424         fi
425         labels (range 1 thru 10);
426 enddef;
427
428 fet_beginchar("Whole slashhead","0slash","wholeslashhead")
429         draw_slash(4 slash_thick# + 0.5 staff_space#);
430 fet_endchar;
431
432 fet_beginchar("Half slashhead","1slash","halfslashhead")
433         draw_slash(3.0 slash_thick# + 0.15 staff_space#);
434 fet_endchar;
435
436 fet_beginchar("Quart slashhead","2slash","quartslashhead")
437         draw_slash(1.5 slash_thick#);
438 fet_endchar;
439
440 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
441 % thick is the distance between the NE/SW parallel lines in the cross
442 % (distance between centres of lines)
443 % in stafflinethickness def
444 %
445 def draw_cross(expr thick) =
446         save pent, slant, ne_dir;
447         pair ne_dir;
448         save crz; path crz;
449
450         pen_thick# := 1.2stafflinethickness#;
451         define_pixels (pen_thick);
452         pickup pencircle scaled pen_thick;
453
454         top y3 = h;
455         ne_dir := unitvector ((1, (2 h -pen_thick)/(w - pen_thick)));
456         rt x4 = w/2;
457         y5 = 0;
458         z4 - z5 = whatever * ne_dir;
459         x6 = 0;
460         z6 - z3 = whatever * ne_dir;
461         z3 - z4 = whatever * (ne_dir yscaled -1);
462
463         z4 - z3 = whatever * (ne_dir) + (ne_dir rotated -90) * thick * stafflinethickness;
464
465         x1 = charwd/2 - .5 pen_thick#;
466         z1 = whatever * ne_dir + thick/2 * stafflinethickness# * (ne_dir rotated -90);
467
468         
469         labels (1,2,3,4,5,6);
470
471         crz = (z6 -- z3 -- z4 -- z5) ;
472
473         draw crz shifted(w/2,0);
474         draw crz xscaled -1 shifted(w/2,0);
475         draw crz yscaled -1 shifted(w/2,0);
476         draw crz scaled -1 shifted(w/2,0);
477
478         charwx := charwd;
479         charwy := y1;
480                 message (decimal charwx);
481                 message (decimal charwy);
482         z12 = (charwx * hppp, y1 * vppp);
483         labels (12);
484 enddef;
485
486 fet_beginchar("Whole Crossed notehead", "0cross", "wholecrossedhead")
487         wid# := black_notehead_width#+4stafflinethickness#;
488         hei# := noteheight#+stafflinethickness#;
489         set_char_box(0, wid#,hei#/2,hei#/2);
490         
491         draw_cross (3.75);
492 fet_endchar;
493
494 fet_beginchar("Half Crossed notehead", "1cross", "halfcrossedhead")
495         wid# := black_notehead_width#+2stafflinethickness#;
496         hei# := noteheight#+stafflinethickness#/2;
497         set_char_box(0, wid#,hei#/2,hei#/2);
498         draw_cross(3.0);
499 fet_endchar;
500
501 fet_beginchar("Crossed notehead", "2cross", "crossedhead")
502         wid# := black_notehead_width#;
503         hei# := noteheight#;
504         set_char_box(0, wid#,hei#/2,hei#/2);
505         draw_cross(1.0);
506 fet_endchar;
507
508 fet_beginchar("X-Circled notehead", "2xcircle", "xcircledhead")
509         wid# := black_notehead_width#*sqrt(sqrt2);
510         hei# := noteheight#*sqrt(sqrt2);
511         set_char_box(0, wid#,hei#/2,hei#/2);
512         cthick := (1.2+1/4)*stafflinethickness;
513         cxr := w/2-cthick/2;
514         cyr := h-cthick/2;
515         pickup pencircle scaled cthick;
516         draw fullcircle xscaled 2cxr yscaled 2cyr shifted (w/2,0);
517         xpos := cxr/sqrt2;
518         ypos := cyr/sqrt2;
519         draw (-xpos+w/2,-ypos) -- (xpos+w/2,ypos);
520         draw (-xpos+w/2,ypos) -- (xpos+w/2,-ypos);
521
522         charwx := charwd ; 
523         charwy := 0 ;
524
525         z12 = (charwx * hppp , charwy * vppp );
526         labels (12);
527 fet_endchar;
528
529
530
531 fet_endgroup("noteheads");
532
533 define_pixels(black_notehead_width);