lilypond-user
[Top][All Lists]
Advanced

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

Re: Bottom-right-aligned, multi-line paragraphs within headings


From: Thomas Morley
Subject: Re: Bottom-right-aligned, multi-line paragraphs within headings
Date: Thu, 10 Jun 2021 00:24:52 +0200

Am Di., 8. Juni 2021 um 19:07 Uhr schrieb Lukas-Fabian Moser <lfm@gmx.de>:
>
> Hi Brent,
>
> > This is marvellous, thank you! Just one question: if I wanted to
> > remove the preceding zeros from the number, how would I do that?
>
> Just omit the (not very elegant) code that I added in order to add the
> preceding zeros. :-)
>
> To wit, replace
>
>            (markup (format #f
>                            (string-append "~" (number->string digits)
> ",'0d")
>                            n)))
>
> by
>
>            (number->string n))
>
> I attach a complete version.
>
> One problem with my code is the fine-tuning of the bottom-alignment of
> the various \markup's: If you look closely, you see that LilyPond
> doesn't use the baselines of the text lines, but the actual lowest point
> of the markups: The lowest point of "Gottes Sohn ist kommen" (no
> descenders) are aligned to the lowest point of the 'g' in 'long'. Not
> ideal, but I don't know how to improve this.
>
> Lukas
>

Hi Lukas,

some remarks:
You refer to my very first LSR snippet
https://lsr.di.unimi.it/LSR/Item?id=765
originally coded with 2.14. (or was it even 2.12.?, don't remember exactly ...)

There I c/p-ed general-column from define-markup-commands.scm, because
it is not public.
For wordwrap-right you obviously had copied (and renamed) the original
textRight (with a hardcoded baseline-skip).

Nowadays I'd rather use general-column from a more recent version. The
LSR-snippet was already improved to have baseline-skip adjustable.


That said...
The problem of not base-aligned texts persist, because general-align
aligns the whole markup, not respecting baselines.
Thus I took a different approach.
Remember, dir-column _respects_ baselines. Following this idea means:
- create a list of line-stencils
- right-align them
- stack them up(!) in reverse order
And after deleting \general-align #Y #DOWN from scoreTitleMarkup we're done.

Leading to:
#(define-markup-command (column-right-up layout props args) (markup-list?)
  #:properties ((baseline-skip))
  (let* ((lines (wordwrap-internal-markup-list layout props #f args))
         (right-aligned-lines
           (map (lambda (stil) (ly:stencil-aligned-to stil X RIGHT)) lines)))
    (stack-lines
      UP
      0.0
      baseline-skip
      (reverse right-aligned-lines))))

#(define-markup-command (number-fromproperty layout props digits symbol)
   (index? symbol?)
   (let ((n (chain-assoc-get symbol props)))
     (if (index? n)
         (interpret-markup
          layout props
          (markup (format #f
                          (string-append "~" (number->string digits) ",'0d")
                          n)))
         empty-stencil)))

#(define-markup-command (wordwrap-right-field layout props symbol)
   (symbol?)
   (let* ((m (chain-assoc-get symbol props)))
     (if (markup-list? m)
         (column-right-up-markup layout props m)
         empty-stencil)))

\paper {
  scoreTitleMarkup = \markup
  \overlay {
  %% Only to demonstrate aligning to baseline, delete me!
  \translate #'(0 . -0.1) \draw-hline
    \fill-line {
      \line {
        \fontsize #7 \number-fromproperty #3 #'header:piece-nr
        \hspace #1
        \normal-text \large \fromproperty #'header:piece-title
      }
      \italic \small
      %% probably:
      \override #'(baseline-skip . 2.5)
      \override #'(line-width . 50)
      \wordwrap-right-field #'header:infotext
    }
  }
}

\paper {
  indent = 0
}

\score {
  \header {
    piece-nr = 0
    piece-title = "Gottes Sohn ist kommen"
    infotext = \markuplist {
      This paragraph is in two or more rows, and the last line needs
      to be level with the bit on the left. It really can be as long
      as you want.
    }
  }
  \relative c' { c1 c e f g a g }
}


\score {
  \header {
    piece-nr = 1
    piece-title = "Another piece"
    infotext = \markuplist {
      This paragraph is in two or more rows, and the last line needs
      to be level with the bit on the left. It really can be as long
      as you want. Bla bla text, bla bla text? Really important bla
bla text, bla bla text.
    }
  }
  \relative g' { g2 f e c d b c1 }
}

The draw-hline is only there to visualize baselines, should be deleted ...

Best,
  Harm



reply via email to

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