]> git.donarmstrong.com Git - lilypond.git/commitdiff
Consider accidentals in optical spacing correction.
authorNeil Puttock <n.puttock@gmail.com>
Mon, 20 Jul 2009 00:00:20 +0000 (01:00 +0100)
committerNeil Puttock <n.puttock@gmail.com>
Mon, 20 Jul 2009 00:00:20 +0000 (01:00 +0100)
- if accidentals are detected sticking out of the right hand stem,
apply spacing correction if stem directions are different
(cherry picked from commit 452c8141d29c8a070d349f2798f2695ff8defd94)

input/regression/spacing-correction-accidentals.ly [new file with mode: 0644]
lily/note-spacing.cc

diff --git a/input/regression/spacing-correction-accidentals.ly b/input/regression/spacing-correction-accidentals.ly
new file mode 100644 (file)
index 0000000..b6c342a
--- /dev/null
@@ -0,0 +1,13 @@
+\version "2.12.3"
+
+\header {
+  texidoc = "If right hand stems have accidentals, optical spacing
+correction is still applied, but only if the stem directions are
+different."
+}
+
+\relative c' {
+  \time 2/4
+  c8 cis''
+  cis8 cis,,
+}
index 24e79cd313b8c190fc72b911f705a76190b49e37..bd796a71354f5d2376164781befe70a7f852a5cd 100644 (file)
@@ -191,7 +191,7 @@ same_direction_correction (Grob *note_spacing, Drul_array<Interval> head_posns)
 }
 
 
-/**
+/*
    Correct for optical illusions. See [Wanske] p. 138. The combination
    up-stem + down-stem should get extra space, the combination
    down-stem + up-stem less.
@@ -219,6 +219,8 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn,
 
   Direction d = LEFT;
 
+  bool acc_right = false;
+
   Grob *bar = Spacing_interface::extremal_break_aligned_grob (me, RIGHT,
                                                              rcolumn->break_status_dir (),
                                                              &bar_xextent);
@@ -235,10 +237,10 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn,
            continue;
 
          /*
-           don't correct if accidentals are sticking out of the right side.
+           Find accidentals which are sticking out of the right side.
          */
-         if (d == RIGHT && Note_column::accidentals (it))
-           return;
+        if (d == RIGHT)
+            acc_right = acc_right || Note_column::accidentals (it);
 
          Grob *stem = Note_column::get_stem (it);
 
@@ -306,7 +308,12 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn,
            correction *= 0.5;
        }
     }
-  else if (stem_dirs[LEFT] * stem_dirs[RIGHT] == 1)
+  /*
+    Only apply same direction correction if there are no
+    accidentals sticking out of the right hand side.
+  */
+  else if (stem_dirs[LEFT] * stem_dirs[RIGHT] == 1
+          && !acc_right)
     correction = same_direction_correction (me, head_posns);
 
   *space += correction;