Skip to content

Remove canvas style attribute update when changing font weight#8733

Open
davepagurek wants to merge 1 commit intodev-2.0from
variable-font-perf
Open

Remove canvas style attribute update when changing font weight#8733
davepagurek wants to merge 1 commit intodev-2.0from
variable-font-perf

Conversation

@davepagurek
Copy link
Copy Markdown
Contributor

Resolves #8732

Changes

Previously, in addition to changing ctx.font, we would set canvas.style['font-variation-settings'] to set the font weight. This used to be necessary to get all browsers to do variable font weight. However, this CSS update causes a relayout on the page each time you change it, which can be quite costly when doing it many times per frame.

That was set up in late 2024. Testing now, in 2026, it seems like neither Chrome nor Firefox has problems without this CSS update. We previously took it out for Safari, as it was actively messing up its rendering. It looks like now we can just take it out for everyone.

This now gets me 60fps on both Chrome and Safari.

Live: https://editor.p5js.org/davepagurek/sketches/JFCOpYLg9

PR Checklist

@p5-bot
Copy link
Copy Markdown

p5-bot bot commented Apr 19, 2026

Continuous Release

CDN link

Published Packages

Commit hash: 549b44a

Previous deployments

This is an automated message.

@davepagurek
Copy link
Copy Markdown
Contributor Author

@Qianqianye does work for you on your test sketch?

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.

1 participant