[Tex/LaTex] Trouble setting new font in Overleaf

cvfontsoverleafxetex

I got the Plasmati Graduate CV template for my curriculum.

It says:
This template needs to be compiled with XeLaTeX and requires the Fontin font (OpenType version preferred) which can be downloaded for free here.

I already changed the compiler to XeLaTeX in Overleaf, it isn't going well:

fontspec error: "font-not-found"

! The font "Fontin" cannot be found.

! See the fontspec documentation for further information.

! For immediate help type H .

l.36 …[SmallCapsFont = Fontin SmallCaps]{Fontin}

% Main document font

I haven't changed the original code

I haven't changed the original code. What am I doing wrong?

Thanks for the attention!

Best Answer

The original code \setmainfont[SmallCapsFont = Fontin SmallCaps]{Fontin} assumes Fontin has been installed in the operating system's font folder. However, this isn't the case on Overleaf, so you'll need to point fontspec at the OTF files by referring to their file names, rather than by their font names.

To get this to compile on Overleaf using the file structure you have in your screenshot (i.e. all font files on the top level, in the same folder as the .tex file), replace the \setmainfont[SmallCapsFont = Fontin SmallCaps]{Fontin} in the preamble with these instead:

\setmainfont[Path = ./,  %% Optional; but UPDATE this if 
                         %% your font files are in a folder
 Extension = .otf,
 UprightFont = *-Regular,
 BoldFont = *-Bold,
 ItalicFont = *-Italic,
 SmallCapsFont = *-SmallCaps]
{Fontin}

If you put the font files in a folder, remember to update the Path parameter (which actually isn't really necessary in your case if fonts are on the same path as the .tex). Note also that when using filenames like this with fontspec, you'll need to specify the fonts for the bold, italics etc explicitly: fontspec doesn't automatically "deduce" which files to use based on the filename pattern Fontin-Regular.otf, you need to tell it exactly what to use.

For reference, here's the list of OTF/TTF fonts that are available on Overleaf.