This is a strange bug. I'm using the textpos
package (which in turn uses the everyshi
package) to place text at a certain position on the page. Consider this document:
% !TEX TS-program = lualatex
\documentclass{article}
\usepackage[absolute]{textpos}
\usepackage{fontspec}
\setmainfont[Renderer=HarfBuzz,Script=Devanagari]{Chandas}
\begin{document}
% package textpos uses \paperheight and \paperwidth
\paperheight=1561bp
\paperwidth=1044bp
\TPGrid{1044}{1561}
\begin{textblock}{200}(173,213)
added later किं बहुना । परस्परं द्वैधम् उत्पन्नम् । added later
\end{textblock}
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: see on Overleaf) 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 textpos
, I get:
added later ��� बहु�� । परस्पर� ��ध�� उत्पन्न�� । added later
What could be the reason? Is there a fix?
AtEveryPageHook
which as far as I can tell doesn't exist and probably cannot be used for this use-case anyway.everyshi
is only 32 lines of well-motivated and self-contained code...