+ set_grob_direction (me, dir);
+ }
+
+ /* Stems in unnatural (forced) direction should be shortened,
+ according to [Roush & Gourlay] */
+ Interval hp = head_positions (me);
+ if (dir && dir * hp[dir] >= 0)
+ {
+ SCM sshorten = me->get_property ("stem-shorten");
+ SCM scm_shorten = ly_c_pair_p (sshorten) ?
+ robust_list_ref ((duration_log (me) - 2) >? 0, sshorten): SCM_EOL;
+ Real shorten = 2* robust_scm2double (scm_shorten,0);
+
+ /* On boundary: shorten only half */
+ if (abs (head_positions (me)[dir]) <= 1)
+ shorten *= 0.5;
+
+ length -= shorten;
+ }
+
+ /* Tremolo stuff. */
+ Grob *t_flag = unsmob_grob (me->get_property ("tremolo-flag"));
+ if (t_flag && !unsmob_grob (me->get_property ("beam")))
+ {
+ /* Crude hack: add extra space if tremolo flag is there.
+
+ We can't do this for the beam, since we get into a loop
+ (Stem_tremolo::raw_stencil () looks at the beam.) --hwn */
+
+ Real minlen = 1.0
+ + 2 * Stem_tremolo::raw_stencil (t_flag).extent (Y_AXIS).length ()
+ / ss;
+
+ if (durlog >= 3)
+ {
+ Interval flag_ext = flag (me).extent (Y_AXIS) ;
+ if (!flag_ext.is_empty ())
+ minlen += 2 * flag_ext.length () / ss ;
+
+ /* The clash is smaller for down stems (since the tremolo is
+ angled up.) */
+ if (dir == DOWN)
+ minlen -= 1.0;
+ }
+ length = length >? (minlen + 1.0);