alexpovel / latex-cookbook

A comprehensive LaTeX template with examples for theses, books and more, employing the 'latest and greatest' (UTF8, glossaries, fonts, ...). The PDF artifact is built using CI/CD, with a Python testing framework.
MIT License
217 stars 20 forks source link

fontspec error, font not found #3

Closed alexpovel closed 2 years ago

alexpovel commented 2 years ago

Original issue (2021-10-18): https://collaborating.tuhh.de/alex/latex-cookbook/-/issues/10

When using package fontspec (or its derivative unicode-math), compilation fails with

! error:  (type 2): cannot find file ''
!  ==> Fatal error occurred, no output PDF file produced!

What happened here and how can it be fixed?

alexpovel commented 2 years ago

It is possible that the font cache is corrupted after moving fonts around. For example, if previously all fonts were in a flat ./fonts/ subdirectory of your document root, and then you decide to sort them into ./fonts/sans/ etc., the luatex cache will still point to the old ones.

See here and also, similarly, here for a solution: delete the .lua and .luc files of the fonts in question from luatex-cache/generic/fonts/.

For MiKTeX 2.9 on Windows 10, this was found in %USERPROFILE%\AppData\Local\MiKTeX\2.9\luatex-cache.

This issue will not occur if using Docker with the proper image, since things are sorted out there.