Am So., 15. Juni 2025 um 21:34 Uhr schrieb Valentin Petzel <[email protected]>:
>
> Hi RipMus,
>
> > Would it be possible to right-align the subtitle text, broken into two
> > lines, so that the second line (the one ending with 2025) is aligned to the
> > right margin?
>
> Yes, by modifying the `\justify-string` command to allow for justification:
>
> %%%
> %%%
> \version "2.24.4"
>
> #(define-markup-command (justify-string-aligned layout props align arg)
>   (ly:dir? string?)
>   #:category align
>   #:properties ((baseline-skip)
>                 wordwrap-string-internal-markup-list)
>   (stack-lines DOWN 0.0 baseline-skip
>                (map
>                 (lambda (stc)
>                   (ly:stencil-aligned-to stc X align))
>                 (wordwrap-string-internal-markup-list layout props #t arg))))
>
> #(define composer "Foo")
> #(define title "TITLE")
> #(define subtitle "a subtitle with a lot, a lot of stuff, much longer than
> this one, which breaks into at least two lines, creating a problem to be
> solved.")
> #(define cyear "2025")
>
> \markup \column {
>   \fill-line { \abs-fontsize #24 #composer " " }
>   \vspace #1
>   \fill-line { \general-align #Y #-1 \abs-fontsize #36 #title
> \general-align #Y #-1 \abs-fontsize #8 \override #'(line-width . 60)
> \justify-string-aligned #RIGHT #(string-join (list subtitle " (" cyear ")")
> "") }
> }
> %%%
>
> Cheers,
> Tina

`wordwrap-string-internal` is one of only three markup-(list)-commands
flagged "internal" and thus not documented, but it _is_ a full blown,
ready-to-use command.
So one could do:

#(define composer "Foo")
#(define title "TITLE")
#(define subtitle
  "a subtitle with a lot, a lot of stuff, much longer than this one, which
   breaks into at least two lines, creating a problem to be solved.")
#(define cyear "2025")

\markup \column {
  \fill-line { \abs-fontsize #24 #composer " " }
  \vspace #1
  \fill-line \general-align #Y #-1 {
      \abs-fontsize #36
      #title
      \abs-fontsize #8
      \override #'(line-width . 60)
      \right-column
      \wordwrap-string-internal ##t #(format #f "~a (~a)" subtitle cyear)
  }
}

Cheers,
  Harm

Reply via email to