* textext sync problem?
@ 2013-08-28 17:40 Meer, H. van der
2013-08-28 19:20 ` Aditya Mahajan
0 siblings, 1 reply; 5+ messages in thread
From: Meer, H. van der @ 2013-08-28 17:40 UTC (permalink / raw)
To: NTG ConTeXt
[-- Attachment #1.1.1: Type: text/plain, Size: 1732 bytes --]
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
[-- Attachment #1.1.2: Type: text/html, Size: 2648 bytes --]
[-- Attachment #1.2: blue.jpg --]
[-- Type: image/jpg, Size: 2847 bytes --]
[-- Attachment #1.3: green.jpg --]
[-- Type: image/jpg, Size: 2470 bytes --]
[-- Attachment #2: notblue.tiff --]
[-- Type: image/tiff, Size: 2340 bytes --]
[-- Attachment #3: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: textext sync problem?
2013-08-28 17:40 textext sync problem? Meer, H. van der
@ 2013-08-28 19:20 ` Aditya Mahajan
2013-08-28 20:12 ` Meer, H. van der
0 siblings, 1 reply; 5+ messages in thread
From: Aditya Mahajan @ 2013-08-28 19:20 UTC (permalink / raw)
To: mailing list for ConTeXt users
On 2013-08-28, at 1:40 PM, "Meer, H. van der" <H.vanderMeer@uva.nl> 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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: textext sync problem?
2013-08-28 19:20 ` Aditya Mahajan
@ 2013-08-28 20:12 ` Meer, H. van der
2013-08-28 21:08 ` Aditya Mahajan
2013-08-28 21:11 ` Hans Hagen
0 siblings, 2 replies; 5+ messages in thread
From: Meer, H. van der @ 2013-08-28 20:12 UTC (permalink / raw)
To: mailing list for ConTeXt users
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 <adityam@umich.edu>
wrote:
>
>
> On 2013-08-28, at 1:40 PM, "Meer, H. van der" <H.vanderMeer@uva.nl> 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
> ___________________________________________________________________________________
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: textext sync problem?
2013-08-28 20:12 ` Meer, H. van der
@ 2013-08-28 21:08 ` Aditya Mahajan
2013-08-28 21:11 ` Hans Hagen
1 sibling, 0 replies; 5+ messages in thread
From: Aditya Mahajan @ 2013-08-28 21:08 UTC (permalink / raw)
To: mailing list for ConTeXt users
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
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: textext sync problem?
2013-08-28 20:12 ` Meer, H. van der
2013-08-28 21:08 ` Aditya Mahajan
@ 2013-08-28 21:11 ` Hans Hagen
1 sibling, 0 replies; 5+ messages in thread
From: Hans Hagen @ 2013-08-28 21:11 UTC (permalink / raw)
To: ntg-context
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
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-08-28 21:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-28 17:40 textext sync problem? Meer, H. van der
2013-08-28 19:20 ` Aditya Mahajan
2013-08-28 20:12 ` Meer, H. van der
2013-08-28 21:08 ` Aditya Mahajan
2013-08-28 21:11 ` Hans Hagen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).