summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/unicode-alphabets/latex/unicode-alphabets.sty
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/unicode-alphabets/latex/unicode-alphabets.sty
Initial commit
Diffstat (limited to 'macros/latex/contrib/unicode-alphabets/latex/unicode-alphabets.sty')
-rw-r--r--macros/latex/contrib/unicode-alphabets/latex/unicode-alphabets.sty118
1 files changed, 118 insertions, 0 deletions
diff --git a/macros/latex/contrib/unicode-alphabets/latex/unicode-alphabets.sty b/macros/latex/contrib/unicode-alphabets/latex/unicode-alphabets.sty
new file mode 100644
index 0000000000..9195bab402
--- /dev/null
+++ b/macros/latex/contrib/unicode-alphabets/latex/unicode-alphabets.sty
@@ -0,0 +1,118 @@
+\ProvidesPackage{unicode-alphabets}[2019/07/23 Unicode alphabets in the Private Use Area]
+
+% License: CC-BY-SA 4.0
+% Author: Mikkel Eide Eriksen <mikkel.eriksen@gmail.com>
+
+\RequirePackage{pgfkeys}
+\RequirePackage{pgfopts}
+
+\RequirePackage{etoolbox}
+\RequirePackage{xparse}
+\RequirePackage{stringstrings}
+
+\RequirePackage{csvsimple}
+
+\input{csvsimple.tmp.patch}
+
+\makeatletter
+
+\newcommand\alph@keys[1]{\pgfkeys{/unicode-alphabets/.cd,#1}}
+
+\newif\ifalph@noentitymacros
+\alph@keys{
+ fonts/.code={\alph@keys{fonts/.cd,#1}},
+% disable entity macros/.is if=alph@noentitymacros,
+% disable entity macros=false,
+ disableentitymacros/.is if=alph@noentitymacros,
+ disableentitymacros=false,
+}
+
+\newcommand\alph@setup[1]{
+ \caselower[q]{#1}
+ \csxdef{#1code}{\thestring}
+ \edef\temp{%
+ \noexpand\alph@keys{
+ fonts/#1/.store in=\unexpanded\expandafter{\csname alph@font@\csuse{#1code}\endcsname},
+ }%
+ }\temp%
+ \alph@keys{
+ #1/.default={\csuse{#1code}},
+ #1/.code={\alph@make@set{\csuse{#1code}}{##1}},
+ }
+}
+\alph@setup{AGL}
+\alph@setup{CYFI}
+\alph@setup{MUFI}
+\alph@setup{SIL}
+\alph@setup{TITUS}
+\alph@setup{UCSUR}
+\alph@setup{UNZ}
+\alph@keys{
+ LINCUA/.style={CYFI,MUFI,TITUS}
+}
+
+\newcommand\alph@make@set[2]{%
+ % #1 = character set
+ % #2 = macro name
+ \newbool{alph@#1@has@entities}%
+ \alph@make@main{#1}{#2}%
+ \csvloop{
+ file={unicode-alphabets.#1.csv},
+ head to column names,
+ head to column names prefix=alph@,
+ command={
+ \ifcsdef{alph@name}{%
+ \ifcsempty{alph@name}{}{%
+ \csxdef{alph@#1@\alph@name}{\alph@codepoint}%
+ }%
+ }{}%
+ \ifcsdef{alph@entity}{%
+ \ifcsempty{alph@entity}{}{%
+ \booltrue{alph@#1@has@entities}%
+ \csxdef{alph@#1@\alph@entity}{\alph@codepoint}%
+ \ifalph@noentitymacros\relax\else%
+ \expanded{\unexpanded{\alph@make@character}{#1}{#2}{\alph@entity}{\alph@codepoint}}%
+ \fi%
+ }%
+ }{}%
+ }%
+ }%
+}
+\newcommand\alph@make@main[2]{%
+ % #1 = character set
+ % #2 = macro name
+ \expandafter\NewDocumentCommand\csname#2\endcsname { s m } {%
+ % #1 = star
+ % #2 = character name
+ {%
+ \IfBooleanF{##1}{%
+ \csuse{alph@font@#1}%
+ }%
+ %!\csuse{alph@#1@##2}!%
+ \ifcsdef{alph@#1@##2}{%
+ \symbol{"\csuse{alph@#1@##2}}%
+ }{%
+ \symbol{"##2}%
+ }%
+ }%
+ }%
+}
+\newcommand\alph@make@character[4]{%
+ % #1 = character set
+ % #2 = macro name
+ % #3 = character name
+ % #4 = code point
+ \expandafter\ProvideDocumentCommand\csname#3\endcsname { s } {%
+ {%
+ \IfBooleanTF{##1}{%
+ \csuse{#2}*{#4}%
+ }{%
+ \csuse{#2}{#4}%
+ }%
+ }%
+ }%
+}
+
+\makeatother
+
+\ProcessPgfPackageOptions{/unicode-alphabets} \ No newline at end of file