From 255fe22c663dbbcb25b693fc8e60ca95343417ef Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Tue, 6 Nov 2012 17:43:45 +0100 Subject: [PATCH] Issue 2951: Allow music of nominally zero duration to be typeset. This is important for things like incipits without notes or other material that produces output without spending time. In particular, this is interesting for \score in markup which more often than not only contains few notational elements and where attempts to just get basic key/clef/timesignature drawings are sometimes failing in frustrating manners. --- lily/constrained-breaking.cc | 14 +++++++++----- lily/global-context-scheme.cc | 3 +-- lily/optimal-page-breaking.cc | 17 ++++++++++++----- lily/page-spacing.cc | 3 +++ lily/simple-spacer.cc | 9 ++++++--- 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/lily/constrained-breaking.cc b/lily/constrained-breaking.cc index c8b7fc1d74..ee8b28906c 100644 --- a/lily/constrained-breaking.cc +++ b/lily/constrained-breaking.cc @@ -202,8 +202,10 @@ Constrained_breaking::solve (vsize start, vsize end, vsize sys_count) } } /* if we get to here, just put everything on one line */ - warning (_ ("cannot find line breaking that satisfies constraints")); - ret.push_back (space_line (0, end_brk)); + if (sys_count > 0) { + warning (_ ("cannot find line breaking that satisfies constraints")); + ret.push_back (space_line (0, end_brk)); + } return ret; } @@ -291,9 +293,11 @@ Constrained_breaking::line_details (vsize start, vsize end, vsize sys_count) } /* if we get to here, just put everything on one line */ - Line_details details; - fill_line_details (&details, 0, end_brk); - ret.push_back (details); + if (sys_count > 0) { + Line_details details; + fill_line_details (&details, 0, end_brk); + ret.push_back (details); + } return ret; } diff --git a/lily/global-context-scheme.cc b/lily/global-context-scheme.cc index 1267793cf3..86ee2b05b9 100644 --- a/lily/global-context-scheme.cc +++ b/lily/global-context-scheme.cc @@ -90,8 +90,7 @@ LY_DEFINE (ly_interpret_music_expression, "ly:interpret-music-expression", LY_ASSERT_TYPE (unsmob_global_context, ctx, 2); Music *music = unsmob_music (mus); - if (!music - || !music->get_length ().to_bool ()) + if (!music) { warning (_ ("no music found in score")); return SCM_BOOL_F; diff --git a/lily/optimal-page-breaking.cc b/lily/optimal-page-breaking.cc index 2b0910f887..3bddcad4ba 100644 --- a/lily/optimal-page-breaking.cc +++ b/lily/optimal-page-breaking.cc @@ -64,12 +64,19 @@ Optimal_page_breaking::solve () best = space_systems_on_best_pages (0, first_page_num); page_count = best.systems_per_page_.size (); - min_sys_count = ideal_sys_count - best.systems_per_page_.back (); + if (page_count == 0) + { + min_sys_count = 0; + } + else + { + min_sys_count = ideal_sys_count - best.systems_per_page_.back (); - if (page_count > 1 && best.systems_per_page_[page_count - 2] > 1) - min_sys_count -= best.systems_per_page_[page_count - 2]; + if (page_count > 1 && best.systems_per_page_[page_count - 2] > 1) + min_sys_count -= best.systems_per_page_[page_count - 2]; - min_sys_count = max (min_sys_count, (vsize)1); + min_sys_count = max (min_sys_count, (vsize)1); + } } else { @@ -103,7 +110,7 @@ Optimal_page_breaking::solve () if (page_count == 1) message (_ ("Fitting music on 1 page...")); - else if (scm_is_integer (forced_page_count)) + else if (scm_is_integer (forced_page_count) || page_count == 0) message (_f ("Fitting music on %d pages...", (int)page_count)); else message (_f ("Fitting music on %d or %d pages...", (int)page_count - 1, (int)page_count)); diff --git a/lily/page-spacing.cc b/lily/page-spacing.cc index 9434fb910a..c2988d8502 100644 --- a/lily/page-spacing.cc +++ b/lily/page-spacing.cc @@ -155,6 +155,9 @@ Page_spacer::solve () } Page_spacing_result ret; + if (simple_state_.empty ()) + return ret; + ret.penalty_ = simple_state_.back ().penalty_ + lines_.back ().page_penalty_ + lines_.back ().turn_penalty_; ret.system_count_status_ = simple_state_.back ().system_count_status_; diff --git a/lily/simple-spacer.cc b/lily/simple-spacer.cc index 88ebae09d8..61afdb9bcc 100644 --- a/lily/simple-spacer.cc +++ b/lily/simple-spacer.cc @@ -370,9 +370,12 @@ get_column_description (vector const &cols, vsize col_index, bool line_s if (next_col) description.spring_ = Spaceable_grob::get_spring (col, next_col); - Grob *end_col = dynamic_cast (cols[col_index + 1])->find_prebroken_piece (LEFT); - if (end_col) - description.end_spring_ = Spaceable_grob::get_spring (col, end_col); + if (col_index + 1 < cols.size ()) + { + Grob *end_col = dynamic_cast (cols[col_index + 1])->find_prebroken_piece (LEFT); + if (end_col) + description.end_spring_ = Spaceable_grob::get_spring (col, end_col); + } for (SCM s = Spaceable_grob::get_minimum_distances (col); scm_is_pair (s); s = scm_cdr (s)) -- 2.39.5