From: Keith OHara Date: Sat, 23 Nov 2013 04:46:49 +0000 (-0800) Subject: page-breaking: allow ragged pages to be compressed X-Git-Tag: release/2.18.1-1~34 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=55aa882b7ef5afc63ce456450d1f910063655506;p=lilypond.git page-breaking: allow ragged pages to be compressed --- diff --git a/Documentation/notation/spacing.itely b/Documentation/notation/spacing.itely index 73b431dd79..7f3a50f1f3 100644 --- a/Documentation/notation/spacing.itely +++ b/Documentation/notation/spacing.itely @@ -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 diff --git a/lily/page-breaking.cc b/lily/page-breaking.cc index a5b03f51e8..7220857d91 100644 --- a/lily/page-breaking.cc +++ b/lily/page-breaking.cc @@ -631,7 +631,11 @@ Page_breaking::make_pages (vector 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); diff --git a/lily/page-layout-problem.cc b/lily/page-layout-problem.cc index 5885a66135..8b0be3a5f7 100644 --- a/lily/page-layout-problem.cc +++ b/lily/page-layout-problem.cc @@ -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++) diff --git a/lily/page-spacing.cc b/lily/page-spacing.cc index a705827d22..a2915febb2 100644 --- a/lily/page-spacing.cc +++ b/lily/page-spacing.cc @@ -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