From fe6ac195a56469e97baceeec305a1f23ce19e022 Mon Sep 17 00:00:00 2001 From: Neil Puttock Date: Mon, 20 Jul 2009 01:00:20 +0100 Subject: [PATCH] Consider accidentals in optical spacing correction. - if accidentals are detected sticking out of the right hand stem, apply spacing correction if stem directions are different (cherry picked from commit 452c8141d29c8a070d349f2798f2695ff8defd94) --- .../spacing-correction-accidentals.ly | 13 +++++++++++++ lily/note-spacing.cc | 17 ++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 input/regression/spacing-correction-accidentals.ly diff --git a/input/regression/spacing-correction-accidentals.ly b/input/regression/spacing-correction-accidentals.ly new file mode 100644 index 0000000000..b6c342a349 --- /dev/null +++ b/input/regression/spacing-correction-accidentals.ly @@ -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,, +} diff --git a/lily/note-spacing.cc b/lily/note-spacing.cc index 24e79cd313..bd796a7135 100644 --- a/lily/note-spacing.cc +++ b/lily/note-spacing.cc @@ -191,7 +191,7 @@ same_direction_correction (Grob *note_spacing, Drul_array 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; -- 2.39.2