On Sat, 13 Oct 2007 20:37:35 +0200
Peter Schorsch [EMAIL PROTECTED] wrote:
Hi,
for an multilanguage document I need to write some rubytext. But I have no
idea how to realize this in context. Math-mode is not a solution as the
line-breaks with longer rubytext - but maybe it is the only way. Hints are
very welcome.
Here is a good and short explanation what rubytext is:
http://www.w3.org/International/questions/qa-ruby
Ciao, P.
Hi Peter,
you can try to use one of my modules for ruby typesetting, I never
finished any of them but I hope I will do this in the future with
support for simple and complex ruby.
The file wolf-jap is the oldest version, the file wolf-newjap should be
replacement for this file and js-ruby is a version I used myself only
in plain XeTeX, none of the module take care at the moment of
overlapping rubys or semthing else, just ruby text above the base text.
If you need something special in the ruby command you can write to me
by private mail and I will add it.
Wolfgang
\def\rubyfont{\rm}
\newtoks\rubybase
\newtoks\rubytext
\newdimen\rubywidth
\def\startRUBY
{\bgroup}
\def\stopRUBY
{\setbox0\hbox{\rubyfont\strut\the\rubytext\unskip}%
\setbox1\hbox{\strut\the\rubybase\unskip}%
\ifdim\wd0\wd1
\rubywidth\wd0
\else
\rubywidth\wd1
\fi
\vbox
{\offinterlineskip
\hbox to\rubywidth{\hss\box0\hss}%
\hbox to\rubywidth{\hss\box1\hss}}%
\egroup}
\def\startRB#1\stopRB{\rubybase{#1}}
\def\startRT#1\stopRT{\rubytext{#1}}
\def\ruby#1#2%
{\startRUBY
\startRB#1\stopRB
\startRT#2\stopRT
\stopRUBY}
\endinput
%D \module
%D [ file=wolf-jap,
%Dversion=20xx.xx.xx,
%D title=\CONTEXT\ User Module,
%D subtitle=Japanese,
%D author=Wolfgang Schuster,
%D date=\currentdate,
%D copyright=Wolfgang Schuster]
\writestatus{loading}{Context User Module / Japanese}
\unprotect
%D Systemvariable
\def\rb{rb} % RuBy
%D Setup for rubyenvironment
\def\setupruby%
{\dosingleempty\dosetupruby}
\def\dosetupruby[#1]%
{\getparameters[\rb][#1]}
%D Ruby definition
\def\ruby%
{\dosingleempty\doruby}
\def\doruby[#1]#2#3% Zeichen unter Rubybase im Moment nicht unterstützt
{\dontleavehmode
\bgroup
\getparameters[\rb][#1]%
\offinterlineskip
\edef\localstrut{\rbstrut}%
\edef\rubysize {\switchtobodyfont[\the\dimexpr\rbscale\bodyfontsize\relax]}%
\setbox0=\hbox{#2}\dimen0=\wd0
\setbox1=\hbox{\rubysize#3}\dimen1=\wd1
\ifdim\dimen0\dimen1
\hbox to \dimen0
{\vbox
{\hbox to \dimen0{\hss\ifx\localstrut\v!yes\strut\fi\box1\hss}
\doifvalue{\rbdistance}{\vskip\rbdistance}
\hbox{\ifx\localstrut\v!yes\strut\fi\box0}}}\space%
\else
%\hbox to \dimen1
% {\vbox
% {\hbox{\box1}
% \vskip-0.7ex
% \hbox to \dimen1{\hss\ifx\localstrut\v!yes\strut\fi\box0\hss}}}%
\hbox to \dimen0
{\vbox
{\hbox to \dimen0{\rubysize\hss\ifx\localstrut\v!yes\strut\fi\box1\hss}
\doifvalue{\rbdistance}{\vskip\rbdistance}
\hbox{\ifx\localstrut\v!yes\strut\fi\box0}}}\space%
\fi
\egroup
\ignorespaces}
%D A few examples
%D
%D Text text text
%D \ruby{ruby base}{ruby text}
%D text text text
%D \ruby[scale=0.7,strut=no,distance=]{ruby base}{ruby text}
%D text text text
%D
%D Text text text
%D \ruby{ruby base}{ruby text}
%D text text text
%D \ruby[strut=no]{ruby base}{ruby text}
%D text text text
%D
%D Text text text
%D \ruby{ruby base}{very long ruby text}
%D text text text
%D \ruby[scale=0.8,strut=no,distance=]{ruby base}{very long ruby text}
%D text text text
%D Default values
\setupruby
[\c!distance=-0.7ex,
\c!scale=0.6,
\c!strut=\v!yes]
\protect \endinput
%D \module
%D [ file=wolf-jap,
%Dversion=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}%