Success! It's not perfect, because it doesn't recognize that we're using a proportional font, but it looks pretty good to me.
It uses vowels (characters that are always vowels) and secondary vowels (characters that are vowels only if there isn't a regular vowel, like y in english), both of which are easily user=defined. I hope this helps. It seems to me to work pretty well. Carl \version "2.12" \paper { ragged-right = ##f } #(define vowel-set (list->char-set (string->list "AEIOUaeiou"))) #(define secondary-vowel-set (list->char-set (string->list "Yy"))) #(define (vowel-alignment syllable) "Calculate the alignment of a syllable in order to place the first vowel at the notehead." (let* ((syllable-length (string-length syllable)) (vowel-count (string-count syllable vowel-set)) (vowel-position (string-index syllable vowel-set)) (secondary-vowel-count (string-count syllable secondary-vowel-set)) (secondary-vowel-position (string-index syllable secondary-vowel-set)) (align-character (if (> vowel-count 0) vowel-position (if (> secondary-vowel-count 0) secondary-vowel-position (/ syllable-length 2))))) (- (/ (* 2 (+ align-character 0.5)) ; 2 is for RIGHT-LEFT ; 0.5 is to center on vowel syllable-length) 1))) #(define (vowel-center music) "For every EventChord in elements of @var{music}, if elements in EventChord has a LyricEvent, add an item just before the EventChord that will provide the appropriate self-alignment-X to allow vowel-centered lyrics." (define (insert-X-align element-list) (if (null? element-list) '() (let* ((element (car element-list)) (element-name (ly:music-property element 'name)) (syllable (if (eq? element-name 'EventChord) (let ((sub-element (car (ly:music-property element 'elements)))) (if (eq? (ly:music-property sub-element 'name 'LyricEvent)) (ly:music-property sub-element 'text) #f)) #f))) (if syllable (cons (make-music 'ContextSpeccedMusic 'context-type 'Bottom 'element (make-music 'OverrideProperty 'pop-first #t 'grob-property-path '(self-alignment-X) 'grob-value (vowel-alignment syllable) 'once #t 'symbol 'LyricText)) ;"INSERTED HERE" (cons element (insert-X-align (cdr element-list)))) (cons element (insert-X-align (cdr element-list))))))) (set! (ly:music-property music 'elements) (insert-X-align (ly:music-property music 'elements))) music) vowelAlignedLyrics = #(define-music-function (parser location music) (ly:music?) "Set x alignment so each syllable of @var{music} will be aligned with the first vowel centered on the note." (vowel-center music)) theNotes = \relative { g a b c | d c b a | g1 } theLyrics = \lyricmode { Each syl -- la -- ble's vowel is on the note. } \score { << \new Voice = "melody" \theNotes \new Lyrics \lyricsto "melody" \theLyrics \new Lyrics \lyricsto "melody" \vowelAlignedLyrics \theLyrics >> }
Vowel Centered Lyrics.png
Description: Vowel Centered Lyrics.png
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user