lilypond-user
[Top][All Lists]
Advanced

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

Re: Right aligned text in header


From: Thomas Morley
Subject: Re: Right aligned text in header
Date: Tue, 13 Mar 2018 22:02:46 +0100

2018-03-13 20:31 GMT+01:00 Br. Samuel Springuel <address@hidden>:
> I'm creating a custom bookTitleMarkup for a project I'm working on and have
> some lines which are setup like `meter` and `arranger` in the default
> template (two blocks of text, one flushed left the other right, on the same
> line).
>
> However, on one of those lines the header properties to be used may be very
> long and thus I need to force word wrapping to less than the full line width
> for each field.  On the left side, that is not a problem, I just use
> `\override #'(line-width . 30) \wordwrap-field`.  However, on the right side
> this doesn't work because the wrapping of the text within the field is left
> aligned inside its box (which is right aligned on the line).  What I'd like
> is for the wrapped text to be right aligned inside its box.  I tried
> changing `text-direction` to -1, and this did change the alignment, but also
> reversed the word order on each line.
>
> Is there an equivalent for `\wordwrap-field` that will flush right the text
> (much like `\justify-field` leads to it being justified)?
>
> %%% Begin Snippet %%%
> \paper  {
> % custom title layout
>     bookTitleMarkup = \markup { \column {
>         \fill-line { \fromproperty #'header:title }
>         \fill-line {
>             \fromproperty #'header:meter
>             \fromproperty #'header:tune
>         }
>         \fill-line {
>             \fromproperty #'header:poet
>             \fromproperty #'header:composer
>         }
>         \fill-line {
>             { \override #'(line-width . 30) \wordwrap-field
> #'header:poet_copyright }
>             { \override #'(line-width . 30) \wordwrap-field
> #'header:tune_copyright }
>         }
>     }}
>     scoreTitleMarkup = {}
> }
>
> \header {
>     title = "Title of song (from lyrics)"
>     meter = "8.8.8.8"
>     tune = "name of tune"
>     poet = "Poet"
>     composer = "Composer"
>     poet_copyright = "A sometimes long statement indicating at least the
> year of the copyright.  Should be flushed left."
>     tune_copyright = "Also may be long and in need of wrapping.  Should be
> flushed right."
> }
>
> \new Staff
> {
>   \new Voice = "mel" { c' }
> }
>
> %%% End Snippet %%



Hi,

do you mean like below?
Based on
http://lsr.di.unimi.it/LSR/Item?u=1&id=765

#(define (general-column align-dir baseline mols)
  (let* ((aligned-mols
           (map (lambda (x) (ly:stencil-aligned-to x X align-dir)) mols)))
    (stack-lines -1 0.0 baseline aligned-mols)))

#(define-markup-command (my-wordwrap-field layout props symbol)
  (symbol?)
  #:category align
  #:properties ((baseline-skip)
                (align-dir LEFT))
  (let* ((m (chain-assoc-get symbol props)))
    (if (string? m)
        (general-column align-dir baseline-skip
          (wordwrap-string-internal-markup-list layout props #f m))
        empty-stencil)))


\paper  {
% custom title layout
    bookTitleMarkup = \markup { \column {
        \fill-line { \fromproperty #'header:title }
        \fill-line {
            \fromproperty #'header:meter
            \fromproperty #'header:tune
        }
        \fill-line {
            \fromproperty #'header:poet
            \fromproperty #'header:composer
        }
        \fill-line {
            {
              \override #'(line-width . 30)
              \wordwrap-field #'header:poet_copyright
            }
            {
              \override #'(line-width . 30)
              \override #'(align-dir . 1)
              \my-wordwrap-field #'header:tune_copyright
            }
        }
    }}
    scoreTitleMarkup = {}
}

\header {
    title = "Title of song (from lyrics)"
    meter = "8.8.8.8"
    tune = "name of tune"
    poet = "Poet"
    composer = "Composer"
    poet_copyright = "A sometimes long statement indicating at least the year
of the copyright.  Should be flushed left."
    tune_copyright = "Also may be long and in need of wrapping.
Should be flushed right."
}

\new Staff
{
  \new Voice = "mel" { c' }
}


Cheers,
  Harm



reply via email to

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