From 2aa1d6f450a7f051aa4b0ddcaf89593f7ff23a60 Mon Sep 17 00:00:00 2001 From: Trevor Daniels Date: Sat, 9 Apr 2011 10:43:57 +0100 Subject: [PATCH] Suppress continuing LyricHyphen under grace note at start of line - improved fix to 688/1590. Simpler and use of callback gives flexibility * lyric-hyphen-grace.ly regression test * lily/spanner.cc exclude grace part from test in kill_zero_spanned_time * scm/define-grobs.scm add kill-zero-spanned-time as after-line-breaking callback to LyricHyphen --- input/regression/lyric-hyphen-grace.ly | 31 ++++++++++++++++++++++++++ lily/spanner.cc | 22 +++++++++--------- scm/define-grobs.scm | 1 + 3 files changed, 43 insertions(+), 11 deletions(-) create mode 100644 input/regression/lyric-hyphen-grace.ly diff --git a/input/regression/lyric-hyphen-grace.ly b/input/regression/lyric-hyphen-grace.ly new file mode 100644 index 0000000000..46d47e576a --- /dev/null +++ b/input/regression/lyric-hyphen-grace.ly @@ -0,0 +1,31 @@ +\header { + + texidoc = "No hyphen should be printed under a grace note at the start +of a line if the grace's main note starts a new syllable." +} + +\version "2.13.59" +<< + \new Staff { + \appoggiatura f'8 g'2 g'( | \break + \appoggiatura f'8 g'2) \appoggiatura f'8 g'2 | \break + \appoggiatura f'8 g'2 g' | \break + g'2 g' | + } + \addlyrics { + \lyricmode { + bla -- bla -- bla -- bla -- bla -- bla -- bla + } + } + \new Staff { + g'2 g' | + g'2 g' | + g'2 g' | + g'2 g' | + } + \addlyrics { + \lyricmode { + bla -- bla -- bla -- bla -- bla -- bla -- bla -- bla + } + } +>> diff --git a/lily/spanner.cc b/lily/spanner.cc index d3fd5a0955..1f77c8e257 100644 --- a/lily/spanner.cc +++ b/lily/spanner.cc @@ -80,7 +80,7 @@ Spanner::do_break_processing () Slice parent_rank_slice; parent_rank_slice.set_full (); - + /* Check if our parent in X-direction spans equally wide or wider than we do. @@ -90,7 +90,7 @@ Spanner::do_break_processing () if (Spanner *parent = dynamic_cast (get_parent ((Axis)a))) parent_rank_slice.intersect (parent->spanned_rank_interval ()); } - + for (vsize i = 1; i < break_points.size (); i++) { Drul_array bounds; @@ -112,15 +112,15 @@ Spanner::do_break_processing () bool ok = parent_rank_slice.contains (bounds[LEFT]->get_column ()->get_rank ()); ok = ok && parent_rank_slice.contains (bounds[RIGHT]->get_column ()->get_rank ()); - + if (!ok) { programming_error (to_string ("Spanner `%s' is not fully contained in parent spanner. Ignoring orphaned part", name ().c_str ())); continue; } - - + + Spanner *span = dynamic_cast (clone ()); span->set_bound (LEFT, bounds[LEFT]); span->set_bound (RIGHT, bounds[RIGHT]); @@ -372,7 +372,7 @@ Spanner::set_spacing_rods (SCM smob) sp->get_bound (RIGHT)); if (!bounds[LEFT] || !bounds[RIGHT]) return SCM_UNSPECIFIED; - + vector cols (root->broken_col_range (bounds[LEFT]->get_column (), bounds[RIGHT]->get_column ())); @@ -383,18 +383,18 @@ Spanner::set_spacing_rods (SCM smob) r.item_drul_[RIGHT] = cols[0]->find_prebroken_piece (LEFT); r.distance_ = robust_scm2double (num_length, 0); r.add_to_cols (); - + r.item_drul_[LEFT] = cols.back ()->find_prebroken_piece (RIGHT); r.item_drul_[RIGHT] = sp->get_bound (RIGHT); r.add_to_cols (); } - + r.distance_ = robust_scm2double (num_length, 0); r.item_drul_[LEFT] = sp->get_bound (LEFT); r.item_drul_[RIGHT] = sp->get_bound (RIGHT); r.add_to_cols (); } - + return SCM_UNSPECIFIED; } @@ -461,7 +461,7 @@ Spanner::bounds_width (SCM grob) Interval w (me->get_bound (LEFT)->relative_coordinate (common, X_AXIS), me->get_bound (RIGHT)->relative_coordinate (common, X_AXIS)); - + w -= me->relative_coordinate (common, X_AXIS); return ly_interval2scm (w); @@ -488,6 +488,7 @@ Spanner::kill_zero_spanned_time (SCM grob) --hwn. */ + moments [LEFT].grace_part_ = 0; if (moments.length () == Moment (0, 0)) me->suicide (); @@ -530,4 +531,3 @@ ADD_INTERFACE (Spanner, "minimum-length " "to-barline " ); - diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 0be8fb44fd..0048dc8598 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -1191,6 +1191,7 @@ (LyricHyphen . ( + (after-line-breaking . ,ly:spanner::kill-zero-spanned-time) (dash-period . 10.0) (height . 0.42) (length . 0.66) -- 2.39.5