\ProvidesPackage{librebaskerville}[%
   2012/12/01 (Bob Tennent)  Supports LibreBaskerville fonts for all LaTeX engines. ] 

\RequirePackage{ifxetex,ifluatex,textcomp}

\newif\iflibrebaskerville@otf
\ifxetex
  \librebaskerville@otftrue
\else\ifluatex
  \librebaskerville@otftrue
\else  % [pdf]LaTeX
  \librebaskerville@otffalse
\fi\fi

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

\DeclareOptionX{type1}{\librebaskerville@otffalse}

\ProcessOptionsX\relax

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

\iflibrebaskerville@otf
  \ifxetex\XeTeXtracingfonts=1\fi
  \defaultfontfeatures{
     Ligatures = TeX ,
     Extension = .otf ,
  }
  \setmainfont
      [ UprightFont    = *-Regular ,
        ItalicFont     = *-Italic ,
        BoldFont       = *-Bold , 
        BoldItalicFont = *-BoldItalic ]
      {LibreBaskerville}
  \newfontfamily\librebaskerville
      [ UprightFont    = *-Regular ,
        ItalicFont     = *-Italic ,
        BoldFont       = *-Bold , 
        BoldItalicFont = *-BoldItalic ]
      {LibreBaskerville}
  \providecommand\sufigures{\addfontfeatures{VerticalPosition=Superior}}


\else % type1

  \fa@naming@exception{figures}{{superior}{proportional}}{Sup}
  \fa@naming@exception{figures}{{superior}{tabular}}{Sup}
  \providecommand\sufigures{\@nomath\sufigures\fontfigurestyle{superior}\selectfont}
  \def\librebaskervillefamily{LibreBaskerville-TLF}
  \renewcommand*\rmdefault{\librebaskervillefamily}
  \newcommand*\librebaskerville{\fontfamily{\librebaskervillefamily}\selectfont}

\fi
\DeclareTextFontCommand{\textsu}{\sufigures}

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

\endinput

