]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix regression with page-spacing-tall-headfoot.ly.
authorJoe Neeman <joeneeman@gmail.com>
Wed, 25 Aug 2010 22:30:52 +0000 (15:30 -0700)
committerJoe Neeman <joeneeman@gmail.com>
Sat, 28 Aug 2010 00:11:06 +0000 (17:11 -0700)
lily/include/page-breaking.hh
lily/page-breaking.cc
lily/page-spacing.cc

index d34534c1ca4eb462b6c1fb9ff4f1bd8ce270d10e..45ec467dc23f6daed3aca01416012f1137217708 100644 (file)
@@ -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<Line_details> cached_line_details_;
   vector<Line_details> uncompressed_line_details_;
 
+  Real paper_height_;
   mutable vector<Real> page_height_cache_;
   mutable vector<Real> last_page_height_cache_;
 
index 4ac005461c68d66a5e187b8f58138c7a371423f0..88f55b896c79b4868fd6b4e8ba8f8a59e7973457 100644 (file)
@@ -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
 {
index 1a3c39cfbf709d88de4725c6238fe8636141eb15..e4b4eec9ef748d039ae49c6b521553fd25c97591 100644 (file)
@@ -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_;