processing of setvariables/getvariables again
![](https://secure.gravatar.com/avatar/d0e94fb08d4620cfbd2f8f59a7868637.jpg?s=120&d=mm&r=g)
Hi all, excuse me for being so pig-headed, but I'm running into the same problem I had two weeks ago. Peter Rolf was incredibly helpful, but I couldnt get things working. It is more a problem of architecture and general choices, IMHO, than of actual code. I tried every single part of what I want to achieve, and it works. The difficulty lies in getting the variables to work... Basic problem: I want to refine my greek module. It provides a command \setupgreek[font=,scale=] which sets variables fonts and scale in the namespace Greek. The command is defined in the module, so in order to use it, the module has to be read. BUT: I want to use the result [i.e. \getvariable {Greek}{font} and \getvariable{Greek}{scale}] within the module itself. Is this possible? Details: I want to organize the fonts in a typescript to be more flexible. So the module first defines the setupcommand: \def\setupgreek{\setvariables[Greek]} then it calls the typescript \usetypescriptfile[type-tasgreek] where all the Greek fonts are defined in this form: \starttypescript [serif] [GreekGentium] [agr] \definefontsynonym [Greekgentium-Roman] [genagr-GentiumAlt] [encoding=agr] \definefontsynonym [Greekgentium-Italic][genagr-GentiumAItI] [encoding=agr] \stoptypescript \starttypescript [serif] [GreekGentium] [name] \usetypescript[serif][fallback] \definefontsynonym [Serif] [Greekgentium-Roman] \definefontsynonym [SerifItalic] [Greekgentium-Italic] \definefontsynonym [SerifBold] [Serif] \definefontsynonym [SerifBoldItalic] [Serif] \stoptypescript So the module calls the typescriptfile (or would it be more elegant to include these typescripts in the module itself?) I then have the definition for the command \localgreek which contains, among other things, a call of the Greek font. I had been planning to implement it in this form: \definetypeface [My\getvariable{Greek}{font}] [rm] [serif] [\getvariable{Greek}{font}] [default] [rscale = \getvariable{Greek} {font},encoding=agr] and then, in the setups for \localgreek, \switchtobodyfont[My\getvariable{Greek}{font}] And that's where I'm banging my head against the wall: the module would be used like this \usemodule[t-greek] \setupgreek[font=GreekGentium,scale=0.9] Which means: the entire module will be read BEFORE the \setupgreek command. But I would need the values of the setupgreek command WITHIN the module. Is that possible at all? Would I have to call a third file where the values are then processed? I tried to look into the source how \setup commands work, but I do get the impression that collecting the values and processing them is done in different files. Is this necessary? And how could I implement it in one module? Sorry if this sounds confusing, but I'm pretty confused, and hoping for enlightenment from the wizzards. All best Thomas
![](https://secure.gravatar.com/avatar/565476157eb3895a9c928ffce26d988d.jpg?s=120&d=mm&r=g)
Hi Thomas, It looks like you are looking for (inside the module): \def\initializegreek {\switchtobodyfont[My\getvariable{Greek}{font}]} \appendtoks \initialize \to \everystarttext There is no other way to get arguments to/from the module. For Hans: it would be really cool if there was a way to do something like this: \usemodule[greek][font=GreekGentium,scale=0.9] with (in this example) the \usemodule command defining the variables \moduleoptionfont \moduleoptionscale etc. Greetings, Taco Thomas A. Schmitz wrote:
Hi all,
excuse me for being so pig-headed, but I'm running into the same problem I had two weeks ago. Peter Rolf was incredibly helpful, but I couldnt get things working. It is more a problem of architecture and general choices, IMHO, than of actual code. I tried every single part of what I want to achieve, and it works. The difficulty lies in getting the variables to work...
Basic problem: I want to refine my greek module. It provides a command
\setupgreek[font=,scale=]
which sets variables fonts and scale in the namespace Greek. The command is defined in the module, so in order to use it, the module has to be read. BUT: I want to use the result [i.e. \getvariable {Greek}{font} and \getvariable{Greek}{scale}] within the module itself. Is this possible?
Details: I want to organize the fonts in a typescript to be more flexible. So the module first defines the setupcommand:
\def\setupgreek{\setvariables[Greek]}
then it calls the typescript
\usetypescriptfile[type-tasgreek]
where all the Greek fonts are defined in this form:
\starttypescript [serif] [GreekGentium] [agr] \definefontsynonym [Greekgentium-Roman] [genagr-GentiumAlt] [encoding=agr] \definefontsynonym [Greekgentium-Italic][genagr-GentiumAItI] [encoding=agr] \stoptypescript
\starttypescript [serif] [GreekGentium] [name] \usetypescript[serif][fallback] \definefontsynonym [Serif] [Greekgentium-Roman] \definefontsynonym [SerifItalic] [Greekgentium-Italic] \definefontsynonym [SerifBold] [Serif] \definefontsynonym [SerifBoldItalic] [Serif] \stoptypescript
So the module calls the typescriptfile (or would it be more elegant to include these typescripts in the module itself?)
I then have the definition for the command \localgreek which contains, among other things, a call of the Greek font. I had been planning to implement it in this form:
\definetypeface [My\getvariable{Greek}{font}] [rm] [serif] [\getvariable{Greek}{font}] [default] [rscale = \getvariable{Greek} {font},encoding=agr]
and then, in the setups for \localgreek,
\switchtobodyfont[My\getvariable{Greek}{font}]
And that's where I'm banging my head against the wall: the module would be used like this
\usemodule[t-greek] \setupgreek[font=GreekGentium,scale=0.9]
Which means: the entire module will be read BEFORE the \setupgreek command. But I would need the values of the setupgreek command WITHIN the module. Is that possible at all? Would I have to call a third file where the values are then processed? I tried to look into the source how \setup commands work, but I do get the impression that collecting the values and processing them is done in different files. Is this necessary? And how could I implement it in one module?
Sorry if this sounds confusing, but I'm pretty confused, and hoping for enlightenment from the wizzards.
All best
Thomas _______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
![](https://secure.gravatar.com/avatar/565476157eb3895a9c928ffce26d988d.jpg?s=120&d=mm&r=g)
Taco Hoekwater wrote:
Hi Thomas,
It looks like you are looking for (inside the module):
\def\initializegreek {\switchtobodyfont[My\getvariable{Greek}{font}]} \appendtoks \initialize \to \everystarttext
Sorry, of course this should read: \appendtoks \initializegreek \to \everystarttext Taco
![](https://secure.gravatar.com/avatar/d0e94fb08d4620cfbd2f8f59a7868637.jpg?s=120&d=mm&r=g)
Hi Taco, thanks for your reply!! I have to catch a train now, but I'll try your suggestion tonight when I'm back. And yes, having the module<something> variables would be great. What does \appendtoks do? Thanks, and all best Thomas On Oct 21, 2005, at 10:24 AM, Taco Hoekwater wrote:
Hi Thomas,
It looks like you are looking for (inside the module):
\def\initializegreek {\switchtobodyfont[My\getvariable{Greek}{font}]} \appendtoks \initialize \to \everystarttext
There is no other way to get arguments to/from the module. For Hans: it would be really cool if there was a way to do something like this:
\usemodule[greek][font=GreekGentium,scale=0.9]
with (in this example) the \usemodule command defining the variables
\moduleoptionfont \moduleoptionscale
etc.
Greetings, Taco
Thomas A. Schmitz wrote:
Hi all, excuse me for being so pig-headed, but I'm running into the same problem I had two weeks ago. Peter Rolf was incredibly helpful, but I couldnt get things working. It is more a problem of architecture and general choices, IMHO, than of actual code. I tried every single part of what I want to achieve, and it works. The difficulty lies in getting the variables to work... Basic problem: I want to refine my greek module. It provides a command \setupgreek[font=,scale=] which sets variables fonts and scale in the namespace Greek. The command is defined in the module, so in order to use it, the module has to be read. BUT: I want to use the result [i.e. \getvariable {Greek}{font} and \getvariable{Greek}{scale}] within the module itself. Is this possible? Details: I want to organize the fonts in a typescript to be more flexible. So the module first defines the setupcommand: \def\setupgreek{\setvariables[Greek]} then it calls the typescript \usetypescriptfile[type-tasgreek] where all the Greek fonts are defined in this form: \starttypescript [serif] [GreekGentium] [agr] \definefontsynonym [Greekgentium-Roman] [genagr-GentiumAlt] [encoding=agr] \definefontsynonym [Greekgentium-Italic][genagr-GentiumAItI] [encoding=agr] \stoptypescript \starttypescript [serif] [GreekGentium] [name] \usetypescript[serif][fallback] \definefontsynonym [Serif] [Greekgentium-Roman] \definefontsynonym [SerifItalic] [Greekgentium-Italic] \definefontsynonym [SerifBold] [Serif] \definefontsynonym [SerifBoldItalic] [Serif] \stoptypescript So the module calls the typescriptfile (or would it be more elegant to include these typescripts in the module itself?) I then have the definition for the command \localgreek which contains, among other things, a call of the Greek font. I had been planning to implement it in this form: \definetypeface [My\getvariable{Greek}{font}] [rm] [serif] [\getvariable{Greek}{font}] [default] [rscale = \getvariable {Greek} {font},encoding=agr] and then, in the setups for \localgreek, \switchtobodyfont[My\getvariable{Greek}{font}] And that's where I'm banging my head against the wall: the module would be used like this \usemodule[t-greek] \setupgreek[font=GreekGentium,scale=0.9] Which means: the entire module will be read BEFORE the \setupgreek command. But I would need the values of the setupgreek command WITHIN the module. Is that possible at all? Would I have to call a third file where the values are then processed? I tried to look into the source how \setup commands work, but I do get the impression that collecting the values and processing them is done in different files. Is this necessary? And how could I implement it in one module? Sorry if this sounds confusing, but I'm pretty confused, and hoping for enlightenment from the wizzards. All best Thomas _______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
_______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
![](https://secure.gravatar.com/avatar/565476157eb3895a9c928ffce26d988d.jpg?s=120&d=mm&r=g)
Thomas A. Schmitz wrote:
Hi Taco,
thanks for your reply!! I have to catch a train now, but I'll try your suggestion tonight when I'm back. And yes, having the module<something> variables would be great.
What does \appendtoks do?
It appends stuff to token registers (like \everystarttext) Taco
![](https://secure.gravatar.com/avatar/d0e94fb08d4620cfbd2f8f59a7868637.jpg?s=120&d=mm&r=g)
Taco, I tried your suggestion, but I'm not sure I'm doing it the right way. I took the definition of \initialize... like so: \def\initializegreekfont% {\getvariable{Greek}{font}} \appendtoks \initializegreekfont \to \everystarttext % I guess I will need a similar procedure for % initializegreekscale later I will need the variable twice: once for selecting the typescript and defining the bodyfont. So in the typescriptfile with the definitions for all the fonts, I have these lines: \starttypescript[Greek] \definetypeface [My\initializegreekfont] [rm] [serif] [\initializegreekfont] [default] [encoding=agr] \stoptypescript And once more for switching to this font: \startsetups[enablegreek] \catcode`~=\other \catcode`|=\other \catcode`'=\other \language[greek] \switchtobodyfont[My\initializegreekfont] \stopsetups %% suggested by Hans \def\localgreek{\rescanwithsetup{enablegreek}} I don't get any errors, but the font is not switched... Any obvious mistakes I'm making? Best Thomas On Oct 21, 2005, at 11:16 AM, Taco Hoekwater wrote:
Thomas A. Schmitz wrote:
Hi Taco, thanks for your reply!! I have to catch a train now, but I'll try your suggestion tonight when I'm back. And yes, having the module<something> variables would be great. What does \appendtoks do?
It appends stuff to token registers (like \everystarttext)
Taco _______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
![](https://secure.gravatar.com/avatar/565476157eb3895a9c928ffce26d988d.jpg?s=120&d=mm&r=g)
Thomas A. Schmitz wrote:
Taco,
I tried your suggestion, but I'm not sure I'm doing it the right way. I took the definition of \initialize... like so:
\def\initializegreekfont% {\getvariable{Greek}{font}} \appendtoks \initializegreekfont \to \everystarttext % I guess I will need a similar procedure for %
That is not what I meant. What (I think) you want is more like this: \def\initializegreekfont% {\starttypescript[Greek] \definetypeface [My\getvariable{Greek}{font}] [rm] [serif] [\getvariable{Greek}{font}] [default] [encoding=agr] \stoptypescript \startsetups[enablegreek] \catcode`~=\other \catcode`|=\other \catcode`'=\other \language[greek] \switchtobodyfont[My\getvariable{Greek}{font}] \stopsetups } \appendtoks \initializegreekfont \to \everystarttext In this way, you postpone all stuff that depends on the user-supplied variables until the occurance of \starttext. I hope you can understand me better now> Cheers, Taco
![](https://secure.gravatar.com/avatar/d0e94fb08d4620cfbd2f8f59a7868637.jpg?s=120&d=mm&r=g)
Taco, thanks so much! With a slight modification, your solution seems to work! I will have to test it a bit, but for the moment, it looks very good. Is the \appendtoks expensive in terms of TeX memory, cpu cycles, etc., or is it a good solution for the time being? All best, and many thanks Thomas On Oct 22, 2005, at 10:55 AM, Taco Hoekwater wrote:
That is not what I meant. What (I think) you want is more like this:
\def\initializegreekfont% {\starttypescript[Greek] \definetypeface [My\getvariable{Greek}{font}] [rm] [serif] [\getvariable{Greek}{font}] [default] [encoding=agr] \stoptypescript \startsetups[enablegreek] \catcode`~=\other \catcode`|=\other \catcode`'=\other \language[greek] \switchtobodyfont[My\getvariable{Greek}{font}] \stopsetups } \appendtoks \initializegreekfont \to \everystarttext
In this way, you postpone all stuff that depends on the user-supplied variables until the occurance of \starttext. I hope you can understand me better now>
Cheers, Taco _______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
![](https://secure.gravatar.com/avatar/565476157eb3895a9c928ffce26d988d.jpg?s=120&d=mm&r=g)
Thomas A. Schmitz wrote:
Is the \appendtoks expensive in terms of TeX memory, cpu cycles, etc., or is it a good solution for the time being?
This solution is perfectly OK. If there was a way to pass arguments through \usemodule, that would be nicer, but if that never happens, this will solution be fine. Taco
participants (2)
-
Taco Hoekwater
-
Thomas A. Schmitz