[dvipdfmx] Color stacks and transformations

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Mar 16 19:05:24 CET 2021


On 16/03/2021 17:26, Shunsaku Hirata wrote:
> Hi,
> 
> Thank you for the report.
> 
> The problem occurs because dvipdfmx tries to re-install the color
> recorded in the pdf:color color stack (default color in the example)
> just after graphics state restore operation.
> This behavior is to ensure the color change induced by pdf:color
> within a graphics state save-restore block to be propagated outside
> of the block.
> 
> I will consider a solution to this issue. Probably it takes some time.
> 
> Thanks,
> Shunsaku Hirata

Hello Shunsaku,

Thanks for the feedback.

----

On the 'restore the color' business, I am slightly confused by the 
intent. I can see it does what you describe, in for example

     \leavevmode
     \special{x:gsave}%
     \special{pdf:bc [1 0 0]}%
     Hello
     \special{x:grestore}%
     world
     \special{pdf:ec}%
     \bye

but that behaviour contrasts with pdfTeX

     \leavevmode
     \pdfsave
     \pdfcolorstack 0 push{1 0 0 rg}%
     Hello
     \pdfrestore
     world
     \pdfcolorstack 0 pop
     \bye

which admittedly is a lot more aggressive all-round here. However, both 
of these demos look unbalanced to me: I'd expect in a well-behaved real 
example that the color stack would be popped *inside* the graphics state 
save/restore pair.

----

I can think of at least a couple of approaches that would work for me if 
available from the driver.

- You could disable re-insertion if pdfcolorstackinit is encountered. 
The moment someone is setting \special{pdfcolorstackinit 1 ...} they are
likely to be using that approach exclusively.

- You could have a keyword-based setting to do the same, for example

     \special{pdfcolorstackpriority on}

  (would allow \special{pdfcolorstackpriority off} if people really need
   the old behavior back)

---

At the macro level I might try setting the 'classical' stack to hold the 
same color as first 'new' one, as they should be equivalent anyway. The 
only slight wrinkle is that as the two take different color spec 
formats, there will be places that this is more challenging. That is 
likely the best way to make things work right now.

Regards,

Joseph


More information about the dvipdfmx mailing list.