# How to get correct content from PDF copying/pasting with Source Han?

I installed the “Language-specific OTFs” version of Source Han Sans from Adobe Font’s Release page, e.g., SourceHanSansSC-Regular.otf, which sets the default ideographs suitable under Simplified Chinese convention but still provides “full character coverage or the ability to language-tag text to use glyphs that are appropriate for the other languages”.

When I create a PDF via

\documentclass{article}
\usepackage{fontspec}
\setmainfont{SourceHanSansSC-Regular.otf}
\newcommand\test{\char"8FD4 E567F\par}
\begin{document}
\test
\test
\test
\test
\test
\test
\end{document}


The output looks fine, with the ideograph U+8FD4 in its five different forms. Also, notice that the digit height is slightly lower than the cap height in Latin/Default Script while the two are equal in CJK Script. This is desirable design in different scripts.

But copying/pasting from the PDF has problem:

From XeLaTeX    From LuaLaTeX

􉲯E567F          返E567F
􉲰E567F          返E567F
􉲭E567F          返E567F
􏖂E567F          返E567F


Observe that both engines have problem with digits under Latin Script: XeTeX thinks they are “tofu” while LuaTeX thinks they are “fullwidth”-variants (U+FF10U+FF19). Furthermore, XeTeX fails to embed the ideograph info U+8FD4 for languages other than Simplified Chinese into the PDF.

• My OS: Windows 8 and the fonts are installed system-wise.
• My TeX Distribution: MiKTeX 2.9.7000 with everything up to date (as of 2019/04/30).
• My PDF Viewer: Adobe Acrobat Reader where I did the copying/pasting.

Maybe related posts:

Added: It appears that issuing \XeTeXgenerateactualtext=1 in the preamble fixes the copying/pasting problem for XeTeX, see also Who changed my Chinese character?. Any ideas about LuaTeX?

I also found many CMap files in the Resources folder of the Release branch. Should I use UniSourceHanSansCN-UTF16-H and, if so, how?

• On "normal" pdflatex the package cmap helped me a lot. I don't now if it works with xetex or luatex. – Oleg Lobachev May 1 at 16:23
• Regarding the digits I would suggest that you add an issue at the font github. – Ulrike Fischer May 1 at 16:24
• @UlrikeFischer Negative. The digit substitution is documented on page 18 of the official font readme file (in English). The equal digit height and cap height version is encoded by default, while the lower digit height version is commonly used in Latin fonts (such as CM, Minion, etc.). Copying/pasting from the readme file (probably generated by Adobe’s commercial software) shows no problem, so it is unlikely a font problem. – Ruixi Zhang May 1 at 17:21
• @OlegLobachev I just realized that \XeTeXgenerateactualtext=1 helps in the XeTeX case. Unfortunately, this new primitive (added in 2016) has not been documented AFAIK. See the thread potential new feature: \XeTeXgenerateactualtext and the still opened ticket #124 Document \XeTeXgenerateactualtext. – Ruixi Zhang May 1 at 17:27