Tuesday, April 22, 2008

LilyPond text spanner text with \halign

Text spanner text can align directly in markup. Use \halign



\new Staff {
c'4
\override TextSpanner #'bound-details #'left #'stencil-align-dir-y =
#center
\override TextSpanner #'bound-details #'left #'text =
\markup { \halign #-1 \italic "vif" \hspace #2 }
c'4 \startTextSpan
c'4
c'4 \stopTextSpan
}


\new Staff {
c'4
\override TextSpanner #'bound-details #'left #'stencil-align-dir-y =
#center
\override TextSpanner #'bound-details #'left #'text =
\markup { \halign #0 \italic "vif" \hspace #2 }
c'4 \startTextSpan
c'4
c'4 \stopTextSpan
}


\new Staff {
c'4
\override TextSpanner #'bound-details #'left #'stencil-align-dir-y =
#center
\override TextSpanner #'bound-details #'left #'text =
\markup { \halign #1 \italic "vif" \hspace #2 }
c'4 \startTextSpan
c'4
c'4 \stopTextSpan
}

The reference point is, in each case, the left edge of the attachment note.

1 comment:

Trevor Bača said...

And it is possible to change the note-part to which the spanner's left text attaches. Do \override TextSpanner #'bound-details #'left #'attach-dir = #center to cause all three of the examples given here to lay out relative to the dead center of the notehead from which the spanner starts (rather than from the left edge of the notehead to which the spanner starts, as show in the post).