This is a strange bug. I'm using the everyshi
package to place text at a certain position on the page. (Actually I'm using the textpos
package, but I isolated the problem to its usage of everyshi
.) Consider this document:
\documentclass{article}\usepackage{everyshi}\usepackage{fontspec}\usepackage{polyglossia}\setmainlanguage{sanskrit}\newfontfamily\devanagarifont[Renderer=HarfBuzz,Script=Devanagari]{Chandas}\begin{document}\EveryShipout{%\global\setbox255=\vbox{%\vbox to 0pt{%\vskip 2in\hbox{added later किंबहुना।परस्परंद्वैधम्उत्पन्नम्। added later}\vss}\unvbox255}}Some text.\newbox\foo\setbox\foo=\vbox{\hbox{boxed किंबहुना।परस्परंद्वैधम्उत्पन्नम्। boxed}}inline किंबहुना।परस्परंद्वैधम्उत्पन्नम्। and also below\unvbox\foo\end{document}
(The Chandas font is from here.) The resulting PDF looks like:
The Devanagari text is the same in all three places. As in my previous question Getting correct searchable text for Devanagari text, everything works fine (when compiled with lualatex
from Tex Live 2020) i.e. selecting and copying text from the PDF gives correct results, for the inline text and for the manually unvboxed text,
inline किंबहुना।परस्परंद्वैधम्उत्पन्नम्। and also below
boxed किंबहुना।परस्परंद्वैधम्उत्पन्नम्। boxed
but for the text added later with \EveryShipout
, I get:
added later ���बहु��।परस्पर���ध��उत्पन्न��। added later
What could be the reason? Is there a fix?