This repository has been archived by the owner on Aug 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
coloremoji.sty
110 lines (96 loc) · 3.3 KB
/
coloremoji.sty
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
\NeedsTeXFormat{pLaTeX2e}
\ProvidesPackage{coloremoji}
\RequirePackage{graphicx}
\newif\if@coloremoji@hires
\newif\if@coloremoji@twitter
\DeclareOption{hires}{\@coloremoji@hirestrue}
\DeclareOption{twitter}{\@coloremoji@twittertrue}
\ProcessOptions\relax
\def\coloremoji@setmode@twitter{%
\def\coloremoji@bb{width=1zw,bb=0 0 38 38}
\def\coloremoji@subdir{twitter}
}
\def\coloremoji@setmode@hires{%
\def\coloremoji@bb{width=1zw,bb=0 0 11.338600 11.338600}
\def\coloremoji@subdir{hires}
}
\def\coloremoji@setmode@lowres{%
\def\coloremoji@bb{width=1zw,bb=0 0 4.535430 4.535430}
\def\coloremoji@subdir{lowres}
}
\if@coloremoji@twitter
\coloremoji@setmode@twitter
\else
\if@coloremoji@hires
\coloremoji@setmode@hires
\else
\coloremoji@setmode@lowres
\fi
\fi
\def\coloremojidir{}%% path to the emoji directory
\newif\if@coloremoji@combining
\edef\coloremoji@vsE{\detokenize{FE0E}}
\edef\coloremoji@vsF{\detokenize{FE0F}}
\edef\coloremoji@combining@list{\detokenize{23,30,31,32,33,34,35,36,37,38,39,1F1E8,1F1E9,1F1EA,1F1EB,1F1EC,1F1EE,1F1EF,1F1F0,1F1F7,1F1FA}}
\def\coloremoji@prefix{}
\def\coloremoji@option@twitter{twitter}
\def\coloremoji@option@hires{hires}
\def\coloremoji@option@lowres{lowres}
\DeclareRobustCommand*{\coloremoji}[2][\relax]{%
\begingroup
\def\coloremoji@option{#1}%
\ifx\coloremoji@option\coloremoji@option@twitter\coloremoji@setmode@twitter\fi
\ifx\coloremoji@option\coloremoji@option@hires\coloremoji@setmode@hires\fi
\ifx\coloremoji@option\coloremoji@option@lowres\coloremoji@setmode@lowres\fi
\@coloremoji@combiningfalse\@coloremoji#2\coloremoji@terminate
\endgroup
}
\def\@coloremoji{\futurelet\coloremoji@target\@@coloremoji}
\def\@@coloremoji#1{%
\ifx\coloremoji@target\coloremoji@terminate
\let\coloremoji@next\relax
\else
\ifx\coloremoji@target##\relax
\expandafter\def\expandafter\coloremoji@target\expandafter{\string##}%
\fi
\ifx\coloremoji@target\#\relax
\expandafter\def\expandafter\coloremoji@target\expandafter{\string##}%
\fi
\kchardef\@temp=`#1\relax
\expandafter\coloremoji@getcodepoint\meaning\@temp\relax
\ifx\coloremoji@currentcodepoint\coloremoji@vsE\else
\ifx\coloremoji@currentcodepoint\coloremoji@vsF\else
\if@coloremoji@combining
\coloremoji@output{\coloremoji@prefix\coloremoji@currentcodepoint}%
\def\coloremoji@prefix{}%
\@coloremoji@combiningfalse
\else
\@for\@temp:=\coloremoji@combining@list\do{%
\ifx\@temp\coloremoji@currentcodepoint
\@coloremoji@combiningtrue
\fi
}%
\if@coloremoji@combining
\edef\coloremoji@prefix{\coloremoji@currentcodepoint-}%
\else
\coloremoji@output{\coloremoji@currentcodepoint}%
\fi
\fi
\fi
\fi
\let\coloremoji@next\@coloremoji
\fi
\coloremoji@next
}
\def\coloremoji@getcodepoint#1"#2\relax{\def\coloremoji@currentcodepoint{#2}}
\def\coloremoji@output#1{%
\def\coloremoji@image{\expandafter\includegraphics\expandafter[\coloremoji@bb]{\coloremojidir\coloremoji@subdir/#1.pdf}}%
\nobreak\hspace{-1zw}%
\iftdir
\raisebox{-.5zw}{\rotatebox[origin=c]{90}{\coloremoji@image}}%
\else
\raisebox{-.12zw}{\coloremoji@image}%
\fi
\nobreak\hspace{-1zw}\nobreak % full-width space
}
\endinput