source file of the GNU LilyPond music typesetter
- (c) 2006 Joe Neeman <joeneeman@gmail.com>
+ (c) 2006--2007 Joe Neeman <joeneeman@gmail.com>
*/
#include "page-turn-page-breaking.hh"
/* If [START, END] does not contain an intermediate
breakpoint, we may need to consider solutions that result in a bad turn.
In this case, we won't abort if the min_page_count is too big */
- if (start < end - 1 && min_p_count > 2)
+ if (start < end - 1 && min_p_count + (page_number % 2) > 2)
return Break_node ();
/* if PAGE-NUMBER is odd, we are starting on a right hand page. That is, we
Page_turn_page_breaking::final_page_num (Break_node const &b)
{
vsize end = b.first_page_number_ + b.page_count_;
- return end + 1 - (end % 2);
+ return end - 1 + (end % 2);
}
void
cur = put_systems_on_pages (start, end, line, div[d], p_num);
if (isinf (cur.demerits_)
- || (cur.page_count_ > 2
+ || (cur.page_count_ + (p_num % 2) > 2
&& (!isinf (this_start_best.demerits_))
&& final_page_num (cur) > final_page_num (this_start_best)))
{
state_.clear ();
message (_f ("Calculating page and line breaks (%d possible page breaks)...",
(int)breaks_.size () - 1) + " ");
- for (vsize i = 0; i < breaks_.size () - 1; i++)
+ for (vsize i = 0; i + 1 < breaks_.size (); i++)
{
calc_subproblem (i);
progress_indication (string ("[") + to_string (i + 1) + "]");
for (vsize j = 0; j < soln[i].page_count_; j++)
lines_per_page.push_back (soln[i].system_count_[j]);
- if (i < soln.size () - 1 && (soln[i].first_page_number_ + soln[i].page_count_) % 2)
+ if (i + 1 < soln.size () && (soln[i].first_page_number_ + soln[i].page_count_) % 2)
/* add a blank page */
lines_per_page.push_back (0);
}