%% $Id: libertinus-otf.sty 770 2018-06-13 14:22:56Z 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.
%%
%
% Copyright 2018 Herbert Voss hvoss@tug.org
%
\ProvidesPackage{libertinus-otf}[%
  2018/06/12 v. 0.07a (Herbert Voss) Supports libertinus fonts for all luatex/xetex .] 

\RequirePackage{ifxetex,ifluatex,xkeyval,textcomp}
\RequirePackage{unicode-math}

\newif\iflibertinus@lining \libertinus@liningtrue         
\newif\ifbiolinum@lining \biolinum@liningtrue            
\newif\iflibertinus@tabular \libertinus@tabulartrue
\newif\ifbiolinum@tabular \biolinum@tabulartrue
\newif\iflibertinus@semibold \libertinus@semiboldfalse

\DeclareOptionX{lining}[true]{\@nameuse{libertinus@lining#1}}
\DeclareOptionX{nf}[true]{%
  \@nameuse{libertinus@lining#1}
  \iflibertinus@lining\libertinus@newfigdefaults\fi
}
\DeclareOptionX{lf}[true]{\iflibertinus@lining\libertinus@newfigdefaults\fi}
\DeclareOptionX{oldstyle}[true]{\iflibertinus@lining\libertinus@newfigdefaults\fi}
\DeclareOptionX{osf}[true]{\iflibertinus@lining\libertinus@newfigdefaults\fi}
\DeclareOptionX{tabular}[true]{\iflibertinus@tabular\libertinus@newfigdefaults\fi}
\DeclareOptionX{t}[true]{\iflibertinus@tabular\libertinus@newfigdefaults\fi}
\DeclareOptionX{proportional}[true]{\iflibertinus@tabular\libertinus@newfigdefaults\fi}
\DeclareOptionX{p}[true]{\iflibertinus@tabular\libertinus@newfigdefaults\fi}
\DeclareOptionX{semibold}[true]{\@nameuse{libertinus@semibold#1}}
\DeclareOptionX{sb}[true]{\@nameuse{libertinus@semibold#1}}
\DeclareOptionX{bold}[true]{\libertinus@semiboldfalse\else\libertinus@semiboldtrue\fi}

\newcommand*\libertinusRM@scale{1}  
\newcommand*\libertinusDisplayT@scale{1} 
\newcommand*\libertinusSF@scale{1}
\newcommand*\libertinusTT@scale{MatchLowercase}  
\newcommand*\libertinusInitialsT@scale{1}  
\DeclareOptionX{ScaleRM}{\renewcommand*{\libertinusRM@scale}{#1}}
\DeclareOptionX{ScaleSF}{\renewcommand*{\libertinusSF@scale}{#1}}
\DeclareOptionX{ScaleTT}{\renewcommand*{\libertinusTT@scale}{#1}}

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

\ProcessOptionsX\relax

\iflibertinus@lining
    \def\libertinus@figurestyle{Lining}
\else
    \def\libertinus@figurestyle{OldStyle}
\fi

\iflibertinus@tabular
    \def\libertinus@figurealign{Monospaced} 
\else
    \def\libertinus@figurealign{Proportional} 
\fi

\iflibertinus@semibold
     \def\libertinus@boldstyle{bold} 
\else
    \def\libertinus@boldstyle{semibold} 
\fi


\ifxetex\XeTeXtracingfonts=1\fi
\defaultfontfeatures{
     Ligatures = TeX ,
     SmallCapsFeatures={Letters=SmallCaps\ifluatex,Renderer=Basic\fi} , 
     \libertinus@defaultfeatures
}
\setmainfont{libertinusserif}[ 
%  Numbers        = {%\libertinus@figurealign,\libertinus@figurestyle},
  Scale          = \libertinusRM@scale ,
  UprightFont    = *-regular,
  ItalicFont     = *-italic,
  BoldFont       = *-\libertinus@boldstyle, 
  BoldItalicFont = *-\libertinus@boldstyle italic,
  SmallCapsFeatures={Letters=SmallCaps}, 
  Extension      = .otf  
]
\setsansfont{libertinussans}[ 
%  Numbers   = {\libertinus@figurealign, \libertinus@figurestyle} ,
  Scale     = \libertinusSF@scale ,
  UprightFont    = *-regular,
  ItalicFont     = *-italic,
  BoldFont       = *-bold, 
  BoldItalicFont = *-bolditalic, 
  SmallCapsFeatures={Letters=SmallCaps},
  Extension      = .otf  
]
\setmonofont{libertinusmono}[ 
%  Numbers   = {\libertinus@figurealign, \libertinus@figurestyle},
  Scale     = \libertinusTT@scale,
  FakeStretch    = 0.8,
  UprightFont    = *-regular,
  ItalicFont     = *-italic,
  BoldFont       = *-bold,
% AutoFakeBold   = 1.5,
  Extension      = .otf, 
]

%\setmathfont{libertinusmath-regular.otf}[BoldFont=libertinusmath-bold.otf]
\setmathfont{libertinusmath-regular.otf}
\setmathfont[version=bold]{libertinusmath-bold.otf}

\newfontfamily\LibertinusKeyboard{libertinuskeyboard-regular.otf}
\newfontfamily\LibertinusDisplay{libertinusserifdisplay-regular.otf}
\newfontfamily\Libertinusinitials{libertinusserifinitials-regular.otf}

\def\biolinumKeyGlyph#1{{\LibertinusKeyboard\symbol{#1}}}
\def\BiolinumKeyGlyph#1{{\LibertinusKeyboard#1}}
\DeclareRobustCommand*\LKey[1]{\BiolinumKeyGlyph{#1}}

\DeclareRobustCommand*\LKeyStrg{\biolinumKeyGlyph{"E170}}
\DeclareRobustCommand*\LKeyAlt{\biolinumKeyGlyph{"E171}}
\DeclareRobustCommand*\LKeyAltGr{\biolinumKeyGlyph{"E172}}
\DeclareRobustCommand*\LKeyShift{\biolinumKeyGlyph{"E174}}
\DeclareRobustCommand*\LKeyTab{\biolinumKeyGlyph{"E175}}
\DeclareRobustCommand*\LKeyEnter{\biolinumKeyGlyph{"E176}}
\DeclareRobustCommand*\LKeyCapsLock{\biolinumKeyGlyph{"E177}}
\DeclareRobustCommand*\LKeyPos{\biolinumKeyGlyph{"E191}}
\DeclareRobustCommand*\LKeyEntf{\biolinumKeyGlyph{"E18A}}
\DeclareRobustCommand*\LKeyEinf{\biolinumKeyGlyph{"E18B}}
\DeclareRobustCommand*\LKeyLeer{\biolinumKeyGlyph{"E18C}}
\let\LKeySpace\LKeyLeer
\DeclareRobustCommand*\LKeyEsc{\biolinumKeyGlyph{"E195}}
\DeclareRobustCommand*\LKeyEnde{\biolinumKeyGlyph{"E196}}
\DeclareRobustCommand*\LKeyTux{\biolinumKeyGlyph{"E000}}
\DeclareRobustCommand*\LKeyWin{\biolinumKeyGlyph{"E168}}
\DeclareRobustCommand*\LKeyMenu{\biolinumKeyGlyph{"E104}}
\DeclareRobustCommand*\LKeyCommand{\biolinumKeyGlyph{"2318}}
\DeclareRobustCommand*\LKeyOptionKey{\biolinumKeyGlyph{"2325}}
\DeclareRobustCommand*\LKeyBack{\biolinumKeyGlyph{"E16E}}
\DeclareRobustCommand*\LKeyUp{\biolinumKeyGlyph{"2191}}
\DeclareRobustCommand*\LKeyDown{\biolinumKeyGlyph{"2193}}
\DeclareRobustCommand*\LKeyLeft{\biolinumKeyGlyph{"2190}}
\DeclareRobustCommand*\LKeyRight{\biolinumKeyGlyph{"2192}}
\DeclareRobustCommand*\LKeyPgUp{\biolinumKeyGlyph{"E198}}
\DeclareRobustCommand*\LKeyPgDown{\biolinumKeyGlyph{"E199}}
\DeclareRobustCommand*\LKeyAt{\biolinumKeyGlyph{"0040}}
\DeclareRobustCommand*\LKeyFn{\biolinumKeyGlyph{"E188}}
\DeclareRobustCommand*\LKeyHome{\biolinumKeyGlyph{"E189}}
\DeclareRobustCommand*\LKeyDel{\biolinumKeyGlyph{"E18A}}
\DeclareRobustCommand*\LKeyIns{\biolinumKeyGlyph{"E18B}}
\DeclareRobustCommand*\LKeyEnd{\biolinumKeyGlyph{"E18E}}
\DeclareRobustCommand*\LKeyGNU{\biolinumKeyGlyph{"E190}}
\DeclareRobustCommand*\LKeyPageUp{\biolinumKeyGlyph{"E19A}}
\DeclareRobustCommand*\LKeyPageDown{\biolinumKeyGlyph{"E19B}}

\@namedef{libertine@key@F@1}{\biolinumKeyGlyph{"E178}}
\@namedef{libertine@key@F@2}{\biolinumKeyGlyph{"E179}}
\@namedef{libertine@key@F@3}{\biolinumKeyGlyph{"E17A}}
\@namedef{libertine@key@F@4}{\biolinumKeyGlyph{"E17B}}
\@namedef{libertine@key@F@5}{\biolinumKeyGlyph{"E17C}}
\@namedef{libertine@key@F@6}{\biolinumKeyGlyph{"E17D}}
\@namedef{libertine@key@F@7}{\biolinumKeyGlyph{"E17E}}
\@namedef{libertine@key@F@8}{\biolinumKeyGlyph{"E17F}}
\@namedef{libertine@key@F@9}{\biolinumKeyGlyph{"E180}}
\@namedef{libertine@key@F@10}{\biolinumKeyGlyph{"E181}}
\@namedef{libertine@key@F@11}{\biolinumKeyGlyph{"E182}}
\@namedef{libertine@key@F@12}{\biolinumKeyGlyph{"E183}}
\@namedef{libertine@key@F@13}{\biolinumKeyGlyph{"E184}}
\@namedef{libertine@key@F@14}{\biolinumKeyGlyph{"E185}}
\@namedef{libertine@key@F@15}{\biolinumKeyGlyph{"E186}}
\@namedef{libertine@key@F@16}{\biolinumKeyGlyph{"E187}}
\DeclareRobustCommand*\LKeyF[1]{\@nameuse{libertine@key@F@#1}}
%
\DeclareRobustCommand*\LKeyAltF[1]{\LKeyAlt+\@nameuse{libertine@key@F@#1}}
\DeclareRobustCommand*\LKeyStrgAltF[1]{\LKeyStrg+\LKeyAlt+\@nameuse{libertine@key@F@#1}}
\DeclareRobustCommand*\LKeyStrgX[1]{\LKeyStrg+\LKey{#1}}
\DeclareRobustCommand*\LKeyShiftX[1]{\LKeyShift+\LKey{#1}}
\DeclareRobustCommand*\LKeyAltX[1]{\LKeyAlt+\LKey{#1}}
\DeclareRobustCommand*\LKeyAltGrX[1]{\LKeyAltGr+\LKey{#1}}
\DeclareRobustCommand*\LKeyShiftStrgX[1]{\LKeyShift+\LKeyStrg+\LKey{#1}}
\DeclareRobustCommand*\LKeyShiftAltX[1]{\LKeyShift+\LKeyAlt+\LKey{#1}}
\DeclareRobustCommand*\LKeyShiftAltGrX[1]{\LKeyShift+\LKeyAltGr+\LKey{#1}}
\DeclareRobustCommand*\LKeyStrgAltX[1]{\LKeyStrg+\LKeyAlt+\LKey{#1}}
\DeclareRobustCommand*\LKeyStrgAltEnt{\LKeyStrg+\LKeyAlt+\LKeyEntf}
\let\LKeyReset\LKeyStrgAltEnt
%
\@namedef{libertine@key@Pad@0}{\biolinumKeyGlyph{"E1A0}}
\@namedef{libertine@key@Pad@1}{\biolinumKeyGlyph{"E1A1}}
\@namedef{libertine@key@Pad@2}{\biolinumKeyGlyph{"E1A2}}
\@namedef{libertine@key@Pad@3}{\biolinumKeyGlyph{"E1A3}}
\@namedef{libertine@key@Pad@4}{\biolinumKeyGlyph{"E1A4}}
\@namedef{libertine@key@Pad@5}{\biolinumKeyGlyph{"E1A5}}
\@namedef{libertine@key@Pad@6}{\biolinumKeyGlyph{"E1A6}}
\@namedef{libertine@key@Pad@7}{\biolinumKeyGlyph{"E1A7}}
\@namedef{libertine@key@Pad@8}{\biolinumKeyGlyph{"E1A8}}
\@namedef{libertine@key@Pad@9}{\biolinumKeyGlyph{"E1A9}}
\@namedef{libertine@key@Pad@10}{\biolinumKeyGlyph{"E1AA}}
\@namedef{libertine@key@Pad@11}{\biolinumKeyGlyph{"E1AB}}
\@namedef{libertine@key@Pad@12}{\biolinumKeyGlyph{"E1AC}}
\@namedef{libertine@key@Pad@13}{\biolinumKeyGlyph{"E1AD}}
\@namedef{libertine@key@Pad@14}{\biolinumKeyGlyph{"E1AE}}
\DeclareRobustCommand*\LKeyPad[1]{\@nameuse{libertine@key@Pad@#1}}
%
% Maus
%
\DeclareRobustCommand*\LMouseEmpty{\biolinumKeyGlyph{"E130}}
\DeclareRobustCommand*\LMouseN{\biolinumKeyGlyph{"E131}}
\DeclareRobustCommand*\LMouseL{\biolinumKeyGlyph{"E132}}
\DeclareRobustCommand*\LMouseM{\biolinumKeyGlyph{"E133}}
\DeclareRobustCommand*\LMouseR{\biolinumKeyGlyph{"E134}}
\DeclareRobustCommand*\LMouseLR{\biolinumKeyGlyph{"E135}}
\DeclareRobustCommand*\LMouseIIEmpty{\biolinumKeyGlyph{"E138}}
\DeclareRobustCommand*\LMouseIIN{\biolinumKeyGlyph{"E139}}
\DeclareRobustCommand*\LMouseIIL{\biolinumKeyGlyph{"E13A}}
\DeclareRobustCommand*\LMouseIIR{\biolinumKeyGlyph{"E13C}}
\DeclareRobustCommand*\LMouseIILR{\biolinumKeyGlyph{"E13D}}
%

