Hi Urs, some educated guessing (and hopefully another suggestion):
On 03/01/2018 11:11 PM, Urs Liska wrote:
Hi all,can anyone tell me *exactly* how the bounding box values are generated and especially rounded in LilyPond? What are they exactly referring to, the content *with* or *without* a border (of the bounding box)?[...] Does the -80 mean: * any value between -79 and -80 * any value between -79.5 and -80.4999999 * or is it even an *outer* box? I mean, the "1" as the Y value of the upper right corner looks suspiciously like "exclusive" value, doesn't it?
Without knowing the code that generates these numbers:I'd assume it *should* mean the first (any value between -79 and -80), that is, the rounding is on the conservative side.
(Precise) bounding box evaluation is highly non-trivial as soon as curves are involved - you need to determine the x- and y-extrema of any such curve. IIUC, GhostScript "simply" renders the page with some resolution to determine the bounding box. To get 1bp-accuracy, use 72ppi, ignore coloring, "just" remember the page area where something has been drawn; then compute an axis-aligned bbox for all those values. To get higher accuracy (see below), the procedure is repeated with higher resolution (and, for efficiency's sake, only for those graphic elements that potentially contribute to the bounding box).
I *guess* that to decide on the layout, Lily has to do something similar, and it flushes those bbox values to the EPS.
I'd be glad about any concrete information or other suggestions.
Both slightly more concrete and another suggestion: wouldn't you be better off with using the high-resolution bounding box determined by GS from an actual rendering of the page? E.g.,
gs -sDEVICE=bbox -q -dBATCH -dNOPAUSE bbox.pdf gives %%BoundingBox: 0 0 480 136 %%HiResBoundingBox: 0.486000 0.432000 479.510774 135.017433for your attached file. These numbers are as accurate as they can reasonably expected to be: GS promises that the numbers are conservatively rounded and accurate to 1 unit in the last place. (Subject to theoretical limitations on Turing-complete page description languages, I guess...)
Note that AFAICS the EPS generated by Lilypond has a white background on the integer coordinates, so the values reported by GS will match the numbers in the file. But since you use LuaLaTeX apparently, I assume you include PDFs rather than EPSs, right? No need to work with both formats, then.
HTH and doesn't add a whole lot of confusion, Alex
Description: S/MIME Cryptographic Signature
_______________________________________________ lilypond-user mailing list firstname.lastname@example.org https://lists.gnu.org/mailman/listinfo/lilypond-user