lilypond-user
[Top][All Lists]
Advanced

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

Re: Purity advice - long wrapped texts


From: Saul Tobin
Subject: Re: Purity advice - long wrapped texts
Date: Wed, 25 Dec 2024 23:34:03 -0500

I haven't had time to play with your code but I notice that you're using grob::always-vertical-skylines-from-stencil. That really should only be used for grobs that can calculate their stencil without knowing line breaks. Instead use grob::unpure-vertical-skylines-from-stencil, which you can find in output-lib.scm. Incidentally you could also use grob::unpure-Y-extent-from-stencil and save yourself a few lines of code. If the extra vertical space you're noticing is on systems where the grob is printed, fixing 
the skyline estimate may help.

The main issue with pure positioning in the approach you're using is that these markups are quite tall but you need to allocate space for them even on systems where they will not be printed. One approach could be to simply divide the pure height estimate by the number of broken spanner segments you expect, so even if the first system is estimated a bit too short and the others are estimated too tall, at least the total allocated space is about right. That said, IMO it would be better if instead of killing parts of the spanner, you just make this grob an item, and write an after-line-breaking callback that finds the horizontal distance from the grob's anchor to the right edge of the system or to the closest column to the right that has as an element another instruction text grob. All the information you need is available after translation by traversing grob object properties. You'd still need a pure height estimate, but pure positioning would only allocate space for the system containing the anchor column for the grob, so the pure estimation you're using now would be pretty close.

Saul

On Mon, Dec 23, 2024 at 9:48 AM Mark Knoop <mark@opus11.net> wrote:
Hi list,

I'm looking for some advice from scheme experts with regard to writing pure functions. I've written a Grob and engraver (attached) for the purpose of setting long text instructions which should be wrapped over a section of music. Obviously the height of the resulting stencil will vary depending on the ultimate width of the spanner.

Thus I've added an unpure-pure container for the Y-extent callback. This is basically working, but any advice on how to improve the pure estimate would be greatly appreciated.

For now I'm simply using the difference of the paper-column ranks to give an indication of the horizontal length. This tends to estimate a larger height than is required (which is better than too small), but leads to some wasted vertical space.

Thanks,

Mark

--
Mark Knoop

reply via email to

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