% From mitthesis package
% Documentation: https://ctan.org/pkg/mitthesis

\ProvidesFile{mitthesis-libertinus.tex}[2025/09/23 v1.02 Load Libertinus and related fonts]

%% Libertinus (serif) text font with newtxmath[libertinus] (pdftex) or Libertinus (unicode) math font
%
%	These fonts are in TeX Live and on CTAN. They are included in a complete LaTeX installation. 
%	They are also available at: 
%  		https://ctan.org/tex-archive/fonts/libertine/opentype 
%		https://github.com/alerque/libertinus
%
\ifpdftex
	\ClassNoteNoLine{\ClassName}{Loading Libertinus type1 text fonts and newtx-libertinus math fonts}
    \RequirePackage[T1]{fontenc}
    \RequirePackage[lf,t,semibold,ScaleTT=0.9]{libertinus} % tabular lining figures
    \RequirePackage[libertinus,vvarbb,subscriptcorrection]{newtxmath}% see package documentation for options
    \RequirePackage{bm}% load after all math to give access to bold math
\else
	\ClassNoteNoLine{\ClassName}{Loading Libertinus OTF text and math fonts}
	%
    \RequirePackage[warnings-off={mathtools-colon,mathtools-overbracket},mathbf=sym]{unicode-math}
    % suppress warnings about lack of integration between mathtools and unicode-math
    % unicode math loads the fontspec package
 	%
    \setmainfont{LibertinusSerif}[% 
    	Extension = .otf,
    	UprightFont = *-Regular,
    	ItalicFont = *-Italic,
    	BoldFont = *-Semibold, 
    	BoldItalicFont = *-SemiboldItalic,
    	RawFeature={+ss05,+dlig,+tnum,+liga}, 
		% +ss02 would change J, K, R; +ss05 changes W; onum = oldstyle figures; hlig = historical ligatures
    ]    
    \setsansfont{LibertinusSans}[% 
    	Extension = .otf,
    	UprightFont = *-Regular,
    	ItalicFont = *-Italic,
    	BoldFont = *-Bold,
	    BoldItalicFont = *-Bold,% does not have bold italic
    	Scale=MatchUppercase,
		RawFeature={+liga,},
	]
	%
    \setmonofont{LibertinusMono}[% 
    	Scale=0.9,% 2024/10/13
	    Extension = .otf,
    	UprightFont = *-Regular,
    	ItalicFont = *-Regular,% does not have italic
    	BoldFont = *-Regular,% does not have bold 
	    BoldItalicFont = *-Regular,% does not have bold italic
	] 
	% 
	\newfontfamily\LibertinusDisplay{LibertinusSerifDisplay-Regular.otf}% a display font, as for titles
	%
	\newfontfamily\LibertinusInitials{LibertinusSerifInitials-Regular.otf}% Large initial letters, as for first word in chapter
	%	     	
    %% a Libertinus math font
    \setmathfont{libertinusmath-regular}[%
     	Extension = .otf,   
    	Scale=MatchUppercase,
%		BoldFont = *,% This font lacks a bold version
    	RawFeature={+ss08},% +ss08 gives slanted integrals (no other features) 	
    	]
	\setmathfont{Latin Modern Math}[range=\nabla,Scale=0.91] % I hate the backward nabla in Libertinus Math...
	
    \newcommand*{\FRAC}[1]{{\addfontfeature{Fractions=On}#1}}% use OpenType feature for fractions, \FRAC{1/2} 
\fi
