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--2009 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.75 stafflinethickness#;
1008 define_blacker_pixels (solfa_pen_thick);
1011 save solfa_base_notewidth;
1012 solfa_base_notewidth# := black_notehead_width#;
1014 solfa_whole_width := whole_notehead_width# / black_notehead_width#;
1015 solfa_half_width := half_notehead_width# / black_notehead_width#;
1016 solfa_quarter_width := 1.0;
1018 def draw_do_head (expr width_factor, dir) =
1020 save left_dist, right_dist;
1022 pair left_dist, right_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;
1036 left_dist = (unitvector (z3 - z1) rotated 90) * 0.5 solfa_pen_thick;
1037 right_dist = (unitvector (z2 - z3) rotated 90) * 0.5 solfa_pen_thick;
1039 p_in := (((z1 - left_dist) -- (z3 - left_dist)) intersectionpoint
1041 -- ((top z1 -- top z2) intersectionpoint
1042 ((z2 - right_dist) -- (z3 - right_dist)))
1043 -- (((z2 - right_dist) -- (z3 - right_dist)) intersectionpoint
1044 ((z1 - left_dist) -- (z3 - left_dist)))
1050 .. (z2 + right_dist){z3 - z2}
1051 -- (z3 + right_dist){z3 - z2}
1053 .. (z3 + left_dist){z1 - z3}
1054 -- (z1 + left_dist){z1 - z3}
1062 charwy := -chardp + 0.5 stafflinethickness#;
1069 fet_beginchar ("Whole dohead", "s0do");
1070 draw_do_head (solfa_whole_width, 1);
1076 fet_beginchar ("Half dohead", "d1do");
1077 draw_do_head (solfa_half_width, -1);
1083 fet_beginchar ("Half dohead", "u1do");
1084 draw_do_head (solfa_half_width, 1);
1090 fet_beginchar ("Quart dohead", "d2do");
1091 draw_do_head (solfa_quarter_width, -1);
1096 fet_beginchar ("Quart dohead", "u2do");
1097 draw_do_head (solfa_quarter_width, 1);
1103 % re - flat top, curved bottom:
1104 % (0,h/2) {dir -90} .. (w/2,-h/2) .. {dir 90} (w,h/2) -- cycle;
1105 % (broader along the base and with more vertical sides for half and
1107 % stem attachment: h/2
1110 def draw_re_head (expr width_factor, dir) =
1114 set_char_box (0, width_factor * solfa_base_notewidth#,
1115 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1117 pickup pencircle scaled solfa_pen_thick;
1124 y2 = curve_start [y3, y1];
1132 labels (range 1 thru 5);
1134 p_in := (z1 + 0.5 solfa_pen_thick * (1, -1))
1138 -- (z5 + 0.5 solfa_pen_thick * (-1, -1))
1151 charwy := curve_start [-chardp, charht];
1159 fet_beginchar ("Whole rehead", "s0re");
1160 draw_re_head (solfa_whole_width, 1);
1166 fet_beginchar ("Half up rehead", "u1re");
1167 draw_re_head (solfa_half_width, 1);
1173 fet_beginchar ("Half down rehead", "d1re");
1174 draw_re_head (solfa_half_width, -1);
1180 fet_beginchar ("Quart rehead", "u2re");
1181 draw_re_head (solfa_quarter_width, 1);
1186 fet_beginchar ("Quart rehead", "d2re");
1187 draw_re_head (solfa_quarter_width, -1);
1192 def draw_mi_head (expr width_factor) =
1193 save path_out, path_in;
1194 save ne_dist, se_dist, ne, se;
1195 path path_out, path_in;
1196 pair ne_dist, se_dist, ne, se;
1198 set_char_box (0, width_factor * solfa_base_notewidth#,
1199 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1201 pickup pencircle scaled solfa_pen_thick;
1212 z6 - z5 = whatever * (z2 - z1);
1213 z8 - z7 = whatever * (z2 - z1);
1214 z8 - z5 = whatever * (z4 - z1);
1215 z6 - z7 = whatever * (z4 - z1);
1217 ne = unitvector (z4 - z1);
1218 se = unitvector (z1 - z2);
1220 ne_dist = (ne rotated 90) * 0.5 solfa_pen_thick;
1221 se_dist = (se rotated 90) * 0.5 solfa_pen_thick;
1223 z5 = whatever [z1, z4] - ne_dist;
1224 z5 = whatever [z1, z2] - 1.5 se_dist;
1226 z5 - z1 = -(z7 - z3);
1228 labels (range 1 thru 8);
1237 .. (z1 + se_dist){-se}
1238 -- (z2 + se_dist){-se}
1240 .. (z2 - ne_dist){ne}
1241 -- (z3 - ne_dist){ne}
1243 .. (z3 - se_dist){se}
1244 -- (z4 - se_dist){se}
1246 .. (z4 + ne_dist){-ne}
1247 -- (z1 + ne_dist){-ne}
1252 fet_beginchar ("Whole mihead", "s0mi");
1253 draw_mi_head (solfa_whole_width);
1259 fet_beginchar ("Half mihead", "s1mi");
1260 draw_mi_head (solfa_quarter_width);
1266 fet_beginchar ("Quart mihead", "s2mi");
1267 draw_mi_head (solfa_quarter_width);
1272 def draw_fa_head (expr width_factor) =
1273 set_char_box (0, width_factor * solfa_base_notewidth#,
1274 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1276 save p_down_in, p_down_out, p_up_in, p_up_out, nw_dist, nw;
1277 path p_down_in, p_down_out, p_up_in, p_up_out;
1280 pickup pencircle scaled solfa_pen_thick;
1293 labels (1, 2, 3, 4);
1295 nw = unitvector (z1 - z3);
1296 nw_dist = (nw rotated 90) * 0.5 solfa_pen_thick;
1298 p_up_in := (((z1 - nw_dist) -- (z3 - nw_dist)) intersectionpoint
1300 -- (((z1 - nw_dist) -- (z3 - nw_dist)) intersectionpoint
1302 -- (z2 + 0.5 solfa_pen_thick * (-1, -1))
1305 p_up_out := lft z1{down}
1306 .. (z1 + nw_dist){-nw}
1307 -- (z3 + nw_dist){-nw}
1315 p_down_in := p_up_in rotated 180 shifted (w, 0);
1316 p_down_out := p_up_out rotated 180 shifted (w, 0);
1323 fet_beginchar ("Whole fa up head", "u0fa");
1324 draw_fa_head (solfa_whole_width);
1330 fet_beginchar ("Whole fa down head", "d0fa");
1331 draw_fa_head (solfa_whole_width);
1337 fet_beginchar ("half fa up head", "u1fa");
1338 draw_fa_head (solfa_half_width);
1344 fet_beginchar ("Half fa down head", "d1fa");
1345 draw_fa_head (solfa_half_width);
1351 fet_beginchar ("Quarter fa up head", "u2fa");
1352 draw_fa_head (solfa_quarter_width);
1357 fet_beginchar ("Quarter fa down head", "d2fa");
1358 draw_fa_head (solfa_quarter_width);
1363 def draw_la_head (expr width_factor) =
1364 set_char_box (0, width_factor * solfa_base_notewidth#,
1365 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1369 pickup pencircle scaled solfa_pen_thick;
1382 labels (range 1 thru 4);
1384 p_in := (z1 + 0.5 solfa_pen_thick * (1, -1))
1385 -- (z2 + 0.5 solfa_pen_thick * (-1, -1))
1386 -- (z3 + 0.5 solfa_pen_thick * (-1, 1))
1387 -- (z4 + 0.5 solfa_pen_thick * (1, 1))
1402 fet_beginchar ("Whole lahead", "s0la");
1403 draw_la_head (solfa_whole_width);
1409 fet_beginchar ("Half lahead", "s1la");
1410 draw_la_head (solfa_half_width);
1416 fet_beginchar ("Quart lahead", "s2la");
1417 draw_la_head (solfa_quarter_width);
1422 def draw_ti_head (expr width_factor, dir) =
1423 set_char_box (0, width_factor * solfa_base_notewidth#,
1424 0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1425 save p_in, p_out, p_top;
1426 save nw_dist, sw_dist, nw, sw;
1427 path p_in, p_out, p_top;
1428 pair nw_dist, sw_dist, nw, sw;
1432 pickup pencircle scaled solfa_pen_thick;
1437 y2 = cone_height [y1, y3];
1443 labels (range 1 thru 4);
1445 nw = unitvector (z2 - z1);
1446 sw = unitvector (z1 - z4);
1448 nw_dist = (nw rotated 90) * 0.5 solfa_pen_thick;
1449 sw_dist = (sw rotated 90) * 0.5 solfa_pen_thick;
1451 p_top := (z2 - sw_dist)
1455 p_in := (((z1 - nw_dist) -- (z2 - nw_dist)) intersectionpoint
1456 ((z1 - sw_dist) -- (z4 - sw_dist)))
1457 -- (((z1 - nw_dist) -- (z2 - nw_dist)) intersectionpoint
1458 ((z2 + sw_dist) .. {right}(bot z3)))
1460 .. (((bot z3){right} .. (z4 + nw_dist)) intersectionpoint
1461 ((z1 - sw_dist) -- (z4 - sw_dist)))
1468 .. (z2 - sw_dist){direction 0 of p_top}
1470 & {direction infinity of p_top}(z4 - nw_dist)
1477 charwy := cone_height [-chardp, charht];
1484 fet_beginchar ("Whole up tihead", "s0ti");
1485 draw_ti_head (solfa_whole_width, 1);
1491 fet_beginchar ("Half up tihead", "u1ti");
1492 draw_ti_head (solfa_half_width, 1);
1498 fet_beginchar ("Half down tihead", "d1ti");
1499 draw_ti_head (solfa_half_width, -1);
1505 fet_beginchar ("Quart up tihead", "u2ti");
1506 draw_ti_head (solfa_quarter_width, 1);
1511 fet_beginchar ("Quart down tihead", "d2ti");
1512 draw_ti_head (solfa_quarter_width, -1);
1517 fet_endgroup ("noteheads");
1521 % we derive black_notehead_width# from the quarter head,
1522 % so we have to define black_notehead_width (pixel qty)
1523 % after the black_notehead_width# itself.
1525 % Let's keep it outside the group as well.
1528 define_pixels (black_notehead_width);