On Thu, 2006-10-12 at 02:37 -0400, Marcus Macauley wrote: > Joe Neeman <[EMAIL PROTECTED]> wrote (earlier): > > You can enable the old page breaker by > > putting #(define page-breaking optimal-page-breaks) in the \paper block. > > I tried this command, and it seemed to work for vertical spacing > (restoring mine to the way it was with 2.9.17), but I notice that the > horizontal spacing has also changed (spread out slightly) in 2.9.22, from > 2.9.17. > > I prefer it the way it was, unless there's a good reason for the change > (which, then, I think should be described somewhere).
There was a good reason (which can be found by searching the lilypond-devel archives for "compression penalty"). But I think there is a better solution for the problem: I make the compression penalty configurable and assign different defaults depending on which page breaker we use. The page-turn-page-breaker gets a big penalty and the others get a small (or even no) penalty. I was a little reluctant to make the penalty configurable because it is something internal to the line breaker and I think it shouldn't need to be modified by the user. But this way it should give good results in most cases without modification. Here's a suggested patch (untested) 2006-10-17 Joe Neeman <[EMAIL PROTECTED]> * 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.
Tue Oct 17 08:45:26 IST 2006 Joe Neeman <[EMAIL PROTECTED]> * 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 <[EMAIL PROTECTED]> + + * 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 <[EMAIL PROTECTED]> * 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<Grob*> 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<Real> 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<Real> get_line_forces (vector<Grob*> const &columns, Real line_len, Real indent, + Real compression_penalty, bool ragged); Column_x_positions get_line_configuration (vector<Grob*> 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<Real> get_line_forces (vector<Grob*> const &columns, - Real line_len, Real indent, bool ragged) + Real line_len, + Real indent, + Real compression_penalty, + bool ragged) { vector<vsize> breaks; vector<Real> 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<Grob*> const &columns, Real line_len, Real indent, + Real compression_penalty, bool ragged) { vector<Column_description> 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
_______________________________________________ bug-lilypond mailing list bug-lilypond@gnu.org http://lists.gnu.org/mailman/listinfo/bug-lilypond