mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Make font use actual canvas height
This commit is contained in:
@@ -38,7 +38,8 @@ module.exports = class FontCommand extends Command {
|
||||
ctxPre.font = this.client.fonts.get(font.filename).toCanvasString(50);
|
||||
const len = ctxPre.measureText(text);
|
||||
const lines = wrapText(ctxPre, text, 950);
|
||||
const canvas = createCanvas(Math.min(len.width + 50, 1000), 50 + (50 * lines.length) + (20 * lines.length));
|
||||
const height = len.actualBoundingBoxAscent + len.actualBoundingBoxDescent;
|
||||
const canvas = createCanvas(Math.min(len.width + 50, 1000), 50 + height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.font = this.client.fonts.get(font.filename).toCanvasString(50);
|
||||
ctx.textBaseline = 'top';
|
||||
|
||||
Reference in New Issue
Block a user