sile-typesetter / sile

The SILE Typesetter — Simon’s Improved Layout Engine
https://sile-typesetter.org
MIT License
1.63k stars 96 forks source link

Measurement error (floats on a grid layout) #826

Open alerque opened 4 years ago

alerque commented 4 years ago

From the mailing list:

when I try to create a floating frame for drop caps on a grid I receive the following error message:

...local/Cellar/sile/0.10.1/share/sile/core/measurement.lua:9: attempt to index a nil value (local 'a')

The resulting PDF file is also corrupted.

Here is an example file:

\begin[papersize=a5]{document}
\script[src=packages/lorem]
\script[src=packages/grid]
\script[src=packages/frametricks]
\makecolumns[columns=2]
\grid[spacing=15pt]

\float[rightboundary=5pt,bottomboundary=1ex]{\font[size=36pt]{A}}
\noindent \lorem[words=50]

\end{document} 

Am I missing something? I am very new to Sile.

alerque commented 4 years ago

I can fairly easily hack around this particular error, but the resulting output from your test is not what you are going to want. It quickly becomes apparent that \float and \grid do not play nice together. A proper fix for this issue will also involve fixing #533. I started messing with it and the root cause of your error is a race condition between when frames get initialized and when/which hooks run. The grid expects to be able to inject it's stuff in one place, but the floating frames thing is short circuiting that place.

The non-hacky fix for this is to fix the frame init hooks, which might actually go a long way towards fixing the other long standing bugs. However it's going to take a bit of messing around and testing. For now sadly I think the answer is that we just don't have drop-caps that play nicely with grid.

Omikhleia commented 6 months ago

Updated the title: drop caps now have a non-float based implementation, but the issue remains valid for general float usage.