-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
Floats need improvement, esp in drop cap use case #394
Labels
enhancement
Software improvement or feature request
Comments
@khaledhosny In the last image above just where I cropped it off there are still some descenders visible from the previous line. Do any of those squiggles ring a bell? |
Closed
This was referenced Sep 9, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Intro
I've had a couple books that use drop-caps at the start of chapters or sections. So far I've hacked around it a couple ways to get the projects out the door, but the result has been brittle and it seems like some functionality is missing.
Finding the right place to even apply drop-cap code
Right out of the gate, figuring out when to apply such a style and getting the right content or letter wrapped is hard. This isn't something I want encoded in my documents which are in Markdown and get converted to other formats as well. I need to do it automatically.
One way has been to overload the
chapter()
or similar command to trigger the style of the next content to come along. In the case of a drop cap letter I'm doing something like this:This hijacks the typesetter the text time it is asked to output something, strips off the first character, sends it to the dropcap function, then goes on with the rest.
This works but it feels dirty and shouldn't be something SILE users should be required to come up with. If it is the right way of doing this let me know and I'll work it up and submit it as a package. If it's the wrong way to go about this I'd love to hear it.
The other way I've tackled this is when something decorative is being placed in leu of a drop-cap. In this case I've hijacked the typesetter functions a little differently:
In this case I'm setting a scratch variable after the appropriate section headings and hijacking the function that pushes unshaped horizontal stuff on the queue to add stuff my own content in there the first time it tries to spit out a line. This doesn't seem quite as dirty as the input filter thing, but still requires a lot of knowledge about the core typesetter to pull off.
It seems like there should be some more general way to munge the document itself after it has been parsed during typesetting to pull this sort of thing off.
The actual drop-cap code
Even after a function is running at the right place, actually typesetting a drop cap is not as easy as the manual makes it sound. My simplest invocation is something like this:
Sample output:
This looks nice enough, but it's deceptively tricky to use because the metrics don't stay put. There is no generalize way to make the dropcap line up with anything. Even after you tailor the metrics to match the font size of the document, how many lines you want it to span, and what the padding should be, it breaks if you fiddle with the document. Any change in the leading or font metrics bork the alignment. The worst is the frame bottom boundary because it determines the leading between the lines next to and below the drop cap. The document leading calculations are not respected and that line may end up with more or less space that it would normally have had. This can even vary from chapter to chapter depending on ascender/descender status. I ended up using a fixed line-spacing for one project just because the drop caps were too unpredictable otherwise.
Somehow the frame logic in
float()
needs to match the leading that would have otherwise been there without the frame.Secondarily I've played around with another way of injecting drop caps. This one is dirty and I know it but it was interesting as a proof of concept. It only works on a lark in about 80% of cases, but depending on how many passes the line-breaking algorithm makes it can also get out of whack. The nice thing is that because it doesn't mess with frames the leading never gets off, just the rskip.
You've been warned:
Yes that makes off with the settings
get()
function and makes it return different values depending on how many times it's been called recently.Sample output:
When the output eats crow:
Related problems
Incidentally this last use case is similar to my problem in #318 that I hacked around yet another way. The major difference there was that line breaks were known entities and there was no flowing that needed to happen. Hence I could work up a paragraph based solution.
Conclusion
That's now 3 ways I've hacked around a similar problem with about half a dozen variants of one of them. I wouldn't wish this on any future users for doing something as simple as typesetting clean drop-caps.
What should we do?
The text was updated successfully, but these errors were encountered: