2 % feta-bolletjes.mf -- implement noteheads
4 % source file of LilyPond's pretty-but-neat music font
6 % (c) 1997--2001 Jan Nieuwenhuizen <janneke@gnu.org>
7 % & Han-Wen Nienhuys <hanwen@cs.uu.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_neo_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_neo_mensural_open_head (expr wid)=
132 draw_neo_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("Neo-mensural open head","0neo_mensural","neomensuralminimhead")
152 draw_neo_mensural_open_head (staff_space#);
155 fet_beginchar("Neo-mensural open head","1neo_mensural","neomensuralsemiminimhead")
156 draw_neo_mensural_open_head (staff_space#);
159 fet_beginchar("Neo-mensural black head","2neo_mensural","neofusahead")
160 draw_neo_mensural_black_head (staff_space#);
164 def draw_mensural_head (expr wid, open) =
167 set_char_box (0, head_width#,
168 noteheight#/2, noteheight#/2);
170 define_pixels(head_width, noteheight);
173 y2 = 1.1 noteheight/2;
175 (x2 - x1) / (y2 - y1) = tand(30);
180 xscaled 0.18 head_width
181 yscaled 0.36 head_width
185 draw z1 -- z2 -- z3 -- z4 -- cycle;
187 filldraw z1 -- z2 -- z3 -- z4 -- cycle;
192 fet_beginchar("Mensural open head","0mensural","mensuralminimhead")
193 draw_mensural_head (staff_space#, true);
196 fet_beginchar("Mensural open head","1mensural","mensuralsemiminimhead")
197 draw_mensural_head (staff_space#, true);
200 fet_beginchar("Mensural black head","2mensural","fusahead")
201 draw_mensural_head (staff_space#, false);
208 % ledger (leger) lines
210 fet_beginchar("Ledger ending", "ledgerending", "ledgerending")
211 set_char_box (5/2 ledgerlinethickness#, 5/2 ledgerlinethickness#,
212 ledgerlinethickness#/2,ledgerlinethickness#/2);
213 pickup pencircle scaled 1.3 blot_diameter;
225 filldraw z1 --- z2 --- z3 --- z4 --- cycle ;
230 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
236 % TODO: Document these!
239 def setup_notehead_vars =
240 save a_b,err_y_a,tilt,superness;
241 save ai_a,ai_bi,err_y_ai,err_x_bi,inner_tilt,inner_superness;
245 % setup addititional vars and calc them
247 save a,beta,ai,bi, ht, wd;
254 define_pixels(a,beta);
255 define_pixels(ai,bi);
256 set_char_box(0, wd#, .5 ht#, .5 ht#);
260 % draw the outer and inner ellipse.
263 black=distorted_ellipse(a,beta,a*err_y_a,0,superness);
264 white=distorted_ellipse(ai,bi,ai*err_y_ai,bi*err_x_bi,inner_superness);
267 x1=-x3=a; x2=x4=0; y1=y3=0; y2=-y4=b;
271 black:=black rotated tilt;
272 black:=black shifted (w/2,0);
273 white:=white rotated inner_tilt;
274 white:=white shifted (w/2,0);
282 def draw_whole_head =
286 err_y_a:=0; % no slant
297 inner_tilt:=125; % jcn
298 % inner_superness:=0.69;
299 inner_superness:=0.68; % jcn
300 b_h:=1; %no rotate-> no height correction
301 a_w:=1; % no rotate-> no width correction
304 whole_notehead_width# := wd#;
310 % dimensions aren't entirely right.
312 fet_beginchar ("Brevis notehead", "-1", "brevishead");
313 save stemthick, fudge;
314 define_pixels (stemthick);
315 fudge = blot_diameter /2;
316 stemthick# = 2 stafflinethickness#;
320 pickup pencircle scaled stemthick;
338 fet_beginchar("Whole notehead", "0", "wholehead")
346 fet_beginchar("Half notehead", "1",
349 % a_b:=1.49; % after text
350 a_b:=1.50; % after drawing
354 superness:=0.67; % jcn
362 inner_superness:=0.80;
367 half_notehead_width# := wd#;
375 fet_beginchar("Quart notehead", "2", "quarthead")
377 % a_b:=1.57; % after text
378 a_b:=1.54; % after drawing
387 inner_superness:=0.707;
392 black_notehead_width# := wd#;
399 fet_beginchar("Whole diamondhead", "0diamond", "wholediamondhead")
403 err_y_a:=0; % no slant
414 inner_tilt:=125; % jcn
415 % inner_superness:=0.69;
416 inner_superness:=0.6; % jcn
417 b_h:=1; %no rotate-> no height correction
418 a_w:=1; % no rotate-> no width correction
421 whole_notehead_width# := wd#;
428 fet_beginchar("Half diamondhead", "1diamond",
432 a_b := 1.50; % after drawing
436 superness:=0.49; % jcn
443 inner_superness:=0.80;
449 half_notehead_width# := wd#;
456 fet_beginchar("Quart diamondhead", "2diamond", "diamondhead")
457 set_char_box(0, black_notehead_width#, noteheight#/2, noteheight#/2);
458 save a_b,err_y_a,tilt,superness;
460 save a,beta,ai,bi, ht, wd;
473 define_pixels(a,beta);
475 black := distorted_ellipse(.72 noteheight, .45 noteheight, -.2 noteheight , 0, superness)
477 % beta,a*err_y_a,0,superness);
479 black:=black rotated tilt;
480 black:=black shifted (w/2,0);
484 save triangle; path triangle;
485 triangle = (-sqrt3/4,-1/2) -- (0,1) -- (sqrt3/4,-1/2) -- cycle;
487 fet_beginchar("Whole trianglehead", "0triangle", "wholetrianglehead")
488 set_char_box(0, 2(noteheight#+stafflinethickness#)/sqrt3*7/8,
489 (noteheight#+stafflinethickness#)/2,(noteheight#+stafflinethickness#)/2);
490 fill triangle scaled (7h/6) shifted (w/2,-h/6);
491 unfill triangle scaled 0.72h shifted (w/2,-h/6);
493 fet_beginchar("Half trianglehead", "1triangle", "halftrianglehead")
494 thick := 1.2stafflinethickness;
495 set_char_box(0, 2noteheight#/sqrt3*7/8,noteheight#/2,noteheight#/2);
496 fill triangle scaled (7h/6) shifted (w/2,-h/6);
497 unfill triangle scaled 0.7h shifted (w/2,-h/6);
499 fet_beginchar("Quart trianglehead", "2triangle", "trianglehead")
500 thick := 1.2stafflinethickness;
501 set_char_box(0, 2noteheight#/sqrt3*7/8,noteheight#/2,noteheight#/2);
502 fill triangle scaled (7h/6) shifted (w/2,-h/6);
506 slope := 1.7; % slope of slash. From scm/grob-description.scm. How to auto-copy?
507 slt := 2/3*0.48staff_space; % thickness of lines. quarter notes get 1.5slt width.
508 slh := 2staff_space; % height of char.
510 %%% Calculated values:
511 sxa := 0; % how much the char exceeds the boundingbox horizontally:
512 slxt := sqrt(slt*slt+(slt/slope)*(slt/slope)); % Width of hor. pen - with thanks to Pythagoras
513 slw := slh/slope; % width of sloping part of slash:
515 % is this really nessesary? -rz
516 fac# := staff_space#/staff_space;
523 def draw_slash(expr hwid) =
524 wid# := slw#+2slxt#+hwid*fac#;
525 set_char_box(0,wid#-2sxa#,slh#/2,slh#/2);
526 define_pixels (wid#);
527 pickup penrazor scaled slxt;
528 draw (-b+slxt/2-sxa,-d) -- (-b+slxt/2+slw-sxa,h);
529 draw (w-slxt/2-slw+sxa,-d) -- (w-slxt/2+sxa,h);
530 pickup penrazor scaled slt rotated 90;
531 draw (-b+slxt-sxa,-d+slt/2) -- (w-slw+sxa,-d+slt/2);
532 draw (-b+slw-sxa,h-slt/2) -- (w-slxt+sxa,h-slt/2);
535 fet_beginchar("Whole slashhead","0slash","wholeslashhead")
536 draw_slash(staff_space);
539 fet_beginchar("Half slashhead","1slash","halfslashhead")
540 draw_slash(0.6staff_space);
543 fet_beginchar("Quart slashhead","2slash","quartslashhead")
547 % thick is the distance between the two parallel lines in the cross (distance between centres of lines)
548 def draw_cross(expr thick) =
549 pent := 1.2stafflinethickness;
550 pickup pencircle scaled pent;
551 % alfa is the slant of the lines (i.e. 1 means 45 degrees)
552 alfa := (2h-pent)/(w-pent);
553 % llen is the length of the little outer lines
554 % llen = thick / sin(2atan(alfa))
555 llen := thick/(ypart(dir(2angle(1,alfa))));
556 xa := llen/sqrt(1+alfa**2);
561 crz = (xa,0) -- (xa+xl,yl) -- (xl,yl+ya) -- (0,ya);
562 draw crz shifted(w/2,0);
563 draw crz xscaled -1 shifted(w/2,0);
564 draw crz yscaled -1 shifted(w/2,0);
565 draw crz scaled -1 shifted(w/2,0);
568 fet_beginchar("Whole Crossed notehead", "0cross", "wholecrossedhead")
569 wid# := black_notehead_width#+4stafflinethickness#;
570 hei# := noteheight#+stafflinethickness#;
571 set_char_box(0, wid#,hei#/2,hei#/2);
572 draw_cross(3.75stafflinethickness);
575 fet_beginchar("Half Crossed notehead", "1cross", "halfcrossedhead")
576 wid# := black_notehead_width#+2stafflinethickness#;
577 hei# := noteheight#+stafflinethickness#/2;
578 set_char_box(0, wid#,hei#/2,hei#/2);
579 draw_cross(3stafflinethickness);
582 fet_beginchar("Crossed notehead", "2cross", "crossedhead")
583 wid# := black_notehead_width#;
585 set_char_box(0, wid#,hei#/2,hei#/2);
586 draw_cross(stafflinethickness/4);
589 fet_beginchar("X-Circled notehead", "2xcircle", "xcircledhead")
590 wid# := black_notehead_width#;
591 hei# := noteheight#+stafflinethickness#;
592 set_char_box(0, wid#,hei#/2,hei#/2);
593 cthick := 1.2stafflinethickness;
596 pickup pencircle scaled cthick;
597 draw fullcircle xscaled 2cxr yscaled 2cyr shifted (w/2,0);
600 draw (-xpos+w/2,-ypos) -- (xpos+w/2,ypos);
601 draw (-xpos+w/2,ypos) -- (xpos+w/2,-ypos);
614 fet_beginchar("Ed. Vat. subbipunctum", "0vaticana_subbipunctum",
615 "vatsubbipunctumhead")
617 a_b := 1.54; % b_h*a_b/a_w = wd/ht
621 save a, beta, ht, wd;
626 set_char_box(0.3wd#, 0.3wd#, 0.5 ht#, 0.5 ht#);
627 black_notehead_width# := wd#;
629 save za, alpha, size;
631 define_pixels(ht, wd);
636 yscaled size rotated -alpha;
637 za = (0, size) / 2 rotated alpha;
643 % parametrized punctum
644 def punctum_char (expr verbose_name, internal_name, mudela_name,
645 left_stem, right_stem,
646 straight, reverse_convexity, excentric, up_shift, mag) =
648 fet_beginchar(verbose_name, internal_name, mudela_name)
650 a_b := 1.54; % b_h*a_b/a_w = wd/ht
654 save a, beta, ht, wd;
655 ht# = noteheight# * mag;
659 set_char_box(0.25wd#, 0.25wd#, 0.5ht#, 0.5ht#);
660 black_notehead_width# := wd#;
664 if reverse_convexity:
665 convexity# = -0.02ht#;
667 convexity# = +0.02ht#;
670 if reverse_convexity:
671 convexity# = -0.05ht#;
673 convexity# = +0.05ht#;
684 define_pixels(ht, wd, convexity, yoffs);
685 pickup pencircle scaled stafflinethickness;
688 z1 = (0.00wd, yoffs - 1.0convexity);
689 z2 = (0.08wd, yoffs + 1.4convexity);
690 z3 = (0.40wd, yoffs);
694 if reverse_convexity:
695 penstroke z1e{up} .. z2e{right} .. z3e;
697 penstroke z1e{down} .. z2e{right} ..z3e;
700 z1 = (0.00wd, yoffs);
701 z2 = (0.20wd, yoffs + convexity);
702 z3 = (0.40wd, yoffs);
706 penstroke z1e .. z2e .. z3e;
710 z5=(0.00wd + 0.5 stafflinethickness, yoffs);
711 z6=(0.00wd + 0.5 stafflinethickness, yoffs - 1.5ht);
714 z5=(0.40wd - 0.25 stafflinethickness, yoffs);
715 z6=(0.40wd - 0.25 stafflinethickness, yoffs - 1.5ht);
724 punctum_char("Ed. Vat. punctum", "0vaticana_punctum", "vatpunctumhead",
725 false, false, false, false, false, false, 1.0);
727 % virga (i.e. right stemmed punctum)
728 punctum_char("Ed. Vat. virga", "0vaticana_virga", "vatvirgahead",
729 false, true, false, false, false, false, 1.0);
731 % left stemmed punctum as used in clivis (flexa) ligature
732 punctum_char("Ed. Vat. reverse virga", "0vaticana_rvirga", "vatrvirgahead",
733 true, false, false, false, false, false, 1.0);
736 punctum_char("Ed. Vat. pes lower punctum", "0vaticana_lpes", "vatlpeshead",
737 false, false, true, true, false, false, 1.0);
740 punctum_char("Ed. Vat. pes upper punctum", "0vaticana_upes", "vatupeshead",
741 false, false, true, false, false, false, 1.0);
743 % pes upper punctum (shifted variation)
745 % Note: This note head is used instead of the regular pes upper
746 % punctum to avoid collision with the lower punctum note of the pes when
747 % the upper punctum sits directly on top of the lower punctum.
748 punctum_char("Ed. Vat. var pes upper punctum", "0vaticana_vupes",
750 false, false, true, false, false, true, 1.0);
752 % small punctum as used in epiphonus/cephalicus
753 punctum_char("Ed. Vat. plica", "0vaticana_plica", "vatplicahead",
754 false, false, true, false, false, false, 0.5);
756 % excentric punctum as used in epiphonus
757 punctum_char("Ed. Vat. epiphonus", "0vaticana_epiphonus", "vatepiphonushead",
758 false, false, false, true, true, false, 1.0);
760 % excentric punctum as used in cephalicus
761 punctum_char("Ed. Vat. cephalicus", "0vaticana_cephalicus",
763 false, false, false, false, true, false, 1.0);
766 fet_beginchar("Ed. Vat. quilisma", "0vaticana_quilisma", "vatquilismahead")
768 a_b:=1.54; % b_h*a_b/a_w = wd/ht
772 save a, beta, ht, wd;
777 set_char_box(0.1wd#, 0.4wd#, 0.5 ht#, 0.5 ht#);
778 black_notehead_width# := wd#;
780 define_pixels(ht, wd);
781 pickup pencircle xscaled stafflinethickness yscaled 0.4ht;
788 draw z1 -- z2 -- z3 -- z4 -- z5 -- z6;
802 fet_beginchar("Ed. Med. subbipunctum", "0medicaea_subbipunctum",
803 "medsubbipunctumhead")
805 a_b := 1.54; % b_h*a_b/a_w = wd/ht
809 save a, beta, ht, wd;
814 set_char_box(wd#/2, wd#/2, 0.5 ht#, 0.5 ht#);
815 black_notehead_width# := wd#;
817 save za, alpha, size;
819 define_pixels(ht, wd);
824 yscaled size rotated -alpha;
825 za = (0, size) / 2 rotated alpha;
830 % parametrized punctum
831 def punctum_char (expr verbose_name, internal_name, mudela_name,
832 left_up_stem, left_down_stem) =
834 fet_beginchar(verbose_name, internal_name, mudela_name)
836 save a, beta, ht, wd;
837 ht# = 2 staff_space#;
839 set_char_box(0.0, 0.4wd#, 0.5ht#, 0.5ht#);
840 black_notehead_width# := wd#;
842 define_pixels(ht, wd);
843 pickup pencircle scaled stafflinethickness;
851 penstroke z1e .. z2e .. z3e;
854 z5=(0.00wd + 0.5 stafflinethickness, 0);
855 z6=(0.00wd + 0.5 stafflinethickness, - 1.25ht);
858 z5=(0.00wd + 0.5 stafflinethickness, 0);
859 z6=(0.00wd + 0.5 stafflinethickness, + 1.25ht);
867 punctum_char("Ed. Med. punctum", "0medicaea_punctum", "medpunctumhead",
870 % left up-stemmed punctum
871 punctum_char("Ed. Med. reverse virga", "0medicaea_rvirga", "medrvirgahead",
874 % virga (i.e. left down-stemmed punctum)
875 punctum_char("Ed. Med. virga", "0medicaea_virga", "medvirgahead",
888 % parametrized punctum
889 def punctum_char (expr verbose_name, internal_name, mudela_name,
892 fet_beginchar(verbose_name, internal_name, mudela_name)
894 a_b := 1.54; % b_h*a_b/a_w = wd/ht
898 save a, beta, ht, wd;
903 set_char_box(wd#/2, wd#/2, 0.5 ht#, 0.5 ht#);
904 black_notehead_width# := wd#;
906 save za, zb, zc, alpha, size;
908 define_pixels(ht, wd);
913 yscaled size rotated -alpha;
914 za = (0, size) / 2 rotated alpha;
919 zc = (0.00wd, - 1.25ht);
926 punctum_char("Hufnagel punctum", "0hufnagel_punctum", "hufpunctumhead", false)
929 punctum_char("Hufnagel virga", "0hufnagel_virga", "hufvirgahead", true)
932 fet_beginchar("Hufnagel pes lower punctum", "0hufnagel_lpes", "huflpeshead")
934 a_b := 1.54; % b_h*a_b/a_w = wd/ht
938 save a, beta, ht, wd;
943 set_char_box(wd#, wd#, 0.7 ht#, 0.7 ht#);
944 black_notehead_width# := wd#;
946 save za, alpha, size;
948 define_pixels(ht, wd);
953 yscaled size rotated -alpha;
958 fet_endgroup("noteheads");
959 define_pixels(black_notehead_width);