Dear List!

I’m still learning lilypond and working on a piece with long text instructions 
that appear over a note or group of notes. So far I have managed to achieve 
this by hacking off the stencils from text spanners and replacing them with the 
line wrapped markup, but I feel there should be a neater solution out there 
that I just haven’t thought or learned about. This hack has also reached it’s 
limits because it has created the need for multiple simultaneous text spanners 
(not in the example). While I could go further down the hack road by placing 
additional spanners in separate voices with spacer rests or starting to destroy 
trill spanners too, that would just increase the mess. Could you please point 
me towards a tidier path? :)

Thanks a lot!

/Leo

\version "2.19.80"

longTextInstr =
#(define-music-function (alongtext)
   (string?)
   #{
     \once \override Staff.TextSpanner.stencil =
     #(lambda (grob)
        (let* ((grob-X (interval-length
                        (ly:stencil-extent (ly:line-spanner::print grob) X)))
               (layout (ly:grob-layout grob))  
               (props (ly:grob-alist-chain grob 
                        (ly:output-def-lookup layout 
                          'text-font-defaults))))
          
          (ly:text-interface::interpret-markup layout props       
            #{ \markup { 
              \override #(cons 'line-width grob-X)
              \wordwrap-string #alongtext }
            #})
          ))
   #}
   )

\relative {
  c'1 \longTextInstr "this is a long text instruction to be printed 
line-wrapped over a group of notes"
  d \startTextSpan
  e f
  e \stopTextSpan
  d
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to