From 3b87476549efb6cea2bd95b21d567147628f3556 Mon Sep 17 00:00:00 2001 From: Christoph Wagner Date: Sun, 30 Jun 2024 10:28:21 +0200 Subject: [PATCH] have repeat signs as stanzas in lyrics --- basic_format_and_style_settings.ly | 46 ++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/basic_format_and_style_settings.ly b/basic_format_and_style_settings.ly index 7c4e0ef..6b93435 100644 --- a/basic_format_and_style_settings.ly +++ b/basic_format_and_style_settings.ly @@ -101,10 +101,44 @@ romanStanza = stanza = #(define-music-function (parser location stanzanumber) (number?) - (make-apply-context - (lambda (context) - (let* ((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))))) +#{ + \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))) + (formattedStanzaNumber (format #f (if (eq? stanzastyle 'roman) romanStanzaFormat stanzaFormat) stanzanumber))) + (ly:context-set-property! context 'stanza formattedStanzaNumber))) +#} +) -ref = { \set stanza = \refString } +ref = { + \once \override StanzaNumber.layer = 23 % set this to signal that there is a real stanza and no repeat signs + \set stanza = \refString +} + +% prints a repStart Sign as stanza if the tag 'repeats is kept. +% if there was a stanza already set by the stanza function with StanzaNumber.layer = 23 we set that also as stanza. +repStartWithTag = \lyricmode { + \tag #'repeats { + \applyContext + #(lambda (context) + (let ((lastStanza (ly:context-property context 'stanza)) + (printLastStanza (= (ly:assoc-get 'layer (ly:context-grob-definition context 'StanzaNumber) 0) 23)) + (stanzaFontSeries (ly:assoc-get 'font-series (ly:context-grob-definition context 'StanzaNumber) 'normal))) + (ly:context-set-property! context 'stanza + (make-concat-markup + (if printLastStanza + (list (make-override-markup `(font-series . ,stanzaFontSeries) lastStanza) (make-hspace-markup 1) repStart) + (list repStart) + ))))) + \once \override StanzaNumber.font-series = #'normal + } +} + +repStopWithTag = \lyricmode { + \tag #'repeats { + \once \override StanzaNumber.font-series = #'normal + \once \override StanzaNumber.direction = 1 + \set stanza = \markup { \repStop } + } +} \ No newline at end of file