\usemodule[visual]
\usemodule[simulate]

\dontcomplain

\startenvironment columnsets-000

\useMPlibrary[dum]

\setupbodyfont
  [palatino]

\setuplayout
  [grid=yes]

\setuplayout
  [backspace=20mm,
   cutspace=15mm,
   width=middle,
   height=middle]

\setupsystem
  [random=1234]

\setuppagenumbering
  [alternative=doublesided,
   location=]

\setupheadertexts
  [pagenumber][right]
  [left][pagenumber]

\setupfootertexts
  [\inputfilename]

\setupfooter
  [style=\tttf]

\setupheader
  [style=\tttf]

\setuptolerance
  [verytolerant,stretch]

\definecolor[color-1][.5(red,green)]
\definecolor[color-2][.5(green,blue)]
\definecolor[color-3][.5(blue,red)]
\definecolor[color-4][.5(white,black)]
\definecolor[color-5][.5(white,color-4)]

\startuniqueMPgraphic{frame}
  fill OverlayBox withcolor \MPcolor{color-1} ;
\stopuniqueMPgraphic

\startuniqueMPgraphic{contrast}
  fill OverlayBox withcolor \MPcolor{color-3} ;
\stopuniqueMPgraphic

\defineoverlay[frame]   [\uniqueMPgraphic{frame}]
\defineoverlay[contrast][\uniqueMPgraphic{contrast}]

% TODO

\unprotect

\protected\def\NormalizeFontWidthSpread#1#2#3#4#5#6%
  {\global\setfalse\NFSpread
   \scratchdimen#3%
   \scratchdimen-.5\scratchdimen
   \advance\scratchdimen#2\relax
   \NormalizeFontWidth
     #1%
     {\enforced\def\+{\global\settrue\NFSpread\gobbleuntil\relax}%
      \enforced\def\\{\gobbleuntil\relax}% newline
      \setupspacing
      #6\relax}%
     {\scratchdimen}%
     {#4}%
   \ifconditional\NFSpread
     % de gap valt in de binding
   \else
     \definefont[\strippedcsname#1][#4 #5]%
   \fi}

\protected\def\SpreadGapText#1#2%
  {{\def\+{\kern#1}#2}}

\protected\def\GapText#1#2#3#4#5% width distance font spec title
  {\bgroup
   \NormalizeFontWidthSpread\DummyFont{#1}{#2}{#3}{#4}{#5}%
   \DummyFont\setupspacing\SpreadGapText{#2}{#5}\endgraf
   \egroup}

\protect

\stopenvironment
