# Why isn't XeTeX properly mapping this Th ligature to T_h?

I realize I am using a proprietary font here, but this is where I discovered this problem (it also applies to other ligatures as well as old style numbers).

\documentclass{article}
\usepackage{fontspec}
\setmainfont[
Path = M:/MyStuff/Fonts/timesnewroman6.80/,
UprightFont = times.ttf,
Ligatures = Discretionary]{tnr}
\begin{document}
Th
\end{document}


When I copy and paste this from the pdf, on the other hand, I get 􀹠 instead of the expected Th. Looking at how this ligature has been encoded (using FontForge), everything seems to have been done properly:

-
Is the resulting PDF available any where? – Khaled Hosny Sep 12 '13 at 21:51
You mean you want the actual file? It's now here: s000.tinyupload.com/index.php?file_id=03340620415189837770 – Sverre Sep 13 '13 at 9:01
Could it be, that you need something along these lines: tex.stackexchange.com/questions/86614/… – canaaerus Sep 13 '13 at 9:23
@canaaerus No, glyphtounicode is for pdfTeX, not XeTeX. Cf. tex.stackexchange.com/questions/110354/… – Sverre Sep 13 '13 at 9:47
Good to know. Unfortunately in the pdf file you provided I can not select th as text with my pdf reader okular. Is the font you use publicly available, so we could try to compile the document ourselves? – canaaerus Sep 13 '13 at 10:06

The Times New Roman font (at least the version shipped with Windows) has a version 3 post table which does not include any glyph names (post is the table that contains glyph names in TrueType fonts). As a result, the PDF driver (xdvipdfmx) will give the glyph synthetic names; for unencoded glyph like this it will simply be glyphXXXX where XXXX is the glyph id.
xdvipdfmx does not currently do such a heuristic as it would require parsing the GSUB table of the font (which is not something the driver usually does; the OpenType layout is done by XeTeX itself), and is not always bulletproof (what if the same glyph is re-used for two different ligatures?).
I think LuaTeX guesses a proper glyph name based on the fact that it is a ligature (would be interesting to see what happens if one inserts the glyph directly using its font id), unfortunately this information is not available to xdvipdfmx at the time of PDF creation. – Khaled Hosny Sep 13 '13 at 17:38
I can find out if you tell me how I do that. I'm used to inserting glyphs directly from fonts with \char"XXXX, where XXXX is the Unicode points, but glyphs like these don't have Unicode points. – Sverre Sep 13 '13 at 17:44