\NeedsTeXFormat{LaTeX2e}[2015/09/07]
\ProvidesExplPackage{utfsym}{2022/04/17}{}{Use TikZ to support icons from Unicode blocks}
%% developed for use in package 'schule' 2016 by Daniel Spittank
%% modified to work with lualatex 2021 by Marei Peischl
%% this package is public domain, CC0

%% - needs ut8 as input encoding
%% - TikZ paths are extracted from Symbola.ttf public domain font by George Douros,
%%   see: http://users.teilar.gr/~g1951d/
%% - supports direct use of unicode symbols
%% - supports textcolor
%% - supports fontsizes
%% - supported Blocks:
%%   - Miscellaneous Symbols and Arrows (2600-26FF)
%%   - Dingbats (2700-27BF)
%%   - Mahjong Tiles (1F000-1F02F)
%%   - Domino Tiles (1F030-1F09F)
%%   - Playing Cards (1F0A0-1F0FF)
%%   - Miscellaneous Symbols and Pictographs (1F300-1F5FF)
%%   - Emoticons / Emoji (1F600-1F64F)
%%   - Transport and Map Symbols (1F680-1F6FF)

\RequirePackage{l3keys2e}

\keys_define:nn {utfsym} {
       create-chars .bool_gset:N = \g__utfsym_create_chars_bool,
       create-chars .default:n = true,
       create-chars .initial:n = true
}

\ProcessKeysOptions{ utfsym }

\ExplSyntaxOff
\RequirePackage{xcolor}
\RequirePackage{tikz}
\RequirePackage{graphicx}

%% command for symbol usage \usym{unicode number}
\newcommand{\usym}[1]{\resizebox{!}{\fontcharht\font`M}{\input{usym#1.tikz}}}

%% command for symbol usage as a picture, scaling by height
%% \usymH{unicode number}{height}
\newcommand{\usymH}[2]{\resizebox{!}{#2}{\input{usym#1.tikz}}}

%% command for symbol usage as a picture, scaling by width
%% \usymW{unicode number}{width}
\newcommand{\usymW}[2]{\resizebox{#2}{!}{\input{usym#1.tikz}}}

%% direct unicode support

\ExplSyntaxOn

\bool_if:NT \g__utfsym_create_chars_bool {
       \cs_if_exist:NTF \DeclareUnicodeCharacter {
               \cs_new:Nn \utfsym_create_char:n {
                       \exp_args:Nx \DeclareUnicodeCharacter{\int_to_Hex:n {#1}}{\usym{\int_to_Hex:n {#1}}}
               }
       }{
               \RequirePackage{newunicodechar}
               \cs_new:Nn \utfsym_create_char:n {
                       \exp_args:Nx \newunicodechar{\char_generate:nn {#1}{12}}{\usym{\int_to_Hex:n {#1}}}
               }
       }

       \int_step_inline:nnn {126976} {127231} {
               \utfsym_create_char:n {#1}
       }

       \int_step_inline:nnn {127744} {128767} {
               \utfsym_create_char:n {#1}
       }

       \int_step_inline:nnn {9728} {10175} {
               \utfsym_create_char:n {#1}
       }
}
\endinput