Hi all,

This slightly altered snippet shows another problem with the fix/workaround: it 
doesn’t make “compressed” words into a [false] melisma automatically, as it 
clearly should — see, for example, when “foobar” appears on a single note.

\version "2.19"
#(define (hack threshold)
  (lambda (grob)
   (let* ((sten (ly:lyric-hyphen::print grob))
          (sten-ex (if (ly:stencil? sten)
                       (ly:stencil-extent sten X)
                       '(-inf.0 . +inf.0))))
     (if (> (interval-length sten-ex) threshold)
         sten
         (let* ((left (ly:spanner-bound grob LEFT))
                (right (ly:spanner-bound grob RIGHT))
                (left-text (ly:grob-property left 'text))
                (right-text (ly:grob-property right 'text))
                (full-text (string-concatenate `(,left-text ,right-text)))
                (full-text-sten (grob-interpret-markup left full-text))
                (full-text-sten-ext (ly:stencil-extent full-text-sten X))
                (ref (ly:grob-common-refpoint left right X))
                (left-ext (ly:grob-extent left ref X))
                (right-ext (ly:grob-extent right ref X))
                (shift (/ (- (interval-length `(,(car left-ext) . ,(cdr 
right-ext)))
                             (interval-length full-text-sten-ext))
                          2)))
           (begin (ly:grob-set-property! left 'X-offset
                    (+ (ly:grob-property left 'X-offset) shift))
                  (ly:grob-set-property! left 'text full-text)
                  (ly:grob-set-property! right 'text "")
                  (ly:grob-set-property! left 'stencil lyric-text::print)
                  (ly:grob-set-property! right 'stencil lyric-text::print)
                  (ly:grob-property left 'stencil)
                  (ly:grob-property right 'stencil)
                  empty-stencil))))))
<<
  \new Voice = "foo" \relative c' {
    \time 1/4
    \repeat unfold 4 { a8 b a[ b] } \break
    \repeat unfold 23 { a8 b a[ b] }
  }
  \new Lyrics \lyricsto "foo" \lyricmode {
    \override Lyrics.LyricHyphen.stencil = #(hack 0.5)
    \override Lyrics.LyricHyphen.minimum-distance = #0
    \repeat unfold 23 { foo -- bar foobar }
  }
>>

Cheers,
Kieren.
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to