3

When I create a pdf file containing English text using pdflatex, I can copy text from it and get a reasonably fair text when pasted in a text editor. But when I do the same with a pdf of Malayalam text created using xelatex, the pasted text has several gaps and often wrong characters too. I was under the impression that the pdf created with xelatex will also have Unicode text, which then can be searched, indexed and copied. At least, that is the impression I got from reading about xelatex. On the other hand, I found that Malayalam text can be clearly copied from a pdf created from Libre Office Writer. Is my impression about XeLaTeX wrong, or my understanding of the pdf format wrong? Or am I mistaken somewhere else? I would be very grateful if someone knowledgeable about this can give a reply.

2
  • Could you please provide an MWE? Commented Jul 5, 2019 at 11:14
  • An MWE from tex.stackexchange.com/q/89118/157031: \documentclass{article} \usepackage{fontspec} \setmainfont[Script=Malayalam]{Rachana} \begin{document} മലയാളം \TeX ഉപയോഗിച്ച് ടൈപ്പ്സെറ്റ് ചെയ്തത് \end{document} Commented Jul 5, 2019 at 13:02

2 Answers 2

1

Malayalam is a script related to Sanskrit, and the single characters undergo considerable changes from the input to the output. In particular, some vowels are placed before the corresponding consonant, and glyphs are put together into compounds, so called ligatures. See https://en.wikipedia.org/wiki/Malayalam_script for examples of ligatures and vowel placements (and much more!).

On the font side, these compounds of consonants are usually precomposed, that is, drawn separately to make them look right. During the typesetting, the characters are replaced with the pre-composed codepoints in the fonts, but those often don't have a textual representation.

There are ways around is, and the font can declare a mapping from code points to character sequences, but this is often not available.

2
  • What about PDF/A support? AFAIK, this format mandates that the Unicode input strings are preserved, thus bypassing the problematic input string→glyph→input-like string conversion. With proper language tagging I can imagine that this works
    – lemzwerg
    Commented Nov 5, 2019 at 7:41
  • I agree that PDF/A can help here, but this is probably not what xelatex produces.
    – norbert
    Commented Nov 5, 2019 at 8:31
1

This seems to be a technical limitation of the XeLaTeX engine. The issue is incomplete CMAP (character map) of the font embedded in PDF. Recent versions of luahbtex can generate PDF containing complex script texts which can be copy pasted back to a text editor properly. Here is one example of such a document: http://books.sayahna.org/ml/pdf/bbh-web.pdf

1
  • This also doesn't seem to solve that problem. When I copy and paste one paragraph from the above link into a text editor, the symbols for the vowel 'എ' joined to consonants is replaced by something else. Perhaps, might lualatex solve the problem?
    – Sasi
    Commented May 4, 2020 at 6:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .