ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* How to realize rubytext in Context?
@ 2007-10-13 18:37 Peter Schorsch
  2007-10-14 11:46 ` Wolfgang Schuster
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Schorsch @ 2007-10-13 18:37 UTC (permalink / raw)
  To: ntg-context

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.
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to realize rubytext in Context?
  2007-10-13 18:37 How to realize rubytext in Context? Peter Schorsch
@ 2007-10-14 11:46 ` Wolfgang Schuster
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Schuster @ 2007-10-14 11:46 UTC (permalink / raw)
  To: ntg-context

[-- Attachment #1: Type: text/plain, Size: 1043 bytes --]

On Sat, 13 Oct 2007 20:37:35 +0200
Peter Schorsch <tralalas@freenet.de> 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

[-- Attachment #2: js-ruby.tex --]
[-- Type: text/x-tex, Size: 601 bytes --]

\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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: wolf-jap.tex --]
[-- Type: text/x-tex; name="wolf-jap.tex", Size: 2281 bytes --]

%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]

\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

[-- Attachment #4: wolf-newjap.tex --]
[-- Type: text/x-tex, Size: 1337 bytes --]

%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

[-- Attachment #5: Type: text/plain, Size: 487 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-10-14 11:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-13 18:37 How to realize rubytext in Context? Peter Schorsch
2007-10-14 11:46 ` Wolfgang Schuster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).