%% Extended support for STIXTwo fonts.
%% Alexey Kuznetsov (mailtokuznetsov@gmail.com)
%% 
%%  This file 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.

\ProvidesPackage{xstix2}[2026/02/28]
\PackageInfo{xstix2}{Extended support for STIXTwo fonts.} 

\def\@STIX@{XSTIX2}
\def\@STIX@Main{XSTIX2}
\def\@STIX@Bold{XSTIX2Bold}

\DeclareOption{original}{\def\@STIX@{STIX2}}
\DeclareOption{bold}{\def\@STIX@Bold{\@STIX@ SemiBold}\def\@STIX@Main{\@STIX@ B}}
\DeclareOption*{\PackageWarning{xstix2.sty}{Package options: original, bold.}}
\ProcessOptions

\RequirePackage{iftex}
\iftutex
   \RequirePackage[quiet]{fontspec}
   \RequirePackage{unicode-math}
   \IfFontExistsTF{STIXTwoText-Regular}{
      \setmainfont{\@STIX@Main}
      \newfontfamily\STIXBold{\@STIX@Bold}
      \newfontfamily\STIXMedium{\@STIX@ Medium}
      \IfFontExistsTF{STIXTwoMath-Regular}{
         \setmathfont{STIX Two Math}
         \IfFontExistsTF{XITSMath-Bold}
            { \setmathfont{XITSMath-Bold}[version=bold, Scale= MatchLowercase] 
              \setoperatorfont\symup }
            { \PackageWarning{xstix2.sty}{Install `xits' package to add bold math font.} }
      }{ \PackageWarning{xstix2.sty}{Install `stix2-otf' package to use STIXTwo math font.} }
   }{ \PackageWarning{xstix2.sty}{Install `stix2-otf' package to use STIXTwo fonts.} }
\else
   \PackageWarning{xstix2.sty}{STIXTwo fonts must be used with `LuaLaTeX' or `XeLaTeX'.}
\fi
