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