\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{CharisSIL}
    [2020/07/19 (Bob Tennent and autoinst)  Style file for CharisSIL fonts.]

\RequirePackage{iftex,xkeyval,textcomp}

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

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

\ProcessOptionsX\relax

\ifCharisSIL@ttf
  \RequirePackage{fontspec}
\else
  \RequirePackage{fontenc,fontaxes}
\fi

\ifCharisSIL@ttf
  \ifxetex\XeTeXtracingfonts=1\fi
  \defaultfontfeatures{
        Ligatures = TeX ,
        Scale     = \CharisSIL@scale ,
        Extension = .ttf }
  \setmainfont
      [ UprightFont    = *-R,
        ItalicFont     = *-I,
        BoldFont    = *-B,
        BoldItalicFont    = *-BI ,
      ]
      {CharisSIL}
  \newfontfamily\CharisSIL
      [ UprightFont    = *-R,
        ItalicFont     = *-I,
        BoldFont    = *-B,
        BoldItalicFont    = *-BI ,
      ]
      {CharisSIL}


\else % type1

  \def\CharisSIL@family{CharisSIL-TLF}
  \renewcommand*\rmdefault{\CharisSIL@family}
  \newcommand*\CharisSIL{\fontfamily{\CharisSIL@family}\selectfont}

\fi

\ifCharisSIL@ttf
  \defaultfontfeatures{}
\fi

\endinput
