1 Commits

Author SHA1 Message Date
tux
5af41cebae new engraver for spacing in chordlyrics 2025-12-15 01:47:33 +01:00
3 changed files with 12 additions and 24 deletions

View File

@@ -134,23 +134,18 @@ override-stanza =
#} #}
) )
#(define (handle-stanza-numbers context numbers number-formater)
(let* ((stanzanumbers (ly:assoc-get 'custom-stanzanumber-override (ly:assoc-get 'details (ly:context-grob-definition context 'StanzaNumber) '()) numbers))
(stanza-style (ly:assoc-get 'style (ly:context-grob-definition context 'StanzaNumber)))
(roman-format (lambda (stanzanumber) (format #f "~@r" stanzanumber))))
(ly:context-set-property! context 'stanza
(number-formater
(if (eq? stanza-style 'roman)
(map roman-format stanzanumbers)
stanzanumbers)))))
#(define (stanza . stanzanumbers) #(define (stanza . stanzanumbers)
#{ #{
\once \override StanzaNumber.details.custom-realstanza = ##t % set this to signal that there is a real stanza and no repeat signs \once \override StanzaNumber.details.custom-realstanza = ##t % set this to signal that there is a real stanza and no repeat signs
\applyContext \applyContext
#(lambda (context) #(lambda (context)
(handle-stanza-numbers context stanzanumbers (let* ((stanzanumbers-override (ly:assoc-get 'custom-stanzanumber-override (ly:assoc-get 'details (ly:context-grob-definition context 'StanzaNumber) '()) #f))
(lambda (numbers) (string-join (map (lambda (n) (format #f stanzaFormat n)) numbers) ", ")))) (stanza-style (ly:assoc-get 'style (ly:context-grob-definition context 'StanzaNumber)))
(stanza-format (lambda (stanzanumber) (format #f (if (eq? stanza-style 'roman) romanStanzaFormat stanzaFormat) stanzanumber))))
(ly:context-set-property! context 'stanza
(string-join (map stanza-format
(if stanzanumbers-override stanzanumbers-override stanzanumbers))
", "))))
#} #}
) )
@@ -158,14 +153,7 @@ ref =
#(define-music-function (stanzanumbers lyrics) ((number-list? (list)) ly:music?) #(define-music-function (stanzanumbers lyrics) ((number-list? (list)) ly:music?)
#{ \lyricmode { #{ \lyricmode {
\once \override StanzaNumber.details.custom-realstanza = ##t % set this to signal that there is a real stanza and no repeat signs \once \override StanzaNumber.details.custom-realstanza = ##t % set this to signal that there is a real stanza and no repeat signs
\applyContext \set stanza = #(make-on-the-fly-markup (lambda (layout props m) ((ly:output-def-lookup layout 'refMarkupFormatter) layout props stanzanumbers)) (make-null-markup))
#(lambda (context)
(handle-stanza-numbers context stanzanumbers
(lambda (numbers)
(make-on-the-fly-markup
(lambda (layout props m)
((ly:output-def-lookup layout 'refMarkupFormatter) layout props numbers))
(make-null-markup)))))
#lyrics #lyrics
} }
#} #}

View File

@@ -16,6 +16,7 @@ songTocColumns = 3
globalSize = 15 globalSize = 15
lyricSize = 1.6 lyricSize = 1.6
stanzaFormat = "~a." stanzaFormat = "~a."
romanStanzaFormat = "~@r."
refString = "Ref.:" refString = "Ref.:"
refStringWithNumbers = "Ref. ~a:" refStringWithNumbers = "Ref. ~a:"
% hübsche Wiederholungszeichen für den Liedtext % hübsche Wiederholungszeichen für den Liedtext

View File

@@ -302,10 +302,9 @@ Chord_lyrics_spacing_engraver =
(ly:grob-set-property! grob 'extra-spacing-width (ly:grob-set-property! grob 'extra-spacing-width
(cons (- chord-width-since-last-lyric) (cdr (ly:grob-property grob 'extra-spacing-width '(0 . 0))))) (cons (- chord-width-since-last-lyric) (cdr (ly:grob-property grob 'extra-spacing-width '(0 . 0)))))
(if last-printed-chord (if last-printed-chord
(let ((gap-for-starting-rest 2.0)) (begin
(if stanza (ly:grob-set-property! stanza 'padding (+ 1 gap-for-starting-rest))) (if stanza (ly:grob-set-property! stanza 'padding chord-width-since-last-lyric))
(ly:grob-set-parent! grob X last-printed-chord) (place-at-right-edge grob last-printed-chord 0)
(ly:grob-set-property! grob 'X-offset gap-for-starting-rest)
))) )))
) )
(set! last-lyric-syllable grob) (set! last-lyric-syllable grob)