fix to text width calculation
now considers new lines to match rendering
This commit is contained in:
@@ -362,7 +362,9 @@ export function measureAndCacheTextWidth(font, text, cache) {
|
|||||||
if (text in cache) {
|
if (text in cache) {
|
||||||
return cache[text];
|
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;
|
cache[text] = width;
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user