I'm trying to find a solution for https://stackoverflow.com/questions/65177985/pandoc-markdown-to-pdf-fixing-missing-character-warnings ; and for that, I found:
... and I almost got there with combofont
; here is an MWE, with the headers output from pandoc
:
tester.tex
:
(EDIT: look in the history to see the original output from pandoc
- I've cut off most of the preamble stuff, and it seems the below MWE reproduces the same problem):
\documentclass[]{article}
\usepackage{lmodern}
\usepackage{combofont}
\setupcombofont{multiscript-regular}
{
{file:lmroman10-regular.otf:\combodefaultfeat} at #1pt, % have this in C:/Windows/Fonts/lmroman10-regular.otf ; C:/bin/texlive/2020/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf
{file:DejaVuSerif.ttf} at #1pt % have this in C:/Windows/Fonts/DejaVuSerif.ttf ; C:/msys64/mingw64/share/fonts/TTF/DejaVuSerif.ttf ;
}
{
{},
fallback
}
\DeclareFontFamily{TU}{multiscript}{}
\DeclareFontShape {TU}{multiscript}{m}{n} {<->combo*multiscript-regular}{}
%\renewcommand\ttdefault{multiscript} % TEX.SE 514940
\AtBeginDocument{\fontfamily{multiscript}\selectfont} % have to do it this way; if the ...\selectfont is just in the header, then \begin{document} resets it, so then we'd have to write the ...\selectfont in the body of the document explicitly, which we'd rather not do
\author{}
\date{}
\begin{document}
Here is a test of a glyph that otherwise trips up *latex: ┌
%\begin{verbatim}
%Here is a test of the same glyph inside verbatim: ┌ ...
%\end{verbatim}
\end{document}
Compiling this:
$ lualatex -halt-on-error -interaction=batchmode tester.tex
This is LuaHBTeX, Version 1.12.0 (TeX Live 2020/W32TeX)
restricted system commands enabled.
luaotfload | loaders : eval: found tfmdata for "luaotfload<1>", injecting.
$ grep 'Missing character' tester.log
... and the PDF result is:
So, for normal/roman/upright text, the glyph is successfully replaced, and there are no 'Missing character' messages in log.
Now, if you uncomment the {verbatim}
snippet in the tester.tex
, the compilation result is:
$ lualatex -halt-on-error -interaction=batchmode tester.tex
This is LuaHBTeX, Version 1.12.0 (TeX Live 2020/W32TeX)
restricted system commands enabled.
luaotfload | loaders : eval: found tfmdata for "luaotfload<1>", injecting.
$ grep 'Missing character' tester.log
Missing character: There is no ┌ (U+250C) in font [lmmono10-regular]:!
... and the resulting PDF is:
So, the character did get replaced in normal text and font - but did not get replaced in the {verbatim}
environment text, where teletype font is used (and a corresponding "Missing character" is output in log).
My question is: how can I set up combofont
, so I can provide a character fallback, for everywhere a teletype font is used (verbatim
and lstlisting
environments, etc)?
(as a note, I was originally interested to provide fallback glyphs only for the teletype text/font; the only reason I provide a fallback for the normal text/font in the above MWE, is because that is the only thing I could get working so far - so at least it is a good starting point).
EDIT: Found a work-around here: Define fallback font for missing glyphs in LuaLaTeX - seemingly, all I was missing was a \renewcommand\ttdefault{multiscript}
after the \DeclareFontShape
command. This does work, and produces this in PDF:
... however, then this uses DejaVuSerif.ttf
as fallback for the teletype font - so I do not get a teletype/mono font shown at all; but what I'd like is to use DejaVuSerif.ttf
as fallback for normal/upright/roman text - and use DejaVuSansMono.ttf
as fallback for teletype text; how can I do that?