-
-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(core): Implement paragraph shaping (parshape) #1264
Conversation
Fixed a failing test. Forgot we add other ways to break lines (notably the break-firstfit) that do not use the Knuth linebreaking. |
Still failing on Lua 5.1 and LuaJit on a simple comparison. Hmm I am at loss here, and don't have Lua 5.1 on this machine. |
Doh, fixed and rebased. Sorry for the noise. Something with |
Following #1268 I realize I should check what happens to headers/folios/footnotes when this shaping is active when the page break occurs (and the current solution for hangindent/hangafter fix in footnotes and folios should also probably be addressed, it's kind of ad hoc). Kind of minor (I don't think users would normally use the parshaping accross pages, but heh). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat feature, but I think the code needs work before it enters SILE core.
Also, was any thought given as to how this works in TTB mode?
Nope. I don't know how to check RTL, TTB, BTB with scripts I can't even read. The line-breaking algorithm is agnostic to the writing direction, so I would expect it to somehow work, but I have no real idea what it implies. |
5d32665
to
cb6a7a8
Compare
Thanks for the contribution, this sounds great. Sorry I had been traveling and haven't been very on top of reviews, but I'll get this checked out eventually. |
The example of the circle was really cool, but that's what I think it should be: an example. I'm going to move it to the example gallery and drastically simplify the test case to something where the numbers can be debugged easier by hand. Basically just enough to prove that the shape table is being used but not much more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to make these changes ... and probably will right now at least as a POC, but I'm open to feedback on the changes I'm proposing here.
I'm working on porting the circle example to something more suited to be adjustable and show off the caching, but my ideas for changing the parShape API are implemented above. Feedback welcome, I don't claim to have hit this nail on the head. |
Here is an example using the modified parshape API drawing a paragraph in a circle using a center point and radius:
|
The explicit cache cleaning sounds real weird. Also, the example could set the settings temporarily so that the default parshaping stops being called afterwards. |
Also this:
Could be done temporarily in "incircle". The example is not very useful otherwise - one would not want to have this globally in a normal use case. (If one does so, we'll get question why plenty of other things starts working weird - a non-stretchable baselineskip gives pretty awful results on pages with footnotes etc.) |
I grant the interface perhaps could use refining, but I couldn't think of any way to get the benefit of cached results but also allow the use of new shapes after the first one without some sort of cache flush mechanism. The
True, before that example actually hits the gallery issues like that should be addressed and it could be commented etc. I just needed a POC that was a little more like somebody might use it rather than the test file which did the minimal work possible to hit all the possible interfaces.
Of course.
Sure. The Lets keep this issue more about the API and whether the right things are exposed vs. handled. |
At the end of the loop in |
@ctrlcctrlv Yes. We're just twiddling standard parameters already used used "linewise" by the typesetter. The typesetter already handles flipping them around based on the writing and advance directions. |
These are the changes I made to the linebreak algorithm as mentioned in #1263
I am suggesting them for inclusion in the standard SILE. They are pretty limited, @simoncozens had already prepared all the way to them. They are a good basis to start playing with, I hope.
As for an actual package using this feature and computing things dynamically... Honestly, I am not sure my current colophon package should make it into the standard SILE now... I mean, it works quite nicely for my needs, but it is quite fragile with several wild assumptions. I don't plan something better for now, but I committed it to my own package repo - So you may look at the PDF in the "examples" folder (for the Woah! effect, I hope 😄 ) and to the actual documentation in the "docs" package (to see why and where it could be so fragile that it might be a mess to maintain in the official distribution), and make your own opinion. And beyond the inherent flaws of the approach, it's also fairly specialized (with "ornaments" I selected, etc.), and I might also add more shapes eventually (triangles/trapezes obviously come to mind), if I ever need them... at some uncertain point... But this just express my concerns and I am open for discussion.