summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/utfsym/latex/utfsym.sty
blob: 91b1e534de638c743720a47871eeca2e2c9b9d4b (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
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
\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