]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix thinkos in page-spacing.
authorJoe Neeman <joeneeman@gmail.com>
Tue, 28 Sep 2010 23:01:17 +0000 (16:01 -0700)
committerJoe Neeman <joeneeman@gmail.com>
Tue, 28 Sep 2010 23:22:55 +0000 (16:22 -0700)
Force is negative if page is overfull, and we can't allow overfull
pages to have infinite badness.

lily/page-spacing.cc

index 00ffcc44585ddd78bb722a319498f0f6da782664..b556c1c3053273ac565396087b87a80843f787fd 100644 (file)
@@ -31,7 +31,7 @@ Page_spacing::calc_force ()
     - breaker_->min_whitespace_at_bottom_of_page (last_line_);
 
   if (rod_height_ + last_line_.bottom_padding_ >= height)
-    force_ = infinity_f;
+    force_ = -infinity_f;
   else
     force_ = (height - rod_height_ - last_line_.bottom_padding_ - spring_len_)
       / max (0.1, inverse_spring_k_);
@@ -300,10 +300,11 @@ Page_spacer::calc_subproblem (vsize page, vsize line)
            space.force_ = 0;
 
          Real demerits = space.force_ * space.force_;
-         /* If a single line is taller than a page, we need to consider it as
-            a possible solution (but we give it a very bad score). */
-         if (isinf (space.force_) && page_start == line)
-           demerits = BAD_SPACING_PENALTY;
+
+         // Clamp the demerits at BAD_SPACING_PENALTY, even if the page
+         // is overfull.  This ensures that TERRIBLE_SPACING_PENALTY takes
+         // precedence over overfull pages.
+         demerits = min (demerits, BAD_SPACING_PENALTY);
          demerits += (prev ? prev->demerits_ : 0);
 
          Real penalty = breaker_->line_count_penalty (line_count);