[NTG-context] metafun & \sometxt: should black be "black" or "textcolor"?
taco at elvenkind.com
Sun Aug 6 16:37:47 CEST 2006
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
special "0 setgray";
A hack, I know. MetaPost should be able to distinguish between
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 ;-)
> A question for you or Hans: can please someone explain me in a few
> words what's the main strategy/philosophy behind \sometxt. I don't
> understand exactly how TeX processes it (and metapost
> shrinks/expands/shifts/colors) it inline.
TeX typesets the argument of the \sometxt macro in a hbox and
writes its box dimensions to <jobname-mpgraph.mpb>.
To the metapost file, a zero-padded serial number is written
instead, and MP uses the dimensions it finds in <jobname-mpgraph.mpb>
for the positioning of that label.
ConTeXt then replaces the metapost label number with the TeX material
while interpreting the Metapost result.
This is the short version, the actual situation is a little bit more
complex (not a whole lot though). The actual code is in meta-tex.tex
More information about the ntg-context