Works perfectly, thanks!
________________________________
From: Aaron Hill <[email protected]>
Sent: Tuesday, June 22, 2021 1:35 AM
To: Nuno Trocado <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: Center graphical markup on staff

On 2021-06-21 5:31 pm, Nuno Trocado wrote:
> Hi everyone!
> How can I have the wiggly line in the example below centered inside the
> staff?
> Thanks,
> Nuno
>
> \score {
>   \relative c' {
>     c4 d
>     s-\markup \override #'(height . 2) \draw-squiggle-line #1 #'(8 . 0)
> ##f
>   }
> }

While you could play around with negative padding to get the TextScript
to overlap the staff, I would recommend hijacking something already on
the staff, such as a rest:

%%%%
markupStencil =
#(define-music-function
  (markup music)
  (markup? ly:music?)
  (define (proc grob)
   (let* ((sten (grob-interpret-markup grob markup))
          (xex (ly:stencil-extent sten X)))
    (ly:grob-set-property! grob 'minimum-X-extent xex)
    (ly:grob-set-property! grob 'stencil sten)))
  #{ \tweak before-line-breaking #proc #music #})

squiggle = \markup
  \override #'(height . 2)
  \draw-squiggle-line #1 #'(8 . 0) ##f

\score {
  \relative c' { c4 d \markupStencil \squiggle r }
}
%%%%

-- Aaron Hill

Reply via email to