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?

AtEveryPageHookwhich as far as I can tell doesn't exist and probably cannot be used for this use-case anyway. – ShreevatsaR Sep 13 '20 at 17:12everyshiis only 32 lines of well-motivated and self-contained code... – ShreevatsaR Sep 13 '20 at 17:20textpospackage was doing… I guess it too must have been updated now.) – ShreevatsaR Dec 16 '20 at 19:22textposand had replaced it witheveryshifor debugging before asking the question, so I edited the question just now to use the original syntax I had been using. I guesstextposhas also been updated now and will no longer have the error (all text will copy fine). Thank you! Could you post that as an answer so that I can accept it and get this question off the Unanswered list? – ShreevatsaR Apr 06 '21 at 22:33