Skip to content

Commit

Permalink
Removing canvas after being used
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenthoms committed Jan 12, 2024
1 parent 4b00986 commit 21b6c23
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions frontend/src/lib/utils/textSize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function calcAndStoreCharWidths(font: string) {
}
}
storedFontWidths.set(font, charWidths);
canvas.remove();
return charWidths;
}

Expand All @@ -35,6 +36,8 @@ export function getTextWidthWithFont(text: string, font: string, sizeInRem: numb
const charWidth = charWidths.get(char);
if (charWidth) {
width += charWidth * sizeInRem;
} else {
width += 1 * sizeInRem;
}
}
return width;
Expand Down

0 comments on commit 21b6c23

Please sign in to comment.