On 6 July 2010 10:54, -Eluze <[email protected]> wrote:

> i have tried both of them but none seems to work in polyphonic situation:

Indeed, this is the main limitation of this approach.  There's no
simple way of determining which notehead in the array is the correct
item to align each voice to.

Since you're using 2.13, I think a better solution would be to use a
Scheme engraver to set the markup's parent: this is fine in polyphonic
situations since each voice can only see the relevant NoteColumn:

\version "2.13.27"

#(define (Text_align_engraver ctx)
   (let ((scripts '())
         (note-column #f))

     `((acknowledgers
        (note-column-interface
         . ,(lambda (trans grob source)
              ;; cache NoteColumn in this voice
              (set! note-column grob)))

        (text-script-interface
         . ,(lambda (trans grob source)
              ;; add each TextScript to `scripts' list
              (set! scripts (cons grob scripts)))))

       (stop-translation-timestep
        . ,(lambda (trans)
             ;; if any TextScript grobs exist,
             ;; set NoteColumn as X-parent
             (and (pair? scripts)
                  (for-each (lambda (script)
                              (set! (ly:grob-parent script X) note-column))
                            scripts))
             ;; clear scripts ready for next timestep
             (set! scripts '()))))))

\layout {
  \context {
    \Voice
    \consists #Text_align_engraver
    \override TextScript #'X-offset =
#ly:self-alignment-interface::aligned-on-x-parent
  }
}

\context Staff <<
  \context Voice = "1" \relative c' {
    \voiceOne
    \override TextScript #'self-alignment-X = #CENTER
    \override NoteColumn #'force-hshift = #4
    d1-\markup \arrow-head #Y #UP ##t
  }
  \context Voice = "2" \relative c' {
    \voiceTwo
    \override TextScript #'self-alignment-X = #CENTER
    c1-\markup \huge "^"
  }
>>

Cheers,
Neil

_______________________________________________
lilypond-user mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to