X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fconstrained-breaking.cc;h=3a56aa47541190b7bd2f6e2669d5292f7e4d1fac;hb=7a6cc2409f4640656fb48c193f0b009be8016ec0;hp=d8235760ac08978fb469e6805d22bc31ea1b91a2;hpb=65988eed499af9a1e1dd0b5d2bde3a5c5f971a96;p=lilypond.git diff --git a/lily/constrained-breaking.cc b/lily/constrained-breaking.cc index d8235760ac..3a56aa4754 100644 --- a/lily/constrained-breaking.cc +++ b/lily/constrained-breaking.cc @@ -4,7 +4,7 @@ source file of the GNU LilyPond music typesetter - (c) 2006--2007 Joe Neeman + (c) 2006--2009 Joe Neeman */ #include "constrained-breaking.hh" @@ -123,6 +123,15 @@ Constrained_breaking::space_line (vsize i, vsize j) bool last = j == breaks_.size () - 1; bool ragged = ragged_right || (last && ragged_last); + /* As a special case, if there is only one line in the score and ragged-right + hasn't been specifically forbidden and the line is stretched, use + ragged spacing. */ + if (last && i == 0 + && lines_.at (i, j).force_ >= 0 + && !scm_is_bool (pscore_->layout ()->c_variable ("ragged-right")) + && !scm_is_bool (pscore_->layout ()->c_variable ("ragged-last"))) + ragged = true; + return get_line_configuration (line, line_dims[RIGHT] - line_dims[LEFT], line_dims[LEFT], ragged); } @@ -189,7 +198,7 @@ Constrained_breaking::solve (vsize start, vsize end, vsize sys_count) vector Constrained_breaking::best_solution (vsize start, vsize end) { - vsize min_systems = min_system_count (start, end); + vsize min_systems = min_system_count (start, end); vsize max_systems = max_system_count (start, end); Real best_demerits = infinity_f; vector best_so_far; @@ -265,7 +274,7 @@ Constrained_breaking::min_system_count (vsize start, vsize end) int Constrained_breaking::max_system_count (vsize start, vsize end) { - vsize brk = (end >= start_.size ()) ? breaks_.size () : starting_breakpoints_[end]; + vsize brk = (end >= start_.size ()) ? breaks_.size () - 1 : starting_breakpoints_[end]; return brk - starting_breakpoints_[start]; } @@ -353,7 +362,7 @@ Constrained_breaking::initialize () line.force_ = forces[i*breaks_.size () + j]; if (ragged && last && !isinf (line.force_)) - line.force_ = (line.force_ < 0) ? infinity_f : 0; + line.force_ = (line.force_ < 0 && j > i + 1) ? infinity_f : 0; if (isinf (line.force_)) break; @@ -372,7 +381,10 @@ Constrained_breaking::initialize () line.turn_permission_ = min_permission (line.page_permission_, line.turn_permission_); - line.extent_ = extent.is_empty () ? Interval (0, 0) : extent; + line.extent_ = (extent.is_empty () + || isnan (extent[LEFT]) + || isnan (extent[RIGHT])) + ? Interval (0, 0) : extent; line.padding_ = padding; line.space_ = space; line.inverse_hooke_ = extent.length () + space;