mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Fix
This commit is contained in:
+6
-1
@@ -221,7 +221,8 @@ module.exports = class CanvasUtil {
|
||||
const word = words[j];
|
||||
if (ctx.measureText(`${currentLine} ${word}`).width <= maxWidth) {
|
||||
currentLine += `${currentLine === '' ? '' : ' '}${word}`;
|
||||
} else if (ctx.measureText(word).width > maxWidth && shouldChunk) {
|
||||
} else if (ctx.measureText(word).width > maxWidth) {
|
||||
if (shouldChunk) {
|
||||
const chunks = [];
|
||||
let currentChunk = '';
|
||||
for (let k = 0; k < word.length; k++) {
|
||||
@@ -243,6 +244,10 @@ module.exports = class CanvasUtil {
|
||||
}
|
||||
currentLine += `${currentLine === '' ? '' : ' '}${chunks[k]}`;
|
||||
}
|
||||
} else {
|
||||
if (currentLine !== '') lines.push(currentLine.trim());
|
||||
currentLine = word;
|
||||
}
|
||||
} else {
|
||||
lines.push(currentLine.trim());
|
||||
currentLine = word;
|
||||
|
||||
Reference in New Issue
Block a user