3

Here's an example of a tex \vbox with some devanagari text in it. My code adds contents of \vbox to document twice, first its copy (using \copy), and later itself (using \box). Both copies look similarly typeset in pdf, which is great. But upon copy-pasting contents from the pdf,[1] I find that the contents added by \copy look different from the contents added by \box. The former has some glyphs turned into tofu 􀈽; looks like the only glyph tofued is reordered Devanagari vowel sign ि i.e. U+093F. The latter doesn't tofu anything, but adds extra spurious space after the consonant-vowel pairs where ि is the consonant.

[1] I used Adobe Reader as it seems to be the only pdf reader that fully supports ActualText feature of pdf format that HarfBuzz utilizes.

Code:

% >> lualatex copyhb.tex
\documentclass{article}
\pagenumbering{gobble}

\usepackage{fontspec}
\newfontfamily\devanagarifont[Script=Devanagari, Renderer=HarfBuzz, Ligatures=TeX]{Noto Sans Devanagari}

\begin{document}

\newbox\tempbox
\setbox\tempbox=\vbox{{\devanagarifont किं बहुना । परस्परं द्वैधम् उत्पन्नम् । पिताजी ज्योतिषी सुकरात\endgraf}}

Box copy: \copy\tempbox

Box contents: \box\tempbox

\end{document}

Screenshot: Screenshot of pdf

Result of copy-paste:

Box copy: 􀈽कंबहुना । परस्परंद्वै धम्उत्पन्नम्। 􀈱पताजी ज्यो􀈱तषी सुकरात

Box contents: कि ं बहुना । परस्परंद्वै धम्उत्पन्नम्। पि ताजी ज्योति षी सुकरात

As can be seen, the 3 tofus 􀈽 placed in "Box copy" contents are for vowel notation ि of consonant-vowel pairs: कि, पि, and ति. Also to be noticed is that this tofuing process gobbles word space, and makes किं बहुना as one word 􀈽कंबहुना. The "Box contents" has correct glyphs, but has extra spacing after same consonant-vowel pairs कि, पि, and ति. The original box contents luckily doesn't gobble space between words किं and बहुना. So IMO if \box contents get rid of extra space after consonant-vowel pairs & if contents added to pdf by \copy are same as those added by \box, then this copy-paste problem should get resolved.

Side note for Renderer=Node: Tofu and spurious spacing problem does not occur with Node renderer. Though it has its own known problem of reordering ि and consonant of its consonant-vowel pair.

4
  • I ran into similar issues (see this or rather its followup, this); I found a workaround by setting ActualText directly (as in this answer). I wrote a quick (hurriedly written, so possibly not very clear) blog post as well. Commented Oct 19, 2020 at 3:04
  • @ShreevatsaR Thanks! Try the dev branch of luaotfload (github.com/latex3/luaotfload/tree/dev), it resolves the discrepancy between ActualText contents of \copy & \box, and \copy now behaves like \box. Though one problem persists: the space that gets added after reordered consonant-vowel pairs that have ` ि`. I haven't tested if spurious space gets added after any other glyph combination, will file a separate issue for extra space. I will update this question after the dev branch is merged into master and released.
    – codepoet
    Commented Oct 19, 2020 at 17:33
  • Thank you; I'll give it a try sometime. Commented Oct 19, 2020 at 17:47
  • @ShreevatsaR Its still under works, I just found that it doesn't work with \hbox because his lua code does some magic using post_linebreak_filter which is not called in \hbox. Also, spurious space is added in cases other than that having ` ि` as vowel in consonant vowel pair. For instance space is added after र्गु in word दुर्गुणों. Here र्+गु was replaced with matra form र्गु.
    – codepoet
    Commented Oct 19, 2020 at 18:23

0

You must log in to answer this question.

Browse other questions tagged .