\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{bitter}
    [200/07/25 (R.D. Tennent)  Supports Bitter fonts for xeLaTeX and luaLaTeX.]

\RequirePackage{iftex}

\ifpdftex
\PackageError{bitter}{%
 *****************************************\MessageBreak
  Please process using XeLaTeX or luaLaTeX\MessageBreak
 *****************************************}
\fi  


\newcommand*{\Bitter@scale}{1}  
\RequirePackage{xkeyval}
\DeclareOptionX{scaled}{\renewcommand*{\Bitter@scale}{#1}}
\DeclareOptionX{scale}{\renewcommand*{\Bitter@scale}{#1}}

\ProcessOptionsX\relax

  \RequirePackage{fontspec}

  \ifxetex\XeTeXtracingfonts=1\fi
  \defaultfontfeatures{
     Ligatures = TeX ,
     Extension = .ttf ,
     Scale     = \Bitter@scale ,
  }
  \setmainfont
      [ UprightFont    = *-Regular ,
        ItalicFont     = *-Italic ,
        BoldFont       = *-Bold , 
      ]
      {Bitter}
  % grab current family in case of subsequent change:
  \let\Bitterfamily\rmdefault 

  \newfontfamily\bitter
      [ UprightFont    = *-Regular ,
        ItalicFont     = *-Italic ,
        BoldFont       = *-Bold , 
      ]
      {Bitter}

% turn off defaults in case other fonts are selected:
  \defaultfontfeatures{}

\endinput

