pic := textext(labeltext);
drawoptions();
% the pic is output later
Deleting the reset implied by the second drawoptions does honor the coloring:
drawoptions(withcolor blue);
pic := textext(labeltext);
I am inclined to conclude that the calling environment containing the drawoptions setting is not captured the moment the textext call is placed, but somewhat later. Because so it can be explained why the latter has the blue color but the former does not
(drawoptions has already been reset before it is taken into account).
The following code variation seems to corroborate this conclusion:
drawoptions(withcolor blue);
pic := textext(labeltext);
drawoptions(withcolor darkgreen);
If the conclusion is correct, I have a serious problem, because it then becomes impossible to predictably change the drawoptions used by textext. The result then might be dependent on timing conditions in the system. In my opinion, calling textext should
capture all relevant data at the precise moment of the call in metapost.
I might be wrong, of course, but otherwise I am in need of a repair.
Hans van der Meer