mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-24 10:25:11 +02:00
Fix
This commit is contained in:
+8
-3
@@ -201,9 +201,14 @@ module.exports = class CanvasUtil {
|
|||||||
const lines = text.split('\n');
|
const lines = text.split('\n');
|
||||||
let currentY = y;
|
let currentY = y;
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
ctx.fillText(line, x, currentY, maxLen);
|
if (line === '') {
|
||||||
const metrics = ctx.measureText(line);
|
const metrics = ctx.measureText('a');
|
||||||
currentY += metrics.emHeightAscent + metrics.emHeightDescent;
|
currentY += metrics.emHeightAscent + metrics.emHeightDescent;
|
||||||
|
} else {
|
||||||
|
ctx.fillText(line, x, currentY, maxLen);
|
||||||
|
const metrics = ctx.measureText(line);
|
||||||
|
currentY += metrics.emHeightAscent + metrics.emHeightDescent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user