X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fconstrained-breaking.cc;h=1e172fd492639c8565f81aebf1acf0b00bf0712c;hb=24cd9ffc8b5a4ea03a29414eb7ae038a2d568d45;hp=4604f5439d0173ae9c048f448ee341a77644190f;hpb=6fa65d64fec139c40804814122e775edb25dc3db;p=lilypond.git diff --git a/lily/constrained-breaking.cc b/lily/constrained-breaking.cc index 4604f5439d..1e172fd492 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--2008 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]; } @@ -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;