\ProvidesPackage{garamondx}[2013/04/22 GaramondNo8 with expert features (Michael Sharpe)]
\RequirePackage{keyval}
\usepackage[T1]{fontenc}
\RequirePackage{fontaxes}% so we can have [bold] italic small caps
\RequirePackage{textcomp}

\newif\ifzgm@osf
\newif\ifzgm@osfI
\newif\ifzgm@swq
\define@key{Zgm}{swashQ}[true]{%
  \def\zgm@swqval{#1}\csname zgm@swq#1\endcsname}
\define@key{Zgm}{scaled}[0.95]{%
  \def\zgm@Scale{#1}}
\define@key{Zgm}{osf}[true]{%
  \csname zgm@osf#1\endcsname}
\define@key{Zgm}{osfI}[true]{%
  \csname zgm@osf#1\endcsname \csname zgm@osfI#1\endcsname%
  \def\zgm@osfIval{#1}}
\def\ProcessOptionsWithKV#1{%
  \let\@tempc\relax
  \let\Zgm@tempa\@empty
  \@for\CurrentOption:=\@classoptionslist\do{%
    \@ifundefined{KV@#1@\CurrentOption}%
    {}%
    {%
      \edef\Zgm@tempa{\Zgm@tempa,\CurrentOption,}%
      \@expandtwoargs\@removeelement\CurrentOption
        \@unusedoptionlist\@unusedoptionlist
    }%
  }%
  \edef\Zgm@tempa{%
    \noexpand\setkeys{#1}{%
      \Zgm@tempa\@ptionlist{\@currname.\@currext}%
    }%
  }%
  \Zgm@tempa
  \let\CurrentOption\@empty
}
\ProcessOptionsWithKV{Zgm}
\AtEndOfPackage{%
  \let\@unprocessedoptions\relax
}

\def\useosf{\zgm@osftrue \def\zgm@osfIval{false}%
  \renewcommand*{\rmdefault}{zgmj}}
\def\useosfI{\zgm@osftrue \def\zgm@osfIval{true}
  \renewcommand*{\rmdefault}{zgmj}}
\@onlypreamble\useosf
\@onlypreamble\useosfI
  
\newcommand{\textlf}[1]{{\fontfamily{zgmx}\selectfont #1}}% to get zgm lf
\newcommand{\textosf}[1]{\oldstylenums{#1}}% to get zgm osf
\newcommand{\textosfI}[1]{{\fontfamily{zgmI}\selectfont #1}}% to get zgm osfI
\renewcommand*{\bfdefault}{b}
\renewcommand*{\scdefault}{sc}% for better compatibility with mathdesign
% set NewG8-sups as footnote markers---may also use superiors for more options
%\DeclareFontFamily{T1}{zgm1}{}%
%  \DeclareFontShape{T1}{zgm1}{m}{n}{%
%    <-> NewG8-sups}{}
%\DeclareRobustCommand{\sustyle}{%
%  \not@math@alphabet\sustyle\relax
%  \usefont{T1}{zgm1}{m}{n}}

%\def\textsu#1{\hbox{{\sustyle#1}}}
%
%\def\@makefnmark{\hbox{\textsu{\@thefnmark}}}

% The following are provided so that we may access swash Q and osfI in any mode
\expandafter\ifx\csname zgm@Scale\endcsname\relax
 \let\zgm@@@Scale\@empty
\else
 \edef\zgm@@@Scale{s*[\csname zgm@Scale\endcsname]}%
\fi
\DeclareFontFamily{T1}{zgmI}{}

\DeclareFontShape{T1}{zgmI}{m}{n}{
   <-> \zgm@@@Scale  T1-zgm-r-osfI
}{}
\DeclareFontShape{T1}{zgmI}{m}{it}{
   <-> \zgm@@@Scale  T1-zgm-ri-osfI
}{}
\DeclareFontShape{T1}{zgmI}{b}{n}{
   <-> \zgm@@@Scale  T1-zgm-b-osfI
}{}
\DeclareFontShape{T1}{zgmI}{b}{it}{
   <-> \zgm@@@Scale  T1-zgm-bi-osfI
}{}

\DeclareFontFamily{T1}{zgmq}{}

\DeclareFontShape{T1}{zgmq}{m}{n}{
   <-> \zgm@@@Scale  T1-zgm-r-lf-swq
}{}
\DeclareFontShape{T1}{zgmq}{m}{it}{
   <-> \zgm@@@Scale  T1-zgm-ri-lf-swq
}{}
\DeclareFontShape{T1}{zgmq}{b}{n}{
   <-> \zgm@@@Scale  T1-zgm-b-lf-swq
}{}
\DeclareFontShape{T1}{zgmq}{b}{it}{
   <-> \zgm@@@Scale  T1-zgm-bi-lf-swq
}{}
\newcommand{\swashQ}{{\fontfamily{zgmq}\selectfont Q}}

\ifzgm@osf
  \renewcommand*{\rmdefault}{zgmj}
\else
  \renewcommand*{\rmdefault}{zgmx}
\fi  
\normalfont
\endinput
%%
%% End of file `garamondx.sty'.
