]> git.donarmstrong.com Git - lilypond.git/commitdiff
page-breaking: allow ragged pages to be compressed
authorKeith OHara <k-ohara5a5a@oco.net>
Sat, 23 Nov 2013 04:46:49 +0000 (20:46 -0800)
committerKeith OHara <k-ohara5a5a@oco.net>
Fri, 29 Nov 2013 02:58:03 +0000 (18:58 -0800)
Documentation/notation/spacing.itely
lily/page-breaking.cc
lily/page-layout-problem.cc
lily/page-spacing.cc

index 762befe6fce79114c1bb81a5a1dfdbb9537d923a..834f23470008bd78eca1a5c243c4af15157e0b8c 100644 (file)
@@ -394,18 +394,16 @@ default value is scaled accordingly.
 @item ragged-bottom
 @funindex ragged-bottom
 
-If set to true, systems will not spread vertically down the page.
-This does not affect the last page.  This should be set to true
-for pieces that have only two or three systems per page, for
-example orchestral scores.
+If this is set to true,
+systems will be set at their natural spacing, neither compressed
+nor stretched vertically to fit the page.
 
 @item ragged-last-bottom
 @funindex ragged-last-bottom
 
-If set to false, systems will spread vertically down the last
-page.  Pieces that amply fill two pages or more should have this
-set to false.  It also affects the last page of book parts, i.e.
-parts of a book created with @code{\bookpart} blocks.
+If this is set to false, then the last page,
+and the last page in each section created with a @code{\bookpart} block,
+will be vertically justified in the same way as the earlier pages.
 
 @end table
 
@@ -1521,10 +1519,12 @@ The @code{\pageBreak} and @code{\noPageBreak} commands may also be
 inserted at top-level, between scores and top-level markups.
 
 There are also analogous settings to @code{ragged-right} and
-@code{ragged-last} which have the same effect on vertical spacing:
-@code{ragged-bottom} and @code{ragged-last-bottom}.  If set to
-@code{#t} the systems on all pages or just the last page
-respectively will not be justified vertically.  See
+@code{ragged-last} which have the same effect on vertical spacing.
+If @code{ragged-bottom} is set to @code{#t} the systems will not
+be justified vertically.  When @code{ragged-last-bottom} is set
+to @code{#t}, as it is by default, empty space is allowed at the
+bottom of the final page (or the final page in each
+@code{\bookpart}).  See
 @ref{Fixed vertical spacing paper variables,,Fixed vertical spacing @code{@bs{}paper} variables}.
 
 Page breaks are computed by the @code{page-breaking} function.  LilyPond
index a5b03f51e8567952e3f00accec6976432a62c82b..7220857d9194e1c7ff4ff5c0c89b91b78b484645 100644 (file)
@@ -631,7 +631,11 @@ Page_breaking::make_pages (vector<vsize> lines_per_page, SCM systems)
       else
         config = layout.solution (rag);
 
-      last_page_force = layout.force ();
+      if ((ragged () && layout.force () < 0.0)
+          || isinf (layout.force ()))
+        warning (_f ("page %d has been compressed", page_num));
+      else
+        last_page_force = layout.force ();
 
       systems_configs_fncounts = scm_cons (scm_cons (lines, config), systems_configs_fncounts);
       footnote_count += fn_lines;
@@ -1168,9 +1172,8 @@ Page_breaking::min_page_count (vsize configuration, vsize first_page_num)
       cur_page_height -= min_whitespace_at_top_of_page (cached_line_details_[page_starter]);
       cur_page_height -= min_whitespace_at_bottom_of_page (cached_line_details_.back ());
 
-      Real cur_height = cur_rod_height + ((ragged_last () || ragged ()) ? cur_spring_height : 0);
       if (!too_few_lines (line_count - cached_line_details_.back ().compressed_nontitle_lines_count_)
-          && cur_height > cur_page_height
+          && cur_rod_height > cur_page_height
           /* don't increase the page count if the last page had only one system */
           && cur_rod_height > cached_line_details_.back ().full_height ())
         ret++;
@@ -1546,9 +1549,11 @@ Page_breaking::space_systems_on_2_pages (vsize configuration, vsize first_page_n
       page1_penalty[i] = line_count_penalty (page1_line_count);
       page1_status[i] = line_count_status (page1_line_count);
 
-      if (ragged2)
+      if (ragged1)
         page2_force[page2_force.size () - 1 - i]
           = (page2.force_ < 0 && i + 1 < page1_force.size ()) ? infinity_f : 0;
+      else if (ragged2 && page2.force_ > 0)
+        page2_force[page2_force.size () - 1 - i] = 0.0;
       else
         page2_force[page2_force.size () - 1 - i] = page2.force_;
       page2_penalty[page2_penalty.size () - 1 - i] = line_count_penalty (page2_line_count);
index 5885a661359b6accd9055228bd11b10cf8f19f88..8b0be3a5f704205e3e1001832be1f09118624596 100644 (file)
@@ -728,12 +728,12 @@ Page_layout_problem::solve_rod_spring_problem (bool ragged, Real fixed_force)
       Real overflow = spacer.configuration_length (spacer.force ())
                       - page_height_;
       if (ragged && overflow < 1e-6)
-        warning (_ ("cannot fit music on page: ragged-spacing was requested, but page was compressed"));
+        warning (_ ("ragged-bottom was specified, but page must be compressed"));
       else
         {
-          warning (_f ("cannot fit music on page: overflow is %f",
+          warning (_f ("compressing over-full page by %.1f staff-spaces",
                        overflow));
-          warning (_ ("compressing music to fit"));
+          force_ = -infinity_f;
           vsize space_count = solution_.size ();
           Real spacing_increment = overflow / (space_count - 2);
           for (vsize i = 2; i < space_count; i++)
index a705827d2274df700b56503bc8b60bb06d58dcb8..a2915febb20197470a4e316436881f103a94e435 100644 (file)
@@ -329,7 +329,7 @@ Page_spacer::calc_subproblem (vsize page, vsize line)
       space.prepend_system (lines_[page_start]);
 
       bool overfull = (space.rod_height_ > paper_height
-                       || (ragged
+                       || (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