Hi Jun,

On Wed, May 1, 2013 at 10:28 PM, Jun Wang <[email protected]> wrote:

>  Hi
> I have a lyrics alignment issue when lyrics contains punctuations.
>
> First Let me take the example from the reference manual,  see the " I am
> so lonely..." piece below.
>
> http://lilypond.org/doc/v2.16/Documentation/notation/common-notation-for-vocal-music#entering-lyrics
>
> \relative c' { \time 3/4 e4 e4. e8 d4 e d c2. }
> \addlyrics { "\"I" am so lone -- "ly,\"" said she }
>
> Note because ("I) is treated as a whole syllable, It makes single
> character (I) not appears in the middle.
> What I want is to make "I" in the middle position under the note.
>
> Second example, see attached pdf, There are lot of punctuations in the
> music, the alignment issue becomes very visible.
>
> Is it possible to explicitly define punctuations in the lilypond file?  Or
> Do I have to tweak each syllable manually?
>

It's possible to write a Scheme function to accommodate certain characters
at the beginning and ending of words.  The following function creates an
override of 'X-offset which hopefully gives you what you want.   You can
modify the list of punctuation characters recognized by modifying the
variables called `punct-R' and `punct-L'.  I added a space character
because I notice in your .pdf that you add one before commas, exclamation
points, etc.

Anyway, hope this is helpful!

-David


\version "2.16"

#(define (align grob)
  (let* ((stil (ly:grob-property grob 'stencil))
         (stil-X (ly:stencil-extent stil X))
         (text (ly:grob-property grob 'text))
         (punct (char-set #\, #\" #\; #\! #\. #\space))
         ; determine X-extent of text stencil without punctuation at end
         (text-L (string-trim-right text punct))
         (text-L-stil (grob-interpret-markup grob text-L))
         (text-L-stil-X (ly:stencil-extent text-L-stil X))
         (displacement (/ (- (cdr text-L-stil-X) (cdr stil-X)) 2))
         ; determine X-extent of text stencil without punctuation at start
         (text-R (string-trim text punct))
         (text-R-stil (grob-interpret-markup grob text-R))
         (text-R-stil-X (ly:stencil-extent text-R-stil X))
         (displacement (+ displacement
                          (/ (- (cdr stil-X) (cdr text-R-stil-X)) 2))))

     (- (ly:self-alignment-interface::aligned-on-x-parent grob)
        displacement)))

\paper {
  ragged-right = ##f
}

\relative c' {
  \time 3/4 e4 e4. e8
  d4 e d c2.
}

\addlyrics {
  \override LyricText #'X-offset = #align
  "\"\"\"I!!!!!!!!!!!!" ,,,am,,,,,,,,,, !!!!!!!!!!!so
  lone -- "ly!!!!!,\"" said "she!!!!!!!!!!!!!!!\""
}
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to