How to Update a Custom Font for LuaLaTeX on Windows
At a glance
- 1. Replace the font
Install the revised font in Windows, or put the font file in your project’s fonts folder.
- 2. Refresh Luaotfload
Run luaotfload-tool --update --force from a TeX Live command prompt.
- 3. Select the font
Use its installed family name, or point fontspec directly to the local font file.
- 4. Compile and check
Compile with LuaLaTeX and confirm that the output uses the revised font.
If LuaLaTeX keeps using an old version of a custom font, the font file, Windows’ font installation, or Luaotfload’s font database may not reflect your change yet. The usual fix is to install the revised font and refresh Luaotfload’s database; for a font kept with your document, you can also load the file directly.
Update a font installed in Windows
Close TeX editors that may be running, then install the revised font in Windows. Depending on your permissions, use the Windows font installer’s option to install it for your account or for all users. If you replaced a font file manually, make sure Windows is actually using the new file and that it has the family name you expect.
Open a TeX Live command prompt and run:
luaotfload-tool --update --force
This asks Luaotfload to rebuild its font-name database and refresh cached font information. If Windows or your editor was open while you installed the font, restart it before compiling again. Then compile the document with LuaLaTeX.
Use fontspec to select an installed font by its family name:
\documentclass{article}
\usepackage{fontspec}
\setmainfont{My Custom Font}
\begin{document}
This text uses the custom font.
\end{document}
Replace My Custom Font with the family name recorded in the font, which may differ from the filename. LuaLaTeX must be the engine: pdfLaTeX does not use fontspec to load system OpenType fonts.
Load a font file from your project
If you want the document to use a specific font file rather than whichever installed font has a given family name, keep the font in your project and load it by filename. For example, with a file named MyFont-Regular.otf in a fonts subfolder:
\documentclass{article}
\usepackage{fontspec}
\setmainfont{MyFont-Regular.otf}[Path=./fonts/]
\begin{document}
This text uses the font file in the project.
\end{document}
Compile this example with LuaLaTeX. The Path is relative to the directory from which the document is compiled, so run the compiler from the project directory or adjust the path. Loading a file directly is useful when you have several fonts with similar family names or want to control exactly which file is used. If you update that file in place and LuaLaTeX still appears to use stale data, refresh Luaotfload as above.
Check whether LuaLaTeX can find the font
If the update command does not solve the problem, check the basics before changing your LaTeX setup:
- Confirm the engine. Use LuaLaTeX, not pdfLaTeX. In TeXstudio or another editor, verify the selected compiler and compile again.
- Check the name. The family name recognized by the font may not match the file’s name. A direct filename selection avoids ambiguity.
- Confirm the installation. Make sure Windows recognizes the new font and that the file is in a location Luaotfload can discover. If you use a project-local font, check the file and
Pathspelling. - Read the log. The
.logfile usually reports whether the requested font was found or substituted. A missing-font message points to discovery or naming; a successful font load but unchanged appearance may mean the old file is still being selected or the font’s revisions look similar.
If the command is not recognized, open a TeX Live command prompt so the TeX Live executables are on your PATH. You can also check that the TeX Live installation includes LuaLaTeX and Luaotfload. The luaotfload-tool --help output lists the options available in your installed version.
Common mistakes
- Refreshing the wrong installation. If more than one TeX distribution is installed, the editor may run LuaLaTeX from a different distribution than the one whose command prompt you used. Check the compiler path in the editor.
- Using a stale family name. A revised font can have different internal family metadata. Select the new family name or use the file directly.
- Updating the cache but not the font file. The refresh command cannot install a font that Windows or the project directory does not contain.
- Compiling with the wrong engine.
fontspecrequires XeLaTeX or LuaLaTeX; this article’s examples use LuaLaTeX.
For a font used only by one document, keeping the font file in the project and selecting it by filename makes the choice explicit. For a font installed for general use, install it in Windows and refresh Luaotfload’s database when you change it.
References
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.