On Thu, Sep 19, 2013 at 11:01 AM, David Nalesnik
<david.nales...@gmail.com>wrote:

> Hi Benjamin,
>
>
[...]


> This is what I come up with:
>

[...]

OK, that was unnecessarily roundabout.  Why bother with columns when I have
access to all grobs, and I can just compare LyricText grobs?

Try this:

(Again, should work on 2.16.1.)

%%%%%%%%%%%%%%%%%%%%

\version "2.17.25"

#(define (my-callback grob)
   (let* ((text (ly:grob-property-data grob 'text))
          (refp (ly:grob-system grob))
          ; This returns all grobs in a line.
          (all-grobs (ly:grob-array->list
                      (ly:grob-object refp 'all-elements)))
          ; We're only interested in LyricText grobs.
          (just-syllables
            (filter
              (lambda (x) (grob::has-interface x 'lyric-syllable-interface))
              all-grobs))
          ; We want the first LyricText grob in the system.  We must locate
this
          ; by position, since grobs don't seem to be listed in order in the
          ; 'all-elements grob array.
          (first-syl
             (fold
               (lambda (elem prev)
                 (if (< (ly:grob-relative-coordinate elem refp X)
                        (ly:grob-relative-coordinate prev refp X))
                     elem
                     prev))
              (car just-syllables)
              just-syllables)))

     ; If our LyricText grob is the first on the line, override its stencil.
     (if (eq? grob first-syl)
         (begin
           (ly:grob-set-property! grob 'text
             #{ \markup \combine #text \translate #'(1.6 . -0.5) \draw-line
#'(-4 . 0) #})
           (ly:grob-set-property! grob 'stencil (lyric-text::print
grob))))))

melody = \repeat unfold 16 g'4
lyr = \lyricmode {
  \repeat unfold 16 sol
}
\score {
  \new Staff <<
    \new Voice = "voice" {
      \melody
    }
    \new Lyrics \with {
      \override LyricText #'after-line-breaking = #my-callback
    } \lyricsto "voice" \lyr
  >>
}
\paper {
  indent = 0
  line-width = 5.5\cm
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to