lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting width of markup in a music function


From: Nathan Reed
Subject: Re: Getting width of markup in a music function
Date: Tue, 11 May 2010 00:17:09 -0700

On Mon, May 10, 2010 at 11:25 PM, Mark Polesky <address@hidden> 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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]