]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-bolletjes.mf
release: 1.1.42
[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 brevis_wid# := 2 interline#;
24
25 def draw_brevis(expr brevwid) =
26         save beamheight, head_width;
27         save holeheight, stem_width;
28         save serif_size, serif_protrude;
29
30         head_width# = brevwid;
31         holeheight = 3 stafflinethickness;
32         stem_width = 1.4 stafflinethickness;
33
34
35         define_pixels(head_width);
36         set_char_box(0, head_width#, noteheight#/2, noteheight#/2);
37         
38         2 beamheight + holeheight = noteheight;
39         serif_size = (holeheight - stafflinethickness)/2;
40         serif_protrude = 1.5 serif_size;
41         penpos1(stem_width, 0);
42         penpos2(stem_width, 0);
43         penpos3(beamheight, 90);
44         penpos4(beamheight, 90);
45         penpos5(stem_width, 180);
46
47         z1l = (0, 0);
48         z2l = (0, -stafflinethickness/2);
49         z3r = z2r + serif_size *(1,-1);
50         y4r = y3r;
51         x4r = head_width/2;
52         z5l = z3l + (-serif_size, -serif_protrude);
53
54         penlabels(1,2,3,4, 5);
55         fill z1r -- z1l -- z5r{down} .. z5l{up} .. z3l{right}
56                 -- z4l -- z4r -- z3r{left} .. z2r{up} -- cycle;
57
58         addto currentpicture also currentpicture yscaled -1;
59         show z4r; show z4l;
60         addto currentpicture also currentpicture 
61                 shifted (-x4r,0) xscaled -1 shifted (x4l,0);
62
63 enddef;
64
65
66 fet_beginchar("Ledger ending", "ledgerending", "ledgerending")
67 set_char_box (5/2 ledgerlinethickness#, 5/2 ledgerlinethickness#,
68                 ledgerlinethickness#/2,ledgerlinethickness#/2);
69         pickup pencircle scaled 1.3 blot_diameter;
70
71         rt x2 = w;
72         lft x1 = -b;
73         x3 = x2;
74         bot y1 = -d;
75         y2 = y1;
76
77         top y3 = h;
78         y4 = y3;
79         x4 = x1;
80
81         filldraw z1 --- z2 --- z3 --- z4 --- cycle ;
82 fet_endchar;
83
84 fet_beginchar("Brevis notehead", "-1", "brevishead")
85         draw_brevis(brevis_wid#);
86 fet_endchar;
87
88 %
89 % Some sources (eg Musix/OpusTeX think that the appendage should be on
90 % the right, my only other ref [Willemze], shows an appendage to the left
91 %
92 fet_beginchar("Longa notehead", "-2", "longahead");
93         draw_brevis(brevis_wid#);
94         save theta;
95         z7 = z5;
96         z6 - z7 = (-stem_width/2, -interline);
97         theta = angle(z6-z7)+ 90;
98         penpos7(stem_width, theta);
99         penpos6(1.2 stem_width, theta);
100         
101         fill z7r .. z6r{z6-z7} .. {z7-z6} z6l -- z7l -- cycle;
102         penlabels(6,7);
103 fet_endchar;
104
105
106 % TODO: Document these!
107
108 % setup user vars
109 def setup_notehead_vars =
110         save a_b,err_y_a,tilt,superness;
111         save ai_a,ai_bi,err_y_ai,err_x_bi,inner_tilt,inner_superness;
112         save b_h,a_w;
113         enddef;
114
115 % setup addititional vars and calc them
116 def notehead_calc =
117         save a,beta,ai,bi, ht, wd;
118         ht# =noteheight#;
119         2beta#=ht#*b_h;
120         a# = beta#*a_b;
121         wd# = 2a# / a_w;
122         ai# = a# * ai_a;
123         bi# = ai#/ai_bi;
124         define_pixels(a,beta);
125         define_pixels(ai,bi);
126         set_char_box(0, wd#, .5 ht#, .5 ht#);
127         enddef;
128
129
130 % draw the outer and inner ellipse.
131 def notehead_draw =
132         path black,white;
133         black=distorted_ellipse(a,beta,a*err_y_a,0,superness);
134         white=distorted_ellipse(ai,bi,ai*err_y_ai,bi*err_x_bi,inner_superness);
135 if test>1: %fixme
136                 save x;
137                 x1=-x3=a; x2=x4=0; y1=y3=0; y2=-y4=b;
138                 penlabels(1,2,3,4);
139                 test_grid;
140 else:
141                 black:=black rotated tilt;
142                 black:=black shifted (w/2,0);
143                 white:=white rotated inner_tilt;
144                 white:=white shifted (w/2,0);
145 fi
146                 fill black;
147                 unfill white;
148
149                 
150         enddef;
151
152 % whole note
153 % Wanske, p.38
154 fet_beginchar("Whole notehead", "0", "wholehead")
155         setup_notehead_vars;
156         
157         a_b:=1.80;
158         err_y_a:=0; % no slant
159         tilt:=0;
160         superness:=0.707;
161         ai_a:=0.508;
162         % ai_bi:=1.23;
163         ai_bi:=1.30; % jcn
164         % err_y_ai:=0.0938;
165         % err_x_bi:=0;
166         err_y_ai:=0;
167         err_x_bi:=0.115;
168         % inner_tilt:=135;
169         inner_tilt:=125; % jcn
170         % inner_superness:=0.69;
171         inner_superness:=0.68; % jcn
172         b_h:=1; %no rotate-> no height correction
173         a_w:=1; % no rotate-> no width correction
174
175         notehead_calc;
176         whole_notehead_width# := wd#;
177         notehead_draw;
178 fet_endchar;
179
180
181
182 % half note
183 % Wanske, p.39
184 fet_beginchar("Half notehead", "1", 
185         "halfhead")
186         setup_notehead_vars;
187                 % a_b:=1.49; % after text
188         a_b:=1.50; % after drawing
189         err_y_a:=0.157;
190         tilt:=34;
191         % superness:=0.66;
192         superness:=0.67; % jcn
193         % ai_a:=0.863;
194         ai_a:=0.850; % jcn
195         % ai_bi:=3.14;
196         ai_bi:=3.30; % jcn
197         err_y_ai:=0;
198         err_x_bi:=-0.12;
199         inner_tilt:=tilt;
200         inner_superness:=0.80;
201         b_h:=0.935;
202         a_w:=1.12;
203
204         notehead_calc;
205         half_notehead_width# := wd#;
206         notehead_draw;
207 fet_endchar;
208
209
210
211 % quarter note
212 % Wanske p.38
213 fet_beginchar("Quart notehead", "2", "quarthead")
214         setup_notehead_vars;
215         % a_b:=1.57; % after text
216         a_b:=1.54; % after drawing
217         err_y_a:=0.044;
218         tilt:=32;
219         superness:=0.707;
220         ai_a:=0;
221         ai_bi:=1;
222         err_y_ai:=0;
223         err_x_bi:=0;
224         inner_tilt:=0;
225         inner_superness:=0.707;
226         b_h:=0.85;
227         a_w:=1.09;
228
229         notehead_calc;
230         black_notehead_width# := wd#;
231         notehead_draw;
232 fet_endchar;
233
234
235 % whole note
236 % Wanske, p.38
237 fet_beginchar("Whole diamondhead", "0diamond", "wholediamondhead")
238         setup_notehead_vars;
239         
240         a_b:=1.80;
241         err_y_a:=0; % no slant
242         tilt:=0;
243         superness:=0.495;
244         ai_a:=0.350;
245         % ai_bi:=1.23;
246         ai_bi:=1.30; % jcn
247         % err_y_ai:=0.0938;
248         % err_x_bi:=0;
249         err_y_ai:=0;
250         err_x_bi:=0.115;
251         % inner_tilt:=135;
252         inner_tilt:=125; % jcn
253         % inner_superness:=0.69;
254         inner_superness:=0.6; % jcn
255         b_h:=1; %no rotate-> no height correction
256         a_w:=1; % no rotate-> no width correction
257
258         notehead_calc;
259         whole_notehead_width# := wd#;
260         notehead_draw;
261 fet_endchar;
262
263
264 % half note
265 % Wanske, p.39
266 fet_beginchar("Half diamondhead", "1diamond", 
267         "halfdiamondhead")
268         setup_notehead_vars;
269
270         a_b := 1.50; % after drawing
271         err_y_a:=0.157;
272
273         tilt:=34;
274         superness:=0.49; % jcn
275         ai_a:=0.550; % jcn
276         ai_bi:=3.30; % jcn
277
278         err_y_ai:=0;
279         err_x_bi:=-0.12;
280         inner_tilt:=tilt;
281         inner_superness:=0.80;
282
283         b_h:= 1.03;
284         a_w:= 1.2;
285
286         notehead_calc;
287         half_notehead_width# := wd#;
288         notehead_draw;
289 fet_endchar;
290
291
292 % quarter note
293 % Wanske p.38
294 fet_beginchar("Quart diamondhead", "2diamond", "diamondhead")
295         set_char_box(0, black_notehead_width#, noteheight#/2, noteheight#/2);
296         save a_b,err_y_a,tilt,superness;
297         save b_h,a_w;
298         save a,beta,ai,bi, ht, wd;
299
300         a_b:= 1.8;
301         err_y_a:=-0.044;
302         b_h:=0.90;
303         a_w:=1.1;
304         tilt:=35;
305         superness:=0.495;
306
307         ht# =noteheight#;
308         2beta#=ht#*b_h;
309         a# = beta#*a_b;
310
311         define_pixels(a,beta);
312
313         black := distorted_ellipse(.72 noteheight, .45 noteheight, -.2 noteheight ,   0, superness)
314                                 
315 %                       beta,a*err_y_a,0,superness);
316
317         black:=black rotated tilt;
318         black:=black shifted (w/2,0);
319         fill black;
320
321 fet_endchar;
322
323 fet_beginchar("Crossed notehead", "2cross", "crossedhead")
324         set_char_box(0, black_notehead_width#, noteheight#/2, noteheight#/2);
325         pickup pencircle scaled 1.5 stafflinethickness;
326         lft x1 = 0;
327         bot y1 = -d;
328         top y2 = h;
329         rt x2 = w;
330
331         draw z1 .. z2;
332         draw (z1 .. z2) yscaled -1;
333 fet_endchar
334
335 def draw_harmonic_notehead(expr harmwid) =
336         save beamheight, head_width, head_char_width;
337         save stemthick;
338         save thin, thick;
339         save ht;
340         
341         head_width# = harmwid;
342
343         define_pixels(head_width);
344         
345         head_char_width = 1.54 noteheight;
346         head_char_width# := 1.54 ht#;
347
348
349         set_char_box(0, head_width#, head_width#/2, head_width#/2);
350
351         thin = stafflinethickness - blot_diameter/2;
352         thick = 2.2 stafflinethickness - blot_diameter/2;
353         penpos1(thick, 45);
354         penpos2(thin, 315);
355         penpos3(thin, 135);
356         penpos4(thick, 55);
357         penpos5(thick, 225);
358         penpos6(thin, 135);
359         penpos7(thin, 315);
360         penpos8(thick, 235);
361
362         
363         pickup pencircle scaled blot_diameter;
364
365         lft x1l = 0;
366         y1l = 0;
367
368         z2l = z1l;
369
370         bot y3l =  -noteheight/2;
371         x3l = head_width/2;
372         z4l = z3l;
373         rt x5l = head_width;
374         y5l =  0;
375         z6l = z5l;
376
377         top y7l = noteheight/2;
378         x7l = (head_width/2); 
379         z8l = z7l;
380
381  
382         penlabels(1,2,3,4,5,6,7,8);
383         test_grid;
384         filldraw z1l -- z2r -- z7r -- z7l -- cycle;
385         filldraw z1l -- z1r -- z4r -- z4l -- cycle;
386         filldraw z3r -- z3l -- z6l -- z6r -- cycle;
387         filldraw z5r -- z5l -- z8l -- z8r -- cycle;
388 enddef;
389
390 harmonic_wid# := interline#;
391
392 fet_beginchar("Harmonic notehead","2harmonic","harmonichead")
393         draw_harmonic_notehead(harmonic_wid#)
394 fet_endchar;
395
396 %fi
397
398 fet_endgroup("noteheads");
399
400 define_pixels(black_notehead_width);