fix to text width calculation

now considers new lines to match rendering
This commit is contained in:
Luis Camacho
2022-04-08 15:53:34 +01:00
parent 3857e2051c
commit 5e2b9fb629

View File

@@ -362,7 +362,9 @@ export function measureAndCacheTextWidth(font, text, cache) {
if (text in cache) {
return cache[text];
}
const width = measureTextWidth(font, text);
const width = text
.split('\n')
.reduce((prev, curr) => Math.max(prev, measureTextWidth(font, curr)), 0);
cache[text] = width;
return width;
}