\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{linguisticspro}
    [2019/05/11 (Bob Tennent and autoinst)  Style file for LinguisticsPro fonts.]

\RequirePackage{ifxetex,ifluatex,xkeyval,textcomp}

\newif\iflinguisticspro@otf 
\ifxetex
  \linguisticspro@otftrue
\else\ifluatex
  \linguisticspro@otftrue
\else  % [pdf]LaTeX
  \linguisticspro@otffalse
\fi\fi

\newcommand*{\LinguisticsPro@scale}{1}
\newcommand*{\LinguisticsProInitials@scale}{1}
\RequirePackage{xkeyval}
\DeclareOptionX{scaled}{\renewcommand*{\LinguisticsPro@scale}{#1}\renewcommand*{\LinguisticsProInitials@scale}{#1}}
\DeclareOptionX{scale}{\renewcommand*{\LinguisticsPro@scale}{#1}\renewcommand*{\LinguisticsProInitials@scale}{#1}}
\DeclareOptionX{type1}{\linguisticspro@otffalse}

\ProcessOptionsX\relax

\iflinguisticspro@otf
  \def\linguisticspro@figurestyle{OldStyle} 
    
\else % type1
  \def\linguisticspro@figurestyle{OsF}
  \def\mdseries@rm{regular}
  \def\seriesdefault{\mdseries@rm}
  \def\bfseries@rm{bold}

\fi

\iflinguisticspro@otf
  \RequirePackage{fontspec}
\else
  \RequirePackage{fontenc,fontaxes,mweights}
\fi

\iflinguisticspro@otf
  \ifxetex\XeTeXtracingfonts=1\fi
  \defaultfontfeatures{
        Ligatures = TeX ,
        Scale     = \LinguisticsPro@scale ,
        Extension = .otf }
  \setmainfont
      [ Numbers = {\linguisticspro@figurestyle},
        UprightFont    = *-Regular ,
        ItalicFont     = *-Italic,
        BoldFont    = *-Bold ,
        BoldItalicFont     = *-BoldItalic ,
      ]
      {LinguisticsPro}
  \newfontfamily\linguisticspro
      [ Numbers = {\linguisticspro@figurestyle},
        UprightFont    = *-Regular ,
        ItalicFont     = *-Italic,
        BoldFont    = *-Bold ,
        BoldItalicFont     = *-BoldItalic ,
      ]
      {LinguisticsPro}

\else % type1

  \def\linguisticspro@family{LinguisticsPro-T\linguisticspro@figurestyle}
  \renewcommand*\rmdefault{\linguisticspro@family}
  \newcommand*\linguisticspro{\fontfamily{\linguisticspro@family}\selectfont}

\fi

\def\linguisticsprolgr{\fontencoding{LGR}\fontfamily{LinguisticsPro-TOsF}\selectfont}  

\iflinguisticspro@otf
  \defaultfontfeatures{}
\fi

\endinput
