%% $Id: firamath-otf.sty 673 2023-01-16 19:44:41Z herbert $
%%
%% This file is distributed under the terms of the LaTeX Project Public
%% License from CTAN archives in directory  macros/latex/base/lppl.txt.
%% Either version 1.3 or, at your option, any later version.
%%
%
% Copyright 2018 Herbert Voss hvoss@tug.org
%
\ProvidesPackage{firamath-otf}[%
  2023/01/16 v. 0.03a (Herbert Voss) Supports fira math fonts for all luatex/xetex .] 

\RequirePackage{iftex,xkeyval,textcomp}


\newif\iffiramath@fakebold \firamath@fakeboldfalse
\newif\iffiramath@lining \firamath@liningtrue
\newif\iffiramath@tabular \firamath@tabulartrue
\newif\iffiramath@usefilenames \firamath@usefilenamesfalse

\def\fira@weight{Regular}% default

\DeclareOptionX{fakebold}[true]{\@nameuse{firamath@fakebold#1}}
\DeclareOptionX{weight}[Regular]{\def\fira@weight{#1}}
\DeclareOptionX{lining}[true]{\@nameuse{firamath@lining#1}}
\DeclareOptionX{nf}[true]{\@nameuse{firamath@lining#1}}
\DeclareOptionX{lf}[true]{\@nameuse{firamath@lining#1}}
\DeclareOptionX{oldstyle}[true]{\@nameuse{if#1}\firamath@liningfalse\else\firamath@liningtrue\fi}
\DeclareOptionX{osf}[true]{\@nameuse{if#1}\firamath@liningfalse\else\firamath@liningtrue\fi}

\DeclareOptionX{usefilenames}[true]{\@nameuse{firamath@usefilenames#1}}
\DeclareOptionX{nomath}[true]{\@nameuse{firamath@nomath#1}}

\DeclareOptionX{tabular}[true]{\@nameuse{firamath@tabular#1}}
\DeclareOptionX{t}[true]{\@nameuse{firamath@tabular#1}}
\DeclareOptionX{proportional}[true]{\@nameuse{if#1}\firamath@tabularfalse\else\firamath@tabulartrue\fi}
\DeclareOptionX{p}[true]{\@nameuse{if#1}\firamath@tabularfalse\else\firamath@tabulartrue\fi}

\newcommand*\firamath@scale{1}  
\DeclareOptionX{Scale}{\renewcommand*{\firamath@scale}{#1}}

\def\firamath@defaultfeatures{}
\DeclareOptionX{defaultfeatures}{\def\firamath@defaultfeatures{#1}}

\DeclareOptionX*{\PassOptionsToPackage{\CurrentOption}{unicode-math}}% added 20230111 hv

\ProcessOptionsX\relax

\RequirePackage{unicode-math}

\iffiramath@fakebold\RequirePackage{xfakebold}\fi
\iffiramath@lining
    \def\firamath@figurestyle{Lining}
\else
    \def\firamath@figurestyle{OldStyle}
\fi

\iffiramath@tabular
    \def\firamath@figurealign{Monospaced} 
\else
    \def\firamath@figurealign{Proportional} 
\fi

\ifxetex\XeTeXtracingfonts=1\fi
\defaultfontfeatures{\firamath@defaultfeatures}

\iffiramath@usefilenames
  \setmathfont{FiraMath-\fira@weight.otf}[
     Scale=\firamath@scale,
     Numbers={\firamath@figurestyle,\firamath@figurealign},
%     BoldFont=FiraMath-Medium.otf
  ]
  \setmathfont[version=pnum,Numbers=Proportional,Scale=\firamath@scale]{FiraMath-Regular.otf}

\else
  \setmathfont{Fira Math Regular}[
     Scale=\firamath@scale,
     Numbers={\firamath@figurestyle,\firamath@figurealign},
%     BoldFont=Fira Math Medium
  ]
  \setmathfont[version=pnum,Numbers=Proportional,Scale=\firamath@scale]{Fira Math Regular}
\fi


\endinput