\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{TheanoOldStyle}
    [2022/09/26 (Bob Tennent and autoinst)  Style file for Theano OldStyle fonts.]

\RequirePackage{ifxetex,ifluatex,xkeyval,textcomp}

\newif\iftheanooldstyle@ttf 
\ifxetex
  \theanooldstyle@ttftrue
\else\ifluatex
  \theanooldstyle@ttftrue
\else  % [pdf]LaTeX
  \theanooldstyle@ttffalse
 \fi\fi  
  
\RequirePackage{fontaxes}

\newcommand*{\TheanoOldStyle@scale}{1}
\RequirePackage{xkeyval}
\DeclareOptionX{scaled}{\renewcommand*{\TheanoOldStyle@scale}{#1}}
\DeclareOptionX{scale}{\renewcommand*{\TheanoOldStyle@scale}{#1}}
\DeclareOptionX{type1}{\theanooldstyle@ttffalse}

\newif\iftheanooldstyle@lining \theanooldstyle@liningtrue
\DeclareOptionX{osf}{\theanooldstyle@liningfalse}
\DeclareOptionX{oldstyle}{\theanooldstyle@liningfalse}

\ProcessOptionsX\relax

\iftheanooldstyle@ttf
  \RequirePackage{fontspec}
  \iftheanooldstyle@lining
     \def\theanooldstyle@figurealign{}
  \else
     \def\theanooldstyle@figurealign{OldStyle}
  \fi
\else
  \RequirePackage{fontenc,fontaxes}
  \iftheanooldstyle@lining
     \def\theanooldstyle@figurealign{LF}
  \else
     \def\theanooldstyle@figurealign{OsF}
  \fi
\fi

\iftheanooldstyle@ttf
  \defaultfontfeatures{
        Ligatures = TeX ,
        Scale     = \TheanoOldStyle@scale ,
        Extension = .ttf }
  \setmainfont
      [ Numbers={\theanooldstyle@figurealign},
        UprightFont    = *-Regular ,
        BoldFont    = *-Bold ,
      ]
      {TheanoOldStyle}
  \newfontfamily\theanooldstyle
      [ Numbers={\theanooldstyle@figurealign},
        UprightFont    = *-Regular ,
        BoldFont    = *-Bold ,
      ]
      {TheanoOldStyle}
  \newfontfamily\theanooldstyleosf
      [ Numbers={OldStyle},
        UprightFont    = *-Regular ,
        BoldFont    = *-Bold ,
      ]
      {TheanoOldStyle}
  \newfontfamily\theanooldstylelf
      [ Numbers={},
        UprightFont    = *-Regular ,
        BoldFont    = *-Bold ,
      ]
      {TheanoOldStyle}

\else % type1

  \def\theanooldstyle@family{TheanoOldStyle-T\theanooldstyle@figurealign}
  \renewcommand*\rmdefault{\theanooldstyle@family}
  \newcommand*\theanooldstyle{\fontfamily{\theanooldstyle@family}\selectfont}
  \newcommand*\theanooldstyleosf{\fontfamily{TheanoOldStyle-TOsF}\selectfont}
  \newcommand*\theanooldstylelf{\fontfamily{TheanoOldStyle-TLF}\selectfont}

\fi

\def\theanooldstylelgr{\fontencoding{LGR}\fontfamily{TheanoOldStyle-TLF}\selectfont}

\iftheanooldstyle@ttf
  \defaultfontfeatures{}
\fi

\endinput
