summaryrefslogtreecommitdiff
path: root/macros/unicodetex/latex/emotion/emotion.sty
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2024-02-09 03:00:44 +0000
committerNorbert Preining <norbert@preining.info>2024-02-09 03:00:44 +0000
commitfa4b456400bb2b415dcbbfe785542c50e9dd61e3 (patch)
tree61bb8ad8f9071ab1f33a17b7bc28dc74fd010b3c /macros/unicodetex/latex/emotion/emotion.sty
parentbaa694429155689a0e8bba804206961689e0a606 (diff)
CTAN sync 202402090300
Diffstat (limited to 'macros/unicodetex/latex/emotion/emotion.sty')
-rw-r--r--macros/unicodetex/latex/emotion/emotion.sty41
1 files changed, 41 insertions, 0 deletions
diff --git a/macros/unicodetex/latex/emotion/emotion.sty b/macros/unicodetex/latex/emotion/emotion.sty
new file mode 100644
index 0000000000..34b02f82ed
--- /dev/null
+++ b/macros/unicodetex/latex/emotion/emotion.sty
@@ -0,0 +1,41 @@
+\RequirePackage{expl3}
+\ProvidesExplPackage{emotion}{2024/02/06}{0.1}{LaTeX emoji}
+
+\RequirePackage { fontspec }
+
+\ExplSyntaxOn
+
+% add emotion command
+\newfontface \emotionfont: { Apple~Color~Emoji } [ Renderer = Harfbuzz ]
+
+% enable update emoji font
+\newcommand{\emotionsetup}[1]{
+\renewfontface \emotionfont: {#1} [ Renderer = HarfBuzz]
+}
+
+% define emoji with unicode
+% 1: id
+% 2: unicode value
+\newcommand{\emotiondef}[2]{
+ \tl_const:cn{l__emotion_ #1}{#2}
+}
+
+% import pre-defined emotion
+\file_input:n { emotion.def }
+
+\tl_set:Nn \l__emotion_tmp_tl {❓}
+
+\newcommand{\emotion}[1]{
+\group_begin:
+\tl_set:Nn \l__emotion_tmp_tl {#1}
+\ifcsname l__emotion_#1\endcsname
+ {\emotionfont:{\tl_use:c {l__emotion_ #1}}}
+\else
+ {\emotionfont:{\tl_use:N \l__emotion_tmp_tl}}
+\fi
+\group_end:
+}
+
+\ExplSyntaxOff
+
+\endinput \ No newline at end of file