[NTG-context] metafun & \sometxt: should black be "black" or "textcolor"?

Hans Hagen pragma at wxs.nl
Mon Aug 7 00:02:15 CEST 2006

Taco Hoekwater wrote:
> Hi Mojca,
> Mojca Miklavec wrote:
>> But the other \sometxt was indeed red - withcolor seems to work, but
>> only conditionally. And I have some weird examples of two texts one
>> after another. In some cases (if something else is drawn inbetween and
>> a color changed twice), then the second text will be black. But it's
>> quite unpredictable (that one might even be bug in my code, so I don't
>> want to complain before I have an example).
> Ok, I looked into this again, and I was definately wrong.
> The actual problem appears to be that metapost does not write a
> color switch for 'black' when it appears at the start of a file,
> it simply assumes the start color is black. This could be
> considered a bug in MetaPost or a missing feature in ConTeXt
> (i have not decided yet :-)).
> Quick fix: You can start your MP code with an explicit color
> initialization.
>    \startMPcode
>       special "0 setgray";
>       ......
>    \stopMPcode
> A hack, I know. MetaPost should be able to distinguish between
>    draw p
> and
>    draw p withcolor (0,0,0)
> but currently it can't (because the structure is initialized
> as (0,0,0)). It is not quite a bug either, because there may
> well be MP code out there that depends on this.
> In fact, probably code by Knuth, Hobby, Jacko, and Hans ;-)
in meta-pdf.tex:


        {\PDFcode{q \MPxscale\space 0 0 \MPyscale\space \MPxoffset\space \MPyoffset\space cm}%
         \ifcase\blackoutMPgraphic\or\PDFcode{0 g 0 G}\fi
         \lower\MPyshift\box\scratchbox % unscaled shift


draw fullcircle scaled 5cm ;
draw btex test etex ;
\stopMPcode red}

draw fullcircle scaled 5cm ;
draw btex test etex ;

\color[red]{red \reuseMPgraphic{test} red}


                                          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 ntg-context mailing list