# How to \setmainfont when “randomfont.ttf” is in different folder?

I'm currently working in sharelatex online Latex editor, using XeLaTeX. I had all the fonts working using the fontspec package, however once moved to the Fonts folder there is no way to make them work:

\setmainfont{./Fonts/Merriweather-Regular.ttf}%
[Ligatures=TeX,
BoldFont=./Fonts/Merriweather-Bold.ttf,
ItalicFont=./Fonts/Merriweather-Italic.ttf,
BoldItalicFont=./Fonts/Merriweather-BoldItalic.ttf]


Even replacing the ./Fonts/, /Fonts/, Fonts/, etc.

Does anyone know how to make it work?

Don't load the fonts with the relative path. Load them by their font names and specify the ExternalLocation key to point to your folder:

\documentclass{article}

\usepackage{fontspec}
\setmainfont[ExternalLocation=Fonts/]{AGaramondPro-Regular.otf}%
[Ligatures=TeX,
BoldFont=AGaramondPro-Bold.otf,
ItalicFont=AGaramondPro-Italic.otf,
BoldItalicFont=AGaramondPro-BoldItalic.otf]

\begin{document}
This is some regular text.
\end{document}