\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{arimo}
    [2017/01/04 (Bob Tennent)  Supports Arimo fonts for all LaTeX engines.]

\RequirePackage{ifxetex,ifluatex,xkeyval,textcomp}

\newif\ifarimo@otf 
\ifxetex
  \arimo@otftrue
\else\ifluatex
  \arimo@otftrue
\else  % [pdf]LaTeX
  \arimo@otffalse
\fi\fi

\newif\ifarimo@default \arimo@defaultfalse

\newcommand*{\Arimo@scale}{1}
\DeclareOptionX{scaled}{\renewcommand*{\Arimo@scale}{#1}}
\DeclareOptionX{scale}{\renewcommand*{\Arimo@scale}{#1}}

\DeclareOptionX{sfdefault}{\arimo@defaulttrue}
\DeclareOptionX{type1}{\arimo@otffalse}

\ProcessOptionsX\relax

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

\ifarimo@otf
  \ifxetex\XeTeXtracingfonts=1\fi
  \defaultfontfeatures{
        Ligatures = TeX ,
        Scale     = \Arimo@scale ,
        Extension = .otf }
  \setsansfont
      [ UprightFont    = *-Regular ,
        ItalicFont     = *-Italic ,
        BoldFont       = *-Bold , 
        BoldItalicFont = *-BoldItalic ]
      {Arimo}
  % grab current family in case of subsequent change:
  \let\arimofamily\sfdefault  
  \ifarimo@default\renewcommand*\familydefault{\arimofamily}\fi
  \newfontfamily\arimo
      [ UprightFont    = *-Regular ,
        ItalicFont     = *-Italic ,
        BoldFont       = *-Bold , 
        BoldItalicFont = *-BoldItalic ]
      {Arimo}
\else % type1
  \def\arimofamily{Arimo-TLF}
  \newcommand*\arimo{\fontfamily{\arimofamily}\selectfont}
  \def\sfdefault{\arimofamily}
  \ifarimo@default\edef\familydefault{\sfdefault}\fi
\fi

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

\endinput
