Hi Urs,
The centering of the slur stencil destroys its alignment (i.e. reference
point), so I'd just leave it alone and center-align the text by explicitly
calculating the necessary markup x shift from the stencil extents.
%%%%%%%%%%%%%%%%%%
\version "2.19.82"
annotatedSlur =
#(define-music-function (padding text) ((number? 1) markup?)
#{
\once \override Slur.after-line-breaking =
#(lambda (grob)
(let*
((stencil (ly:slur::print grob))
(dir (ly:grob-property grob 'direction))
(markup-stencil (grob-interpret-markup grob text))
(shift (- (interval-center (ly:stencil-extent stencil X))
(interval-center (ly:stencil-extent markup-stencil X))))
(new-stencil
(ly:stencil-combine-at-edge
stencil
Y dir
(ly:stencil-translate-axis markup-stencil shift X)
padding)))
(ly:grob-set-property! grob 'stencil new-stencil)))
#})
{
\annotatedSlur
%\markup \score { c''' }
\markup "hin."
c''4 ( g' g' c'' )
}
%%%%%%%%%%%%%%%%%%
HTH,
Torsten