Le jeudi 22 juin 2023 à 09:14 -0400, Kieren MacMillan a écrit :

> Hi all,
> 
> The callback shown in this snippet is something that is automatically 
> included in all my engravings that include lyrics; it is designed to remove 
> LyricExtenders that fall below a minimum-length threshold.
> 
> Is the given code still the best way to accomplish what I want?
> In particular, I know after-line-breaking isn’t always the optimal place to 
> put callbacks — is there a better place for this one?


Indeed, you can put it in stencil:

```
\version "2.25.5"

extenderMinLength =
\override LyricExtender.stencil =
  #(grob-transformer
    'stencil
    (lambda (grob orig)
      (if (and (ly:stencil? orig)
               (< (interval-length (ly:stencil-extent orig X))
                  (ly:grob-property grob 'minimum-length))
               (null? (ly:spanner-broken-into (ly:grob-original grob))))
          empty-stencil
          orig)))
  
\layout {
  indent = 0
  \context {
    \Lyrics
    \extenderMinLength
    \override LyricExtender.minimum-length = #3
  }
}

mel = { g'2 ~ 4 4 ~ 2 ~ 4 4 4 ~ 16 8. ~ 8 8 4 ~ 4 r r2 }
lyr = \lyricmode { These __ are __ lyr -- ic __ ex -- ten -- ders. __ }

test =
  <<
    \new Staff \new Voice = "melody" \mel
    \addlyrics \lyr
  >>

\score {
  \test
}

\score {
  \layout { ragged-right = ##f }
  \test
}
```

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to