# [NTG-context] Ugly bug with TikZ in recent ConTeXt MKIV

Hans Hagen pragma at wxs.nl
Thu Nov 18 10:49:53 CET 2010

On 18-11-2010 10:03, Mojca Miklavec wrote:
> On Thu, Nov 18, 2010 at 09:48, Hans Hagen wrote:
>> On 18-11-2010 12:00, Mojca Miklavec wrote:
>>>
>>> Dear Hans,
>>>
>>> The following example worked perfectly fine with the version of
>>> ConTeXt MKIV I was using one hour ago (no idea which version, but
>>> something less than two weeks old). It still works OK with MKII and it
>>> works much worse in the real document that I'm using.
>>>
>>> In my document both images are completely screwed up. Here it's only
>>> the second one and if I comment out the first one, the second figure
>>> comes out fine, so I'm a bit clueless about what magic is going on
>>> inbetween.
>>>
>>> Nothing in TikZ has changed (I'm still using the "frozen" version from
>>> November 2009 from minimals), so it must have something to do with
>>> ConTeXt MKIV. It just messes up with some boxes on the page in some
>>> unpredictable way.
>
> Hans,
>
> thanks a lot for the really nice simple example.
>
>> I have no clue ... maybe some magic tikz variable (or shared register) that
>> does not get reset?
>
> I have no clue either, but this has never been a problem before and it
> still works perfectly in both pdfTeX and XeTeX. So something really
> looks suspicious on the MKIV part.

After some tracing and hard thinking Taco and I found interesting spaces
showing up in the output that result from a kludge in tikz:

Normally one will use \ignorespaces to catch spurious spaces but tikz
invokes \nullfont assuming that its fontdimen 2 is zero. But, in context

You can put this in cont-new.mkiv as a temporary hack

\let\normalnullfont\nullfont

\def\nullfont
{\fontdimen1\normalnullfont\zeropoint
\fontdimen2\normalnullfont\zeropoint
\fontdimen3\normalnullfont\zeropoint
\fontdimen4\normalnullfont\zeropoint
\fontdimen5\normalnullfont\zeropoint
\fontdimen6\normalnullfont\zeropoint
\fontdimen7\normalnullfont\zeropoint
\normalnullfont}

-----------------------------------------------------------------