]> git.donarmstrong.com Git - lilypond.git/commitdiff
Cleaning Feta flags code
authorJanek Warchoł <lemniskata.bernoulliego@gmail.com>
Fri, 25 Feb 2011 10:16:33 +0000 (11:16 +0100)
committerGraham Percival <graham@percival-music.ca>
Wed, 9 Mar 2011 11:32:08 +0000 (11:32 +0000)
This patch makes flags code more uniform and easier to maintain.
There is no actual change to the font itself, only to the way it is coded.

mf/feta-flags.mf

index 9cf49030679c5f16b98a4227a1fcb0948205e297..90407a456fb9a26f491219d0413c8ef63e621808 100644 (file)
@@ -135,24 +135,31 @@ enddef;
 
 fet_beginchar ("8th Flag (up)", "u3");
        save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
+       save flagspace, total_depth, flag_count;
 
+       flag_count = 1;
+       total_depth# = 3 staff_space# - blot_diameter# / 2;
        flare = staff_space;
+       flagspace# = staff_space#;
        hip_depth_ratio = .72;
-       foot_width_ratio = .8;
        hip_width# = upflag_width# - hip_thickness# / 2;
-       foot_depth# = 3 staff_space# - blot_diameter# / 2;
+       foot_width_ratio = .8;
+
+       (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
+
        define_pixels (hip_width, foot_depth);
+       define_whole_vertical_pixels (flagspace);
 
-       set_char_box (0,
-                     hip_width# + stemthickness# / 2 + right_upflag_space#,
+       set_char_box (0, hip_width# + stemthickness# / 2 + right_upflag_space#,
                      foot_depth# + foot_thickness# / 2, stemthickness# / 2);
 
-       draw_flag ((0,0), flare, (hip_width, foot_depth),
+       draw_flag ((0, -(flag_count - 1) * flagspace),
+                  flare, (hip_width, foot_depth),
                   hip_depth_ratio, foot_width_ratio,
                   hip_thickness, foot_thickness, 1);
 
-       draw_square_block ((-0.5 stemthickness_rounded, -staff_space_rounded),
-                          (0, 0));
+       draw_square_block ((-0.5 stemthickness_rounded, 0),
+                          (0, (-flag_count * staff_space_rounded)));
 fet_endchar;
 
 
@@ -160,22 +167,24 @@ fet_beginchar ("16th Flag (up)", "u4");
        save flare, hip_depth_ratio, hip_width, foot_depth, foot_width_ratio;
        save flagspace, total_depth, flag_count;
 
-       total_depth# = 3.5 staff_space# - blot_diameter# / 2;
        flag_count = 2;
+       total_depth# = 3.5 staff_space# - blot_diameter# / 2;
        flare = .85 staff_space;
        flagspace# = .85 staff_space#;
        hip_depth_ratio = .72;
        hip_width# = upflag_width# - hip_thickness# / 2;
-       flagspace# + foot_depth# = total_depth#;
        foot_width_ratio = .8;
+
+       (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
+
        define_pixels (hip_width, foot_depth);
        define_whole_vertical_pixels (flagspace);
 
-       set_char_box (0,
-                     hip_width# + stemthickness# / 2 + right_upflag_space#,
+       set_char_box (0, hip_width# + stemthickness# / 2 + right_upflag_space#,
                      total_depth# + foot_thickness# / 2, stemthickness# / 2);
 
-       draw_flag ((0, -flagspace), flare, (hip_width, foot_depth),
+       draw_flag ((0, -(flag_count - 1) * flagspace),
+                  flare, (hip_width, foot_depth),
                   hip_depth_ratio, foot_width_ratio,
                   hip_thickness, foot_thickness, 1);
 
@@ -183,7 +192,7 @@ fet_beginchar ("16th Flag (up)", "u4");
                  hip_thickness, foot_thickness);
 
        draw_square_block ((-0.5 stemthickness_rounded, 0),
-                          (0, -2 staff_space_rounded));
+                          (0, (-flag_count * staff_space_rounded)));
 fet_endchar;
 
 
@@ -207,7 +216,8 @@ fet_beginchar ("32nd Flag (up)", "u5");
        set_char_box (0, hip_width# + right_upflag_space#,
                      total_depth# + foot_thickness# / 2, stemthickness# / 2);
 
-       draw_flag ((0, -2 flagspace), flare, (hip_width, foot_depth),
+       draw_flag ((0, -(flag_count - 1) * flagspace),
+                  flare, (hip_width, foot_depth),
                   hip_depth_ratio, foot_width_ratio,
                   hip_thickness, foot_thickness, 1);
 
@@ -217,7 +227,7 @@ fet_beginchar ("32nd Flag (up)", "u5");
                  hip_thickness, foot_thickness);
 
        draw_square_block ((-0.5 stemthickness_rounded, 0),
-                          (0, -3 staff_space_rounded));
+                          (0, (-flag_count * staff_space_rounded)));
 fet_endchar;
 
 
@@ -226,11 +236,11 @@ fet_beginchar ("64th Flag (up)", "u6");
        save flagspace, total_depth, flag_count;
 
        flag_count = 4;
+       total_depth# = 5.25 staff_space#;
        flare = .85 staff_space;
        flagspace# = .9 staff_space#;
        hip_depth_ratio = .72;
        hip_width# = upflag_width# - hip_thickness# / 2;
-       total_depth# = 5.25 staff_space#;
        foot_width_ratio = .8;
 
        (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
@@ -241,8 +251,8 @@ fet_beginchar ("64th Flag (up)", "u6");
        set_char_box (0, hip_width# + right_upflag_space#,
                      total_depth# + foot_thickness# / 2, stemthickness# / 2);
 
-       draw_flag ((0, -(flag_count - 1) * flagspace), flare,
-                  (hip_width, foot_depth),
+       draw_flag ((0, -(flag_count - 1) * flagspace),
+                  flare, (hip_width, foot_depth),
                   hip_depth_ratio, foot_width_ratio,
                   hip_thickness, foot_thickness, 1);
 
@@ -254,7 +264,7 @@ fet_beginchar ("64th Flag (up)", "u6");
                  hip_thickness, foot_thickness);
 
        draw_square_block ((-0.5 stemthickness_rounded, 0),
-                          (0, -4 staff_space_rounded));
+                          (0, (-flag_count * staff_space_rounded)));
 fet_endchar;
 
 
@@ -263,11 +273,11 @@ fet_beginchar ("128th Flag (up)", "u7");
        save flagspace, total_depth, flag_count;
 
        flag_count = 5;
+       total_depth# = 6.25 staff_space#;
        flare = .85 staff_space;
        flagspace# = .93 staff_space#;
        hip_depth_ratio = .72;
        hip_width# = upflag_width# - hip_thickness# / 2;
-       total_depth# = 6.25 staff_space#;
        foot_width_ratio = .8;
 
        (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
@@ -278,8 +288,8 @@ fet_beginchar ("128th Flag (up)", "u7");
        set_char_box (0, hip_width# + right_upflag_space#,
                      total_depth# + foot_thickness# / 2, stemthickness# / 2);
 
-       draw_flag ((0, -(flag_count - 1) * flagspace), flare,
-                  (hip_width, foot_depth),
+       draw_flag ((0, -(flag_count - 1) * flagspace),
+                  flare, (hip_width, foot_depth),
                   hip_depth_ratio, foot_width_ratio,
                   hip_thickness, foot_thickness, 1);
 
@@ -293,7 +303,7 @@ fet_beginchar ("128th Flag (up)", "u7");
                  hip_thickness, foot_thickness);
 
        draw_square_block ((-0.5 stemthickness_rounded, 0),
-                          (0, -5 staff_space_rounded));
+                          (0, (-flag_count * staff_space_rounded)));
 fet_endchar;
 
 
@@ -302,107 +312,28 @@ fet_beginchar ("8th (down)", "d3");
        save flagspace, total_depth, flag_count;
 
        flag_count = 1;
+       total_depth# = 2.85 staff_space#;
        flare = staff_space;
        flagspace# = .9 staff_space#;
        hip_depth_ratio = .72;
        hip_width# = downflag_width# - hip_thickness# / 2;
-       total_depth# = 2.85 staff_space#;
        foot_width_ratio = .8;
 
        (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
 
-       define_pixels (hip_width, flagspace, foot_depth);
+       define_pixels (hip_width, foot_depth);
+       define_whole_vertical_pixels (flagspace);
 
        set_char_box (0, hip_width# + right_downflag_space#,
                      total_depth# + foot_thickness# / 2, stemthickness# / 2)
 
-       draw_flag ((0, -(flag_count - 1) * flagspace), flare,
-                  (hip_width, foot_depth),
+       draw_flag ((0, -(flag_count - 1) * flagspace),
+                  flare, (hip_width, foot_depth),
                   hip_depth_ratio, foot_width_ratio,
                   hip_thickness, foot_thickness, 0);
 
        draw_square_block ((-0.5 stemthickness_rounded, 0),
-                          (0, -staff_space_rounded));
-
-       y_mirror_char;
-fet_endchar;
-
-
-%%%%%%%%
-%
-% Single Stroke for Short Appogiatura
-%
-
-fet_beginchar ("grace dash (up)", "ugrace");
-       save flare, hip_depth_ratio, hip_width, foot_depth;
-
-       hip_depth_ratio = .72;
-       flare# = staff_space#;
-       hip_width# = upflag_width# - hip_thickness# / 2;
-       foot_depth# = 3 staff_space#;
-
-       define_pixels (hip_width, foot_depth);
-
-       set_char_box (hip_width# * hip_depth_ratio,
-                     hip_width# + right_upflag_space#,
-                     foot_depth# * hip_depth_ratio, -flare#)
-
-       pickup pencircle scaled 1.5 stemthickness;
-
-       z1 = (-b, -d);
-       z2 = (w, h);
-
-       penpos1 (1.5 stemthickness, angle (z2 - z1) - 90);
-       penpos2 (1.5 stemthickness, angle (z2 - z1) - 90);
-
-       fill z1l
-            -- z2l
-            .. top z2
-            .. rt z2
-            .. z2r
-            -- z1r
-            .. bot z1
-            .. lft z1
-            .. cycle;
-
-       penlabels (1, 2);
-fet_endchar;
-
-
-fet_beginchar ("grace dash (down)", "dgrace");
-       save flare, hip_depth_ratio, hip_width, foot_depth;
-       save total_depth;
-
-       hip_depth_ratio = .72 ;
-       flare# = .99 staff_space#;
-       hip_width# = downflag_width# - hip_thickness# / 2;
-       total_depth# = 2.85 staff_space#;
-       foot_depth# = total_depth#;
-       foot_width_ratio = .8;
-
-       define_pixels (hip_width, foot_depth);
-
-       set_char_box (hip_width# * hip_depth_ratio,
-                     hip_width# + right_downflag_space#,
-                     foot_depth# * hip_depth_ratio, -flare#)
-
-       pickup pencircle scaled 1.5 stemthickness;
-
-       z1 = (-b, -d);
-       z2 = (w, h);
-
-       penpos1 (1.5 stemthickness, angle (z2 - z1) - 90);
-       penpos2 (1.5 stemthickness, angle (z2 - z1) - 90);
-
-       fill z1l
-            -- z2l
-            .. top z2
-            .. rt z2
-            .. z2r
-            -- z1r
-            .. bot z1
-            .. lft z1
-            .. cycle;
+                          (0, (-flag_count * staff_space_rounded)));
 
        y_mirror_char;
 fet_endchar;
@@ -413,23 +344,23 @@ fet_beginchar ("16th (down)", "d4");
        save flagspace, total_depth, flag_count;
 
        flag_count = 2;
+       total_depth# = 3.0 staff_space# - blot_diameter# / 2;
        flare = .8 staff_space;
        flagspace# = .9 staff_space#;
        hip_depth_ratio = .85;
        hip_width# = downflag_width# - hip_thickness# / 2;
-       total_depth# = 3.0 staff_space# - blot_diameter# / 2;
        foot_width_ratio = .95;
 
        (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
 
-       set_char_box (0, hip_width# + right_downflag_space#,
-                     total_depth# + foot_thickness# / 2, stemthickness# / 2);
-
        define_pixels (hip_width, foot_depth);
        define_whole_vertical_pixels (flagspace);
 
-       draw_flag ((0, -(flag_count - 1) * flagspace), flare,
-                  (hip_width, foot_depth),
+       set_char_box (0, hip_width# + right_downflag_space#,
+                     total_depth# + foot_thickness# / 2, stemthickness# / 2);
+
+       draw_flag ((0, -(flag_count - 1) * flagspace),
+                  flare, (hip_width, foot_depth),
                   hip_depth_ratio, foot_width_ratio,
                   hip_thickness, foot_thickness, 0);
 
@@ -437,7 +368,7 @@ fet_beginchar ("16th (down)", "d4");
                  hip_thickness, foot_thickness);
 
        draw_square_block ((-0.5 stemthickness_rounded, 0),
-                          (0, -2 staff_space_rounded));
+                          (0, (-flag_count * staff_space_rounded)));
 
        y_mirror_char;
 fet_endchar;
@@ -448,11 +379,11 @@ fet_beginchar ("32nd (down)", "d5");
        save flagspace, total_depth, flag_count;
 
        flag_count = 3;
+       total_depth# = 3.85 staff_space#;
        flare = .84 staff_space;
        flagspace# = .9 staff_space#;
        hip_depth_ratio = .85;
        hip_width# = downflag_width# - hip_thickness# / 2;
-       total_depth# = 3.85 staff_space#;
        foot_width_ratio = .95;
 
        (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
@@ -463,8 +394,8 @@ fet_beginchar ("32nd (down)", "d5");
        set_char_box (0, hip_width# + right_downflag_space#,
                      total_depth# + foot_thickness# / 2, stemthickness# / 2);
 
-       draw_flag ((0, -(flag_count - 1) * flagspace), flare,
-                  (hip_width, foot_depth),
+       draw_flag ((0, -(flag_count - 1) * flagspace),
+                  flare, (hip_width, foot_depth),
                   hip_depth_ratio, foot_width_ratio,
                   hip_thickness, foot_thickness, 0);
 
@@ -474,7 +405,7 @@ fet_beginchar ("32nd (down)", "d5");
                  hip_thickness, foot_thickness);
 
        draw_square_block ((-0.5 stemthickness_rounded, 0),
-                          (0, -3 staff_space_rounded));
+                          (0, (-flag_count * staff_space_rounded)));
 
        y_mirror_char;
 fet_endchar;
@@ -485,11 +416,11 @@ fet_beginchar ("64th (down)", "d6");
        save flagspace, total_depth, flag_count;
 
        flag_count = 4;
+       total_depth# = 4.35 staff_space#;
        flare = .8 staff_space;
        flagspace# = .9 staff_space#;
        hip_depth_ratio = .85;
        hip_width# = downflag_width# - hip_thickness# / 2;
-       total_depth# = 4.35 staff_space#;
        foot_width_ratio = .98;
 
        (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
@@ -500,8 +431,8 @@ fet_beginchar ("64th (down)", "d6");
        set_char_box (0, hip_width# + right_downflag_space#,
                      total_depth# + foot_thickness# / 2, stemthickness# / 2);
 
-       draw_flag ((0, -(flag_count - 1) * flagspace), flare,
-                  (hip_width, foot_depth),
+       draw_flag ((0, -(flag_count - 1) * flagspace),
+                  flare, (hip_width, foot_depth),
                   hip_depth_ratio, foot_width_ratio,
                   hip_thickness, foot_thickness, 0);
 
@@ -513,7 +444,7 @@ fet_beginchar ("64th (down)", "d6");
                  hip_thickness, foot_thickness);
 
        draw_square_block ((-0.5 stemthickness_rounded, 0),
-                          (0, -4 staff_space_rounded));
+                          (0, (-flag_count * staff_space_rounded)));
 
        y_mirror_char;
 fet_endchar;
@@ -524,22 +455,23 @@ fet_beginchar ("128th (down)", "d7");
        save flagspace, total_depth, flag_count;
 
        flag_count = 5;
+       total_depth# = 5.25 staff_space#;
        flare = .8 staff_space;
        flagspace# = .9 staff_space#;
        hip_depth_ratio = .85;
        hip_width# = downflag_width# - hip_thickness# / 2;
-       total_depth# = 5.25 staff_space#;
        foot_width_ratio = .98;
 
        (flag_count - 1) * flagspace# + foot_depth# = total_depth#;
+
        define_pixels (hip_width, foot_depth);
        define_whole_vertical_pixels (flagspace);
 
        set_char_box (0, hip_width# + right_downflag_space#,
                      total_depth# + foot_thickness# / 2, stemthickness# / 2);
 
-       draw_flag ((0, -(flag_count - 1) * flagspace), flare,
-                  (hip_width, foot_depth),
+       draw_flag ((0, -(flag_count - 1) * flagspace),
+                  flare, (hip_width, foot_depth),
                   hip_depth_ratio, foot_width_ratio,
                   hip_thickness, foot_thickness, 0);
 
@@ -553,9 +485,90 @@ fet_beginchar ("128th (down)", "d7");
                  hip_thickness, foot_thickness);
 
        draw_square_block ((-0.5 stemthickness_rounded, 0),
-                          (0, -5 staff_space_rounded));
+                          (0, (-flag_count * staff_space_rounded)));
 
        y_mirror_char;
 fet_endchar;
 
+
+%%%%%%%%
+%
+% Single Stroke for Short Appogiatura
+%
+
+fet_beginchar ("grace dash (up)", "ugrace");
+       save flare, hip_depth_ratio, hip_width, foot_depth;
+
+       hip_depth_ratio = .72;
+       flare# = staff_space#;
+       hip_width# = upflag_width# - hip_thickness# / 2;
+       foot_depth# = 3 staff_space#;
+
+       define_pixels (hip_width, foot_depth);
+
+       set_char_box (hip_width# * hip_depth_ratio,
+                     hip_width# + right_upflag_space#,
+                     foot_depth# * hip_depth_ratio, -flare#)
+
+       pickup pencircle scaled 1.5 stemthickness;
+
+       z1 = (-b, -d);
+       z2 = (w, h);
+
+       penpos1 (1.5 stemthickness, angle (z2 - z1) - 90);
+       penpos2 (1.5 stemthickness, angle (z2 - z1) - 90);
+
+       fill z1l
+            -- z2l
+            .. top z2
+            .. rt z2
+            .. z2r
+            -- z1r
+            .. bot z1
+            .. lft z1
+            .. cycle;
+
+       penlabels (1, 2);
+fet_endchar;
+
+
+fet_beginchar ("grace dash (down)", "dgrace");
+       save flare, hip_depth_ratio, hip_width, foot_depth;
+       save total_depth;
+
+       hip_depth_ratio = .72 ;
+       flare# = .99 staff_space#;
+       hip_width# = downflag_width# - hip_thickness# / 2;
+       total_depth# = 2.85 staff_space#;
+       foot_depth# = total_depth#;
+       foot_width_ratio = .8;
+
+       define_pixels (hip_width, foot_depth);
+
+       set_char_box (hip_width# * hip_depth_ratio,
+                     hip_width# + right_downflag_space#,
+                     foot_depth# * hip_depth_ratio, -flare#)
+
+       pickup pencircle scaled 1.5 stemthickness;
+
+       z1 = (-b, -d);
+       z2 = (w, h);
+
+       penpos1 (1.5 stemthickness, angle (z2 - z1) - 90);
+       penpos2 (1.5 stemthickness, angle (z2 - z1) - 90);
+
+       fill z1l
+            -- z2l
+            .. top z2
+            .. rt z2
+            .. z2r
+            -- z1r
+            .. bot z1
+            .. lft z1
+            .. cycle;
+
+       y_mirror_char;
+fet_endchar;
+
+
 fet_endgroup ("flags");