2 % feta-bolletjes.mf -- implement noteheads
4 % source file of LilyPond's pretty-but-neat music font
6 % (c) 1997--2006 Jan Nieuwenhuizen <janneke@gnu.org>
7 % & Han-Wen Nienhuys <hanwen@xs4all.nl>
8 % & Juergen Reuter <reuter@ipd.uka.de>
18 % Most beautiful noteheads are pronounced, not circular,
19 % and not even symmetric.
20 % These examples are inspired by [Wanske]; see literature list.
24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
28 save black_notehead_width, noteheight;
29 save half_notehead_width, whole_notehead_width, slash_thick;
30 save slash_slope, overdone_heads, solfa_noteheight;
34 numeric black_notehead_width;
35 numeric whole_notehead_width;
36 numeric half_notehead_width;
39 fet_begingroup ("noteheads");
42 % Slope of slash. From scm/grob-description.scm. How to auto-copy?
45 % Thickness of slash lines. Quarter notes get 1.5slt width.
46 slash_thick# := 2/3 * 0.48 staff_space#;
50 % Hand-engraved music often has balls extending above and below
51 % the lines. If you like that, modify overdone heads (unit:
52 % stafflinethickness).
55 noteheight# := staff_space# + (1 + overdone_heads) * stafflinethickness#;
59 % solfa heads should not overlap on chords.
61 solfa_noteheight# := staff_space# - stafflinethickness#;
63 define_pixels (slash_thick);
64 define_whole_vertical_pixels (noteheight);
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69 % SLANT moves both extrema on the long axis (by SLANT * ELLIPTICITY,
70 % so SLANT = -1, puts the extreme on the long axis next to the short
74 def draw_outside_ellipse (expr ellipticity, tilt, superness, slant) =
79 pat := superellipse ((ellipticity, 0), (-slant * ellipticity, 1.0),
80 (-ellipticity, 0), (slant * ellipticity, -1.0),
82 pat := pat rotated tilt;
84 save top_point, right_point;
85 pair top_point, right_point;
87 top_point := directionpoint left of pat;
88 right_point := directionpoint up of pat;
92 scaling# = noteheight# / (2 ypart (top_point));
93 width# := 2 xpart (right_point) * scaling#;
94 define_pixels (scaling, width);
96 set_char_box (0, width#, noteheight# / 2, noteheight# / 2);
98 d := d - feta_space_shift;
101 charwy := ypart (right_point) * scaling#;
104 pat := pat scaled scaling shifted (w / 2, .5 (h - d));
106 width := hround width;
108 if test_outlines = 1:
116 def undraw_inside_ellipse (expr ellipticity, tilt, superness, clearance) =
121 pat := superellipse ((ellipticity, 0), (0, 1.0),
122 (-ellipticity, 0), (0, -1.0),
124 pat := pat rotated tilt;
126 save top_point, right_point;
127 pair top_point, right_point;
129 top_point := directionpoint left of pat;
130 right_point := directionpoint up of pat;
132 save height, scaling;
134 height# = staff_space# + stafflinethickness# - clearance;
135 scaling# = height# / (2 ypart (top_point));
136 define_pixels (scaling);
137 pat := pat scaled scaling shifted (w / 2, .5 (h - d));
139 if test_outlines = 1:
149 % dimensions aren't entirely right.
151 def draw_longa (expr up) =
152 save stemthick, fudge;
154 stemthick# = 2 stafflinethickness#;
155 define_whole_blacker_pixels (stemthick);
157 fudge = hround (blot_diameter / 2);
159 draw_outside_ellipse (1.80, 0, 0.707, 0);
160 undraw_inside_ellipse (1.30, 125, 0.68, 2 stafflinethickness#);
162 pickup pencircle scaled stemthick;
172 top y4 = h + 3.0 staff_space;
175 bot y1 = -d - 3.0 staff_space;
186 draw_gridline (z1, z2, stemthick);
187 draw_gridline (z3, z4, stemthick);
191 fet_beginchar ("Longa notehead", "u-2");
194 draw_staff (-2, 2, 0);
197 fet_beginchar ("Longa notehead", "d-2");
200 draw_staff (-2, 2, 0);
205 fet_beginchar ("Longa notehead", "u-2");
208 draw_staff (-2, 2, 0.5);
211 fet_beginchar ("Longa notehead", "d-2");
214 draw_staff (-2, 2, 0.5);
220 % dimensions aren't entirely right.
223 save stemthick, fudge;
225 stemthick# = 2 stafflinethickness#;
226 define_whole_blacker_pixels (stemthick);
228 fudge = hround (blot_diameter / 2);
230 draw_outside_ellipse (1.80, 0, 0.707, 0);
231 undraw_inside_ellipse (1.30, 125, 0.68, 2 stafflinethickness#);
233 pickup pencircle scaled stemthick;
245 draw_gridline (z1, z2, stemthick);
246 draw_gridline (z3, z4, stemthick);
250 fet_beginchar ("Brevis notehead", "s-1");
253 draw_staff (-2, 2, 0);
258 fet_beginchar ("Brevis notehead", "s-1");
261 draw_staff (-2, 2, 0.5);
266 fet_beginchar ("Whole notehead", "s0");
267 draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0, 0.707, 0);
268 undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10,
269 0.68, 2 stafflinethickness#);
271 whole_notehead_width# := charwd;
273 draw_staff (-2, 2, 0);
278 fet_beginchar ("Whole notehead", "s0");
279 draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0,
281 undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10,
282 0.68, 2 stafflinethickness#);
284 draw_staff (-2, 2, 0.5);
291 fet_beginchar ("Half notehead", "s1");
292 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34, 0.66, 0.17);
293 undraw_inside_ellipse (3.25, 33, 0.81, 2.5 stafflinethickness#);
295 half_notehead_width# := charwd;
297 draw_staff (-2, 2, 0);
302 fet_beginchar ("Half notehead", "s1");
303 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34,
305 undraw_inside_ellipse (3.25, 33, 0.81,
306 2.5 stafflinethickness#);
308 draw_staff (-2, 2, 0.5);
313 fet_beginchar ("Quart notehead", "s2");
314 % used to have 32. With 31, they are slightly bolder.
315 draw_outside_ellipse (1.49 - puff_up_factor / 3.0, 31, 0.707, 0);
316 black_notehead_width# := charwd;
318 draw_staff (-2, 2, 0);
322 fet_beginchar ("Quart notehead", "s2");
323 draw_outside_ellipse (1.49 - puff_up_factor / 3.0, 31,
326 draw_staff (-2, 2, 0.5);
331 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
334 fet_beginchar ("Whole diamondhead", "s0diamond");
335 draw_outside_ellipse (1.80, 0, 0.495, 0);
336 undraw_inside_ellipse (1.30, 125, 0.6,
337 .4 staff_space# + stafflinethickness#);
339 draw_staff (-2, 2, 0);
344 fet_beginchar ("Whole diamondhead", "s0diamond");
345 draw_outside_ellipse (1.80, 0, 0.495, 0);
346 undraw_inside_ellipse (1.30, 125, 0.6,
347 .4 staff_space# + stafflinethickness#);
349 draw_staff (-2, 2, 0.5);
354 fet_beginchar ("Half diamondhead", "s1diamond");
355 draw_outside_ellipse (1.50, 34, 0.49, 0.17);
356 undraw_inside_ellipse (3.5, 33, 0.80,
357 .3 staff_space# + 1.5 stafflinethickness#);
359 draw_staff (-2, 2, 0);
364 fet_beginchar ("Half diamondhead", "s1diamond");
365 draw_outside_ellipse (1.50, 34, 0.49, 0.17);
366 undraw_inside_ellipse (3.5, 33, 0.80,
368 + 1.5 stafflinethickness#);
370 draw_staff (-2, 2, 0.5);
375 fet_beginchar ("Quart diamondhead", "s2diamond");
376 draw_outside_ellipse (1.80, 35, 0.495, -0.25);
378 draw_staff (-2, 2, 0);
383 fet_beginchar ("Quart diamondhead", "s2diamond");
384 draw_outside_ellipse (1.80, 35, 0.495, -0.25);
386 draw_staff (-2, 2, 0.5);
391 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
394 vardef penposx@# (expr d) =
404 z@#l = pat intersectionpoint (z@# -- infinity * dir (d + 180));
405 z@#r = pat intersectionpoint (z@# -- infinity * dir (d));
412 % UGH : xs not declared as argument.
414 def define_triangle_shape (expr stemdir) =
415 save triangle_a, triangle_b, triangle_c;
416 save triangle_out_a, triangle_out_b, triangle_out_c;
417 save triangle_in, triangle_out;
418 save width, depth, height;
419 save origin, left_up_dir;
420 save exact_left_point, exact_right_point, exact_down_point;
422 path triangle_a, triangle_b, triangle_c;
423 path triangle_out_a, triangle_out_b, triangle_out_c;
424 path triangle_in, triangle_out;
425 pair origin, left_up_dir;
426 pair exact_down_point, exact_left_point, exact_right_point;
429 pen_thick# = stafflinethickness# + .1 staff_space#;
430 define_pixels (llap);
431 define_blacker_pixels (pen_thick);
433 left_up_dir = llap# * dir (90 + tilt);
435 xpart (left_up_dir) * xs - (pen_thick# * xs) / 2 + xpart origin = 0;
438 exact_left_point := origin + (left_up_dir xscaled xs);
439 exact_down_point := origin + (left_up_dir rotated 120 xscaled xs);
440 exact_right_point := origin + (left_up_dir rotated 240 xscaled xs);
442 height# = ypart (exact_left_point + origin) + pen_thick# / 2;
443 depth# = -ypart (exact_down_point + origin) + pen_thick# / 2;
444 width# = xpart (exact_right_point - exact_left_point)
447 set_char_box (0, width#, depth#, height#);
449 % Formerly, the shape has simply been drawn with an elliptical pen
450 % (`scaled pen_thick xsaled xs'), but the envelope of such a curve
451 % is of 6th degree. For the sake of mf2pt1, we approximate it.
453 pickup pencircle scaled pen_thick xscaled xs;
455 z0 = (hround_pixels (xpart origin), 0);
457 z1 = z1' = z0 + llap * dir (90 + tilt) xscaled xs;
458 z2 = z2' = z0 + llap * dir (90 + tilt + 120) xscaled xs;
459 z3 = z3' = z0 + llap * dir (90 + tilt + 240) xscaled xs;
461 z12 = caveness [.5[z1, z2], z3];
462 z23 = caveness [.5[z2, z3], z1];
463 z31 = caveness [.5[z3, z1], z2];
465 triangle_a = z1 .. z12 .. z2;
466 triangle_b = z2 .. z23 .. z3;
467 triangle_c = z3 .. z31 .. z1;
469 penposx1 (angle (direction 0 of triangle_a) - 90);
470 penposx2 (angle (direction 0 of triangle_b) - 90);
471 penposx3 (angle (direction 0 of triangle_c) - 90);
473 penposx1' (angle (direction infinity of triangle_c) + 90);
474 penposx2' (angle (direction infinity of triangle_a) + 90);
475 penposx3' (angle (direction infinity of triangle_b) + 90);
477 penposx12 (angle (z12 - z0));
478 penposx23 (angle (z23 - z0));
479 penposx31 (angle (z31 - z0));
481 z10 = (z0 -- z1) intersectionpoint (z1l .. z12l .. z2'r);
482 z20 = (z0 -- z2) intersectionpoint (z2l .. z23l .. z3'r);
483 z30 = (z0 -- z3) intersectionpoint (z3l .. z31l .. z1'r);
496 triangle_out_a = z1r .. z12r .. z2'l;
497 triangle_out_b = z2r .. z23r .. z3'l;
498 triangle_out_c = z3r .. z31r .. z1'l;
500 triangle_out = top z1
502 .. z1r{direction 0 of triangle_out_a}
504 & {direction infinity of triangle_out_a}z2'l
507 .. z2r{direction 0 of triangle_out_b}
509 & {direction infinity of triangle_out_b}z3'l
512 .. z3r{direction 0 of triangle_out_c}
514 & {direction infinity of triangle_out_c}z1'l
518 labels (0, 10, 20, 30);
519 penlabels (1, 1', 2, 2', 3, 3', 12, 23, 31);
523 charwy := ypart exact_right_point;
524 charwx := xpart exact_right_point + .5 pen_thick# * xs;
526 charwy := -ypart exact_down_point;
527 charwx := (width# - (xpart exact_down_point - 0.5 * xs * pen_thick#));
532 def draw_whole_triangle_head =
538 llap# = 3/4 noteheight#;
542 define_triangle_shape (1);
548 fet_beginchar ("Whole trianglehead", "s0triangle");
549 draw_whole_triangle_head;
551 draw_staff (-2, 2, 0);
556 fet_beginchar ("Whole trianglehead", "s0triangle");
557 draw_whole_triangle_head;
559 draw_staff (-2, 2, 0.5);
564 def draw_small_triangle_head (expr dir) =
570 llap# = 2/3 noteheight#;
573 define_triangle_shape (dir);
577 filldraw triangle_out;
578 unfilldraw triangle_in;
582 fet_beginchar ("Half trianglehead (downstem)", "d1triangle");
583 draw_small_triangle_head (-1);
585 draw_staff (-2, 2, 0);
589 fet_beginchar ("Half trianglehead (upstem)", "u1triangle");
590 draw_small_triangle_head (1);
592 draw_staff (-2, 2, 0.5);
596 def draw_closed_triangle_head (expr dir) =
602 llap# = 2/3 noteheight#;
605 define_triangle_shape (dir);
610 fet_beginchar ("Quart trianglehead (upstem)", "u2triangle");
611 draw_closed_triangle_head (1);
613 draw_staff (-2, 2, 0);
617 fet_beginchar ("Quart trianglehead (downstem)", "d2triangle");
618 draw_closed_triangle_head (-1);
620 draw_staff (-2, 2, 0.5);
624 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
626 % Slash heads are for indicating improvisation. They are
627 % twice as high as normal heads.
629 def draw_slash (expr hwid_hash) =
633 exact_height = staff_space# + stafflinethickness# / 2;
635 set_char_box (0, 2 exact_height / slash_slope + hwid_hash,
636 exact_height, exact_height);
645 pickup pencircle scaled blot_diameter;
650 lft x2 = 2 h / slash_slope;
657 ne = unitvector (z3 - z4);
658 nw_dist = (ne rotated 90) * 0.5 blot_diameter;
661 .. (z1 + nw_dist){ne}
662 -- (z2 + nw_dist){ne}
665 .. (z3 - nw_dist){-ne}
666 -- (z4 - nw_dist){-ne}
670 if hwid_hash > 2 slash_thick#:
673 th = slash_thick - blot_diameter;
678 z6 - z5 = whatever * ne;
679 z8 - z7 = whatever * ne;
681 z5 = z1 + whatever * ne + th * (ne rotated -90);
682 z8 = z4 + whatever * ne + th * (ne rotated 90);
690 labels (range 1 thru 10);
694 fet_beginchar ("Whole slashhead", "s0slash");
695 draw_slash (4 slash_thick# + 0.5 staff_space#);
697 draw_staff (-2, 2, 0);
701 fet_beginchar ("Half slashhead", "s1slash");
702 draw_slash (3.0 slash_thick# + 0.15 staff_space#);
704 draw_staff (-2, 2, 0);
708 fet_beginchar ("Quart slashhead", "s2slash");
709 draw_slash (1.5 slash_thick#);
711 draw_staff (-2, 2, 0);
715 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
717 % `thick' is the distance between the NE/SW parallel lines in the cross
718 % (distance between centres of lines) in multiples of stafflinethickness
720 def draw_cross (expr thick) =
722 save ne_dist, nw_dist, rt_dist, up_dist;
723 save crz_in, crz_out;
726 pair ne_dist, nw_dist, rt_dist, up_dist;
727 path crz_in, crz_out;
729 pen_thick# := 1.2 stafflinethickness#;
730 thickness# := thick * stafflinethickness#;
731 define_pixels (thickness);
732 define_blacker_pixels (pen_thick);
734 pickup pencircle scaled pen_thick;
739 ne = unitvector ((1, (2 h - pen_thick) / (w - pen_thick)));
742 z4 - z5 = whatever * ne;
744 z6 - z3 = whatever * ne;
745 z3 - z4 = whatever * (ne yscaled -1);
747 z4 - z3 = whatever * (ne) + (ne rotated -90) * thickness;
750 x1 = charwd / 2 - .5 pen_thick#;
752 + thick / 2 * stafflinethickness# * (ne rotated -90);
754 % labels (1, 2, 3, 4, 5, 6);
756 nw = unitvector (z3 - z4);
758 up_dist = up * 0.5 pen_thick / cosd (angle (ne));
759 rt_dist = right * 0.5 pen_thick / sind (angle (ne));
760 nw_dist = (ne rotated 90) * 0.5 pen_thick;
761 ne_dist = (nw rotated -90) * 0.5 pen_thick;
767 x4 := hround (x4' + .5 pen_thick) - .5 pen_thick;
768 x5 := hfloor (x5' + xpart rt_dist) - xpart rt_dist;
769 y6 := vfloor (y6' + ypart up_dist) - ypart up_dist;
771 crz_out = (z6 + up_dist)
772 -- (z3 + nw_dist){ne}
774 .. (z3 + ne_dist){-nw}
775 -- (z4 + ne_dist){-nw}
777 .. (z4 - nw_dist){-ne}
779 crz_out := crz_out shifted (0, feta_shift)
780 -- reverse crz_out yscaled -1 shifted (0, -feta_eps);
782 -- reverse crz_out xscaled -1 shifted (-feta_eps, 0)
786 x4 := hround (x4' - xpart rt_dist) + xpart rt_dist;
787 x5 := hceiling (x5' - .5 pen_thick) + .5 pen_thick;
788 y6 := vfloor (y6' - .5 pen_thick) + .5 pen_thick;
790 crz_in = (bot z6){right}
791 .. (z6 - nw_dist){ne}
794 -- (z5 + nw_dist){-ne}
796 crz_in := crz_in shifted (0, feta_shift)
797 -- reverse crz_in yscaled -1 shifted (0, -feta_eps);
799 -- reverse crz_in xscaled -1 shifted (-feta_eps, 0)
804 currentpicture := currentpicture shifted (hround (w / 2), 0);
807 charwy := y1 + feta_shift;
809 z12 = (charwx * hppp, y1 * vppp);
815 fet_beginchar ("Whole Crossed notehead", "s0cross");
818 wid# := black_notehead_width# + 4 stafflinethickness#;
819 hei# := noteheight# + stafflinethickness#;
821 set_char_box (0, wid#, hei# / 2, hei# / 2);
825 remember_pic := currentpicture;
827 draw_staff (-2, 2, 0);
832 fet_beginchar ("Whole Crossed notehead", "s0cross");
835 wid# := black_notehead_width# + 4 stafflinethickness#;
836 hei# := noteheight# + stafflinethickness#;
838 set_char_box (0, wid#, hei# / 2, hei# / 2);
840 currentpicture := remember_pic;
842 draw_staff (-2, 2, 0.5);
847 fet_beginchar ("Half Crossed notehead", "s1cross");
850 wid# := black_notehead_width# + 2 stafflinethickness#;
851 hei# := noteheight# + stafflinethickness# / 2;
853 set_char_box (0, wid#, hei# / 2, hei# / 2);
857 remember_pic := currentpicture;
859 draw_staff (-2, 2, 0);
864 fet_beginchar ("Half Crossed notehead", "s1cross");
867 wid# := black_notehead_width# + 2 stafflinethickness#;
868 hei# := noteheight# + stafflinethickness# / 2;
870 set_char_box (0, wid#, hei# / 2, hei# / 2);
872 currentpicture := remember_pic;
874 draw_staff (-2, 2, 0.5);
879 fet_beginchar ("Crossed notehead", "s2cross");
880 wid# := black_notehead_width#;
882 set_char_box (0, wid#, hei# / 2, hei# / 2);
886 remember_pic := currentpicture;
888 draw_staff (-2, 2, 0);
893 fet_beginchar ("Crossed notehead", "s2cross");
894 wid# := black_notehead_width#;
896 set_char_box (0, wid#, hei# / 2, hei# / 2);
898 currentpicture := remember_pic;
900 draw_staff (-2, 2, 0.5);
905 fet_beginchar ("X-Circled notehead", "s2xcircle");
907 save cthick, cxd, cyd, dy;
909 wid# := black_notehead_width# * sqrt (sqrt2);
910 hei# := noteheight# * sqrt (sqrt2);
912 set_char_box (0, wid#, hei# / 2, hei# / 2);
914 d := d - feta_space_shift;
916 cthick# := (1.2 + 1/4) * stafflinethickness#;
917 define_blacker_pixels (cthick);
920 cyd := h + d - cthick / 2;
924 pickup pencircle scaled cthick;
926 fill fullcircle xscaled (cxd + cthick)
927 yscaled (cyd + cthick)
929 unfill fullcircle xscaled (cxd - cthick)
930 yscaled (cyd - cthick)
933 xpos := .5 cxd / sqrt2;
934 ypos := .5 cyd / sqrt2;
936 pickup penrazor scaled cthick rotated (angle (xpos, ypos) + 90);
937 draw (-xpos + w / 2, -ypos + dy) -- (xpos + w / 2, ypos + dy);
939 pickup penrazor scaled cthick rotated (angle (xpos, -ypos) + 90);
940 draw (-xpos + w / 2, ypos + dy) -- (xpos + w / 2, -ypos + dy);
945 z12 = (charwx * hppp, charwy * vppp);
948 remember_pic := currentpicture;
950 draw_staff (-2, 2, 0);
955 fet_beginchar ("X-Circled notehead", "s2xcircle");
957 save cthick, cxr, cyr;
959 wid# := black_notehead_width# * sqrt (sqrt2);
960 hei# := noteheight# * sqrt (sqrt2);
962 set_char_box (0, wid#, hei# / 2, hei# / 2);
964 currentpicture := remember_pic;
966 draw_staff (-2, 2, 0.5);
976 save solfa_pen_thick;
977 solfa_pen_thick# = 1.75 stafflinethickness#;
978 define_blacker_pixels (solfa_pen_thick);
981 save solfa_base_notewidth;
982 solfa_base_notewidth# := black_notehead_width#;
984 solfa_whole_width := whole_notehead_width# / black_notehead_width#;
985 solfa_half_width := half_notehead_width# / black_notehead_width#;
986 solfa_quarter_width := 1.0;
988 def draw_do_head (expr width_factor, dir) =
990 save left_dist, right_dist;
992 pair left_dist, right_dist;
994 set_char_box (0, width_factor * solfa_base_notewidth#,
995 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
997 pickup pencircle scaled solfa_pen_thick;
1006 left_dist = (unitvector (z3 - z1) rotated 90) * 0.5 solfa_pen_thick;
1007 right_dist = (unitvector (z2 - z3) rotated 90) * 0.5 solfa_pen_thick;
1009 p_in := (((z1 - left_dist) -- (z3 - left_dist)) intersectionpoint
1011 -- ((top z1 -- top z2) intersectionpoint
1012 ((z2 - right_dist) -- (z3 - right_dist)))
1013 -- (((z2 - right_dist) -- (z3 - right_dist)) intersectionpoint
1014 ((z1 - left_dist) -- (z3 - left_dist)))
1020 .. (z2 + right_dist){z3 - z2}
1021 -- (z3 + right_dist){z3 - z2}
1023 .. (z3 + left_dist){z1 - z3}
1024 -- (z1 + left_dist){z1 - z3}
1032 charwy := -chardp + 0.5 stafflinethickness#;
1039 fet_beginchar ("Whole dohead", "s0do");
1040 draw_do_head (solfa_whole_width, 1);
1046 fet_beginchar ("Half dohead", "d1do");
1047 draw_do_head (solfa_half_width, -1);
1053 fet_beginchar ("Half dohead", "u1do");
1054 draw_do_head (solfa_half_width, 1);
1060 fet_beginchar ("Quart dohead", "d2do");
1061 draw_do_head (solfa_quarter_width, -1);
1066 fet_beginchar ("Quart dohead", "u2do");
1067 draw_do_head (solfa_quarter_width, 1);
1073 % re - flat top, curved bottom:
1074 % (0,h/2) {dir -90} .. (w/2,-h/2) .. {dir 90} (w,h/2) -- cycle;
1075 % (broader along the base and with more vertical sides for half and
1077 % stem attachment: h/2
1080 def draw_re_head (expr width_factor, dir) =
1084 set_char_box (0, width_factor * solfa_base_notewidth#,
1085 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1087 pickup pencircle scaled solfa_pen_thick;
1094 y2 = curve_start [y3, y1];
1102 labels (range 1 thru 5);
1104 p_in := (z1 + 0.5 solfa_pen_thick * (1, -1))
1108 -- (z5 + 0.5 solfa_pen_thick * (-1, -1))
1121 charwy := curve_start [-chardp, charht];
1129 fet_beginchar ("Whole rehead", "s0re");
1130 draw_re_head (solfa_whole_width, 1);
1136 fet_beginchar ("Half up rehead", "u1re");
1137 draw_re_head (solfa_half_width, 1);
1143 fet_beginchar ("Half down rehead", "d1re");
1144 draw_re_head (solfa_half_width, -1);
1150 fet_beginchar ("Quart rehead", "u2re");
1151 draw_re_head (solfa_quarter_width, 1);
1156 fet_beginchar ("Quart rehead", "d2re");
1157 draw_re_head (solfa_quarter_width, -1);
1162 def draw_mi_head (expr width_factor) =
1163 save path_out, path_in;
1164 save ne_dist, se_dist, ne, se;
1165 path path_out, path_in;
1166 pair ne_dist, se_dist, ne, se;
1168 set_char_box (0, width_factor * solfa_base_notewidth#,
1169 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1171 pickup pencircle scaled solfa_pen_thick;
1182 z6 - z5 = whatever * (z2 - z1);
1183 z8 - z7 = whatever * (z2 - z1);
1184 z8 - z5 = whatever * (z4 - z1);
1185 z6 - z7 = whatever * (z4 - z1);
1187 ne = unitvector (z4 - z1);
1188 se = unitvector (z1 - z2);
1190 ne_dist = (ne rotated 90) * 0.5 solfa_pen_thick;
1191 se_dist = (se rotated 90) * 0.5 solfa_pen_thick;
1193 z5 = whatever [z1, z4] - ne_dist;
1194 z5 = whatever [z1, z2] - 1.5 se_dist;
1196 z5 - z1 = -(z7 - z3);
1198 labels (range 1 thru 8);
1207 .. (z1 + se_dist){-se}
1208 -- (z2 + se_dist){-se}
1210 .. (z2 - ne_dist){ne}
1211 -- (z3 - ne_dist){ne}
1213 .. (z3 - se_dist){se}
1214 -- (z4 - se_dist){se}
1216 .. (z4 + ne_dist){-ne}
1217 -- (z1 + ne_dist){-ne}
1222 fet_beginchar ("Whole mihead", "s0mi");
1223 draw_mi_head (solfa_whole_width);
1229 fet_beginchar ("Half mihead", "s1mi");
1230 draw_mi_head (solfa_quarter_width);
1236 fet_beginchar ("Quart mihead", "s2mi");
1237 draw_mi_head (solfa_quarter_width);
1242 def draw_fa_head (expr width_factor) =
1243 set_char_box (0, width_factor * solfa_base_notewidth#,
1244 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1246 save p_down_in, p_down_out, p_up_in, p_up_out, nw_dist, nw;
1247 path p_down_in, p_down_out, p_up_in, p_up_out;
1250 pickup pencircle scaled solfa_pen_thick;
1263 labels (1, 2, 3, 4);
1265 nw = unitvector (z1 - z3);
1266 nw_dist = (nw rotated 90) * 0.5 solfa_pen_thick;
1268 p_up_in := (((z1 - nw_dist) -- (z3 - nw_dist)) intersectionpoint
1270 -- (((z1 - nw_dist) -- (z3 - nw_dist)) intersectionpoint
1272 -- (z2 + 0.5 solfa_pen_thick * (-1, -1))
1275 p_up_out := lft z1{down}
1276 .. (z1 + nw_dist){-nw}
1277 -- (z3 + nw_dist){-nw}
1285 p_down_in := p_up_in rotated 180 shifted (w, 0);
1286 p_down_out := p_up_out rotated 180 shifted (w, 0);
1293 fet_beginchar ("Whole fa up head", "u0fa");
1294 draw_fa_head (solfa_whole_width);
1300 fet_beginchar ("Whole fa down head", "d0fa");
1301 draw_fa_head (solfa_whole_width);
1307 fet_beginchar ("half fa up head", "u1fa");
1308 draw_fa_head (solfa_half_width);
1314 fet_beginchar ("Half fa down head", "d1fa");
1315 draw_fa_head (solfa_half_width);
1321 fet_beginchar ("Quarter fa up head", "u2fa");
1322 draw_fa_head (solfa_quarter_width);
1327 fet_beginchar ("Quarter fa down head", "d2fa");
1328 draw_fa_head (solfa_quarter_width);
1333 def draw_la_head (expr width_factor) =
1334 set_char_box (0, width_factor * solfa_base_notewidth#,
1335 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1339 pickup pencircle scaled solfa_pen_thick;
1352 labels (range 1 thru 4);
1354 p_in := (z1 + 0.5 solfa_pen_thick * (1, -1))
1355 -- (z2 + 0.5 solfa_pen_thick * (-1, -1))
1356 -- (z3 + 0.5 solfa_pen_thick * (-1, 1))
1357 -- (z4 + 0.5 solfa_pen_thick * (1, 1))
1372 fet_beginchar ("Whole lahead", "s0la");
1373 draw_la_head (solfa_whole_width);
1379 fet_beginchar ("Half lahead", "s1la");
1380 draw_la_head (solfa_half_width);
1386 fet_beginchar ("Quart lahead", "s2la");
1387 draw_la_head (solfa_quarter_width);
1392 def draw_ti_head (expr width_factor, dir) =
1393 set_char_box (0, width_factor * solfa_base_notewidth#,
1394 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1395 save p_in, p_out, p_top;
1396 save nw_dist, sw_dist, nw, sw;
1397 path p_in, p_out, p_top;
1398 pair nw_dist, sw_dist, nw, sw;
1402 pickup pencircle scaled solfa_pen_thick;
1407 y2 = cone_height [y1, y3];
1413 labels (range 1 thru 4);
1415 nw = unitvector (z2 - z1);
1416 sw = unitvector (z1 - z4);
1418 nw_dist = (nw rotated 90) * 0.5 solfa_pen_thick;
1419 sw_dist = (sw rotated 90) * 0.5 solfa_pen_thick;
1421 p_top := (z2 - sw_dist)
1425 p_in := (((z1 - nw_dist) -- (z2 - nw_dist)) intersectionpoint
1426 ((z1 - sw_dist) -- (z4 - sw_dist)))
1427 -- (((z1 - nw_dist) -- (z2 - nw_dist)) intersectionpoint
1428 ((z2 + sw_dist) .. {right}(bot z3)))
1430 .. (((bot z3){right} .. (z4 + nw_dist)) intersectionpoint
1431 ((z1 - sw_dist) -- (z4 - sw_dist)))
1438 .. (z2 - sw_dist){direction 0 of p_top}
1440 & {direction infinity of p_top}(z4 - nw_dist)
1447 charwy := cone_height [-chardp, charht];
1454 fet_beginchar ("Whole up tihead", "s0ti");
1455 draw_ti_head (solfa_whole_width, 1);
1461 fet_beginchar ("Half up tihead", "u1ti");
1462 draw_ti_head (solfa_half_width, 1);
1468 fet_beginchar ("Half down tihead", "d1ti");
1469 draw_ti_head (solfa_half_width, -1);
1475 fet_beginchar ("Quart up tihead", "u2ti");
1476 draw_ti_head (solfa_quarter_width, 1);
1481 fet_beginchar ("Quart down tihead", "d2ti");
1482 draw_ti_head (solfa_quarter_width, -1);
1487 fet_endgroup ("noteheads");
1491 % we derive black_notehead_width# from the quarter head,
1492 % so we have to define black_notehead_width (pixel qty)
1493 % after the black_notehead_width# itself.
1495 % Let's keep it outside the group as well.
1498 define_pixels (black_notehead_width);