#61 [en] fix banner

This commit is contained in:
Avris 2020-11-15 15:55:44 +01:00
parent 59cce29c70
commit 9dbcc8a413
2 changed files with 8 additions and 4 deletions

View File

@ -48,8 +48,8 @@ router.get('/banner/:pronounName*.png', async (req, res) => {
const logo = await loadImage('node_modules/@fortawesome/fontawesome-pro/svgs/light/tags.svg');
leftRatio = 5;
context.drawImage(logo, width / leftRatio - imageSize / 2, height / 2 - imageSize / 1.25 / 2, imageSize, imageSize / 1.25);
context.font = 'regular 120pt Quicksand';
context.fillText(translations.title, width / leftRatio + imageSize / 1.5, height / 2 + 48);
context.font = `regular ${translations.title.length < 10 ? 120 : 80}pt Quicksand`;
context.fillText(translations.title, width / leftRatio + imageSize / 1.5, height / 2 + (translations.title.length < 10 ? 48 : 36));
}
if (pronounName.startsWith('@')) {
@ -84,7 +84,7 @@ router.get('/banner/:pronounName*.png', async (req, res) => {
const logo = await loadImage('node_modules/@fortawesome/fontawesome-pro/svgs/light/tags.svg');
if (!pronoun && pronounName !== 'dowolne') { // TODO
if (!pronoun && pronounName !== req.config.pronouns.any.route) {
await fallback();
return res.set('content-type', mime).send(canvas.toBuffer(mime));
}
@ -93,7 +93,7 @@ router.get('/banner/:pronounName*.png', async (req, res) => {
context.font = 'regular 48pt Quicksand'
context.fillText(translations.pronouns.intro + ':', width / leftRatio + imageSize / 1.5, height / 2 - 36)
const pronounNameOptions = pronounName === 'dowolne' ? ['dowolne'] : pronoun.nameOptions();
const pronounNameOptions = pronounName === req.config.pronouns.any.route ? [req.config.pronouns.any.route] : pronoun.nameOptions();
context.font = `bold ${pronounNameOptions.length <= 2 ? '70' : '36'}pt Quicksand`
context.fillText(pronounNameOptions.join('\n'), width / leftRatio + imageSize / 1.5, height / 2 + (pronounNameOptions.length <= 2 ? 72 : 24))

View File

@ -39,6 +39,10 @@ export const buildPronoun = (pronouns, path) => {
? base
: Pronoun.from(Compressor.uncompress(pronounStr, base ? base.toArray() : null));
if (!process.env.CONFIG) {
return pronoun;
}
if (!pronoun && process.env.CONFIG.pronouns.emoji !== false && isEmoji(path)) {
pronoun = buildPronounFromTemplate(path, process.env.CONFIG.pronouns.emoji);
}