0

(This is based on my workaround related to my answer to using emoticons with pdflatex — this workaround is discussed in another answer). The gist is: it turns out that in the years after I posted the answer, the behavior of xelatex changed!

Up to TeXLive2018, the PDF files produced by xelatex were “color-neutral”: when \includegraphicsed, they would inherit the current foreground color from the parent document. However, with TeXLive2021 the generated PDF file has color-setting commands. The result: one must binary-edit (unreliable and inconvenient) this PDF file before it may be fully used in other documents. (The details of the change and which postprocessing is needed is discussed in the link above. The core is the following change:)

- q 1 0 0 1 72 -62.967 cm                 BT /F1 9.9626 Tf -72 64.65 Td[<1841>]TJ ET Q
+ q 1 0 0 1 72 -62.967 cm 0 G 0 g 0 g 0 G BT /F1 9.9626 Tf -72 64.65 Td[<1841>]TJ ET Q

Question: is there a way to advice xelatex to not use color-setting commands?


In more detail: with the input file like

\documentclass[crop]{standalone}
\usepackage{fontspec}
\setmainfont{DejaVu Sans}  % https://dejavu-fonts.github.io/
\begin{document}
⇢
\end{document}

then uncompressing with pdftk file.pdf output uncompress-file.pdf uncompress (every) page’s content looks like what is shown above.


To test color-neutrality, one can include the generated PDF file as in:

\documentclass{article}
\usepackage{graphicx,xcolor}
\begin{document}
\color{red}\includegraphics[height=1in]{emoji-from-list.pdf}
\end{document}

(with color-neutral included PDF file the content should be red).

  • 2
    I really don't like it if I have to follow up three links only to understand what a question is about. Please make your question self contained, links should only be references. – Ulrike Fischer Feb 24 '23 at 13:04
  • @UlrikeFischer: I wrote it this way because I thought it is self-contained. I thought that the links are needed only to explain the motivations! I still do not understand which parts of the linked questions would help you understand what the question is about. Hints? – Ilya Zakharevich Feb 25 '23 at 10:57
  • 1
    Your question is missing an example that can be used for a test. – Ulrike Fischer Feb 25 '23 at 11:21
  • Yes, thanks! Testing your examples, this became clear — so now I think it is better. – Ilya Zakharevich Feb 25 '23 at 11:33

1 Answers1

4

You can try to compile with

xelatex -output-driver="xdvipdfmx -c" file

For

\ExplSyntaxOn
\sys_ensure_backend:
\pdf_uncompress:
\ExplSyntaxOff

\documentclass{article} \begin{document} abc \end{document}

it changes the stream from

stream
 q 1 0 0 1 72 769.89 cm 0 G 0 g BT /F1 9.9626 Tf 76.712 -62.765 Td[<001c0023>-28<002b>]TJ 154.421 -567.87 Td[<0052>]TJ ET Q

endstream

to

stream
 q 1 0 0 1 72 769.89 cm BT /F1 9.9626 Tf 76.712 -62.765 Td[<001c0023>-28<002b>]TJ 154.421 -567.87 Td[<0052>]TJ ET Q

endstream

As an alternative use lualatex.

Ulrike Fischer
  • 327,261
  • lualatex works indeed, thanks (with TeXLive2021)! Unfortunately, with xelatex and the driver xdvipdfmx the output (with TeXLive2021) still contains 0 G 0 g. In more detail: the code you gave does not compile; removing the preamble (and uncompressing with pdftk) shows color-setting commands. – Ilya Zakharevich Feb 25 '23 at 11:13
  • works fine for me in texlive 2021 (it fails in 2020), are you sure that you used the -c option? And there is no need to use pdftk, you can set the compresslevel with the -z option (that is what \pdf_uncompress: is doing). – Ulrike Fischer Feb 26 '23 at 11:53
  • Thanks for -z. (Since xelatex and lualatex are useless on my system, I do not know anything about their command-line syntax.) Yes, I’m sure about -c option! Anything else I can do for debugging? – Ilya Zakharevich Feb 27 '23 at 01:56
  • BTW, while lualatex works (and does not take minute[s] to finish!), it produces wrong PDF. An obsolete version of the requested font is used. Is it a bug, or an expected behavior? – Ilya Zakharevich Feb 27 '23 at 01:57
  • Same results with -no-pdf and then running xdvipdfmx -c -z 0 emoji-from-list.xdv. The producer is xdvipdfmx (20210318). (Already the first generated object — №6 — contains 0 g 0 G.) – Ilya Zakharevich Mar 01 '23 at 07:07
  • my xdvipdfmx on texlive 2021 is a bit newer (xdvipdfmx Version 20211117), it is quite possible that windows got an update that other systems got only with tl2022. Regarding fonts with lualatex: the log-file shows which fonts lualatex uses, and with the fontspec options (e.g. Path) it is possible to configure that. – Ulrike Fischer Mar 01 '23 at 07:47
  • TeXLive2021 was released 2021-03-25. It cannot contain anything that new. See https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2021/. You must have updated after this release… – Ilya Zakharevich Mar 01 '23 at 11:34
  • On windows it can. We get updates of some binaries during the year. I remember that I could test some new features earlier. – Ulrike Fischer Mar 01 '23 at 12:04
  • I’m on windows. No updates. (Without my — manual — actions.) [I do not update manually — for me a reproducible state is much more important than getting new exciting bugs in unpredictable moments.] – Ilya Zakharevich Mar 02 '23 at 11:25