From 8c7386807b7607ae6e0bee073624d9e5f71b0a38 Mon Sep 17 00:00:00 2001 From: Christoph Wagner Date: Sat, 30 Mar 2024 18:12:51 +0100 Subject: [PATCH] fix spacing in new chordlyrics system --- chord_settings.ly | 13 ++++++++++++- verses_with_chords.ly | 35 +++++++++++++++++++++++++++++------ 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/chord_settings.ly b/chord_settings.ly index 18cbd1f..9e0317c 100644 --- a/chord_settings.ly +++ b/chord_settings.ly @@ -100,6 +100,15 @@ generalLayout = \layout { } } +#(define-public (custom-lyric-text::print grob) + "Allow interpretation of tildes as lyric tieing marks." + ;; See also similar code in Lyric_performer. + (let ((text (ly:grob-property grob 'text))) + + (grob-interpret-markup grob (if (string? text) + (make-pad-right-markup -0.1 (make-tied-lyric-markup text)) + text)))) + lyricsWithChordsLayout = \layout { \generalLayout \context { @@ -108,14 +117,16 @@ lyricsWithChordsLayout = \layout { } \context { \Lyrics - \override VerticalAxisGroup.nonstaff-relatedstaff-spacing.basic-distance = 0 + \override VerticalAxisGroup.nonstaff-relatedstaff-spacing.basic-distance = #(- (- songTextLineHeigth songTextChordFontSize) 1) \override LyricText.parent-alignment-X = #LEFT \override LyricText.self-alignment-X = #LEFT \override LyricText.word-space = 0.8 \override LyricSpace.minimum-distance = 0.8 + \override LyricText.stencil = #custom-lyric-text::print } \context { \Score + \override PaperColumn.keep-inside-line = ##f \override SpacingSpanner.uniform-stretching = ##t \override SpacingSpanner.spacing-increment = 0 \remove Bar_number_engraver diff --git a/verses_with_chords.ly b/verses_with_chords.ly index 7f1f82c..396b71b 100644 --- a/verses_with_chords.ly +++ b/verses_with_chords.ly @@ -203,22 +203,42 @@ y) `(,amount . 0)))) +#(define-markup-command (pad-right layout props amount arg) + (number? markup?) + (let* ((m (interpret-markup layout props arg)) + (x (ly:stencil-extent m X)) + (y (ly:stencil-extent m Y))) + (ly:make-stencil (ly:stencil-expr m) + (cons (car x) (+ (cdr x) amount)) + y))) + +#(define-markup-command (score-equal-height layout props reference-height lines) + (number? markup-list?) + #:category music + #:properties ((baseline-skip)) + (stack-stencils Y DOWN baseline-skip + (map + (lambda (line) (ly:make-stencil (ly:stencil-expr line) (ly:stencil-extent line X) `(0 . ,reference-height))) + (interpret-markup-list layout props lines)))) + #(define-markup-command (chordlyrics layout props lyrics) (ly:music?) #:properties ((verse-chords #f) (verse-reference-voice #f) - (verse-break-voice #f)) + (verse-break-voice #f) + (verse-line-height songTextLineHeigth) + (intraverse-vspace 0)) "Vers mit Akkorden" (interpret-markup layout props #{ \markup { - \override #'(baseline-skip . 0.3) + \override #`(baseline-skip . ,intraverse-vspace) \pad-left #-10 - \score { + \score-equal-height #verse-line-height \score-lines { \transposable << \new Devnull { #(if (ly:music? verse-break-voice) verse-break-voice) } - #(if (ly:music? verse-chords) verse-chords songChords) - \new NullVoice { #(if (ly:music? verse-reference-voice) verse-reference-voice firstVoice) } + #(if (ly:music? verse-chords) verse-chords #{ \chords { \verseChords } #}) + \new NullVoice { #(if (ly:music? verse-reference-voice) verse-reference-voice #{ \global \firstVoice #}) } \addlyrics { #lyrics } >> \layout { @@ -237,5 +257,8 @@ #(define-markup-command (nochordlyrics layout props lyrics) (ly:music?) "Vers ohne Akkorde" (interpret-markup layout props - (markup #:override `(verse-chords . ,#{#}) #:chordlyrics lyrics)) + (markup + #:override `(verse-chords . ,#{#}) + #:override `(verse-line-height . ,(- songTextLineHeigth 2)) + #:chordlyrics lyrics)) )