[dev-context] problem with TikZ & ConTeXt MKIV

Hans Hagen pragma at wxs.nl
Wed Jul 22 11:30:39 CEST 2009


Hans Hagen wrote:
> Aditya Mahajan wrote:
>> On Mon, 20 Jul 2009, Hans Hagen wrote:
>>
>>> Mojca Miklavec wrote:
>>>> With 2009.07.20 09:35 MKIV & latest TikZ I get (among many other
>>>> errors that follow)
>>>>
>>>> ! Undefined control sequence.
>>>> \pgfutil at addpdfresource@colorspaces ...olorspaces
>>>>                                                   {#1}
>>>> l.396 ...rspaces{ /pgfprgb [/Pattern /DeviceRGB] }
>>>>
>>>> ?
>>>>
>>>> I don't know if that's a problem with TikZ or ConTeXt (no time to
>>>> debug now, but maybe I can try to prepare some minimal example that
>>>> fails; later). ConTeXt MKII works fine on the same document.
>>>
>>> this has to do with the fact that tikz manipulates documents resources
>>>
>>> it probably went unnnoticed in previous mkiv and mkii, but that way 
>>> tikz was obscuring regular context resource handling (i.e. when you 
>>> use mp an tikz mixed one of them wins with respect to resources so 
>>> the other kind's graphics fail to view i.e. shades, transparencies, etc)
>>>
>>> therefore in mkiv all access is shielded and goes via special macros:
>>>
>>> \pdfbackendsetextgstate {name}{legal pdf}
>>> \pdfbackendsetcolorspace{name}{legal pdf}
>>> \pdfbackendsetpattern   {name}{legal pdf}
>>> \pdfbackendsetshade     {name}{legal pdf}
>>>
>>> normal "legal pdf" is a reference like 123 0 R
>>>
>>> If more access is needed, i can add it but it will always go via an 
>>> interface as in mkiv most \pdfcommands are going away.
>>>
>>> So, tikz needs to be adapted to this. A few weeks ago I looked at it 
>>> but found out that i had an old version so delayed it.
>>
>> I am using the latest context minimals with latest tikz.
>>
>> Test file:
>>
>> \logginall
>> \usemodule[tikz]
>> \starttext
>> \input knuth
>> \stoptext
>>
>>
>> The log file says
>>
>> \pgfutil at addpdfresource@colorspaces 
>> #1->\appendtoPDFdocumentcolorspaces {#1}
>> #1<- /pgfprgb [/Pattern /DeviceRGB]
>> {undefined}
> 
> hm, my logfile says nothing
> 
>> So, \appendtoPDFdocumentcolorspaces is undefined.
>>
>> Now, \append...colorspaces is defined in back-pdf.tex which AFAIU that 
>> file is not loaded. It is redefined in spec-fdf.mkii, so mkii uses 
>> that defininition. In mkiv, back-pdf.mkiv defines 
>> \pdfbackendsetcolorspace.
>>
>> So, which command should tikz use so that it works with both mkii and 
>> mkiv. Or should it do a \beginLUATEX redefinition of some macros for 
>> mkiv?
>> The relavant tikz file is tex/generic/pgf/pgfutil-context.def so the 
>> changes there will not affect latex.
> 
> something
> 
> \ifnum\texengine=\luatexengine
>   \pdfbackendsetcolorspace{pgfprgb}{[/Pattern /DeviceRGB]}%
> \else
>   \appendtoPDFdocumentcolorspaces{/pgfprgb [/Pattern /DeviceRGB]}%
> \fi
> 
> but i didn't test it

i tried to locate the relevant code but as not all context specific code 
sits in the context subdir i give up (Till probably can fix it way faster)

The following code at least gets the resource pointers in the file 
(works with beta on the website) but the objects that are refered to are 
not saved in the file

\def\dopgf at sys@pdf at addtopageresources@extgs   /#1 
#2\relax{\pdfbackendsetextgstate{#1}{#2}}
\def\dopgf at sys@pdf at addtopageresources@patterns/#1 
#2\relax{\pdfbackendsetpattern  {#1}{#2}}

\def\pgf at sys@pdf at addtopageresources@extgs 
#1{\normalexpanded{\noexpand\dopgf at sys@pdf at addtopageresources@extgs 
#1\relax}}
\def\pgf at sys@pdf at addtopageresources@patterns#1{\normalexpanded{\noexpand\dopgf at sys@pdf at addtopageresources@patterns#1\relax}}

the two step is needed because \pdfbackendsetextgstate expects two 
arguments (in principle shades can also be dealt with but tikz keeps 
them local to the xform so there is no problem there)

i tested with:

\starttext

\usetikzlibrary{patterns}

\starttikzpicture
     \draw[pattern color=red,pattern=bricks] (0,0) circle (1cm);
\stoptikzpicture

\stoptext


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the dev-context mailing list