mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 06:42:50 +02:00
Swap all files to new font system
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage, registerFont } = require('canvas');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const path = require('path');
|
||||
const { wrapText } = require('../../util/Canvas');
|
||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Regular.ttf'), { family: 'Noto' });
|
||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-CJK.otf'), { family: 'Noto' });
|
||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Emoji.ttf'), { family: 'Noto' });
|
||||
|
||||
module.exports = class SonicSaysCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -50,11 +47,11 @@ module.exports = class SonicSaysCommand extends Command {
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.textBaseline = 'top';
|
||||
ctx.drawImage(base, 0, 0);
|
||||
ctx.font = '24px Noto';
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(24);
|
||||
let fontSize = 24;
|
||||
while (ctx.measureText(text).width > 648) {
|
||||
fontSize--;
|
||||
ctx.font = `${fontSize}px Noto`;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const lines = await wrapText(ctx, text, 185);
|
||||
ctx.fillStyle = 'white';
|
||||
|
||||
Reference in New Issue
Block a user