I am using textext to draw text from inside a metapost program. The drawoptions macro is used by metapost to set drawing options such as color. As I understand, the textext call is handled by the tex-side of the metapost-context system, initiated of course from the metapost side. My impression is that this occurs asynchronously, judging by the problem I encountered. On the metapost side I have: drawoptions(withcolor blue); pic := textext(labeltext); drawoptions(); % the pic is output later [cid:3EBB8ADD-F7B8-4DE1-8990-9EB0E0F45EF6@fritz.box] Deleting the reset implied by the second drawoptions does honor the coloring: drawoptions(withcolor blue); pic := textext(labeltext); [cid:8813D244-4326-4F4A-8520-3C704619954C@fritz.box] 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); [cid:415E4344-B8AA-492B-B320-D57D405462EB@fritz.box] 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
On 2013-08-28, at 1:40 PM, "Meer, H. van der"
I am using textext to draw text from inside a metapost program. The drawoptions macro is used by metapost to set drawing options such as color. As I understand, the textext call is handled by the tex-side of the metapost-context system, initiated of course from the metapost side. My impression is that this occurs asynchronously, judging by the problem I encountered.
On the metapost side I have:
drawoptions(withcolor blue); pic := textext(labeltext); drawoptions(); % the pic is output later
Can you posts complete minimal example? Drawoptions are only taken into consideration when the picture is drawn, and textext does not draw the picture. So, it is not surprising that when you actually draw the picture, the current draw options are used. Aditya
Do I understand ypu correctly then that:
(1) textext delivers a picture containing what it did typeset, regardless of the setting of drawop
(2) drawoptions (withcolor red) then applies the color to that picture?
But then there is a complication.
On input textext("\tfb text") the above seems to apply, but submitting textext("\orange\tfb text") makes the text orange coloured in spit of the drawoptions setting. Thus textext seems to behave differently for getting an explicit color for its content or not.
Before ripping the program for a minimal example I would like to first have a clear understanding of the functioning of textext in relation to metapost. It seems that as yet I do not have a clear enough picture of that process.
Hans van der Meer
On 28 aug. 2013, at 21:20, Aditya Mahajan
On 2013-08-28, at 1:40 PM, "Meer, H. van der"
wrote: I am using textext to draw text from inside a metapost program. The drawoptions macro is used by metapost to set drawing options such as color. As I understand, the textext call is handled by the tex-side of the metapost-context system, initiated of course from the metapost side. My impression is that this occurs asynchronously, judging by the problem I encountered.
On the metapost side I have:
drawoptions(withcolor blue); pic := textext(labeltext); drawoptions(); % the pic is output later
Can you posts complete minimal example? Drawoptions are only taken into consideration when the picture is drawn, and textext does not draw the picture. So, it is not surprising that when you actually draw the picture, the current draw options are used.
Aditya ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
On Wed, 28 Aug 2013, Meer, H. van der wrote:
Do I understand ypu correctly then that:
(1) textext delivers a picture containing what it did typeset, regardless of the setting of drawop (2) drawoptions (withcolor red) then applies the color to that picture?
But then there is a complication. On input textext("\tfb text") the above seems to apply, but submitting textext("\orange\tfb text") makes the text orange coloured in spit of the drawoptions setting. Thus textext seems to behave differently for getting an explicit color for its content or not.
Before ripping the program for a minimal example I would like to first have a clear understanding of the functioning of textext in relation to metapost. It seems that as yet I do not have a clear enough picture of that process.
The example below illustrates what is happening: \starttext \startMPcode newpicture p; drawoptions (withcolor red); p := image (addto currentpicture doublepath unitsquare scaled 1cm ); drawoptions (); draw p; \stopMPcode \stoptext drawoptions() are used only when you use draw or fill (look up their definition in mp-base.mpiv). textext does not use draw or fill. If you want drawoptions to be honored, you can do something as follows: \starttext \startMPcode newpicture p; drawoptions (withcolor red); p := image (draw textext("\tfd text")); drawoptions (); draw p; \stopMPcode \stoptext Aditya
On 8/28/2013 10:12 PM, Meer, H. van der wrote:
Do I understand ypu correctly then that:
(1) textext delivers a picture containing what it did typeset, regardless of the setting of drawop (2) drawoptions (withcolor red) then applies the color to that picture?
But then there is a complication. On input textext("\tfb text") the above seems to apply, but submitting textext("\orange\tfb text") makes the text orange coloured in spit of the drawoptions setting. Thus textext seems to behave differently for getting an explicit color for its content or not.
Before ripping the program for a minimal example I would like to first have a clear understanding of the functioning of textext in relation to metapost. It seems that as yet I do not have a clear enough picture of that process.
even then, as aditya mentioned, a minimal example is needed as now i had to made one myself anyhow, textext is not a real picture in the sense that it only carries around dimensions and the text string dealing with color is already somewhat complex and the 'current' color of the picture is taken into account, so with "draw somepic withcolor red" the color gets applied to all picture components and drawoptions are also applied (part of the draw definition) i made a patch that also carries some extra color info but i'm not sure how robust it is (i also did some further optimization) btw, we do have a 'named properties' feature in metafun: \startMPpage property p[] ; p1 = properties(withcolor blue) ; p2 = properties(withcolor red) ; % fill fullcircle scaled 2cm withproperties p1 ; picture pic ; pic := textext("one") ; draw pic withproperties p1 ; draw pic shifted (1cm,0) withproperties p2 ; drawoptions(withcolor red); pic := textext("one") shifted (1cm,0) ; drawoptions(); draw pic ; drawoptions(withcolor green); draw textext("one") shifted (2cm,0) ; drawoptions(); \stopMPpage Hans (in flu-mode so more bugs than usual) ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (3)
-
Aditya Mahajan
-
Hans Hagen
-
Meer, H. van der