%% $Id: heros-otf.sty 624 2022-10-13 09:18:22Z herbert $
%%
%% This file is distributed under the terms of the LaTeX Project Public
%% License from CTAN archives in directory  macros/latex/base/lppl.txt.
%% Either version 1.3 or, at your option, any later version.
%%
%
%
\ProvidesPackage{heros-otf}[%
  2022/10/13 v. 0.01 (Herbert Voss) Supports heros fonts for lualatex and xelatex.] 

\RequirePackage{iftex,xkeyval,textcomp}

\newif\ifheros@lining \heros@liningtrue
\newif\ifheros@tabular \heros@tabulartrue
\newif\ifheros@usefilenames \heros@usefilenamestrue
\newif\ifheros@condensed \heros@condensedfalse

\DeclareOptionX{lining}[true]{\@nameuse{heros@lining#1}}
\DeclareOptionX{nf}[true]{\@nameuse{heros@lining#1}}
\DeclareOptionX{lf}[true]{\@nameuse{heros@lining#1}}
\DeclareOptionX{oldstyle}[true]{\@nameuse{if#1}\heros@liningfalse\else\heros@liningtrue\fi}
\DeclareOptionX{osf}[true]{\@nameuse{if#1}\heros@liningfalse\else\heros@liningtrue\fi}

\DeclareOptionX{condensed}{\heros@condensedtrue}
\DeclareOptionX{default}{\renewcommand\familydefault{\sfdefault}}

\DeclareOptionX{usefilenames}[true]{\@nameuse{heros@usefilenames#1}}

\DeclareOptionX{tabular}[true]{\@nameuse{heros@tabular#1}}
\DeclareOptionX{t}[true]{\@nameuse{heros@tabular#1}}
\DeclareOptionX{proportional}[true]{\@nameuse{if#1}\heros@tabularfalse\else\heros@tabulartrue\fi}
\DeclareOptionX{p}[true]{\@nameuse{if#1}\heros@tabularfalse\else\heros@tabulartrue\fi}

\newcommand*\herosSF@scale{1}  
\DeclareOptionX{ScaleSF}{\renewcommand*{\herosSF@scale}{#1}}

\def\heros@defaultfeatures{}
\DeclareOptionX{defaultfeatures}{\def\heros@defaultfeatures{#1}}

\ProcessOptionsX\relax

\RequirePackage{fontspec}

\ifheros@lining
    \def\heros@figurestyle{+lnum;-onum}
\else
    \def\heros@figurestyle{+onum;-lnum}
\fi

\ifheros@tabular
    \def\heros@figurealign{+tnum} 
\else
    \def\heros@figurealign{+pnum} 
\fi

\ifxetex\XeTeXtracingfonts=1\fi
\defaultfontfeatures[\sffamily]{
     Ligatures = TeX ,
     SmallCapsFeatures={Letters=SmallCaps},%       \ifluatex,Renderer=Basic\fi}, 
     \heros@defaultfeatures
}

\ifheros@usefilenames
%------------------------   filenames start -------------------------

%texgyreheros-bold.otf		texgyreheros-italic.otf
%texgyreheros-bolditalic.otf	texgyreheros-regular.otf

\ifheros@condensed
\setsansfont{texgyreheroscn}[ 
  RawFeature     = {\heros@figurealign;\heros@figurestyle},
  Scale          = \herosSF@scale,
  UprightFont    = *-regular,
  ItalicFont     = *-italic,
  ItalicFeatures = { SmallCapsFont = *-italic },
  SlantedFont    = *-regular,
  SlantedFeatures= {FakeSlant=0.2},
  BoldFont       = *-bold,
  BoldFeatures   = { SmallCapsFont = *-bold },
  BoldItalicFont = *-bolditalic,
  BoldItalicFeatures = { SmallCapsFont = *-bolditalic },
  BoldSlantedFont= *-bold,
  BoldSlantedFeatures= {FakeSlant=0.2, SmallCapsFont = *-bold },
  SmallCapsFont  = *-regular,
%  SmallCapsFeatures={RawFeature=+smcp},
  SmallCapsFeatures={Letters=SmallCaps}, 
  Extension      = .otf  
]
\else
\setsansfont{texgyreheros}[ 
  RawFeature     = {\heros@figurealign;\heros@figurestyle},
  Scale          = \herosSF@scale,
  UprightFont    = *-regular,
  ItalicFont     = *-italic,
  ItalicFeatures = { SmallCapsFont = *-italic },
  SlantedFont    = *-regular,
  SlantedFeatures= {FakeSlant=0.2},
  BoldFont       = *-bold,
  BoldFeatures   = { SmallCapsFont = *-bold },
  BoldItalicFont = *-bolditalic,
  BoldItalicFeatures = { SmallCapsFont = *-bolditalic },
  BoldSlantedFont= *-bold,
  BoldSlantedFeatures= {FakeSlant=0.2, SmallCapsFont = *-bold },
  SmallCapsFont  = *-regular,
%  SmallCapsFeatures={RawFeature=+smcp},
  SmallCapsFeatures={Letters=SmallCaps}, 
  Extension      = .otf  
]
\newfontfamily\heroscn{texgyreheroscn}[ 
  RawFeature     = {\heros@figurealign;\heros@figurestyle},
  Scale          = \herosSF@scale,
  UprightFont    = *-regular,
  ItalicFont     = *-italic,
  ItalicFeatures = { SmallCapsFont = *-italic },
  SlantedFont    = *-regular,
  SlantedFeatures= {FakeSlant=0.2},
  BoldFont       = *-bold,
  BoldFeatures   = { SmallCapsFont = *-bold },
  BoldItalicFont = *-bolditalic,
  BoldItalicFeatures = { SmallCapsFont = *-bolditalic },
  BoldSlantedFont= *-bold,
  BoldSlantedFeatures= {FakeSlant=0.2, SmallCapsFont = *-bold },
  SmallCapsFont  = *-regular,
%  SmallCapsFeatures={RawFeature=+smcp},
  SmallCapsFeatures={Letters=SmallCaps}, 
  Extension      = .otf  
]
\fi

\newfontfamily\heros{texgyreheros}[ 
  RawFeature     = {\heros@figurealign;\heros@figurestyle},
  Scale          = \herosSF@scale,
  UprightFont    = *-regular,
  ItalicFont     = *-italic,
  ItalicFeatures = { SmallCapsFont = *-italic },
  SlantedFont    = *-regular,
  SlantedFeatures= {FakeSlant=0.2},
  BoldFont       = *-bold,
  BoldFeatures   = { SmallCapsFont = *-bold },
  BoldItalicFont = *-bolditalic,
  BoldItalicFeatures = { SmallCapsFont = *-bolditalic },
  BoldSlantedFont= *-bold,
  BoldSlantedFeatures= {FakeSlant=0.2, SmallCapsFont = *-bold },
  SmallCapsFont  = *-regular,
%  SmallCapsFeatures={RawFeature=+smcp},
  SmallCapsFeatures={Letters=SmallCaps}, 
  Extension      = .otf  
]

\newfontfamily\herosOsF{texgyreheros}[
  RawFeature     = {+onum},
  Scale          = \herosSF@scale ,
  UprightFont    = *-regular,
  ItalicFont     = *-italic,
  ItalicFeatures = { SmallCapsFont = *-italic },
  SlantedFont    = *-regular,
  SlantedFeatures= {FakeSlant=0.2},
  BoldFont       = *-bold,
  BoldFeatures   = { SmallCapsFont = *-bold },
  BoldItalicFont = *-bolditalic,
  BoldItalicFeatures = { SmallCapsFont = *-bolditalic },
  BoldSlantedFont= *-bold,
  BoldSlantedFeatures= {FakeSlant=0.2, SmallCapsFont = *-bold },
  SmallCapsFont  = *-regular,
%  SmallCapsFeatures={RawFeature=+smcp},
  SmallCapsFeatures={Letters=SmallCaps}, 
  Extension      = .otf  
]
\newfontfamily\heroscnOsF{texgyreheroscn}[
  RawFeature     = {+onum},
  Scale          = \herosSF@scale ,
  UprightFont    = *-regular,
  ItalicFont     = *-italic,
  ItalicFeatures = { SmallCapsFont = *-italic },
  SlantedFont    = *-regular,
  SlantedFeatures= {FakeSlant=0.2},
  BoldFont       = *-bold,
  BoldFeatures   = { SmallCapsFont = *-bold },
  BoldItalicFont = *-bolditalic,
  BoldItalicFeatures = { SmallCapsFont = *-bolditalic },
  BoldSlantedFont= *-bold,
  BoldSlantedFeatures= {FakeSlant=0.2, SmallCapsFont = *-bold },
  SmallCapsFont  = *-regular,
%  SmallCapsFeatures={RawFeature=+smcp},
  SmallCapsFeatures={Letters=SmallCaps}, 
  Extension      = .otf  
]

\newfontfamily\herosTLF{texgyreheros}[
  RawFeature        = {+tnum;-onum},
  Scale          = \herosSF@scale ,
  UprightFont    = *-regular,
  ItalicFont     = *-italic,
  ItalicFeatures = { SmallCapsFont = *-italic },
  SlantedFont    = *-regular,
  SlantedFeatures= {FakeSlant=0.2},
  BoldFont       = *-bold,
  BoldFeatures   = { SmallCapsFont = *-bold },
  BoldItalicFont = *-bolditalic,
  BoldItalicFeatures = { SmallCapsFont = *-bolditalic },
  BoldSlantedFont= *-bold,
  BoldSlantedFeatures= {FakeSlant=0.2, SmallCapsFont = *-bold },
  SmallCapsFont  = *-regular,
%  SmallCapsFeatures={RawFeature=+smcp},
  SmallCapsFeatures={Letters=SmallCaps}, 
  Extension      = .otf  
]
\newfontfamily\heroscnTLF{texgyreheroscn}[
  RawFeature        = {+tnum;-onum},
  Scale          = \herosSF@scale ,
  UprightFont    = *-regular,
  ItalicFont     = *-italic,
  ItalicFeatures = { SmallCapsFont = *-italic },
  SlantedFont    = *-regular,
  SlantedFeatures= {FakeSlant=0.2},
  BoldFont       = *-bold,
  BoldFeatures   = { SmallCapsFont = *-bold },
  BoldItalicFont = *-bolditalic,
  BoldItalicFeatures = { SmallCapsFont = *-bolditalic },
  BoldSlantedFont= *-bold,
  BoldSlantedFeatures= {FakeSlant=0.2, SmallCapsFont = *-bold },
  SmallCapsFont  = *-regular,
%  SmallCapsFeatures={RawFeature=+smcp},
  SmallCapsFeatures={Letters=SmallCaps}, 
  Extension      = .otf  
]
%------------------------   filenames stop -------------------------
\else
%------------------------   symbolic names start -------------------------
\ifheros@condensed
\setsansfont{TeX Gyre Heros Condensed}[ 
  RawFeature        = {\heros@figurealign,\heros@figurestyle},
  Scale             = \herosSF@scale ,
  UprightFont       = * Regular,
  SlantedFont       = * Regular,
  SlantedFeatures   = {FakeSlant=0.2},
  ItalicFont        = * Italic,
  ItalicFeatures    = { SmallCapsFont = * Italic },
  BoldFont          = * Bold, 
  BoldFeatures      = { SmallCapsFont = * Bold },
  BoldItalicFont    = * Bold Italic,
  BoldItalicFeatures= { SmallCapsFont = * Bold Italic },
  SmallCapsFont     = * Regular,
  SmallCapsFeatures = {RawFeature=+smcp},
  BoldSlantedFont   = * Bold,
  BoldSlantedFeatures = {FakeSlant=0.2, SmallCapsFont = * Bold },
  SmallCapsFeatures  = {Letters=SmallCaps}, 
]

\else
\setsansfont{TeX Gyre Heros}[ 
  RawFeature        = {\heros@figurealign,\heros@figurestyle},
  Scale             = \herosSF@scale ,
  UprightFont       = * Regular,
  SlantedFont       = * Regular,
  SlantedFeatures   = {FakeSlant=0.2},
  ItalicFont        = * Italic,
  ItalicFeatures    = { SmallCapsFont = * Italic },
  BoldFont          = * Bold, 
  BoldFeatures      = { SmallCapsFont = * Bold },
  BoldItalicFont    = * Bold Italic,
  BoldItalicFeatures= { SmallCapsFont = * Bold Italic },
  SmallCapsFont     = * Regular,
  SmallCapsFeatures = {RawFeature=+smcp},
  BoldSlantedFont   = * Bold,
  BoldSlantedFeatures = {FakeSlant=0.2, SmallCapsFont = * Bold },
  SmallCapsFeatures  = {Letters=SmallCaps}, 
]
\fi
\newfontfamily\heros{TeX Gyre Heros}[
  RawFeature        = {\heros@figurealign,\heros@figurestyle},
  Scale             = \herosSF@scale ,
  UprightFont       = * Regular,
  SlantedFont       = * Regular,
  SlantedFeatures   = {FakeSlant=0.2},
  ItalicFont        = * Italic,
  ItalicFeatures    = { SmallCapsFont = * Italic },
  BoldFont          = * Bold, 
  BoldFeatures      = { SmallCapsFont = * Bold },
  BoldItalicFont    = * Bold Italic,
  BoldItalicFeatures= { SmallCapsFont = * Bold Italic },
  SmallCapsFont     = * Regular,
  SmallCapsFeatures = {RawFeature=+smcp},
  BoldSlantedFont   = * Bold,
  BoldSlantedFeatures = {FakeSlant=0.2, SmallCapsFont = * Bold },
  SmallCapsFeatures  = {Letters=SmallCaps}, 
]
\newfontfamily\heroscn{TeX Gyre Heros Condensed}[
  RawFeature        = {\heros@figurealign,\heros@figurestyle},
  Scale             = \herosSF@scale ,
  UprightFont       = * Regular,
  SlantedFont       = * Regular,
  SlantedFeatures   = {FakeSlant=0.2},
  ItalicFont        = * Italic,
  ItalicFeatures    = { SmallCapsFont = * Italic },
  BoldFont          = * Bold, 
  BoldFeatures      = { SmallCapsFont = * Bold },
  BoldItalicFont    = * Bold Italic,
  BoldItalicFeatures= { SmallCapsFont = * Bold Italic },
  SmallCapsFont     = * Regular,
  SmallCapsFeatures = {RawFeature=+smcp},
  BoldSlantedFont   = * Bold,
  BoldSlantedFeatures = {FakeSlant=0.2, SmallCapsFont = * Bold },
  SmallCapsFeatures  = {Letters=SmallCaps}, 
]
\newfontfamily\herosOsF{TeX Gyre Heros}[
  RawFeature        = {OldStyle,Proportional},
  Scale             = \herosSF@scale ,
  UprightFont       = * Regular,
  SlantedFont       = * Regular,
  SlantedFeatures   = {FakeSlant=0.2},
  ItalicFont        = * Italic,
  ItalicFeatures    = { SmallCapsFont = * Italic },
  BoldFont          = * Bold, 
  BoldFeatures      = { SmallCapsFont = * Bold },
  BoldItalicFont    = * Bold Italic,
  BoldItalicFeatures= { SmallCapsFont = * Bold Italic },
  SmallCapsFont     = * Regular,
  SmallCapsFeatures = {RawFeature=+smcp},
  BoldSlantedFont   = * Bold,
  BoldSlantedFeatures = {FakeSlant=0.2, SmallCapsFont = * Bold },
  SmallCapsFeatures  = {Letters=SmallCaps}, 
]
\newfontfamily\heroscnOsF{TeX Gyre Heros}[
  RawFeature        = {OldStyle,Proportional},
  Scale             = \herosSF@scale ,
  UprightFont       = * Regular,
  SlantedFont       = * Regular,
  SlantedFeatures   = {FakeSlant=0.2},
  ItalicFont        = * Italic,
  ItalicFeatures    = { SmallCapsFont = * Italic },
  BoldFont          = * Bold, 
  BoldFeatures      = { SmallCapsFont = * Bold },
  BoldItalicFont    = * Bold Italic,
  BoldItalicFeatures= { SmallCapsFont = * Bold Italic },
  SmallCapsFont     = * Regular,
  SmallCapsFeatures = {RawFeature=+smcp},
  BoldSlantedFont   = * Bold,
  BoldSlantedFeatures = {FakeSlant=0.2, SmallCapsFont = * Bold },
  SmallCapsFeatures  = {Letters=SmallCaps}, 
]

\newfontfamily\herosTLF{TeX Gyre Heros}[
  RawFeature        = {Lining,Monospaced},
  Scale             = \herosSF@scale ,
  UprightFont       = * Regular,
  SlantedFont       = * Regular,
  SlantedFeatures   = {FakeSlant=0.2},
  ItalicFont        = * Italic,
  ItalicFeatures    = { SmallCapsFont = * Italic },
  BoldFont          = * Bold, 
  BoldFeatures      = { SmallCapsFont = * Bold },
  BoldItalicFont    = * Bold Italic,
  BoldItalicFeatures= { SmallCapsFont = * Bold Italic },
  SmallCapsFont     = * Regular,
  SmallCapsFeatures = {RawFeature=+smcp},
  BoldSlantedFont   = * Bold,
  BoldSlantedFeatures = {FakeSlant=0.2, SmallCapsFont = * Bold },
  SmallCapsFeatures  = {Letters=SmallCaps}, 
]
\newfontfamily\heroscnTLF{TeX Gyre Heros}[
  RawFeature        = {Lining,Monospaced},
  Scale             = \herosSF@scale ,
  UprightFont       = * Regular,
  SlantedFont       = * Regular,
  SlantedFeatures   = {FakeSlant=0.2},
  ItalicFont        = * Italic,
  ItalicFeatures    = { SmallCapsFont = * Italic },
  BoldFont          = * Bold, 
  BoldFeatures      = { SmallCapsFont = * Bold },
  BoldItalicFont    = * Bold Italic,
  BoldItalicFeatures= { SmallCapsFont = * Bold Italic },
  SmallCapsFont     = * Regular,
  SmallCapsFeatures = {RawFeature=+smcp},
  BoldSlantedFont   = * Bold,
  BoldSlantedFeatures = {FakeSlant=0.2, SmallCapsFont = * Bold },
  SmallCapsFeatures  = {Letters=SmallCaps}, 
]

\fi
%------------------------   symbolic names stop -------------------------

%\ifheros@nomath\else
%  \typeout{*************************************^^J%
%           * Using heros math              *^^J%
%           *************************************}%
%\setmathfont{texgyreheros-math.otf}[AutoFakeBold,RawFeature=\herosMM@feature]
%\fi

\def\sufigures{\addfontfeatures{VerticalPosition=Superior}}
\DeclareTextFontCommand{\textsup}{\sufigures}
\DeclareTextFontCommand{\textinit}{\herosInitials}%  Initials

\def\Lsup#1{{\addfontfeature{RawFeature=+sups}#1}}
\def\Lsinf#1{{\addfontfeature{RawFeature=+sinf}#1}}
\def\Land{{\addfontfeature{RawFeature=+ss06}\&}}

\def\Lcase#1{{\addfontfeature{RawFeature=case}#1}}
\def\LCASE{\@ifnextchar-\L@CASE\L@@CASE}
\def\L@CASE-{\addfontfeature{RawFeature=-case}}
\def\L@@CASE#1{\addfontfeature{RawFeature=+case}\ifx#1+\else#1\fi}

\def\Lfrac#1{{\addfontfeature{RawFeature=+frac}#1}}
\def\LFRAC{\@ifnextchar-\L@FRAC\L@@FRAC}
\def\L@FRAC-{\addfontfeature{RawFeature=-frac}}
\def\L@@FRAC#1{\addfontfeature{RawFeature=+frac}\ifx#1+\else#1\fi}

\def\Lcpsp#1{{\addfontfeature{RawFeature=+cpsp}#1}}
\def\LCPSP{\@ifnextchar-\L@CPSP\L@@CPSP}
\def\L@CPSP-{\addfontfeature{RawFeature=-cpsp}}
\def\L@@CPSP#1{\addfontfeature{RawFeature=+cpsp}\ifx#1+\else#1\fi}

\def\Lss#1#2#3{{\addfontfeature{RawFeature=+ss#1#2}#3}}
\def\LSS#1#2{\addfontfeature{RawFeature=+ss#1#2}}

\def\Lctosc#1{{\addfontfeature{RawFeature=+c2sc}#1}}
\def\LCtoSC{\@ifnextchar-\L@CtoSC\L@@CtoSC}
\def\L@CtoSC-{\addfontfeature{RawFeature=-c2sc}}
\def\L@@CtoSC#1{\addfontfeature{RawFeature=+c2sc}\ifx#1+\else#1\fi}

\def\Lctosmcp#1{{\addfontfeature{RawFeature={+c2sc,+smcp}}#1}}
\def\LCtoSMCP{\@ifnextchar-\L@CtoSMCP\L@@CtoSMCP}
\def\L@CtoSMCP-{\addfontfeature{RawFeature={-c2sc,-smcp}}}
\def\L@@CtoSMCP#1{\addfontfeature{RawFeature={+c2sc,+smcp}}\ifx#1+\else#1\fi}

\def\Lsalt#1{{\addfontfeature{RawFeature=+salt}#1}}
\def\LSALT{\@ifnextchar-\L@SALT\L@@SALT}
\def\L@SALT-{\addfontfeature{RawFeature=-salt}}
\def\L@@SALT#1{\addfontfeature{RawFeature=+salt}\ifx#1+\else#1\fi}

\def\Lliga#1{{\addfontfeature{RawFeature=+liga}#1}}
\def\LLIGA{\@ifnextchar-\L@LIGA\L@@LIGA}
\def\L@LIGA-{\addfontfeature{RawFeature=-liga}}
\def\L@@LIGA#1{\addfontfeature{RawFeature=+liga}\ifx#1+\else#1\fi}


\def\Lhlig#1{{\addfontfeature{RawFeature=+hlig}#1}}
\def\LHLIG{\@ifnextchar-\L@HLIG\L@@HLIG}
\def\L@HLIG-{\addfontfeature{RawFeature=-hlig}}
\def\L@@HLIG#1{\addfontfeature{RawFeature=+hlig}\ifx#1+\else#1\fi}

\def\Ldlig#1{{\addfontfeature{RawFeature=+dlig}#1}}
\def\LDLIG{\@ifnextchar-\L@DLIG\L@@DLIG}
\def\L@DLIG-{\addfontfeature{RawFeature=-dlig}}
\def\L@@DLIG#1{\addfontfeature{RawFeature=+dlig}\ifx#1+\else#1\fi}

\endinput

