[dvipdfmx] Multiple color stacks
Joseph Wright
joseph.wright at morningstar2.co.uk
Tue Apr 19 17:35:31 CEST 2022
Hello all,
A whilst ago, dvipdfmx was extended to support multiple color stacks.
These are set up independent of the 'original' color stack, which can be
accessed using either "color push" or "bc" specials. When this was
introduced, I spotted an issue in that after some operations, dvipdfmx
resets the color to that from this original stack. We had hoped at that
stage that this could all be handled in the macro layer.
We recently tried to switch the main LaTeX graphics .def files to use
multiple color stacks, and immediately ran into issues. Also at the
macro level we can catch some 'hidden' resets, we can't deal with users
having simple bcontent/econtent pairs around - these come up from
various sources. So we had to back out using the multiple stacks. As an
example, the following shows the behaviour:
\special{pdfcolorstackinit 0 (0 g 0 G)}
\special{pdfcolorstack 0 push (0 0 1 rg)}
Some text
\special{pdf:bcontent}
\special{pdfcolorstack 0 push (1 0 0 rg)}
Intermediate text
\special{pdf:econtent}
Some more text
\bye
At present, it seems that whilst the stack support looks OK, it's really
not usable for day-to-day LaTeX documents, as we simply can't deal with
the reset requirement at the macro level. If you look at a pdfTeX example
\pdfcolorstack 0 push {0 0 1 rg}
Some text
\pdfsave
\pdfcolorstack 0 push {1 0 0 rg}
Intermediate text
\pdfrestore
Some more text
\bye
then all works 'out of the box'.
What I think we need for the multiple stacks to work is for the
'classical' one to be the same as pdfcolorstack 0, so
\special{color push Black} -> \special{pdfcolorstack 0 push (0 g)}
\special{pdf:bc [0 0 1]} -> \special{pdfcolorstack 0 push (0 0 1 rg)}
and with therefore "pdfcolorstackinit 0" not required. We'd then be able
to use the same code more-or-less in pdfTeX, LuaTeX and dvipdfmx routes.
As it stands, I can't risk using the multiple stack approach, which is a
real shame.
Joseph
More information about the dvipdfmx
mailing list.