Skip to content
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

context2d: Fix default font behavior. #3316

Closed
wants to merge 1 commit into from

Conversation

tfaller
Copy link

@tfaller tfaller commented Nov 14, 2021

Hello,

I've encountered an inconsistency of context2d text rendering.
Previous, if you used contex2d to "fillText" (with default font) on the first page, the current jsPDF font (and size) was used (not the context2d font). However, if you then "fillText" on the next page, suddenly the context2d font will be used. So you end up with text rendered in different fonts.

I propose with this PR that if you access the context2d for the first time, that we force apply the context2d font as the current jsPDF font. This makes rendering text consistent.

Of course, if someone changes the jsPDF font in the meantime, the problem is back. But I think this is a complete other topic. And a mix between two rendering methods are probably not that common.

Regards
Thomas

@HackbrettXXX
Copy link
Collaborator

Thanks for the PR. The same thing happens for all the other properties like fillStyle, etc.

Since the workaround is pretty simple (just assign the properties yourself), I would prefer a proper fix instead of a hotfix like this, especially since this hotfix might break existing code. I've created an issue to track this: #3319. For this reason I'm closing this PR for now.

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.

2 participants