-
Notifications
You must be signed in to change notification settings - Fork 500
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
Vertically centered table rows are not actually vertically centered #1964
Comments
Getting text to vertically align center in Prawn is nearly impossible. That's because every font has a built-in line height, and how that information is reported varies from font to font. If we get it working for one font, then it's off for a different font. I have spent many, many hours trying to make it work consistently, and I just can't do it. So I regret to information you that this is just the way it is. It will never be perfect. |
To clarify, I have already fixed the middle alignment in the main branch (see 285f857). However, I couldn't fix the bottom alignment, which ends up matching the middle alignment. But it's at least better than the screenshot you posted. Unless someone can show me a better way to do it, I'm closing this issue as I have no plans to work on it any further. |
Thanks for the quick response! I don't know a lot about font rendering, but I took a stab at a fix in prawn-table, just by re-using their cheeky move-before-rendering alignment code. Here's the PR. I move up for Top, don't move at all for Center, and move down for Bottom. Do you see this breaking things for other fonts, given I'm using the same variables ( |
That may work for the built-in fonts, but it's the TTF fonts where things get tricky (like NotoSerif). They are the ones that have a built-in line height. That's further complicated by the fact that Asciidoctor PDF itself supports a line height that has to be taken into consideration. The fix in Prawn itself will not be enough to fix the alignment universally in Asciidoctor PDF. You are welcome to try to make the fix in Asciidoctor PDF, and I will review it. But I won't be investing any time in it myself. |
Thanks again for the time. I ran a test on 310 Windows TTF fonts, and my change seems to fix most TTF fonts. In cases where it doesn't help, things aren't any worse than the existing behavior, they just don't get much better. Hope to see this merged upstream so users can at least get some expected behavior for majority of cases, vs current behavior of being broken everywhere for even the builtin fonts. If the Prawn fix doesn't help Asciidoctor, can I suggest adding a note |
You're welcome to submit a docs or code fix to Asciidoctor PDF, and I will review. As I said, I'm not going to initiate the effort to address this issue because I am already overstretched. But I will take the time to review an effort that is being driven by a community member. |
Using the default theme, the following Asciidoc generates the table seen in the screenshot below. Vertical-alignment seems to be off? I'm not a Ruby guy and can't figure this codebase out enough to fix, but I think this might be a good starting point? First added along with tests in this commit.
The text was updated successfully, but these errors were encountered: