upd: add tossface emojis as an option

This commit is contained in:
Marie 2024-01-04 20:42:25 +01:00
parent c8a7e27e70
commit 3c3c5e190a
No known key found for this signature in database
GPG key ID: 56569BBE47D2C828
10 changed files with 39 additions and 4 deletions

View file

@ -5,6 +5,7 @@
const twemojiSvgBase = '/twemoji';
const fluentEmojiPngBase = '/fluent-emoji';
const tossfaceSvgBase = '/tossface';
export function char2twemojiFilePath(char: string): string {
let codes = Array.from(char, x => x.codePointAt(0)?.toString(16));
@ -23,3 +24,14 @@ export function char2fluentEmojiFilePath(char: string): string {
const fileName = codes.map(x => x!.padStart(4, '0')).join('-');
return `${fluentEmojiPngBase}/${fileName}.png`;
}
export function char2tossfaceFilePath(char: string): string {
let codes = Array.from(char, x => x.codePointAt(0)?.toString(16));
// Twemoji is the only emoji font which still supports the shibuya 50 emoji to this day
if (codes[0]?.startsWith('e50a')) return char2twemojiFilePath(char);
// Tossface does not use the fe0f modifier
codes = codes.filter(x => x !== 'fe0f');
codes = codes.filter(x => x && x.length);
const fileName = codes.join('-');
return `${tossfaceSvgBase}/${fileName}.svg`;
}