summaryrefslogtreecommitdiff
path: root/packages/client/src/scripts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2022-12-26 16:04:56 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2022-12-26 16:04:56 +0900
commitd106fb39abf8fe17c00e562c1237fcacfe158345 (patch)
tree5600e668f6048868f94958a722ab3bbe9cb078de /packages/client/src/scripts
parent:art: (diff)
downloadsharkey-d106fb39abf8fe17c00e562c1237fcacfe158345.tar.gz
sharkey-d106fb39abf8fe17c00e562c1237fcacfe158345.tar.bz2
sharkey-d106fb39abf8fe17c00e562c1237fcacfe158345.zip
feat: introduce fluent emoji
Diffstat (limited to 'packages/client/src/scripts')
-rw-r--r--packages/client/src/scripts/emoji-base.ts20
-rw-r--r--packages/client/src/scripts/twemoji-base.ts12
2 files changed, 20 insertions, 12 deletions
diff --git a/packages/client/src/scripts/emoji-base.ts b/packages/client/src/scripts/emoji-base.ts
new file mode 100644
index 0000000000..3f05642d57
--- /dev/null
+++ b/packages/client/src/scripts/emoji-base.ts
@@ -0,0 +1,20 @@
+const twemojiSvgBase = '/twemoji';
+const fluentEmojiPngBase = '/fluent-emoji';
+
+export function char2twemojiFilePath(char: string): string {
+ let codes = Array.from(char).map(x => x.codePointAt(0)?.toString(16));
+ if (!codes.includes('200d')) codes = codes.filter(x => x !== 'fe0f');
+ codes = codes.filter(x => x && x.length);
+ const fileName = codes.join('-');
+ return `${twemojiSvgBase}/${fileName}.svg`;
+}
+
+export function char2fluentEmojiFilePath(char: string): string {
+ let codes = Array.from(char).map(x => x.codePointAt(0)?.toString(16));
+ // Fluent Emojiは国旗非対応 https://github.com/microsoft/fluentui-emoji/issues/25
+ if (codes[0]?.startsWith('1f1')) return char2twemojiFilePath(char);
+ if (!codes.includes('200d')) codes = codes.filter(x => x !== 'fe0f');
+ codes = codes.filter(x => x && x.length);
+ const fileName = codes.map(x => x!.padStart(4, '0')).join('-');
+ return `${fluentEmojiPngBase}/${fileName}.png`;
+}
diff --git a/packages/client/src/scripts/twemoji-base.ts b/packages/client/src/scripts/twemoji-base.ts
deleted file mode 100644
index 638aae3284..0000000000
--- a/packages/client/src/scripts/twemoji-base.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-export const twemojiSvgBase = '/twemoji';
-
-export function char2fileName(char: string): string {
- let codes = Array.from(char).map(x => x.codePointAt(0)?.toString(16));
- if (!codes.includes('200d')) codes = codes.filter(x => x !== 'fe0f');
- codes = codes.filter(x => x && x.length);
- return codes.join('-');
-}
-
-export function char2filePath(char: string): string {
- return `${twemojiSvgBase}/${char2fileName(char)}.svg`;
-}