\header {
texidoc = "The number of pages in a score can be forced by setting
-@code{page-count} in the (book-level) paper block."
+@code{page-count} in the (book-level) paper block. If there are too
+few systems for the number of pages, we append blank pages."
}
#(set-default-paper-size "a6")
--- /dev/null
+\version "2.11.34"
+
+\header {
+ texidoc = "The number of pages in a score can be forced by setting
+@code{page-count} in the (book-level) paper block. Even if there are
+too many systems for that number of pages, we will squeeze them in."
+}
+
+#(set-default-paper-size "a6")
+
+\book {
+ \paper { page-count = 1}
+ \score { { \repeat unfold 10 {c'1 \break} } }
+}
\ No newline at end of file
Page_spacing_result best;
vsize page_count = robust_scm2int (forced_page_count, 1);
- Line_division ideal_line_division;
- Line_division best_division;
+ Line_division ideal_line_division = current_configuration (0);
+ Line_division best_division = ideal_line_division;
vsize min_sys_count = 1;
vsize ideal_sys_count = system_count ();
best = space_systems_on_best_pages (0, first_page_num);
page_count = best.systems_per_page_.size ();
- ideal_line_division = current_configuration (0);
- best_division = ideal_line_division;
ideal_sys_count = best.system_count ();
min_sys_count = ideal_sys_count - best.systems_per_page_.back ();
if (page_count > 1 && best.systems_per_page_[page_count - 2] > 1)
min_sys_count -= best.systems_per_page_[page_count - 2];
}
+ else
+ best = space_systems_on_n_pages (0, page_count, first_page_num);
if (page_count == 1)
message (_ ("Fitting music on 1 page..."));
vsize min_p_count = min_page_count (i, first_page_num);
Page_spacing_result cur;
- if (min_p_count > page_count)
- continue;
- else if (min_p_count == page_count)
+ if (min_p_count == page_count)
cur = space_systems_on_n_pages (i, page_count, first_page_num);
else
cur = space_systems_on_n_or_one_more_pages (i, page_count-1, first_page_num);
Page_breaking::space_systems_on_n_pages (vsize configuration, vsize n, vsize first_page_num)
{
Page_spacing_result ret;
- assert (n >= min_page_count (configuration, first_page_num));
cache_line_details (configuration);
+ bool valid_n = (n >= min_page_count (configuration, first_page_num)
+ && n <= cached_line_details_.size ());
- if (n == 1 && n <= cached_line_details_.size ())
+ if (!valid_n)
+ programming_error ("number of pages is out of bounds");
+
+ if (n == 1 && valid_n)
ret = space_systems_on_1_page (cached_line_details_,
page_height (first_page_num, is_last ()),
ragged () || (is_last () && ragged_last ()));
- else if (n == 2 && n <= cached_line_details_.size ())
+ else if (n == 2 && valid_n)
ret = space_systems_on_2_pages (configuration, first_page_num);
else
{
cache_line_details (configuration);
vsize min_p_count = min_page_count (configuration, first_page_num);
+ bool valid_n = n >= min_p_count || n <= cached_line_details_.size ();
+
+ if (!valid_n)
+ programming_error ("both page counts are out of bounds");
- if (n == 1)
+ if (n == 1 && valid_n)
{
bool rag = ragged () || (is_last () && ragged_last ());
Real height = page_height (first_page_num, is_last ());
{
Page_spacer ps (cached_line_details_, first_page_num, this);
- if (n >= min_p_count)
+ if (n >= min_p_count || !valid_n)
n_res = ps.solve (n);
- if (n < cached_line_details_.size ())
+ if (n < cached_line_details_.size () || !valid_n)
m_res = ps.solve (n+1);
}