summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Neeman <joeneeman@gmail.com>2009-03-13 13:35:28 -0700
committerJoe Neeman <joeneeman@gmail.com>2009-03-13 13:35:28 -0700
commitff82301f08133f2a61893159abfc551e50428b3b (patch)
tree02e551f98d316a912ae55ae362caa7a86072c495
parentde4c92336824fc99f845e3c36646945ed0a7912f (diff)
Add regression tests for max-systems-per-page and systems-per-page.
-rw-r--r--input/regression/page-breaking-max-systems-per-page.ly19
-rw-r--r--input/regression/page-breaking-min-systems-per-page1.ly17
-rw-r--r--input/regression/page-breaking-min-systems-per-page2.ly10
-rw-r--r--input/regression/page-breaking-systems-per-page.ly17
-rw-r--r--lily/optimal-page-breaking.cc6
-rw-r--r--lily/page-breaking.cc13
6 files changed, 62 insertions, 20 deletions
diff --git a/input/regression/page-breaking-max-systems-per-page.ly b/input/regression/page-breaking-max-systems-per-page.ly
new file mode 100644
index 0000000000..18f420a532
--- /dev/null
+++ b/input/regression/page-breaking-max-systems-per-page.ly
@@ -0,0 +1,19 @@
+\version "2.13.1"
+
+\header {
+ texidoc = "The max-systems-per-page variable prevents more
+than a given number of systems from being on a page. Titles
+are not counted as systems. \noPageBreak can override
+max-systems-per-page in unusual situations."
+ title = "Title"
+}
+
+#(set-default-paper-size "a6")
+
+\book {
+ \paper {
+ max-systems-per-page = 1
+ }
+
+ { c'1 \break c'1 \break \noPageBreak c'1 \break c'1 }
+} \ No newline at end of file
diff --git a/input/regression/page-breaking-min-systems-per-page1.ly b/input/regression/page-breaking-min-systems-per-page1.ly
index b8e9ce6a1a..ecaedeed86 100644
--- a/input/regression/page-breaking-min-systems-per-page1.ly
+++ b/input/regression/page-breaking-min-systems-per-page1.ly
@@ -4,15 +4,14 @@
\header {
texidoc = "The min-systems-per-page variable forces each page to have
-a minimum number of systems. Titles do not count as systems here.
-
-This exposes a bug with the current implementation; min-systems-per-page
-is not honored if to do so we would need uneven line breaking."
- title = "Example"
+a minimum number of systems. Titles do not count as systems here."
+ title = "Title"
}
-\paper {
- min-systems-per-page = 5
-}
+\book {
+ \paper {
+ min-systems-per-page = 5
+ }
-{ \repeat unfold 11 { c'1 } \pageBreak \repeat unfold 6 { c'1 } } \ No newline at end of file
+ { \repeat unfold 11 { c'1 } \pageBreak \repeat unfold 6 { c'1 } }
+} \ No newline at end of file
diff --git a/input/regression/page-breaking-min-systems-per-page2.ly b/input/regression/page-breaking-min-systems-per-page2.ly
index 56fb1a61fb..6d5550912f 100644
--- a/input/regression/page-breaking-min-systems-per-page2.ly
+++ b/input/regression/page-breaking-min-systems-per-page2.ly
@@ -7,8 +7,10 @@
the desire not to overfill a page."
}
-\paper {
- min-systems-per-page = 20
-}
+\book {
+ \paper {
+ min-systems-per-page = 20
+ }
-\repeat unfold 21 { c'1 } \ No newline at end of file
+ \repeat unfold 21 { c'1 }
+} \ No newline at end of file
diff --git a/input/regression/page-breaking-systems-per-page.ly b/input/regression/page-breaking-systems-per-page.ly
new file mode 100644
index 0000000000..ce275378e7
--- /dev/null
+++ b/input/regression/page-breaking-systems-per-page.ly
@@ -0,0 +1,17 @@
+\version "2.13.1"
+
+\header {
+ texidoc = "The systems-per-page variable forces a certain number of systems
+per page. Titles are not counted as systems."
+ title = "Title"
+}
+
+#(set-default-paper-size "a6")
+
+\book {
+ \paper {
+ systems-per-page = 3
+ }
+
+ { \repeat unfold 3 { c'1 } \pageBreak \repeat unfold 3 { c'1 } }
+} \ No newline at end of file
diff --git a/lily/optimal-page-breaking.cc b/lily/optimal-page-breaking.cc
index e23bad2351..6e5d20dfd6 100644
--- a/lily/optimal-page-breaking.cc
+++ b/lily/optimal-page-breaking.cc
@@ -78,9 +78,9 @@ Optimal_page_breaking::solve_chunk (vsize end)
}
if (page_count == 1 || scm_is_integer (forced_page_count))
- progress_indication (_f ("[%d, %d pages]", (int) end, (int) page_count));
+ progress_indication (_f ("[%d: %d pages]", (int) end, (int) page_count));
else
- progress_indication (_f ("[%d, %d or %d pages]", (int) end, (int) page_count-1, (int)page_count));
+ progress_indication (_f ("[%d: %d or %d pages]", (int) end, (int) page_count-1, (int)page_count));
/* try a smaller number of systems than the ideal number for line breaking */
Line_division bound = ideal_line_division;
@@ -174,7 +174,7 @@ Optimal_page_breaking::solve ()
{
vector<vsize> systems_per_page;
- message (_f ("Solving %d page-breaking chunks...", last_break_position ()-1));
+ message (_f ("Solving %d page-breaking chunks...", last_break_position ()));
for (vsize end = 1; end <= last_break_position (); ++end)
{
vector<vsize> chunk_systems = solve_chunk (end);
diff --git a/lily/page-breaking.cc b/lily/page-breaking.cc
index 1c0d21cdc7..f19079ce35 100644
--- a/lily/page-breaking.cc
+++ b/lily/page-breaking.cc
@@ -924,17 +924,22 @@ Page_breaking::space_systems_with_fixed_number_per_page (vsize configuration,
res.systems_per_page_.push_back (line - page_first_line);
- // Don't say that the force is infinite even if it is: if we were told to
- // put a certain number of systems on a page then we will, even if it's bad.
- res.force_.push_back (min (space.force_, BAD_SPACING_PENALTY));
+ res.force_.push_back (space.force_);
res.penalty_ += cached_line_details_[line-1].page_penalty_;
+ if (system_count_on_this_page != systems_per_page_)
+ {
+ res.penalty_ += TERRIBLE_SPACING_PENALTY;
+ res.system_count_status_ |= ((system_count_on_this_page < systems_per_page_))
+ ? SYSTEM_COUNT_TOO_FEW : SYSTEM_COUNT_TOO_MANY;
+ }
+
page_first_line = line;
}
/* Recalculate forces for the last page because we know now that is
really the last page. */
space.resize (page_height (first_page_num + page, true));
- res.force_.back () = min(space.force_, BAD_SPACING_PENALTY);
+ res.force_.back () = space.force_;
return finalize_spacing_result (configuration, res);
}