lilypond-user
[Top][All Lists]
Advanced

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

Re: Descenders affecting line height calculation for lyrics in columns?


From: Bernhard Fisseni
Subject: Re: Descenders affecting line height calculation for lyrics in columns?
Date: Thu, 20 Jan 2022 23:16:07 +0100

Bernhard Fisseni schrieb am 20.01.22 um 20:13:
Bernhard Fisseni schrieb am 20.01.22 um 15:36:
Hi Aaron,

thank you for the informative answer!

Aaron Hill schrieb am 20.01.22 um 10:07:
On 2022-01-19 11:41 pm, Bernhard Fisseni wrote:
[ . . . ] In the
song, there are some lines with descenders (p, g, q going below the
baseline).  I show the effect here by inserting "q" in the left
column. Lilypond seems to calculate the "real" line height of the
writing, not some kind of nominal text line height, so that a line
with descenders is higher than a line without. [ . . . ]
Is this the expected behaviour?

No (but kind of yes).

Firstly, \column and \line work properly, respecting baseline-skip and
word-space:

In your code, you have nested \columns within \columns, which does not
work the same as a singular \column would.  \column attempts to align
the contains markups by their respective baselines.  [...]
There are likely many ways to tackle this.  (Other folks on the list
might chime in with their preferred method.)  The simplest option I see
is manually adjusting the baseline-skip between the inner and outer
\columns:
[...]
The math above is that two lines at baseline-skip of three plus an extra
staff space means an effective baseline-skip of seven.

Thank you very much for the explanation!  Maybe it would make sense to
adjust the manual at
<https://lilypond.org/doc/v2.22/Documentation/notation/stanzas>
accordingly.  I was very surprised that a recommended practice did not
work ‘beautifully’.



Secondly, the stanza commands seem to call for defining a two-argument
macro like \columnstanza, but I got lost in the documentation on the
different ways and the different types of objects.

Perhaps something like this:

[...]

Indeed, thank you again!  I modified this a little bit to do the
adjustment calculation, see below.  Given the ease of Kieren's solution,
this is possibly just interesting for getting started with the
programming and for understanding the object types.  Ideally, I would
like to arrive at something like

(let ((line-count (sum (length stanzas))))
     ...)

or some calculation of the ‘real’ height of the internal column, just to
get rid of superflous parameters. However, I do not know how to do look
into the stanzas (I tried using braces within braces for the argument,
but that is not accessible the way I thought).  One should probably also
do the numbering automatically.  (That's much less involved, but I would
assume it also involves something like recursing on the list of stanzas.)


Improved version using Kieren's strut and the suggested stanza commands.
   I suppose it still shows I don't understand the system well; I would
be grateful for suggestions on how to make this a little more elegant.

(Sorry, this should have been cleanedup.  But now I will stop spamming.)

#(set-default-paper-size "a6")
melody = \relative {
  c'4 c c c | d d d d
}

text = \lyricmode {
  \set stanza = "1." This is verse one.
  It has two lines.
}

\score{ <<
  \new Voice = "one" { \melody }
  \new Lyrics \lyricsto "one" \text

        \layout { }
      }


#(define-markup-command
  (strut-line layout props line)
  (markup?)
  (interpret-markup layout props #{
    \markup{
      \combine #line \transparent "Ij"
    }
  #}))

#(define-markup-command
   (stanza-list layout props stanzas)
   (markup-list?)
     (interpret-markup layout props #{
     \markup
     \column {
       #stanzas
     }
    #}))

#(define-markup-list-command
  (apply-very-last-strut layout props stanza-lines)
  (markup-list?)
  (letrec ((apply-last-strut
            (lambda (stanza-lines)
             (if (null? stanza-lines)
              stanza-lines
              (if (> (length stanza-lines) 1)
               (cons (interpret-markup layout props #{
                      \markup {#(car stanza-lines)}
                #})
               (apply-last-strut (cdr stanza-lines)))
   (interpret-markup-list layout props #{
     \markuplist {
       \strut-line #stanza-lines
     }
    #}))))))
    (apply-last-strut stanza-lines)))

#(define-markup-command
  (my-stanza layout props number lines)
  (markup? markup-list?)
  #:properties ((extra-space 1))
  (interpret-markup layout props #{
   \markup {
     \combine \null \vspace #extra-space \line {
       \bold #number
       \column {
         \apply-very-last-strut #lines
       }
     }
   }
  #}))

\markup {
  \fill-line {
    \hspace #1
    \stanza-list {
      \my-stanza "2." {
        "q This is verse two."
        "q It has two lines."
      }
      \my-stanza "3." {
        "q This is verse three."
        "q It has two lines."
      }
    }
    \hspace #1
    \stanza-list {
      \my-stanza "4." {
        "This is verse four."
        "It has two lines."
      }
      \my-stanza "5." {
        "This is verse five."
        "It has two lines."
      }
    }
    \hspace #1
  }
}



Again, grateful for pointers,
Best regards,
     Bernhard






reply via email to

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