]> git.donarmstrong.com Git - lilypond.git/commitdiff
Page spacing: compute more accurately page space when a line next-space is equal...
authorNicolas Sceaux <nicolas.sceaux@free.fr>
Wed, 11 Jul 2007 20:48:38 +0000 (22:48 +0200)
committerNicolas Sceaux <nicolas.sceaux@free.fr>
Wed, 11 Jul 2007 20:48:38 +0000 (22:48 +0200)
lily/include/page-spacing.hh
lily/page-breaking.cc
lily/page-spacing.cc

index fc4c15f55e0662862d2d3558dde17e17f5c96a88..ba05a4de9d740a14c2c0a92ce0969131cf3b898b 100644 (file)
@@ -77,5 +77,4 @@ struct Page_spacing
   void clear ();
 };
 
-Real line_space (Line_details const &line);
 #endif /* PAGE_SPACING_HH */
index 270337da7d306255e932dcfd90597461971c6300..9ad833610aeebce6acf8e1138a337d1b39b4046a 100644 (file)
@@ -619,7 +619,7 @@ Page_breaking::min_page_count (vsize configuration, vsize first_page_num)
       Real ext_len = cached_line_details_[i].extent_.length ();
       Real next_rod_height = cur_rod_height + ext_len
        + ((cur_rod_height > 0) ? cached_line_details_[i].padding_: 0);
-      Real next_spring_height = cur_spring_height + line_space (cached_line_details_[i]);
+      Real next_spring_height = cur_spring_height + cached_line_details_[i].space_;
       Real next_height = next_rod_height + (ragged () ? next_spring_height : 0);
 
 
@@ -628,7 +628,7 @@ Page_breaking::min_page_count (vsize configuration, vsize first_page_num)
              && cached_line_details_[i-1].page_permission_ == ly_symbol2scm ("force")))
        {
          cur_rod_height = ext_len;
-         cur_spring_height = line_space (cached_line_details_[i]);
+         cur_spring_height = cached_line_details_[i].space_;
          cur_page_height = page_height (first_page_num + ret, false);
          ret++;
        }
index 536e4ff7a002beac3746b573bb8f1f0182979c4e..fa1c273f370658b725e9a396a9fe06eb08627665 100644 (file)
 #include "page-breaking.hh"
 #include "warn.hh"
 
-/* In order to prevent possible division by zero, we require every line
-   to have a spring of non-zero length. */
-Real
-line_space (const Line_details &line)
-{
-  return max (0.1, line.space_);
-}
-
 void
 Page_spacing::calc_force ()
 {
-  if (rod_height_ + last_line_.bottom_padding_ >= page_height_ || !inverse_spring_k_)
+  if (rod_height_ + last_line_.bottom_padding_ >= page_height_)
     force_ = infinity_f;
   else
-    force_ = (page_height_ - rod_height_ - last_line_.bottom_padding_ - spring_len_) / inverse_spring_k_;
+    force_ = (page_height_ - rod_height_ - last_line_.bottom_padding_ - spring_len_)
+      / max (0.1, inverse_spring_k_);
 }
 
 void
@@ -36,8 +29,8 @@ Page_spacing::append_system (const Line_details &line)
   rod_height_ += last_line_.padding_;
 
   rod_height_ += line.extent_.length ();
-  spring_len_ += line_space (line);
-  inverse_spring_k_ += max (0.1, line.inverse_hooke_);
+  spring_len_ += line.space_;
+  inverse_spring_k_ += line.inverse_hooke_;
 
   last_line_ = line;
 
@@ -53,8 +46,8 @@ Page_spacing::prepend_system (const Line_details &line)
     last_line_ = line;
 
   rod_height_ += line.extent_.length ();
-  spring_len_ += line_space (line);
-  inverse_spring_k_ += max (0.1, line.inverse_hooke_);
+  spring_len_ += line.space_;
+  inverse_spring_k_ += line.inverse_hooke_;
 
   calc_force ();
 }