1 % Feta (not the Font-En-Tja) music font -- implement scripts
2 % This file is part of LilyPond, the GNU music typesetter.
4 % Copyright (C) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
5 % Jan Nieuwenhuizen <janneke@gnu.org>
8 % LilyPond 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.
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/>.
22 fet_begingroup ("scripts");
25 save alpha, radius, crook_thinness, crook_fatness, dot_size;
29 % [Wanske] and some Baerenreiter editions
30 % suggest about 80 degrees instead of a half-circle
33 radius# = 1.25 staff_space#;
34 crook_thinness# = 1.5 linethickness#;
35 crook_fatness# = 0.25 staff_space# + 1.5 linethickness#;
37 radius# + crook_fatness# / 2 = h#;
38 radius# + crook_thinness# / 2 = w#;
40 set_char_box (w#, w#, crook_thinness# / 2, h#);
42 define_pixels (radius, crook_thinness, crook_fatness);
44 dot_size# = 8/6 crook_fatness#;
45 define_whole_blacker_pixels (dot_size);
47 penpos1 (crook_thinness, 0);
48 penpos2 (crook_fatness, -90);
53 .. z1l{dir (-alpha - 90)}
54 .. {dir (90 - alpha)}z1r
57 -- reverse pat xscaled -1 shifted (-feta_eps, 0)
61 pickup pencircle scaled dot_size;
63 bot y4 = vround (-crook_thinness / 2);
68 fet_beginchar ("fermata up", "ufermata");
74 fet_beginchar ("fermata down", "dfermata");
80 def draw_short_fermata =
81 save fat_factor, thinness, dot_size;
82 save left_dist, right_dist, se, ne;
83 pair left_dist, right_dist, se, ne;
85 set_char_box (staff_space#, staff_space#, 0, 2.2 staff_space#);
87 dot_size# = 0.266 staff_space# + 2.666 linethickness#;
88 define_whole_blacker_pixels (dot_size);
91 thinness = 1.5 linethickness;
93 pickup pencircle scaled thinness;
102 z1 - z4 = whatever * (charwd, -charht);
103 z4 = fat_factor [z3, z5];
105 ne = unitvector (z3 - z5);
106 se = unitvector (z2 - z3);
108 left_dist = (ne rotated 90) * 0.5 thinness;
109 right_dist = (se rotated 90) * 0.5 thinness;
112 .. (z5 - left_dist){ne}
113 -- (((z5 - left_dist) -- (z3 - left_dist)) intersectionpoint
114 ((z1 - right_dist) -- (z4 - right_dist)))
115 -- (z1 - right_dist){se}
118 .. (z2 + right_dist){-se}
119 -- (z3 + right_dist){-se}
121 .. (z3 + left_dist){-ne}
122 -- (z5 + left_dist){-ne}
125 pickup pencircle scaled dot_size;
134 fet_beginchar ("short fermata up", "ushortfermata");
136 labels (1, 2, 3, 4, 5, 6);
140 fet_beginchar ("short fermata down", "dshortfermata");
146 def draw_long_fermata =
147 save stemthick, beamheight, dot_size, wd;
151 wd# = 2.5 staff_space#;
152 stemthick = hround (1.5 linethickness);
153 beamheight = 0.3 staff_space + linethickness;
154 dot_size# = 0.266 staff_space# + 2.666 * linethickness#;
156 define_whole_blacker_pixels (dot_size);
158 set_char_box (wd# / 2, wd# / 2, 0, 3/2 staff_space#);
160 pickup pencircle scaled blot_diameter;
168 pickup pencircle scaled stemthick;
181 -- reverse pat xscaled -1 shifted (-feta_eps, 0)
186 pickup pencircle scaled dot_size;
195 fet_beginchar ("long fermata up", "ulongfermata");
201 fet_beginchar ("long fermata down", "dlongfermata");
207 def draw_very_long_fermata =
208 save ibeamheight, obeamheight;
209 save ihwd, ohwd, iht, oht; % inner/outer half_width/height
210 save stemthick, dot_size;
214 ihwd# = 1.0 staff_space#;
215 ohwd# = 1.5 staff_space#;
216 iht# = 0.9 staff_space#;
217 oht# = 1.6 staff_space#;
218 define_pixels (ihwd, ohwd, iht, oht)
220 stemthick = hround (1.5 linethickness);
221 ibeamheight# = 0.3 staff_space#;
222 obeamheight# = 0.5 staff_space#;
223 define_pixels (ibeamheight, obeamheight);
225 dot_size# = (iht# - ibeamheight#) * 8/10;
226 define_whole_blacker_pixels (dot_size);
228 set_char_box (ohwd#, ohwd#, 0, oht#);
230 pickup pencircle scaled blot_diameter;
239 ipat := top z11{left}
242 pickup pencircle scaled stemthick;
244 x2 = -ohwd + stemthick;
245 y2 = oht - obeamheight;
248 x12 = -ihwd + stemthick;
249 y12 = iht - ibeamheight;
259 -- reverse opat xscaled -1 shifted (-feta_eps, 0)
267 -- reverse ipat xscaled -1 shifted (-feta_eps, 0)
273 pickup pencircle scaled dot_size;
282 fet_beginchar ("very long fermata up", "uverylongfermata");
283 draw_very_long_fermata;
284 labels (1, 2, 3, 11, 12, 13, 4);
288 fet_beginchar ("very long fermata down", "dverylongfermata");
289 draw_very_long_fermata;
295 % Thumbs are used in cello music.
296 % TODO : thumbs should look like the finger-font and should be placed in
297 % the same way in the score.
300 fet_beginchar ("Thumb", "thumb");
301 save thin, height, width, thick, depth;
302 height# = 5/4 width#;
303 height# = staff_space#;
304 depth# = 1.6 (height# / 2);
306 set_char_box (width# / 2, width# / 2, depth#, height# / 2);
308 define_pixels (height, width);
310 thin = .6 linethickness + 0.06 staff_space;
311 2 thick + 0.5 (height - 2 thin) = width;
315 penpos3 (thick, 180);
322 penlabels (1, 2, 3, 4);
331 y5 = -d + brush_thick / 2;
332 brush_thick = 0.9 thick;
337 draw_brush (z4r, 1.4 thin, z5, brush_thick);
342 % `\accent' is TeX reserved.
345 def draw_accent (expr bottom_left, top_right, thickness, diminish) =
347 thinning_start = 0.4;
348 pickup pencircle scaled thickness;
350 lft x1 = xpart bottom_left;
351 top y1 = ypart top_right;
352 lft x6 = xpart bottom_left;
353 bot y6 = ypart bottom_left;
355 rt z4 = (xpart top_right, (ypart top_right + ypart bottom_left) / 2);
356 x5 = x3 = thinning_start [xpart top_right, xpart bottom_left]
357 - linethickness + 0.1 staff_space;
358 z3 = whatever [z1, z4];
359 z5 = whatever [z6, z4];
361 penpos1 (thickness, angle (z3 - z1) + 90);
362 penpos3 (thickness, angle (z3 - z1) + 90);
363 penpos4 (thickness, 90);
364 penpos5 (thickness, angle (z6 - z5) + 90);
365 penpos6 (thickness, angle (z6 - z5) + 90);
367 x4 - x7 = diminish * thickness;
379 ..tension 0.8.. rt z4
388 fet_beginchar ("> accent", "sforzato");
389 set_char_box (.9 staff_space#, .9 staff_space#,
390 .5 staff_space#, .5 staff_space#);
392 draw_accent ((-w, -d), (w, h),
393 0.05 staff_space + linethickness, 0.7);
394 penlabels (1, 3, 4, 5, 6);
399 fet_beginchar ("espr", "espr");
400 set_char_box (1.9 staff_space#, 1.9 staff_space#,
401 .5 staff_space#, .5 staff_space#);
403 draw_accent ((w - 1.78 staff_space, -d), (w, h),
404 0.05 staff_space + linethickness, 0.6);
405 addto currentpicture also currentpicture xscaled -1;
409 fet_beginchar ("staccato dot", "staccato");
411 radius# = 0.20 * staff_space#;
412 define_whole_pixels (radius);
414 pickup pencircle scaled 2 radius;
417 set_char_box (radius#, radius#, radius#, radius#);
421 def draw_staccatissimo =
423 height# = .8 staff_space#;
424 radius# = linethickness# + .1 staff_space#;
425 define_whole_blacker_pixels (radius);
426 define_pixels (height);
428 draw_brush ((0, 0), linethickness, (0, height), 2 radius);
430 set_char_box (radius#, radius#,
431 blot_diameter# / 2, height# + radius#);
435 fet_beginchar ("staccatissimo/martellato up", "ustaccatissimo");
440 fet_beginchar ("staccatissimo/martellato down", "dstaccatissimo");
446 fet_beginchar ("portato/single tenuto", "tenuto");
448 thick# = 1.6 linethickness#;
449 define_whole_blacker_pixels (thick);
451 set_char_box (.6 staff_space#, .6 staff_space#,
452 thick# / 2, thick# / 2);
454 draw_rounded_block ((-b, -thick / 2), (w, thick / 2), thick);
459 save thick, dot_size;
460 thick# = 1.4 linethickness#;
461 dot_size# = 2.4 linethickness# + 0.08 staff_space#;
462 define_whole_blacker_pixels (thick, dot_size);
464 set_char_box (.6 staff_space#, .6 staff_space#,
465 thick# / 2, .5 staff_space# + .5 dot_size#);
467 draw_rounded_block ((-b, -thick / 2), (w, thick / 2), thick);
469 pickup pencircle scaled dot_size;
474 fet_beginchar ("portato/tenuto with staccato", "uportato");
479 fet_beginchar ("portato/tenuto with staccato", "dportato");
486 save fat_factor, thinness;
487 save left_dist, right_dist, ne, se;
488 pair left_dist, right_dist, ne, se;
490 set_char_box (staff_space# / 2, staff_space# / 2,
491 0, 1.1 staff_space#);
494 thinness = linethickness;
496 pickup pencircle scaled thinness;
505 z1 - z4 = whatever * (charwd, -charht);
506 z4 = fat_factor [z3, z5];
508 ne = unitvector (z3 - z5);
509 se = unitvector (z2 - z3);
511 left_dist = (ne rotated 90) * 0.5 thinness;
512 right_dist = (se rotated 90) * 0.5 thinness;
515 .. (z5 - left_dist){ne}
516 -- (((z5 - left_dist) -- (z3 - left_dist)) intersectionpoint
517 ((z1 - right_dist) -- (z4 - right_dist)))
518 -- (z1 - right_dist){se}
521 .. (z2 + right_dist){-se}
522 -- (z3 + right_dist){-se}
524 .. (z3 + left_dist){-ne}
525 -- (z5 + left_dist){-ne}
530 fet_beginchar ("marcato up", "umarcato");
532 labels (1, 2, 3, 4, 5);
537 % The down marcato char (not very much used).
538 % Contrary to what some MF/TeX `gurus' believe
539 % it is *point*-symmetric with the "up" version
542 fet_beginchar ("marcato down", "dmarcato");
549 % used in french horn music todo
551 % TODO: too light at 20pt
554 fet_beginchar ("open (unstopped)", "open");
555 save thin, height, width, thick;
557 height# = 5/4 width#;
558 height# = staff_space#;
559 thin = .6 linethickness + 0.06 staff_space;
561 set_char_box (width# / 2, width# / 2, height# / 2, height# / 2);
563 define_pixels (width, height);
565 2 thick + 0.6 (height - 2 thin) = width;
569 penpos3 (thick, 180);
576 penlabels (1, 2, 3, 4);
586 fet_beginchar ("halfopen (unstopped)", "halfopen");
587 save thin, height, width, thick, factor, slash;
590 height# = 5/4 width#;
591 height# = staff_space#;
592 thin = 0.6 linethickness + 0.06 staff_space;
593 slash# = 1.05 linethickness#;
595 set_char_box (width# / 2, width# / 2, height# / 2, height# / 2);
597 define_pixels (width, height, slash);
599 2 thick + 0.6 (height - 2 thin) = width;
603 penpos3 (thick, 180);
610 penlabels (1, 2, 3, 4);
618 draw_brush ((-w * factor, -h * factor), slash,
619 (w * factor, h * factor), slash);
623 fet_beginchar ("plus (stopped)", "stopped");
624 save hthick, vthick, size, outer_hsize, outer_vsize;
626 hthick# = vthick# = 2 linethickness#;
627 size# = 1.1 staff_space#;
628 define_whole_blacker_pixels (vthick);
629 define_whole_vertical_blacker_pixels (hthick);
631 set_char_box (size# / 2, size# / 2, size# / 2, size# / 2);
633 outer_hsize = hround ((b + w - vthick) / 2);
634 outer_vsize = vround ((h + d - hthick) / 2);
635 w := b := (2 outer_hsize + vthick) / 2;
636 h := d := (2 outer_vsize + hthick) / 2;
638 draw_rounded_block ((-b, -d + outer_vsize),
639 (w, -d + outer_vsize + hthick), hthick);
640 draw_rounded_block ((-b + outer_hsize, -d),
641 (-b + outer_hsize + vthick, h), vthick);
645 fet_beginchar ("Upbow", "upbow");
648 thick = 1.4 linethickness;
649 wd# = 1.3 staff_space#;
652 set_char_box (wd# / 2, wd# / 2, 0, ht#);
654 draw_accent ((-h, -w), (0, w), thick, 0.9);
655 currentpicture := currentpicture rotated -90;
659 fet_beginchar ("Downbow", "downbow");
660 save stemthick, beamheight, wd;
664 wd# = 1.5 staff_space#;
667 stemthick = hround (1.2 linethickness);
669 set_char_box (wd# / 2, wd# / 2, 0, 4/3 staff_space#);
673 pickup pencircle scaled blot_diameter;
681 pickup pencircle scaled stemthick;
694 -- reverse pat xscaled -1 shifted (-feta_eps, 0)
703 % Inspired by a computer-set version of Auf dem Strom by Baerenreiter.
707 save thin, thick, ball_diam, darkness;
708 save wd, ht, thick_nibangle, ball_nib_thick;
712 wd# = 35/16 staff_space#;
713 ht# = 18/17 staff_space#;
714 darkness = 0.3 linethickness + 0.09 staff_space;
716 set_char_box (wd# / 2, wd# / 2, ht# / 2, ht# / 2);
721 ball_nib_thick = 2.7 darkness;
722 ball_diam = ball_nib_thick + (h - ball_nib_thick) / 10;
732 penpos1 (1.1 thick, thick_nibangle);
733 penpos2 (thick, thick_nibangle);
735 penpos4 (ball_nib_thick, -90);
738 swoosh := z1l{curl 0}
746 .. swoosh scaled -1 shifted (-feta_eps, -feta_eps)
750 y5r = y4l - ball_diam / 2;
753 penpos5 (1.6 ball_diam / 2, 10);
754 penpos6 (ball_diam / 2, 150);
761 fill ploop scaled -1 shifted (-feta_eps, -feta_eps);
765 fet_beginchar ("Reverse turn", "reverseturn");
767 currentpicture := currentpicture yscaled -1;
771 fet_beginchar ("Turn", "turn");
773 penlabels (1, 2, 3, 4, 5, 6, 7);
778 % Inspired by a (by now) PD edition of Durand & C'ie edition of
779 % Saint-Saens' Celloconcerto no. 1
781 % FIXME take out hardcoded vars.
782 % FIXME the two loops on the `t' should be smoother (and the left one bigger).
783 % FIXME generic macros for serifs: top of the t and bottom of r
786 fet_beginchar ("Trill (`tr')", "trill");
787 save start_nib_angle, ascender_extra, ex, hair_thick, fatness;
788 save slant, t_fatness, r_fatness, kerning, t_overshoot;
789 save uitschieter, bulb_size, krul_ang;
792 ascender_extra# = 1/2 ex#;
793 ascender# = ascender_extra# + ex#;
794 ex# = 1.4 staff_space#;
796 start_nib_angle = 20;
798 define_pixels (ex, ascender_extra, ascender, kerning);
800 t_overshoot = 0.03 ex;
802 t_fatness = 0.78 fatness;
803 t_width = 1.9 t_fatness;
804 r_fatness = 0.78 fatness;
805 uitschieter = 0.48 ex;
806 hair_thick = linethickness;
807 r_flare = .5 hair_thick + 0.25 r_fatness;
808 r_width = 2 r_fatness + 0.25 kerning;
811 local_copy (transform)(currenttransform);
812 currenttransform := currenttransform slanted slant
813 shifted (-staff_space, 0);
815 set_char_box (.85 staff_space#, .85 staff_space#, 0, ascender#);
819 % try to position in such a way that the center is the visual
822 x1l = 0.2 staff_space;
823 x1r - x1l = t_fatness;
824 penpos1 (start_nib_wid, start_nib_angle);
827 penpos2 (start_nib_wid, start_nib_angle);
829 z3l = (x2l + 0.5 t_width, - t_overshoot);
831 z4l = (x2l + t_width, 0.23 ex);
832 penpos4 (whatever, 180); % 200
833 x4l - x4r = hair_thick;
835 x3r = 0.5 [x4r, x2r];
836 % 1.7 [x3l, x3r] = x4r;
837 y3r - y3l = 0.6 t_fatness;
844 pickup pencircle scaled hair_thick;
846 z5 = (x2l + t_fatness / 2, 2/3 ex);
847 lft x6 = x2l - uitschieter;
848 y6 = y5; % - 1/20 ex;
849 z7 = z5 + whatever * dir krul_ang;
850 up_angle = krul_ang; % = angle (z7-z5)
851 x7 = 5/10 kerning + x5;
859 z4' = point 0.85 of krul_p;
860 penpos4' (hair_thick, angle (direction 0.85 of krul_p) + 90);
862 % the body of the `t' and the bottom loop
863 fill z1r{dir (angle (z1l - z1r) + 30)}
864 .. z1l{-dir (angle (z1r - z1l) - 45)}
866 ..tension (1 + .5 slant).. z3l{right}
868 .. z4'l{direction 0.85 of krul_p}
869 -- z4'r{-direction 0.85 of krul_p}
872 ..tension (1.5 + .7 slant).. z2r{up}
875 z5' = point 1.1 of krul_p;
876 penpos5' (hair_thick, angle (direction 1.1 of krul_p) + 90);
877 z5'' = point 1.5 of krul_p;
878 penpos5'' (hair_thick, angle (direction 1.5 of krul_p) + 90);
879 z5''' = point 1.8 of krul_p;
880 penpos5''' (hair_thick, angle (direction 1.8 of krul_p) + 90);
881 z6 = point 2 of krul_p;
882 penpos6 (hair_thick, angle (direction 2 of krul_p) + 90);
883 z6' = point 2.3 of krul_p;
884 penpos6' (hair_thick, angle (direction 2.3 of krul_p) + 90);
885 z6'' = point 2.6 of krul_p;
886 penpos6'' (hair_thick, angle (direction 2.6 of krul_p) + 90);
887 z6''' = point 2.9 of krul_p;
888 penpos6''' (hair_thick, angle (direction 2.9 of krul_p) + 90);
889 penpos7 (hair_thick, up_angle + 90);
890 z7' = point 3.2 of krul_p;
891 penpos7' (hair_thick, angle (direction 3.2 of krul_p) + 90);
894 penstroke z5'e{direction 1.1 of krul_p}
895 .. z5''e{direction 1.5 of krul_p}
896 .. z5'''e{direction 1.8 of krul_p}
897 .. z6e{direction 2 of krul_p}
898 .. z6'e{direction 2.3 of krul_p}
899 .. z6''e{direction 2.6 of krul_p}
900 .. {direction 2.9 of krul_p}z6'''e;
904 penpos9 (r_fatness, 0);
907 y10 = -0.3 linethickness;
908 penpos10 (r_fatness, 0);
910 penpos11 (hair_thick, -4);
913 z13l = (x9l + r_width, y11 - linethickness);
914 penpos13 (r_flare, 180);
916 z15 = z13r - (bulb_size * r_fatness, 0);
917 z14 = 0.5 [z13l, z15] - (0, bulb_size * r_fatness);
926 (u, v) = before intersectiontimes after;
928 save before_bulb, after_bulb;
929 path before_bulb, after_bulb;
930 before_bulb := z9r{up}
931 ..tension 0.94.. z13r{down};
932 after_bulb := z13l{up}
933 ..tension 1.06.. z15{down};
934 (u_bulb, v_bulb) = before_bulb intersectiontimes after_bulb;
936 % the connection between `t' and `r', the body of the `r',
941 -- simple_serif (z10l, z10r, -30)
943 .. subpath (0, u_bulb) of before_bulb
944 .. subpath (v_bulb, infinity) of after_bulb
947 .. subpath (0, u) of before
948 .. subpath (v, infinity) of after
951 penlabels (range 1 thru 15);
952 penlabels (4', 5', 5'', 5''', 6', 6'', 6''', 7');
957 save radius, thickness;
961 radius# := .5 staff_space#;
963 set_char_box (radius#, radius#, radius#, 2/3 staff_space#);
965 thickness := hround (1.5 linethickness);
967 pickup pencircle scaled thickness;
986 -- reverse pat xscaled -1 shifted (-feta_eps, 0)
992 fet_beginchar ("left heel", "upedalheel");
998 fet_beginchar ("right heel", "dpedalheel");
1005 save ht, wd, thickness;
1007 thickness := 1.5 linethickness;
1008 ht# := 1.5 staff_space#;
1010 define_pixels (ht, wd);
1012 set_char_box (wd#, wd#, 0, ht#);
1013 draw_accent ((-h, -w), (0, w), thickness, 0.9);
1014 currentpicture := currentpicture rotated -90;
1018 fet_beginchar ("left toe", "upedaltoe");
1023 fet_beginchar ("right toe", "dpedaltoe");
1029 fet_beginchar ("Flageolet", "flageolet");
1030 save height, width, thickness, superness;
1032 height# = 4/15 staffsize#;
1034 thickness# = blot_diameter#;
1035 define_pixels (height, width);
1036 define_whole_blacker_pixels (thickness);
1038 set_char_box (width# / 2, width# / 2, height# / 2, height# / 2);
1040 penpos1 (thickness, 90);
1041 penpos2 (thickness, 180);
1042 penpos3 (thickness, 270);
1043 penpos4 (thickness, 0);
1054 penlabels (1, 2, 3, 4);
1056 % mf doesn't handle pixel dropouts in outline objects, so we use
1057 % `draw' if not called by mpost
1058 if known miterlimit:
1065 pickup pencircle scaled thickness;
1076 % TODO: ARGRGHGH code dup.
1079 fet_beginchar ("Segno", "segno");
1080 save thin, thick, ball_diam, darkness, pointheight;
1081 save wd, ht, thick_nibangle, ball_nib_thick;
1085 ht# = 3 staff_space#;
1086 wd# = 2 staff_space#;
1087 darkness = .08 staff_space + 0.4 linethickness;
1089 set_char_box (wd# / 2, wd# / 2, ht# / 2, ht# / 2);
1091 thick_nibangle = 30;
1094 ball_nib_thick = 2.7 darkness;
1095 ball_diam = ball_nib_thick + (w - ball_nib_thick) / 10;
1096 pointheight = 2 linethickness;
1106 penpos1 (thick, 2 thick_nibangle);
1107 penpos2 (thick, thick_nibangle);
1108 penpos3 (thin, -90);
1109 penpos4 (ball_nib_thick, 180 - thick_nibangle);
1114 swoosh := z1l{curl 0}
1122 .. (swoosh scaled -1)
1126 x5r = x4l - ball_diam / 2;
1129 penpos5 (1.6 ball_diam / 2, 100);
1130 penpos6 (ball_diam / 2, 240);
1137 fill ploop scaled -1;
1139 penpos7 (2 thin, 0);
1141 penpos8 (2 thin, 0);
1147 pickup pencircle scaled 2 thin;
1148 drawdot (-x2r, pointheight);
1149 drawdot (x2r, -pointheight);
1151 penlabels (range 1 thru 8);
1155 fet_beginchar ("Varied Segno", "varsegno");
1156 save ht, wd, loopdist, loopangle;
1157 save thin, med, thick;
1158 save bulbradius, center;
1161 ht# = 8 staff_space#;
1162 wd# = 2.5 staff_space#;
1164 set_char_box (wd# / 2, wd# / 2, ht# / 2, ht# / 2);
1165 % set_char_box (0, 0, ht# / 2, ht# / 2);
1167 loopdist = 4/3 staff_space;
1170 thick = 1/2 staff_space;
1171 med = 1/4 staff_space;
1172 thin = 1/10 staff_space;
1175 y1 = 13/4 staff_space;
1178 z2l = (0, 4 staff_space);
1179 penpos2 (med, 270 - loopangle);
1182 y3 = y1 + 1/4 staff_space;
1183 penpos3 (med, 270 + loopangle);
1185 center = (0, 2 staff_space);
1186 z4 = (3/4 staff_space, 2 staff_space)
1187 rotatedabout (center, 180 - loopangle);
1190 y9 = y4 - 2 loopdist;
1192 y10 = y5 - 2 loopdist;
1194 penpos4 (thick, 90 - loopangle);
1195 penpos5 (thick, 90 - loopangle);
1196 penpos9 (thick, 90 - loopangle);
1197 penpos10 (thick, 90 - loopangle);
1199 z6 = (4/3 staff_space, 4/3 staff_space)
1200 rotatedabout (2/3 center, -loopangle);
1202 y11 = y6 - 2 loopdist;
1204 penpos6 (thin, -loopangle);
1205 penpos11 (thin, -loopangle);
1208 penpos7 (thick, 270 - loopangle);
1210 z8 = (4/3 staff_space, 0) rotated (180 - loopangle);
1211 penpos8 (thin, -loopangle);
1214 penpos12 (thick, 270 - loopangle);
1216 z1' = 4/3[z1l, z1r];
1217 bulbradius = length (z1l - z1');
1218 pickup pencircle scaled 2 bulbradius;
1220 save se_dir, nw_dir;
1221 pair se_dir, nw_dir;
1222 se_dir := dir -loopangle;
1223 nw_dir := dir (180 - loopangle);
1225 draw_bulb (-1, z1r, z1l, bulbradius, .8);
1239 addto currentpicture also currentpicture scaled -1;
1241 penlabels (1, 1', 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
1242 % draw_staff (-2, 2, 0);
1246 fet_beginchar ("Coda", "coda");
1247 save stickout, thin, thick, codawidth, codaheight;
1249 stickout# = 0.35 staff_space#;
1250 codawidth# = 2/3 staff_space#;
1251 codaheight# = staff_space#;
1252 define_pixels (codawidth, codaheight);
1254 set_char_box (codawidth# + stickout#, codawidth# + stickout#,
1255 codaheight# + stickout#, codaheight# + stickout#);
1257 thin = 1.2 linethickness;
1258 0.1 (codaheight - 2 thin) = (codawidth - 2 thick);
1261 penpos2 (thin, -90);
1262 penpos3 (thick, -180);
1263 penpos4 (thin, -270);
1272 penlabels (1, 2, 3, 4);
1285 draw_gridline ((0, -h), (0, h), thin);
1286 draw_gridline ((-w, 0), (w, 0), thin);
1290 fet_beginchar ("Varied Coda", "varcoda");
1291 save thin, thick, codawidth, codaheight;
1292 thin# = 1.2 linethickness#;
1293 thick# = 1.0 linethickness# + 0.25 staff_space#;
1294 codawidth# = 2/3 staff_space#;
1295 codaheight# = staff_space#;
1296 define_pixels (thin, thick, codawidth, codaheight);
1298 set_char_box (codawidth# + thick#, codawidth# + thick#,
1299 codaheight# + thick#, codaheight# + thick#);
1301 x1 = -codawidth + thick - .5 blot_diameter;
1303 x2 = codawidth - thick + .5 blot_diameter;
1305 draw_square_block (z1, z2);
1311 draw_block (z3, z4);
1313 labels (1, 2, 3, 4);
1315 addto currentpicture also currentpicture scaled -1;
1317 draw_gridline ((0, -h), (0, h), thin);
1318 draw_gridline ((-w, 0), (w, 0), thin);
1323 save alpha, thick, thin, ht;
1326 thin# = 1.2 linethickness#;
1327 thick# = 3 linethickness#;
1328 ht# = .6 staff_space#;
1329 define_pixels (thin, thick, ht);
1331 set_char_box (0, .5 staff_space#, ht#, ht#);
1333 penpos1 (thick, alpha);
1334 penpos2 (thick, alpha + 90);
1335 penpos3 (thin, 180 - alpha);
1336 penpos4 (thin, 90 - alpha);
1344 fill z1l{dir (alpha + 90)}
1346 .. z1r{dir (alpha - 90)}
1347 .. z3l{dir (270 - alpha)}
1348 .. z4l{dir (180 - alpha)}
1349 .. z3r{dir (90-alpha)}
1354 fet_beginchar ("Right Comma", "rcomma");
1356 penlabels (1, 2, 3, 4);
1360 fet_beginchar ("Left Comma", "lcomma");
1367 save thick, thin, ht, wd, alpha;
1370 thin# = 1.2 linethickness#;
1371 thick# = 3 linethickness#;
1372 ht# = .6 staff_space#;
1373 wd# = .25 staff_space#;
1374 define_pixels (thin, thick, ht, alpha);
1376 set_char_box (wd#, wd#, ht#, ht#);
1381 draw_brush (z1, thin, z2, thick);
1385 fet_beginchar ("Right Varied Comma", "rvarcomma");
1391 fet_beginchar ("Left Varied Comma", "lvarcomma");
1397 thick# := 1/24 designsize;
1398 define_blacker_pixels (thick);
1400 rthin := 0.075 * staff_space + 0.5 linethickness;
1401 rthick := 2 thick + rthin;
1406 save ne, nw, se, sw;
1408 pair ne, nw, se, sw;
1412 nw = dir (alpha + 180);
1413 ne = dir (alpha + 90);
1415 sw = dir (alpha - 90);
1417 penpos1 (rthin, alpha + 90);
1418 penpos2 (5/4 rthick, alpha);
1419 penpos3 (3/4 rthick, alpha);
1420 penpos4 (5/4 rthick, alpha);
1421 penpos5 (rthin, alpha + 90);
1423 z1 = (width / 2, height) - overshoot * se;
1424 z2 = 2 [z4, (width / 2, height / 2)];
1426 x4 = 2/8 staff_space;
1429 z5 = 2 [z1, (width / 2, height / 2)];
1430 z6 = z2l + 1/2 rthin * sw;
1431 z7 = z4l + 1/2 rthin * sw + 1/2 rthin * se;
1432 z8 = 2 [z6, (width / 2, height / 2)];
1433 z9 = 2 [z7, (width / 2, height / 2)];
1449 fet_beginchar ("Arpeggio", "arpeggio");
1450 save height, overshoot, width;
1451 height# = staff_space#;
1452 width# = 0.8 height#;
1453 overshoot# = 0.25 staff_space#;
1454 define_pixels (height, overshoot, width);
1456 set_char_box (0, width#, 0, height#);
1458 penlabels (range 1 thru 9);
1460 draw_staff (-2, 2, 0.0);
1465 % Extendable Trill symbol.
1467 % Rename me to Trill, rename Trill to Tr?
1470 fet_beginchar ("Trill_element", "trill_element");
1471 save height, overshoot;
1472 height# = staff_space#;
1473 width# = 0.8 height#;
1474 overshoot# = 0.25 staff_space#;
1475 define_pixels (height, overshoot, width);
1477 set_char_box (0, height#, 0, width#);
1480 currentpicture := currentpicture shifted -(width / 2, height / 2);
1481 currentpicture := currentpicture rotated 90;
1482 currentpicture := currentpicture shifted (height / 2, width / 2);
1487 % Arpeggio arrow by Chris Jackson <chris@fluffhouse.org.uk>
1490 def draw_arpeggio_arrow =
1491 save thinness, height, width, overshoot;
1492 save nw, ne, se, sw;
1494 save before_left, before_right, after_left, after_right;
1495 save u_left, v_left, u_right, v_right;
1496 pair nw, ne, se, sw;
1497 path before_left, before_right, after_left, after_right;
1499 height# = staff_space#;
1500 width# = 0.8 height#;
1501 overshoot# = 0.25 staff_space#;
1502 define_pixels (height, overshoot, width);
1504 set_char_box (0, width#, 0, height#);
1507 nw = dir (alpha + 180);
1508 ne = dir (alpha + 90);
1510 sw = dir (alpha - 90);
1512 penpos1 (rthin, alpha + 90);
1513 penpos2 (5/4 rthick, alpha);
1514 penpos3 (5/4 rthick, 0);
1516 z1 = (width / 2, height) - overshoot * se; % numbering is consistent
1517 % with the arpeggio symbol
1518 z2 = 2 [z4, (width / 2, height / 2)];
1519 z3 = (0.5 width, 0.5 height);
1520 z4 = (0.25 staff_space, rthin);
1521 z6 = z2l + 1/2 rthin * sw;
1522 z9 = (width / 2, height) + overshoot * se;
1524 pickup pencircle scaled vround (0.5 rthin);
1526 bot z10 = (0.5 w, 0);
1527 lft z11 = (0.5 w - hround (0.8 w), 0.8 h);
1528 rt z12 = (0.5 w + hround (0.8 w), 0.8 h);
1533 after_left := (z3 + (0, -0.25 rthin / cosd (angle (nw))))
1534 -- (z11 + 0.25 rthin * ne);
1535 (u_left, v_left) = before_left intersectiontimes after_left;
1537 before_right := (z12 + 0.25 rthin * nw)
1538 -- (z3 + (0, -0.25 rthin / cosd (angle (nw))));
1539 after_right := z3r{up}
1542 (u_right, v_right) = before_right intersectiontimes after_right;
1544 fill subpath (0, u_left) of before_left
1545 .. subpath (v_left, infinity) of after_left
1548 .. {dir -50}(z11 + 0.25 rthin * sw)
1549 .. (z10 + 0.25 rthin * sw){dir -70}
1551 .. {dir 70}(z10 + 0.25 rthin * se)
1552 .. (z12 + 0.25 rthin * se){dir 50}
1555 .. subpath (0, u_right) of before_right
1556 .. subpath (v_right, infinity) of after_right
1559 % mf doesn't handle pixel dropouts in outline objects, so we use
1560 % `draw' if not called by mpost
1561 if not known miterlimit:
1562 pickup pencircle scaled 0.7 rthin;
1564 -- (z9 + 0.5 rthin * dir (alpha - 90));
1569 fet_beginchar ("Arpeggio arrow down", "arpeggio.arrow.M1");
1570 draw_arpeggio_arrow;
1571 penlabels (range 1 thru 12);
1575 fet_beginchar ("Arpeggio arrow up", "arpeggio.arrow.1");
1576 draw_arpeggio_arrow;
1577 currentpicture := currentpicture scaled -1
1578 shifted (w - feta_eps, h - feta_eps);
1587 % Railroad tracks. We define two variants of these -- both as slightly
1588 % tapered, comma-shaped curves and as two straight parallel slashes.
1591 fet_beginchar ("Curved caesura", "caesura.curved");
1592 save slant, space_between, clearance;
1594 save botthick, topthick;
1598 botthick = 1.5 linethickness;
1599 topthick = 2.5 linethickness;
1601 pickup pencircle scaled botthick;
1604 space_between# = 0.6 staff_space#;
1605 clearance# = 0.2 staff_space#;
1606 height# = 1.2 staff_space#;
1608 set_char_box (0, 2.0 staff_space#,
1609 staff_space# - clearance#, height#);
1610 define_pixels (clearance, height);
1611 define_whole_pixels (space_between);
1617 x2 = (y2 - y1) / slant;
1621 alpha = angle (z2 - z1);
1622 penpos1 (botthick, alpha - krom);
1623 penpos3 (botthick, alpha - krom + 90);
1625 penpos2 (topthick, alpha + krom);
1626 penpos4 (topthick, alpha + krom + 90);
1631 penlabels (1, 2, 3, 4);
1633 pat := z3r{(z1r - z1l)}
1641 fill pat shifted (space_between, 0);
1645 fet_beginchar ("Straight caesura", "caesura.straight");
1646 save slant, space_between, clearance;
1647 save thick, ne, pat;
1652 thick = 2.88 linethickness;
1654 space_between# = 0.56 staff_space#;
1655 clearance# = 0.2 staff_space#;
1657 set_char_box (0, 2.0 staff_space#,
1658 staff_space# - clearance#, 1.2 staff_space#);
1659 define_whole_pixels (space_between);
1666 x4 = x1 + (h + d) / slant;
1669 ne = unitvector (z4 - z1);
1671 z1a = z1 + blot_diameter * ne;
1672 z1b = z1 + blot_diameter * right;
1673 z2a = z2 + blot_diameter * ne;
1674 z2b = z2 + blot_diameter * left;
1676 z3a = z3 - blot_diameter * ne;
1677 z3b = z3 + blot_diameter * left;
1678 z4a = z4 - blot_diameter * ne;
1679 z4b = z4 + blot_diameter * right;
1692 fill pat shifted (space_between, 0);
1694 labels(range 1 thru 4);
1695 labels(1a, 1b, 2a, 2b, 3a, 3b, 4a, 4b);
1699 fet_beginchar ("snap pizzicato (Bartok pizzicato)", "snappizzicato");
1700 save height, width, thickness, superness;
1702 height# = 4/15 staffsize#;
1704 thickness# = 1.3 linethickness#;
1705 define_pixels (height, width);
1706 define_whole_blacker_pixels (thickness);
1708 set_char_box (width# / 2, width# / 2, height# / 2, height# * 3 / 4);
1710 penpos1 (thickness, 90);
1711 penpos2 (thickness, 180);
1712 penpos3 (thickness, 270);
1713 penpos4 (thickness, 0);
1724 penlabels (1, 2, 3, 4);
1726 % mf doesn't handle pixel dropouts in outline objects, so we use
1727 % `draw' if not called by mpost
1728 if known miterlimit:
1735 pickup pencircle scaled thickness;
1746 draw_gridline (z5, z6, thickness);
1751 fet_endgroup ("scripts");