Skip to content

Commit 3d98a69

Browse files
authored
chore: faster font weight detection (#4211)
## Description Using willReadFrequently option makes it 3-5 times faster ## Steps for reproduction 1. click button 2. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 5de6) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file
1 parent 5a88b40 commit 3d98a69

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

apps/builder/app/canvas/shared/font-weight-support.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const testFontWeights = (fontFamily: string) => {
1818
const canvas = document.createElement("canvas");
1919
canvas.width = 200;
2020
canvas.height = 20;
21-
const context = canvas.getContext("2d");
21+
const context = canvas.getContext("2d", { willReadFrequently: true });
2222
const supportedWeights: Array<FontWeight> = ["400"];
2323

2424
if (context === null) {

0 commit comments

Comments
 (0)