\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{GoSans}
    [2017/04/02 (Bob Tennent and autoinst)  Style file for Go Sans fonts.]

\RequirePackage{ifxetex,ifluatex,xkeyval,textcomp}

\newif\ifgo@ttf 
\ifxetex
  \go@ttftrue
\else\ifluatex
  \go@ttftrue
\else  % [pdf]LaTeX
  \go@ttffalse
\fi\fi

\newif\ifgo@medium  \go@mediumfalse
\newif\ifgo@default \go@defaultfalse

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

\DeclareOptionX{medium}{\go@mediumtrue}
\DeclareOptionX{default}{\go@defaulttrue}
\DeclareOptionX{sfdefault}{\go@defaulttrue}


\ProcessOptionsX

\ifgo@ttf

  \def\go@boldstyle{Bold}
  \def\go@regstyle{Regular}
  \ifgo@medium\def\go@boldstyle{Medium}\fi

\else % type1

  \def\bfseries@sf{b}
  \def\mdseries@sf{m}
  \ifgo@medium\def\bfseries@sf{mb}\fi
  
\fi


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

\ifgo@ttf
  \ifxetex\XeTeXtracingfonts=1\fi
  \defaultfontfeatures{
        Ligatures = TeX ,
        Scale     = \Go@scale ,
        Extension = .ttf }
  \setsansfont
      [ UprightFont    = *-Regular ,
        ItalicFont     = *-Regular-Italic ,
        BoldFont    = *-\go@boldstyle ,
        BoldItalicFont     = *-\go@boldstyle-Italic ,
        SmallCapsFont = {GoSmallcaps},
        ItalicFeatures = {SmallCapsFont=GoSmallcaps-Italic},
        FontFace = {mb}{n}{Font=*-Medium},
        FontFace = {mb}{it}{Font=*-Medium-Italic},
        FontFace = {b}{n}{Font=*-Bold},
        FontFace = {b}{it}{Font=*-Bold-Italic},
      ]
      {Go}
  % grab current family in case of subsequent change:
  \let\gofamily\sfdefault  
  \ifgo@default\renewcommand*\familydefault{\gofamily}\fi

\else % type1

  \def\gofamily{Go-TLF}
  \renewcommand*\sfdefault{\gofamily}
  \ifgo@default\edef\familydefault{\sfdefault}\edef\seriesdefault{\mdseries@sf}\fi


\fi

\def\gomedium{\fontfamily{\gofamily}\fontseries{mb}\selectfont}
\def\gobold{\fontfamily{\gofamily}\fontseries{b}\selectfont}

\ifgo@ttf
  \defaultfontfeatures{}
\fi

\endinput
