mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 06:42:50 +02:00
Fix lint
This commit is contained in:
+23
-25
@@ -220,34 +220,32 @@ module.exports = class CanvasUtil {
|
|||||||
for (let j = 0; j < words.length; j++) {
|
for (let j = 0; j < words.length; j++) {
|
||||||
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 {
|
} else if (ctx.measureText(word).width > maxWidth) {
|
||||||
if (ctx.measureText(word).width > maxWidth) {
|
const chunks = [];
|
||||||
const chunks = [];
|
let currentChunk = '';
|
||||||
let currentChunk = '';
|
for (let k = 0; k < word.length; k++) {
|
||||||
for (let k = 0; k < word.length; k++) {
|
const char = word[k];
|
||||||
const char = word[k];
|
if (ctx.measureText(`${currentChunk}${char}`).width <= maxWidth) {
|
||||||
if (ctx.measureText(`${currentChunk}${char}`).width <= maxWidth) {
|
currentChunk += char;
|
||||||
currentChunk += char;
|
} else {
|
||||||
} else {
|
|
||||||
chunks.push(currentChunk);
|
|
||||||
currentChunk = char;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (currentChunk !== '') {
|
|
||||||
chunks.push(currentChunk);
|
chunks.push(currentChunk);
|
||||||
|
currentChunk = char;
|
||||||
}
|
}
|
||||||
for (let k = 0; k < chunks.length; k++) {
|
|
||||||
if (ctx.measureText(`${currentLine} ${chunks[k]}`).width > maxWidth) {
|
|
||||||
lines.push(currentLine.trim());
|
|
||||||
currentLine = '';
|
|
||||||
}
|
|
||||||
currentLine += `${currentLine === '' ? '' : ' '}${chunks[k]}`;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
lines.push(currentLine.trim());
|
|
||||||
currentLine = word;
|
|
||||||
}
|
}
|
||||||
|
if (currentChunk !== '') {
|
||||||
|
chunks.push(currentChunk);
|
||||||
|
}
|
||||||
|
for (let k = 0; k < chunks.length; k++) {
|
||||||
|
if (ctx.measureText(`${currentLine} ${chunks[k]}`).width > maxWidth) {
|
||||||
|
lines.push(currentLine.trim());
|
||||||
|
currentLine = '';
|
||||||
|
}
|
||||||
|
currentLine += `${currentLine === '' ? '' : ' '}${chunks[k]}`;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lines.push(currentLine.trim());
|
||||||
|
currentLine = word;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentLine !== '') {
|
if (currentLine !== '') {
|
||||||
|
|||||||
Reference in New Issue
Block a user