html2canvas icon indicating copy to clipboard operation
html2canvas copied to clipboard

Update canvas-renderer.ts to fix Vertical alignment issues with text

Open haztheo opened this issue 2 years ago • 7 comments

  • Bug 1 Fixes vertical alignment of text within divs - issue shown here: https://github.com/niklasvh/html2canvas/issues/2937

  • Now the fillText usage logically makes sense

  • Tested across Chrome, Firefox, Safari

Before: 1660838787558

After: 1660838848709

haztheo avatar Aug 18 '22 16:08 haztheo

Can we merge it?

eugeneZolotarenko avatar Jul 24 '23 13:07 eugeneZolotarenko

Hey, this was approved for close to a year now? Can we merge it?

JoaquimLey avatar Aug 29 '23 22:08 JoaquimLey

Can be tested in @cantoo/html2canvas

Sharcoux avatar Aug 31 '23 02:08 Sharcoux

I tried this out and for me the text got justified too much.

Latest release:

With this patch:

This patch, but after applying this suggestion https://github.com/niklasvh/html2canvas/pull/2938/files#r972962898

caendesilva avatar Feb 03 '24 19:02 caendesilva

I have done a little more research into this, and it seems that the calculation is using the incorrect parameters. The baseline should actually be the font size in px. Will make a new PR.

acurrieclark avatar Feb 14 '24 09:02 acurrieclark

Ah, damn. @acurrieclark do you mind pushing your fix to this project too: https://github.com/cantoo-scribe/html2canvas ? This one seems a bit abandoned and I tried to merge the most promising PRs inside it

Sharcoux avatar Feb 14 '24 10:02 Sharcoux

@Sharcoux in case you didn't see, I raised this as an issue on your fork. There are a couple of possible solutions to the problem. I have found one which fixes things on my end, but it may not be the most general solution.

acurrieclark avatar Feb 21 '24 07:02 acurrieclark