Попытка починить шрифты

This commit is contained in:
JonnyBro 2021-12-14 00:13:06 +05:00
parent 4b1e6ec646
commit ac227fb1ea
4 changed files with 15 additions and 13 deletions

Binary file not shown.

View file

@ -4,12 +4,13 @@ const Canvas = require("canvas"),
{ resolve } = require("path"); { resolve } = require("path");
// Register assets fonts // Register assets fonts
Canvas.registerFont(resolve("./assets/fonts/RubikMonoOne-Regular.ttf"), { family: "Regular" }); Canvas.registerFont(resolve("./assets/fonts/RubikMonoOne-Regular.ttf"), { family: "RubikMonoOne" });
Canvas.registerFont(resolve("./assets/fonts/KeepCalm-Medium.ttf"), { family: "KeepCalm" });
const applyText = (canvas, text, defaultFontSize) => { const applyText = (canvas, text, defaultFontSize) => {
const ctx = canvas.getContext("2d"); const ctx = canvas.getContext("2d");
do { do {
ctx.font = `${defaultFontSize -= 10}px Regular`; ctx.font = `${defaultFontSize -= 10}px RubikMonoOne`;
} while (ctx.measureText(text).width > 600); } while (ctx.measureText(text).width > 600);
return ctx.font; return ctx.font;
}; };
@ -76,19 +77,19 @@ module.exports = class {
server: member.guild.name server: member.guild.name
}), canvas.width - 690, canvas.height - 85); }), canvas.width - 690, canvas.height - 85);
// Draw discriminator // Draw discriminator
ctx.font = "35px Regular"; ctx.font = "35px RubikMonoOne";
ctx.fillText(member.user.discriminator, canvas.width - 624, canvas.height - 180); ctx.fillText(member.user.discriminator, canvas.width - 624, canvas.height - 180);
// Draw number // Draw number
ctx.font = "22px Regular"; ctx.font = "22px RubikMonoOne";
ctx.fillText(member.guild.translate("administration/welcome:IMG_NB", { ctx.fillText(member.guild.translate("administration/welcome:IMG_NB", {
memberCount: member.guild.memberCount memberCount: member.guild.memberCount
}), 50, canvas.height - 50); }), 50, canvas.height - 50);
// Draw # for discriminator // Draw # for discriminator
ctx.fillStyle = "#44d14a"; ctx.fillStyle = "#44d14a";
ctx.font = "70px Regular"; ctx.font = "70px RubikMonoOne";
ctx.fillText("#", canvas.width - 690, canvas.height - 165); ctx.fillText("#", canvas.width - 690, canvas.height - 165);
// Draw Title with gradient // Draw Title with gradient
ctx.font = "65px Regular"; ctx.font = "65px RubikMonoOne";
ctx.strokeStyle = "#1d2124"; ctx.strokeStyle = "#1d2124";
ctx.lineWidth = 15; ctx.lineWidth = 15;
ctx.strokeText(member.guild.translate("administration/welcome:TITLE"), canvas.width - 670, canvas.height - 330); ctx.strokeText(member.guild.translate("administration/welcome:TITLE"), canvas.width - 670, canvas.height - 330);

View file

@ -4,12 +4,13 @@ const Canvas = require("canvas"),
{ resolve } = require("path"); { resolve } = require("path");
// Register assets fonts // Register assets fonts
Canvas.registerFont(resolve("./assets/fonts/RubikMonoOne-Regular.ttf"), { family: "Regular" }); Canvas.registerFont(resolve("./assets/fonts/RubikMonoOne-Regular.ttf"), { family: "RubikMonoOne" });
Canvas.registerFont(resolve("./assets/fonts/KeepCalm-Medium.ttf"), { family: "KeepCalm" });
const applyText = (canvas, text, defaultFontSize) => { const applyText = (canvas, text, defaultFontSize) => {
const ctx = canvas.getContext("2d"); const ctx = canvas.getContext("2d");
do { do {
ctx.font = `${defaultFontSize -= 10}px Regular`; ctx.font = `${defaultFontSize -= 10}px RubikMonoOne`;
} while (ctx.measureText(text).width > 600); } while (ctx.measureText(text).width > 600);
return ctx.font; return ctx.font;
}; };
@ -60,19 +61,19 @@ module.exports = class {
server: member.guild.name server: member.guild.name
}), canvas.width - 690, canvas.height - 65); }), canvas.width - 690, canvas.height - 65);
// Draw discriminator // Draw discriminator
ctx.font = "35px Regular"; ctx.font = "35px RubikMonoOne";
ctx.fillText(member.user.discriminator, canvas.width - 624, canvas.height - 180); ctx.fillText(member.user.discriminator, canvas.width - 624, canvas.height - 180);
// Draw number // Draw number
ctx.font = "22px Regular"; ctx.font = "22px RubikMonoOne";
ctx.fillText(member.guild.translate("administration/goodbye:IMG_NB", { ctx.fillText(member.guild.translate("administration/goodbye:IMG_NB", {
memberCount: member.guild.memberCount memberCount: member.guild.memberCount
}), 50, canvas.height - 50); }), 50, canvas.height - 50);
// Draw # for discriminator // Draw # for discriminator
ctx.fillStyle = "#44d14a"; ctx.fillStyle = "#44d14a";
ctx.font = "70px Regular"; ctx.font = "70px RubikMonoOne";
ctx.fillText("#", canvas.width - 690, canvas.height - 165); ctx.fillText("#", canvas.width - 690, canvas.height - 165);
// Draw Title with gradient // Draw Title with gradient
ctx.font = "65px Regular"; ctx.font = "65px RubikMonoOne";
ctx.strokeStyle = "#1d2124"; ctx.strokeStyle = "#1d2124";
ctx.lineWidth = 15; ctx.lineWidth = 15;
ctx.strokeText(member.guild.translate("administration/goodbye:TITLE"), canvas.width - 670, canvas.height - 330); ctx.strokeText(member.guild.translate("administration/goodbye:TITLE"), canvas.width - 670, canvas.height - 330);

View file

@ -16,7 +16,7 @@
"BIRTHDATE": "🎂 День рождения", "BIRTHDATE": "🎂 День рождения",
"NO_BIRTHDATE": "День рождения не указан", "NO_BIRTHDATE": "День рождения не указан",
"LOVER": "❤ Вторая половинка", "LOVER": "❤ Вторая половинка",
"REGISTERED": "📅 Аккаунт создан", "REGISTERED": "📅 Профиль создан",
"NO_LOVER": "Свободен", "NO_LOVER": "Свободен",
"ACHIEVEMENTS": "🔥 Достижения", "ACHIEVEMENTS": "🔥 Достижения",
"ACHIEVEMENTS_CONTENT": "Получите больше информации с помощью `{{prefix}}achievements`!", "ACHIEVEMENTS_CONTENT": "Получите больше информации с помощью `{{prefix}}achievements`!",