\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{overlock}
    [2019/10/15 (Bob Tennent)  Supports Overlock fonts for all LaTeX engines.]

\RequirePackage{ifxetex,ifluatex,xkeyval,textcomp}

\newif\ifoverlock@ttf 
\ifxetex
  \overlock@ttftrue
\else\ifluatex
  \overlock@ttftrue
\else  % [pdf]LaTeX
  \overlock@ttffalse
\fi\fi

\newif\ifoverlock@default \overlock@defaultfalse
\newif\ifoverlock@black \overlock@blackfalse

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

\DeclareOptionX{default}{\overlock@defaulttrue}
\DeclareOptionX{sfdefault}{\overlock@defaulttrue}
\DeclareOptionX{type1}{\overlock@ttffalse}
\DeclareOptionX{black}{\overlock@blacktrue}

\ProcessOptionsX\relax

\ifoverlock@ttf
  \def\overlock@boldstyle{Bold}
  \ifoverlock@black\def\overlock@boldstyle{Black}\fi

\else % type1

  \def\bfseries@sf{b}
  \ifoverlock@black\def\bfseries@sf{eb}\fi
\fi

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

\ifoverlock@ttf
  \ifxetex\XeTeXtracingfonts=1\fi
  \defaultfontfeatures{
        Ligatures = TeX ,
        Scale     = \Overlock@scale ,
        Extension = .ttf }
  \setsansfont
      [ UprightFont    = *-Regular ,
        ItalicFont     = *-Italic ,
        BoldFont       = *-\overlock@boldstyle , 
        SmallCapsFont = {OverlockSC-Regular},
        BoldItalicFont = *-\overlock@boldstyle Italic ]
      {Overlock}
  % grab current family in case of subsequent change:
  \let\overlockfamily\sfdefault  
  \newfontfamily\overlock
      [ UprightFont    = *-Regular ,
        ItalicFont     = *-Italic ,
        BoldFont       = *-\overlock@boldstyle , 
        SmallCapsFont = {OverlockSC-Regular},
        BoldItalicFont = *-\overlock@boldstyle Italic ]
      {Overlock}
  \newfontfamily\overlockBlack
      [ UprightFont    = *-Black ,
        ItalicFont     = *-BlackItalic ,
        BoldFont       = *-Black , 
        BoldItalicFont = *-BlackItalic ]
      {Overlock}
  \def\sffamily{\overlock}
  \ifoverlock@default
    \edef\familydefault{\overlockfamily}
  \fi
\else % type1
  \def\overlockfamily{Overlock-LF}
  \def\sfdefault{\overlockfamily}
  \def\sffamily{\fontfamily{\overlockfamily}\selectfont}
  \def\overlock{\fontfamily{\overlockfamily}\selectfont}
  \def\overlockBlack{\fontfamily{\overlockfamily}\fontseries{eb}\selectfont}
  \ifoverlock@default\def\familydefault{\sfdefault}
  \fi
  
\fi


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

\endinput
