From: Joe Neeman Date: Wed, 25 Aug 2010 22:30:52 +0000 (-0700) Subject: Fix regression with page-spacing-tall-headfoot.ly. X-Git-Tag: release/2.13.32-1~24 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=02ecfc59e4e77633139ba19d9cf45701d17fac40;p=lilypond.git Fix regression with page-spacing-tall-headfoot.ly. --- diff --git a/lily/include/page-breaking.hh b/lily/include/page-breaking.hh index d34534c1ca..45ec467dc2 100644 --- a/lily/include/page-breaking.hh +++ b/lily/include/page-breaking.hh @@ -121,6 +121,7 @@ public: int max_systems_per_page () const; int min_systems_per_page () const; Real page_height (int page_number, bool last) const; + Real paper_height () const; vsize system_count () const; Real line_count_penalty (int line_count) const; int line_count_status (int line_count) const; @@ -196,6 +197,7 @@ private: vector cached_line_details_; vector uncompressed_line_details_; + Real paper_height_; mutable vector page_height_cache_; mutable vector last_page_height_cache_; diff --git a/lily/page-breaking.cc b/lily/page-breaking.cc index 4ac005461c..88f55b896c 100644 --- a/lily/page-breaking.cc +++ b/lily/page-breaking.cc @@ -177,6 +177,7 @@ Page_breaking::Page_breaking (Paper_book *pb, Break_predicate is_break, Prob_bre { book_ = pb; system_count_ = 0; + paper_height_ = robust_scm2double (pb->paper_->c_variable ("paper-height"), 1.0); ragged_ = to_boolean (pb->paper_->c_variable ("ragged-bottom")); ragged_last_ = to_boolean (pb->paper_->c_variable ("ragged-last-bottom")); systems_per_page_ = max (0, robust_scm2int (pb->paper_->c_variable ("systems-per-page"), 0)); @@ -365,6 +366,15 @@ Page_breaking::make_page (int page_num, bool last) const SCM_UNDEFINED)); } +// Returns the total height of the paper, including margins and +// space for the header/footer. This is an upper bound on +// page_height, and it doesn't depend on the current page. +Real +Page_breaking::paper_height () const +{ + return paper_height_; +} + Real Page_breaking::page_height (int page_num, bool last) const { diff --git a/lily/page-spacing.cc b/lily/page-spacing.cc index 1a3c39cfbf..e4b4eec9ef 100644 --- a/lily/page-spacing.cc +++ b/lily/page-spacing.cc @@ -247,6 +247,7 @@ Page_spacer::calc_subproblem (vsize page, vsize line) // we need to look ahead a few systems in order to find the best solution. But // we won't, because we stop once we overfill the page with the large header. vsize page_num = page == VPOS ? 0 : page; + Real paper_height = breaker_->paper_height (); Page_spacing space (breaker_->page_height (page_num + first_page_num_, last), breaker_); Page_spacing_node &cur = page == VPOS ? simple_state_[line] : state_.at (line, page); @@ -272,13 +273,16 @@ Page_spacer::calc_subproblem (vsize page, vsize line) space.prepend_system (lines_[page_start]); + bool overfull = (space.rod_height_ > paper_height + || (ragged + && (space.rod_height_ + space.spring_len_ > paper_height))); // This 'if' statement is a little hard to parse. It won't consider this configuration // if it is overfull unless the current configuration is the first one with this start // point. We also make an exception (and consider this configuration) if the previous // configuration we tried had fewer lines than min-systems-per-page. if (!breaker_->too_few_lines (line_count) && page_start < line - && (isinf (space.force_) || (space.force_ < 0 && ragged))) + && overfull) break; line_count += lines_[page_start].compressed_nontitle_lines_count_;