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 (head_width#/2, head_width#/2,
168 noteheight#/2, noteheight#/2);
170 define_pixels(head_width, noteheight);
173 y1 = x2 = y3 = x4 = 0;
175 y2 = 1.4 noteheight/2;
179 xscaled 0.15 head_width
180 yscaled 0.30 head_width
183 % pencircle width correction
184 save zc, zd; pair zc, zd;
185 zc = (+0.150 head_width * sind(30), +0.150 head_width * cosd(30));
186 zd = (+0.075 head_width * sind(30), -0.075 head_width * cosd(30));
189 draw (z1+zc+zd) -- (z2-zc+zd) --
190 (z3-zc-zd) -- (z4+zc-zd) -- cycle;
192 filldraw (z1+zc+zd) -- (z2-zc+zd) --
193 (z3-zc-zd) -- (z4+zc-zd) -- cycle;
198 fet_beginchar("Mensural open head","0mensural","mensuralminimhead")
199 draw_mensural_head (staff_space#, true);
202 fet_beginchar("Mensural open head","1mensural","mensuralsemiminimhead")
203 draw_mensural_head (staff_space#, true);
206 fet_beginchar("Mensural black head","2mensural","fusahead")
207 draw_mensural_head (staff_space#, false);
214 % ledger (leger) lines
216 fet_beginchar("Ledger ending", "ledgerending", "ledgerending")
217 set_char_box (5/2 ledgerlinethickness#, 5/2 ledgerlinethickness#,
218 ledgerlinethickness#/2,ledgerlinethickness#/2);
219 pickup pencircle scaled 1.3 blot_diameter;
231 filldraw z1 --- z2 --- z3 --- z4 --- cycle ;
236 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
242 % TODO: Document these!
245 def setup_notehead_vars =
246 save a_b,err_y_a,tilt,superness;
247 save ai_a,ai_bi,err_y_ai,err_x_bi,inner_tilt,inner_superness;
251 % setup addititional vars and calc them
253 save a,beta,ai,bi, ht, wd;
260 define_pixels(a,beta);
261 define_pixels(ai,bi);
262 set_char_box(0, wd#, .5 ht#, .5 ht#);
266 % draw the outer and inner ellipse.
269 black=distorted_ellipse(a,beta,a*err_y_a,0,superness);
270 white=distorted_ellipse(ai,bi,ai*err_y_ai,bi*err_x_bi,inner_superness);
273 x1=-x3=a; x2=x4=0; y1=y3=0; y2=-y4=b;
277 black:=black rotated tilt;
278 black:=black shifted (w/2,0);
279 white:=white rotated inner_tilt;
280 white:=white shifted (w/2,0);
288 def draw_whole_head =
292 err_y_a:=0; % no slant
303 inner_tilt:=125; % jcn
304 % inner_superness:=0.69;
305 inner_superness:=0.68; % jcn
306 b_h:=1; %no rotate-> no height correction
307 a_w:=1; % no rotate-> no width correction
310 whole_notehead_width# := wd#;
316 % dimensions aren't entirely right.
318 fet_beginchar ("Brevis notehead", "-1", "brevishead");
319 save stemthick, fudge;
320 define_pixels (stemthick);
321 fudge = blot_diameter /2;
322 stemthick# = 2 stafflinethickness#;
326 pickup pencircle scaled stemthick;
344 fet_beginchar("Whole notehead", "0", "wholehead")
352 fet_beginchar("Half notehead", "1",
355 % a_b:=1.49; % after text
356 a_b:=1.50; % after drawing
360 superness:=0.67; % jcn
368 inner_superness:=0.80;
373 half_notehead_width# := wd#;
381 fet_beginchar("Quart notehead", "2", "quarthead")
383 % a_b:=1.57; % after text
384 a_b:=1.54; % after drawing
393 inner_superness:=0.707;
398 black_notehead_width# := wd#;
405 fet_beginchar("Whole diamondhead", "0diamond", "wholediamondhead")
409 err_y_a:=0; % no slant
420 inner_tilt:=125; % jcn
421 % inner_superness:=0.69;
422 inner_superness:=0.6; % jcn
423 b_h:=1; %no rotate-> no height correction
424 a_w:=1; % no rotate-> no width correction
427 whole_notehead_width# := wd#;
434 fet_beginchar("Half diamondhead", "1diamond",
438 a_b := 1.50; % after drawing
442 superness:=0.49; % jcn
449 inner_superness:=0.80;
455 half_notehead_width# := wd#;
462 fet_beginchar("Quart diamondhead", "2diamond", "diamondhead")
463 set_char_box(0, black_notehead_width#, noteheight#/2, noteheight#/2);
464 save a_b,err_y_a,tilt,superness;
466 save a,beta,ai,bi, ht, wd;
479 define_pixels(a,beta);
481 black := distorted_ellipse(.72 noteheight, .45 noteheight, -.2 noteheight , 0, superness)
483 % beta,a*err_y_a,0,superness);
485 black:=black rotated tilt;
486 black:=black shifted (w/2,0);
490 save triangle; path triangle;
491 triangle = (-sqrt3/4,-1/2) -- (0,1) -- (sqrt3/4,-1/2) -- cycle;
493 fet_beginchar("Whole trianglehead", "0triangle", "wholetrianglehead")
494 set_char_box(0, 2(noteheight#+stafflinethickness#)/sqrt3*7/8,
495 (noteheight#+stafflinethickness#)/2,(noteheight#+stafflinethickness#)/2);
496 fill triangle scaled (7h/6) shifted (w/2,-h/6);
497 unfill triangle scaled 0.72h shifted (w/2,-h/6);
499 fet_beginchar("Half trianglehead", "1triangle", "halftrianglehead")
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);
503 unfill triangle scaled 0.7h shifted (w/2,-h/6);
505 fet_beginchar("Quart trianglehead", "2triangle", "trianglehead")
506 thick := 1.2stafflinethickness;
507 set_char_box(0, 2noteheight#/sqrt3*7/8,noteheight#/2,noteheight#/2);
508 fill triangle scaled (7h/6) shifted (w/2,-h/6);
512 slope := 1.7; % slope of slash. From scm/grob-description.scm. How to auto-copy?
513 slt := 2/3*0.48staff_space; % thickness of lines. quarter notes get 1.5slt width.
514 slh := 2staff_space; % height of char.
516 %%% Calculated values:
517 sxa := 0; % how much the char exceeds the boundingbox horizontally:
518 slxt := sqrt(slt*slt+(slt/slope)*(slt/slope)); % Width of hor. pen - with thanks to Pythagoras
519 slw := slh/slope; % width of sloping part of slash:
521 % is this really nessesary? -rz
522 fac# := staff_space#/staff_space;
529 def draw_slash(expr hwid) =
530 wid# := slw#+2slxt#+hwid*fac#;
531 set_char_box(0,wid#-2sxa#,slh#/2,slh#/2);
532 define_pixels (wid#);
533 pickup penrazor scaled slxt;
534 draw (-b+slxt/2-sxa,-d) -- (-b+slxt/2+slw-sxa,h);
535 draw (w-slxt/2-slw+sxa,-d) -- (w-slxt/2+sxa,h);
536 pickup penrazor scaled slt rotated 90;
537 draw (-b+slxt-sxa,-d+slt/2) -- (w-slw+sxa,-d+slt/2);
538 draw (-b+slw-sxa,h-slt/2) -- (w-slxt+sxa,h-slt/2);
541 fet_beginchar("Whole slashhead","0slash","wholeslashhead")
542 draw_slash(staff_space);
545 fet_beginchar("Half slashhead","1slash","halfslashhead")
546 draw_slash(0.6staff_space);
549 fet_beginchar("Quart slashhead","2slash","quartslashhead")
553 % thick is the distance between the two parallel lines in the cross (distance between centres of lines)
554 def draw_cross(expr thick) =
555 pent := 1.2stafflinethickness;
556 pickup pencircle scaled pent;
557 % alfa is the slant of the lines (i.e. 1 means 45 degrees)
558 alfa := (2h-pent)/(w-pent);
559 % llen is the length of the little outer lines
560 % llen = thick / sin(2atan(alfa))
561 llen := thick/(ypart(dir(2angle(1,alfa))));
562 xa := llen/sqrt(1+alfa**2);
567 crz = (xa,0) -- (xa+xl,yl) -- (xl,yl+ya) -- (0,ya);
568 draw crz shifted(w/2,0);
569 draw crz xscaled -1 shifted(w/2,0);
570 draw crz yscaled -1 shifted(w/2,0);
571 draw crz scaled -1 shifted(w/2,0);
574 fet_beginchar("Whole Crossed notehead", "0cross", "wholecrossedhead")
575 wid# := black_notehead_width#+4stafflinethickness#;
576 hei# := noteheight#+stafflinethickness#;
577 set_char_box(0, wid#,hei#/2,hei#/2);
578 draw_cross(3.75stafflinethickness);
581 fet_beginchar("Half Crossed notehead", "1cross", "halfcrossedhead")
582 wid# := black_notehead_width#+2stafflinethickness#;
583 hei# := noteheight#+stafflinethickness#/2;
584 set_char_box(0, wid#,hei#/2,hei#/2);
585 draw_cross(3stafflinethickness);
588 fet_beginchar("Crossed notehead", "2cross", "crossedhead")
589 wid# := black_notehead_width#;
591 set_char_box(0, wid#,hei#/2,hei#/2);
592 draw_cross(stafflinethickness/4);
595 fet_beginchar("X-Circled notehead", "2xcircle", "xcircledhead")
596 wid# := black_notehead_width#;
597 hei# := noteheight#+stafflinethickness#;
598 set_char_box(0, wid#,hei#/2,hei#/2);
599 cthick := 1.2stafflinethickness;
602 pickup pencircle scaled cthick;
603 draw fullcircle xscaled 2cxr yscaled 2cyr shifted (w/2,0);
606 draw (-xpos+w/2,-ypos) -- (xpos+w/2,ypos);
607 draw (-xpos+w/2,ypos) -- (xpos+w/2,-ypos);
620 fet_beginchar("Ed. Vat. subbipunctum", "0vaticana_subbipunctum",
621 "vatsubbipunctumhead")
623 a_b := 1.54; % b_h*a_b/a_w = wd/ht
627 save a, beta, ht, wd;
632 set_char_box(0.3wd#, 0.3wd#, 0.5 ht#, 0.5 ht#);
633 black_notehead_width# := wd#;
635 save za, alpha, size;
637 define_pixels(ht, wd);
642 yscaled size rotated -alpha;
643 za = (0, size) / 2 rotated alpha;
649 % parametrized punctum
650 def punctum_char (expr verbose_name, internal_name, mudela_name,
651 left_stem, right_stem,
652 straight, reverse_convexity, excentric, up_shift, mag) =
654 fet_beginchar(verbose_name, internal_name, mudela_name)
656 a_b := 1.54; % b_h*a_b/a_w = wd/ht
660 save a, beta, ht, wd;
661 ht# = noteheight# * mag;
665 set_char_box(0.25wd#, 0.25wd#, 0.5ht#, 0.5ht#);
666 black_notehead_width# := wd#;
670 if reverse_convexity:
671 convexity# = -0.02ht#;
673 convexity# = +0.02ht#;
676 if reverse_convexity:
677 convexity# = -0.05ht#;
679 convexity# = +0.05ht#;
690 define_pixels(ht, wd, convexity, yoffs);
691 pickup pencircle scaled stafflinethickness;
694 z1 = (0.00wd, yoffs - 1.0convexity);
695 z2 = (0.08wd, yoffs + 1.4convexity);
696 z3 = (0.40wd, yoffs);
700 if reverse_convexity:
701 penstroke z1e{up} .. z2e{right} .. z3e;
703 penstroke z1e{down} .. z2e{right} ..z3e;
706 z1 = (0.00wd, yoffs);
707 z2 = (0.20wd, yoffs + convexity);
708 z3 = (0.40wd, yoffs);
712 penstroke z1e .. z2e .. z3e;
716 z5=(0.00wd + 0.5 stafflinethickness, yoffs);
717 z6=(0.00wd + 0.5 stafflinethickness, yoffs - 1.5ht);
720 z5=(0.40wd - 0.25 stafflinethickness, yoffs);
721 z6=(0.40wd - 0.25 stafflinethickness, yoffs - 1.5ht);
730 punctum_char("Ed. Vat. punctum", "0vaticana_punctum", "vatpunctumhead",
731 false, false, false, false, false, false, 1.0);
733 % virga (i.e. right stemmed punctum)
734 punctum_char("Ed. Vat. virga", "0vaticana_virga", "vatvirgahead",
735 false, true, false, false, false, false, 1.0);
737 % left stemmed punctum as used in clivis (flexa) ligature
738 punctum_char("Ed. Vat. reverse virga", "0vaticana_rvirga", "vatrvirgahead",
739 true, false, false, false, false, false, 1.0);
742 punctum_char("Ed. Vat. pes lower punctum", "0vaticana_lpes", "vatlpeshead",
743 false, false, true, true, false, false, 1.0);
746 punctum_char("Ed. Vat. pes upper punctum", "0vaticana_upes", "vatupeshead",
747 false, false, true, false, false, false, 1.0);
749 % pes upper punctum (shifted variation)
751 % Note: This note head is used instead of the regular pes upper
752 % punctum to avoid collision with the lower punctum note of the pes when
753 % the upper punctum sits directly on top of the lower punctum.
754 punctum_char("Ed. Vat. var pes upper punctum", "0vaticana_vupes",
756 false, false, true, false, false, true, 1.0);
758 % small punctum as used in epiphonus/cephalicus
759 punctum_char("Ed. Vat. plica", "0vaticana_plica", "vatplicahead",
760 false, false, true, false, false, false, 0.5);
762 % excentric punctum as used in epiphonus
763 punctum_char("Ed. Vat. epiphonus", "0vaticana_epiphonus", "vatepiphonushead",
764 false, false, false, true, true, false, 1.0);
766 % excentric punctum as used in cephalicus
767 punctum_char("Ed. Vat. cephalicus", "0vaticana_cephalicus",
769 false, false, false, false, true, false, 1.0);
772 fet_beginchar("Ed. Vat. quilisma", "0vaticana_quilisma", "vatquilismahead")
774 a_b:=1.54; % b_h*a_b/a_w = wd/ht
778 save a, beta, ht, wd;
783 set_char_box(0.1wd#, 0.4wd#, 0.5 ht#, 0.5 ht#);
784 black_notehead_width# := wd#;
786 define_pixels(ht, wd);
787 pickup pencircle xscaled stafflinethickness yscaled 0.4ht;
794 draw z1 -- z2 -- z3 -- z4 -- z5 -- z6;
808 fet_beginchar("Ed. Med. subbipunctum", "0medicaea_subbipunctum",
809 "medsubbipunctumhead")
811 a_b := 1.54; % b_h*a_b/a_w = wd/ht
815 save a, beta, ht, wd;
820 set_char_box(wd#/2, wd#/2, 0.5 ht#, 0.5 ht#);
821 black_notehead_width# := wd#;
823 save za, alpha, size;
825 define_pixels(ht, wd);
830 yscaled size rotated -alpha;
831 za = (0, size) / 2 rotated alpha;
836 % parametrized punctum
837 def punctum_char (expr verbose_name, internal_name, mudela_name,
838 left_up_stem, left_down_stem) =
840 fet_beginchar(verbose_name, internal_name, mudela_name)
842 save a, beta, ht, wd;
843 ht# = 2 staff_space#;
845 set_char_box(0.0, 0.4wd#, 0.5ht#, 0.5ht#);
846 black_notehead_width# := wd#;
848 define_pixels(ht, wd);
849 pickup pencircle scaled stafflinethickness;
857 penstroke z1e .. z2e .. z3e;
860 z5=(0.00wd + 0.5 stafflinethickness, 0);
861 z6=(0.00wd + 0.5 stafflinethickness, - 1.25ht);
864 z5=(0.00wd + 0.5 stafflinethickness, 0);
865 z6=(0.00wd + 0.5 stafflinethickness, + 1.25ht);
873 punctum_char("Ed. Med. punctum", "0medicaea_punctum", "medpunctumhead",
876 % left up-stemmed punctum
877 punctum_char("Ed. Med. reverse virga", "0medicaea_rvirga", "medrvirgahead",
880 % virga (i.e. left down-stemmed punctum)
881 punctum_char("Ed. Med. virga", "0medicaea_virga", "medvirgahead",
894 % parametrized punctum
895 def punctum_char (expr verbose_name, internal_name, mudela_name,
898 fet_beginchar(verbose_name, internal_name, mudela_name)
900 a_b := 1.54; % b_h*a_b/a_w = wd/ht
904 save a, beta, ht, wd;
909 set_char_box(wd#/2, wd#/2, 0.5 ht#, 0.5 ht#);
910 black_notehead_width# := wd#;
912 save za, zb, zc, alpha, size;
914 define_pixels(ht, wd);
919 yscaled size rotated -alpha;
920 za = (0, size) / 2 rotated alpha;
925 zc = (0.00wd, - 1.25ht);
932 punctum_char("Hufnagel punctum", "0hufnagel_punctum", "hufpunctumhead", false)
935 punctum_char("Hufnagel virga", "0hufnagel_virga", "hufvirgahead", true)
938 fet_beginchar("Hufnagel pes lower punctum", "0hufnagel_lpes", "huflpeshead")
940 a_b := 1.54; % b_h*a_b/a_w = wd/ht
944 save a, beta, ht, wd;
949 set_char_box(wd#, wd#, 0.7 ht#, 0.7 ht#);
950 black_notehead_width# := wd#;
952 save za, alpha, size;
954 define_pixels(ht, wd);
959 yscaled size rotated -alpha;
964 fet_endgroup("noteheads");
965 define_pixels(black_notehead_width);