lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: LyricHyphen hara-kiri


From: Kieren MacMillan
Subject: Re: LyricHyphen hara-kiri
Date: Sat, 21 Dec 2013 15:27:05 -0500

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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]