new MyWay about \sometxt
Hello, instead of checking the problems with MyWay about database module, I created another unfinished piece about \sometxt (as promised already long ago): http://dl.contextgarden.net/myway/sometxt.pdf \sometxt{...} should be used instead of textext("...") in metafun graphics whenever possible, since it's much more efficient. An average user shouldn't care about much more than that. The MyWay is devoted to the curious ones. I hope that I included all the major ideas which Hans implemented in Summer/Autumn 2006 on my request. Although not all of them are documented well enough, I tried to mention them at least. The document is full of mistakes and badly formulated sentences (I should start reading more English literature instead of mailing lists and articles ;). I wellcome any suggestions for improving it. Thanks to Hans van der Meer who provided me the first feedback ;) Just two questions left for Hans H. (Hans v. d. M. has brought up exactly the same questions as I had a while ago): 1.) wouldn't it make sense to use \chardef\TeXtextcolormode\zerocount as the default value? I don't see any advantages of setting it to "one" (but I might have overseen something). Can you please take a look at page 4 of the above listed MyWay and tell me if I forgot something? 2.) Why does \textext still rely on its older brother textext(...), when it could be a synonym for \sometxt{...} instead? I really don't see any advantage of \textext{...} over \sometxt{...}. \textext{...} canonot be used for concatenating strings or creating dynamic labels either. It's just a picture, just as \sometxt ... And it would probably also be more straightforward to explain to metafun users that textext("...") should now be \textext{...} instead of trying to explain them that it's best to use some completely new command. Thanks a lot, Mojca
On Tue, 30 Jan 2007, Mojca Miklavec wrote:
Hello,
instead of checking the problems with MyWay about database module, I created another unfinished piece about \sometxt (as promised already long ago):
http://dl.contextgarden.net/myway/sometxt.pdf
\sometxt{...} should be used instead of textext("...") in metafun graphics whenever possible, since it's much more efficient. An average user shouldn't care about much more than that. The MyWay is devoted to the curious ones. I hope that I included all the major ideas which Hans implemented in Summer/Autumn 2006 on my request. Although not all of them are documented well enough, I tried to mention them at least.
Very nice. Now, I do not need to look up old mails to figure out how to manipulate sometxt. I have one example where \sometxt[...]{...} is useful. If you are interested, I can send it to you. I thought a bit about your feature request, and it is not too difficult to implement it. Here is a patch that allows you to use \sometext[font][iwona,20pt]{...}. Careful of spurious linebreaks. %======================================================= \long\def\redofiltersometxt[#1]% {\doifnextcharelse[{\reredofiltersometxt[#1]}{\redodofiltersometxt[#1]}} \long\def\redodofiltersometxt[#1]#2% {\increment\txtcounter \TeXtext[#1]\txtcounter{#2}% \filtersometxt} \long\def\reredofiltersometxt[#1][#2]#3% {\increment\txtcounter \TeXtext[#1]\txtcounter{\switchtobodyfont[#2]\strut#3}% \filtersometxt} \definetextext[font]{\donothing} \usetypescript[iwona][texnansi] \starttext \startMPcode draw fullcircle xyscaled (3cm,2cm); label(\sometxt{Hello world!}, origin); \stopMPcode % Does not cause any harm. \startMPcode draw fullcircle xyscaled (3cm,2cm); label(\sometxt[font]{Hello world!}, origin); \stopMPcode \startMPcode draw fullcircle xyscaled (3cm,2cm); label(\sometxt[font][iwona,20pt]{Hello world!}, origin); \stopMPcode \stoptext %=============================================================== I haven't tested it, but I do not think that this should cause any problems with existing code. \definetextext[font] is just a dummy. It should work with other things also. You can get rid of the dummy by checking in redodofiltersometxt if #1 is has a comma or not. Would that extra overhead be useful of gnuplot? Hans, is there a reason for not defining dodofiltersometxt as \long\def\dodofiltersometxt#1#2% #3 {\ifx#2\empty \else \increment\txtcounter \TeXtext\txtcounter{#1}% \expandafter\filtersometxt \fi#2}% #3 whih will be a bit faster. Aditya
On 1/30/07, Aditya Mahajan wrote:
On Tue, 30 Jan 2007, Mojca Miklavec wrote:
Hello,
instead of checking the problems with MyWay about database module, I created another unfinished piece about \sometxt (as promised already long ago):
http://dl.contextgarden.net/myway/sometxt.pdf
\sometxt{...} should be used instead of textext("...") in metafun graphics whenever possible, since it's much more efficient. An average user shouldn't care about much more than that. The MyWay is devoted to the curious ones. I hope that I included all the major ideas which Hans implemented in Summer/Autumn 2006 on my request. Although not all of them are documented well enough, I tried to mention them at least.
Very nice. Now, I do not need to look up old mails to figure out how to manipulate sometxt.
I've put there everything that came to my mind, but 99% of the usage is still only \sometxt{...}. The rest is trickery.
I have one example where \sometxt[...]{...} is useful. If you are interested, I can send it to you.
I can include it in the manual if you want. I used \sometxt[] for gnuplot because it looks more elegant and more backward compatible that adding a bunch of additonal macros in front of it. The example in MyWay is "artificial".
I thought a bit about your feature request, and it is not too difficult to implement it. Here is a patch that allows you to use \sometext[font][iwona,20pt]{...}. Careful of spurious linebreaks.
Great!!! Having a hardcoded \sometxt[font] doesn't help me much, but I'll copy the code literally to the module and replace [font] by [gp].
%=======================================================
\long\def\redofiltersometxt[#1]% {\doifnextcharelse[{\reredofiltersometxt[#1]}{\redodofiltersometxt[#1]}}
\long\def\redodofiltersometxt[#1]#2% {\increment\txtcounter \TeXtext[#1]\txtcounter{#2}% \filtersometxt}
\long\def\reredofiltersometxt[#1][#2]#3% {\increment\txtcounter \TeXtext[#1]\txtcounter{\switchtobodyfont[#2]\strut#3}% \filtersometxt}
\definetextext[font]{\donothing}
\usetypescript[iwona][texnansi]
\starttext \startMPcode draw fullcircle xyscaled (3cm,2cm); label(\sometxt{Hello world!}, origin); \stopMPcode
% Does not cause any harm. \startMPcode draw fullcircle xyscaled (3cm,2cm); label(\sometxt[font]{Hello world!}, origin); \stopMPcode
\startMPcode draw fullcircle xyscaled (3cm,2cm); label(\sometxt[font][iwona,20pt]{Hello world!}, origin); \stopMPcode
\stoptext
%===============================================================
I haven't tested it, but I do not think that this should cause any problems with existing code. \definetextext[font] is just a dummy. It should work with other things also. You can get rid of the dummy by checking in redodofiltersometxt if #1 is has a comma or not. Would that extra overhead be useful of gnuplot?
Yes. But copying the code literally doesn't make as much sense since other users might have different needs than "second optional parameter should switch the font". I'll add that to the gnuplot module directly. The only thing that could help would be a high-level user interface to define such commands, such as is \definetextext[name]{\command} So that one could then define % I'm not sure what should come inbetween \definetextext[myboldfont]???{\myboldfont} % #1 might be empty \def\myboldfont[#1]#2{\framed{ \doifnot{#1}{}{\switchtobodyfont[#1]} \strut\bf #2}} for example and use it as \sometxt[myboldfont][iwona]{this will be bold and framed iwona} But your current code is more than enough for me (apart from the fact that it's not really nice to redefine low-level macros, but I'll try to keep up with low-level changes, should any accur) ;) Thanks again, Mojca (Before you asked for the feature of having optional parameters, I redefined the low-level interface to accept \gptext{...} and \gptext[fontname]{...} ;)
Hans, is there a reason for not defining dodofiltersometxt as
\long\def\dodofiltersometxt#1#2% #3 {\ifx#2\empty \else \increment\txtcounter \TeXtext\txtcounter{#1}% \expandafter\filtersometxt \fi#2}% #3
whih will be a bit faster.
On Tue, 30 Jan 2007, Mojca Miklavec wrote:
On 1/30/07, Aditya Mahajan wrote:
On Tue, 30 Jan 2007, Mojca Miklavec wrote:
Hello,
instead of checking the problems with MyWay about database module, I created another unfinished piece about \sometxt (as promised already long ago):
http://dl.contextgarden.net/myway/sometxt.pdf
\sometxt{...} should be used instead of textext("...") in metafun graphics whenever possible, since it's much more efficient. An average user shouldn't care about much more than that. The MyWay is devoted to the curious ones. I hope that I included all the major ideas which Hans implemented in Summer/Autumn 2006 on my request. Although not all of them are documented well enough, I tried to mention them at least.
Very nice. Now, I do not need to look up old mails to figure out how to manipulate sometxt.
I've put there everything that came to my mind, but 99% of the usage is still only \sometxt{...}. The rest is trickery.
I have one example where \sometxt[...]{...} is useful. If you are interested, I can send it to you.
I can include it in the manual if you want. I used \sometxt[] for gnuplot because it looks more elegant and more backward compatible that adding a bunch of additonal macros in front of it.
I mainly use the \sometxt[..]{..} feature to create labels in my metapost figures. The normal setup is \definetextext[parbox]{\framed[frame=off, width=2cm, autowidth=force, align=middle, background=color, backgroundcolor=white]} Which insures that I do not have to worry about line breaking of long labels, and the unfill trick to get white backgrounds in labels. The down-side is that the background is white instead of being transparent. So, if you have a colored page background, the figure looks odd. I have attached a complete example.
I thought a bit about your feature request, and it is not too difficult to implement it. Here is a patch that allows you to use \sometext[font][iwona,20pt]{...}. Careful of spurious linebreaks.
Great!!!
Having a hardcoded \sometxt[font] doesn't help me much, but I'll copy the code literally to the module and replace [font] by [gp].
The font is not hardcoded. But you need to have something there. Otherwise you need a mechanism to distinguish between \sometxt[whatever] and \sometxt[iwona]
%======================================================= [snip[ %===============================================================
I haven't tested it, but I do not think that this should cause any problems with existing code. \definetextext[font] is just a dummy. It should work with other things also. You can get rid of the dummy by checking in redodofiltersometxt if #1 is has a comma or not. Would that extra overhead be useful of gnuplot?
Yes. But copying the code literally doesn't make as much sense since other users might have different needs than "second optional parameter should switch the font". I'll add that to the gnuplot module directly.
It can be configurable. Maybe something like \defineopttextext[whatever]{\command} so that with \sometxt[whatever][2nd arg]{stuff} translates to \command[2nd ard]{stuff} and \sometxt[whatever]{stuff} translates to \command{stuff}. That would involve more work to write the macro \command, but will provide more flexibility.
The only thing that could help would be a high-level user interface to define such commands, such as is \definetextext[name]{\command}
So that one could then define % I'm not sure what should come inbetween \definetextext[myboldfont]???{\myboldfont} % #1 might be empty \def\myboldfont[#1]#2{\framed{ \doifnot{#1}{}{\switchtobodyfont[#1]} ^^^^^^^^^^^^^^^^ \doifnothing or \doifsomething is easier to read \strut\bf #2}} for example and use it as \sometxt[myboldfont][iwona]{this will be bold and framed iwona}
It may be possible to extend definetextext to do this rather than \defineopttextext. In any case, it is upto the macro \command to ensure that it can handly the optinal argument. I will see if I can cook up something working.
But your current code is more than enough for me (apart from the fact that it's not really nice to redefine low-level macros, but I'll try to keep up with low-level changes, should any accur) ;)
Or persuade Hans to have a proper version in the core :) Aditya
Aditya Mahajan wrote:
It can be configurable. Maybe something like
\defineopttextext[whatever]{\command}
so that with \sometxt[whatever][2nd arg]{stuff} translates to \command[2nd ard]{stuff} and \sometxt[whatever]{stuff} translates to \command{stuff}.
That would involve more work to write the macro \command, but will provide more flexibility.
optional stuff is tricky in macros that (in the mp graphic expansion) need to be fully expandable ... in mkiv i will write another preprocessor and then such things may be feasible
But your current code is more than enough for me (apart from the fact that it's not really nice to redefine low-level macros, but I'll try to keep up with low-level changes, should any accur) ;)
Or persuade Hans to have a proper version in the core :)
remind me to look at it -) Hans ----------------------------------------------------------------- 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 -----------------------------------------------------------------
On 1/30/07, Aditya Mahajan wrote:
I thought a bit about your feature request, and it is not too difficult to implement it. Here is a patch that allows you to use \sometext[font][iwona,20pt]{...}. Careful of spurious linebreaks.
%=======================================================
\long\def\redofiltersometxt[#1]% {\doifnextcharelse[{\reredofiltersometxt[#1]}{\redodofiltersometxt[#1]}}
\long\def\redodofiltersometxt[#1]#2% {\increment\txtcounter \TeXtext[#1]\txtcounter{#2}% \filtersometxt}
\long\def\reredofiltersometxt[#1][#2]#3% {\increment\txtcounter \TeXtext[#1]\txtcounter{\switchtobodyfont[#2]\strut#3}% \filtersometxt}
\definetextext[font]{\donothing}
\usetypescript[iwona][texnansi]
\starttext \startMPcode draw fullcircle xyscaled (3cm,2cm); label(\sometxt{Hello world!}, origin); \stopMPcode
% Does not cause any harm. \startMPcode draw fullcircle xyscaled (3cm,2cm); label(\sometxt[font]{Hello world!}, origin); \stopMPcode
\startMPcode draw fullcircle xyscaled (3cm,2cm); label(\sometxt[font][iwona,20pt]{Hello world!}, origin); \stopMPcode
\stoptext
%===============================================================
I haven't tested it, but I do not think that this should cause any problems with existing code.
If gnuplot doesn't fail with it, it probably means that it works OK ;) "Helvetica" seems to work OK here: http://dl.contextgarden.net/misc/gnuplot-context.zip (Usually I get dozens of error messages when applying something new, at least "memory limit exceeded" if everything else happens to work by accident ;) The most funny part was when practiacally all the labels were missing on one plot before I figured out that \setupbodyfont[somefont,14pt] \switchtobodyfont[some other font] doesn't work at all without defining bodyfontenvironment. Thank you very much again! The .tex file is still in its "pre-alpha" state, but at least I was able to "finalize" the terminal with a clean syntax ;)
Would that extra overhead be useful of gnuplot?
yes ... once I manage to convince the developers that the difference between these two plots might be relevant enough to justify an additional driver: http://gnuplot.sourceforge.net/demo_4.1/enhancedtext.html http://dl.contextgarden.net/misc/enhancedtext.pdf (I hope that Patrick will not be reading this before I manage to remove the files again ;) Mojca
Mojca Miklavec wrote:
Hello,
instead of checking the problems with MyWay about database module, I created another unfinished piece about \sometxt (as promised already long ago):
http://dl.contextgarden.net/myway/sometxt.pdf
\sometxt{...} should be used instead of textext("...") in metafun graphics whenever possible, since it's much more efficient. An average user shouldn't care about much more than that. The MyWay is devoted to the curious ones. I hope that I included all the major ideas which Hans implemented in Summer/Autumn 2006 on my request. Although not all of them are documented well enough, I tried to mention them at least.
the textext stuff is from far before 2006 -) you say that's been buggy but that not really the case ... the problem is that we are dealing with a quite complex situation which has to be dealt with outside tex - we need to recognize textext in order to force a tex run inside mp (inbetween mp in texexec) - we need to make sure that env's get passed - we need to make sure that no extra runs take place when nothing has changed etc. Combine this with users either or not having write 18 enabled and one gets a mess. The basic principles are rather simple. The 'prefered-by-you' method is fast because mp never sees the text. The text is typeste in the current run and saved in a box. Mp only gets the dimensions and typets a reference in a monospace font (which then ends up in a string) the mp to pdf converter can recognize this label (text), and recalculate from that (+ the box dimensions) how things should be scaled. This mechanism is a spin of from experiments with piping data into mp (luatex exp long ago). So, the other mechanism is rather robust because mp never sees any real complex text. This is also why things like color, graphics etc work well.
1.) wouldn't it make sense to use \chardef\TeXtextcolormode\zerocount as the default value? I don't see any advantages of setting it to "one" (but I might have overseen something). Can you please take a
you oversee my local truckload of files that assume that behaviour and compatibility is what i want
look at page 4 of the above listed MyWay and tell me if I forgot something?
2.) Why does \textext still rely on its older brother textext(...), when it could be a synonym for \sometxt{...} instead? I really don't see any advantage of \textext{...} over \sometxt{...}. \textext{...} canonot be used for concatenating strings or creating dynamic labels either. It's just a picture, just as \sometxt ... And it would probably also be more straightforward to explain to metafun users that textext("...") should now be \textext{...} instead of trying to explain them that it's best to use some completely new command.
dunno ... history ... don't change if you don't have too ... one never knows what surprised lurk .. users do tricky things so things may break ...
Hans -- ----------------------------------------------------------------- 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 -----------------------------------------------------------------
participants (3)
-
Aditya Mahajan
-
Hans Hagen
-
Mojca Miklavec