[NTG-context] \=i

Hans Hagen ntg-context@ntg.nl
Thu, 03 Jun 2004 13:31:49 +0200


At 21:45 02/06/2004, you wrote:

>I'd prefer (at least a variant) that does it based on fontstyle as well:
>
>\unprotect
>
>\definesystemvariable{sx}
>
>\def\definestylecollection
>    {\dotripleargument\dodefinestylecollection}
>
>\def\dodefinestylecollection[#1][#2][#3][#4]%
>    {\unexpanded\setvalue{#1}{\styleinstance[#1]}%
>     \setvalue{\??sx#1:#2:#3}{#4}}
>
>\unexpanded\def\styleinstance[#1]%
>    {\executeifdefined{\??sx#1:\fontstyle:\fontalternative}{\getvalue{\?
>?sx#1:\fontstyle:\s!default}}}
>
>\protect
>\definestylecollection[caps][ss][default][\sc]
>\definestylecollection[caps][ss][bf][\bc]
>\definestylecollection[caps][ss][bi][\bc]
>\definestylecollection[caps][ss][bs][\bc]

% \definestylecollection[mine]

% \definestyleinstance[mine][default][sorry]
% \definestyleinstance[mine][tt][bs][ttbs:\rm\sl]
% \definestyleinstance[mine][tt][bf][ttbf:\rm\sl]
% \definestyleinstance[mine][bf][\sl]
% \definestyleinstance[mine][sl][\tt]

% {\bf test \mine test \sl test \mine test \bs oeps \mine oeps {\tt test 
\mine \bf test}}

\definesystemvariable{sx}

\def\definestylecollection
   {\dosingleargument\dodefinestylecollection}

\def\dodefinestylecollection[#1]%
   {\iffirstargument
      \unexpanded\setvalue{#1}{\styleinstance[#1]}%
      \def\docommand##1%
        {\def\dodocommand####1{\letbeundefined{\??sx##1:####1:\commalistelement}}%
         \processcommacommand[\alternativelist,\s!default]\dodocommand}%
      \processcommacommand[\stylelist,\s!default]\docommand
    \fi}

\def\definestyleinstance
   {\doquadrupleargument\dodefinestyleinstance}

\def\dodefinestyleinstance[#1][#2][#3][#4]% [name] [rm|ss|tt|..] 
[sl|bf|...] [whatever]
   {\iffirstargument
      \doifundefined{#1}{\definestylecollection[#1]}%
    \fi
    \iffourthargument
      \setvalue{\??sx#1:#2:#3}{#4}%
    \else\ifthirdargument
      \setvalue{\??sx#1::#2}{#3}%
    \else\ifsecondargument
      \letvalue{\??sx#1::#2}\empty
    \fi\fi\fi}

\unexpanded\def\styleinstance[#1]% will be faster
   {%\begingroup\expanded{\infofont[#1:\fontstyle:\fontalternative]}\endgroup
    \executeifdefined{\??sx#1:\fontstyle:\fontalternative}%
   {\executeifdefined{\??sx#1:\fontstyle:\s!default}%
   {\executeifdefined{\??sx#1::\fontalternative}
   {\getvalue        {\??sx#1::\s!default}}}}}