%D \module
%D   [       file=wolf-jap,
%D        version=20xx.xx.xx,
%D          title=\CONTEXT\ User Module,
%D       subtitle=Japanese,
%D         author=Wolfgang Schuster,
%D           date=\currentdate,
%D      copyright=Wolfgang Schuster]

\unprotect

\startconstants all
      overhang: overhang
\stopconstants

\def\????rb{@@@@rb}

\newdimen\rubywidth

\newsignal\rubysignal

\def\setupruby
  {\dodoubleargument\getparameters[\????rb]}


\def\startRUBY
  {\dosingleempty\dostartRUBY}

\def\dostartRUBY[#1]%
  {\dontleavehmode
   \bgroup
   \iffirstargument
     \setupruby[#1]%
   \fi
   \ifdim\lastskip=\rubysignal
     \def\@@@@rboverhang{no}%
   \fi}

\def\startRB#1\stopRB
  {\setbox1=\hbox{#1}}

\def\startRT#1\stopRT
  {\setbox0=\hbox{#1}}

\def\stopRUBY
  {\dimen0=\wd0
   \multiply\dimen0 by\@@@@rbscale
   \divide\dimen0 by 1000
   \dimen1=\wd1
   \ifdim\dimen0>\dimen1
     \ifx\@@@@rboverhang\v!yes
       \rubywidth=\dimen1
     \else
       \rubywidth=\dimen0
     \fi
   \else
     \rubywidth=\dimen1
   \fi
   \vbox
     {\hbox\!!to\rubywidth
        %{\hss\switchtobodyfont[\dimexpr\@@@@rbscale\bodyfontsize\relax]\box0\hss}
        {\hss\box0\hss}%
      \hbox\!!to\rubywidth{\hss\small\box1\hss}}%
   \egroup
   \hskip\rubysignal}


\setupruby
  [align=middle,
   overhang=yes,
   scale=500]

\protect \endinput
