On Mon, May 10, 2010 at 11:25 PM, Mark Polesky <markpole...@yahoo.com>wrote:

> Nathan Reed wrote:
> > I'd like to be able to compute the width of a markup
> > inside a music function, so that I can size another
> > element based on the size of the markup.
>
> Can we see some code?  What is the music-function for?
>
> - Mark
>

Here's my code as it stands.  It produces a narration measure as shown in
the image linked in my previous message.

narration =
#(define-music-function (parser location rest text1 text2)
                        (ly:music? string? string?)
    (let (
            (fermata-event
                (make-music
                    'ArticulationEvent
                    'tweaks (list '(outside-staff-priority . 0))    ; Force
fermata to be under the markup text
                    'articulation-type "fermata"))
            (text-event
                (make-music
                    'TextScriptEvent
                    'direction 1
                    'tweaks (list '(baseline-skip . 2))                ; Fix
line spacing for text
                    'text (markup #:center-align #:teeny #:column (text1
text2))))
            (result (ly:music-deep-copy rest)))
        (set! (ly:music-property result 'elements)
            (append
                (ly:music-property rest 'elements)
                (list fermata-event text-event)))
        #{ \textLengthOn $result \textLengthOff #} ))

I call it like:

\narration r1 #"On the branch..." #"...chirped the bird gaily."

I'd like to expand the measure to be slightly wider than the text, so it
doesn't collide with rehearsal marks.

Thanks,
Nathan Reed
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to