bug-lilypond
[Top][All Lists]
Advanced

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

Re: Page breaking fails for multiline embedded score


From: Boris Shingarov
Subject: Re: Page breaking fails for multiline embedded score
Date: Thu, 11 Feb 2010 23:50:25 -0500
User-agent: Webmail 5.0

Quoting Neil Puttock <address@hidden>:

If you do this, you'll have to change the \score command to a
markup-list command, since a markup command can only return a single
stencil.  This is problematic

Here is some proof-of-concept code. I am sure people will point out how it is inconsistent with existing Lilypond conventions, but at least it does fix the bug. Of course, it needs more work to become part of Lilypond.
In define-markup-commands.scm:

(define (paper-score-stencils ps)
  (map paper-system-stencil
    (vector->list (ly:paper-score-paper-systems ps))))

;(define (combine-score-stencils stencils)
;       (stack-stencils Y DOWN baseline-skip
;                       stencils))

(define (combine-score-stencils stencils)
  (reverse stencils))  ; FIXME, need some baseline-skip

(define-builtin-markup-command (score layout props score)
  (ly:score?)
  music
  ((baseline-skip))
  "... doc string omitted for brevity ..."
  (let ((output (ly:score-embedded-format score layout)))
    (if (ly:music-output? output)
        (combine-score-stencils (paper-score-stencils output))
        (begin
(ly:warning (_"no systems found in \\score markup, does it have a \\layout block?"))
          empty-stencil))))

This returns a list of separate stencils instead of one monolithic stencil. Now, append instead of cons if interpret-markup returned more than one stencil:

In markup.scm:

(define (prepend-stencil aStencil stencilList)
"Prepend aStencil to stencilList. Normally, aStencil is assumed to be a stencil;
   but it is also allowed to be a list of stencils."
  (if (ly:stencil? aStencil)
      (cons aStencil stencilList)
      (append aStencil stencilList)))

(define-public (interpret-markup-list layout props markup-list)
  (let ((stencils (list)))
    (for-each (lambda (m)
                (set! stencils
                      (if (markup-command-list? m)
                          (append! (reverse! (apply (car m) layout props (cdr 
m)))
                                   stencils)
                          (prepend-stencil (interpret-markup layout props m) 
stencils))))
              markup-list)
    (reverse! stencils)))

A drawback of this approach is that other, unrelated, commands need to be aware of this too:

(define-builtin-markup-command (vcenter layout props arg)
  (markup?)
  align
  ()
  "... doc string omitted for brevity ..."
  (define (center-align m) (ly:stencil-aligned-to m Y CENTER))
  (let* ((mol (interpret-markup layout props arg)))
    (if (ly:stencil? mol)
      (center-align mol)
      (map center-align mol)
  )))

There are two problems. First, object life scope. The modification causes this:

programming error: Parsed object should be dead: static scm_unused_struct* Grob::mark_smob(scm_unused_struct*)
continuing, cross fingers
programming error: Parsed object should be dead: static scm_unused_struct* Prob::mark_smob(scm_unused_struct*)
continuing, cross fingers
programming error: Parsed object should be dead: static scm_unused_struct* Context_def::mark_smob(scm_unused_struct*)
continuing, cross fingers

Not sure why. Second, I am not at all sure if my placement of "reverse!" is correct.
I don't think it's enough just to map the stencils: they still need
some degree of baseline-skip, otherwise they'll be stacked as close as
possible.  I think `space-lines' would be the most appropriate way to
keep them positioned nicely (using the existing default for
baseline-skip)

Of course, combine-score-stencils needs a real implementation, not just (reverse stencils). But unfortunately, I do not understand what you mean by space-lines. Could you explain in a little more detail?

Boris Shingarov
Work on Lilypond under grant from Sonus Paradisi / Jiri Zurek (Prague),
Czech Science Foundation, Project No. 401/09/0419





reply via email to

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