+/*
+ move the stem to right of the notehead if it is up.
+ */
+MAKE_SCHEME_CALLBACK (Stem, offset_callback, 2);
+SCM
+Stem::offset_callback (SCM element_smob, SCM)
+{
+ Grob *me = unsmob_grob (element_smob);
+ Real r = 0.0;
+
+ if (Grob *f = first_head (me))
+ {
+ Interval head_wid = f->extent (f, X_AXIS);
+ Real attach = 0.0;
+
+ if (is_invisible (me))
+ attach = 0.0;
+ else
+ attach = Note_head::stem_attachment_coordinate (f, X_AXIS);
+
+ Direction d = get_direction (me);
+ Real real_attach = head_wid.linear_combination (d * attach);
+ r = real_attach;
+
+ /* If not centered: correct for stem thickness. */
+ if (attach)
+ {
+ Real rule_thick = thickness (me);
+ r += - d * rule_thick * 0.5;
+ }
+ }
+ else
+ {
+ SCM rests = me->get_property ("rests");
+ if (scm_is_pair (rests))
+ {
+ Grob * rest = unsmob_grob (scm_car (rests));
+ r = rest->extent (rest, X_AXIS).center ();
+ }
+ }
+ return scm_make_real (r);
+}