| 1 |
% This is the macro package used by OpTeX, see http://petr.olsak.net/optex |
| 2 |
|
| 3 |
% emoji.opm, Petr Olšák <[email protected]>, 2021 |
| 4 |
|
| 5 |
% Emoji allows us to use colored emoticons as characters from the font. |
| 6 |
% The \emoji{<name>} command is available, see texdoc emoji (from |
| 7 |
% corresponding LaTeX package). |
| 8 |
|
| 9 |
\_codedecl \emoji {Emotikons from the TwemojiMozilla.ttf font} |
| 10 |
|
| 11 |
\_namespace{emoji} |
| 12 |
|
| 13 |
\_doc ----------------------------- |
| 14 |
Font TwemojiMozilla.ttf is loaded. The font feature +colr is needed. |
| 15 |
The `\emojifont` is implemented using `\_resizethefont` as size-dependent. |
| 16 |
\_cod ----------------------------- |
| 17 |
|
| 18 |
\_initunifonts |
| 19 |
\_font\.tenemoji=[TwemojiMozilla]:+colr |
| 20 |
\_def\.emojifont{\.tenemoji\_resizethefont} |
| 21 |
\_def\.emoji#1{{\.emojifont\_trycs{_emoji_:#1}{\_opwarning{unknown emoji "#1"}}}} |
| 22 |
|
| 23 |
\_doc ----------------------------- |
| 24 |
The mapping from names or aliases to the codes are declared in the |
| 25 |
`emoji-table.def` file from the \LaTeX/ package emoji. |
| 26 |
\_cod ----------------------------- |
| 27 |
|
| 28 |
\_bgroup |
| 29 |
\_def\__emoji_def #1 #2#3#4#5#6{% #1=n, #2=data, #3=name, #4=aliases, #5=descr, #6=versi |
| 30 |
\_sxdef{_emoji_:#3}{#2}% |
| 31 |
\_ifx^#4^\_else \_foreach #4, \_do ##1, {\_global\_slet{_emoji_:##1}{_emoji_:#3}}\_fi |
| 32 |
} |
| 33 |
\_def\ProvidesExplFile#1#2#3#4{} |
| 34 |
\_def\__emoji_group#1 #2{} |
| 35 |
\_def\__emoji_subgroup#1 #2{} |
| 36 |
\_catcode`\#=12 |
| 37 |
\_input {emoji-table.def}% defining emoji names |
| 38 |
\_egroup |
| 39 |
|
| 40 |
\_nspublic \emoji \emojifont ; |
| 41 |
|
| 42 |
\_endnamespace |
| 43 |
|
| 44 |
\_endcode |
| 45 |
|
| 46 |
\begtt % ----------------------- Testing file --------------------------- |
| 47 |
\load[emoji] |
| 48 |
We can use \emoji{grinning} or directly: {\emojifont 😀} too. |
| 49 |
\bye |
| 50 |
\endtt % ---------------------------------------------------------------- |
| 51 |
|
| 52 |
More than 3000 emoticons are available. |
| 53 |
|
| 54 |
See also \ulink[http://petr.olsak.net/optex/optex-tricks.html#emoji] |
| 55 |
{\OpTeX/ trick 0062}. |
| 56 |
|
| 57 |
If you want black-and-white pictograms, see another font: |
| 58 |
\url{http://petr.olsak.net/optex/optex-tricks.html\#fawesome} |