summaryrefslogtreecommitdiff
path: root/macros/unicodetex/latex/emotion/emotion.sty
blob: 34b02f82edbd2e514207d0073f852c89326411c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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