% Copyright 2018 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}{2018/08/30}{5.3.1}{non-uTeX helper for fontawesome5}

\cs_new:Nn\__fontawesome_def_icon:nnnnn{
  \tl_if_empty:nF{#1}{
    \cs_new:Npn#1{\faPreselectedIcon{#2}}
  }
  \tl_const:cn{c__fontawesome_slot_#2_tl}{{#3}{#4}}
}
\file_input:n{fontawesome5-mapping.def}
\cs_new: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:Nn\fontawesome_use_icon:nn{
  \cs_if_exist:cTF{c__fontawesome_slot_#2_tl}{
    \exp_last_unbraced:Nv
      \__fontawesome_icon_at:nnnn
      {c__fontawesome_slot_#2_tl}
        {#1}{#2}
  }{
    \msg_error:nnxx{fontawesome5}{icon-not-found}{#2}{#1}
  }
}
