Le 14/11/2022 à 17:11, Kieren MacMillan a écrit :
Hi again!Given the success of my first sortie, here's another snippet that might be automated. (Note that this one matches the OP's situation.) This is definitely a tweak I do on a very regular basis in my music-with-text scores: sliding a text backwards, potentially under previous grobs. This one is obviously [intentionally] extreme, and again avoids some “dragons” (clefs, breaks, other lyrics, etc.). Then again, I had to trial-and-error it to find the final number I used (0.5), and don’t currently know what algorithm might be applied to remove the T&E process… In any case, I’m hopeful that lightning will strike twice, and a single “hacky” function might (a) be applicable to a huge percentage of real-world situations and (b) might be additional input/data for a potential general solution down the line.
\version "2.23.81"
#(ly:set-option 'compile-scheme-code)
\layout {
\context {
\Lyrics
\consists
#(lambda (context)
(let ((previous #f))
(make-engraver
(acknowledgers
((lyric-syllable-interface engraver grob source-engraver)
(when previous
(set! (ly:grob-object previous 'right-syllable)
grob))
(set! previous grob))))))
}
}
autoMove =
\tweak LyricSpace.springs-and-rods ##f
\tweak LyricHyphen.springs-and-rods ##f % untested
\tweak LyricText.extra-spacing-height #'(+inf.0 . -inf.0)
\tweak LyricText.after-line-breaking
#(lambda (grob)
(let ((right (ly:grob-object grob 'right-syllable #f)))
(when right
(ly:grob-property right 'after-line-breaking)
(let* ((refp (ly:grob-system grob))
(end (interval-end (ly:grob-extent grob refp X)))
(right-begin (interval-start (ly:grob-extent right
refp X)))
(default-space (- right-begin end))
;; Same as LyricSpace.minimum-distance default, should be
;; read there ...
(padding 0.45))
(when (< default-space padding)
(ly:grob-translate-axis! grob
(- default-space padding)
X))))))
\etc
\paper {
top-margin = 0.5\in
left-margin = 0.5\in
line-width = 6\in
ragged-right = ##f
}
spacecase_notes = { R1 a'4 c'8 f' bes'4 a' g'8 8 \tuplet 3/2 { g'8 8
fis' } g'2 }
spacecase_lyrics = \lyricmode { \autoMove Scraunched is the long -- est
sin -- gle syl -- la -- ble word! }
\score {
<<
\new Staff \new Voice = "melody" \spacecase_notes
\new Lyrics \lyricsto "melody" \spacecase_lyrics
>>
}
This just removes the lyric syllable's presence in horizontal
spacing, then adjusts its placement if it collides with its
right neighbor. It works in this case because there is nothing
on the left that the lyric syllable in question could collide
with. (It also does not handle collisions with other things
than the next lyric syllable.)
Best,
Jean
OpenPGP_signature
Description: OpenPGP digital signature
