[Tex/LaTex] XeLatex otf font won’t load

fontsfontspecxetex

I am very inexperienced with LaTeX. I have a tex file that has worked for a long time, then stopped without any changes to the file.

We purchased NeueHaasGrotDisp font. I have the fonts in OTF format.

I am getting the following error:

(C:\myPath\Program\Binaries\miktex\tex\xelatex\fontspec\fontspec.cfg))Running miktex-makemf.exe...
miktex-makemf: The NeueHaasGrotDisp-55Roman source file could not be found.

Running hbf2gf.exe...
hbf2gf (CJK ver. 4.8.3)

Couldn't find `NeueHaasGrotDisp-55Rom.cfg'

miktex-maketfm: No creation rule for font NeueHaasGrotDisp-55Roman.

! Font \zf@basefont=NeueHaasGrotDisp-55Roman at 10.0pt not loadable: Metric(TFM) file or installed font not found.
\zf@fontspec ...ntname \zf@suffix " at \f@size pt 
                                              \unless \ifzf@icu \zf@set@...
l.151 {NeueHaasGrotDisp}

My code:

...
\usepackage{fontspec}

...
%Regular Font
\newfontfamily\nhg [
  Path = {/Program Files (x86)/program/fonts/},
  BoldFont = *-75Bold,
  UprightFont = *-55Roman,
  ItalicFont = *-36ThinItalic,
  Extension = .otf
]

{NeueHaasGrotDisp}
%Light Font
\newfontfamily\nhgl [
  Path = {/Program Files (x86)/program/fonts/}, 
  BoldFont = *-75Bold,
  UprightFont = *-45Light,
  Extension = .otf
]
{NeueHaasGrotDisp}

At /Program Files (x86)/program/fonts/ I have the following files:

  • NeueHaasGrotDisp-36ThinItalic.otf
  • NeueHaasGrotDisp-45Light.otf
  • NeueHaasGrotDisp-55Roman.otf
  • NeueHaasGrotDisp-75Bold.otf

Would this happen if our font license expired? Is this checked when the font is loaded?

Best Answer

Your path needs to be surrounded by braces {}. I also separate the ending comma-delimiters with a space.

Here is how I would do it.

I used:

  1. Folder called Fonts inside of base directory (where your font files are located)
  2. MinionPro*.otf (grabs all variants, assuming your file name scheme is fontname-type.otf where -type represents: -Bold, -Italic, -Regular, etc.)

(I have an extra file for semibold that I did not load with fontspec. I usually overcome this limitation by creating another font family or by replacing the bold font depending on the situation.)

Code

\documentclass{article}
\usepackage{fontspec}

\newfontfamily\yourcustomnameforthisfont[%
    Path = {Fonts/} ,
    Extension = .otf ,
    UprightFont = *-Regular ,
    ItalicFont = *-It ,
    BoldFont = *-Bold ,
    BoldItalicFont = *-BoldIt
    ]{MinionPro}
\usepackage{lipsum}
\begin{document}
{\yourcustomnameforthisfont\lipsum}
\end{document}

Output

(Note that I am missing the lipsum package in the screenshot and the \yourcustomnameforthisfont. The screenshot is to show the relationship between the \newfontfamily code and the files.) enter image description here