lilypond-user
[Top][All Lists]
Advanced

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

Re: LyricExtender snippet: still the best way?


From: Jean Abou Samra
Subject: Re: LyricExtender snippet: still the best way?
Date: Thu, 22 Jun 2023 17:33:00 +0200
User-agent: Evolution 3.48.3 (3.48.3-1.fc38)

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

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