olsak / OpTeX

OpTeX - LuaTeX format with extended Plain TeX macros
http://petr.olsak.net/optex/
35 stars 13 forks source link

\square not working with unicode fonts #80

Closed gromadan closed 2 years ago

gromadan commented 2 years ago

While

$\square$
\bye

works,

\fontfam[LMfonts]
$\square$
\bye

does not.

By the way, I find it a bit dangerous that when a character is missing in a font, then optex does not throw an error. Instead, one obtains just a warning message, which is even not labelled as WARNING, so it is easy to overlook it.

olsak commented 2 years ago

This issue was solved by previous commit https://github.com/olsak/OpTeX/commit/857bdab77340f77c99f12df3d45a43c328357ddd The warnings about missing characters are directly implemented i TeX. Macro programmer can only say if such warnings are printed to the log only (plain TeX) or to the terminal too (opTeX). The format of these warnings in not in our hand.

gromadan commented 2 years ago

I see, sorry, I should have updated my version first.

vlasakm commented 2 years ago

Actually, there is an undocument callback for intercepting warnings (show_warning_message), but this particular warning goes through different code path, so it is not useful here. But maybe it would be worth for other cases?

For example the following:

\fontfam[lm]
\directlua{
callback.add_to_callback("show_warning_message", function()
    texio.write_nl(string.format("WARNING l.\pcent s: (\pcent s): \pcent s", status.linenumber, status.lastwarningtag, status.lastwarningstring))
end)
}
\pdfrestore
\bye

Produces warning in the OpTeX format:

WARNING l.8: (pdf backend): 'restore' is missing a 'save'

instead of

warning  (pdf backend): 'restore' is missing a 'save'

But AFAIK what LuaTeX calls "warnings" are usually checks for consistencies in pdfTeX / LuaTeX additions and often like here with the "backend", the warning is emitted "when the page gets written to PDF", which doesn't really correspond to the printed line number, which might be misleading. Other misleading thing is, that the warning does not come from OpTeX directly, although with the change above, would use the same formatting.

@gromadan There are actually several options for reporting missing characters, contolled by the value of \tracinglostchars:

So if you really want errors you can try \tracinglostchars=3. (OpTeX by default has \tracinglostchars=2). For example:

\fontfam[lm]
\tracinglostchars=3
$\square$
\bye

stops with:

Missing character: There is no ^^C (U+0003) in font rsfs10!
.
l.3 $\square$

?

@olsak I just noticed that \loggingall sets \tracinglostchars=1, but it should probably also be 2.