Tue Oct 17 08:45:26 IST 2006 Joe Neeman * Suggested patch for configurable compression-penalty diff -rN -u old-lilypond/ChangeLog new-lilypond/ChangeLog --- old-lilypond/ChangeLog 2006-10-17 08:48:36.000000000 +0200 +++ new-lilypond/ChangeLog 2006-10-17 08:48:37.000000000 +0200 @@ -1,3 +1,13 @@ +2006-10-17 Joe Neeman + + * lily/page-turn-page-breaking.cc (Page_turn_page_breaking): set + a higher default for compression-penalty + + * lily/simple-spacer.cc: + * lily/constrained-breaking.cc: + make get_line_forces and get_line_configuration take a + compression_penalty parameter. + 2006-10-17 Han-Wen Nienhuys * lily/script-column.cc (row_before_line_breaking): also handle diff -rN -u old-lilypond/lily/constrained-breaking.cc new-lilypond/lily/constrained-breaking.cc --- old-lilypond/lily/constrained-breaking.cc 2006-10-17 08:48:36.000000000 +0200 +++ new-lilypond/lily/constrained-breaking.cc 2006-10-17 08:48:36.000000000 +0200 @@ -122,8 +122,10 @@ Column_x_positions Constrained_breaking::space_line (vsize i, vsize j) { - bool ragged_right = to_boolean (pscore_->layout ()->c_variable ("ragged-right")); - bool ragged_last = to_boolean (pscore_->layout ()->c_variable ("ragged-last")); + Output_def *l = pscore_->layout (); + bool ragged_right = to_boolean (l->c_variable ("ragged-right")); + bool ragged_last = to_boolean (l->c_variable ("ragged-last")); + Real compression_penalty = robust_scm2double (l->c_variable ("compression-penalty"), 0.5); Column_x_positions col; vector line (all_.begin () + breaks_[i], @@ -132,7 +134,11 @@ bool last = j == breaks_.size () - 1; bool ragged = ragged_right || (last && ragged_last); - return get_line_configuration (line, line_dims[RIGHT] - line_dims[LEFT], line_dims[LEFT], ragged); + return get_line_configuration (line, + line_dims[RIGHT] - line_dims[LEFT], + line_dims[LEFT], + compression_penalty, + ragged); } void @@ -324,6 +330,7 @@ System *sys = pscore_->root_system (); Real padding = robust_scm2double (l->c_variable ("between-system-padding"), 0); Real space = robust_scm2double (l->c_variable ("ideal-system-space"), 0); + Real compression_penalty = robust_scm2double (l->c_variable ("compression-penalty"), 0.5); Interval first_line = line_dimensions_int (pscore_->layout (), 0); Interval other_lines = line_dimensions_int (pscore_->layout (), 1); @@ -334,6 +341,7 @@ vector forces = get_line_forces (all_, other_lines.length (), other_lines.length () - first_line.length (), + compression_penalty, ragged_right_); for (vsize i = 0; i < breaks_.size () - 1; i++) { diff -rN -u old-lilypond/lily/include/simple-spacer.hh new-lilypond/lily/include/simple-spacer.hh --- old-lilypond/lily/include/simple-spacer.hh 2006-10-17 08:48:36.000000000 +0200 +++ new-lilypond/lily/include/simple-spacer.hh 2006-10-17 08:48:36.000000000 +0200 @@ -69,11 +69,13 @@ vector get_line_forces (vector const &columns, Real line_len, Real indent, + Real compression_penalty, bool ragged); Column_x_positions get_line_configuration (vector const &columns, Real line_len, Real indent, + Real compression_penalty, bool ragged); #endif /* SIMPLE_SPACER_HH */ diff -rN -u old-lilypond/lily/page-turn-page-breaking.cc new-lilypond/lily/page-turn-page-breaking.cc --- old-lilypond/lily/page-turn-page-breaking.cc 2006-10-17 08:48:36.000000000 +0200 +++ new-lilypond/lily/page-turn-page-breaking.cc 2006-10-17 08:48:36.000000000 +0200 @@ -27,6 +27,12 @@ Page_turn_page_breaking::Page_turn_page_breaking (Paper_book *pb) : Page_breaking (pb, is_break) { + /* because the page-turn-page-breaker has to deal with more constraints, + we are likely to find worse line-breaking configurations and we set + the compression-penalty higher so that those line-breaking configurations + will be stretched rather than compressed. */ + if (!scm_is_number (pb->paper_->c_variable ("compression-penalty"))) + pb->paper_->set_variable (ly_symbol2scm ("compression-penalty"), scm_from_int (4)); } Page_turn_page_breaking::~Page_turn_page_breaking () diff -rN -u old-lilypond/lily/simple-spacer.cc new-lilypond/lily/simple-spacer.cc --- old-lilypond/lily/simple-spacer.cc 2006-10-17 08:48:36.000000000 +0200 +++ new-lilypond/lily/simple-spacer.cc 2006-10-17 08:48:36.000000000 +0200 @@ -415,7 +415,10 @@ vector get_line_forces (vector const &columns, - Real line_len, Real indent, bool ragged) + Real line_len, + Real indent, + Real compression_penalty, + bool ragged) { vector breaks; vector force; @@ -471,13 +474,9 @@ } spacer.solve ((b == 0) ? line_len - indent : line_len, ragged); - /* add a (convex) penalty for compression. We do this _only_ in get_line_forces, - not get_line_configuration. This is temporary, for backwards compatibility; - the old line/page-breaking stuff ignores page breaks when it calculates line - breaks, so compression penalties can result in scores (eg. wtk-fugue) blowing - up to too many pages. */ + /* add a (convex) penalty for compression */ Real f = spacer.force (); - force[b * breaks.size () + c] = f - (f < 0 ? f*f*f*f*4 : 0); + force[b * breaks.size () + c] = f - (f < 0 ? f*f*f*f*compression_penalty : 0); if (end < cols.size () && cols[end].break_permission_ == force_break) break; @@ -498,6 +497,7 @@ get_line_configuration (vector const &columns, Real line_len, Real indent, + Real compression_penalty, bool ragged) { vector cols; @@ -534,7 +534,8 @@ } spacer.solve (line_len, ragged); - ret.force_ = spacer.force (); + Real f = spacer.force (); + ret.force_ = f - (f < 0 ? f*f*f*f*compression_penalty : 0); /* We used to have a penalty for compression, no matter what, but that