Given the usecase mentioned, it seems more prudent to check if the font exists, and if not, to load the fallback font.
To do that, I would recommend the method used in this answer using the fontspec package.
In your case, the MWE from that answer would be changed slightly to:
\documentclass{article}
%\url{https://tex.stackexchange.com/q/438577/86}
\usepackage{fontspec}
% Check to see if this font is installed system-wide
\IfFontExistsTF{TeX Gyre Termes}{%
% One person has this installed system-wide
\setmainfont{TeX Gyre Termes}
}{
% If not, load it from the file
\setmainfont{Latin Modern Roman}
}
\begin{document}
Wouldn't it be nice if this were Termes?
\end{document}
replacing TeX Gyre Termes with the font you want to check for and Latin Modern Roman with the font you want to fall back to.
The other possibility is to put the font file into the project directory, assuming you have an .otf or .ttf, and load it using fontspec with \setmainfont{texgyretermes-regular.otf}. This should work on Overleaf as well as locally.
\IfFileExiststo check for the font file – samcarter_is_at_topanswers.xyz Apr 26 '23 at 12:36~/My_love_letter_to_TeX.txtin your home folder... – samcarter_is_at_topanswers.xyz Apr 26 '23 at 12:43ifplatformpackage. Overleaf also uses an old texlive version, assuming your system is up to date, you could check the kernel version. – samcarter_is_at_topanswers.xyz Apr 26 '23 at 12:47