I've been working with a large document in Sharelatex for some time and I kept getting a fontspec error that it could not find the font file. However, despite this error message the document kept compiling normally, that is until I switched the font to Garamond. Now the document will only compile the sans-serif portion of the document.
Below is my MWE without the sans serif portion.
\documentclass[12pt]{scrbook}
\usepackage[paperwidth=7.5in, paperheight=9.25in, top=1in, bottom=1.375in, left=1in, right=1in]{geometry}
\setlength{\parindent}{2em}
%Fonts
\usepackage{fontspec}
%This is ShareLaTeX Specific (or if the fonts are not installed in your system)
%-----------------------------------------------------------------------
% Garamond
\setmainfont[BoldFont=GARABD.otf,ItalicFont=GARAIT.otf]{GARAMOND.otf}
\begin{document}
Something is wrong! I am momentarily blinded and confused by moving, overlapping, translucent images that overwhelm my vision of the book I am reading. The room I sit in is visually a frenetic whirling mess. Abject fear grips me, first at the base of my spine, then it rips up my spine to my cortex and beyond. \par
\end{document}
Any ideas of how to fix this? I've tried altering the file names, but this has produced no result.
Best Answer
With
setmainfont
you're essential building case-sensitive font paths.You're code does not work because you are telling fontspec to look in all paths like this (example shows paths for bold font):
TeX Default Known Font Path Segments
On Unix-based computers, you can figure out the TeX font folders with:
which evaluates to
/home/texlive/2016/texmf-var/fonts/conf
for 2016, or for the appropriate year of your installed version.Otherwise
fontspec
does have an automatic path finding mechanism for system fonts, where you can just do\setmainfont{Arial}
, but this is not as explicit and therefore in my experience leads to problems with cross-platform or cross-computer compatibility.See How do I load a texlive font with fontspec?
Empowering YOU to DO it Yourself
Find folder where you files reside (without knowing your OS, I will just make up something)
Given fonts are in same folder with these names:
How would I set up
fontspec
for this?Notes
Many pro fonts use dashes in their file names to separate the variants, so you'll often see the following:
How would i set this up? Well, unfortunately
fontspec
does not support all of those fonts simultaneously, so I might either settle for less and use\setmainfont
or load them all by breaking them up into families e.g.\newfontfamily\dejavucondensed
\newfontfamily\dejavu
\newfontfamily\dejavulight
.