Fix avatar from name to support lowercase

This commit is contained in:
ayumi-signal 2023-09-28 16:31:58 -04:00 committed by GitHub
parent e3750ef471
commit 72d1695612
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 9 deletions

View file

@ -101,15 +101,14 @@ export async function avatarDataToBytes(
);
} else if (color && text) {
const { bg, fg } = getAvatarColor(color);
const textToWrite = text.toLocaleUpperCase();
setCanvasBackground(bg, context, canvas);
context.fillStyle = fg;
const font = await getFont(textToWrite);
const font = await getFont(text);
context.font = font;
context.textBaseline = 'middle';
context.textAlign = 'center';
context.fillText(textToWrite, CANVAS_SIZE / 2, CANVAS_SIZE / 2 + 30);
context.fillText(text, CANVAS_SIZE / 2, CANVAS_SIZE / 2 + 30);
} else if (color && icon) {
const iconPath = `images/avatars/avatar_${icon}.svg`;
await drawImage(iconPath, context, canvas);