Merge pull request #12106 from IQGeo/issue-12101

improve text width calculation
This commit is contained in:
Andreas Hocevar
2022-06-08 15:39:29 +02:00
committed by GitHub
3 changed files with 61 additions and 1 deletions
+3 -1
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;
}