[dvipdfmx] Possible extensions to color special support

Joseph Wright joseph.wright at morningstar2.co.uk
Wed Sep 2 23:38:21 CEST 2020


On 02/09/2020 16:30, Shunsaku Hirata wrote:
> Hi Joseph,
> 
>> The first area is the stroke/fill ('non-stroke') split. At present,
>> "pdf:bcolor" pushes both stroke and non-stroke color to the stack. One
>> can set the two separately, but only by using a PDF literal, which
>> therefore does not go to the stack. This can lead to 'interesting'
>> outcomes if the two are inter-mixed. Would something like
>>
>>       pdf:strokecolor / pdf:sc
>>       pdf:fillcolor / pdf:fc
>>
>> be possible to set only the stroke or fill. Both of these would still
>> 'pair' with pdf:ec, in the same way in pdfTeX one can do
>>
>>       \pdfcolorstack <n> push {0.1 0.2 0.3 0.4 k}
>>       ...
>>       \pdfcolorstack <n> pop
>>
>> as well as
>>
>>       \pdfcolorstack <n> push {0.1 0.2 0.3 0.4 k 0.1 0.2 0.3 0.4 K}
>>       ...
>>       \pdfcolorstack <n> pop
> 
> So pdf:sc in the example above pushes specified stroke color
> and current fill color onto the color stack.
> 
> Both adding new specials and extending existing pdf:bc special
> to accept "stroke" and "fill" keyword like
> 
>    pdf:bc fill [1 0 0]
> 
> can be easily done.

A keyword would also work fine: which ever is easier to code for you, we 
can work with.

>> The second thing is highlighted in some ways by that pdfTeX example: the
>> existence of more than one stack. Additional stacks are useful for
>> footnotes, transparency, etc., and so are less easily supported using
>> dvipdfmx than with pdfTeX. (When using dvips, one can code in the stacks
>> manually using PostScript.) The current 'main' stack approach must of
>> course not change, so any pdf:bc or similar will always use this main
>> 'stack 0'. A possible way to add additional stacks would be to work
>> closer to pdfTeX, i.e. have them take 'raw' PDF specs, so perhaps
>> pdf:colorstack/pdf:cs
>>
>>       \special{pdf:cs 1 push 0.1 0.2 0.3 0.4 k}
>>       ...
>>       \special{pdf:cs 1 pop}
>>
>> i.e. syntax
>>
>>       pdf:cs <n> [push|pop] <PDF literal>
>>
> 
> I rather want to avoid using "PDF literal" which can affect outside
> the special command as much as possible since this makes it
> difficult to manage things properly.
> 
> Anyway, I will consider extending dvipdfmx to support such features.
> 
> For transparency support, I already added new special commands
> pdf:bxgstate and pdf:exgstate which can be used as
> 
>    \special{pdf:bxgstate << /CA 0.5 /ca 0.5 >>}
>    Transparent text.
>    \special{pdf:exgstate}%
> 
> where a dictionary object representing ExtGState should be supplied
> as an argument.

I'll explore these specials: I was not aware of them.

Joseph


More information about the dvipdfmx mailing list.