summaryrefslogtreecommitdiff
path: root/fonts/fontawesome5/tex/fontawesome5-generic-helper.sty
blob: 416fd9954d6580e4240b453f27bbd7730ef789b8 (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
% Copyright 2018--2020 Marcel Krueger
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
% 
% The Current Maintainer of this work is Marcel Krueger
%

\@ifpackageloaded{fontawesome5}{}{\PackageError{fontawesome5-generic-helper}{This package should not be loaded individually. Load fontawesome5 instead.}{}}

\ProvidesExplPackage{fontawesome5-generic-helper}{2020/01/15}{5.12.0}{non-uTeX helper for fontawesome5}

\cs_new_protected:Nn\__fontawesome_def_icon:nnnnn{
  \tl_if_empty:nF{#1}{
    \cs_new_protected:Npn#1{\faPreselectedIcon{#2}}
  }
  \tl_const:cn{c__fontawesome_slot_#2_tl}{{#3}{#4}}
}
\file_input:n{fontawesome5-mapping.def}
\cs_new_protected:Nn\__fontawesome_icon_at:nnnn{
  {
    \usefont
      {U}
      {fontawesome#1}
      {#3}
      {n}
    \unless\iffontchar\font#2
      \fontseries{solid}
      \selectfont
      \iffontchar\font#2
        \msg_warning:nnxx{fontawesome5}{style-substitution}{#4}{#3}
      \else
        \msg_error:nnxx{fontawesome5}{icon-not-found}{#4}{#3}
      \fi
    \fi
    \char#2
  }
}
\cs_new_protected:Nn\fontawesome_use_icon:nn{
  \cs_if_exist:cTF{c__fontawesome_slot_#2_tl}{
    \bool_if:NTF\c__fontawesome_fixed_bool{
      \makebox[1.5em][c]
    }{
      \use:n
    }
    {
      \exp_last_unbraced:Nv
        \__fontawesome_icon_at:nnnn
        {c__fontawesome_slot_#2_tl}
          {#1}{#2}
    }
  }{
    \msg_error:nnxx{fontawesome5}{icon-not-found}{#2}{#1}
  }
}