]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-bolletjes.mf
release: 1.3.18
[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, 1998 Jan Nieuwenhuizen <janneke@gnu.org>
7 % & Han-Wen Nienhuys <hanwen@stack.nl>
8
9
10
11 % most beautiful noteheads are pronounced, not circular, 
12 % and not even symmetric.
13 % These examples are inspired by [Wanske], see literature list
14
15
16 save black_notehead_width;
17 numeric black_notehead_width;
18
19 fet_begingroup("noteheads");
20
21 noteheight#:=interline#+ (1 + overdone_heads) *stafflinethickness#;
22 define_pixels(noteheight);
23
24
25 %%%%%%%%
26 %
27 %
28 %
29 % MENSURAL NOTATION
30 %
31 %
32 %
33 brevis_wid# := 2 interline#;
34
35 def draw_brevis(expr brevwid) =
36         save beamheight, head_width;
37         save holeheight, stem_width;
38         save serif_size, serif_protrude;
39
40         head_width# = brevwid;
41         holeheight = 3 stafflinethickness;
42         stem_width = 1.4 stafflinethickness;
43
44
45         define_pixels(head_width);
46         set_char_box(0, head_width#, noteheight#/2, noteheight#/2);
47         
48         2 beamheight + holeheight = noteheight;
49         serif_size = (holeheight - stafflinethickness)/2;
50         serif_protrude = 1.5 serif_size;
51         penpos1(stem_width, 0);
52         penpos2(stem_width, 0);
53         penpos3(beamheight, 90);
54         penpos4(beamheight, 90);
55         penpos5(stem_width, 180);
56
57         z1l = (0, 0);
58         z2l = (0, -stafflinethickness/2);
59         z3r = z2r + serif_size *(1,-1);
60         y4r = y3r;
61         x4r = head_width/2;
62         z5l = z3l + (-serif_size, -serif_protrude);
63
64         penlabels(1,2,3,4, 5);
65         fill z1r -- z1l -- z5r{down} .. z5l{up} .. z3l{right}
66                 -- z4l -- z4r -- z3r{left} .. z2r{up} -- cycle;
67
68         addto currentpicture also currentpicture yscaled -1;
69         show z4r; show z4l;
70         addto currentpicture also currentpicture 
71                 shifted (-x4r,0) xscaled -1 shifted (x4l,0);
72
73 enddef;
74
75
76 %
77 % Some sources (eg Musix/OpusTeX think that the appendage should be on
78 % the left, some say right. Right wins democratically.
79 %
80 def draw_longa (expr wid) =
81         draw_brevis(wid);
82         save theta;
83
84         x7r = head_width;
85         y7 = y5;
86 %       z7 = z5;
87         z6 - z7 = (stem_width/2, -interline);
88         theta = angle(z6-z7)+ 90;
89         penpos7(stem_width, theta);
90         penpos6(1.2 stem_width, theta);
91         
92         fill z7r .. z6r{z6-z7} .. {z7-z6} z6l -- z7l -- cycle;
93         penlabels(6,7);
94 enddef;
95
96 %
97 % En wij presenteren U: de opvolgster van Emily
98 %
99 % (ze is wel breed)
100
101 fet_beginchar("Maxima notehead", "-3mensural", "mensuralmaximahead");
102         draw_longa (1.3 brevis_wid#)
103 fet_endchar;
104
105 fet_beginchar("Longa notehead", "-2mensural", "mensurallongahead");
106         draw_longa (brevis_wid#)
107 fet_endchar;
108
109 fet_beginchar("Brevis notehead", "-1mensural", "mensuralbrevishead")
110         draw_brevis(brevis_wid#);
111 fet_endchar;
112
113 def draw_mensural_black_head (expr wid) =
114         save head_width;
115         head_width# = wid;
116         set_char_box (0, head_width#, noteheight#/2, noteheight#/2);
117
118
119         y3 = y1 =0;
120         x2 = x4 = (x1 + x3) /2;
121         define_pixels (head_width);
122         pickup pencircle scaled blot_diameter;
123         top y2 = h;
124         bot y4 = -d;
125         lft x1 = 0;
126         rt x3 = w;
127
128         filldraw z1 -- z2 -- z3 -- z4 -- cycle;
129 enddef;
130
131 def draw_mensural_open_head (expr wid)=
132         draw_mensural_black_head (wid);
133         save diamNW, diamSW;
134         diamNW = length (z2 - z1) + blot_diameter;
135         diamSW = length (z4 - z1) + blot_diameter;
136         
137         save hole_widthNW, hole_widthSW;
138         hole_widthNW = 0.34 diamNW ;
139         hole_widthSW + 2.6 stafflinethickness = diamSW;
140
141         (z7 + z5)/2 = (w/2, 0);
142         (z8 + z6)/2 = (w/2, 0);
143         (z6 - z5) = hole_widthNW * unitvector (z2 - z1);
144         (z7 - z6) = hole_widthSW * unitvector (z4 - z1);
145
146         labels (1,2,3,4,5,6,7,8);
147
148         unfill z5 -- z6 -- z7 -- z8 --cycle;
149 enddef;
150
151 fet_beginchar("Mensural open head","0mensural","mensuralminimhead")
152         draw_mensural_open_head (interline#);
153 fet_endchar;
154
155 fet_beginchar("Mensural open head","1mensural","mensuralsemiminimhead")
156         draw_mensural_open_head (interline#);
157 fet_endchar;
158
159 fet_beginchar("Mensural black head","2mensural","fusahead")
160         draw_mensural_black_head (interline#);
161 fet_endchar;
162
163
164 %%%%%%%%%%%%
165 %
166 %
167 % ledger (leger) lines
168 %
169 fet_beginchar("Ledger ending", "ledgerending", "ledgerending")
170 set_char_box (5/2 ledgerlinethickness#, 5/2 ledgerlinethickness#,
171                 ledgerlinethickness#/2,ledgerlinethickness#/2);
172         pickup pencircle scaled 1.3 blot_diameter;
173
174         rt x2 = w;
175         lft x1 = -b;
176         x3 = x2;
177         bot y1 = -d;
178         y2 = y1;
179
180         top y3 = h;
181         y4 = y3;
182         x4 = x1;
183
184         filldraw z1 --- z2 --- z3 --- z4 --- cycle ;
185 fet_endchar;
186
187
188
189 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
190 %
191 %
192 %
193 %
194 %
195 % TODO: Document these!
196
197 % setup user vars
198 def setup_notehead_vars =
199         save a_b,err_y_a,tilt,superness;
200         save ai_a,ai_bi,err_y_ai,err_x_bi,inner_tilt,inner_superness;
201         save b_h,a_w;
202         enddef;
203
204 % setup addititional vars and calc them
205 def notehead_calc =
206         save a,beta,ai,bi, ht, wd;
207         ht# =noteheight#;
208         2beta#=ht#*b_h;
209         a# = beta#*a_b;
210         wd# = 2a# / a_w;
211         ai# = a# * ai_a;
212         bi# = ai#/ai_bi;
213         define_pixels(a,beta);
214         define_pixels(ai,bi);
215         set_char_box(0, wd#, .5 ht#, .5 ht#);
216         enddef;
217
218
219 % draw the outer and inner ellipse.
220 def notehead_draw =
221         path black,white;
222         black=distorted_ellipse(a,beta,a*err_y_a,0,superness);
223         white=distorted_ellipse(ai,bi,ai*err_y_ai,bi*err_x_bi,inner_superness);
224 if test>1: %fixme
225                 save x;
226                 x1=-x3=a; x2=x4=0; y1=y3=0; y2=-y4=b;
227                 penlabels(1,2,3,4);
228                 test_grid;
229 else:
230                 black:=black rotated tilt;
231                 black:=black shifted (w/2,0);
232                 white:=white rotated inner_tilt;
233                 white:=white shifted (w/2,0);
234 fi
235                 fill black;
236                 unfill white;
237
238                 
239         enddef;
240
241 def draw_whole_head =
242         setup_notehead_vars;
243         
244         a_b:=1.80;
245         err_y_a:=0; % no slant
246         tilt:=0;
247         superness:=0.707;
248         ai_a:=0.508;
249         % ai_bi:=1.23;
250         ai_bi:=1.30; % jcn
251         % err_y_ai:=0.0938;
252         % err_x_bi:=0;
253         err_y_ai:=0;
254         err_x_bi:=0.115;
255         % inner_tilt:=135;
256         inner_tilt:=125; % jcn
257         % inner_superness:=0.69;
258         inner_superness:=0.68; % jcn
259         b_h:=1; %no rotate-> no height correction
260         a_w:=1; % no rotate-> no width correction
261
262         notehead_calc;
263         whole_notehead_width# := wd#;
264         notehead_draw;
265 enddef;
266
267
268 %
269 % dimensions aren't entirely right.
270 %
271 fet_beginchar ("Brevis notehead", "-1", "brevishead");
272         save stemthick, fudge;
273         define_pixels (stemthick);
274         fudge = blot_diameter /2;
275         stemthick# = 2 stafflinethickness#;
276
277         draw_whole_head;
278
279         pickup pencircle scaled stemthick;
280
281         bot y1 = -d;
282         top y2 = h;
283         rt x1 - fudge = 0;
284         x1 = x2;
285
286         fudge + lft x3 = w;
287         x4 = x3;
288         y4 = y2;
289         y3 = y1;
290
291         draw z1 -- z2;
292         draw z3 -- z4;
293 fet_endchar;
294
295 % whole note
296 % Wanske, p.38
297 fet_beginchar("Whole notehead", "0", "wholehead")
298         draw_whole_head;
299 fet_endchar;
300
301
302
303 % half note
304 % Wanske, p.39
305 fet_beginchar("Half notehead", "1", 
306         "halfhead")
307         setup_notehead_vars;
308                 % a_b:=1.49; % after text
309         a_b:=1.50; % after drawing
310         err_y_a:=0.157;
311         tilt:=34;
312         % superness:=0.66;
313         superness:=0.67; % jcn
314         % ai_a:=0.863;
315         ai_a:=0.850; % jcn
316         % ai_bi:=3.14;
317         ai_bi:=3.30; % jcn
318         err_y_ai:=0;
319         err_x_bi:=-0.12;
320         inner_tilt:=tilt;
321         inner_superness:=0.80;
322         b_h:=0.935;
323         a_w:=1.12;
324
325         notehead_calc;
326         half_notehead_width# := wd#;
327         notehead_draw;
328 fet_endchar;
329
330
331
332 % quarter note
333 % Wanske p.38
334 fet_beginchar("Quart notehead", "2", "quarthead")
335         setup_notehead_vars;
336         % a_b:=1.57; % after text
337         a_b:=1.54; % after drawing
338         err_y_a:=0.044;
339         tilt:=32;
340         superness:=0.707;
341         ai_a:=0;
342         ai_bi:=1;
343         err_y_ai:=0;
344         err_x_bi:=0;
345         inner_tilt:=0;
346         inner_superness:=0.707;
347         b_h:=0.85;
348         a_w:=1.09;
349
350         notehead_calc;
351         black_notehead_width# := wd#;
352         notehead_draw;
353 fet_endchar;
354
355
356 % whole note
357 % Wanske, p.38
358 fet_beginchar("Whole diamondhead", "0diamond", "wholediamondhead")
359         setup_notehead_vars;
360         
361         a_b:=1.80;
362         err_y_a:=0; % no slant
363         tilt:=0;
364         superness:=0.495;
365         ai_a:=0.350;
366         % ai_bi:=1.23;
367         ai_bi:=1.30; % jcn
368         % err_y_ai:=0.0938;
369         % err_x_bi:=0;
370         err_y_ai:=0;
371         err_x_bi:=0.115;
372         % inner_tilt:=135;
373         inner_tilt:=125; % jcn
374         % inner_superness:=0.69;
375         inner_superness:=0.6; % jcn
376         b_h:=1; %no rotate-> no height correction
377         a_w:=1; % no rotate-> no width correction
378
379         notehead_calc;
380         whole_notehead_width# := wd#;
381         notehead_draw;
382 fet_endchar;
383
384
385 % half note
386 % Wanske, p.39
387 fet_beginchar("Half diamondhead", "1diamond", 
388         "halfdiamondhead")
389         setup_notehead_vars;
390
391         a_b := 1.50; % after drawing
392         err_y_a:=0.157;
393
394         tilt:=34;
395         superness:=0.49; % jcn
396         ai_a:=0.550; % jcn
397         ai_bi:=3.30; % jcn
398
399         err_y_ai:=0;
400         err_x_bi:=-0.12;
401         inner_tilt:=tilt;
402         inner_superness:=0.80;
403
404         b_h:= 1.03;
405         a_w:= 1.2;
406
407         notehead_calc;
408         half_notehead_width# := wd#;
409         notehead_draw;
410 fet_endchar;
411
412
413 % quarter note
414 % Wanske p.38
415 fet_beginchar("Quart diamondhead", "2diamond", "diamondhead")
416         set_char_box(0, black_notehead_width#, noteheight#/2, noteheight#/2);
417         save a_b,err_y_a,tilt,superness;
418         save b_h,a_w;
419         save a,beta,ai,bi, ht, wd;
420
421         a_b:= 1.8;
422         err_y_a:=-0.044;
423         b_h:=0.90;
424         a_w:=1.1;
425         tilt:=35;
426         superness:=0.495;
427
428         ht# =noteheight#;
429         2beta#=ht#*b_h;
430         a# = beta#*a_b;
431
432         define_pixels(a,beta);
433
434         black := distorted_ellipse(.72 noteheight, .45 noteheight, -.2 noteheight ,   0, superness)
435                                 
436 %                       beta,a*err_y_a,0,superness);
437
438         black:=black rotated tilt;
439         black:=black shifted (w/2,0);
440         fill black;
441 fet_endchar;
442
443 fet_beginchar("Crossed notehead", "2cross", "crossedhead")
444         set_char_box(0, black_notehead_width#, noteheight#/2, noteheight#/2);
445         pickup pencircle scaled 1.5 stafflinethickness;
446         lft x1 = 0;
447         bot y1 = -d;
448         top y2 = h;
449         rt x2 = w;
450
451         draw z1 .. z2;
452         draw (z1 .. z2) yscaled -1;
453 fet_endchar
454
455
456 fet_endgroup("noteheads");
457 define_pixels(black_notehead_width);