2 % feta-bolletjes.mf -- implement noteheads
4 % source file of LilyPond's pretty-but-neat music font
6 % (c) 1997, 1998 Jan Nieuwenhuizen <janneke@gnu.org>
7 % & Han-Wen Nienhuys <hanwen@stack.nl>
11 % most beautiful noteheads are pronounced, not circular,
12 % and not even symmetric.
13 % These examples are inspired by [Wanske], see literature list
16 save black_notehead_width;
17 numeric black_notehead_width;
19 fet_begingroup("noteheads");
21 noteheight#:=staff_space#+ (1 + overdone_heads) *stafflinethickness#;
22 define_pixels(noteheight);
33 brevis_wid# := 2 staff_space#;
35 def draw_brevis(expr brevwid) =
36 save beamheight, head_width;
37 save holeheight, stem_width;
38 save serif_size, serif_protrude;
40 head_width# = brevwid;
41 holeheight = 3 stafflinethickness;
42 stem_width = 1.4 stafflinethickness;
45 define_pixels(head_width);
46 set_char_box(0, head_width#, noteheight#/2, noteheight#/2);
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);
58 z2l = (0, -stafflinethickness/2);
59 z3r = z2r + serif_size *(1,-1);
62 z5l = z3l + (-serif_size, -serif_protrude);
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;
68 addto currentpicture also currentpicture yscaled -1;
70 addto currentpicture also currentpicture
71 shifted (-x4r,0) xscaled -1 shifted (x4l,0);
77 % Some sources (eg Musix/OpusTeX think that the appendage should be on
78 % the left, some say right. Right wins democratically.
80 def draw_longa (expr wid) =
87 z6 - z7 = (stem_width/2, -staff_space);
88 theta = angle(z6-z7)+ 90;
89 penpos7(stem_width, theta);
90 penpos6(1.2 stem_width, theta);
92 fill z7r .. z6r{z6-z7} .. {z7-z6} z6l -- z7l -- cycle;
97 % En wij presenteren U: de opvolgster van Emily
101 fet_beginchar("Maxima notehead", "-3mensural", "mensuralmaximahead");
102 draw_longa (1.3 brevis_wid#)
105 fet_beginchar("Longa notehead", "-2mensural", "mensurallongahead");
106 draw_longa (brevis_wid#)
109 fet_beginchar("Brevis notehead", "-1mensural", "mensuralbrevishead")
110 draw_brevis(brevis_wid#);
113 def draw_mensural_black_head (expr wid) =
116 set_char_box (0, head_width#, noteheight#/2, noteheight#/2);
120 x2 = x4 = (x1 + x3) /2;
121 define_pixels (head_width);
122 pickup pencircle scaled blot_diameter;
128 filldraw z1 -- z2 -- z3 -- z4 -- cycle;
131 def draw_mensural_open_head (expr wid)=
132 draw_mensural_black_head (wid);
134 diamNW = length (z2 - z1) + blot_diameter;
135 diamSW = length (z4 - z1) + blot_diameter;
137 save hole_widthNW, hole_widthSW;
138 hole_widthNW = 0.34 diamNW ;
139 hole_widthSW + 2.6 stafflinethickness = diamSW;
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);
146 labels (1,2,3,4,5,6,7,8);
148 unfill z5 -- z6 -- z7 -- z8 --cycle;
151 fet_beginchar("Mensural open head","0mensural","mensuralminimhead")
152 draw_mensural_open_head (staff_space#);
155 fet_beginchar("Mensural open head","1mensural","mensuralsemiminimhead")
156 draw_mensural_open_head (staff_space#);
159 fet_beginchar("Mensural black head","2mensural","fusahead")
160 draw_mensural_black_head (staff_space#);
167 % ledger (leger) lines
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;
184 filldraw z1 --- z2 --- z3 --- z4 --- cycle ;
189 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
195 % TODO: Document these!
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;
204 % setup addititional vars and calc them
206 save a,beta,ai,bi, ht, wd;
213 define_pixels(a,beta);
214 define_pixels(ai,bi);
215 set_char_box(0, wd#, .5 ht#, .5 ht#);
219 % draw the outer and inner ellipse.
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);
226 x1=-x3=a; x2=x4=0; y1=y3=0; y2=-y4=b;
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);
241 def draw_whole_head =
245 err_y_a:=0; % no slant
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
263 whole_notehead_width# := wd#;
269 % dimensions aren't entirely right.
271 fet_beginchar ("Brevis notehead", "-1", "brevishead");
272 save stemthick, fudge;
273 define_pixels (stemthick);
274 fudge = blot_diameter /2;
275 stemthick# = 2 stafflinethickness#;
279 pickup pencircle scaled stemthick;
297 fet_beginchar("Whole notehead", "0", "wholehead")
305 fet_beginchar("Half notehead", "1",
308 % a_b:=1.49; % after text
309 a_b:=1.50; % after drawing
313 superness:=0.67; % jcn
321 inner_superness:=0.80;
326 half_notehead_width# := wd#;
334 fet_beginchar("Quart notehead", "2", "quarthead")
336 % a_b:=1.57; % after text
337 a_b:=1.54; % after drawing
346 inner_superness:=0.707;
351 black_notehead_width# := wd#;
358 fet_beginchar("Whole diamondhead", "0diamond", "wholediamondhead")
362 err_y_a:=0; % no slant
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
380 whole_notehead_width# := wd#;
387 fet_beginchar("Half diamondhead", "1diamond",
391 a_b := 1.50; % after drawing
395 superness:=0.49; % jcn
402 inner_superness:=0.80;
408 half_notehead_width# := wd#;
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;
419 save a,beta,ai,bi, ht, wd;
432 define_pixels(a,beta);
434 black := distorted_ellipse(.72 noteheight, .45 noteheight, -.2 noteheight , 0, superness)
436 % beta,a*err_y_a,0,superness);
438 black:=black rotated tilt;
439 black:=black shifted (w/2,0);
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;
452 draw (z1 .. z2) yscaled -1;
456 fet_endgroup("noteheads");
457 define_pixels(black_notehead_width);