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