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--2010 Jan Nieuwenhuizen <janneke@gnu.org>
5 % & Han-Wen Nienhuys <hanwen@xs4all.nl>
6 % & Juergen Reuter <reuter@ipd.uka.de>
9 % LilyPond is free software: you can redistribute it and/or modify
10 % it under the terms of the GNU General Public License as published by
11 % the Free Software Foundation, either version 3 of the License, or
12 % (at your option) any later version.
14 % LilyPond is distributed in the hope that it will be useful,
15 % but WITHOUT ANY WARRANTY; without even the implied warranty of
16 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 % GNU General Public License for more details.
19 % You should have received a copy of the GNU General Public License
20 % along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
29 % Most beautiful noteheads are pronounced, not circular,
30 % and not even symmetric.
31 % These examples are inspired by [Wanske]; see literature list.
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 save black_notehead_width, noteheight;
40 save half_notehead_width, whole_notehead_width, slash_thick;
41 save slash_slope, overdone_heads, solfa_noteheight;
45 numeric black_notehead_width;
46 numeric whole_notehead_width;
47 numeric half_notehead_width;
50 fet_begingroup ("noteheads");
53 % Slope of slash. From scm/grob-description.scm. How to auto-copy?
56 % Thickness of slash lines. Quarter notes get 1.5slt width.
57 slash_thick# := 2/3 * 0.48 staff_space#;
61 % Hand-engraved music often has balls extending above and below
62 % the lines. If you like that, modify overdone heads (unit:
63 % stafflinethickness).
66 noteheight# := staff_space# + (1 + overdone_heads) * stafflinethickness#;
70 % solfa heads should not overlap on chords.
72 solfa_noteheight# := staff_space# - stafflinethickness#;
74 define_pixels (slash_thick);
75 define_whole_vertical_pixels (noteheight);
78 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80 % SLANT moves both extrema on the long axis (by SLANT * ELLIPTICITY,
81 % so SLANT = -1, puts the extreme on the long axis next to the short
85 def draw_outside_ellipse (expr ellipticity, tilt, superness, slant) =
90 pat := superellipse ((ellipticity, 0), (-slant * ellipticity, 1.0),
91 (-ellipticity, 0), (slant * ellipticity, -1.0),
93 pat := pat rotated tilt;
95 save top_point, right_point;
96 pair top_point, right_point;
98 top_point := directionpoint left of pat;
99 right_point := directionpoint up of pat;
103 scaling# = noteheight# / (2 ypart (top_point));
104 width# := 2 xpart (right_point) * scaling#;
105 define_pixels (scaling, width);
107 set_char_box (0, width#, noteheight# / 2, noteheight# / 2);
109 d := d - feta_space_shift;
112 charwy := ypart (right_point) * scaling#;
115 pat := pat scaled scaling shifted (w / 2, .5 (h - d));
117 width := hround width;
119 if test_outlines = 1:
127 def undraw_inside_ellipse (expr ellipticity, tilt, superness, clearance) =
132 pat := superellipse ((ellipticity, 0), (0, 1.0),
133 (-ellipticity, 0), (0, -1.0),
135 pat := pat rotated tilt;
137 save top_point, right_point;
138 pair top_point, right_point;
140 top_point := directionpoint left of pat;
141 right_point := directionpoint up of pat;
143 save height, scaling;
145 height# = staff_space# + stafflinethickness# - clearance;
146 scaling# = height# / (2 ypart (top_point));
147 define_pixels (scaling);
148 pat := pat scaled scaling shifted (w / 2, .5 (h - d));
150 if test_outlines = 1:
160 % dimensions aren't entirely right.
162 def draw_longa (expr up) =
163 save stemthick, fudge;
165 stemthick# = 2 stafflinethickness#;
166 define_whole_blacker_pixels (stemthick);
168 fudge = hround (blot_diameter / 2);
170 draw_outside_ellipse (1.80, 0, 0.707, 0);
171 undraw_inside_ellipse (1.30, 125, 0.68, 2 stafflinethickness#);
173 pickup pencircle scaled stemthick;
183 top y4 = h + 3.0 staff_space;
186 bot y1 = -d - 3.0 staff_space;
197 draw_gridline (z1, z2, stemthick);
198 draw_gridline (z3, z4, stemthick);
204 fet_beginchar ("Longa notehead", "uM2");
207 draw_staff (-2, 2, 0);
210 fet_beginchar ("Longa notehead", "dM2");
213 draw_staff (-2, 2, 0);
218 fet_beginchar ("Longa notehead", "uM2");
221 draw_staff (-2, 2, 0.5);
224 fet_beginchar ("Longa notehead", "dM2");
227 draw_staff (-2, 2, 0.5);
233 % dimensions aren't entirely right.
235 def draw_brevis (expr linecount) =
236 save stemthick, fudge;
238 stemthick# = 2 stafflinethickness#;
239 define_whole_blacker_pixels (stemthick);
241 fudge = hround (blot_diameter / 2);
243 draw_outside_ellipse (1.80, 0, 0.707, 0);
244 undraw_inside_ellipse (1.30, 125, 0.68, 2 stafflinethickness#);
246 pickup pencircle scaled stemthick;
258 for i := 0 step 1 until linecount - 1:
259 draw_gridline (z1 - (1.5 * i * stemthick, 0),
260 z2 - (1.5 * i * stemthick, 0), stemthick);
261 draw_gridline (z3 + (1.5 * i * stemthick, 0),
262 z4 + (1.5 * i * stemthick, 0), stemthick);
267 fet_beginchar ("Brevis notehead", "sM1");
270 draw_staff (-2, 2, 0);
275 fet_beginchar ("Brevis notehead", "sM1");
278 draw_staff (-2, 2, 0.5);
283 fet_beginchar ("Double-lined brevis notehead", "sM1double");
286 draw_staff (-2, 2, 0);
291 fet_beginchar ("Double-lined brevis notehead", "sM1double");
294 draw_staff (-2, 2, 0.5);
299 fet_beginchar ("Whole notehead", "s0");
300 draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0, 0.707, 0);
301 undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10,
302 0.68, 2 stafflinethickness#);
304 whole_notehead_width# := charwd;
306 draw_staff (-2, 2, 0);
311 fet_beginchar ("Whole notehead", "s0");
312 draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0,
314 undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10,
315 0.68, 2 stafflinethickness#);
317 draw_staff (-2, 2, 0.5);
322 fet_beginchar ("Half notehead", "s1");
323 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34, 0.66, 0.17);
324 undraw_inside_ellipse (3.25, 33, 0.81, 2.5 stafflinethickness#);
326 half_notehead_width# := charwd;
328 draw_staff (-2, 2, 0);
333 fet_beginchar ("Half notehead", "s1");
334 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34,
336 undraw_inside_ellipse (3.25, 33, 0.81,
337 2.5 stafflinethickness#);
339 draw_staff (-2, 2, 0.5);
344 fet_beginchar ("Quart notehead", "s2");
345 % used to have 32. With 31, they are slightly bolder.
346 draw_outside_ellipse (1.49 - puff_up_factor / 3.0, 31, 0.707, 0);
347 black_notehead_width# := charwd;
349 draw_staff (-2, 2, 0);
354 fet_beginchar ("Quart notehead", "s2");
355 draw_outside_ellipse (1.49 - puff_up_factor / 3.0, 31,
358 draw_staff (-2, 2, 0.5);
363 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
366 fet_beginchar ("Whole diamondhead", "s0diamond");
367 draw_outside_ellipse (1.80, 0, 0.495, 0);
368 undraw_inside_ellipse (1.30, 125, 0.6,
369 .4 staff_space# + stafflinethickness#);
371 draw_staff (-2, 2, 0);
376 fet_beginchar ("Whole diamondhead", "s0diamond");
377 draw_outside_ellipse (1.80, 0, 0.495, 0);
378 undraw_inside_ellipse (1.30, 125, 0.6,
379 .4 staff_space# + stafflinethickness#);
381 draw_staff (-2, 2, 0.5);
386 fet_beginchar ("Half diamondhead", "s1diamond");
387 draw_outside_ellipse (1.50, 34, 0.49, 0.17);
388 undraw_inside_ellipse (3.5, 33, 0.80,
389 .3 staff_space# + 1.5 stafflinethickness#);
391 draw_staff (-2, 2, 0);
396 fet_beginchar ("Half diamondhead", "s1diamond");
397 draw_outside_ellipse (1.50, 34, 0.49, 0.17);
398 undraw_inside_ellipse (3.5, 33, 0.80,
400 + 1.5 stafflinethickness#);
402 draw_staff (-2, 2, 0.5);
407 fet_beginchar ("Quart diamondhead", "s2diamond");
408 draw_outside_ellipse (1.80, 35, 0.495, -0.25);
410 draw_staff (-2, 2, 0);
415 fet_beginchar ("Quart diamondhead", "s2diamond");
416 draw_outside_ellipse (1.80, 35, 0.495, -0.25);
418 draw_staff (-2, 2, 0.5);
423 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
426 vardef penposx@# (expr d) =
436 z@#l = pat intersectionpoint (z@# -- infinity * dir (d + 180));
437 z@#r = pat intersectionpoint (z@# -- infinity * dir (d));
443 % UGH: xs not declared as argument.
445 def define_triangle_shape (expr stemdir) =
446 save triangle_a, triangle_b, triangle_c;
447 save triangle_out_a, triangle_out_b, triangle_out_c;
448 save triangle_in, triangle_out;
449 save width, depth, height;
450 save origin, left_up_dir;
451 save exact_left_point, exact_right_point, exact_down_point;
453 path triangle_a, triangle_b, triangle_c;
454 path triangle_out_a, triangle_out_b, triangle_out_c;
455 path triangle_in, triangle_out;
456 pair origin, left_up_dir;
457 pair exact_down_point, exact_left_point, exact_right_point;
460 pen_thick# = stafflinethickness# + .1 staff_space#;
461 define_pixels (llap);
462 define_blacker_pixels (pen_thick);
464 left_up_dir = llap# * dir (90 + tilt);
466 xpart (left_up_dir) * xs - (pen_thick# * xs) / 2 + xpart origin = 0;
469 exact_left_point := origin + (left_up_dir xscaled xs);
470 exact_down_point := origin + (left_up_dir rotated 120 xscaled xs);
471 exact_right_point := origin + (left_up_dir rotated 240 xscaled xs);
473 height# = ypart (exact_left_point + origin) + pen_thick# / 2;
474 depth# = -ypart (exact_down_point + origin) + pen_thick# / 2;
475 width# = xpart (exact_right_point - exact_left_point)
478 set_char_box (0, width#, depth#, height#);
480 % Formerly, the shape has simply been drawn with an elliptical pen
481 % (`scaled pen_thick xscaled xs'), but the envelope of such a curve
482 % is of 6th degree. For the sake of mf2pt1, we approximate it.
484 pickup pencircle scaled pen_thick xscaled xs;
486 z0 = (hround_pixels (xpart origin), 0);
488 z1 = z1' = z0 + llap * dir (90 + tilt) xscaled xs;
489 z2 = z2' = z0 + llap * dir (90 + tilt + 120) xscaled xs;
490 z3 = z3' = z0 + llap * dir (90 + tilt + 240) xscaled xs;
492 z12 = caveness [.5[z1, z2], z3];
493 z23 = caveness [.5[z2, z3], z1];
494 z31 = caveness [.5[z3, z1], z2];
496 triangle_a = z1 .. z12 .. z2;
497 triangle_b = z2 .. z23 .. z3;
498 triangle_c = z3 .. z31 .. z1;
500 penposx1 (angle (direction 0 of triangle_a) - 90);
501 penposx2 (angle (direction 0 of triangle_b) - 90);
502 penposx3 (angle (direction 0 of triangle_c) - 90);
504 penposx1' (angle (direction infinity of triangle_c) + 90);
505 penposx2' (angle (direction infinity of triangle_a) + 90);
506 penposx3' (angle (direction infinity of triangle_b) + 90);
508 penposx12 (angle (z12 - z0));
509 penposx23 (angle (z23 - z0));
510 penposx31 (angle (z31 - z0));
512 z10 = (z0 -- z1) intersectionpoint (z1l .. z12l .. z2'r);
513 z20 = (z0 -- z2) intersectionpoint (z2l .. z23l .. z3'r);
514 z30 = (z0 -- z3) intersectionpoint (z3l .. z31l .. z1'r);
527 triangle_out_a = z1r .. z12r .. z2'l;
528 triangle_out_b = z2r .. z23r .. z3'l;
529 triangle_out_c = z3r .. z31r .. z1'l;
531 triangle_out = top z1
533 .. z1r{direction 0 of triangle_out_a}
535 & {direction infinity of triangle_out_a}z2'l
538 .. z2r{direction 0 of triangle_out_b}
540 & {direction infinity of triangle_out_b}z3'l
543 .. z3r{direction 0 of triangle_out_c}
545 & {direction infinity of triangle_out_c}z1'l
548 labels (0, 10, 20, 30);
549 penlabels (1, 1', 2, 2', 3, 3', 12, 23, 31);
553 charwy := ypart exact_right_point;
554 charwx := xpart exact_right_point + .5 pen_thick# * xs;
556 charwy := -ypart exact_down_point;
557 charwx := width# - (xpart exact_down_point - .5 pen_thick# * xs);
562 def draw_whole_triangle_head =
568 llap# = 3/4 noteheight#;
572 define_triangle_shape (1);
578 fet_beginchar ("Whole trianglehead", "s0triangle");
579 draw_whole_triangle_head;
581 draw_staff (-2, 2, 0);
586 fet_beginchar ("Whole trianglehead", "s0triangle");
587 draw_whole_triangle_head;
589 draw_staff (-2, 2, 0.5);
594 def draw_small_triangle_head (expr dir) =
600 llap# = 2/3 noteheight#;
603 define_triangle_shape (dir);
607 filldraw triangle_out;
608 unfilldraw triangle_in;
612 fet_beginchar ("Half trianglehead (downstem)", "d1triangle");
613 draw_small_triangle_head (-1);
615 draw_staff (-2, 2, 0);
619 fet_beginchar ("Half trianglehead (upstem)", "u1triangle");
620 draw_small_triangle_head (1);
622 draw_staff (-2, 2, 0.5);
626 def draw_closed_triangle_head (expr dir) =
632 llap# = 2/3 noteheight#;
635 define_triangle_shape (dir);
640 fet_beginchar ("Quart trianglehead (upstem)", "u2triangle");
641 draw_closed_triangle_head (1);
643 draw_staff (-2, 2, 0);
647 fet_beginchar ("Quart trianglehead (downstem)", "d2triangle");
648 draw_closed_triangle_head (-1);
650 draw_staff (-2, 2, 0.5);
654 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
656 % Slash heads are for indicating improvisation. They are
657 % twice as high as normal heads.
659 def draw_slash (expr hwid_hash) =
663 exact_height = staff_space# + stafflinethickness# / 2;
665 set_char_box (0, 2 exact_height / slash_slope + hwid_hash,
666 exact_height, exact_height);
675 pickup pencircle scaled blot_diameter;
680 lft x2 = 2 h / slash_slope;
687 ne = unitvector (z3 - z4);
688 nw_dist = (ne rotated 90) * 0.5 blot_diameter;
691 .. (z1 + nw_dist){ne}
692 -- (z2 + nw_dist){ne}
695 .. (z3 - nw_dist){-ne}
696 -- (z4 - nw_dist){-ne}
700 if hwid_hash > 2 slash_thick#:
703 th = slash_thick - blot_diameter;
708 z6 - z5 = whatever * ne;
709 z8 - z7 = whatever * ne;
711 z5 = z1 + whatever * ne + th * (ne rotated -90);
712 z8 = z4 + whatever * ne + th * (ne rotated 90);
720 labels (range 1 thru 10);
724 fet_beginchar ("Whole slashhead", "s0slash");
725 draw_slash (4 slash_thick# + 0.5 staff_space#);
727 draw_staff (-2, 2, 0);
731 fet_beginchar ("Half slashhead", "s1slash");
732 draw_slash (3.0 slash_thick# + 0.15 staff_space#);
734 draw_staff (-2, 2, 0);
738 fet_beginchar ("Quart slashhead", "s2slash");
739 draw_slash (1.5 slash_thick#);
741 draw_staff (-2, 2, 0);
745 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
747 % `thick' is the distance between the NE/SW parallel lines in the cross
748 % (distance between centres of lines) in multiples of stafflinethickness
750 def draw_cross (expr thick) =
752 save ne_dist, nw_dist, rt_dist, up_dist;
753 save crz_in, crz_out;
756 pair ne_dist, nw_dist, rt_dist, up_dist;
757 path crz_in, crz_out;
759 pen_thick# := 1.2 stafflinethickness#;
760 thickness# := thick * stafflinethickness#;
761 define_pixels (thickness);
762 define_blacker_pixels (pen_thick);
764 pickup pencircle scaled pen_thick;
769 ne = unitvector ((1, (2 h - pen_thick) / (w - pen_thick)));
772 z4 - z5 = whatever * ne;
774 z6 - z3 = whatever * ne;
775 z3 - z4 = whatever * (ne yscaled -1);
777 z4 - z3 = whatever * (ne) + (ne rotated -90) * thickness;
780 x1 = charwd / 2 - .5 pen_thick#;
782 + thick / 2 * stafflinethickness# * (ne rotated -90);
784 % labels (1, 2, 3, 4, 5, 6);
786 nw = unitvector (z3 - z4);
788 up_dist = up * 0.5 pen_thick / cosd (angle (ne));
789 rt_dist = right * 0.5 pen_thick / sind (angle (ne));
790 nw_dist = (ne rotated 90) * 0.5 pen_thick;
791 ne_dist = (nw rotated -90) * 0.5 pen_thick;
797 x4 := hround (x4' + .5 pen_thick) - .5 pen_thick;
798 x5 := hfloor (x5' + xpart rt_dist) - xpart rt_dist;
799 y6 := vfloor (y6' + ypart up_dist) - ypart up_dist;
801 crz_out = (z6 + up_dist)
802 -- (z3 + nw_dist){ne}
804 .. (z3 + ne_dist){-nw}
805 -- (z4 + ne_dist){-nw}
807 .. (z4 - nw_dist){-ne}
809 crz_out := crz_out shifted (0, feta_shift)
810 -- reverse crz_out yscaled -1 shifted (0, -feta_eps);
812 -- reverse crz_out xscaled -1 shifted (-feta_eps, 0)
816 x4 := hround (x4' - xpart rt_dist) + xpart rt_dist;
817 x5 := hceiling (x5' - .5 pen_thick) + .5 pen_thick;
818 y6 := vfloor (y6' - .5 pen_thick) + .5 pen_thick;
820 crz_in = (bot z6){right}
821 .. (z6 - nw_dist){ne}
824 -- (z5 + nw_dist){-ne}
826 crz_in := crz_in shifted (0, feta_shift)
827 -- reverse crz_in yscaled -1 shifted (0, -feta_eps);
829 -- reverse crz_in xscaled -1 shifted (-feta_eps, 0)
834 currentpicture := currentpicture shifted (hround (w / 2), 0);
837 charwy := y1 + feta_shift;
839 z12 = (charwx * hppp, y1 * vppp);
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);
855 remember_pic := currentpicture;
857 draw_staff (-2, 2, 0);
862 fet_beginchar ("Whole Crossed notehead", "s0cross");
865 wid# := black_notehead_width# + 4 stafflinethickness#;
866 hei# := noteheight# + stafflinethickness#;
868 set_char_box (0, wid#, hei# / 2, hei# / 2);
870 currentpicture := remember_pic;
872 draw_staff (-2, 2, 0.5);
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);
887 remember_pic := currentpicture;
889 draw_staff (-2, 2, 0);
894 fet_beginchar ("Half Crossed notehead", "s1cross");
897 wid# := black_notehead_width# + 2 stafflinethickness#;
898 hei# := noteheight# + stafflinethickness# / 2;
900 set_char_box (0, wid#, hei# / 2, hei# / 2);
902 currentpicture := remember_pic;
904 draw_staff (-2, 2, 0.5);
909 fet_beginchar ("Crossed notehead", "s2cross");
910 wid# := black_notehead_width#;
912 set_char_box (0, wid#, hei# / 2, hei# / 2);
916 remember_pic := currentpicture;
918 draw_staff (-2, 2, 0);
923 fet_beginchar ("Crossed notehead", "s2cross");
924 wid# := black_notehead_width#;
926 set_char_box (0, wid#, hei# / 2, hei# / 2);
928 currentpicture := remember_pic;
930 draw_staff (-2, 2, 0.5);
935 fet_beginchar ("X-Circled notehead", "s2xcircle");
937 save cthick, cxd, cyd, dy;
939 wid# := black_notehead_width# * sqrt (sqrt2);
940 hei# := noteheight# * sqrt (sqrt2);
942 set_char_box (0, wid#, hei# / 2, hei# / 2);
944 d := d - feta_space_shift;
946 cthick# := (1.2 + 1/4) * stafflinethickness#;
947 define_blacker_pixels (cthick);
950 cyd := h + d - cthick / 2;
954 pickup pencircle scaled cthick;
956 fill fullcircle xscaled (cxd + cthick)
957 yscaled (cyd + cthick)
959 unfill fullcircle xscaled (cxd - cthick)
960 yscaled (cyd - cthick)
963 xpos := .5 cxd / sqrt2;
964 ypos := .5 cyd / sqrt2;
966 pickup penrazor scaled cthick rotated (angle (xpos, ypos) + 90);
967 draw (-xpos + w / 2, -ypos + dy) -- (xpos + w / 2, ypos + dy);
969 pickup penrazor scaled cthick rotated (angle (xpos, -ypos) + 90);
970 draw (-xpos + w / 2, ypos + dy) -- (xpos + w / 2, -ypos + dy);
975 z12 = (charwx * hppp, charwy * vppp);
978 remember_pic := currentpicture;
980 draw_staff (-2, 2, 0);
985 fet_beginchar ("X-Circled notehead", "s2xcircle");
987 save cthick, cxr, cyr;
989 wid# := black_notehead_width# * sqrt (sqrt2);
990 hei# := noteheight# * sqrt (sqrt2);
992 set_char_box (0, wid#, hei# / 2, hei# / 2);
994 currentpicture := remember_pic;
996 draw_staff (-2, 2, 0.5);
1003 % SOLFA SHAPED NOTES
1006 save solfa_pen_thick;
1007 solfa_pen_thick# = 1.3 stafflinethickness#;
1008 define_blacker_pixels (solfa_pen_thick);
1011 save solfa_base_notewidth;
1012 solfa_base_notewidth# := black_notehead_width#;
1014 solfa_whole_width := 1.0;
1015 solfa_half_width := 1.0;
1016 solfa_quarter_width := 1.0;
1018 def draw_do_head (expr width_factor, dir, thickness_factor) =
1020 save left_dist, right_dist, bottom_dist;
1022 pair left_dist, right_dist, bottom_dist;
1024 set_char_box (0, width_factor * solfa_base_notewidth#,
1025 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1027 pickup pencircle scaled solfa_pen_thick;
1030 bottom_thick_factor := thickness_factor;
1031 % no different thickness for left side if we want uniform thickness
1032 left_thick_factor := if thickness_factor = 1 :
1035 0.7 * thickness_factor;
1044 left_dist = (unitvector (z3 - z1) rotated 90) * 0.5 solfa_pen_thick;
1045 right_dist = (unitvector (z2 - z3) rotated 90) * 0.5 solfa_pen_thick;
1046 bottom_dist = (0,1) * 0.5 solfa_pen_thick;
1050 save point_a, point_b, point_c;
1051 pair point_a, point_b, point_c;
1053 pa := (z1 - left_thick_factor * left_dist) --
1054 (z3 - left_thick_factor * left_dist);
1055 pb := (z1 + bottom_thick_factor * bottom_dist) --
1056 (z2 + bottom_thick_factor * bottom_dist);
1057 pc := (z2 - right_dist) -- (z3 - right_dist);
1060 point_a := pa intersectionpoint pb;
1061 point_b := pb intersectionpoint pc;
1062 point_c := pc intersectionpoint pa;
1064 p_in := point_a -- point_b -- point_c -- cycle;
1069 .. (z2 + right_dist){z3 - z2}
1070 -- (z3 + right_dist){z3 - z2}
1072 .. (z3 + left_dist){z1 - z3}
1073 -- (z1 + left_dist){z1 - z3}
1080 charwy := -chardp + 0.5 stafflinethickness#;
1087 fet_beginchar ("Whole dohead", "s0do");
1088 draw_do_head (solfa_whole_width, 1, 3.25);
1094 fet_beginchar ("Half dohead", "d1do");
1095 draw_do_head (solfa_half_width, -1, 3.25);
1101 fet_beginchar ("Half dohead", "u1do");
1102 draw_do_head (solfa_half_width, 1, 3.25);
1108 fet_beginchar ("Quart dohead", "d2do");
1109 draw_do_head (solfa_quarter_width, -1, 3.25);
1114 fet_beginchar ("Quart dohead", "u2do");
1115 draw_do_head (solfa_quarter_width, 1, 3.25);
1121 fet_beginchar ("Whole thin dohead", "s0doThin");
1122 draw_do_head (solfa_whole_width, 1, 1);
1128 fet_beginchar ("Half thin dohead", "d1doThin");
1129 draw_do_head (solfa_half_width, -1, 1);
1135 fet_beginchar ("Half thin dohead", "u1doThin");
1136 draw_do_head (solfa_half_width, 1, 1);
1142 fet_beginchar ("Quart thin dohead", "d2doThin");
1143 draw_do_head (solfa_quarter_width, -1, 1);
1148 fet_beginchar ("Quart thin dohead", "u2doThin");
1149 draw_do_head (solfa_quarter_width, 1, 1);
1156 % re - flat top, curved bottom:
1157 % (0,h/2) {dir -90} .. (w/2,-h/2) .. {dir 90} (w,h/2) -- cycle;
1158 % (broader along the base and with more vertical sides for half and
1161 % Note: According to some shape-note singers, there should be no size
1162 % differences for half and whole notes, contrary to the comment above
1164 % stem attachment: h/2
1167 def draw_re_head (expr width_factor, dir, thickness_factor) =
1171 set_char_box (0, width_factor * solfa_base_notewidth#,
1172 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1174 pickup pencircle scaled solfa_pen_thick;
1182 y2 = curve_start [y3, y1];
1190 labels (range 1 thru 5);
1192 p_in := (z1 + 0.5 solfa_pen_thick * (1, -1 * thickness_factor))
1194 .. ((top z3) + (0, thickness_factor * 0.5 solfa_pen_thick))
1196 -- (z5 + 0.5 solfa_pen_thick * (-1, -1 * thickness_factor))
1209 charwy := curve_start [-chardp, charht];
1217 fet_beginchar ("Whole rehead", "s0re");
1218 draw_re_head (solfa_whole_width, 1, 2.5);
1224 fet_beginchar ("Half up rehead", "u1re");
1225 draw_re_head (solfa_half_width, 1, 2.5);
1231 fet_beginchar ("Half down rehead", "d1re");
1232 draw_re_head (solfa_half_width, -1, 2.5);
1238 fet_beginchar ("Quart rehead", "u2re");
1239 draw_re_head (solfa_quarter_width, 1, 2.5);
1244 fet_beginchar ("Quart rehead", "d2re");
1245 draw_re_head (solfa_quarter_width, -1, 2.5);
1250 fet_beginchar ("Whole thin rehead", "s0reThin");
1251 draw_re_head (solfa_whole_width, 1, 1);
1257 fet_beginchar ("Half up thin rehead", "u1reThin");
1258 draw_re_head (solfa_half_width, 1, 1);
1264 fet_beginchar ("Half down thin rehead", "d1reThin");
1265 draw_re_head (solfa_half_width, -1, 1);
1271 fet_beginchar ("Quart thin rehead", "u2reThin");
1272 draw_re_head (solfa_quarter_width, 1, 1);
1277 fet_beginchar ("Quart thin rehead", "d2reThin");
1278 draw_re_head (solfa_quarter_width, -1, 1);
1285 %%%% mi head -- diamond shape
1287 def draw_mi_head (expr width_factor, thickness_factor, mirror) =
1288 save path_out, path_in;
1289 save ne_dist, se_dist, ne, se;
1290 save path_a, path_b, path_c, path_d;
1291 path path_out, path_in;
1292 pair ne_dist, se_dist, ne, se;
1293 path path_a, path_b, path_c, path_d;
1297 set_char_box (0, width_factor * solfa_base_notewidth#,
1298 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1300 pickup pencircle scaled solfa_pen_thick;
1311 % inner sides are parallel to outer sides
1312 z6 - z5 = whatever * (z2 - z1);
1313 z8 - z7 = whatever * (z2 - z1);
1314 z8 - z5 = whatever * (z4 - z1);
1315 z6 - z7 = whatever * (z4 - z1);
1317 ne = unitvector (z4 - z1);
1318 se = unitvector (z1 - z2);
1320 ne_dist = (ne rotated 90) * 0.5 solfa_pen_thick;
1321 se_dist = (se rotated 90) * 0.5 solfa_pen_thick;
1323 path_a := (z1 - se_dist) -- (z2 - se_dist);
1324 path_b := (z2 + (ne_dist * thickness_factor)) --
1325 (z3 + (ne_dist * thickness_factor));
1326 path_c := (z3 + se_dist) -- (z4 + se_dist);
1327 path_d := (z4 - (ne_dist * thickness_factor)) --
1328 (z1 - (ne_dist * thickness_factor));
1330 z5 = path_a intersectionpoint path_d;
1331 z7 = path_b intersectionpoint path_c;
1333 labels (range 1 thru 8);
1341 path_in := if mirror:
1344 inner_path reflectedabout (z2, z4);
1348 .. (z1 + se_dist){-se}
1349 -- (z2 + se_dist){-se}
1351 .. (z2 - ne_dist){ne}
1352 -- (z3 - ne_dist){ne}
1354 .. (z3 - se_dist){se}
1355 -- (z4 - se_dist){se}
1357 .. (z4 + ne_dist){-ne}
1358 -- (z1 + ne_dist){-ne}
1363 fet_beginchar ("Whole mihead", "s0mi");
1364 draw_mi_head (solfa_whole_width, 3, false);
1370 fet_beginchar ("Half mihead", "s1mi");
1371 draw_mi_head (solfa_quarter_width, 3, false);
1376 fet_beginchar ("Quart mihead", "s2mi");
1377 draw_mi_head (solfa_quarter_width, 3, false);
1383 fet_beginchar ("Whole mirror mihead", "s0miMirror");
1384 draw_mi_head (solfa_whole_width, 3, true);
1389 fet_beginchar ("Half mirror mihead", "s1miMirror");
1390 draw_mi_head (solfa_quarter_width, 3, true);
1395 fet_beginchar ("Quart mirror mihead", "s2miMirror");
1396 draw_mi_head (solfa_quarter_width, 3, true);
1402 fet_beginchar ("Whole thin mihead", "s0miThin");
1403 draw_mi_head (solfa_whole_width, 1, false);
1409 fet_beginchar ("Half thin mihead", "s1miThin");
1410 draw_mi_head (solfa_quarter_width, 1, false);
1416 fet_beginchar ("Quart thin mihead", "s2miThin");
1417 draw_mi_head (solfa_quarter_width, 1, false);
1425 def draw_fa_head (expr width_factor, thickness_factor) =
1426 set_char_box (0, width_factor * solfa_base_notewidth#,
1427 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1429 save p_down_in, p_down_out, p_up_in, p_up_out, nw_dist, nw;
1430 path p_down_in, p_down_out, p_up_in, p_up_out;
1431 save path_a, path_b, path_c;
1432 path path_a, path_b, path_c;
1435 pickup pencircle scaled solfa_pen_thick;
1448 labels (1, 2, 3, 4);
1450 nw = unitvector (z1 - z3);
1451 nw_dist = (nw rotated 90) * 0.5 solfa_pen_thick;
1453 path_a := (z1 - (0,1) * thickness_factor * solfa_pen_thick) --
1454 (z2 - (0,1) * thickness_factor * solfa_pen_thick);
1455 path_b := (z2 - (1,0) * 0.5 solfa_pen_thick) --
1456 (z3 - (1,0) * 0.5 solfa_pen_thick);
1457 path_c := (z3 - nw_dist) -- (z1 - nw_dist);
1459 p_up_in := (path_a intersectionpoint path_b) --
1460 (path_b intersectionpoint path_c) --
1461 (path_c intersectionpoint path_a) --
1464 p_up_out := lft z1{down}
1465 .. (z1 + nw_dist){-nw}
1466 -- (z3 + nw_dist){-nw}
1474 p_down_in := p_up_in rotated 180 shifted (w, 0);
1475 p_down_out := p_up_out rotated 180 shifted (w, 0);
1482 fet_beginchar ("Whole fa up head", "u0fa");
1483 draw_fa_head (solfa_whole_width, 1.5);
1489 fet_beginchar ("Whole fa down head", "d0fa");
1490 draw_fa_head (solfa_whole_width, 1.5);
1496 fet_beginchar ("half fa up head", "u1fa");
1497 draw_fa_head (solfa_half_width, 1.5);
1503 fet_beginchar ("Half fa down head", "d1fa");
1504 draw_fa_head (solfa_half_width, 1.5);
1510 fet_beginchar ("Quarter fa up head", "u2fa");
1511 draw_fa_head (solfa_quarter_width, 1.5);
1516 fet_beginchar ("Quarter fa down head", "d2fa");
1517 draw_fa_head (solfa_quarter_width, 1.5);
1522 fet_beginchar ("Whole thin fa up head", "u0faThin");
1523 draw_fa_head (solfa_whole_width, 1);
1529 fet_beginchar ("Whole thin fa down head", "d0faThin");
1530 draw_fa_head (solfa_whole_width, 1);
1536 fet_beginchar ("half thin fa up head", "u1faThin");
1537 draw_fa_head (solfa_half_width, 1);
1543 fet_beginchar ("Half thin fa down head", "d1faThin");
1544 draw_fa_head (solfa_half_width, 1);
1550 fet_beginchar ("Quarter thin fa up head", "u2faThin");
1551 draw_fa_head (solfa_quarter_width, 1);
1556 fet_beginchar ("Quarter thin fa down head", "d2faThin");
1557 draw_fa_head (solfa_quarter_width, 1);
1565 %% Note -- sol head is the same shape as a standard music
1566 %% head, and doesn't vary from style to style.
1567 %% However, width is constant with duration, so we
1568 %% can't just use the standard note font.
1570 def draw_sol_head (expr filled) =
1571 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34, 0.66, 0.17);
1573 undraw_inside_ellipse (3.25, 33, 0.81, 2.5 stafflinethickness#);
1575 draw_staff (-2, 2, 0);
1578 fet_beginchar ("Whole solhead", "s0sol");
1579 draw_sol_head ( false);
1583 fet_beginchar ("Half solhead", "s1sol");
1584 draw_sol_head ( false);
1588 fet_beginchar ("Quart solhead", "s2sol");
1589 draw_sol_head ( true);
1596 def draw_la_head (expr width_factor, thickness_factor) =
1597 set_char_box (0, width_factor * solfa_base_notewidth#,
1598 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1602 pickup pencircle scaled solfa_pen_thick;
1615 labels (range 1 thru 4);
1617 p_in := (z1 + 0.5 solfa_pen_thick * (1, -thickness_factor))
1618 -- (z2 + 0.5 solfa_pen_thick * (-1, -thickness_factor))
1619 -- (z3 + 0.5 solfa_pen_thick * (-1, thickness_factor))
1620 -- (z4 + 0.5 solfa_pen_thick * (1, thickness_factor))
1635 fet_beginchar ("Whole lahead", "s0la");
1636 draw_la_head (solfa_whole_width, 3);
1642 fet_beginchar ("Half lahead", "s1la");
1643 draw_la_head (solfa_half_width, 3);
1649 fet_beginchar ("Quart lahead", "s2la");
1650 draw_la_head (solfa_quarter_width, 3);
1655 fet_beginchar ("Whole thin lahead", "s0laThin");
1656 draw_la_head (solfa_whole_width, 1);
1662 fet_beginchar ("Half thin lahead", "s1laThin");
1663 draw_la_head (solfa_half_width, 1);
1669 fet_beginchar ("Quart lahead", "s2laThin");
1670 draw_la_head (solfa_quarter_width, 1);
1678 def draw_ti_head (expr width_factor, dir, thickness_factor) =
1679 set_char_box (0, width_factor * solfa_base_notewidth#,
1680 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1681 save p_in, p_out, p_top, p_top_in;
1682 save nw_dist, sw_dist, nw, sw;
1683 path p_in, p_out, p_top, p_top_in;
1684 pair nw_dist, sw_dist, nw, sw;
1688 pickup pencircle scaled solfa_pen_thick;
1693 y2 = cone_height [y1, y3];
1699 y5 = y1 + thickness_factor * 0.5 * solfa_pen_thick;
1701 labels (range 1 thru 4);
1703 nw = unitvector (z2 - z1);
1704 sw = unitvector (z1 - z4);
1706 nw_dist = (nw rotated 90) * 0.5 solfa_pen_thick;
1707 sw_dist = (sw rotated 90) * 0.5 solfa_pen_thick;
1709 p_top := (z2 - sw_dist)
1713 p_top_in := (z2 + sw_dist * thickness_factor) {- sw}
1714 .. ((top z3) - (0,1) * thickness_factor * 0.5 solfa_pen_thick) {right}
1715 .. (z4 + nw_dist * thickness_factor){- nw};
1717 save path_a, path_b;
1718 path path_a, path_b;
1722 z6 = path_a intersectionpoint p_top_in;
1723 z7 = path_b intersectionpoint p_top_in;
1725 p_in := z5 -- z6 .. bot z3 .. z7 -- cycle;
1731 .. (z2 - sw_dist){direction 0 of p_top}
1733 & {direction infinity of p_top}(z4 - nw_dist)
1740 charwy := cone_height [-chardp, charht];
1747 fet_beginchar ("Whole up tihead", "s0ti");
1748 draw_ti_head (solfa_whole_width, 1, 3);
1754 fet_beginchar ("Half up tihead", "u1ti");
1755 draw_ti_head (solfa_half_width, 1, 3);
1761 fet_beginchar ("Half down tihead", "d1ti");
1762 draw_ti_head (solfa_half_width, -1, 3);
1768 fet_beginchar ("Quart up tihead", "u2ti");
1769 draw_ti_head (solfa_quarter_width, 1, 3);
1774 fet_beginchar ("Quart down tihead", "d2ti");
1775 draw_ti_head (solfa_quarter_width, -1, 3);
1780 fet_beginchar ("Whole thin up tihead", "s0tiThin");
1781 draw_ti_head (solfa_whole_width, 1, 1);
1787 fet_beginchar ("Half thin up tihead", "u1tiThin");
1788 draw_ti_head (solfa_half_width, 1, 1);
1794 fet_beginchar ("Half thin down tihead", "d1tiThin");
1795 draw_ti_head (solfa_half_width, -1, 1);
1801 fet_beginchar ("Quart thin up tihead", "u2tiThin");
1802 draw_ti_head (solfa_quarter_width, 1, 1);
1807 fet_beginchar ("Quart thin down tihead", "d2tiThin");
1808 draw_ti_head (solfa_quarter_width, -1, 1);
1814 fet_endgroup ("noteheads");
1819 % we derive black_notehead_width# from the quarter head,
1820 % so we have to define black_notehead_width (pixel qty)
1821 % after the black_notehead_width# itself.
1823 % Let's keep it outside the group as well.
1826 define_pixels (black_notehead_width);