From: Keith OHara Date: Sun, 16 Sep 2012 23:26:01 +0000 (-0700) Subject: stem.cc: be robust in case of missing note-head stencils X-Git-Tag: release/2.17.3-1~10 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=9a5963d27b58b7d1528dab2d15b9c52575417267;p=lilypond.git stem.cc: be robust in case of missing note-head stencils --- diff --git a/lily/flag.cc b/lily/flag.cc index 77491befd6..31ddf349c9 100644 --- a/lily/flag.cc +++ b/lily/flag.cc @@ -186,11 +186,13 @@ Flag::internal_calc_y_offset (SCM smob, bool pure) Real blot = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter")); - Real y2 = pure - ? stem->pure_height (stem, 0, INT_MAX)[d] - : stem->extent (stem, Y_AXIS)[d]; + Interval stem_extent = pure + ? stem->pure_height (stem, 0, INT_MAX) + : stem->extent (stem, Y_AXIS); - return scm_from_double (y2 - d * blot / 2); + return scm_from_double (stem_extent.is_empty () + ? 0.0 + : stem_extent[d] - d * blot / 2); } MAKE_SCHEME_CALLBACK (Flag, calc_x_offset, 1); diff --git a/lily/grob.cc b/lily/grob.cc index c515c18616..031af32636 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -472,9 +472,11 @@ Grob::extent (Grob *refp, Axis a) const } // We never want nan, so we avoid shifting infinite values. - for (LEFT_and_RIGHT (d)) - if (!isinf (real_ext[d])) - real_ext[d] += offset; + if(!isinf (offset)) + real_ext.translate(offset); + else + this->warning(_f ("ignored infinite %s-offset", + a == X_AXIS ? "X" : "Y")); return real_ext; } diff --git a/lily/stem-tremolo.cc b/lily/stem-tremolo.cc index 5c5ee051d4..1f9d2d8a7a 100644 --- a/lily/stem-tremolo.cc +++ b/lily/stem-tremolo.cc @@ -314,7 +314,7 @@ Stem_tremolo::y_offset (Grob *me, bool pure) } bool whole_note = Stem::duration_log (stem) <= 0; - if (whole_note) + if (whole_note || isinf(end_y)) { /* we shouldn't position relative to the end of the stem since the stem is invisible */ diff --git a/lily/stem.cc b/lily/stem.cc index 8069a456c8..7037b8869c 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -545,7 +545,8 @@ Stem::calc_positioning_done (SCM smob) = hed->extent (hed, X_AXIS).linear_combination (CENTER) - heads[i]->extent (heads[i], X_AXIS).linear_combination (CENTER); - heads[i]->translate_axis (amount, X_AXIS); + if (!isnan (amount)) // empty heads can produce NaN + heads[i]->translate_axis (amount, X_AXIS); } bool parity = true; Real lastpos = Real (Staff_symbol_referencer::get_position (heads[0])); @@ -794,7 +795,8 @@ Stem::internal_calc_stem_begin_position (Grob *me, bool calc_beam) Real y_attach = Note_head::stem_attachment_coordinate (head, Y_AXIS); y_attach = head_height.linear_combination (y_attach); - pos += d * y_attach * 2 / ss; + if (!isinf (y_attach) && !isnan (y_attach)) // empty heads + pos += d * y_attach * 2 / ss; } return pos; @@ -882,7 +884,7 @@ Stem::offset_callback (SCM smob) Direction d = get_grob_direction (me); Real real_attach = head_wid.linear_combination (d * attach); - Real r = real_attach; + Real r = isnan(real_attach)? 0.0: real_attach; /* If not centered: correct for stem thickness. */ string style = robust_symbol2string (f->get_property ("style"), "default");