lilypond-user
[Top][All Lists]
Advanced

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

Re: Text Spanner auto expand to end of duration


From: Thomas Morley
Subject: Re: Text Spanner auto expand to end of duration
Date: Thu, 12 Nov 2020 21:25:22 +0100

Am Do., 12. Nov. 2020 um 14:36 Uhr schrieb Dimitris Marinakis
<dtsmarin02@gmail.com>:
>
> Can this be adapted to work with Text Spanners? Does anyone have any similar 
> workarounds?
> I just need to automatically extend TextSpanners to the end of the duration 
> without too many manual guesstimations.
>
>  #(define (encompass-duration grob)
>    (let* ((rb (ly:spanner-bound grob RIGHT))
>           (sys (ly:grob-system grob))
>           (cols (ly:grob-array->list (ly:grob-object sys 'columns)))
>           (me-forward (memq rb cols)))
>      (if (and me-forward (> (length me-forward) 1))
>          (ly:spanner-set-bound! grob RIGHT (cadr me-forward)))
>      (ly:piano-pedal-bracket::print grob)))
>
> {
>   \override Staff.PianoPedalBracket.stencil = #encompass-duration
>  % \override Staff.PianoPedalBracket.shorten-pair = #'(0 . 0.5)
>   \set Staff.pedalSustainStyle = #'bracket
>   c'4\sustainOn c' c' c'\sustainOff
>   c'4 c'\sustainOn c'\sustainOff c'
>   c'4\sustainOn c' c' c'
>   \break
>   c'4\sustainOff c' c' c'
> }
>
>

Hi,

probably below.
Works for both, TextSpanner and PianoPedalBracket. Not sure if it will
work for all spanner-grobs in every situation, though.

\version "2.20.0"

#(define (encompass-spanner-duration grob)
   (let* ((rb (ly:spanner-bound grob RIGHT))
          (right-col (ly:item-get-column rb))
          (right-neighbor (ly:grob-object right-col 'right-neighbor)))
     (if (ly:grob? right-neighbor)
         (ly:spanner-set-bound! grob RIGHT right-neighbor))))

{
  \override TextSpanner.after-line-breaking =
    #encompass-spanner-duration
  c'4\startTextSpan c' c' c'\stopTextSpan
  c'4 c'\startTextSpan c'\stopTextSpan c'
  c'4\startTextSpan c' c' c'
  \break
  c'4\stopTextSpan c' c'\startTextSpan c'\stopTextSpan
}

{
  \override Staff.PianoPedalBracket.after-line-breaking =
    #encompass-spanner-duration
  \set Staff.pedalSustainStyle = #'bracket
  c'4\sustainOn c' c' c'\sustainOff
  c'4 c'\sustainOn c'\sustainOff c'
  c'4\sustainOn c' c' c'
  \break
  c'4\sustainOff c' c' c'
}

Cheers,
  Harm



reply via email to

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