[Tex/LaTex] \pdfglyphtounicode with XeTeX

libertineligaturesxetex

One well known problem with using the font Linux Libertine (presumably other fonts too), is that its many ligatures are not recognized in the resulting pdf-file, so that it's not possible to search for or copy a ligature such as 'Th'.

One way of fixing this is addressed in the question Make ligatures in Linux Libertine copyable (and searchable)

But the fix addressed there doesn't work with XeTeX. Compiling Ulrike's MWE will only result in an error message

> Undefined control sequence.
l.7 \pdfglyphtounicode

So what is the best fix for XeTeX?

Best Answer

XeTeX simply doesn't support the \pdfglyphtounicode primitive, so this route is not available. To understand why, remember that pdfTeX is 8-bit while XeTeX is natively UTF-8. AS such, it's perfectly reasonable for XeTeX to expect fonts to be 'properly' constructed to have glyphs in the appropriately-named slots and therefore to work correctly in the PDF output with no 'trickery'.

Taking the 'what to do' side of things, the problem is most likely with the font. For example, some fonts have the correct glyphs but in the 'wrong' places (e.g. in the Private Use Area). That's really not a 'TeX problem': all that can be done is to talk with the font designers and try to get them to fix it.

Related Question