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

\ProvidesFile{mitthesis-libertinus.tex}[2026/11/11 v1.05 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 (these are the defaults)
    \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,
	    Ligatures=Discretionary,
	    StylisticSet=05, % named replacement for RawFeature={+ss05},
		% +ss02 would change J, K, R; +ss05 changes W; onum = oldstyle figures; hlig = historical ligatures
		% see: https://github.com/alerque/libertinus/blob/master/documentation/Opentype-Features.pdf
    ]    
    \setsansfont{LibertinusSans}[% 
    	Extension = .otf,
    	UprightFont = *-Regular,
    	ItalicFont  = *-Italic,
    	BoldFont    = *-Bold,
	    BoldItalicFont = *-Bold,% does not have bold italic
    	Scale=MatchUppercase,
	]
	%
    \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
    %%	This font lacks a separate bold version (\symbf, \symbfit, etc. ordinarily cover most needs)
    \setmathfont{LibertinusMath-Regular}[%
     	Extension = .otf,   
    	Scale=MatchUppercase,
	    StylisticSet=8, % like RawFeature={+ss08}; +ss08 gives slanted integrals (no other features) 	
    	]
	\setmathfont{Latin Modern Math}[range={\nabla,\mitnabla,\mbfnabla,\mbfitnabla,\mbfsansnabla,\mbfitsansnabla},Scale=0.91] % Replace the backward nabla in Libertinus Math.
	
    \newcommand*{\FRAC}[1]{{\addfontfeature{Fractions=On}#1}}% use OpenType feature for fractions, \FRAC{1/2} 
\fi
