lilypond-user
[Top][All Lists]
Advanced

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

Re: Change stanza formatting


From: Aaron Hill
Subject: Re: Change stanza formatting
Date: Fri, 01 Mar 2019 17:21:23 -0800
User-agent: Roundcube Webmail/1.3.8

On 2019-03-01 10:20 am, David F. wrote:
There’s one small issue that I noticed.  I’m engraving music with
simultaneous bilingual lyrics and I’m using the stanza number to print
the language name. Since the language name is almost always longer
than the first syllable, it is making that first note column wider
than it would be without the stanza number. Is there a way to keep the
sanza number from influencing the width of the note column?

(On the one hand, the extra space isn’t necessarily a big deal.  But
the whole reason I want to print the language names on top of the
lyrics instead of to the left of them is that I’ve run into cases
where the extra text in the stanza number is preventing me from
getting everything I want onto the first line of music.)

Would it work to use abbreviations for the languages? (e.g. "E:" and "F:" for "English" and "Français".) Unless your first LyricText is particularly wide, there should be enough room for such an abbreviation as a traditional StanzaNumber without the need to play around with properties.

--

As an alternative, you could see if right-aligning the StanzaNumbers works for you. Since this means the LyricTexts and StanzaNumbers share a common right extent, there should be no additional space added before the next syllable:

%%%%
\version "2.19.82"

\layout { \context { \Lyrics
  \override StanzaNumber.direction = #UP
  \override StanzaNumber.side-axis = #Y
  \override StanzaNumber.padding = #0.2
  \override StanzaNumber.X-offset = #(lambda (grob)
    (define (grob-list-property glst prop)
      (map (lambda (g) (ly:grob-property g prop)) glst))
    (let* ((sse (ly:grob-object grob 'side-support-elements))
           (lyrics (cdr (ly:grob-array->list sse)))
           (lyrics-extents (grob-list-property lyrics 'X-extent))
           (lyrics-widths (map interval-length lyrics-extents))
           (lyrics-offsets (grob-list-property lyrics 'X-offset))
           (lyrics-rights (map + lyrics-offsets lyrics-widths))
           (lyrics-right (apply max lyrics-rights))
           (grob-extent (ly:grob-property grob 'X-extent))
           (grob-width (interval-length grob-extent)))
     (- lyrics-right grob-width)))
} }

\new Voice \relative { \time 3/4 g'2 e4 a2 f4 g2. }
\addlyrics { \set stanza = #"English" Hi, my name is Bert. }
\addlyrics { \set stanza =  #"Français" Oooh, ché -- ri, je t'aime }
%%%%

NOTE: The code above considers all of the LyricTexts in the column, not just the current line. As a result, there is a consistent right-alignment of the StanzaNumbers based on the widest of the LyricTexts.

--

Assuming you want left-alignment without the added space to the right, you will probably have to resort to altering the actual extents of the StanzaNumber:

%%%%
\version "2.19.82"

#(define (interval-max . args) (reduce interval-union empty-interval args))
#(define ((side-support-property func prop) grob)
  (let* ((sse (ly:grob-object grob 'side-support-elements))
         (elems (cdr (ly:grob-array->list sse)))
         (props (map (lambda (g) (ly:grob-property g prop)) elems)))
    (apply func props)))

\layout { \context { \Lyrics
  \override StanzaNumber.direction = #UP
  \override StanzaNumber.side-axis = #Y
  \override StanzaNumber.padding = #0.2
\override StanzaNumber.X-offset = #(side-support-property min 'X-offset) \override StanzaNumber.X-extent = #(side-support-property interval-max 'X-extent) \override StanzaNumber.Y-offset = #ly:side-position-interface::y-aligned-side
} }

\new Voice \relative { \time 3/4 g'2 c,4 a'2 f4 g2. }
\addlyrics { \set stanza = #"English" Hi, my name is Bert. }
\addlyrics { \set stanza =  #"Français" Oooh, ché -- ri, je t'aime }
%%%%

But be advised this approach can generate overlapping ink. In the example above, I lowered the E in the first measure to middle C to demonstrate this. The collision occurs because we told LilyPond that the StanzaNumber only extended as far to the right as the supporting LyricTexts.


-- Aaron Hill



reply via email to

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