Skip to content

Vertical text alignment fix#3151

Open
acurrieclark wants to merge 3 commits into
niklasvh:masterfrom
acurrieclark:only-change-text
Open

Vertical text alignment fix#3151
acurrieclark wants to merge 3 commits into
niklasvh:masterfrom
acurrieclark:only-change-text

Conversation

@acurrieclark
Copy link
Copy Markdown

An attempt has previously been made to fix this in #2938, but I don't think it worked as intended.

This fix has been working well for me an I hope it can help others.

@yorickshan
Copy link
Copy Markdown

thx for your pr, this fix has been merged to html2canvas-pro

@matortheeternal
Copy link
Copy Markdown

@yorickshan This change broke font rendering by html2canvas-pro when using a non-default line height.

Specifically: fontSize is not the pixel offset of the baseline of text when lineHeight is not = to the browser default of 1.175.

I have not verified that the old baseline returned by getFontMetrics returns the correct value, but I believe it is more logically correct than simply assuming fontSize is the distance from the top of the rect to the baseline, and a simple test can show this. Simply set line-height: 1 and you will observe a 17.5% difference in the position of text when comparing the browser to the canvas produced by html2canvas-pro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants