1 % Feta (not the Font-En-Tja) music font -- implement noteheads
2 % This file is part of LilyPond, the GNU music typesetter.
4 % Copyright (C) 1997--2012 Jan Nieuwenhuizen <janneke@gnu.org>
5 % & Han-Wen Nienhuys <hanwen@xs4all.nl>
6 % & Juergen Reuter <reuter@ipd.uka.de>
8 % The LilyPond font is free software: you can redistribute it and/or modify
9 % it under the terms of the GNU General Public License as published by
10 % the Free Software Foundation, either version 3 of the License, or
11 % (at your option) any later version, or under the SIL Open Font License.
13 % LilyPond is distributed in the hope that it will be useful,
14 % but WITHOUT ANY WARRANTY; without even the implied warranty of
15 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 % GNU General Public License for more details.
18 % You should have received a copy of the GNU General Public License
19 % along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
28 % Most beautiful noteheads are pronounced, not circular,
29 % and not even symmetric.
30 % These examples are inspired by [Wanske]; see literature list.
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 save half_notehead_width, whole_notehead_width;
39 save solfa_noteheight;
41 numeric whole_notehead_width;
42 numeric half_notehead_width;
44 fet_begingroup ("noteheads");
48 % solfa heads should not overlap on chords.
50 solfa_noteheight# := staff_space# - stafflinethickness#;
52 def undraw_inside_ellipse (expr ellipticity, tilt, superness, clearance) =
57 pat := superellipse ((ellipticity, 0), (0, 1.0),
58 (-ellipticity, 0), (0, -1.0),
60 pat := pat rotated tilt;
62 save top_point, right_point;
63 pair top_point, right_point;
65 top_point := directionpoint left of pat;
66 right_point := directionpoint up of pat;
70 height# = staff_space# + stafflinethickness# - clearance;
71 scaling# = height# / (2 ypart (top_point));
72 define_pixels (scaling);
73 pat := pat scaled scaling shifted (w / 2, .5 (h - d));
84 def draw_longa (expr up) =
85 save stemthick, fudge;
87 stemthick# = 2 stafflinethickness#;
88 define_whole_blacker_pixels (stemthick);
90 % Longas of smaller design sizes should have their lines farther
91 % apart (the overlap with notehead ellipsoid should be smaller).
92 fudge = hround (blot_diameter
95 - (20 / (design_size + 4)))),
98 draw_outside_ellipse (1.80, 0, 0.707, 0);
99 undraw_inside_ellipse (1.30, 125, 0.68, 2 stafflinethickness#);
101 pickup pencircle scaled stemthick;
103 % Longas of smaller design sizes should have their lines longer.
104 line_length := min (max (0.7, (64/60 - (design_size / 60))), 0.85);
106 % Line lengths between 0.72 and 0.77 are not nice
107 % because they are neither separate nor connected
108 % when there is an interval of fourth.
109 if line_length < 0.75:
110 quanted_line_length := min (0.72, line_length);
112 quanted_line_length := max (0.77, line_length);
116 final_line_length := quanted_line_length * staff_space;
119 define_pixels (boxtop, boxbot);
122 bot y1 = -final_line_length;
123 top y2 = final_line_length;
127 fudge + lft x3 = width;
129 top y4 = h + 3.0 staff_space;
131 boxtop# := staff_space# * (quanted_line_length + 3.0) - stemthick# ;
132 boxbot# := staff_space# * quanted_line_length;
134 bot y1 = -d - 3.0 staff_space;
135 top y2 = final_line_length;
139 fudge + lft x3 = width;
142 bot y3 = -final_line_length;
143 boxtop# := staff_space# * quanted_line_length;
144 boxbot# := staff_space# * (quanted_line_length + 3.0) - stemthick# ;
147 draw_gridline (z1, z2, stemthick);
148 draw_gridline (z3, z4, stemthick);
150 set_char_box (stemthick#,
159 fet_beginchar ("Longa notehead", "uM2");
162 draw_staff (-2, 2, 0);
166 fet_beginchar ("Longa notehead", "dM2");
169 draw_staff (-2, 2, 0);
174 fet_beginchar ("Longa notehead", "uM2");
177 draw_staff (-2, 2, 0.5);
181 fet_beginchar ("Longa notehead", "dM2");
184 draw_staff (-2, 2, 0.5);
189 def draw_brevis (expr linecount, line_thickness_multiplier) =
190 save stemthick, fudge, gap;
192 stemthick# = line_thickness_multiplier * 2 * stafflinethickness#;
193 define_whole_blacker_pixels (stemthick);
195 % double-lined breves of smaller design sizes should have
196 % bigger gap between the lines.
197 gap# := (0.95 - 0.008 * design_size) * stemthick#;
199 % Breves of smaller design sizes should have their lines farther
200 % apart (the overlap with notehead ellipsoid should be smaller).
201 fudge = hround (blot_diameter
204 - (20 / (design_size + 4))
208 draw_outside_ellipse (1.80, 0, 0.707, 0);
209 undraw_inside_ellipse (1.30, 125, 0.68, 2 stafflinethickness#);
212 pickup pencircle scaled stemthick;
214 % Breves of smaller design sizes should have their lines longer.
215 line_length := min (max (0.7, (64/60 - (design_size / 60))), 0.85);
217 % Line lengths between 0.72 and 0.77 are not nice
218 % because they are neither separate nor connected
219 % when there is an interval of fourth.
220 if line_length < 0.75:
221 quanted_line_length := min (0.72, line_length);
223 quanted_line_length := max (0.77, line_length);
226 set_char_box (stemthick# * linecount + gap# * (linecount - 1),
227 width# + stemthick# * linecount + gap# * (linecount - 1),
228 staff_space# * quanted_line_length,
229 staff_space# * quanted_line_length);
231 bot y1 = -quanted_line_length * staff_space;
232 top y2 = quanted_line_length * staff_space;
236 fudge + lft x3 = width;
241 for i := 0 step 1 until linecount - 1:
242 line_distance := i * (gap + stemthick);
243 draw_gridline (z1 - (line_distance, 0),
244 z2 - (line_distance, 0),
246 draw_gridline (z3 + (line_distance, 0),
247 z4 + (line_distance, 0),
253 fet_beginchar ("Brevis notehead", "sM1");
256 draw_staff (-2, 2, 0);
261 fet_beginchar ("Brevis notehead", "sM1");
264 draw_staff (-2, 2, 0.5);
269 fet_beginchar ("Double-lined brevis notehead", "sM1double");
270 draw_brevis (2, 0.8);
272 draw_staff (-2, 2, 0);
277 fet_beginchar ("Double-lined brevis notehead", "sM1double");
278 draw_brevis (2, 0.8);
280 draw_staff (-2, 2, 0.5);
285 fet_beginchar ("Whole notehead", "s0");
286 draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0, 0.707, 0);
287 undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10,
288 0.68, 2 stafflinethickness#);
290 whole_notehead_width# := charwd;
292 draw_staff (-2, 2, 0);
297 fet_beginchar ("Whole notehead", "s0");
298 draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0,
300 undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10,
301 0.68, 2 stafflinethickness#);
303 draw_staff (-2, 2, 0.5);
308 fet_beginchar ("Half notehead", "s1");
309 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34, 0.66, 0.17);
310 undraw_inside_ellipse (3.25, 33, 0.81, 2.5 stafflinethickness#);
312 half_notehead_width# := charwd;
314 draw_staff (-2, 2, 0);
319 fet_beginchar ("Half notehead", "s1");
320 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34,
322 undraw_inside_ellipse (3.25, 33, 0.81,
323 2.5 stafflinethickness#);
325 draw_staff (-2, 2, 0.5);
330 fet_beginchar ("Quarter notehead", "s2");
332 draw_staff (-2, 2, 0);
337 fet_beginchar ("Quarter notehead", "s2");
338 draw_outside_ellipse (1.49 - puff_up_factor / 3.0, 31,
341 draw_staff (-2, 2, 0.5);
346 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
349 fet_beginchar ("Whole diamondhead", "s0diamond");
350 draw_outside_ellipse (1.80, 0, 0.495, 0);
351 undraw_inside_ellipse (1.30, 125, 0.6,
352 .4 staff_space# + stafflinethickness#);
354 draw_staff (-2, 2, 0);
359 fet_beginchar ("Whole diamondhead", "s0diamond");
360 draw_outside_ellipse (1.80, 0, 0.495, 0);
361 undraw_inside_ellipse (1.30, 125, 0.6,
362 .4 staff_space# + stafflinethickness#);
364 draw_staff (-2, 2, 0.5);
369 fet_beginchar ("Half diamondhead", "s1diamond");
370 draw_outside_ellipse (1.50, 34, 0.49, 0.17);
371 undraw_inside_ellipse (3.5, 33, 0.80,
372 .3 staff_space# + 1.5 stafflinethickness#);
374 draw_staff (-2, 2, 0);
379 fet_beginchar ("Half diamondhead", "s1diamond");
380 draw_outside_ellipse (1.50, 34, 0.49, 0.17);
381 undraw_inside_ellipse (3.5, 33, 0.80,
383 + 1.5 stafflinethickness#);
385 draw_staff (-2, 2, 0.5);
390 fet_beginchar ("Quarter diamondhead", "s2diamond");
391 draw_outside_ellipse (1.80, 35, 0.495, -0.25);
393 draw_staff (-2, 2, 0);
398 fet_beginchar ("Quarter diamondhead", "s2diamond");
399 draw_outside_ellipse (1.80, 35, 0.495, -0.25);
401 draw_staff (-2, 2, 0.5);
406 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
409 vardef penposx@# (expr d) =
419 z@#l = pat intersectionpoint (z@# -- infinity * dir (d + 180));
420 z@#r = pat intersectionpoint (z@# -- infinity * dir (d));
426 % UGH: xs not declared as argument.
428 def define_triangle_shape (expr stemdir) =
429 save triangle_a, triangle_b, triangle_c;
430 save triangle_out_a, triangle_out_b, triangle_out_c;
431 save triangle_in, triangle_out;
432 save width, depth, height;
433 save origin, left_up_dir;
434 save exact_left_point, exact_right_point, exact_down_point;
436 path triangle_a, triangle_b, triangle_c;
437 path triangle_out_a, triangle_out_b, triangle_out_c;
438 path triangle_in, triangle_out;
439 pair origin, left_up_dir;
440 pair exact_down_point, exact_left_point, exact_right_point;
443 pen_thick# = stafflinethickness# + .1 staff_space#;
444 define_pixels (llap);
445 define_blacker_pixels (pen_thick);
447 left_up_dir = llap# * dir (90 + tilt);
449 xpart (left_up_dir) * xs - (pen_thick# * xs) / 2 + xpart origin = 0;
452 exact_left_point := origin + (left_up_dir xscaled xs);
453 exact_down_point := origin + (left_up_dir rotated 120 xscaled xs);
454 exact_right_point := origin + (left_up_dir rotated 240 xscaled xs);
456 height# = ypart (exact_left_point + origin) + pen_thick# / 2;
457 depth# = -ypart (exact_down_point + origin) + pen_thick# / 2;
458 width# = xpart (exact_right_point - exact_left_point)
461 set_char_box (0, width#, depth#, height#);
463 % Formerly, the shape has simply been drawn with an elliptical pen
464 % (`scaled pen_thick xscaled xs'), but the envelope of such a curve
465 % is of 6th degree. For the sake of mf2pt1, we approximate it.
467 pickup pencircle scaled pen_thick xscaled xs;
469 z0 = (hround_pixels (xpart origin), 0);
471 z1 = z1' = z0 + llap * dir (90 + tilt) xscaled xs;
472 z2 = z2' = z0 + llap * dir (90 + tilt + 120) xscaled xs;
473 z3 = z3' = z0 + llap * dir (90 + tilt + 240) xscaled xs;
475 z12 = caveness [.5[z1, z2], z3];
476 z23 = caveness [.5[z2, z3], z1];
477 z31 = caveness [.5[z3, z1], z2];
479 triangle_a = z1 .. z12 .. z2;
480 triangle_b = z2 .. z23 .. z3;
481 triangle_c = z3 .. z31 .. z1;
483 penposx1 (angle (direction 0 of triangle_a) - 90);
484 penposx2 (angle (direction 0 of triangle_b) - 90);
485 penposx3 (angle (direction 0 of triangle_c) - 90);
487 penposx1' (angle (direction infinity of triangle_c) + 90);
488 penposx2' (angle (direction infinity of triangle_a) + 90);
489 penposx3' (angle (direction infinity of triangle_b) + 90);
491 penposx12 (angle (z12 - z0));
492 penposx23 (angle (z23 - z0));
493 penposx31 (angle (z31 - z0));
495 z10 = (z0 -- z1) intersectionpoint (z1l .. z12l .. z2'r);
496 z20 = (z0 -- z2) intersectionpoint (z2l .. z23l .. z3'r);
497 z30 = (z0 -- z3) intersectionpoint (z3l .. z31l .. z1'r);
510 triangle_out_a = z1r .. z12r .. z2'l;
511 triangle_out_b = z2r .. z23r .. z3'l;
512 triangle_out_c = z3r .. z31r .. z1'l;
514 triangle_out = top z1
516 .. z1r{direction 0 of triangle_out_a}
518 & {direction infinity of triangle_out_a}z2'l
521 .. z2r{direction 0 of triangle_out_b}
523 & {direction infinity of triangle_out_b}z3'l
526 .. z3r{direction 0 of triangle_out_c}
528 & {direction infinity of triangle_out_c}z1'l
531 labels (0, 10, 20, 30);
532 penlabels (1, 1', 2, 2', 3, 3', 12, 23, 31);
536 charwy := ypart exact_right_point;
537 charwx := xpart exact_right_point + .5 pen_thick# * xs;
539 charwy := -ypart exact_down_point;
540 charwx := width# - (xpart exact_down_point - .5 pen_thick# * xs);
545 def draw_whole_triangle_head =
551 llap# = 3/4 noteheight#;
555 define_triangle_shape (1);
561 fet_beginchar ("Whole trianglehead", "s0triangle");
562 draw_whole_triangle_head;
564 draw_staff (-2, 2, 0);
569 fet_beginchar ("Whole trianglehead", "s0triangle");
570 draw_whole_triangle_head;
572 draw_staff (-2, 2, 0.5);
577 def draw_small_triangle_head (expr dir) =
583 llap# = 2/3 noteheight#;
586 define_triangle_shape (dir);
590 filldraw triangle_out;
591 unfilldraw triangle_in;
595 fet_beginchar ("Half trianglehead (downstem)", "d1triangle");
596 draw_small_triangle_head (-1);
598 draw_staff (-2, 2, 0);
602 fet_beginchar ("Half trianglehead (upstem)", "u1triangle");
603 draw_small_triangle_head (1);
605 draw_staff (-2, 2, 0.5);
609 def draw_closed_triangle_head (expr dir) =
615 llap# = 2/3 noteheight#;
618 define_triangle_shape (dir);
623 fet_beginchar ("Quarter trianglehead (upstem)", "u2triangle");
624 draw_closed_triangle_head (1);
626 draw_staff (-2, 2, 0);
630 fet_beginchar ("Quarter trianglehead (downstem)", "d2triangle");
631 draw_closed_triangle_head (-1);
633 draw_staff (-2, 2, 0.5);
637 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
639 % Slash heads are for indicating improvisation. They are
640 % twice as high as normal heads.
642 def draw_slash (expr hwid_hash) =
646 exact_height = staff_space# + stafflinethickness# / 2;
648 set_char_box (0, 2 exact_height / slash_slope + hwid_hash,
649 exact_height, exact_height);
658 pickup pencircle scaled blot_diameter;
663 lft x2 = 2 h / slash_slope;
670 ne = unitvector (z3 - z4);
671 nw_dist = (ne rotated 90) * 0.5 blot_diameter;
674 .. (z1 + nw_dist){ne}
675 -- (z2 + nw_dist){ne}
678 .. (z3 - nw_dist){-ne}
679 -- (z4 - nw_dist){-ne}
683 if hwid_hash > 2 slash_thick#:
686 th = slash_thick - blot_diameter;
691 z6 - z5 = whatever * ne;
692 z8 - z7 = whatever * ne;
694 z5 = z1 + whatever * ne + th * (ne rotated -90);
695 z8 = z4 + whatever * ne + th * (ne rotated 90);
703 labels (range 1 thru 10);
707 fet_beginchar ("Whole slashhead", "s0slash");
708 draw_slash (4 slash_thick# + 0.5 staff_space#);
710 draw_staff (-2, 2, 0);
714 fet_beginchar ("Half slashhead", "s1slash");
715 draw_slash (3.0 slash_thick# + 0.15 staff_space#);
717 draw_staff (-2, 2, 0);
721 fet_beginchar ("Quarter slashhead", "s2slash");
722 draw_slash (1.5 slash_thick#);
724 draw_staff (-2, 2, 0);
728 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
730 % `thick' is the distance between the NE/SW parallel lines in the cross
731 % (distance between centres of lines) in multiples of stafflinethickness
733 def draw_cross (expr thick) =
735 save ne_dist, nw_dist, rt_dist, up_dist;
736 save crz_in, crz_out;
739 pair ne_dist, nw_dist, rt_dist, up_dist;
740 path crz_in, crz_out;
742 pen_thick# := 1.2 stafflinethickness#;
743 thickness# := thick * stafflinethickness#;
744 define_pixels (thickness);
745 define_blacker_pixels (pen_thick);
747 pickup pencircle scaled pen_thick;
752 ne = unitvector ((1, (2 h - pen_thick) / (w - pen_thick)));
755 z4 - z5 = whatever * ne;
757 z6 - z3 = whatever * ne;
758 z3 - z4 = whatever * (ne yscaled -1);
760 z4 - z3 = whatever * (ne) + (ne rotated -90) * thickness;
763 x1 = charwd / 2 - .5 pen_thick#;
765 + thick / 2 * stafflinethickness# * (ne rotated -90);
767 % labels (1, 2, 3, 4, 5, 6);
769 nw = unitvector (z3 - z4);
771 up_dist = up * 0.5 pen_thick / cosd (angle (ne));
772 rt_dist = right * 0.5 pen_thick / sind (angle (ne));
773 nw_dist = (ne rotated 90) * 0.5 pen_thick;
774 ne_dist = (nw rotated -90) * 0.5 pen_thick;
780 x4 := hround (x4' + .5 pen_thick) - .5 pen_thick;
781 x5 := hfloor (x5' + xpart rt_dist) - xpart rt_dist;
782 y6 := vfloor (y6' + ypart up_dist) - ypart up_dist;
784 crz_out = (z6 + up_dist)
785 -- (z3 + nw_dist){ne}
787 .. (z3 + ne_dist){-nw}
788 -- (z4 + ne_dist){-nw}
790 .. (z4 - nw_dist){-ne}
792 crz_out := crz_out shifted (0, feta_shift)
793 -- reverse crz_out yscaled -1 shifted (0, -feta_eps);
795 -- reverse crz_out xscaled -1 shifted (-feta_eps, 0)
799 x4 := hround (x4' - xpart rt_dist) + xpart rt_dist;
800 x5 := hceiling (x5' - .5 pen_thick) + .5 pen_thick;
801 y6 := vfloor (y6' - .5 pen_thick) + .5 pen_thick;
803 crz_in = (bot z6){right}
804 .. (z6 - nw_dist){ne}
807 -- (z5 + nw_dist){-ne}
809 crz_in := crz_in shifted (0, feta_shift)
810 -- reverse crz_in yscaled -1 shifted (0, -feta_eps);
812 -- reverse crz_in xscaled -1 shifted (-feta_eps, 0)
817 currentpicture := currentpicture shifted (hround (w / 2), 0);
820 charwy := y1 + feta_shift;
822 z12 = (charwx * hppp, y1 * vppp);
828 fet_beginchar ("Whole Crossed notehead", "s0cross");
831 wid# := black_notehead_width# + 4 stafflinethickness#;
832 hei# := noteheight# + stafflinethickness#;
834 set_char_box (0, wid#, hei# / 2, hei# / 2);
838 remember_pic := currentpicture;
840 draw_staff (-2, 2, 0);
845 fet_beginchar ("Whole Crossed notehead", "s0cross");
848 wid# := black_notehead_width# + 4 stafflinethickness#;
849 hei# := noteheight# + stafflinethickness#;
851 set_char_box (0, wid#, hei# / 2, hei# / 2);
853 currentpicture := remember_pic;
855 draw_staff (-2, 2, 0.5);
860 fet_beginchar ("Half Crossed notehead", "s1cross");
863 wid# := black_notehead_width# + 2 stafflinethickness#;
864 hei# := noteheight# + stafflinethickness# / 2;
866 set_char_box (0, wid#, hei# / 2, hei# / 2);
870 remember_pic := currentpicture;
872 draw_staff (-2, 2, 0);
877 fet_beginchar ("Half Crossed notehead", "s1cross");
880 wid# := black_notehead_width# + 2 stafflinethickness#;
881 hei# := noteheight# + stafflinethickness# / 2;
883 set_char_box (0, wid#, hei# / 2, hei# / 2);
885 currentpicture := remember_pic;
887 draw_staff (-2, 2, 0.5);
892 fet_beginchar ("Crossed notehead", "s2cross");
893 wid# := black_notehead_width#;
895 set_char_box (0, wid#, hei# / 2, hei# / 2);
899 remember_pic := currentpicture;
901 draw_staff (-2, 2, 0);
906 fet_beginchar ("Crossed notehead", "s2cross");
907 wid# := black_notehead_width#;
909 set_char_box (0, wid#, hei# / 2, hei# / 2);
911 currentpicture := remember_pic;
913 draw_staff (-2, 2, 0.5);
918 fet_beginchar ("X-Circled notehead", "s2xcircle");
920 save cthick, cxd, cyd, dy;
922 wid# := black_notehead_width# * sqrt (sqrt2);
923 hei# := noteheight# * sqrt (sqrt2);
925 set_char_box (0, wid#, hei# / 2, hei# / 2);
927 d := d - feta_space_shift;
929 cthick# := (1.2 + 1/4) * stafflinethickness#;
930 define_blacker_pixels (cthick);
933 cyd := h + d - cthick / 2;
937 pickup pencircle scaled cthick;
939 fill fullcircle xscaled (cxd + cthick)
940 yscaled (cyd + cthick)
942 unfill fullcircle xscaled (cxd - cthick)
943 yscaled (cyd - cthick)
946 xpos := .5 cxd / sqrt2;
947 ypos := .5 cyd / sqrt2;
949 pickup penrazor scaled cthick rotated (angle (xpos, ypos) + 90);
950 draw (-xpos + w / 2, -ypos + dy)
951 -- (xpos + w / 2, ypos + dy);
953 pickup penrazor scaled cthick rotated (angle (xpos, -ypos) + 90);
954 draw (-xpos + w / 2, ypos + dy)
955 -- (xpos + w / 2, -ypos + dy);
960 z12 = (charwx * hppp, charwy * vppp);
963 remember_pic := currentpicture;
965 draw_staff (-2, 2, 0);
970 fet_beginchar ("X-Circled notehead", "s2xcircle");
972 save cthick, cxr, cyr;
974 wid# := black_notehead_width# * sqrt (sqrt2);
975 hei# := noteheight# * sqrt (sqrt2);
977 set_char_box (0, wid#, hei# / 2, hei# / 2);
979 currentpicture := remember_pic;
981 draw_staff (-2, 2, 0.5);
991 % Note: For whole and half notes, the `fill' curve (p_out) is offset from
992 % the points that specify the outer geometry, because we need to add
993 % the rounding. In contrast, the inner curve is not offset, because
994 % there is no rounding.
996 % This means that to get a line of thick_factor * pen_thickness,
997 % we need to offset the inner curve by
999 % (thick_factor - 0.5) * pen_thickness
1003 % (2 * thick_factor - 1) * half_pen_thickness
1005 save solfa_pen_thick;
1006 solfa_pen_thick# = 1.3 stafflinethickness#;
1007 define_blacker_pixels (solfa_pen_thick);
1009 save solfa_pen_radius;
1010 solfa_pen_radius = 0.5 solfa_pen_thick;
1012 save solfa_base_notewidth;
1013 solfa_base_notewidth# := black_notehead_width#;
1015 solfa_whole_width := 1.0;
1016 solfa_half_width := 1.0;
1017 solfa_quarter_width := 1.0;
1022 % Triangle with base parallel to staff lines.
1025 def draw_do_head (expr width_factor, dir, thickness_factor) =
1027 save left_dist, right_dist, bottom_dist;
1029 pair left_dist, right_dist, bottom_dist;
1031 set_char_box (0, width_factor * solfa_base_notewidth#,
1032 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1034 bottom_thick_factor := 2 * thickness_factor - 1;
1035 % no different thickness for left side if we want uniform thickness
1036 if thickness_factor = 1:
1037 left_thick_factor := 1;
1039 left_thick_factor := 0.7 * bottom_thick_factor;
1043 pen_radius := min (solfa_pen_radius,
1044 (h + d) / (3 * (1 + bottom_thick_factor)));
1046 pickup pencircle scaled (2 * pen_radius);
1055 left_dist = (unitvector (z3 - z1) rotated 90) * pen_radius;
1056 right_dist = (unitvector (z2 - z3) rotated 90) * pen_radius;
1057 bottom_dist = (0,1) * pen_radius;
1061 save point_a, point_b, point_c;
1062 pair point_a, point_b, point_c;
1064 pa := (z1 - left_thick_factor * left_dist)
1065 -- (z3 - left_thick_factor * left_dist);
1066 pb := (z1 + bottom_thick_factor * bottom_dist)
1067 -- (z2 + bottom_thick_factor * bottom_dist);
1068 pc := (z2 - right_dist)
1069 -- (z3 - right_dist);
1071 point_a := pa intersectionpoint pb;
1072 point_b := pb intersectionpoint pc;
1073 point_c := pc intersectionpoint pa;
1083 .. (z2 + right_dist){z3 - z2}
1084 -- (z3 + right_dist){z3 - z2}
1086 .. (z3 + left_dist){z1 - z3}
1087 -- (z1 + left_dist){z1 - z3}
1094 charwy := -chardp + 0.5 stafflinethickness#;
1104 fet_beginchar ("Whole dohead", "s0do");
1105 draw_do_head (solfa_whole_width, 1, do_weight);
1111 fet_beginchar ("Half dohead", "d1do");
1112 draw_do_head (solfa_half_width, -1, do_weight);
1118 fet_beginchar ("Half dohead", "u1do");
1119 draw_do_head (solfa_half_width, 1, do_weight);
1125 fet_beginchar ("Quarter dohead", "d2do");
1126 draw_do_head (solfa_quarter_width, -1, do_weight);
1131 fet_beginchar ("Quarter dohead", "u2do");
1132 draw_do_head (solfa_quarter_width, 1, do_weight);
1137 fet_beginchar ("Whole thin dohead", "s0doThin");
1138 draw_do_head (solfa_whole_width, 1, 1);
1144 fet_beginchar ("Half thin dohead", "d1doThin");
1145 draw_do_head (solfa_half_width, -1, 1);
1151 fet_beginchar ("Half thin dohead", "u1doThin");
1152 draw_do_head (solfa_half_width, 1, 1);
1158 fet_beginchar ("Quarter thin dohead", "d2doThin");
1159 draw_do_head (solfa_quarter_width, -1, 1);
1164 fet_beginchar ("Quarter thin dohead", "u2doThin");
1165 draw_do_head (solfa_quarter_width, 1, 1);
1171 % re - flat top, curved bottom:
1175 % .. {dir 90} (w,h/2)
1178 % (broader along the base and with more vertical sides for half and
1181 % Note: According to some shape-note singers, there should be no size
1182 % differences for half and whole notes, contrary to the comment above.
1183 % Consequently, we have made them all the same width.
1185 % stem attachment: h/2
1187 def draw_re_head (expr width_factor, dir, thickness_factor) =
1191 set_char_box (0, width_factor * solfa_base_notewidth#,
1192 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1195 offset = (2 * thickness_factor - 1);
1202 pen_radius := min (solfa_pen_radius,
1203 (h + d) * (1-curve_start) / (1+ offset));
1205 pickup pencircle scaled (2 * pen_radius);
1210 y2 = curve_start [y3, y1];
1218 labels (range 1 thru 5);
1220 p_in := (z1 + pen_radius * (1, -1 * offset))
1222 .. ((top z3) + (0, offset * pen_radius))
1224 -- (z5 + pen_radius * (-1, -1 * offset))
1237 charwy := curve_start [-chardp, charht];
1248 fet_beginchar ("Whole rehead", "s0re");
1249 draw_re_head (solfa_whole_width, 1, re_weight);
1255 fet_beginchar ("Half up rehead", "u1re");
1256 draw_re_head (solfa_half_width, 1, re_weight);
1262 fet_beginchar ("Half down rehead", "d1re");
1263 draw_re_head (solfa_half_width, -1, re_weight);
1269 fet_beginchar ("Quarter up rehead", "u2re");
1270 draw_re_head (solfa_quarter_width, 1, re_weight);
1275 fet_beginchar ("Quarter down rehead", "d2re");
1276 draw_re_head (solfa_quarter_width, -1, re_weight);
1281 fet_beginchar ("Whole thin rehead", "s0reThin");
1282 draw_re_head (solfa_whole_width, 1, 1);
1288 fet_beginchar ("Half up thin rehead", "u1reThin");
1289 draw_re_head (solfa_half_width, 1, 1);
1295 fet_beginchar ("Half down thin rehead", "d1reThin");
1296 draw_re_head (solfa_half_width, -1, 1);
1302 fet_beginchar ("Quarter thin rehead", "u2reThin");
1303 draw_re_head (solfa_quarter_width, 1, 1);
1308 fet_beginchar ("Quarter thin rehead", "d2reThin");
1309 draw_re_head (solfa_quarter_width, -1, 1);
1314 %%%% mi head -- diamond shape
1316 % two versions, depending on whether the `strong' lines are on the nw & se
1319 def draw_mi_head (expr width_factor, thickness_factor, mirror) =
1320 save path_out, path_in;
1321 save ne_dist, se_dist, ne, se;
1322 save path_a, path_b, path_c, path_d;
1323 path path_out, path_in;
1324 pair ne_dist, se_dist, ne, se;
1325 path path_a, path_b, path_c, path_d;
1329 set_char_box (0, width_factor * solfa_base_notewidth#,
1330 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1333 offset := 2 * thickness_factor - 1;
1337 note_diagonal := w / 2 ++ (h + d) / 2;
1341 pen_radius := min (solfa_pen_radius,
1342 .3 * note_diagonal / (1 + offset));
1344 pickup pencircle scaled (2 * pen_radius);
1355 % inner sides are parallel to outer sides
1356 z6 - z5 = whatever * (z2 - z1);
1357 z8 - z7 = whatever * (z4 - z3);
1358 z8 - z5 = whatever * (z4 - z1);
1359 z7 - z6 = whatever * (z3 - z2);
1361 ne = unitvector (z4 - z1);
1362 se = unitvector (z2 - z1);
1364 ne_dist = (ne rotated 90) * pen_radius;
1365 se_dist = (se rotated 90) * pen_radius;
1367 path_a := (z1 + se_dist)
1369 path_b := (z2 + (ne_dist * offset))
1370 -- (z3 + (ne_dist * offset));
1371 path_c := (z3 - se_dist)
1373 path_d := (z4 - (ne_dist * offset))
1374 -- (z1 - (ne_dist * offset));
1376 z5 = path_a intersectionpoint path_d;
1377 z7 = path_b intersectionpoint path_c;
1379 labels (range 1 thru 8);
1388 path_in := inner_path;
1390 path_in := inner_path reflectedabout (z2, z4);
1393 path_out := lft z1 {down}
1394 .. (z1 - se_dist){se}
1395 -- (z2 - se_dist){se}
1397 .. (z2 - ne_dist){ne}
1398 -- (z3 - ne_dist){ne}
1400 .. (z3 + se_dist){-se}
1401 -- (z4 + se_dist){-se}
1403 .. (z4 + ne_dist){-ne}
1404 -- (z1 + ne_dist){-ne}
1409 save mi_weight, mi_width;
1413 fet_beginchar ("Whole mihead", "s0mi");
1414 draw_mi_head (mi_width * solfa_whole_width, mi_weight, false);
1420 fet_beginchar ("Half mihead", "s1mi");
1421 draw_mi_head (mi_width * solfa_quarter_width, mi_weight, false);
1427 fet_beginchar ("Quarter mihead", "s2mi");
1428 draw_mi_head (mi_width * solfa_quarter_width, mi_weight, false);
1433 fet_beginchar ("Whole mirror mihead", "s0miMirror");
1434 draw_mi_head (mi_width * solfa_whole_width, mi_weight, true);
1440 fet_beginchar ("Half mirror mihead", "s1miMirror");
1441 draw_mi_head (mi_width * solfa_quarter_width, mi_weight, true);
1447 fet_beginchar ("Quarter mirror mihead", "s2miMirror");
1448 draw_mi_head (mi_width * solfa_quarter_width, mi_weight, true);
1453 fet_beginchar ("Whole thin mihead", "s0miThin");
1454 draw_mi_head (mi_width * solfa_whole_width, 1, false);
1460 fet_beginchar ("Half thin mihead", "s1miThin");
1461 draw_mi_head (mi_width * solfa_quarter_width, 1, false);
1467 fet_beginchar ("Quarter thin mihead", "s2miThin");
1468 draw_mi_head (mi_width * solfa_quarter_width, 1, false);
1475 % Right triangle, hypotenuse from nw to se corner. Stem attaches on
1476 % vertical side in direction of horizontal side.
1478 def draw_fa_head (expr width_factor, thickness_factor) =
1479 set_char_box (0, width_factor * solfa_base_notewidth#,
1480 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1482 save p_down_in, p_down_out, p_up_in, p_up_out, nw_dist, nw;
1483 path p_down_in, p_down_out, p_up_in, p_up_out;
1484 save path_a, path_b, path_c;
1485 path path_a, path_b, path_c;
1489 offset := 2 * thickness_factor - 1;
1492 pen_radius := min (solfa_pen_radius,
1493 .33 * (h + d) / (1 + offset));
1495 pickup pencircle scaled (2 * pen_radius);
1508 labels (1, 2, 3, 4);
1510 nw = unitvector (z1 - z3);
1511 nw_dist = (nw rotated 90) * pen_radius;
1513 path_a := (z1 - (0,1) * offset * pen_radius)
1514 -- (z2 - (0,1) * offset * pen_radius);
1515 path_b := (z2 - (1,0) * pen_radius)
1516 -- (z3 - (1,0) * pen_radius);
1517 path_c := (z3 - nw_dist)
1520 p_up_in := (path_a intersectionpoint path_b)
1521 -- (path_b intersectionpoint path_c)
1522 -- (path_c intersectionpoint path_a)
1525 p_up_out := lft z1{down}
1526 .. (z1 + nw_dist){-nw}
1527 -- (z3 + nw_dist){-nw}
1535 p_down_in := p_up_in rotated 180 shifted (w, 0);
1536 p_down_out := p_up_out rotated 180 shifted (w, 0);
1545 fet_beginchar ("Whole fa up head", "u0fa");
1546 draw_fa_head (solfa_whole_width, fa_weight);
1552 fet_beginchar ("Whole fa down head", "d0fa");
1553 draw_fa_head (solfa_whole_width, fa_weight);
1559 fet_beginchar ("half fa up head", "u1fa");
1560 draw_fa_head (solfa_half_width, fa_weight);
1566 fet_beginchar ("Half fa down head", "d1fa");
1567 draw_fa_head (solfa_half_width, fa_weight);
1573 fet_beginchar ("Quarter fa up head", "u2fa");
1574 draw_fa_head (solfa_quarter_width, fa_weight);
1579 fet_beginchar ("Quarter fa down head", "d2fa");
1580 draw_fa_head (solfa_quarter_width, fa_weight);
1585 fet_beginchar ("Whole thin fa up head", "u0faThin");
1586 draw_fa_head (solfa_whole_width, 1);
1592 fet_beginchar ("Whole thin fa down head", "d0faThin");
1593 draw_fa_head (solfa_whole_width, 1);
1599 fet_beginchar ("half thin fa up head", "u1faThin");
1600 draw_fa_head (solfa_half_width, 1);
1606 fet_beginchar ("Half thin fa down head", "d1faThin");
1607 draw_fa_head (solfa_half_width, 1);
1613 fet_beginchar ("Quarter thin fa up head", "u2faThin");
1614 draw_fa_head (solfa_quarter_width, 1);
1619 fet_beginchar ("Quarter thin fa down head", "d2faThin");
1620 draw_fa_head (solfa_quarter_width, 1);
1628 % Note: sol head is the same shape as a standard music head, and doesn't
1629 % vary from style to style. However, width is constant with duration,
1630 % so we can't just use the standard note font.
1632 def draw_sol_head (expr filled) =
1633 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34, 0.66, 0.17);
1635 undraw_inside_ellipse (3.25, 33, 0.81, 2.5 stafflinethickness#);
1637 draw_staff (-2, 2, 0);
1640 fet_beginchar ("Whole solhead", "s0sol");
1641 draw_sol_head ( false);
1645 fet_beginchar ("Half solhead", "s1sol");
1646 draw_sol_head ( false);
1650 fet_beginchar ("Quarter solhead", "s2sol");
1651 draw_sol_head ( true);
1659 def draw_la_head (expr width_factor, thickness_factor) =
1660 set_char_box (0, width_factor * solfa_base_notewidth#,
1661 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1666 offset := 2 * thickness_factor - 1;
1669 pen_radius := min (solfa_pen_radius,
1670 .35 * (h + d) / (1 + offset));
1672 pickup pencircle scaled (2 * pen_radius);
1685 labels (range 1 thru 4);
1687 p_in := (z1 + pen_radius * (1, -offset))
1688 -- (z2 + pen_radius * (-1, -offset))
1689 -- (z3 + pen_radius * (-1, offset))
1690 -- (z4 + pen_radius * (1, offset))
1708 fet_beginchar ("Whole lahead", "s0la");
1709 draw_la_head (solfa_whole_width, la_weight);
1715 fet_beginchar ("Half lahead", "s1la");
1716 draw_la_head (solfa_half_width, la_weight);
1722 fet_beginchar ("Quarter lahead", "s2la");
1723 draw_la_head (solfa_quarter_width, la_weight);
1728 fet_beginchar ("Whole thin lahead", "s0laThin");
1729 draw_la_head (solfa_whole_width, 1);
1735 fet_beginchar ("Half thin lahead", "s1laThin");
1736 draw_la_head (solfa_half_width, 1);
1742 fet_beginchar ("Quarter lahead", "s2laThin");
1743 draw_la_head (solfa_quarter_width, 1);
1750 % `Snow-cone', V with rounded top.
1752 def draw_ti_head (expr width_factor, dir, thickness_factor) =
1753 set_char_box (0, width_factor * solfa_base_notewidth#,
1754 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1755 save p_in, p_out, p_top, p_top_in;
1756 path p_in, p_out, p_top, p_top_in;
1761 offset := 2 * thickness_factor - 1;
1764 pen_radius := min (solfa_pen_radius,
1765 .4 * (h + d) / (1 + offset));
1767 pickup pencircle scaled (2 * pen_radius);
1772 y2 = cone_height [y1, y3];
1778 y5 = y1 + offset * pen_radius;
1780 labels (range 1 thru 4);
1782 save nw_dist, sw_dist, nw, sw;
1783 pair nw_dist, sw_dist, nw, sw;
1785 nw = unitvector (z2 - z1);
1786 sw = unitvector (z1 - z4);
1788 nw_dist = (nw rotated 90) * pen_radius;
1789 sw_dist = (sw rotated 90) * pen_radius;
1791 p_top := (z2 + nw * pen_radius)
1793 .. (z4 - sw * pen_radius);
1795 p_top_in := (z2 - nw * offset * pen_radius)
1796 .. (z3 - (0,1) * pen_radius) {right}
1797 .. (z4 + sw * offset * pen_radius);
1799 save path_a, path_b;
1800 path path_a, path_b;
1806 z6 = path_a intersectionpoint p_top_in;
1807 z7 = path_b intersectionpoint p_top_in;
1819 .. (z2 + nw * pen_radius){direction 0 of p_top}
1821 & {direction infinity of p_top}(z4 - sw * pen_radius)
1828 charwy := cone_height [-chardp, charht];
1838 fet_beginchar ("Whole up tihead", "s0ti");
1839 draw_ti_head (solfa_whole_width, 1, ti_weight);
1845 fet_beginchar ("Half up tihead", "u1ti");
1846 draw_ti_head (solfa_half_width, 1, ti_weight);
1852 fet_beginchar ("Half down tihead", "d1ti");
1853 draw_ti_head (solfa_half_width, -1, ti_weight);
1859 fet_beginchar ("Quarter up tihead", "u2ti");
1860 draw_ti_head (solfa_quarter_width, 1, ti_weight);
1865 fet_beginchar ("Quarter down tihead", "d2ti");
1866 draw_ti_head (solfa_quarter_width, -1, ti_weight);
1871 fet_beginchar ("Whole thin up tihead", "s0tiThin");
1872 draw_ti_head (solfa_whole_width, 1, 1);
1878 fet_beginchar ("Half thin up tihead", "u1tiThin");
1879 draw_ti_head (solfa_half_width, 1, 1);
1885 fet_beginchar ("Half thin down tihead", "d1tiThin");
1886 draw_ti_head (solfa_half_width, -1, 1);
1892 fet_beginchar ("Quarter thin up tihead", "u2tiThin");
1893 draw_ti_head (solfa_quarter_width, 1, 1);
1898 fet_beginchar ("Quarter thin down tihead", "d2tiThin");
1899 draw_ti_head (solfa_quarter_width, -1, 1);
1904 %%%%%% Funk shape note heads
1906 % Funk heads are narrower than Aiken and Sacred Harp, so we need a new
1909 funk_notehead_width := 0.75;
1913 % Parabolic on one side, vertical line on other
1914 % Has up and down shapes for *all* notes
1916 def draw_Funk_do_head (expr width_factor, thickness_factor) =
1917 set_char_box (0, width_factor * solfa_base_notewidth#,
1918 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1921 offset := 2 * thickness_factor - 1;
1924 pen_radius := min (solfa_pen_radius,
1925 .3 * (h + d) / (1 + offset));
1927 pickup pencircle scaled (2 * pen_radius);
1938 x4 = x1 - pen_radius;
1939 y4 = y1 + offset * pen_radius;
1942 x5 = x2 + pen_radius;
1945 y6 = y3 - offset * pen_radius;
1947 save p_up_in, p_up_out, p_down_in, p_down_out;
1948 path p_up_in, p_up_out, p_down_in, p_down_out;
1950 p_down_in := z4{left}
1955 p_down_out := bot z1{left}
1962 p_up_in := p_down_in rotated 180 shifted (w,0);
1963 p_up_out := p_down_out rotated 180 shifted (w,0);
1968 save funk_do_weight;
1969 funk_do_weight := 1.7;
1971 fet_beginchar ("Whole up Funk dohead", "u0doFunk");
1972 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1978 fet_beginchar ("Whole down Funk dohead", "d0doFunk");
1979 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1985 fet_beginchar ("Half up Funk dohead", "u1doFunk");
1986 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1992 fet_beginchar ("Half down Funk dohead", "d1doFunk");
1993 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1999 fet_beginchar ("Quarter up Funk dohead", "u2doFunk");
2000 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
2005 fet_beginchar ("Quarter down Funk dohead", "d2doFunk");
2006 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
2013 % Has up and down shapes for *all* notes
2015 def draw_Funk_re_head (expr width_factor, thickness_factor) =
2016 set_char_box (0, width_factor * solfa_base_notewidth#,
2017 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2020 offset := 2 * thickness_factor - 1;
2023 pen_radius := min (solfa_pen_radius,
2024 .3 * (h + d) / (1 + offset));
2026 pickup pencircle scaled (2 * pen_radius);
2037 x3 := curve_in [x1, x2];
2045 save ne, se, ne_perp, se_perp;
2046 pair ne, se, ne_perp, se_perp;
2048 ne := unitvector (z2 - z1);
2049 se := unitvector (z4 - z1);
2050 ne_perp := ne rotated 90;
2051 se_perp := se rotated 90;
2053 save path_a, path_b, path_c, path_d;
2054 path path_a, path_b, path_c, path_d;
2055 save arrow_a_perp, arrow_b_perp;
2056 pair arrow_a_perp, arrow_b_perp;
2059 path_d := z2 .. z3{down} .. z4;
2060 arrow_a_perp = unitvector (direction 0 of path_d rotated 90)
2062 arrow_b_perp = unitvector (direction 2 of path_d rotated 90)
2065 path_b := (z1 + se_perp * pen_radius)
2066 -- z4 + se_perp * offset * pen_radius;
2067 path_a := (z1 - ne_perp * pen_radius)
2068 -- z2 - ne_perp * offset * pen_radius;
2069 path_c := z2 - arrow_a_perp
2071 .. z4 - arrow_b_perp;
2073 z5 = path_a intersectionpoint path_b;
2074 z7 = path_a intersectionpoint path_c;
2075 z8 = path_b intersectionpoint path_c;
2077 save p_up_in, p_down_in, p_up_out, p_down_out;
2078 path p_up_in, p_down_in, p_up_out, p_down_out;
2086 p_down_out := lft z1{up}
2087 .. (z1 + ne_perp * pen_radius){ne}
2088 -- (z2 + ne_perp * pen_radius){ne}
2091 .. (z2 + arrow_a_perp)
2093 .. (z4 + arrow_b_perp)
2096 .. z4 - se_perp * pen_radius
2097 -- z1 - se_perp * pen_radius
2100 p_up_in := p_down_in rotated 180 shifted (w, 0);
2101 p_up_out := p_down_out rotated 180 shifted (w, 0);
2106 save funk_re_weight;
2107 funk_re_weight = 1.7;
2109 fet_beginchar ("Whole up Funk rehead", "u0reFunk");
2110 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2116 fet_beginchar ("Whole down Funk rehead", "d0reFunk");
2117 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2123 fet_beginchar ("Half up Funk rehead", "u1reFunk");
2124 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2130 fet_beginchar ("Half down Funk rehead", "d1reFunk");
2131 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2137 fet_beginchar ("Quarter up Funk rehead", "u2reFunk");
2138 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2143 fet_beginchar ("Quarter down Funk rehead", "d2reFunk");
2144 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2151 % Has up and down shapes for all hollow notes
2153 save funk_mi_width, funk_mi_weight;
2154 funk_mi_width := 1.2;
2155 funk_mi_weight := 1.9;
2157 fet_beginchar ("Whole up Funk mihead", "u0miFunk");
2158 draw_mi_head (funk_mi_width * funk_notehead_width,
2159 funk_mi_weight, false);
2165 fet_beginchar ("Whole down Funk mihead", "d0miFunk");
2166 draw_mi_head (funk_mi_width * funk_notehead_width,
2167 funk_mi_weight, true);
2173 fet_beginchar ("Half up Funk mihead", "u1miFunk");
2174 draw_mi_head (funk_mi_width * funk_notehead_width,
2175 funk_mi_weight, false);
2181 fet_beginchar ("Half down Funk mihead", "d1miFunk");
2182 draw_mi_head (funk_mi_width * funk_notehead_width,
2183 funk_mi_weight, true);
2189 fet_beginchar ("Quarter Funk mihead", "s2miFunk");
2190 draw_mi_head (funk_mi_width * funk_notehead_width,
2191 funk_mi_weight, false);
2198 % Does it rotate for whole notes?
2199 % Same as other shape note systems
2200 % Need special notes because of special width
2202 save funk_fa_weight;
2203 funk_fa_weight := 1.9;
2205 fet_beginchar ("Whole up Funk fahead", "u0faFunk");
2206 draw_fa_head (funk_notehead_width, funk_fa_weight);
2212 fet_beginchar ("Whole down Funk fahead", "d0faFunk");
2213 draw_fa_head (funk_notehead_width, funk_fa_weight);
2219 fet_beginchar ("Half up Funk fahead", "u1faFunk");
2220 draw_fa_head (funk_notehead_width, funk_fa_weight);
2226 fet_beginchar ("Half down Funk fahead", "d1faFunk");
2227 draw_fa_head (funk_notehead_width, funk_fa_weight);
2233 fet_beginchar ("Quarter up Funk fahead", "u2faFunk");
2234 draw_fa_head (funk_notehead_width, funk_fa_weight);
2239 fet_beginchar ("Quarter down Funk fahead", "d2faFunk");
2240 draw_fa_head (funk_notehead_width, funk_fa_weight);
2245 %%%%%% Funk sol head is the same as the others
2246 % Need special character because of skinnier head
2248 def draw_Funk_sol_head (expr filled) =
2251 noteheight# := solfa_noteheight#;
2252 draw_outside_ellipse (1.2, 34, 0.71, 0.);
2254 undraw_inside_ellipse (1.9, 33, 0.74, 5.5 stafflinethickness#);
2256 draw_staff (-2, 2, 0);
2261 fet_beginchar ("Whole Funk solhead", "s0solFunk");
2262 draw_Funk_sol_head ( false);
2266 fet_beginchar ("Half Funk solhead", "s1solFunk");
2267 draw_Funk_sol_head ( false);
2271 fet_beginchar ("Quarter Funk solhead", "s2solFunk");
2272 draw_Funk_sol_head ( true);
2278 % Same as for other shape notes
2279 % Smaller width requires special characters
2281 save funk_la_weight;
2282 funk_la_weight := 1.9;
2284 fet_beginchar ("Whole Funk lahead", "s0laFunk");
2285 draw_la_head (funk_notehead_width, funk_notehead_width);
2291 fet_beginchar ("Half Funk lahead", "s1laFunk");
2292 draw_la_head (funk_notehead_width, funk_notehead_width);
2298 fet_beginchar ("Quarter Funk lahead", "s2laFunk");
2299 draw_la_head (funk_notehead_width, funk_notehead_width);
2305 % `Sideways snow cone'.
2306 % Rotates for all notes.
2308 def draw_Funk_ti_head (expr width_factor, thickness_factor) =
2309 set_char_box (0, width_factor * solfa_base_notewidth#,
2310 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2315 offset := 2 * thickness_factor - 1;
2318 pen_radius := min (solfa_pen_radius,
2319 .33 * (h + d) / (1 + offset));
2321 pickup pencircle scaled (2 * pen_radius);
2326 x2 = cone_width [x1, x3];
2335 save nw_dist, sw_dist, ne, se;
2336 pair nw_dist, sw_dist, ne, se;
2338 ne = unitvector (z2 - z1);
2339 se = unitvector (z4 - z1);
2341 nw_dist = (ne rotated 90) * pen_radius ;
2342 sw_dist = (se rotated -90) * pen_radius;
2344 save path_a, path_b;
2345 path path_a, path_b;
2346 path_a := z1 - nw_dist
2347 -- z2 - offset * nw_dist;
2348 path_b := z1 - sw_dist
2349 -- z4 - offset * sw_dist;
2351 save path_right, path_right_in;
2352 path path_right, path_right_in;
2353 path_right := (z2 + ne * pen_radius)
2355 .. (z4 + se * pen_radius);
2357 path_right_in := (z2 - ne * pen_radius)
2359 .. (z4 - se * pen_radius);
2361 z5 = path_a intersectionpoint path_b;
2362 z6 = path_a intersectionpoint path_right_in;
2363 z7 = path_b intersectionpoint path_right_in;
2365 save p_up_in, p_down_in, p_up_out, p_down_out;
2366 path p_up_in, p_down_in, p_up_out, p_down_out;
2374 p_down_out := lft z1
2378 .. (z2 + ne * pen_radius){direction 0 of path_right}
2380 & {direction infinity of path_right}(z4 + se * pen_radius)
2386 p_up_in := p_down_in rotated 180 shifted (w, 0);
2387 p_up_out := p_down_out rotated 180 shifted (w, 0);
2391 save funk_ti_weight;
2392 funk_ti_weight := 1.6;
2394 fet_beginchar ("Whole up Funk tihead", "u0tiFunk");
2395 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2401 fet_beginchar ("Whole down Funk tihead", "d0tiFunk");
2402 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2408 fet_beginchar ("Half up Funk tihead", "u1tiFunk");
2409 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2415 fet_beginchar ("Half down Funk tihead", "d1tiFunk");
2416 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2422 fet_beginchar ("Quarter up Funk tihead", "u2tiFunk");
2423 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2428 fet_beginchar ("Quarter down Funk tihead", "d2tiFunk");
2429 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2434 %%%%%% Walker shape note heads
2436 % Walker heads are narrow like Funk heads, so use funk_notehead_width.
2439 %%%%%% Walker do head
2441 % Trapezoid, with largest side on stem side
2443 def draw_Walker_do_head (expr width_factor, dir, thickness_factor) =
2444 set_char_box (0, width_factor * solfa_base_notewidth#,
2445 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2447 pickup pencircle scaled solfa_pen_thick;
2450 offset := 2 * thickness_factor - 1;
2452 % adjust width so stem can be centered
2453 if .5w <> good.x .5w: change_width; fi
2457 scaling# = charwd / w;
2462 x1 = inset [x4, x3];
2465 x2 = inset [x3, x4];
2474 labels (range 1 thru 4);
2476 save left_dir, left_perp, right_dir, right_perp;
2477 pair left_dir, left_perp, right_dir, right_perp;
2479 left_dir = unitvector(z1 - z4);
2480 left_perp = (left_dir rotated 90) * solfa_pen_radius;
2481 right_dir = unitvector(z3 - z2);
2482 right_perp = (right_dir rotated 90) * solfa_pen_radius;
2484 save path_a, path_b, path_c, path_d;
2485 path path_a, path_b, path_c, path_d;
2487 path_a := (z4 - left_perp)
2488 -- (z1 - left_perp);
2489 path_b := (z1 - (0, offset*solfa_pen_radius))
2490 -- (z2 - (0, offset*solfa_pen_radius));
2491 path_c := (z2 - right_perp)
2492 -- (z3 - right_perp);
2493 path_d := (z3 + (0, offset*solfa_pen_radius))
2494 -- (z4 + (0, offset*solfa_pen_radius));
2499 p_in := (path_a intersectionpoint path_b)
2500 -- (path_b intersectionpoint path_c)
2501 -- (path_c intersectionpoint path_d)
2502 -- (path_d intersectionpoint path_a)
2505 p_out := top z1{right}
2507 .. z2 + right_perp {right_dir}
2508 -- z3 + right_perp {right_dir}
2511 .. z4 + left_perp {left_dir}
2512 .. z1 + left_perp {left_dir}
2515 charwx := scaling# * (w/2 + solfa_pen_radius);
2516 charwy := scaling# * y2 ;
2519 p_in := p_in rotated 180 shifted (w,0);
2520 p_out := p_out rotated 180 shifted (w,0);
2525 save walker_do_weight;
2526 walker_do_weight := 1.5;
2528 fet_beginchar ("Whole Walker dohead", "s0doWalker");
2529 draw_Walker_do_head (funk_notehead_width, 0, walker_do_weight);
2535 fet_beginchar ("Half up Walker dohead", "u1doWalker");
2536 draw_Walker_do_head (funk_notehead_width, 1, walker_do_weight);
2542 fet_beginchar ("Half down Walker dohead", "d1doWalker");
2543 draw_Walker_do_head (funk_notehead_width, 0, walker_do_weight);
2549 fet_beginchar ("Quarter up Walker dohead", "u2doWalker");
2550 draw_Walker_do_head (funk_notehead_width, 1, walker_do_weight);
2555 fet_beginchar ("Quarter down Walker dohead", "d2doWalker");
2556 draw_Walker_do_head (funk_notehead_width, 0, walker_do_weight);
2561 %%%%%% Walker re head
2562 % Parabolic on one side, shallow parabola on other
2563 % Has up and down shapes for *all* notes
2565 def draw_Walker_re_head (expr width_factor, thickness_factor) =
2566 set_char_box (0, width_factor * solfa_base_notewidth#,
2567 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2570 offset := 2 * thickness_factor - 1;
2573 pen_radius := min (solfa_pen_radius,
2574 .3 * (h + d) / (1 + offset));
2576 pickup pencircle scaled (2 * pen_radius);
2579 dish_factor := 0.20;
2590 x4 = dish_factor [x1, x2];
2594 y5 = y1 + offset * pen_radius;
2597 x6 = x2 + pen_radius;
2600 y7 = y3 - offset * pen_radius;
2603 x8 = x4 - pen_radius;
2605 save path_a, path_d;
2606 path path_a, path_d;
2608 save p_a_start_dir, p_a_end_dir, p_a_start_perp, p_a_end_perp;
2609 pair p_a_start_dir, p_a_end_dir, p_a_start_perp, p_a_end_perp;
2611 path_a := z3 .. z4{down} .. z1;
2613 p_a_start_dir := unitvector(direction 0 of path_a);
2614 p_a_end_dir := unitvector(direction infinity of path_a);
2615 p_a_start_perp := (p_a_start_dir rotated 90) * pen_radius;
2616 p_a_end_perp := (p_a_end_dir rotated 90) * pen_radius;
2618 path_d := (z3 - p_a_start_perp){p_a_start_dir}
2620 ..(z1 - p_a_end_perp){p_a_end_dir};
2622 save path_b, path_c;
2623 path path_b, path_c;
2625 path_b := z5 {left} .. z6{up};
2626 path_c := z7 {left} .. z6{down};
2628 z9 = path_d intersectionpoint path_b;
2629 z10 = path_d intersectionpoint path_c;
2631 labels (range 1 thru 4);
2633 save p_up_in, p_up_out, p_down_in, p_down_out;
2634 path p_up_in, p_up_out, p_down_in, p_down_out;
2637 ... {right} z10 {p_a_start_dir}
2639 .. {p_a_end_dir} z9 {left}
2642 p_down_out := lft z2{up}
2645 .. (z3 + p_a_start_perp){p_a_start_dir}
2647 .. (z1 + p_a_end_perp) {p_a_end_dir}
2652 p_up_in := p_down_in rotated 180 shifted (w,0);
2653 p_up_out := p_down_out rotated 180 shifted (w,0);
2657 save walker_re_weight;
2658 walker_re_weight := 1.2;
2660 fet_beginchar ("Whole Walker rehead", "s0reWalker");
2661 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2667 fet_beginchar ("Half up Walker rehead", "u1reWalker");
2668 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2674 fet_beginchar ("Half down Walker rehead", "d1reWalker");
2675 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2681 fet_beginchar ("Quarter up Walker rehead", "u2reWalker");
2682 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2687 fet_beginchar ("Quarter down Walker rehead", "d2reWalker");
2688 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2693 %%%%%% Walker mi head
2695 % Symmetric for all hollow notes
2697 save walker_mi_width, walker_mi_weight;
2698 walker_mi_width := 1.2;
2699 walker_mi_weight := 1.5;
2701 fet_beginchar ("Whole Walker mihead", "s0miWalker");
2702 draw_mi_head (walker_mi_width * funk_notehead_width,
2703 walker_mi_weight, true);
2709 fet_beginchar ("Half Walker mihead", "s1miWalker");
2710 draw_mi_head (walker_mi_width * funk_notehead_width,
2711 walker_mi_weight, true);
2717 fet_beginchar ("Quarter Walker mihead", "s2miWalker");
2718 draw_mi_head (walker_mi_width * funk_notehead_width,
2719 walker_mi_weight, true);
2726 % Does not rotate for whole notes
2727 % Whole rotation is different from Funk, so special notes
2729 %%%%%% Funk sol head is the same as the others
2730 % Need special character because of skinnier head
2732 save walker_fa_weight;
2733 walker_fa_weight := 1.5;
2735 fet_beginchar ("Whole Walker fahead", "s0faWalker");
2736 draw_fa_head (funk_notehead_width, walker_fa_weight);
2742 fet_beginchar ("Half up Walker fahead", "u1faWalker");
2743 draw_fa_head (funk_notehead_width, walker_fa_weight);
2749 fet_beginchar ("Half down Walker fahead", "d1faWalker");
2750 draw_fa_head (funk_notehead_width, walker_fa_weight);
2756 fet_beginchar ("Quarter up Walker fahead", "u2faWalker");
2757 draw_fa_head (funk_notehead_width, walker_fa_weight);
2762 fet_beginchar ("Quarter down Walker fahead", "d2faWalker");
2763 draw_fa_head (funk_notehead_width, walker_fa_weight);
2769 % Same as Funk, no special notes
2772 %%%%%% Walker la head
2774 % Lighter weight requires separate notes
2776 save walker_la_weight;
2777 walker_la_weight := 1.5;
2779 fet_beginchar ("Whole Walker lahead", "s0laWalker");
2780 draw_la_head (funk_notehead_width, walker_la_weight);
2786 fet_beginchar ("Half Funk lahead", "s1laWalker");
2787 draw_la_head (funk_notehead_width, walker_la_weight);
2793 fet_beginchar ("Quarter Funk lahead", "s2laWalker");
2794 draw_la_head (funk_notehead_width, walker_la_weight);
2799 %%%%%% Walker ti head
2800 % Triangular arrowhead
2801 % Rotates for all but whole notes
2803 def draw_Walker_ti_head (expr width_factor, thickness_factor) =
2804 set_char_box (0, width_factor * solfa_base_notewidth#,
2805 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2808 offset := 2 * thickness_factor - 1;
2811 pen_radius := min (solfa_pen_radius,
2812 .3 * (h + d) / (1 + offset));
2814 pickup pencircle scaled (2 * pen_radius);
2826 labels (range 1 thru 4);
2828 save nw_dist, sw_dist, ne, se;
2829 pair nw_dist, sw_dist, ne, se;
2831 ne = unitvector (z2 - z1);
2832 se = unitvector (z3 - z1);
2834 nw_dist = (ne rotated 90) * pen_radius ;
2835 sw_dist = (se rotated -90) * pen_radius;
2838 save path_a, path_b, path_c;
2839 path path_a, path_b, path_c;
2840 path_a := z2 - nw_dist * offset
2841 -- z1 - nw_dist * offset;
2842 path_b := z3 - sw_dist * offset
2843 -- z1 - sw_dist * offset;
2844 path_c := z2 + left * pen_radius
2845 -- z3 + left * pen_radius;
2847 z4 = path_a intersectionpoint path_b;
2848 z5 = path_a intersectionpoint path_c;
2849 z6 = path_b intersectionpoint path_c;
2851 save p_up_in, p_down_in, p_up_out, p_down_out;
2852 path p_up_in, p_down_in, p_up_out, p_down_out;
2859 p_down_out := lft z1{up}
2860 .. (z1 + nw_dist){ne}
2861 -- (z2 + nw_dist){ne}
2866 .. (z3 + sw_dist){- se}
2867 .. (z1 + sw_dist){- se}
2870 p_up_in := p_down_in rotated 180 shifted (w, 0);
2871 p_up_out := p_down_out rotated 180 shifted (w, 0);
2875 save walker_ti_weight;
2876 walker_ti_weight := 1.4;
2878 fet_beginchar ("Whole Walker tihead", "s0tiWalker");
2879 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2885 fet_beginchar ("Half up Walker tihead", "u1tiWalker");
2886 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2892 fet_beginchar ("Half down Walker tihead", "d1tiWalker");
2893 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2899 fet_beginchar ("Quarter up Walker tihead", "u2tiWalker");
2900 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2905 fet_beginchar ("Quarter down Walker tihead", "d2tiWalker");
2906 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2910 fet_endgroup ("noteheads");
2914 % we derive black_notehead_width# from the quarter head,
2915 % so we have to define black_notehead_width (pixel qty)
2916 % after the black_notehead_width# itself.
2918 % Let's keep it outside the group as well.
2921 define_pixels (black_notehead_width);