The following MWE does not work for me:

% !TeX program = LuaLaTeX
% !TeX encoding = UTF-8
It was a dark and stormy night.

My objective to is to filter out the fontspec error message telling me that The font "DoesNotExist" cannot be found. Above, I used "The" as the only filter word, since I am not sure if fontspec is inerting non-breaking space in its messages. From the silence package documentation, I expect that the starred command will filter the error message during compilation. No joy.

Could it be that fontspec, or luatex, or the expl3 syntax used within fontspec.sty, is incompatible with silence? Or am I doing something wrong?

My ultimate objective is to catch the fontspec error for a particular font, and substitute my own error message that is more helpful (to me).

  • That's a pretty heavy error, which I see reported by luaotfload, not fontspec. Aren't you looking for something more like LaTeX Font Warning: Font shape EU2/DoesNotExist... warning? – jon Oct 13 '16 at 2:06
  • Hmm.. The error I get says that it is reported by fontspec (I can see it in the fontspec style file). However, it is quite possible that luaotfload is cooperating with fontspec there. Alas, I cannot easily decode what is happening in the style files. In any case: I found a workaround that doesn't answer my question, but minimally does what I need it to do. I can edit one of the macros in fontspec-luatex.sty, so that when it give the cannot find font message, it also says "If the missing font is DoesNotExist, see item 14.3 in the handout." Then attention is directed there. – user103221 Oct 13 '16 at 3:55
  • Are you looking in the actual .log or working through the .sty files? I was just looking at the .log that results from your test file. (And, fontspec definitely relies on luaotfload: there'd be no fontspec for LuaTeX without it ... or at least a radically different fontspec.) – jon Oct 13 '16 at 4:19
  • Didn't look in the log... Got caught up looking at the .sty files. Sometimes simple things are overlooked. I just went by the message that appeared in the console, which (in TeXworks) mentions fontspec rather than luaotfload. Or, if it does mention luaotfload, that message has disappeared from view by the time it is noticed. Task for tomorrow. – user103221 Oct 13 '16 at 5:21

The silence package does nothing at all with messages generated by fontspec, that uses the expl3 features for them.

The error message is

! fontspec error: "font-not-found"
! The font "DoesNotExist" cannot be found.
! See the fontspec documentation for further information.
! For immediate help type H <return>.

There is a simple redirection mechanism if you want to silence warning or error messages:


\msg_redirect_name:nnn { fontspec } { font-not-found } { none }



It was a dark and stormy night.


However, this will end up in a lower level error message:

! Font \EU2/DoesNotExist(0)/m/n/10=DoesNotExist:mode=node;+tlig; at 10pt not lo
adable: metric data not found or bad.
  • Ah, that tells me that I was trying to do the wrong thing to start with. That's helpful in itself. If I cannot (myself) figure out how to handle the lower-level message, then I will reply on editing the fontspec message. I don't have to hide the error so much as produce a different error message. Editing the fontspec message is is easy as copying that section of code to the Preamble immediately below loading fontspec, and editing it there. All of it is loaded from an input file, so it is invisible to the user. – user103221 Oct 13 '16 at 14:42
  • I tried the code above, which performs as described. But apparently \msg_redirect_name can only redirect to a class of results, such as warning or none. Ideally, I would like the redirect to go to a different error message, which I will define in expl3. so instead of none in the above code, the redirect would go to myown-error-message-macro which I can create by imitating the original expl3 code. The ordinary latex analogy is the renewcommand feature. – user103221 Oct 13 '16 at 20:07
  • @RobtA That's not provided, I'm afraid. You might file a motivated feature request. – egreg Oct 13 '16 at 20:14
  • Ah, that explains why I could not find it via search! But I am not faced with a show-stopper problem, just a convenience for the benefit of those who don't read my instructions before trying to compile. Useful, but not priority. Thanks. – user103221 Oct 13 '16 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy