\ProvidesPackage{marcellus}[%
   2019/09/18 (Bob Tennent)  Supports Marcellus fonts for all LaTeX engines. ] 

\RequirePackage{ifxetex,ifluatex,textcomp}

\newif\ifmarcellus@ttf
\ifxetex
  \marcellus@ttftrue
\else\ifluatex
  \marcellus@ttftrue
\else  % [pdf]LaTeX
  \marcellus@ttffalse
\fi\fi

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

\DeclareOptionX{type1}{\marcellus@ttffalse}

\ProcessOptionsX\relax

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

\ifmarcellus@ttf
  \ifxetex\XeTeXtracingfonts=1\fi
  \defaultfontfeatures{
     Ligatures = TeX ,
     Extension = .ttf ,
  }
  \setmainfont
      [ UprightFont    = *-Regular ,
        BoldFont       = *-Regular,
        SmallCapsFont = {MarcellusSmallCaps}
      ]
      {Marcellus}
  \newfontfamily\marcellus
      [ UprightFont    = *-Regular ,
        BoldFont       = *-Regular,
        SmallCapsFont = {MarcellusSmallCaps}
      ]
      {Marcellus}

\else % type1

  \def\mdseries@rm{regular}
  \def\bfseries@rm{regular}
  \def\marcellusfamily{Marcellus-LF}
  \renewcommand*\rmdefault{\marcellusfamily}
  \newcommand*\marcellus{\fontfamily{\marcellusfamily}\selectfont}

\fi

% turn off defaults in case other fonts are selected:
\ifmarcellus@ttf
  \defaultfontfeatures{}
\fi

\endinput

