% Typescript test file
\setuplayout[margin=0pt, height=fit, width=fit, backspace=0cm, header=0cm, footer=\headerheight]
%\showframe
%\showboxes


\setuphead[section][color={red}]% this color key influences my macro why?
\setuphead[subsection][color=black]

\setupbodyfontenvironment[14pt][script=10pt,
								scriptscript=8pt, 
								x=10pt, 
								xx=7pt, 
								big=18pt,
								small=10pt]

\unprotect

\define\Kern{\hskip2pt}

\define\MyTestText{€\Kern \$\Kern \%\Kern \&\Kern ?\Kern @\Kern µ\Kern ∆\Kern ∂\Kern π\Kern ∞\Kern 1\Kern 2\Kern 3\Kern 4\Kern 5\Kern 6\Kern 7\Kern 8\Kern 9\Kern 0\Kern ff\Kern ft\Kern fft}

\def\OpticalsTest{\dosingleempty\doOpticalsTest}


\def\doOpticalsTest[#1]#2{%
	\getparameters[OO][Limitone={.37\textwidth},%text limit for font name (e.g. SerifDisplay-Regular)
					   Limittwo={3cm},%limit for "Example Text" - not that usefull
					   Limittext={.57\textwidth},%limit for text in Textkey
					   Size=\bodyfontsize,%textsize
					   Feature=default,%desired Open Type Font feature
					   Color=black,%text color
					   Text=,#1]%what text should be displayed
	\bgroup
		\def\Mycolor{\color[\OOColor]}
		\def\processitem##1{\OpticalTest[#1]{##1}}%
		\processcommalist[#2]\processitem
	\egroup
}

\def\OpticalTest[#1]#2{%
	\addff{\OOFeature}\definedfont[#2 at \OOSize]\setupinterlinespace%
	\hbox to \textwidth{\clip[width=.39\textwidth, bottomoffset=\strutdepth]{%
		\hbox to .39\textwidth{%
			\hfill\limitatetext{#2}{\OOLimitone}{\textellipsis}%
							  }}%
		\hbox to .61\textwidth{:\hskip.2cm%
			\doifelse{\OOText}{}%
			{{\ruledhbox to 3.6cm{\quotation{\limitatetext{Example\Kern Text}{\OOLimittwo}{\textellipsis}}\hfill}%
			\limitatetext{\MyTestText}{\OOLimittext}{\textellipsis}}}%
			{\limitatetext{\OOText}{\OOLimittext}{\textellipsis}}\hfilll
							  }%
					    }\vskip3pt
}%

\protect

\setupbodyfont[14pt]

\starttext

\section{Section in red}

\OpticalsTest[Text={Test text, Test text, Test text, Test text, Test text, Test text, Test text, Test text, Test text, Test text, Test text, Test text},Size=40pt]
{SerifCaption-Regular,SerifSmalltext-Regular,SerifRegular-Regular,SerifSubhead-Regular,SerifDisplay-Regular}
\blank
\OpticalsTest{SerifCaption-Bold,SerifSmalltext-Bold,SerifRegular-Bold,SerifSubhead-Bold,SerifDisplay-Bold}
\blank
\OpticalsTest{SerifCaption-Italic,SerifSmalltext-Italic,SerifRegular-Italic,SerifSubhead-Italic,SerifDisplay-Italic}

\subsection{Subsection in black}

\OpticalsTest[Text={Test text, Test text, Test text, Test text, Test text, Test text, Test text, Test text, Test text, Test text, Test text, Test text},Size=40pt, Feature=stretched]
{SerifCaption-Regular,SerifSmalltext-Regular,SerifRegular-Regular,SerifSubhead-Regular,SerifDisplay-Regular}
\blank
\OpticalsTest{SerifCaption-Bold,SerifSmalltext-Bold,SerifRegular-Bold,SerifSubhead-Bold,SerifDisplay-Bold}
\blank
\OpticalsTest{SerifCaption-Italic,SerifSmalltext-Italic,SerifRegular-Italic,SerifSubhead-Italic,SerifDisplay-Italic}



\stoptext