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 initial property values are not applied #3319

Open
HackbrettXXX opened this issue Nov 16, 2021 · 0 comments
Open

context2d initial property values are not applied #3319

HackbrettXXX opened this issue Nov 16, 2021 · 0 comments

Comments

@HackbrettXXX
Copy link
Collaborator

Example borrowed from #2701:

var doc = new jsPDF()
var ctx = doc.context2d
ctx.strokeText(`font: ${ctx.font}, line: ${ctx.lineWidth}`, 10, 10)
ctx.font = ctx.font // font size is changed(16px → 10px)
ctx.strokeText(`font: ${ctx.font}, line: ${ctx.lineWidth}`, 10, 20)
ctx.lineWidth = ctx.lineWidth // line width is changed(0.2px → 1px)
ctx.strokeText(`font: ${ctx.font}, line: ${ctx.lineWidth}`, 10, 30)

The same thing happens after manually switching or creating pages with addPage or setPage.

A correct solution would probably check if the current document state is the same as the context2d state and if not would apply the properties that are different before executing a command like fill, fillText, stroke, etc.

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

No branches or pull requests

1 participant