\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{coelacanth}
    [2017/09/10 (Bob Tennent and autoinst)  Style file for Coelacanth fonts.]

\RequirePackage{ifxetex,ifluatex,xkeyval,textcomp}

\newif\ifcoelacanth@otf 
\ifxetex
  \coelacanth@otftrue
\else\ifluatex
  \coelacanth@otftrue
\else  % [pdf]LaTeX
  \coelacanth@otffalse
\fi\fi

\newif\ifcoelacanth@lining \coelacanth@liningfalse
\newif\ifcoelacanth@tabular \coelacanth@tabularfalse

\newif\ifcoelacanth@light \coelacanth@lightfalse
\newif\ifcoelacanth@extralight \coelacanth@extralightfalse
\newif\ifcoelacanth@semibold \coelacanth@semiboldfalse
\newif\ifcoelacanth@heavy \coelacanth@heavyfalse

\newcommand*{\Coelacanth@scale}{1}
\RequirePackage{xkeyval}
\DeclareOptionX{scaled}{\renewcommand*{\Coelacanth@scale}{#1}}
\DeclareOptionX{scale}{\renewcommand*{\Coelacanth@scale}{#1}}
\DeclareOptionX{type1}{\coelacanth@otffalse}
\DeclareOptionX{lining}{\coelacanth@liningtrue}
\DeclareOptionX{nf}{\coelacanth@liningtrue}
\DeclareOptionX{lf}{\coelacanth@liningtrue}
\DeclareOptionX{oldstyle}{\coelacanth@liningfalse}
\DeclareOptionX{osf}{\coelacanth@liningfalse}
\DeclareOptionX{tabular}{\coelacanth@tabulartrue}
\DeclareOptionX{t}{\coelacanth@tabulartrue}
\DeclareOptionX{proportional}{\coelacanth@tabularfalse}
\DeclareOptionX{p}{\coelacanth@tabularfalse}
\DeclareOptionX{l}{\coelacanth@lighttrue}
\DeclareOptionX{el}{\coelacanth@extralighttrue}
\DeclareOptionX{sb}{\coelacanth@semiboldtrue}
\DeclareOptionX{h}{\coelacanth@heavytrue}


\ExecuteOptionsX{oldstyle,proportional}
\ProcessOptionsX\relax

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

\ifcoelacanth@otf
  \ifcoelacanth@lining
    \def\coelacanth@figurestyle{Lining}
  \else
    \def\coelacanth@figurestyle{OldStyle} 
  \fi
  \ifcoelacanth@tabular
    \def\coelacanth@figurealign{Monospaced} 
  \else
    \def\coelacanth@figurealign{Proportional} 
  \fi
\else % type1
  \ifcoelacanth@lining
    \def\coelacanth@figurestyle{LF}
  \else
    \def\coelacanth@figurestyle{OsF}
  \fi
  \ifcoelacanth@tabular
    \def\coelacanth@figurealign{T}
  \else
    \def\coelacanth@figurealign{}
  \fi
\fi

\ifcoelacanth@otf
  \ifcoelacanth@light
    \def\coelacanth@regularstyle{Lt}
  \else\ifcoelacanth@extralight
    \def\coelacanth@regularstyle{ExtraLt}
  \else
    \def\coelacanth@regularstyle{}
  \fi\fi
\else % type1
  \def\mdseries@rm{m}
  \ifcoelacanth@light
    \def\mdseries@rm{l}
  \else\ifcoelacanth@extralight
    \def\mdseries@rm{el}
  \fi\fi
\fi


\ifcoelacanth@otf
  \ifcoelacanth@semibold
    \def\coelacanth@boldstyle{Semibd}
  \else\ifcoelacanth@heavy
    \def\coelacanth@boldstyle{Heavy}
  \else
    \def\coelacanth@boldstyle{Bold}
  \fi\fi
\else % type1
  \def\bfseries@rm{b}
  \ifcoelacanth@semibold
    \def\bfseries@rm{sb}
  \else\ifcoelacanth@heavy
    \def\bfseries@rm{h}
  \fi\fi
\fi
   

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

\ifcoelacanth@otf
  \ifxetex\XeTeXtracingfonts=1\fi
  \defaultfontfeatures{
        Ligatures = TeX ,
        Scale     = \Coelacanth@scale ,
        SmallCapsFeatures={\ifluatex Renderer=Basic\fi},
        Extension = .otf }
  \setmainfont
      [ Numbers = {\coelacanth@figurealign,\coelacanth@figurestyle},
        UprightFont    = *\coelacanth@regularstyle ,
        ItalicFont     = *Italic ,
        BoldFont    = *\coelacanth@boldstyle ,
        BoldItalicFont     = *Italic ,
      ]
      {Coelacanth}
  \newfontfamily\coelacanth
      [ Numbers = {\coelacanth@figurealign,\coelacanth@figurestyle},
        UprightFont    = *\coelacanth@regularstyle ,
        ItalicFont     = *Italic ,
        BoldFont    = *\coelacanth@boldstyle ,
        BoldItalicFont     = *Italic ,
      ]
      {Coelacanth}
  \newfontfamily\coelacanthOsF
      [ Numbers = {\coelacanth@figurealign,OldStyle},
        UprightFont    = *\coelacanth@regularstyle ,
        ItalicFont     = *Italic ,
        BoldFont    = *\coelacanth@boldstyle ,
        BoldItalicFont     = *Italic ,
      ]
      {Coelacanth}
  \newfontfamily\coelacanthLF
      [ Numbers = {\coelacanth@figurealign,Lining},
        UprightFont    = *\coelacanth@regularstyle ,
        ItalicFont     = *Italic ,
        BoldFont    = *\coelacanth@boldstyle ,
        BoldItalicFont     = *Italic ,
      ]
      {Coelacanth}
  \DeclareTextFontCommand{\oldstylenums}{\coelacanthOsF}
  \DeclareTextFontCommand{\liningnums}{\coelacanthLF}

\else % type1

  \def\coelacanth@family{Coelacanth-\coelacanth@figurealign\coelacanth@figurestyle}
  \renewcommand*\rmdefault{\coelacanth@family}
  \newcommand*\coelacanth{\fontfamily{\coelacanth@family}\selectfont}

  \DeclareTextFontCommand{\oldstylenums}{\fontfamily{Coelacanth-\coelacanth@figurealign OsF}\selectfont}
  \DeclareTextFontCommand{\liningnums}{\fontfamily{Coelacanth-\coelacanth@figurealign LF}\selectfont}

\fi

\ifcoelacanth@otf
  \newfontfamily\coelacanthtabular
    [ Numbers = {Monospaced,\coelacanth@figurestyle},
        UprightFont    = *\coelacanth@regularstyle ,
        ItalicFont     = *Italic ,
        BoldFont    = *\coelacanth@boldstyle ,
        BoldItalicFont     = *Italic ,
      ]
      {Coelacanth}
  \newfontfamily\coelacanthproportional
    [ Numbers = {Proportional,\coelacanth@figurestyle},
        UprightFont    = *\coelacanth@regularstyle ,
        ItalicFont     = *Italic ,
        BoldFont    = *\coelacanth@boldstyle ,
        BoldItalicFont     = *Italic ,
      ]
      {Coelacanth}
  \DeclareTextFontCommand{\tabularnums}{\coelacanthtabular}
  \DeclareTextFontCommand{\proportionalnums}{\coelacanthproportional}
\else % type1
  \DeclareTextFontCommand{\tabularnums}{\fontfamily{Coelacanth-T\coelacanth@figurestyle}\selectfont}
  \DeclareTextFontCommand{\proportionalnums}{\fontfamily{Coelacanth-\coelacanth@figurestyle}\selectfont}
\fi

\ifcoelacanth@otf
  \defaultfontfeatures{}
\fi

\endinput
