[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
LyricExtender snippet: still the best way?
From: |
Kieren MacMillan |
Subject: |
LyricExtender snippet: still the best way? |
Date: |
Thu, 22 Jun 2023 09:14:35 -0400 |
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?
Thanks,
Kieren.
%%% SNIPPET BEGINS
\version "2.25.2"
#(define (conditional-kill-lyric-extender-callback . args)
(lambda (grob)
(let* ((orig (ly:grob-original grob))
(siblings (ly:spanner-broken-into orig))
(minimum-length
(if (null? args)
(ly:grob-property grob 'minimum-length 0)
(car args)))
(X-extent (ly:stencil-extent (ly:grob-property grob 'stencil
empty-stencil) X))
(natural-length (- (cdr X-extent) (car X-extent))))
(if (and (> minimum-length natural-length)
(<= (length siblings) 1)) ;; never kill a broken extender
(ly:grob-suicide! grob)))))
\layout {
indent = 0
\context {
\Lyrics
\override LyricExtender.minimum-length = #3
\override LyricExtender.after-line-breaking =
#(conditional-kill-lyric-extender-callback)
}
}
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
}
%%% SNIPPET ENDS
______________________________________________
My work day may look different than your work day. Please do not feel obligated
to read or respond to this email outside of your normal working hours.
- LyricExtender snippet: still the best way?,
Kieren MacMillan <=