mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 22:32:52 +02:00
Fix font size in two-buttons
This commit is contained in:
@@ -54,18 +54,19 @@ module.exports = class TwoButtonsCommand extends Command {
|
|||||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'two-buttons.png'));
|
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'two-buttons.png'));
|
||||||
const canvas = createCanvas(base.width, base.height);
|
const canvas = createCanvas(base.width, base.height);
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
|
ctx.textBaseline = 'top';
|
||||||
ctx.drawImage(base, 0, 0);
|
ctx.drawImage(base, 0, 0);
|
||||||
ctx.rotate(-12 * (Math.PI / 180));
|
ctx.rotate(-12 * (Math.PI / 180));
|
||||||
ctx.font = '50px Noto';
|
ctx.font = '34px Noto';
|
||||||
let fontSize = 50;
|
let fontSize = 34;
|
||||||
while (ctx.measureText(first).width > 244) {
|
while (ctx.measureText(first).width > 244) {
|
||||||
fontSize -= 1;
|
fontSize -= 1;
|
||||||
ctx.font = `${fontSize}px Noto`;
|
ctx.font = `${fontSize}px Noto`;
|
||||||
}
|
}
|
||||||
const firstLines = await wrapText(ctx, first, 183);
|
const firstLines = await wrapText(ctx, first, 183);
|
||||||
ctx.fillText(firstLines.join('\n'), 45, 178);
|
ctx.fillText(firstLines.join('\n'), 45, 178);
|
||||||
ctx.font = '50px Noto';
|
ctx.font = '34px Noto';
|
||||||
fontSize = 50;
|
fontSize = 34;
|
||||||
while (ctx.measureText(second).width > 163) {
|
while (ctx.measureText(second).width > 163) {
|
||||||
fontSize -= 1;
|
fontSize -= 1;
|
||||||
ctx.font = `${fontSize}px Noto`;
|
ctx.font = `${fontSize}px Noto`;
|
||||||
|
|||||||
Reference in New Issue
Block a user