Make it possible to override a stanza number

This commit is contained in:
tux 2024-11-20 17:14:04 +01:00
parent d56c11c5ff
commit 8800341e18

View File

@ -105,13 +105,21 @@ romanStanza =
#(define-music-function (parser location) ()
#{ \override StanzaNumber.style = #'roman #})
override-stanza =
#(define-music-function (parser location stanzanumber) (number?)
#{
\once \override StanzaNumber.forced-spacing = #stanzanumber % misuse property "forced-spacing" to override the stanzanumber
#}
)
stanza =
#(define-music-function (parser location stanzanumber) (number?)
#{
\once \override StanzaNumber.layer = 23 % set this to signal that there is a real stanza and no repeat signs
\applyContext
#(lambda (context)
(let* ((stanzastyle (ly:assoc-get 'style (ly:context-grob-definition context 'StanzaNumber)))
(let* ((stanzanumber (ly:assoc-get 'forced-spacing (ly:context-grob-definition context 'StanzaNumber) stanzanumber))
(stanzastyle (ly:assoc-get 'style (ly:context-grob-definition context 'StanzaNumber)))
(formattedStanzaNumber (format #f (if (eq? stanzastyle 'roman) romanStanzaFormat stanzaFormat) stanzanumber)))
(ly:context-set-property! context 'stanza formattedStanzaNumber)))
#}