%%^^A%% um-code-pkgopt.dtx -- part of UNICODE-MATH <wspr.io/unicode-math>
%%^^A%% Package options.

% \section{setup and package options}
%
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%
% \begin{macro}{\@@_keys_choices:nn}
% To simplify the creation of option keys, let's iterate in pairs rather than worry about equals signs and commas.
%    \begin{macrocode}
\cs_new:Nn \@@_keys_choices:nn
  {
    \cs_set:Npn \@@_keys_choices_fn:nn { \@@_keys_choices_aux:nnn {#1} }
    \use:x
      {
        \exp_not:N \keys_define:nn {unicode-math}
          {
            #1 .choice: ,
            \@@_tl_map_dbl:nN {#2} \@@_keys_choices_fn:nn
          }
      }
  }
%    \end{macrocode}
%    \begin{macrocode}
\cs_new:Nn \@@_keys_choices_aux:nnn { #1 / #2 .code:n = { \exp_not:n {#3} } , }
%    \end{macrocode}
%
%    \begin{macrocode}
\cs_new:Nn \@@_tl_map_dbl:nN
  {
    \__@@_tl_map_dbl:Nnn #2 #1 \q_recursion_tail {}{} \q_recursion_stop
  }
%    \end{macrocode}
%
%    \begin{macrocode}
\cs_new:Nn \__@@_tl_map_dbl:Nnn
  {
    \quark_if_recursion_tail_stop:n {#2}
    \quark_if_recursion_tail_stop:n {#3}
    #1 {#2} {#3}
    \__@@_tl_map_dbl:Nnn #1
 }
%    \end{macrocode}
% \end{macro}
%
% \paragraph{Compatibility}
%    \begin{macrocode}
\@@_keys_choices:nn {mathup}
  {
    {sym}  { \bool_set_false:N \g_@@_mathrm_text_bool }
    {text} { \bool_set_true:N  \g_@@_mathrm_text_bool }
  }
%    \end{macrocode}
%    \begin{macrocode}
\@@_keys_choices:nn {mathrm}
  {
    {sym}  { \bool_set_false:N \g_@@_mathrm_text_bool }
    {text} { \bool_set_true:N  \g_@@_mathrm_text_bool }
  }
%    \end{macrocode}
%    \begin{macrocode}
\@@_keys_choices:nn {mathit}
  {
    {sym}  { \bool_set_false:N \g_@@_mathit_text_bool }
    {text} { \bool_set_true:N  \g_@@_mathit_text_bool }
  }
%    \end{macrocode}
%    \begin{macrocode}
\@@_keys_choices:nn {mathbf}
  {
    {sym}  { \bool_set_false:N \g_@@_mathbf_text_bool }
    {text} { \bool_set_true:N  \g_@@_mathbf_text_bool }
  }
%    \end{macrocode}
%    \begin{macrocode}
\@@_keys_choices:nn {mathsf}
  {
    {sym}  { \bool_set_false:N \g_@@_mathsf_text_bool }
    {text} { \bool_set_true:N  \g_@@_mathsf_text_bool }
  }
%    \end{macrocode}
%    \begin{macrocode}
\@@_keys_choices:nn {mathtt}
  {
    {sym}  { \bool_set_false:N \g_@@_mathtt_text_bool }
    {text} { \bool_set_true:N  \g_@@_mathtt_text_bool }
  }
%    \end{macrocode}
%
% \paragraph{math-style}
%    \begin{macrocode}
\@@_keys_choices:nn {normal-style}
  {
       {ISO} {
              \bool_set_false:N \g_@@_literal_bool
              \bool_set_false:N \g_@@_upGreek_bool
              \bool_set_false:N \g_@@_upgreek_bool
              \bool_set_false:N \g_@@_upLatin_bool
              \bool_set_false:N \g_@@_uplatin_bool
             }
       {TeX} {
              \bool_set_false:N \g_@@_literal_bool
              \bool_set_true:N  \g_@@_upGreek_bool
              \bool_set_false:N \g_@@_upgreek_bool
              \bool_set_false:N \g_@@_upLatin_bool
              \bool_set_false:N \g_@@_uplatin_bool
             }
    {french} {
              \bool_set_false:N \g_@@_literal_bool
              \bool_set_true:N  \g_@@_upGreek_bool
              \bool_set_true:N  \g_@@_upgreek_bool
              \bool_set_true:N  \g_@@_upLatin_bool
              \bool_set_false:N \g_@@_uplatin_bool
             }
   {upright} {
              \bool_set_false:N \g_@@_literal_bool
              \bool_set_true:N  \g_@@_upGreek_bool
              \bool_set_true:N  \g_@@_upgreek_bool
              \bool_set_true:N  \g_@@_upLatin_bool
              \bool_set_true:N  \g_@@_uplatin_bool
             }
   {literal} {
              \bool_set_true:N  \g_@@_literal_bool
             }
  }
%    \end{macrocode}
%
%    \begin{macrocode}
\@@_keys_choices:nn {math-style}
  {
      {ISO} {
             \unimathsetup { nabla=upright, partial=italic,
              normal-style=ISO, bold-style=ISO, sans-style=italic }
            }
      {TeX} {
             \unimathsetup { nabla=upright, partial=italic,
               normal-style=TeX, bold-style=TeX, sans-style=upright }
            }
   {french} {
             \unimathsetup { nabla=upright, partial=upright,
               normal-style=french, bold-style=upright, sans-style=upright }
            }
  {upright} {
             \unimathsetup { nabla=upright, partial=upright,
               normal-style=upright, bold-style=upright, sans-style=upright }
            }
  {literal} {
             \unimathsetup { colon=literal, nabla=literal, partial=literal,
               normal-style=literal, bold-style=literal, sans-style=literal }
            }
  }
%    \end{macrocode}
%
% \paragraph{bold-style}
%    \begin{macrocode}
\@@_keys_choices:nn {bold-style}
  {
      {ISO} {
             \bool_set_false:N \g_@@_bfliteral_bool
             \bool_set_false:N \g_@@_bfupGreek_bool
             \bool_set_false:N \g_@@_bfupgreek_bool
             \bool_set_false:N \g_@@_bfupLatin_bool
             \bool_set_false:N \g_@@_bfuplatin_bool
            }
      {TeX} {
             \bool_set_false:N \g_@@_bfliteral_bool
             \bool_set_true:N  \g_@@_bfupGreek_bool
             \bool_set_false:N \g_@@_bfupgreek_bool
             \bool_set_true:N  \g_@@_bfupLatin_bool
             \bool_set_true:N  \g_@@_bfuplatin_bool
            }
  {upright} {
             \bool_set_false:N \g_@@_bfliteral_bool
             \bool_set_true:N  \g_@@_bfupGreek_bool
             \bool_set_true:N  \g_@@_bfupgreek_bool
             \bool_set_true:N  \g_@@_bfupLatin_bool
             \bool_set_true:N  \g_@@_bfuplatin_bool
            }
  {literal} {
             \bool_set_true:N  \g_@@_bfliteral_bool
            }
  }
%    \end{macrocode}
%
% \paragraph{sans-style}
%    \begin{macrocode}
\@@_keys_choices:nn {sans-style}
  {
    {italic}  { \bool_set_false:N \g_@@_upsans_bool    }
    {upright} { \bool_set_true:N  \g_@@_upsans_bool    }
    {literal} { \bool_set_true:N  \g_@@_sfliteral_bool }
  }
%    \end{macrocode}
%
%
% \paragraph{Nabla and partial}
%    \begin{macrocode}
\@@_keys_choices:nn {nabla}
  {
    {upright} {
                \bool_set_false:N \g_@@_literal_Nabla_bool
                \bool_set_true:N  \g_@@_upNabla_bool
              }
    {italic}  {
                \bool_set_false:N \g_@@_literal_Nabla_bool
                \bool_set_false:N \g_@@_upNabla_bool
              }
    {literal} {
                \bool_set_true:N  \g_@@_literal_Nabla_bool
              }
  }
%    \end{macrocode}
%
%    \begin{macrocode}
\@@_keys_choices:nn {partial}
  {
   {upright} {
               \bool_set_false:N \g_@@_literal_partial_bool
               \bool_set_true:N  \g_@@_uppartial_bool
             }
   {italic}  {
               \bool_set_false:N \g_@@_literal_partial_bool
               \bool_set_false:N \g_@@_uppartial_bool
             }
   {literal} {
               \bool_set_true:N  \g_@@_literal_partial_bool
             }
  }
%    \end{macrocode}
%
% \paragraph{Colon style}
%    \begin{macrocode}
\@@_keys_choices:nn {colon}
  {
    {literal} { \bool_set_true:N  \g_@@_literal_colon_bool }
    {TeX}     { \bool_set_false:N \g_@@_literal_colon_bool }
  }
%    \end{macrocode}
%
% \paragraph{Slash delimiter style}
%    \begin{macrocode}
\@@_keys_choices:nn {slash-delimiter}
  {
    {ascii} { \tl_set:Nn \g_@@_slash_delimiter_usv {"002F} }
    {frac}  { \tl_set:Nn \g_@@_slash_delimiter_usv {"2044} }
    {div}   { \tl_set:Nn \g_@@_slash_delimiter_usv {"2215} }
  }
%    \end{macrocode}
%
%
% \paragraph{Active fraction style}
%    \begin{macrocode}
\@@_keys_choices:nn {active-frac}
  {
    {small}
    {
      \cs_if_exist:NTF \tfrac
        { \bool_set_true:N \l_@@_smallfrac_bool }
        {
          \@@_warning:n {no-tfrac}
          \bool_set_false:N \l_@@_smallfrac_bool
        }
      \use:c {@@_setup_active_frac:}
    }

    {normalsize}
    {
      \bool_set_false:N \l_@@_smallfrac_bool
      \use:c {@@_setup_active_frac:}
    }
  }
%    \end{macrocode}
%
% \paragraph{Debug/tracing}
%
%    \begin{macrocode}
\keys_define:nn {unicode-math}
  {
    warnings-off .code:n =
      {
        \clist_map_inline:nn {#1}
          { \msg_redirect_name:nnn { unicode-math } { ##1 } { none } }
      }
  }
%    \end{macrocode}
%
%    \begin{macrocode}
\@@_keys_choices:nn {trace}
  {
    {on}    {} % default
    {debug} { \msg_redirect_module:nnn { unicode-math } { log } { warning } }
    {off}   { \msg_redirect_module:nnn { unicode-math } { log } { none } }
  }
%    \end{macrocode}
%
% \subsection{Defaults}
%
%    \begin{macrocode}
\unimathsetup {math-style=TeX}
\unimathsetup {slash-delimiter=ascii}
\unimathsetup {trace=off}
\unimathsetup {mathrm=text,mathit=text,mathbf=text,mathsf=text,mathtt=text}
\cs_if_exist:NT \tfrac { \unimathsetup {active-frac=small} }
\ProcessKeysOptions {unicode-math}
%    \end{macrocode}
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}

\endinput

% /©
%
% ------------------------------------------------
% The UNICODE-MATH package  <wspr.io/unicode-math>
% ------------------------------------------------
% This package is free software and may be redistributed and/or modified under
% the conditions of the LaTeX Project Public License, version 1.3c or higher
% (your choice): <http://www.latex-project.org/lppl/>.
% ------------------------------------------------
% Copyright 2006-2018  Will Robertson, LPPL "maintainer"
% Copyright 2010-2017  Philipp Stephani
% Copyright 2011-2017  Joseph Wright
% Copyright 2012-2015  Khaled Hosny
% ------------------------------------------------
%
% ©/
