%\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{fontsetup}[Easy font setup by Antonis Tsolomitis]
\typeout{fontsetup: Easy font setup by Antonis Tsolomitis}

\chardef\fontsetupdefault=0 %
\chardef\fontsetupgfsartemisia=1
\chardef\fontsetupgfsdidot=2
\chardef\fontsetupgfsdidotclassic=3
\chardef\fontsetupgfsneohellenic=4
\chardef\fontsetupcambria=5 %install cambria as a system font. cambria.ttc, cambriai.ttf, cambriab.ttf, cambriaz.ttf
\chardef\fontsetuplucida=6 %install in TeX tree
\chardef\fontsetupkerkis=7
\chardef\fontsetupfira=8 
\chardef\fontsetuptimes=9
\chardef\fontsetuppalatino=10 %install Linotype Palatino as a System font. Files pala.ttf palai, palab, palabi. Install fspPalatinoGreekSmallCaps as a System font.
\chardef\fontsetupstixtwo=11
\chardef\fontsetupneokadmus=12
\chardef\fontsetupmsgaramond=13 %install Microsoft Garamond as a System font. Gara.TTF, Garai, Garabd
\chardef\fontsetupebgaramond=14
\chardef\fontsetupminion=15 % Install MinionPro and provided fspMinionGreekSmallCaps as a system font.
\chardef\fontsetupneoeuler=16
\chardef\fontsetuplibertinus=17
\chardef\fontsetupolddefault=18 % old (thin) CMR

\chardef\fontsetupfont\fontsetupdefault
\DeclareOption{default}{\chardef\fontsetupfont\fontsetupdefault}
\DeclareOption{gfsartemisia}{\chardef\fontsetupfont\fontsetupgfsartemisia}
\DeclareOption{gfsdidot}{\chardef\fontsetupfont\fontsetupgfsdidot}
\DeclareOption{gfsdidotclassic}{\chardef\fontsetupfont\fontsetupgfsdidotclassic}
\DeclareOption{gfsneohellenic}{\chardef\fontsetupfont\fontsetupgfsneohellenic}
\DeclareOption{cambria}{\chardef\fontsetupfont\fontsetupcambria}
\DeclareOption{lucida}{\chardef\fontsetupfont\fontsetuplucida}
\DeclareOption{kerkis}{\chardef\fontsetupfont\fontsetupkerkis}
\DeclareOption{fira}{\chardef\fontsetupfont\fontsetupfira}
\DeclareOption{times}{\chardef\fontsetupfont\fontsetuptimes}
\DeclareOption{palatino}{\chardef\fontsetupfont\fontsetuppalatino}
\DeclareOption{stixtwo}{\chardef\fontsetupfont\fontsetupstixtwo}
\DeclareOption{neokadmus}{\chardef\fontsetupfont\fontsetupneokadmus}
\DeclareOption{msgaramond}{\chardef\fontsetupfont\fontsetupmsgaramond}
\DeclareOption{ebgaramond}{\chardef\fontsetupfont\fontsetupebgaramond}
\DeclareOption{minion}{\chardef\fontsetupfont\fontsetupminion}
\DeclareOption{neoeuler}{\chardef\fontsetupfont\fontsetupneoeuler}
\DeclareOption{libertinus}{\chardef\fontsetupfont\fontsetuplibertinus}
\DeclareOption{olddefault}{\chardef\fontsetupfont\fontsetupolddefault}
\DeclareOption*{\PackageWarning{fontsetup}{Unknown ‘\CurrentOption’}}
%
\newif\if@upint
\DeclareOption{upint}{\@upinttrue}
%
\ProcessOptions

%provide a test to know if a 16bits TeX is used.
\RequirePackage{ifthen}
\RequirePackage{iftex}
\newboolean{TeXUnicode}
\ifXeTeX
   \setboolean{TeXUnicode}{true}
\fi
\ifLuaTeX  
   \setboolean{TeXUnicode}{true}
\fi



\ifthenelse{\boolean{TeXUnicode}}{%
  %The user runs unicode engine
  \ifcase\fontsetupfont
  \RequirePackage{fspdefault}
%
\if@upint
\setmathfont[StylisticSet=2]{NewCMMath-Book.otf}
\else
\setmathfont{NewCMMath-Book.otf}
\fi
%
  \or
  \RequirePackage{fspgfsartemisiaot}
\or
  \RequirePackage{fspgfsdidotot}
\or
  \RequirePackage{fspgfsdidotclassicot}
\or
  \RequirePackage{fspgfsneohellenicot}
\or
  \RequirePackage{fspcambria}
\or
   \RequirePackage{fsplucidaot}
%   \RequirePackage[usefilenames]{lucida-otf} %for some reason it fails
\or
  \RequirePackage{fspkerkisot}
\or
  \RequirePackage{fspfiraot}
\or
  \RequirePackage{fsptimesot}
\or
  \RequirePackage{fsppalatinoot}
\or
  \RequirePackage{fspstixtwoot}
\or
  \RequirePackage{neokadmus}
\or
  \RequirePackage{fspmsgaramondot}
\or
  \RequirePackage{fspebgaramondot}
\or
  \RequirePackage{fspminion}
\or
  \RequirePackage{fspneoeulerot}
\or
  \RequirePackage{libertinus-otf}
\or
\RequirePackage{fspolddefault}
%
\if@upint
\setmathfont[StylisticSet=2]{NewCMMath-Regular.otf}
\else
\setmathfont{NewCMMath-Regular.otf}
\fi
%
  \fi
}{%the user runs 8bit engine
\relax}




\endinput

