]> git.donarmstrong.com Git - lilypond.git/blobdiff - mf/feta-toevallig.mf
Run `make grand-replace'.
[lilypond.git] / mf / feta-toevallig.mf
index f473e236f0493fe3a9c1b876e609b36aa4677fd7..80e81055409629b58e42386667319ff78caaddc7 100644 (file)
@@ -1,10 +1,23 @@
 %
 % feta-toevallig.mf -- implement Accidentals
 %
-% source file of the Feta (Font-En-Tja) music font
+% (c) 1997--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
 %
-% (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+
+%
+% also show in other configuration wrt staff lines.
 %
+def draw_shifted_too =
+if test > 0:
+       fet_beginchar ("shifted too", "");
+               set_char_box (0, 0, 0, 0);
+               currentpicture := remember_pic;
+
+               draw_staff (-2, 2, 0.5);
+       fet_endchar;
+fi;
+enddef;
 
 
 %
 %
 
 
+%
+% Naming for accidentals (including microtonal variants):
+%
+%   SHARPBASE[.SLASHES.STEMS]
+%   FLATBASE[.MODIFIER]
+%  
+% Examples:
+%
+%   sharp.slashslash.stem
+%   mirroredflat.flat
+%
+%
+
+
 fet_begingroup ("accidentals");
 
 
 save remember_pic;
 picture remember_pic;
 
+save sharp_beamheight;
+sharp_beamheight# := 0.3 staff_space# + stafflinethickness#;
 
 %
 % The beams of most sharps have horizontal endings (as if drawn with
@@ -29,28 +58,27 @@ picture remember_pic;
 %
 
 def draw_meta_sharp (expr width, offset) =
-       save beamheight, beamwidth, beamslope;
+       save beamwidth, beamslope;
        save ne, nw_dist;
        pair ne, nw_dist;
 
        beamwidth := width;
 
-       beamheight# := 0.3 staff_space# + stafflinethickness#;
-       define_whole_vertical_blacker_pixels (beamheight);
+       define_whole_vertical_blacker_pixels (sharp_beamheight);
 
        clearxy;
 
-       beamslope = beamheight / beamwidth;
+       beamslope = sharp_beamheight / beamwidth;
 
        pickup pencircle scaled 2 blot_diameter;
 
        rt x2 - lft x1 = beamwidth;
-       y2 - y1 = beamheight;
+       z2 = z1 + whatever * (beamwidth, sharp_beamheight);
        .5 [z1, z3] = (.5 w, offset);
        x3 = x2;
-       top y2 - bot y3 = beamheight;
+       top y2 - bot y3 = sharp_beamheight;
        x4 = x1;
-       top y1 - bot y4 = beamheight;
+       top y1 - bot y4 = sharp_beamheight;
 
        ne = unitvector (z2 - z1);
        nw_dist = (ne rotated 90) * blot_diameter;
@@ -69,7 +97,7 @@ def draw_meta_sharp (expr width, offset) =
 enddef;
 
 
-fet_beginchar ("Sharp", "2");
+fet_beginchar ("Sharp", "sharp");
        save stem, stemx, stemwidth;
        save outer_space, interbeam;
 
@@ -111,20 +139,10 @@ fet_beginchar ("Sharp", "2");
 fet_endchar;
 
 
-if test > 0:
-       fet_beginchar ("Sharp", "2");
+draw_shifted_too;
 
-               set_char_box (0, 1.1 staff_space#,
-                             1.5 staff_space#, 1.5 staff_space#);
-
-               currentpicture := remember_pic;
 
-               draw_staff (-2, 2, 0.5);
-       fet_endchar;
-fi;
-
-
-fet_beginchar ("1/2 Sharp", "1");
+fet_beginchar ("1/2 Sharp", "sharp.slashslash.stem");
        save stem, stemwidth;
        save outer_space, interbeam;
 
@@ -161,20 +179,104 @@ fet_beginchar ("1/2 Sharp", "1");
 fet_endchar;
 
 
-if test > 0:
-       fet_beginchar ("1/2 Sharp", "1");
+draw_shifted_too;
 
-               set_char_box (0, 0.7 staff_space#,
-                             1.5 staff_space#, 1.5 staff_space#);
 
-               currentpicture := remember_pic;
+fet_beginchar ("Sharp (3 beams)", "sharp.slashslashslash.stemstem");
+       save stem, stemx, stemwidth;
+       save outer_space, interbeam;
+       save sharp_beamheight;
 
-               draw_staff (-2, 2, 0.5);
-       fet_endchar;
-fi;
+       sharp_beamheight# := 0.22 staff_space# + stafflinethickness#;
+
+       stemwidth# := stafflinethickness# + .05 staff_space#;
+       define_whole_blacker_pixels (stemwidth);
+
+       interbeam := 1.2 staff_space_rounded;
+
+       set_char_box (0, 1.1 staff_space#,
+                     1.5 staff_space#, 1.5 staff_space#);
+
+       stem := 7 / 16 * w;
+       stemx := hround stem;
+       outer_space := hround ((w - stemx - stemwidth) / 2);
+
+       w := 2 outer_space + stemx + stemwidth;
+       d := d - feta_space_shift;
+
+       draw_meta_sharp (.88 w, -.5 interbeam);
+       draw_meta_sharp (.88 w, -.5 interbeam + vround interbeam);
+       sharp_beamheight# := 1/.88 sharp_beamheight#;
+       draw_meta_sharp (w, 0);
+
+       pickup pencircle scaled stemwidth;
+
+       lft x5 = lft x6 = outer_space;
+       lft x7 = lft x8 = outer_space + stemx;
+       bot y5 = -d;
+       top y6 = vround (1.5 staff_space - stem * beamslope);
+       bot y7 = -top y6 + feta_space_shift;
+       top y8 = h;
+
+       labels (5, 6, 7, 8);    
+
+       draw_gridline (z5, z6, stemwidth);
+       draw_gridline (z7, z8, stemwidth);
+
+       remember_pic := currentpicture;
+
+       draw_staff (-2, 2, 0);
+fet_endchar;
+
+
+draw_shifted_too;
+
+
+fet_beginchar ("1/2 Sharp (3 beams)", "sharp.slashslashslash.stem");
+       save stem, stemx, stemwidth;
+       save outer_space, interbeam;
+       save sharp_beamheight;
+
+       sharp_beamheight# := 0.22 staff_space# + stafflinethickness#;
+
+       stemwidth# := stafflinethickness# + .05 staff_space#;
+       define_whole_blacker_pixels (stemwidth);
+
+       interbeam := 1.2 staff_space_rounded;
+
+       set_char_box (0, 0.95 staff_space#,
+                     1.3 staff_space#, 1.3 staff_space#);
 
+       stem := 7 / 16 * w;
+       outer_space := hround ((w - stemwidth) / 2);
+
+       w := 2 outer_space + stemwidth;
+       d := d - feta_space_shift;
+
+       draw_meta_sharp (.8 w, -.5 interbeam);
+       draw_meta_sharp (.8 w, -.5 interbeam + vround interbeam);
+       sharp_beamheight# := 1/.8 sharp_beamheight#;
+       draw_meta_sharp (w, 0);
+
+       pickup pencircle scaled stemwidth;
+
+       lft x5 = lft x6 = outer_space;
+       top y6 = vround (1.5 staff_space - .5 stem);
+       bot y5 = -top y6 + feta_space_shift;
+       labels (5, 6);
+
+       draw_gridline (z5, z6, stemwidth);
+
+       remember_pic := currentpicture;
+
+       draw_staff (-2, 2, 0);
+fet_endchar;
 
-fet_beginchar ("3/4 Sharp", "3");
+
+draw_shifted_too;
+
+
+fet_beginchar ("3/4 Sharp", "sharp.slashslash.stemstemstem");
        save stem, stemx, stemwidth;
        save outer_space, interbeam;
 
@@ -220,24 +322,14 @@ fet_beginchar ("3/4 Sharp", "3");
 fet_endchar;
 
 
-if test > 0:
-       fet_beginchar ("3/4 Sharp", "3");
-
-               set_char_box (0, 1.6 staff_space#,
-                             1.5 staff_space#, 1.5 staff_space#);
-
-               currentpicture := remember_pic;
-
-               draw_staff (-2, 2, 0.5);
-       fet_endchar;
-fi;
+draw_shifted_too;
 
 
 %
 % The stems of the natural are brushed (at least, in Barenreiter SCS)
 %
 
-fet_beginchar ("Natural", "0");
+fet_beginchar ("Natural", "natural");
        save stemwidth, top_stem_thick;
        save ne, pat_top, pat_bottom;
        pair ne;
@@ -325,16 +417,7 @@ fet_beginchar ("Natural", "0");
 fet_endchar;
 
 
-if test > 0:
-       fet_beginchar ("Natural", "0");
-               set_char_box (0, 2/3 staff_space#,
-                             1.5 staff_space#, 1.5 staff_space#);
-
-               currentpicture := remember_pic;
-
-               draw_staff (-2, 2, 0.5);
-       fet_endchar;
-fi;
+draw_shifted_too;
 
 
 %
@@ -369,7 +452,7 @@ def draw_meta_flat (expr xcenter, w, crook_fatness) =
                smaller_hole = 0.35 stafflinethickness;
        else:
                smaller_hole = 0;
-       fi
+       fi;
        clearing = 1.7 stafflinethickness;
        crook_thinness = .7 stafflinethickness + .06 staff_space;
        top_crook_thinness = 1 stafflinethickness + .065 staff_space;
@@ -455,7 +538,7 @@ enddef;
 % unfortunately, 600dpi is not enough to show the brush of the stem.
 %
 
-fet_beginchar ("Flat", "-2");
+fet_beginchar ("Flat", "flat");
        set_char_box (1.2 stafflinethickness#, .8 staff_space#,
                      0.6 staff_space#, 1.9 staff_space#);
 
@@ -468,19 +551,228 @@ fet_beginchar ("Flat", "-2");
 fet_endchar;
 
 
-if test > 0:
-       fet_beginchar ("Flat", "-2");
-               set_char_box (1.2 stafflinethickness#, .8 staff_space#,
-                             0.6 staff_space#, 1.9 staff_space#);
+draw_shifted_too;
 
-               currentpicture := remember_pic;
 
-               draw_staff (-2, 2, 0.5);
-       fet_endchar;
-fi;
+fet_beginchar ("Flat (slashed)", "flat.slash");
+       set_char_box (.4 staff_space#, .8 staff_space#,
+                     0.6 staff_space#, 1.9 staff_space#);
+
+       draw_meta_flat (0, w, 0.31 staff_space);
+
+       clearxy;
+
+       save slope, slash_width;
+       slope = 0.5;
+       slash_width = w;
+
+       z11 = (0, h / 2);
+       z12 = z11 - (slash_width, slash_width * slope) / 2;
+       z13 = z11 + (slash_width, slash_width * slope) / 2;
+       penpos12 (1.5 stafflinethickness, angle (z13 - z12) - 90);
+       penpos13 (1.5 stafflinethickness, angle (z13 - z12) - 90);
+
+       z14 = z12 - .75 stafflinethickness * unitvector (z13 - z12);
+       z15 = z13 + .75 stafflinethickness * unitvector (z13 - z12);
+
+       fill z13r
+            .. z15
+            .. z13l
+            -- z12l
+            .. z14
+            .. z12r
+            -- z13r
+            .. cycle;
+
+       penlabels (12, 13);
+       labels (14, 15);
+
+       remember_pic := currentpicture;
+
+       draw_staff (-2, 2, 0);
+fet_endchar;
+
+
+fet_beginchar ("Flat (slashed twice)", "flat.slashslash");
+       set_char_box (.4 staff_space#, .8 staff_space#,
+                     0.6 staff_space#, 1.9 staff_space#);
+
+       draw_meta_flat (0, w, 0.31 staff_space);
+
+       clearxy;
+
+       save slope, slash_width;
+       slope = 0.5;
+       slash_width = w;
+
+       z11 = (0, 5/12 h);
+       z12 = z11 - (slash_width, slash_width * slope) / 2;
+       z13 = z11 + (slash_width, slash_width * slope) / 2;
+       penpos12 (1.5 stafflinethickness, angle (z13 - z12) - 90);
+       penpos13 (1.5 stafflinethickness, angle (z13 - z12) - 90);
+
+       z14 = z12 - .75 stafflinethickness * unitvector (z13 - z12);
+       z15 = z13 + .75 stafflinethickness * unitvector (z13 - z12);
 
+       fill z13r
+            .. z15
+            .. z13l
+            -- z12l
+            .. z14
+            .. z12r
+            -- z13r
+            .. cycle;
+
+       penlabels (12, 13);
+       labels (14, 15);
+
+       z21 = (0, 2/3 h);
+       z22 = z21 - (slash_width, slash_width * slope) / 2;
+       z23 = z21 + (slash_width, slash_width * slope) / 2;
+       penpos22 (1.5 stafflinethickness, angle (z23 - z22) - 90);
+       penpos23 (1.5 stafflinethickness, angle (z23 - z22) - 90);
+
+       z24 = z22 - .75 stafflinethickness * unitvector (z23 - z22);
+       z25 = z23 + .75 stafflinethickness * unitvector (z23 - z22);
+
+       fill z23r
+            .. z25
+            .. z23l
+            -- z22l
+            .. z24
+            .. z22r
+            -- z23r
+            .. cycle;
+
+       penlabels (22, 23);
+       labels (24, 25);
+
+       remember_pic := currentpicture;
+
+       draw_staff (-2, 2, 0);
+fet_endchar;
+
+
+fet_beginchar ("Flatflat (mirrored)", "mirroredflat.flat");
+       set_char_box (0, 1.6 staff_space#, 
+                     0.6 staff_space#, 1.9 staff_space#);
+
+       % This is a modified version of `draw_meta_flat'.
+
+       save crook_thinness, crook_fatness;
+       save bottom_overshoot, bot_crook_dir;
+       save top_stem_thick, bottom_stem_thick, hair, smaller_hole;
+       save top_crook_thinness;
+       save zwiep;
+       save center;
+       pair center, bot_crook_dir;
+       save clearing, wid;
+       save pat;
+       path pat;
+
+       clearxy;
+
+       wid = w / 2;
+
+       % the stem shouldn't reach the top staff line.
+       %% TODO: should take from height.
+       %
+       % TODO: parameterize this
+       %
+       if wid >= 0.75 staff_space:
+               smaller_hole = 0.35 stafflinethickness;
+       else:
+               smaller_hole = 0;
+       fi;
+       clearing = 1.7 stafflinethickness;
+       crook_thinness = .7 stafflinethickness + .06 staff_space;
+       crook_fatness = 0.31 staff_space;
+       top_crook_thinness = 1 stafflinethickness + .065 staff_space;
+       bottom_overshoot = stafflinethickness;
+
+       bottom_stem_thick# = 0.06 staff_space# + 0.6 stafflinethickness#;
+       top_stem_thick# = 0.1 staff_space# + 1.2 stafflinethickness#;
+       define_whole_blacker_pixels (bottom_stem_thick, top_stem_thick);
+
+       if odd (top_stem_thick - bottom_stem_thick):
+               top_stem_thick := top_stem_thick - 1;
+       fi;
+
+       center = (0, 0);
+
+       x1l = hround (-.5 top_stem_thick);
+       y1 = vround (2 staff_space - clearing);
+       x2l = hround (-.5 bottom_stem_thick);
+       y2 = -.5 staff_space - .5 stafflinethickness;
+
+       penpos1 (top_stem_thick, 0);
+       penpos2 (bottom_stem_thick, 0);
+
+       y3l = vfloor ((staff_space - stafflinethickness) / 2);
+       z3l = whatever [z2r, z1r];
+       z3r = .3 [z2r, z1r] + (smaller_hole, 0);
+       x3r := hceiling x3r;
+
+       z10 = whatever [z2r, z1r] + (smaller_hole, 0);
+       y10 = -1/10 staff_space;
+       x10 := hceiling x10;
+
+       x11 = bottom_overshoot / 3;
+       y11 = -vround (.5 (staff_space + stafflinethickness)
+                      + bottom_overshoot);
+
+       penpos4 (whatever, 53);
+
+       y4l - y4r = top_crook_thinness;
+       y5r = .15 staff_space;
+       x5l = hround (wid);
+       y4 = staff_space / 2;
+       x4r = .45 [x5r, x3r];
+       y4l := vround y4l;
+
+       penpos5 (crook_fatness, -175);
+
+       bot_crook_dir = unitvector ((x5l, 0) - z11);
+       z8 = z11 + whatever * bot_crook_dir;
+       y8 = -staff_space / 2;
+
+       z7 = z8
+            + whatever * bot_crook_dir
+            + crook_thinness * (bot_crook_dir rotated 90);
+       x7 = .1 [x3r, x8];
 
-fet_beginchar ("Semi flat", "-1");
+       pat := z3r{z3r - z10}
+              .. z4r{right}
+              .. z5r{down}
+              .. z7{-bot_crook_dir}
+              & z7
+              .. z10{z3r - z10}
+              -- cycle;
+       unfill pat;
+       unfill pat xscaled -1;
+
+       pat := z11{right}
+              .. z8{bot_crook_dir}
+              .. z5l{up}
+              .. z4l{left}
+              .. z3l;
+       fill pat
+            -- simple_serif (z1r, z1l, 30)
+            -- reverse pat xscaled -1 shifted (-feta_eps, 0)
+            -- cycle;
+
+       currentpicture := currentpicture shifted (w/2, 0);
+
+       remember_pic := currentpicture;
+
+       draw_staff (-2, 2, 0);
+fet_endchar;
+
+
+draw_shifted_too;
+
+
+fet_beginchar ("Semi flat", "mirroredflat");
        set_char_box (1.2 stafflinethickness#, .8 staff_space#,
                      0.6 staff_space#, 1.9 staff_space#);
 
@@ -489,7 +781,43 @@ fet_beginchar ("Semi flat", "-1");
 fet_endchar;
 
 
-fet_beginchar ("Double Flat", "-4");
+fet_beginchar ("Semi flat", "mirroredflat.backslash");
+       set_char_box (.4 staff_space#, .8 staff_space#,
+                     0.6 staff_space#, 1.9 staff_space#);
+
+       draw_meta_flat (0, w, 0.31 staff_space);
+
+       clearxy;
+
+       save slope, slash_width;
+       slope = 0.5;
+       slash_width = w;
+
+       z11 = (0, h / 2);
+       z12 = z11 - (slash_width, slash_width * slope) / 2;
+       z13 = z11 + (slash_width, slash_width * slope) / 2;
+       penpos12 (1.5 stafflinethickness, angle (z13 - z12) - 90);
+       penpos13 (1.5 stafflinethickness, angle (z13 - z12) - 90);
+
+       z14 = z12 - .75 stafflinethickness * unitvector (z13 - z12);
+       z15 = z13 + .75 stafflinethickness * unitvector (z13 - z12);
+
+       fill z13r
+            .. z15
+            .. z13l
+            -- z12l
+            .. z14
+            .. z12r
+            -- z13r
+            .. cycle;
+
+       currentpicture := currentpicture xscaled -1 shifted (w - b, 0);
+
+       labels (1, 2, 3);
+fet_endchar;
+
+
+fet_beginchar ("Double Flat", "flatflat");
        save left_wid, overlap, right_wid;
 
        left_wid = .7;
@@ -500,12 +828,12 @@ fet_beginchar ("Double Flat", "-4");
                      (left_wid + right_wid - overlap) * staff_space#,
                      .6 staff_space#, 1.9 staff_space#);
        draw_meta_flat (0, left_wid * staff_space, 1/3 staff_space);
-       draw_meta_flat (round ((left_wid - overlap) * staff_space),
-                       right_wid * staff_space, 0.33 staff_space);
+       draw_meta_flat (hround ((left_wid - overlap) * staff_space),
+                       right_wid * staff_space, 1/3 staff_space);
 fet_endchar;
 
 
-fet_beginchar ("3/4 Flat", "-3");
+fet_beginchar ("3/4 Flat", "flatflat.slash");
        save left_wid, overlap, right_wid;
 
        left_wid = .7;
@@ -516,8 +844,8 @@ fet_beginchar ("3/4 Flat", "-3");
                      (left_wid + right_wid - overlap) * staff_space#,
                      .6 staff_space#, 1.9 staff_space#);
        draw_meta_flat (0, left_wid * staff_space, 1/3 staff_space);
-       draw_meta_flat (round ((left_wid - overlap) * staff_space),
-                       right_wid * staff_space, 0.33 staff_space);
+       draw_meta_flat (hround ((left_wid - overlap) * staff_space),
+                       right_wid * staff_space, 1/3 staff_space);
 
        %% maybe we should clip part of the stems?
        %% or make the 1st flat smaller?
@@ -537,7 +865,7 @@ fet_beginchar ("3/4 Flat", "-3");
             .. z13l
             -- z12l
             .. z14
-            .. z12 r
+            .. z12r
             -- z13r
             .. cycle;
 
@@ -550,26 +878,10 @@ fet_beginchar ("3/4 Flat", "-3");
 fet_endchar;
 
 
-if test > 0:
-       fet_beginchar ("3/4 Flat", "-3");
-               save left_wid, overlap, right_wid;
-
-               left_wid = .7;
-               right_wid = .8;
-               overlap = .05;
+draw_shifted_too;
 
-               set_char_box (1.2 stafflinethickness#,
-                             (left_wid + right_wid - overlap) * staff_space#,
-                             .6 staff_space#, 1.9 staff_space#);
-
-               currentpicture := remember_pic;
 
-               draw_staff (-2, 2, 0.5);
-       fet_endchar;
-fi;
-
-
-fet_beginchar ("Double Sharp", "4");
+fet_beginchar ("Double Sharp", "doublesharp");
        save klaverblad, klaversteel;
        save pat;
        path pat;
@@ -623,16 +935,7 @@ fet_beginchar ("Double Sharp", "4");
 fet_endchar;
 
 
-if test > 0:
-       fet_beginchar ("Double Sharp", "4");
-               set_char_box (0, staff_space#,
-                             .5 staff_space#, .5 staff_space#);
-
-               currentpicture := remember_pic;
-
-               draw_staff (-2, 2, 0.5);
-       fet_endchar;
-fi;
+draw_shifted_too;
 
 
 def draw_paren =
@@ -672,16 +975,7 @@ fet_beginchar ("Right Parenthesis", "rightparen");
 fet_endchar;
 
 
-if test > 0:
-       fet_beginchar ("Right Parenthesis", "rightparen");
-               draw_paren;
-               penlabels (1, 2, 3);
-
-               remember_pic := currentpicture;
-
-               draw_staff (-2, 2, 0.5);
-       fet_endchar;
-fi;
+draw_shifted_too;
 
 
 fet_beginchar ("Left Parenthesis", "leftparen");
@@ -692,5 +986,4 @@ fet_beginchar ("Left Parenthesis", "leftparen");
        set_char_box (charwd, charbp, chardp, charht);
 fet_endchar;
 
-
 fet_endgroup ("accidentals");