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 set_char_box (stemthick#,
106 pickup pencircle scaled stemthick;
108 % Longas of smaller design sizes should have their lines longer.
109 line_length := min (max (0.7, (64/60 - (design_size / 60))), 0.85);
111 % Line lengths between 0.72 and 0.77 are not nice
112 % because they are neither separate nor connected
113 % when there is an interval of fourth.
114 if line_length < 0.75:
115 quanted_line_length := min (0.72, line_length);
117 quanted_line_length := max (0.77, line_length);
120 final_line_length := quanted_line_length * staff_space;
123 bot y1 = -final_line_length;
124 top y2 = final_line_length;
128 fudge + lft x3 = width;
130 top y4 = h + 3.0 staff_space;
133 bot y1 = -d - 3.0 staff_space;
134 top y2 = final_line_length;
138 fudge + lft x3 = width;
141 bot y3 = -final_line_length;
144 draw_gridline (z1, z2, stemthick);
145 draw_gridline (z3, z4, stemthick);
151 fet_beginchar ("Longa notehead", "uM2");
154 draw_staff (-2, 2, 0);
158 fet_beginchar ("Longa notehead", "dM2");
161 draw_staff (-2, 2, 0);
166 fet_beginchar ("Longa notehead", "uM2");
169 draw_staff (-2, 2, 0.5);
173 fet_beginchar ("Longa notehead", "dM2");
176 draw_staff (-2, 2, 0.5);
181 def draw_brevis (expr linecount, line_thickness_multiplier) =
182 save stemthick, fudge, gap;
184 stemthick# = line_thickness_multiplier * 2 * stafflinethickness#;
185 define_whole_blacker_pixels (stemthick);
187 % double-lined breves of smaller design sizes should have
188 % bigger gap between the lines.
189 gap# := (0.95 - 0.008 * design_size) * stemthick#;
191 % Breves of smaller design sizes should have their lines farther
192 % apart (the overlap with notehead ellipsoid should be smaller).
193 fudge = hround (blot_diameter
196 - (20 / (design_size + 4))
200 draw_outside_ellipse (1.80, 0, 0.707, 0);
201 undraw_inside_ellipse (1.30, 125, 0.68, 2 stafflinethickness#);
203 set_char_box (stemthick# * linecount + gap# * (linecount - 1),
204 width# + stemthick# * linecount + gap# * (linecount - 1),
209 pickup pencircle scaled stemthick;
211 % Breves of smaller design sizes should have their lines longer.
212 line_length := min (max (0.7, (64/60 - (design_size / 60))), 0.85);
214 % Line lengths between 0.72 and 0.77 are not nice
215 % because they are neither separate nor connected
216 % when there is an interval of fourth.
217 if line_length < 0.75:
218 quanted_line_length := min (0.72, line_length);
220 quanted_line_length := max (0.77, line_length);
223 bot y1 = -quanted_line_length * staff_space;
224 top y2 = quanted_line_length * staff_space;
228 fudge + lft x3 = width;
233 for i := 0 step 1 until linecount - 1:
234 line_distance := i * (gap + stemthick);
235 draw_gridline (z1 - (line_distance, 0),
236 z2 - (line_distance, 0),
238 draw_gridline (z3 + (line_distance, 0),
239 z4 + (line_distance, 0),
245 fet_beginchar ("Brevis notehead", "sM1");
248 draw_staff (-2, 2, 0);
253 fet_beginchar ("Brevis notehead", "sM1");
256 draw_staff (-2, 2, 0.5);
261 fet_beginchar ("Double-lined brevis notehead", "sM1double");
262 draw_brevis (2, 0.8);
264 draw_staff (-2, 2, 0);
269 fet_beginchar ("Double-lined brevis notehead", "sM1double");
270 draw_brevis (2, 0.8);
272 draw_staff (-2, 2, 0.5);
277 fet_beginchar ("Whole notehead", "s0");
278 draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0, 0.707, 0);
279 undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10,
280 0.68, 2 stafflinethickness#);
282 whole_notehead_width# := charwd;
284 draw_staff (-2, 2, 0);
289 fet_beginchar ("Whole notehead", "s0");
290 draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0,
292 undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10,
293 0.68, 2 stafflinethickness#);
295 draw_staff (-2, 2, 0.5);
300 fet_beginchar ("Half notehead", "s1");
301 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34, 0.66, 0.17);
302 undraw_inside_ellipse (3.25, 33, 0.81, 2.5 stafflinethickness#);
304 half_notehead_width# := charwd;
306 draw_staff (-2, 2, 0);
311 fet_beginchar ("Half notehead", "s1");
312 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34,
314 undraw_inside_ellipse (3.25, 33, 0.81,
315 2.5 stafflinethickness#);
317 draw_staff (-2, 2, 0.5);
322 fet_beginchar ("Quarter notehead", "s2");
324 draw_staff (-2, 2, 0);
329 fet_beginchar ("Quarter notehead", "s2");
330 draw_outside_ellipse (1.49 - puff_up_factor / 3.0, 31,
333 draw_staff (-2, 2, 0.5);
338 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
341 fet_beginchar ("Whole diamondhead", "s0diamond");
342 draw_outside_ellipse (1.80, 0, 0.495, 0);
343 undraw_inside_ellipse (1.30, 125, 0.6,
344 .4 staff_space# + stafflinethickness#);
346 draw_staff (-2, 2, 0);
351 fet_beginchar ("Whole diamondhead", "s0diamond");
352 draw_outside_ellipse (1.80, 0, 0.495, 0);
353 undraw_inside_ellipse (1.30, 125, 0.6,
354 .4 staff_space# + stafflinethickness#);
356 draw_staff (-2, 2, 0.5);
361 fet_beginchar ("Half diamondhead", "s1diamond");
362 draw_outside_ellipse (1.50, 34, 0.49, 0.17);
363 undraw_inside_ellipse (3.5, 33, 0.80,
364 .3 staff_space# + 1.5 stafflinethickness#);
366 draw_staff (-2, 2, 0);
371 fet_beginchar ("Half diamondhead", "s1diamond");
372 draw_outside_ellipse (1.50, 34, 0.49, 0.17);
373 undraw_inside_ellipse (3.5, 33, 0.80,
375 + 1.5 stafflinethickness#);
377 draw_staff (-2, 2, 0.5);
382 fet_beginchar ("Quarter diamondhead", "s2diamond");
383 draw_outside_ellipse (1.80, 35, 0.495, -0.25);
385 draw_staff (-2, 2, 0);
390 fet_beginchar ("Quarter diamondhead", "s2diamond");
391 draw_outside_ellipse (1.80, 35, 0.495, -0.25);
393 draw_staff (-2, 2, 0.5);
398 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
401 vardef penposx@# (expr d) =
411 z@#l = pat intersectionpoint (z@# -- infinity * dir (d + 180));
412 z@#r = pat intersectionpoint (z@# -- infinity * dir (d));
418 % UGH: xs not declared as argument.
420 def define_triangle_shape (expr stemdir) =
421 save triangle_a, triangle_b, triangle_c;
422 save triangle_out_a, triangle_out_b, triangle_out_c;
423 save triangle_in, triangle_out;
424 save width, depth, height;
425 save origin, left_up_dir;
426 save exact_left_point, exact_right_point, exact_down_point;
428 path triangle_a, triangle_b, triangle_c;
429 path triangle_out_a, triangle_out_b, triangle_out_c;
430 path triangle_in, triangle_out;
431 pair origin, left_up_dir;
432 pair exact_down_point, exact_left_point, exact_right_point;
435 pen_thick# = stafflinethickness# + .1 staff_space#;
436 define_pixels (llap);
437 define_blacker_pixels (pen_thick);
439 left_up_dir = llap# * dir (90 + tilt);
441 xpart (left_up_dir) * xs - (pen_thick# * xs) / 2 + xpart origin = 0;
444 exact_left_point := origin + (left_up_dir xscaled xs);
445 exact_down_point := origin + (left_up_dir rotated 120 xscaled xs);
446 exact_right_point := origin + (left_up_dir rotated 240 xscaled xs);
448 height# = ypart (exact_left_point + origin) + pen_thick# / 2;
449 depth# = -ypart (exact_down_point + origin) + pen_thick# / 2;
450 width# = xpart (exact_right_point - exact_left_point)
453 set_char_box (0, width#, depth#, height#);
455 % Formerly, the shape has simply been drawn with an elliptical pen
456 % (`scaled pen_thick xscaled xs'), but the envelope of such a curve
457 % is of 6th degree. For the sake of mf2pt1, we approximate it.
459 pickup pencircle scaled pen_thick xscaled xs;
461 z0 = (hround_pixels (xpart origin), 0);
463 z1 = z1' = z0 + llap * dir (90 + tilt) xscaled xs;
464 z2 = z2' = z0 + llap * dir (90 + tilt + 120) xscaled xs;
465 z3 = z3' = z0 + llap * dir (90 + tilt + 240) xscaled xs;
467 z12 = caveness [.5[z1, z2], z3];
468 z23 = caveness [.5[z2, z3], z1];
469 z31 = caveness [.5[z3, z1], z2];
471 triangle_a = z1 .. z12 .. z2;
472 triangle_b = z2 .. z23 .. z3;
473 triangle_c = z3 .. z31 .. z1;
475 penposx1 (angle (direction 0 of triangle_a) - 90);
476 penposx2 (angle (direction 0 of triangle_b) - 90);
477 penposx3 (angle (direction 0 of triangle_c) - 90);
479 penposx1' (angle (direction infinity of triangle_c) + 90);
480 penposx2' (angle (direction infinity of triangle_a) + 90);
481 penposx3' (angle (direction infinity of triangle_b) + 90);
483 penposx12 (angle (z12 - z0));
484 penposx23 (angle (z23 - z0));
485 penposx31 (angle (z31 - z0));
487 z10 = (z0 -- z1) intersectionpoint (z1l .. z12l .. z2'r);
488 z20 = (z0 -- z2) intersectionpoint (z2l .. z23l .. z3'r);
489 z30 = (z0 -- z3) intersectionpoint (z3l .. z31l .. z1'r);
502 triangle_out_a = z1r .. z12r .. z2'l;
503 triangle_out_b = z2r .. z23r .. z3'l;
504 triangle_out_c = z3r .. z31r .. z1'l;
506 triangle_out = top z1
508 .. z1r{direction 0 of triangle_out_a}
510 & {direction infinity of triangle_out_a}z2'l
513 .. z2r{direction 0 of triangle_out_b}
515 & {direction infinity of triangle_out_b}z3'l
518 .. z3r{direction 0 of triangle_out_c}
520 & {direction infinity of triangle_out_c}z1'l
523 labels (0, 10, 20, 30);
524 penlabels (1, 1', 2, 2', 3, 3', 12, 23, 31);
528 charwy := ypart exact_right_point;
529 charwx := xpart exact_right_point + .5 pen_thick# * xs;
531 charwy := -ypart exact_down_point;
532 charwx := width# - (xpart exact_down_point - .5 pen_thick# * xs);
537 def draw_whole_triangle_head =
543 llap# = 3/4 noteheight#;
547 define_triangle_shape (1);
553 fet_beginchar ("Whole trianglehead", "s0triangle");
554 draw_whole_triangle_head;
556 draw_staff (-2, 2, 0);
561 fet_beginchar ("Whole trianglehead", "s0triangle");
562 draw_whole_triangle_head;
564 draw_staff (-2, 2, 0.5);
569 def draw_small_triangle_head (expr dir) =
575 llap# = 2/3 noteheight#;
578 define_triangle_shape (dir);
582 filldraw triangle_out;
583 unfilldraw triangle_in;
587 fet_beginchar ("Half trianglehead (downstem)", "d1triangle");
588 draw_small_triangle_head (-1);
590 draw_staff (-2, 2, 0);
594 fet_beginchar ("Half trianglehead (upstem)", "u1triangle");
595 draw_small_triangle_head (1);
597 draw_staff (-2, 2, 0.5);
601 def draw_closed_triangle_head (expr dir) =
607 llap# = 2/3 noteheight#;
610 define_triangle_shape (dir);
615 fet_beginchar ("Quarter trianglehead (upstem)", "u2triangle");
616 draw_closed_triangle_head (1);
618 draw_staff (-2, 2, 0);
622 fet_beginchar ("Quarter trianglehead (downstem)", "d2triangle");
623 draw_closed_triangle_head (-1);
625 draw_staff (-2, 2, 0.5);
629 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
631 % Slash heads are for indicating improvisation. They are
632 % twice as high as normal heads.
634 def draw_slash (expr hwid_hash) =
638 exact_height = staff_space# + stafflinethickness# / 2;
640 set_char_box (0, 2 exact_height / slash_slope + hwid_hash,
641 exact_height, exact_height);
650 pickup pencircle scaled blot_diameter;
655 lft x2 = 2 h / slash_slope;
662 ne = unitvector (z3 - z4);
663 nw_dist = (ne rotated 90) * 0.5 blot_diameter;
666 .. (z1 + nw_dist){ne}
667 -- (z2 + nw_dist){ne}
670 .. (z3 - nw_dist){-ne}
671 -- (z4 - nw_dist){-ne}
675 if hwid_hash > 2 slash_thick#:
678 th = slash_thick - blot_diameter;
683 z6 - z5 = whatever * ne;
684 z8 - z7 = whatever * ne;
686 z5 = z1 + whatever * ne + th * (ne rotated -90);
687 z8 = z4 + whatever * ne + th * (ne rotated 90);
695 labels (range 1 thru 10);
699 fet_beginchar ("Whole slashhead", "s0slash");
700 draw_slash (4 slash_thick# + 0.5 staff_space#);
702 draw_staff (-2, 2, 0);
706 fet_beginchar ("Half slashhead", "s1slash");
707 draw_slash (3.0 slash_thick# + 0.15 staff_space#);
709 draw_staff (-2, 2, 0);
713 fet_beginchar ("Quarter slashhead", "s2slash");
714 draw_slash (1.5 slash_thick#);
716 draw_staff (-2, 2, 0);
720 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
722 % `thick' is the distance between the NE/SW parallel lines in the cross
723 % (distance between centres of lines) in multiples of stafflinethickness
725 def draw_cross (expr thick) =
727 save ne_dist, nw_dist, rt_dist, up_dist;
728 save crz_in, crz_out;
731 pair ne_dist, nw_dist, rt_dist, up_dist;
732 path crz_in, crz_out;
734 pen_thick# := 1.2 stafflinethickness#;
735 thickness# := thick * stafflinethickness#;
736 define_pixels (thickness);
737 define_blacker_pixels (pen_thick);
739 pickup pencircle scaled pen_thick;
744 ne = unitvector ((1, (2 h - pen_thick) / (w - pen_thick)));
747 z4 - z5 = whatever * ne;
749 z6 - z3 = whatever * ne;
750 z3 - z4 = whatever * (ne yscaled -1);
752 z4 - z3 = whatever * (ne) + (ne rotated -90) * thickness;
755 x1 = charwd / 2 - .5 pen_thick#;
757 + thick / 2 * stafflinethickness# * (ne rotated -90);
759 % labels (1, 2, 3, 4, 5, 6);
761 nw = unitvector (z3 - z4);
763 up_dist = up * 0.5 pen_thick / cosd (angle (ne));
764 rt_dist = right * 0.5 pen_thick / sind (angle (ne));
765 nw_dist = (ne rotated 90) * 0.5 pen_thick;
766 ne_dist = (nw rotated -90) * 0.5 pen_thick;
772 x4 := hround (x4' + .5 pen_thick) - .5 pen_thick;
773 x5 := hfloor (x5' + xpart rt_dist) - xpart rt_dist;
774 y6 := vfloor (y6' + ypart up_dist) - ypart up_dist;
776 crz_out = (z6 + up_dist)
777 -- (z3 + nw_dist){ne}
779 .. (z3 + ne_dist){-nw}
780 -- (z4 + ne_dist){-nw}
782 .. (z4 - nw_dist){-ne}
784 crz_out := crz_out shifted (0, feta_shift)
785 -- reverse crz_out yscaled -1 shifted (0, -feta_eps);
787 -- reverse crz_out xscaled -1 shifted (-feta_eps, 0)
791 x4 := hround (x4' - xpart rt_dist) + xpart rt_dist;
792 x5 := hceiling (x5' - .5 pen_thick) + .5 pen_thick;
793 y6 := vfloor (y6' - .5 pen_thick) + .5 pen_thick;
795 crz_in = (bot z6){right}
796 .. (z6 - nw_dist){ne}
799 -- (z5 + nw_dist){-ne}
801 crz_in := crz_in shifted (0, feta_shift)
802 -- reverse crz_in yscaled -1 shifted (0, -feta_eps);
804 -- reverse crz_in xscaled -1 shifted (-feta_eps, 0)
809 currentpicture := currentpicture shifted (hround (w / 2), 0);
812 charwy := y1 + feta_shift;
814 z12 = (charwx * hppp, y1 * vppp);
820 fet_beginchar ("Whole Crossed notehead", "s0cross");
823 wid# := black_notehead_width# + 4 stafflinethickness#;
824 hei# := noteheight# + stafflinethickness#;
826 set_char_box (0, wid#, hei# / 2, hei# / 2);
830 remember_pic := currentpicture;
832 draw_staff (-2, 2, 0);
837 fet_beginchar ("Whole Crossed notehead", "s0cross");
840 wid# := black_notehead_width# + 4 stafflinethickness#;
841 hei# := noteheight# + stafflinethickness#;
843 set_char_box (0, wid#, hei# / 2, hei# / 2);
845 currentpicture := remember_pic;
847 draw_staff (-2, 2, 0.5);
852 fet_beginchar ("Half Crossed notehead", "s1cross");
855 wid# := black_notehead_width# + 2 stafflinethickness#;
856 hei# := noteheight# + stafflinethickness# / 2;
858 set_char_box (0, wid#, hei# / 2, hei# / 2);
862 remember_pic := currentpicture;
864 draw_staff (-2, 2, 0);
869 fet_beginchar ("Half Crossed notehead", "s1cross");
872 wid# := black_notehead_width# + 2 stafflinethickness#;
873 hei# := noteheight# + stafflinethickness# / 2;
875 set_char_box (0, wid#, hei# / 2, hei# / 2);
877 currentpicture := remember_pic;
879 draw_staff (-2, 2, 0.5);
884 fet_beginchar ("Crossed notehead", "s2cross");
885 wid# := black_notehead_width#;
887 set_char_box (0, wid#, hei# / 2, hei# / 2);
891 remember_pic := currentpicture;
893 draw_staff (-2, 2, 0);
898 fet_beginchar ("Crossed notehead", "s2cross");
899 wid# := black_notehead_width#;
901 set_char_box (0, wid#, hei# / 2, hei# / 2);
903 currentpicture := remember_pic;
905 draw_staff (-2, 2, 0.5);
910 fet_beginchar ("X-Circled notehead", "s2xcircle");
912 save cthick, cxd, cyd, dy;
914 wid# := black_notehead_width# * sqrt (sqrt2);
915 hei# := noteheight# * sqrt (sqrt2);
917 set_char_box (0, wid#, hei# / 2, hei# / 2);
919 d := d - feta_space_shift;
921 cthick# := (1.2 + 1/4) * stafflinethickness#;
922 define_blacker_pixels (cthick);
925 cyd := h + d - cthick / 2;
929 pickup pencircle scaled cthick;
931 fill fullcircle xscaled (cxd + cthick)
932 yscaled (cyd + cthick)
934 unfill fullcircle xscaled (cxd - cthick)
935 yscaled (cyd - cthick)
938 xpos := .5 cxd / sqrt2;
939 ypos := .5 cyd / sqrt2;
941 pickup penrazor scaled cthick rotated (angle (xpos, ypos) + 90);
942 draw (-xpos + w / 2, -ypos + dy)
943 -- (xpos + w / 2, ypos + dy);
945 pickup penrazor scaled cthick rotated (angle (xpos, -ypos) + 90);
946 draw (-xpos + w / 2, ypos + dy)
947 -- (xpos + w / 2, -ypos + dy);
952 z12 = (charwx * hppp, charwy * vppp);
955 remember_pic := currentpicture;
957 draw_staff (-2, 2, 0);
962 fet_beginchar ("X-Circled notehead", "s2xcircle");
964 save cthick, cxr, cyr;
966 wid# := black_notehead_width# * sqrt (sqrt2);
967 hei# := noteheight# * sqrt (sqrt2);
969 set_char_box (0, wid#, hei# / 2, hei# / 2);
971 currentpicture := remember_pic;
973 draw_staff (-2, 2, 0.5);
983 % Note: For whole and half notes, the `fill' curve (p_out) is offset from
984 % the points that specify the outer geometry, because we need to add
985 % the rounding. In contrast, the inner curve is not offset, because
986 % there is no rounding.
988 % This means that to get a line of thick_factor * pen_thickness,
989 % we need to offset the inner curve by
991 % (thick_factor - 0.5) * pen_thickness
995 % (2 * thick_factor - 1) * half_pen_thickness
997 save solfa_pen_thick;
998 solfa_pen_thick# = 1.3 stafflinethickness#;
999 define_blacker_pixels (solfa_pen_thick);
1001 save solfa_pen_radius;
1002 solfa_pen_radius = 0.5 solfa_pen_thick;
1004 save solfa_base_notewidth;
1005 solfa_base_notewidth# := black_notehead_width#;
1007 solfa_whole_width := 1.0;
1008 solfa_half_width := 1.0;
1009 solfa_quarter_width := 1.0;
1014 % Triangle with base parallel to staff lines.
1017 def draw_do_head (expr width_factor, dir, thickness_factor) =
1019 save left_dist, right_dist, bottom_dist;
1021 pair left_dist, right_dist, bottom_dist;
1023 set_char_box (0, width_factor * solfa_base_notewidth#,
1024 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1026 bottom_thick_factor := 2 * thickness_factor - 1;
1027 % no different thickness for left side if we want uniform thickness
1028 if thickness_factor = 1:
1029 left_thick_factor := 1;
1031 left_thick_factor := 0.7 * bottom_thick_factor;
1035 pen_radius := min (solfa_pen_radius,
1036 (h + d) / (3 * (1 + bottom_thick_factor)));
1038 pickup pencircle scaled (2 * pen_radius);
1047 left_dist = (unitvector (z3 - z1) rotated 90) * pen_radius;
1048 right_dist = (unitvector (z2 - z3) rotated 90) * pen_radius;
1049 bottom_dist = (0,1) * pen_radius;
1053 save point_a, point_b, point_c;
1054 pair point_a, point_b, point_c;
1056 pa := (z1 - left_thick_factor * left_dist)
1057 -- (z3 - left_thick_factor * left_dist);
1058 pb := (z1 + bottom_thick_factor * bottom_dist)
1059 -- (z2 + bottom_thick_factor * bottom_dist);
1060 pc := (z2 - right_dist)
1061 -- (z3 - right_dist);
1063 point_a := pa intersectionpoint pb;
1064 point_b := pb intersectionpoint pc;
1065 point_c := pc intersectionpoint pa;
1075 .. (z2 + right_dist){z3 - z2}
1076 -- (z3 + right_dist){z3 - z2}
1078 .. (z3 + left_dist){z1 - z3}
1079 -- (z1 + left_dist){z1 - z3}
1086 charwy := -chardp + 0.5 stafflinethickness#;
1096 fet_beginchar ("Whole dohead", "s0do");
1097 draw_do_head (solfa_whole_width, 1, do_weight);
1103 fet_beginchar ("Half dohead", "d1do");
1104 draw_do_head (solfa_half_width, -1, do_weight);
1110 fet_beginchar ("Half dohead", "u1do");
1111 draw_do_head (solfa_half_width, 1, do_weight);
1117 fet_beginchar ("Quarter dohead", "d2do");
1118 draw_do_head (solfa_quarter_width, -1, do_weight);
1123 fet_beginchar ("Quarter dohead", "u2do");
1124 draw_do_head (solfa_quarter_width, 1, do_weight);
1129 fet_beginchar ("Whole thin dohead", "s0doThin");
1130 draw_do_head (solfa_whole_width, 1, 1);
1136 fet_beginchar ("Half thin dohead", "d1doThin");
1137 draw_do_head (solfa_half_width, -1, 1);
1143 fet_beginchar ("Half thin dohead", "u1doThin");
1144 draw_do_head (solfa_half_width, 1, 1);
1150 fet_beginchar ("Quarter thin dohead", "d2doThin");
1151 draw_do_head (solfa_quarter_width, -1, 1);
1156 fet_beginchar ("Quarter thin dohead", "u2doThin");
1157 draw_do_head (solfa_quarter_width, 1, 1);
1163 % re - flat top, curved bottom:
1167 % .. {dir 90} (w,h/2)
1170 % (broader along the base and with more vertical sides for half and
1173 % Note: According to some shape-note singers, there should be no size
1174 % differences for half and whole notes, contrary to the comment above.
1175 % Consequently, we have made them all the same width.
1177 % stem attachment: h/2
1179 def draw_re_head (expr width_factor, dir, thickness_factor) =
1183 set_char_box (0, width_factor * solfa_base_notewidth#,
1184 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1187 offset = (2 * thickness_factor - 1);
1194 pen_radius := min (solfa_pen_radius,
1195 (h + d) * (1-curve_start) / (1+ offset));
1197 pickup pencircle scaled (2 * pen_radius);
1202 y2 = curve_start [y3, y1];
1210 labels (range 1 thru 5);
1212 p_in := (z1 + pen_radius * (1, -1 * offset))
1214 .. ((top z3) + (0, offset * pen_radius))
1216 -- (z5 + pen_radius * (-1, -1 * offset))
1229 charwy := curve_start [-chardp, charht];
1240 fet_beginchar ("Whole rehead", "s0re");
1241 draw_re_head (solfa_whole_width, 1, re_weight);
1247 fet_beginchar ("Half up rehead", "u1re");
1248 draw_re_head (solfa_half_width, 1, re_weight);
1254 fet_beginchar ("Half down rehead", "d1re");
1255 draw_re_head (solfa_half_width, -1, re_weight);
1261 fet_beginchar ("Quarter up rehead", "u2re");
1262 draw_re_head (solfa_quarter_width, 1, re_weight);
1267 fet_beginchar ("Quarter down rehead", "d2re");
1268 draw_re_head (solfa_quarter_width, -1, re_weight);
1273 fet_beginchar ("Whole thin rehead", "s0reThin");
1274 draw_re_head (solfa_whole_width, 1, 1);
1280 fet_beginchar ("Half up thin rehead", "u1reThin");
1281 draw_re_head (solfa_half_width, 1, 1);
1287 fet_beginchar ("Half down thin rehead", "d1reThin");
1288 draw_re_head (solfa_half_width, -1, 1);
1294 fet_beginchar ("Quarter thin rehead", "u2reThin");
1295 draw_re_head (solfa_quarter_width, 1, 1);
1300 fet_beginchar ("Quarter thin rehead", "d2reThin");
1301 draw_re_head (solfa_quarter_width, -1, 1);
1306 %%%% mi head -- diamond shape
1308 % two versions, depending on whether the `strong' lines are on the nw & se
1311 def draw_mi_head (expr width_factor, thickness_factor, mirror) =
1312 save path_out, path_in;
1313 save ne_dist, se_dist, ne, se;
1314 save path_a, path_b, path_c, path_d;
1315 path path_out, path_in;
1316 pair ne_dist, se_dist, ne, se;
1317 path path_a, path_b, path_c, path_d;
1321 set_char_box (0, width_factor * solfa_base_notewidth#,
1322 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1325 offset := 2 * thickness_factor - 1;
1329 note_diagonal := w / 2 ++ (h + d) / 2;
1333 pen_radius := min (solfa_pen_radius,
1334 .3 * note_diagonal / (1 + offset));
1336 pickup pencircle scaled (2 * pen_radius);
1347 % inner sides are parallel to outer sides
1348 z6 - z5 = whatever * (z2 - z1);
1349 z8 - z7 = whatever * (z4 - z3);
1350 z8 - z5 = whatever * (z4 - z1);
1351 z7 - z6 = whatever * (z3 - z2);
1353 ne = unitvector (z4 - z1);
1354 se = unitvector (z2 - z1);
1356 ne_dist = (ne rotated 90) * pen_radius;
1357 se_dist = (se rotated 90) * pen_radius;
1359 path_a := (z1 + se_dist)
1361 path_b := (z2 + (ne_dist * offset))
1362 -- (z3 + (ne_dist * offset));
1363 path_c := (z3 - se_dist)
1365 path_d := (z4 - (ne_dist * offset))
1366 -- (z1 - (ne_dist * offset));
1368 z5 = path_a intersectionpoint path_d;
1369 z7 = path_b intersectionpoint path_c;
1371 labels (range 1 thru 8);
1380 path_in := inner_path;
1382 path_in := inner_path reflectedabout (z2, z4);
1385 path_out := lft z1 {down}
1386 .. (z1 - se_dist){se}
1387 -- (z2 - se_dist){se}
1389 .. (z2 - ne_dist){ne}
1390 -- (z3 - ne_dist){ne}
1392 .. (z3 + se_dist){-se}
1393 -- (z4 + se_dist){-se}
1395 .. (z4 + ne_dist){-ne}
1396 -- (z1 + ne_dist){-ne}
1401 save mi_weight, mi_width;
1405 fet_beginchar ("Whole mihead", "s0mi");
1406 draw_mi_head (mi_width * solfa_whole_width, mi_weight, false);
1412 fet_beginchar ("Half mihead", "s1mi");
1413 draw_mi_head (mi_width * solfa_quarter_width, mi_weight, false);
1419 fet_beginchar ("Quarter mihead", "s2mi");
1420 draw_mi_head (mi_width * solfa_quarter_width, mi_weight, false);
1425 fet_beginchar ("Whole mirror mihead", "s0miMirror");
1426 draw_mi_head (mi_width * solfa_whole_width, mi_weight, true);
1432 fet_beginchar ("Half mirror mihead", "s1miMirror");
1433 draw_mi_head (mi_width * solfa_quarter_width, mi_weight, true);
1439 fet_beginchar ("Quarter mirror mihead", "s2miMirror");
1440 draw_mi_head (mi_width * solfa_quarter_width, mi_weight, true);
1445 fet_beginchar ("Whole thin mihead", "s0miThin");
1446 draw_mi_head (mi_width * solfa_whole_width, 1, false);
1452 fet_beginchar ("Half thin mihead", "s1miThin");
1453 draw_mi_head (mi_width * solfa_quarter_width, 1, false);
1459 fet_beginchar ("Quarter thin mihead", "s2miThin");
1460 draw_mi_head (mi_width * solfa_quarter_width, 1, false);
1467 % Right triangle, hypotenuse from nw to se corner. Stem attaches on
1468 % vertical side in direction of horizontal side.
1470 def draw_fa_head (expr width_factor, thickness_factor) =
1471 set_char_box (0, width_factor * solfa_base_notewidth#,
1472 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1474 save p_down_in, p_down_out, p_up_in, p_up_out, nw_dist, nw;
1475 path p_down_in, p_down_out, p_up_in, p_up_out;
1476 save path_a, path_b, path_c;
1477 path path_a, path_b, path_c;
1481 offset := 2 * thickness_factor - 1;
1484 pen_radius := min (solfa_pen_radius,
1485 .33 * (h + d) / (1 + offset));
1487 pickup pencircle scaled (2 * pen_radius);
1500 labels (1, 2, 3, 4);
1502 nw = unitvector (z1 - z3);
1503 nw_dist = (nw rotated 90) * pen_radius;
1505 path_a := (z1 - (0,1) * offset * pen_radius)
1506 -- (z2 - (0,1) * offset * pen_radius);
1507 path_b := (z2 - (1,0) * pen_radius)
1508 -- (z3 - (1,0) * pen_radius);
1509 path_c := (z3 - nw_dist)
1512 p_up_in := (path_a intersectionpoint path_b)
1513 -- (path_b intersectionpoint path_c)
1514 -- (path_c intersectionpoint path_a)
1517 p_up_out := lft z1{down}
1518 .. (z1 + nw_dist){-nw}
1519 -- (z3 + nw_dist){-nw}
1527 p_down_in := p_up_in rotated 180 shifted (w, 0);
1528 p_down_out := p_up_out rotated 180 shifted (w, 0);
1537 fet_beginchar ("Whole fa up head", "u0fa");
1538 draw_fa_head (solfa_whole_width, fa_weight);
1544 fet_beginchar ("Whole fa down head", "d0fa");
1545 draw_fa_head (solfa_whole_width, fa_weight);
1551 fet_beginchar ("half fa up head", "u1fa");
1552 draw_fa_head (solfa_half_width, fa_weight);
1558 fet_beginchar ("Half fa down head", "d1fa");
1559 draw_fa_head (solfa_half_width, fa_weight);
1565 fet_beginchar ("Quarter fa up head", "u2fa");
1566 draw_fa_head (solfa_quarter_width, fa_weight);
1571 fet_beginchar ("Quarter fa down head", "d2fa");
1572 draw_fa_head (solfa_quarter_width, fa_weight);
1577 fet_beginchar ("Whole thin fa up head", "u0faThin");
1578 draw_fa_head (solfa_whole_width, 1);
1584 fet_beginchar ("Whole thin fa down head", "d0faThin");
1585 draw_fa_head (solfa_whole_width, 1);
1591 fet_beginchar ("half thin fa up head", "u1faThin");
1592 draw_fa_head (solfa_half_width, 1);
1598 fet_beginchar ("Half thin fa down head", "d1faThin");
1599 draw_fa_head (solfa_half_width, 1);
1605 fet_beginchar ("Quarter thin fa up head", "u2faThin");
1606 draw_fa_head (solfa_quarter_width, 1);
1611 fet_beginchar ("Quarter thin fa down head", "d2faThin");
1612 draw_fa_head (solfa_quarter_width, 1);
1620 % Note: sol head is the same shape as a standard music head, and doesn't
1621 % vary from style to style. However, width is constant with duration,
1622 % so we can't just use the standard note font.
1624 def draw_sol_head (expr filled) =
1625 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34, 0.66, 0.17);
1627 undraw_inside_ellipse (3.25, 33, 0.81, 2.5 stafflinethickness#);
1629 draw_staff (-2, 2, 0);
1632 fet_beginchar ("Whole solhead", "s0sol");
1633 draw_sol_head ( false);
1637 fet_beginchar ("Half solhead", "s1sol");
1638 draw_sol_head ( false);
1642 fet_beginchar ("Quarter solhead", "s2sol");
1643 draw_sol_head ( true);
1651 def draw_la_head (expr width_factor, thickness_factor) =
1652 set_char_box (0, width_factor * solfa_base_notewidth#,
1653 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1658 offset := 2 * thickness_factor - 1;
1661 pen_radius := min (solfa_pen_radius,
1662 .35 * (h + d) / (1 + offset));
1664 pickup pencircle scaled (2 * pen_radius);
1677 labels (range 1 thru 4);
1679 p_in := (z1 + pen_radius * (1, -offset))
1680 -- (z2 + pen_radius * (-1, -offset))
1681 -- (z3 + pen_radius * (-1, offset))
1682 -- (z4 + pen_radius * (1, offset))
1700 fet_beginchar ("Whole lahead", "s0la");
1701 draw_la_head (solfa_whole_width, la_weight);
1707 fet_beginchar ("Half lahead", "s1la");
1708 draw_la_head (solfa_half_width, la_weight);
1714 fet_beginchar ("Quarter lahead", "s2la");
1715 draw_la_head (solfa_quarter_width, la_weight);
1720 fet_beginchar ("Whole thin lahead", "s0laThin");
1721 draw_la_head (solfa_whole_width, 1);
1727 fet_beginchar ("Half thin lahead", "s1laThin");
1728 draw_la_head (solfa_half_width, 1);
1734 fet_beginchar ("Quarter lahead", "s2laThin");
1735 draw_la_head (solfa_quarter_width, 1);
1742 % `Snow-cone', V with rounded top.
1744 def draw_ti_head (expr width_factor, dir, thickness_factor) =
1745 set_char_box (0, width_factor * solfa_base_notewidth#,
1746 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1747 save p_in, p_out, p_top, p_top_in;
1748 path p_in, p_out, p_top, p_top_in;
1753 offset := 2 * thickness_factor - 1;
1756 pen_radius := min (solfa_pen_radius,
1757 .4 * (h + d) / (1 + offset));
1759 pickup pencircle scaled (2 * pen_radius);
1764 y2 = cone_height [y1, y3];
1770 y5 = y1 + offset * pen_radius;
1772 labels (range 1 thru 4);
1774 save nw_dist, sw_dist, nw, sw;
1775 pair nw_dist, sw_dist, nw, sw;
1777 nw = unitvector (z2 - z1);
1778 sw = unitvector (z1 - z4);
1780 nw_dist = (nw rotated 90) * pen_radius;
1781 sw_dist = (sw rotated 90) * pen_radius;
1783 p_top := (z2 + nw * pen_radius)
1785 .. (z4 - sw * pen_radius);
1787 p_top_in := (z2 - nw * offset * pen_radius)
1788 .. (z3 - (0,1) * pen_radius) {right}
1789 .. (z4 + sw * offset * pen_radius);
1791 save path_a, path_b;
1792 path path_a, path_b;
1798 z6 = path_a intersectionpoint p_top_in;
1799 z7 = path_b intersectionpoint p_top_in;
1811 .. (z2 + nw * pen_radius){direction 0 of p_top}
1813 & {direction infinity of p_top}(z4 - sw * pen_radius)
1820 charwy := cone_height [-chardp, charht];
1830 fet_beginchar ("Whole up tihead", "s0ti");
1831 draw_ti_head (solfa_whole_width, 1, ti_weight);
1837 fet_beginchar ("Half up tihead", "u1ti");
1838 draw_ti_head (solfa_half_width, 1, ti_weight);
1844 fet_beginchar ("Half down tihead", "d1ti");
1845 draw_ti_head (solfa_half_width, -1, ti_weight);
1851 fet_beginchar ("Quarter up tihead", "u2ti");
1852 draw_ti_head (solfa_quarter_width, 1, ti_weight);
1857 fet_beginchar ("Quarter down tihead", "d2ti");
1858 draw_ti_head (solfa_quarter_width, -1, ti_weight);
1863 fet_beginchar ("Whole thin up tihead", "s0tiThin");
1864 draw_ti_head (solfa_whole_width, 1, 1);
1870 fet_beginchar ("Half thin up tihead", "u1tiThin");
1871 draw_ti_head (solfa_half_width, 1, 1);
1877 fet_beginchar ("Half thin down tihead", "d1tiThin");
1878 draw_ti_head (solfa_half_width, -1, 1);
1884 fet_beginchar ("Quarter thin up tihead", "u2tiThin");
1885 draw_ti_head (solfa_quarter_width, 1, 1);
1890 fet_beginchar ("Quarter thin down tihead", "d2tiThin");
1891 draw_ti_head (solfa_quarter_width, -1, 1);
1896 %%%%%% Funk shape note heads
1898 % Funk heads are narrower than Aiken and Sacred Harp, so we need a new
1901 funk_notehead_width := 0.75;
1905 % Parabolic on one side, vertical line on other
1906 % Has up and down shapes for *all* notes
1908 def draw_Funk_do_head (expr width_factor, thickness_factor) =
1909 set_char_box (0, width_factor * solfa_base_notewidth#,
1910 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1913 offset := 2 * thickness_factor - 1;
1916 pen_radius := min (solfa_pen_radius,
1917 .3 * (h + d) / (1 + offset));
1919 pickup pencircle scaled (2 * pen_radius);
1930 x4 = x1 - pen_radius;
1931 y4 = y1 + offset * pen_radius;
1934 x5 = x2 + pen_radius;
1937 y6 = y3 - offset * pen_radius;
1939 save p_up_in, p_up_out, p_down_in, p_down_out;
1940 path p_up_in, p_up_out, p_down_in, p_down_out;
1942 p_down_in := z4{left}
1947 p_down_out := bot z1{left}
1954 p_up_in := p_down_in rotated 180 shifted (w,0);
1955 p_up_out := p_down_out rotated 180 shifted (w,0);
1960 save funk_do_weight;
1961 funk_do_weight := 1.7;
1963 fet_beginchar ("Whole up Funk dohead", "u0doFunk");
1964 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1970 fet_beginchar ("Whole down Funk dohead", "d0doFunk");
1971 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1977 fet_beginchar ("Half up Funk dohead", "u1doFunk");
1978 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1984 fet_beginchar ("Half down Funk dohead", "d1doFunk");
1985 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1991 fet_beginchar ("Quarter up Funk dohead", "u2doFunk");
1992 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1997 fet_beginchar ("Quarter down Funk dohead", "d2doFunk");
1998 draw_Funk_do_head (funk_notehead_width, funk_do_weight);
2005 % Has up and down shapes for *all* notes
2007 def draw_Funk_re_head (expr width_factor, thickness_factor) =
2008 set_char_box (0, width_factor * solfa_base_notewidth#,
2009 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2012 offset := 2 * thickness_factor - 1;
2015 pen_radius := min (solfa_pen_radius,
2016 .3 * (h + d) / (1 + offset));
2018 pickup pencircle scaled (2 * pen_radius);
2029 x3 := curve_in [x1, x2];
2037 save ne, se, ne_perp, se_perp;
2038 pair ne, se, ne_perp, se_perp;
2040 ne := unitvector (z2 - z1);
2041 se := unitvector (z4 - z1);
2042 ne_perp := ne rotated 90;
2043 se_perp := se rotated 90;
2045 save path_a, path_b, path_c, path_d;
2046 path path_a, path_b, path_c, path_d;
2047 save arrow_a_perp, arrow_b_perp;
2048 pair arrow_a_perp, arrow_b_perp;
2051 path_d := z2 .. z3{down} .. z4;
2052 arrow_a_perp = unitvector (direction 0 of path_d rotated 90)
2054 arrow_b_perp = unitvector (direction 2 of path_d rotated 90)
2057 path_b := (z1 + se_perp * pen_radius)
2058 -- z4 + se_perp * offset * pen_radius;
2059 path_a := (z1 - ne_perp * pen_radius)
2060 -- z2 - ne_perp * offset * pen_radius;
2061 path_c := z2 - arrow_a_perp
2063 .. z4 - arrow_b_perp;
2065 z5 = path_a intersectionpoint path_b;
2066 z7 = path_a intersectionpoint path_c;
2067 z8 = path_b intersectionpoint path_c;
2069 save p_up_in, p_down_in, p_up_out, p_down_out;
2070 path p_up_in, p_down_in, p_up_out, p_down_out;
2078 p_down_out := lft z1{up}
2079 .. (z1 + ne_perp * pen_radius){ne}
2080 -- (z2 + ne_perp * pen_radius){ne}
2083 .. (z2 + arrow_a_perp)
2085 .. (z4 + arrow_b_perp)
2088 .. z4 - se_perp * pen_radius
2089 -- z1 - se_perp * pen_radius
2092 p_up_in := p_down_in rotated 180 shifted (w, 0);
2093 p_up_out := p_down_out rotated 180 shifted (w, 0);
2098 save funk_re_weight;
2099 funk_re_weight = 1.7;
2101 fet_beginchar ("Whole up Funk rehead", "u0reFunk");
2102 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2108 fet_beginchar ("Whole down Funk rehead", "d0reFunk");
2109 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2115 fet_beginchar ("Half up Funk rehead", "u1reFunk");
2116 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2122 fet_beginchar ("Half down Funk rehead", "d1reFunk");
2123 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2129 fet_beginchar ("Quarter up Funk rehead", "u2reFunk");
2130 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2135 fet_beginchar ("Quarter down Funk rehead", "d2reFunk");
2136 draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2143 % Has up and down shapes for all hollow notes
2145 save funk_mi_width, funk_mi_weight;
2146 funk_mi_width := 1.2;
2147 funk_mi_weight := 1.9;
2149 fet_beginchar ("Whole up Funk mihead", "u0miFunk");
2150 draw_mi_head (funk_mi_width * funk_notehead_width,
2151 funk_mi_weight, false);
2157 fet_beginchar ("Whole down Funk mihead", "d0miFunk");
2158 draw_mi_head (funk_mi_width * funk_notehead_width,
2159 funk_mi_weight, true);
2165 fet_beginchar ("Half up Funk mihead", "u1miFunk");
2166 draw_mi_head (funk_mi_width * funk_notehead_width,
2167 funk_mi_weight, false);
2173 fet_beginchar ("Half down Funk mihead", "d1miFunk");
2174 draw_mi_head (funk_mi_width * funk_notehead_width,
2175 funk_mi_weight, true);
2181 fet_beginchar ("Quarter Funk mihead", "s2miFunk");
2182 draw_mi_head (funk_mi_width * funk_notehead_width,
2183 funk_mi_weight, false);
2190 % Does it rotate for whole notes?
2191 % Same as other shape note systems
2192 % Need special notes because of special width
2194 save funk_fa_weight;
2195 funk_fa_weight := 1.9;
2197 fet_beginchar ("Whole up Funk fahead", "u0faFunk");
2198 draw_fa_head (funk_notehead_width, funk_fa_weight);
2204 fet_beginchar ("Whole down Funk fahead", "d0faFunk");
2205 draw_fa_head (funk_notehead_width, funk_fa_weight);
2211 fet_beginchar ("Half up Funk fahead", "u1faFunk");
2212 draw_fa_head (funk_notehead_width, funk_fa_weight);
2218 fet_beginchar ("Half down Funk fahead", "d1faFunk");
2219 draw_fa_head (funk_notehead_width, funk_fa_weight);
2225 fet_beginchar ("Quarter up Funk fahead", "u2faFunk");
2226 draw_fa_head (funk_notehead_width, funk_fa_weight);
2231 fet_beginchar ("Quarter down Funk fahead", "d2faFunk");
2232 draw_fa_head (funk_notehead_width, funk_fa_weight);
2237 %%%%%% Funk sol head is the same as the others
2238 % Need special character because of skinnier head
2240 def draw_Funk_sol_head (expr filled) =
2243 noteheight# := solfa_noteheight#;
2244 draw_outside_ellipse (1.2, 34, 0.71, 0.);
2246 undraw_inside_ellipse (1.9, 33, 0.74, 5.5 stafflinethickness#);
2248 draw_staff (-2, 2, 0);
2253 fet_beginchar ("Whole Funk solhead", "s0solFunk");
2254 draw_Funk_sol_head ( false);
2258 fet_beginchar ("Half Funk solhead", "s1solFunk");
2259 draw_Funk_sol_head ( false);
2263 fet_beginchar ("Quarter Funk solhead", "s2solFunk");
2264 draw_Funk_sol_head ( true);
2270 % Same as for other shape notes
2271 % Smaller width requires special characters
2273 save funk_la_weight;
2274 funk_la_weight := 1.9;
2276 fet_beginchar ("Whole Funk lahead", "s0laFunk");
2277 draw_la_head (funk_notehead_width, funk_notehead_width);
2283 fet_beginchar ("Half Funk lahead", "s1laFunk");
2284 draw_la_head (funk_notehead_width, funk_notehead_width);
2290 fet_beginchar ("Quarter Funk lahead", "s2laFunk");
2291 draw_la_head (funk_notehead_width, funk_notehead_width);
2297 % `Sideways snow cone'.
2298 % Rotates for all notes.
2300 def draw_Funk_ti_head (expr width_factor, thickness_factor) =
2301 set_char_box (0, width_factor * solfa_base_notewidth#,
2302 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2307 offset := 2 * thickness_factor - 1;
2310 pen_radius := min (solfa_pen_radius,
2311 .33 * (h + d) / (1 + offset));
2313 pickup pencircle scaled (2 * pen_radius);
2318 x2 = cone_width [x1, x3];
2327 save nw_dist, sw_dist, ne, se;
2328 pair nw_dist, sw_dist, ne, se;
2330 ne = unitvector (z2 - z1);
2331 se = unitvector (z4 - z1);
2333 nw_dist = (ne rotated 90) * pen_radius ;
2334 sw_dist = (se rotated -90) * pen_radius;
2336 save path_a, path_b;
2337 path path_a, path_b;
2338 path_a := z1 - nw_dist
2339 -- z2 - offset * nw_dist;
2340 path_b := z1 - sw_dist
2341 -- z4 - offset * sw_dist;
2343 save path_right, path_right_in;
2344 path path_right, path_right_in;
2345 path_right := (z2 + ne * pen_radius)
2347 .. (z4 + se * pen_radius);
2349 path_right_in := (z2 - ne * pen_radius)
2351 .. (z4 - se * pen_radius);
2353 z5 = path_a intersectionpoint path_b;
2354 z6 = path_a intersectionpoint path_right_in;
2355 z7 = path_b intersectionpoint path_right_in;
2357 save p_up_in, p_down_in, p_up_out, p_down_out;
2358 path p_up_in, p_down_in, p_up_out, p_down_out;
2366 p_down_out := lft z1
2370 .. (z2 + ne * pen_radius){direction 0 of path_right}
2372 & {direction infinity of path_right}(z4 + se * pen_radius)
2378 p_up_in := p_down_in rotated 180 shifted (w, 0);
2379 p_up_out := p_down_out rotated 180 shifted (w, 0);
2383 save funk_ti_weight;
2384 funk_ti_weight := 1.6;
2386 fet_beginchar ("Whole up Funk tihead", "u0tiFunk");
2387 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2393 fet_beginchar ("Whole down Funk tihead", "d0tiFunk");
2394 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2400 fet_beginchar ("Half up Funk tihead", "u1tiFunk");
2401 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2407 fet_beginchar ("Half down Funk tihead", "d1tiFunk");
2408 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2414 fet_beginchar ("Quarter up Funk tihead", "u2tiFunk");
2415 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2420 fet_beginchar ("Quarter down Funk tihead", "d2tiFunk");
2421 draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2426 %%%%%% Walker shape note heads
2428 % Walker heads are narrow like Funk heads, so use funk_notehead_width.
2431 %%%%%% Walker do head
2433 % Trapezoid, with largest side on stem side
2435 def draw_Walker_do_head (expr width_factor, dir, thickness_factor) =
2436 set_char_box (0, width_factor * solfa_base_notewidth#,
2437 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2439 pickup pencircle scaled solfa_pen_thick;
2442 offset := 2 * thickness_factor - 1;
2444 % adjust width so stem can be centered
2445 if .5w <> good.x .5w: change_width; fi
2449 scaling# = charwd / w;
2454 x1 = inset [x4, x3];
2457 x2 = inset [x3, x4];
2466 labels (range 1 thru 4);
2468 save left_dir, left_perp, right_dir, right_perp;
2469 pair left_dir, left_perp, right_dir, right_perp;
2471 left_dir = unitvector(z1 - z4);
2472 left_perp = (left_dir rotated 90) * solfa_pen_radius;
2473 right_dir = unitvector(z3 - z2);
2474 right_perp = (right_dir rotated 90) * solfa_pen_radius;
2476 save path_a, path_b, path_c, path_d;
2477 path path_a, path_b, path_c, path_d;
2479 path_a := (z4 - left_perp)
2480 -- (z1 - left_perp);
2481 path_b := (z1 - (0, offset*solfa_pen_radius))
2482 -- (z2 - (0, offset*solfa_pen_radius));
2483 path_c := (z2 - right_perp)
2484 -- (z3 - right_perp);
2485 path_d := (z3 + (0, offset*solfa_pen_radius))
2486 -- (z4 + (0, offset*solfa_pen_radius));
2491 p_in := (path_a intersectionpoint path_b)
2492 -- (path_b intersectionpoint path_c)
2493 -- (path_c intersectionpoint path_d)
2494 -- (path_d intersectionpoint path_a)
2497 p_out := top z1{right}
2499 .. z2 + right_perp {right_dir}
2500 -- z3 + right_perp {right_dir}
2503 .. z4 + left_perp {left_dir}
2504 .. z1 + left_perp {left_dir}
2507 charwx := scaling# * (w/2 + solfa_pen_radius);
2508 charwy := scaling# * y2 ;
2511 p_in := p_in rotated 180 shifted (w,0);
2512 p_out := p_out rotated 180 shifted (w,0);
2517 save walker_do_weight;
2518 walker_do_weight := 1.5;
2520 fet_beginchar ("Whole Walker dohead", "s0doWalker");
2521 draw_Walker_do_head (funk_notehead_width, 0, walker_do_weight);
2527 fet_beginchar ("Half up Walker dohead", "u1doWalker");
2528 draw_Walker_do_head (funk_notehead_width, 1, walker_do_weight);
2534 fet_beginchar ("Half down Walker dohead", "d1doWalker");
2535 draw_Walker_do_head (funk_notehead_width, 0, walker_do_weight);
2541 fet_beginchar ("Quarter up Walker dohead", "u2doWalker");
2542 draw_Walker_do_head (funk_notehead_width, 1, walker_do_weight);
2547 fet_beginchar ("Quarter down Walker dohead", "d2doWalker");
2548 draw_Walker_do_head (funk_notehead_width, 0, walker_do_weight);
2553 %%%%%% Walker re head
2554 % Parabolic on one side, shallow parabola on other
2555 % Has up and down shapes for *all* notes
2557 def draw_Walker_re_head (expr width_factor, thickness_factor) =
2558 set_char_box (0, width_factor * solfa_base_notewidth#,
2559 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2562 offset := 2 * thickness_factor - 1;
2565 pen_radius := min (solfa_pen_radius,
2566 .3 * (h + d) / (1 + offset));
2568 pickup pencircle scaled (2 * pen_radius);
2571 dish_factor := 0.20;
2582 x4 = dish_factor [x1, x2];
2586 y5 = y1 + offset * pen_radius;
2589 x6 = x2 + pen_radius;
2592 y7 = y3 - offset * pen_radius;
2595 x8 = x4 - pen_radius;
2597 save path_a, path_d;
2598 path path_a, path_d;
2600 save p_a_start_dir, p_a_end_dir, p_a_start_perp, p_a_end_perp;
2601 pair p_a_start_dir, p_a_end_dir, p_a_start_perp, p_a_end_perp;
2603 path_a := z3 .. z4{down} .. z1;
2605 p_a_start_dir := unitvector(direction 0 of path_a);
2606 p_a_end_dir := unitvector(direction infinity of path_a);
2607 p_a_start_perp := (p_a_start_dir rotated 90) * pen_radius;
2608 p_a_end_perp := (p_a_end_dir rotated 90) * pen_radius;
2610 path_d := (z3 - p_a_start_perp){p_a_start_dir}
2612 ..(z1 - p_a_end_perp){p_a_end_dir};
2614 save path_b, path_c;
2615 path path_b, path_c;
2617 path_b := z5 {left} .. z6{up};
2618 path_c := z7 {left} .. z6{down};
2620 z9 = path_d intersectionpoint path_b;
2621 z10 = path_d intersectionpoint path_c;
2623 labels (range 1 thru 4);
2625 save p_up_in, p_up_out, p_down_in, p_down_out;
2626 path p_up_in, p_up_out, p_down_in, p_down_out;
2629 ... {right} z10 {p_a_start_dir}
2631 .. {p_a_end_dir} z9 {left}
2634 p_down_out := lft z2{up}
2637 .. (z3 + p_a_start_perp){p_a_start_dir}
2639 .. (z1 + p_a_end_perp) {p_a_end_dir}
2644 p_up_in := p_down_in rotated 180 shifted (w,0);
2645 p_up_out := p_down_out rotated 180 shifted (w,0);
2649 save walker_re_weight;
2650 walker_re_weight := 1.2;
2652 fet_beginchar ("Whole Walker rehead", "s0reWalker");
2653 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2659 fet_beginchar ("Half up Walker rehead", "u1reWalker");
2660 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2666 fet_beginchar ("Half down Walker rehead", "d1reWalker");
2667 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2673 fet_beginchar ("Quarter up Walker rehead", "u2reWalker");
2674 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2679 fet_beginchar ("Quarter down Walker rehead", "d2reWalker");
2680 draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2685 %%%%%% Walker mi head
2687 % Symmetric for all hollow notes
2689 save walker_mi_width, walker_mi_weight;
2690 walker_mi_width := 1.2;
2691 walker_mi_weight := 1.5;
2693 fet_beginchar ("Whole Walker mihead", "s0miWalker");
2694 draw_mi_head (walker_mi_width * funk_notehead_width,
2695 walker_mi_weight, true);
2701 fet_beginchar ("Half Walker mihead", "s1miWalker");
2702 draw_mi_head (walker_mi_width * funk_notehead_width,
2703 walker_mi_weight, true);
2709 fet_beginchar ("Quarter Walker mihead", "s2miWalker");
2710 draw_mi_head (walker_mi_width * funk_notehead_width,
2711 walker_mi_weight, true);
2718 % Does not rotate for whole notes
2719 % Whole rotation is different from Funk, so special notes
2721 %%%%%% Funk sol head is the same as the others
2722 % Need special character because of skinnier head
2724 save walker_fa_weight;
2725 walker_fa_weight := 1.5;
2727 fet_beginchar ("Whole Walker fahead", "s0faWalker");
2728 draw_fa_head (funk_notehead_width, walker_fa_weight);
2734 fet_beginchar ("Half up Walker fahead", "u1faWalker");
2735 draw_fa_head (funk_notehead_width, walker_fa_weight);
2741 fet_beginchar ("Half down Walker fahead", "d1faWalker");
2742 draw_fa_head (funk_notehead_width, walker_fa_weight);
2748 fet_beginchar ("Quarter up Walker fahead", "u2faWalker");
2749 draw_fa_head (funk_notehead_width, walker_fa_weight);
2754 fet_beginchar ("Quarter down Walker fahead", "d2faWalker");
2755 draw_fa_head (funk_notehead_width, walker_fa_weight);
2761 % Same as Funk, no special notes
2764 %%%%%% Walker la head
2766 % Lighter weight requires separate notes
2768 save walker_la_weight;
2769 walker_la_weight := 1.5;
2771 fet_beginchar ("Whole Walker lahead", "s0laWalker");
2772 draw_la_head (funk_notehead_width, walker_la_weight);
2778 fet_beginchar ("Half Funk lahead", "s1laWalker");
2779 draw_la_head (funk_notehead_width, walker_la_weight);
2785 fet_beginchar ("Quarter Funk lahead", "s2laWalker");
2786 draw_la_head (funk_notehead_width, walker_la_weight);
2791 %%%%%% Walker ti head
2792 % Triangular arrowhead
2793 % Rotates for all but whole notes
2795 def draw_Walker_ti_head (expr width_factor, thickness_factor) =
2796 set_char_box (0, width_factor * solfa_base_notewidth#,
2797 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2800 offset := 2 * thickness_factor - 1;
2803 pen_radius := min (solfa_pen_radius,
2804 .3 * (h + d) / (1 + offset));
2806 pickup pencircle scaled (2 * pen_radius);
2818 labels (range 1 thru 4);
2820 save nw_dist, sw_dist, ne, se;
2821 pair nw_dist, sw_dist, ne, se;
2823 ne = unitvector (z2 - z1);
2824 se = unitvector (z3 - z1);
2826 nw_dist = (ne rotated 90) * pen_radius ;
2827 sw_dist = (se rotated -90) * pen_radius;
2830 save path_a, path_b, path_c;
2831 path path_a, path_b, path_c;
2832 path_a := z2 - nw_dist * offset
2833 -- z1 - nw_dist * offset;
2834 path_b := z3 - sw_dist * offset
2835 -- z1 - sw_dist * offset;
2836 path_c := z2 + left * pen_radius
2837 -- z3 + left * pen_radius;
2839 z4 = path_a intersectionpoint path_b;
2840 z5 = path_a intersectionpoint path_c;
2841 z6 = path_b intersectionpoint path_c;
2843 save p_up_in, p_down_in, p_up_out, p_down_out;
2844 path p_up_in, p_down_in, p_up_out, p_down_out;
2851 p_down_out := lft z1{up}
2852 .. (z1 + nw_dist){ne}
2853 -- (z2 + nw_dist){ne}
2858 .. (z3 + sw_dist){- se}
2859 .. (z1 + sw_dist){- se}
2862 p_up_in := p_down_in rotated 180 shifted (w, 0);
2863 p_up_out := p_down_out rotated 180 shifted (w, 0);
2867 save walker_ti_weight;
2868 walker_ti_weight := 1.4;
2870 fet_beginchar ("Whole Walker tihead", "s0tiWalker");
2871 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2877 fet_beginchar ("Half up Walker tihead", "u1tiWalker");
2878 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2884 fet_beginchar ("Half down Walker tihead", "d1tiWalker");
2885 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2891 fet_beginchar ("Quarter up Walker tihead", "u2tiWalker");
2892 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2897 fet_beginchar ("Quarter down Walker tihead", "d2tiWalker");
2898 draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2902 fet_endgroup ("noteheads");
2906 % we derive black_notehead_width# from the quarter head,
2907 % so we have to define black_notehead_width (pixel qty)
2908 % after the black_notehead_width# itself.
2910 % Let's keep it outside the group as well.
2913 define_pixels (black_notehead_width);