lilypond-user
[Top][All Lists]
Advanced

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

Re: Modified slur stencil with added markup


From: Urs Liska
Subject: Re: Modified slur stencil with added markup
Date: Fri, 12 Oct 2018 09:58:18 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

Hi Torsten,


Am 12.10.2018 um 00:56 schrieb Torsten Hämmerle:
Hi Urs,

The centering of the slur stencil destroys its alignment (i.e. reference
point), so I'd just leave it alone and center-align the text by explicitly
calculating the necessary markup x shift from the stencil extents.


%%%%%%%%%%%%%%%%%%
\version "2.19.82"

annotatedSlur =
#(define-music-function (padding text) ((number? 1) markup?)
    #{
      \once \override Slur.after-line-breaking =
      #(lambda (grob)
         (let*
          ((stencil (ly:slur::print grob))
           (dir (ly:grob-property grob 'direction))
           (markup-stencil (grob-interpret-markup grob text))
           (shift (- (interval-center (ly:stencil-extent stencil X))
                    (interval-center (ly:stencil-extent markup-stencil X))))
           (new-stencil
            (ly:stencil-combine-at-edge
             stencil
             Y dir
             (ly:stencil-translate-axis markup-stencil shift X)
             padding)))
          (ly:grob-set-property! grob 'stencil new-stencil)))
    #})

{
   \annotatedSlur
   %\markup \score { c''' }
   \markup "hin."
   c''4 ( g' g' c'' )
}
%%%%%%%%%%%%%%%%%%

HTH,
Torsten

Thank you very much, this indeed fixes the horizontal alignment problem in a clean and understandable way - although I wouldn't have known how to do it. What is 'interval-center'? Grepping the source doesn't show a definition, so I'd assume it's in the C++ domain? I haven't found anything about that in the documentation (or through Google).

Urs



reply via email to

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