+ labels (1, 2, 3, 4);
+
+ addto currentpicture also currentpicture scaled -1;
+
+ draw_gridline ((0, -h), (0, h), thin);
+ draw_gridline ((-w, 0), (w, 0), thin);
+fet_endchar;
+
+
+def draw_comma =
+ save alpha, thick, thin, ht;
+
+ alpha := 35;
+ thin# = 1.2 linethickness#;
+ thick# = 3 linethickness#;
+ ht# = .6 staff_space#;
+ define_pixels (thin, thick, ht);
+
+ set_char_box (0, .5 staff_space#, ht#, ht#);
+
+ penpos1 (thick, alpha);
+ penpos2 (thick, alpha + 90);
+ penpos3 (thin, 180 - alpha);
+ penpos4 (thin, 90 - alpha);
+
+ x3r = 0;
+ x1l = x3l;
+ y2r = -y4l = h;
+ z1 = z2;
+ z3 = z4;
+
+ fill z1l{dir (alpha + 90)}
+ .. z2r{dir alpha}
+ .. z1r{dir (alpha - 90)}
+ .. z3l{dir (270 - alpha)}
+ .. z4l{dir (180 - alpha)}
+ .. z3r{dir (90-alpha)}
+ .. cycle;
+enddef;
+
+
+fet_beginchar ("Right Comma", "rcomma");
+ draw_comma;
+ penlabels (1, 2, 3, 4);
+fet_endchar;
+
+
+fet_beginchar ("Left Comma", "lcomma");
+ draw_comma;
+ xy_mirror_char;
+fet_endchar;
+
+
+def draw_varcomma =
+ save thick, thin, ht, wd, alpha;
+
+ alpha := 35;
+ thin# = 1.2 linethickness#;
+ thick# = 3 linethickness#;
+ ht# = .6 staff_space#;
+ wd# = .25 staff_space#;
+ define_pixels (thin, thick, ht, alpha);
+
+ set_char_box (wd#, wd#, ht#, ht#);
+
+ z1 = (-b, -d);
+ z2 = (w, h);
+
+ draw_brush (z1, thin, z2, thick);
+enddef;
+
+
+fet_beginchar ("Right Varied Comma", "rvarcomma");
+ draw_varcomma;
+ labels (1, 2);
+fet_endchar;
+
+
+fet_beginchar ("Left Varied Comma", "lvarcomma");
+ draw_varcomma;
+ xy_mirror_char;
+fet_endchar;
+
+
+thick# := 1/24 designsize;
+define_blacker_pixels (thick);
+
+rthin := 0.075 * staff_space + 0.5 linethickness;
+rthick := 2 thick + rthin;
+
+
+def draw_arpeggio =
+ save alpha;
+ save ne, nw, se, sw;
+ save x, y;
+ pair ne, nw, se, sw;
+
+ alpha := -40;
+
+ nw = dir (alpha + 180);
+ ne = dir (alpha + 90);
+ se = dir alpha;
+ sw = dir (alpha - 90);
+
+ penpos1 (rthin, alpha + 90);
+ penpos2 (5/4 rthick, alpha);
+ penpos3 (3/4 rthick, alpha);
+ penpos4 (5/4 rthick, alpha);
+ penpos5 (rthin, alpha + 90);
+
+ z1 = (width / 2, height) - overshoot * se;
+ z2 = 2 [z4, (width / 2, height / 2)];
+ z3 = 1/2 [z2, z4];
+ x4 = 2/8 staff_space;
+ y4 = rthin;
+
+ z5 = 2 [z1, (width / 2, height / 2)];
+ z6 = z2l + 1/2 rthin * sw;
+ z7 = z4l + 1/2 rthin * sw + 1/2 rthin * se;
+ z8 = 2 [z6, (width / 2, height / 2)];
+ z9 = 2 [z7, (width / 2, height / 2)];
+
+ fill z1l{se}
+ -- z6
+ .. z3l
+ .. z7{se}
+ -- z5l
+ .. z5r{nw}
+ -- z8
+ .. z3r
+ .. z9{nw}
+ -- z1r
+ .. cycle;
+enddef;
+
+
+fet_beginchar ("Arpeggio", "arpeggio");
+ save height, overshoot, width;
+ height# = staff_space#;
+ width# = 0.8 height#;
+ overshoot# = 0.25 staff_space#;
+ define_pixels (height, overshoot, width);
+
+ set_char_box (0, width#, 0, height#);
+ draw_arpeggio;
+ penlabels (range 1 thru 9);
+
+ draw_staff (-2, 2, 0.0);
+fet_endchar;
+
+
+%
+% Extendable Trill symbol.
+% Not yet used
+% Rename me to Trill, rename Trill to Tr?
+%
+
+fet_beginchar ("Trill_element", "trill_element");
+ save height, overshoot;
+ height# = staff_space#;
+ width# = 0.8 height#;
+ overshoot# = 0.25 staff_space#;
+ define_pixels (height, overshoot, width);
+
+ set_char_box (0, height#, 0, width#);
+ draw_arpeggio;
+
+ currentpicture := currentpicture shifted -(width / 2, height / 2);
+ currentpicture := currentpicture rotated 90;
+ currentpicture := currentpicture shifted (height / 2, width / 2);
+fet_endchar;
+
+
+%
+% Arpeggio arrow by Chris Jackson <chris@fluffhouse.org.uk>
+%
+
+def draw_arpeggio_arrow =
+ save thinness, height, width, overshoot;
+ save nw, ne, se, sw;
+ save alpha;
+ save before_left, before_right, after_left, after_right;
+ save u_left, v_left, u_right, v_right;
+ pair nw, ne, se, sw;
+ path before_left, before_right, after_left, after_right;
+
+ height# = staff_space#;
+ width# = 0.8 height#;
+ overshoot# = 0.25 staff_space#;
+ define_pixels (height, overshoot, width);
+
+ set_char_box (0, width#, 0, height#);
+
+ alpha := -40;
+ nw = dir (alpha + 180);
+ ne = dir (alpha + 90);
+ se = dir alpha;
+ sw = dir (alpha - 90);
+
+ penpos1 (rthin, alpha + 90);
+ penpos2 (5/4 rthick, alpha);
+ penpos3 (5/4 rthick, 0);
+
+ z1 = (width / 2, height) - overshoot * se; % numbering is consistent
+ % with the arpeggio symbol
+ z2 = 2 [z4, (width / 2, height / 2)];
+ z3 = (0.5 width, 0.5 height);
+ z4 = (0.25 staff_space, rthin);
+ z6 = z2l + 1/2 rthin * sw;
+ z9 = (width / 2, height) + overshoot * se;
+
+ pickup pencircle scaled vround (0.5 rthin);
+
+ bot z10 = (0.5 w, 0);
+ lft z11 = (0.5 w - hround (0.8 w), 0.8 h);
+ rt z12 = (0.5 w + hround (0.8 w), 0.8 h);
+
+ before_left := z1l
+ -- z6{z6 - z1l}
+ .. {down}z3l;
+ after_left := (z3 + (0, -0.25 rthin / cosd (angle (nw))))
+ -- (z11 + 0.25 rthin * ne);
+ (u_left, v_left) = before_left intersectiontimes after_left;
+
+ before_right := (z12 + 0.25 rthin * nw)
+ -- (z3 + (0, -0.25 rthin / cosd (angle (nw))));
+ after_right := z3r{up}
+ .. z9{z1r - z9}
+ -- z1r;
+ (u_right, v_right) = before_right intersectiontimes after_right;
+
+ fill subpath (0, u_left) of before_left
+ .. subpath (v_left, infinity) of after_left
+ .. top z11
+ .. lft z11
+ .. {dir -50}(z11 + 0.25 rthin * sw)
+ .. (z10 + 0.25 rthin * sw){dir -70}
+ .. bot z10
+ .. {dir 70}(z10 + 0.25 rthin * se)
+ .. (z12 + 0.25 rthin * se){dir 50}
+ .. rt z12
+ .. top z12
+ .. subpath (0, u_right) of before_right
+ .. subpath (v_right, infinity) of after_right
+ .. cycle;
+
+ % mf doesn't handle pixel dropouts in outline objects, so we use
+ % `draw' if not called by mpost
+ if not known miterlimit:
+ pickup pencircle scaled 0.7 rthin;
+ draw z1
+ -- (z9 + 0.5 rthin * dir (alpha - 90));
+ fi;
+enddef;
+
+
+fet_beginchar ("Arpeggio arrow down", "arpeggio.arrow.M1");
+ draw_arpeggio_arrow;
+ penlabels (range 1 thru 12);
+fet_endchar;
+
+
+fet_beginchar ("Arpeggio arrow up", "arpeggio.arrow.1");
+ draw_arpeggio_arrow;
+ currentpicture := currentpicture scaled -1
+ shifted (w - feta_eps, h - feta_eps);
+fet_endchar;
+
+
+% Hmm
+input feta-slag;
+
+
+%
+% Railroad tracks. We define two variants of these -- both as slightly
+% tapered, comma-shaped curves and as two straight parallel slashes.
+%
+
+fet_beginchar ("Curved caesura", "caesura.curved");
+ save slant, space_between, clearance;
+ save alpha, pat;
+ save botthick, topthick;
+ save krom;
+ path pat;
+
+ botthick = 1.5 linethickness;
+ topthick = 2.5 linethickness;
+
+ pickup pencircle scaled botthick;
+
+ slant = 3.5;
+ space_between# = 0.6 staff_space#;
+ clearance# = 0.2 staff_space#;
+ height# = 1.2 staff_space#;
+
+ set_char_box (0, 2.0 staff_space#,
+ staff_space# - clearance#, height#);
+ define_pixels (clearance, height);
+ define_whole_pixels (space_between);
+
+ bot y1 = -d;
+ top y2 = h;
+
+ lft x1 = 0;
+ x2 = (y2 - y1) / slant;
+
+ krom = 10;
+
+ alpha = angle (z2 - z1);
+ penpos1 (botthick, alpha - krom);
+ penpos3 (botthick, alpha - krom + 90);
+
+ penpos2 (topthick, alpha + krom);
+ penpos4 (topthick, alpha + krom + 90);
+
+ z3 = z1;
+ z4 = z2;
+
+ penlabels (1, 2, 3, 4);
+
+ pat := z3r{(z1r - z1l)}
+ .. z4r{z2r-z2l}
+ .. z2r{z4l-z4r}
+ .. z4l{z2l-z2r}
+ .. z3l{z1l-z1r}
+ .. z1l{z3r-z3l}
+ .. cycle;
+ fill pat;
+ fill pat shifted (space_between, 0);
+fet_endchar;
+
+
+fet_beginchar ("Straight caesura", "caesura.straight");
+ save slant, space_between, clearance;
+ save thick, ne, pat;
+ path pat;
+ pair ne;
+
+ slant = 2.0;
+ thick = 2.88 linethickness;
+
+ space_between# = 0.56 staff_space#;
+ clearance# = 0.2 staff_space#;
+
+ set_char_box (0, 2.0 staff_space#,
+ staff_space# - clearance#, 1.2 staff_space#);
+ define_whole_pixels (space_between);
+
+ x1 = 0;
+ x2 = x1 + thick;
+ y1 = y2 = -d;
+
+ x3 = x4 + thick;
+ x4 = x1 + (h + d) / slant;
+ y3 = y4 = h;
+
+ ne = unitvector (z4 - z1);
+
+ z1a = z1 + blot_diameter * ne;
+ z1b = z1 + blot_diameter * right;
+ z2a = z2 + blot_diameter * ne;
+ z2b = z2 + blot_diameter * left;
+
+ z3a = z3 - blot_diameter * ne;
+ z3b = z3 + blot_diameter * left;
+ z4a = z4 - blot_diameter * ne;
+ z4b = z4 + blot_diameter * right;
+
+ pat = z1a{-ne}
+ .. {right}z1b
+ -- z2b{right}
+ .. {ne}z2a
+ -- z3a{ne}
+ .. {left}z3b
+ -- z4b{left}
+ .. {-ne}z4a
+ -- cycle;
+
+ fill pat;
+ fill pat shifted (space_between, 0);
+
+ labels(range 1 thru 4);
+ labels(1a, 1b, 2a, 2b, 3a, 3b, 4a, 4b);