Re: xelatex, revtex4-2 vs article, CID mapping destroyed after gs-based concatenation
Bastien DUMONT <[email protected]> Mon, 12 Jan 2026 18:38:00 +0000
| Newsgroups | gmane.comp.tex.texhax |
|---|---|
| Message-ID | <aWU_ezdcDobx7fHX@localhost> |
Hello,
This is due to a restriction in ghostscript that could be lifted by this
commit, which apparently has still not been merged into ghostscript:
https://cgit.ghostscript.com/cgi-bin/cgit.cgi/ghostpdl.git/patch/?id=65f6ea3c1660ea05b6a575cbe738e66e54b9a497
The corresponding bug report is here: https://bugs.ghostscript.com/show_bug.cgi?id=708042
I compiled successfully a patched version of ghostscript on my computer
following this procedure:
```
wget 'https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs10040/ghostpdl-10.04.0.tar.gz'
7z x ghostpdl-10.04.0.tar.gz && 7z x ghostpdl-10.04.0.tar
cd ghostpdl-10.04.0
wget 'https://cgit.ghostscript.com/cgi-bin/cgit.cgi/ghostpdl.git/patch/?id=65f6ea3c1660ea05b6a575cbe738e66e54b9a497'
git apply index.html\?id=65f6ea3c1660ea05b6a575cbe738e66e54b9a497
find . -name configure -execdir chmod +x '{}' \;
./configure
make
```
It may work with versions later than 10.04 as well, I never tried.
Best regards,
Bastien
Le Monday 12 January 2026 à 06:49:10PM, Norbert Preining a écrit :
> Hi all,
>
> I have posted this already on SX
> https://tex.stackexchange.com/questions/758136/xelatex-and-ghostscript-based-concatenation-drops-cid-mapping-with-revtex-4-2
> but here now, too:
>
> The following test file:
> ```
> \documentclass{revtex4-2}
> \begin{document}
> efficient
> \end{document}
> ```
> when compiled with `xelatex` and combined with itself (or any other PDF file) using ghostscript as in
> ```
> gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -sOutputFile=foo.pdf file1.pdf file1.pdf
> ```
> produces a broken text mapping, as seen when running txt2pdf.py (from pdfminer-six) or copy-pasting the word
> ```
> $ pdf2txt.py foo.pdf
> e(cid:123)cient
>
> 1
>
>
> e(cid:123)cient
>
> 1
> ```
>
> Now, when I use `article` documentclass, everything works and pdf2txt.py returns:
> ```
> efficient
>
> 1
>
>
> efficient
>
> 1
> ```
> (mind the unicode ff ligature)
>
> Has anyone an idea where to search for what `revtex4-2.cls` is doing wrongly?
>
> Thanks
>
> [2026-01-12] Additional finding: Decompressing the pdf files, I see the following differences:
>
> * between the original (pre-concatenation) PDF (left = revtex4-2, right=article) the text representation/generation has changed:
> ```
> stream
> - q 1 0 0 1 72 769.89 cm 0 G 0 g BT /F1 9.9626 Tf 485.113 35.866 Td[<0052>]TJ -493.15 -25.903 Td[<0032007b002b00420032004d>28<0069>]TJ ET Q
> + q 1 0 0 1 72 769.89 cm 0 G 0 g BT /F1 9.9626 Tf 76.712 -62.765 Td[<0032007b002b00420032004d>27<0069>]TJ 154.421 -567.87 Td[<0052>]TJ ET Q
>
> endstream
> ```
>
> Looking at the uncompressed PDFs **after** concatenation, I clearly see that the CID map has changed:
> ```
> @@ -192,13 +192,14 @@
> 1 begincodespacerange
> <0000><ffff>
> endcodespacerange
> -6 beginbfrange
> +7 beginbfrange
> <002b><002b><0063>
> <0032><0032><0065>
> <0042><0042><0069>
> <004d><004d><006e>
> <0052><0052><0031>
> <0069><0069><0074>
> +<007b><007b><fb000069>
> endbfrange
> endcmap
> CMapName currentdict /CMap defineresource pop
> ```
>
> So it seems some settings in revtex4-2 does change how text ends up in the PDF.
>
> Note that both pdfs contain the same fonts in the same encodings (only the random font prefix has changed).
>
> Thanks for any insight!
>
> Best regards
>
> Norbert
>
> --
> DI Dr Norbert Preining https://www.preining.info
> arXiv / Cornell University + IFMGA Guide + TU Wien + TeX Live
> GPG: 0x860CDC13 fp: F7D8 A928 26E3 16A1 9FA0 ACF0 6CAC A448 860C DC13