-
Notifications
You must be signed in to change notification settings - Fork 36
Description
fontspec provides a highly usable interface enabling users to configure opentype fonts in sophisticated ways. However, the handling of .fontspec files undermines users ability to use this power.
Packaged .fontspec files are loaded by default and override settings specified explicitly by users at document level. Please correct me if I'm mistaken about this. (I keep thinking there must be a way, but have not found it.) This makes it unnecessarily (IMHO) difficult for people to override those settings.
It is always possible to write an empty or alternative .fontspec file, but this
- is not ideal for portability/reproducibility;
- does not allow using the
.fontspecdefaults for some instances but not others; - means that changing a single default requires copying the whole file.
A relatively minor example: https://tex.stackexchange.com/q/757922/.
A related example:
\documentclass{article}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}
\setmathfont{NewCM10-Book.otf}[range={up}]
\begin{document}
a
\end{document}fails to compile.
luaotfload | db : Reload initiated (formats: otf,ttf,ttc); reason: File not found: "--.otf".
! Package fontspec Error:
(fontspec) The font "--" cannot be found; this may be but
(fontspec) usually is not a fontspec bug. Either there is a
(fontspec) typo in the font name/file, the font is not
(fontspec) installed (correctly), or there is a bug in the
(fontspec) underlying font loading engine (XeTeX/luaotfload).
For immediate help type H <return>.
...
l.508 \setmathfont{NewCM10-Book.otf}[range={up}]
? h
A font might not be found for many reasons.
Check the spelling, where the font is installed etc. etc.
When in doubt, ask someone for help!Creating an empty NewCM10-Book.fontspec permits compilation, but obviously zaps all the default settings for all instances of the font.
I think fontspec should make it easy for users to override .fontspec defaults at the document level.
Something like
\setmainfont[Renderer=Node]{NewCM10-Book.otf}should ensure the node renderer is used, regardless of any .fontspec file.
Similarly, something like
\setmainfont[fontspec=ignore]{NewCM10-Book.otf}should load the font without reading any .fontspec at all. (Ideally, it should load a new instance, if necessary.)
I understand if the response to this is 'don't use fontspec if you don't like it'. That's fair enough and, if I start using LuaTeX, it is probably what I will do. But for many users, Unicode font configuration without fontspec is not a practical option.