Nice work, Harm!
- Abraham
On Wed, Feb 3, 2016 at 3:43 PM, Thomas Morley-2 [via Lilypond] <
ml-node+s1069038n186821...@n5.nabble.com> wrote:
> 2016-02-03 19:40 GMT+01:00 Simon Albrecht <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=186821&i=0>>:
>
> > On 03.02.2016 19:24, Jonathan Scholbach wrote:
> >>
> >> I want to create a template for a cover page. I do that by redefining
> >> bookTitleMarkup. The title of the piece is stored as string in a
> variable
> >
> >
> > If there’s no particular need for that, I’d use a normal header block
> and
> > \fromproperty.
> >
> >> and I want to print it relatively tall on the cover page. It works.
> >> But sadly when the title is too long it runs off the page, because
> >> LilyPond does not automatically break the line. How can I get LilyPond
> to
> >> break the line automatically when the title runs off page?
> >
> >
> > Try this:
> >
> > %%%%%%%%%%%%%%
> > \version "2.19.22"
> >
> > \paper {
> > bookTitleMarkup = \markup {
> > \fontsize #15 \wordwrap-field #'header:title
> > }
> > }
> >
> > \book {
> > \header {
> > title = "Many many words may result in a title that is too long for
> one
> > line"
> > }
> > \relative c' { c d e f }
> > }
> > %%%%%%%%%%%%%%%
> >
> > I don’t know how to center-align the wrapped lines, though… Anyone?
> >
> > Best, Simon
>
>
>
> /wordwrap-field puts out a single stencil. You can't align the lines
> you see after the stencil is created. At least you wouldn't want ...
> ;)
>
> How about below, description should make clear what's happening
> (hopefully).
>
> #(define-markup-command (my-wordwrap-field layout props align symbol)
> (number? symbol?)
> #:properties ((baseline-skip))
> #:category align
> "Same as @code{wordwrap-field}, but internally a stencil-list is
> produced
> first, which will aligned according to @var{align}, putting out a single
> stencil."
>
> ;; c/p from define-markup-commands.scm, because it's not public
> (define (general-column align-dir baseline mols)
> "Stack @var{mols} vertically, aligned to @var{align-dir}
> horizontally."
> (let* ((aligned-mols
> (map (lambda (x) (ly:stencil-aligned-to x X align-dir))
> mols))
> (stacked-stencil (stack-lines -1 0.0 baseline aligned-mols))
> (stacked-extent (ly:stencil-extent stacked-stencil X)))
> (ly:stencil-translate-axis stacked-stencil (- (car stacked-extent))
> X)))
>
> (let* ((m (chain-assoc-get symbol props)))
> (if (string? m)
> (general-column
> align
> baseline-skip
> (wordwrap-string-internal-markup-list layout props #f m))
> empty-stencil)))
>
>
> \paper {
> bookTitleMarkup = \markup \fill-line {
> \fontsize #15 \my-wordwrap-field #CENTER #'header:title
> }
> }
>
> \header {
> title = "Many many words may result in a title that is too long for one
> line"
> }
> \relative c' { c d e f }
>
>
> HTH,
> Harm
>
> _______________________________________________
> lilypond-user mailing list
> [hidden email] <http:///user/SendEmail.jtp?type=node&node=186821&i=1>
> https://lists.gnu.org/mailman/listinfo/lilypond-user
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://lilypond.1069038.n5.nabble.com/automatic-line-breaking-in-markup-tp186810p186821.html
> To start a new topic under User, email ml-node+s1069038n...@n5.nabble.com
> To unsubscribe from Lilypond, click here
> <http://lilypond.1069038.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=2&code=dGlzaW1zdC5saWx5cG9uZEBnbWFpbC5jb218Mnw4MzU3Njg3MDU=>
> .
> NAML
> <http://lilypond.1069038.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
View this message in context:
http://lilypond.1069038.n5.nabble.com/automatic-line-breaking-in-markup-tp186810p186824.html
Sent from the User mailing list archive at Nabble.com.
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user