[NTG-context] Is rendering furigana over horizontal or vertical japanese text doable in ConTeXt?

黄复雄 aahuaang at gmail.com
Sun Aug 21 10:24:22 CEST 2022


Currently, the ruby module does not seem to support cjk fonts? I have
a preliminary implementation of furigana(pinyin in Chinese) as:

```lmtx
% define the pinyin font
\definefont[pinyinfont][name:ahpinying*default at 9pt]
% define the pinyin command
\define[2]\pinyin{%
    \setbox1 = \hbox{#1}%
    \setbox2 = \hbox{\darkgray \pinyinfont #2}%
    \newdimen\maxwd%
    \ifdim \wd1>\wd2 \maxwd=\wd1 \else \maxwd=\wd2 \fi%
    \setbox1 = \hbox to \maxwd{\hfill \box1 \hfill}%
    \setbox2 = \hbox to \maxwd{\hfill \box2 \hfill}%
    \hskip0pt plus5pt\vbox{\setupinterlinespace[line=0.5em]\box2\box1}%
above line
    % \hskip0pt
plus5pt\vtop{\setupinterlinespace[line=0.5em]\box1\box2}% under line
}
```
usage as follows:

```lmtx
\pinyin{寖備}{jìn bèi}
```

BTW, I hav made a vertical typesetting module for Chinese in ConTeXt LMTX,
vertical_typeset.lua in https://github.com/Fusyong/vertical-typesetting

You should modify the set for Japanese characters and punctuations here:

```lua
local function chars_to_vertical(c)
    return c >= 0x04E00 and c <= 0x09FFF
end

local puncs_to_rotate = {
[0x3001] = true, -- 、
[0xFF0C] = true, -- ,
[0x3002] = true, -- 。
[0xFF0E] = true, -- .
[0xFF1F] = true, -- ?
[0xFF01] = true, -- !
[0xFF1A] = true, -- :
[0xFF1B] = true, -- ;
}
```

and there is a doc for example, 大学章句.lmtx, in https://github.com/Fusyong/jiazhu,
and jiazhu.lua in same place is a module of Jiazhu (or 夹注, 割注) in ConTeXt LMTX.

But all the comments are in Chinese.


amano.kenji via ntg-context <ntg-context at ntg.nl> 于2022年8月16日周二 19:34写道:
>
> At least, furigana seems covered.
>
> How do I know which document to consult? There are many PDF files that come with ConTeXt.
>
> ------- Original Message -------
> On Monday, August 15th, 2022 at 3:39 PM, Wolfgang Schuster via ntg-context <ntg-context at ntg.nl> wrote:
>
>
> > amano.kenji via ntg-context schrieb am 15.08.2022 um 14:00:
> >
> > > Is there any documentation about \ruby?
> >
> >
> > You can see all available parameters in setup-en.pdf, the example below
> > shows a few of them:
> >
> > %%%% begin example
> > \setupinterlinespace[line=4ex]
> >
> > \setuptype[style=\ttx]
> >
> > \starttext
> >
> > \start
> > xxxxxxxxx \ruby{aaa}{bbb} xxxxxxxxx
> > \stop
> >
> > \start \setupruby[location=left]
> > \type{\setupruby[location=left]}\quad xxxxxxxxx \ruby{aaa}{bbb} xxxxxxxxx
> > \stop
> >
> > \start \setupruby[location=right]
> > \type{\setupruby[location=right]}\quad xxxxxxxxx \ruby{aaa}{bbb} xxxxxxxxx
> > \stop
> >
> > \start \setupruby[location=right,left={[},right={]}]
> > \type{\setupruby[left={[},right={]}]}\quad xxxxxxxxx \ruby{aaa}{bbb}
> > xxxxxxxxx
> > \stop
> >
> > \start \setupruby[align=flushleft]
> > \type{\setupruby[align=flushleft]}\quad xxxxxxxxx \ruby{aaaaaa}{bbb}
> > xxxxxxxxx
> > \stop
> >
> > \start \setupruby[align=flushright]
> > \type{\setupruby[align=flushright]}\quad xxxxxxxxx \ruby{aaaaaa}{bbb}
> > xxxxxxxxx
> > \stop
> >
> > \start \setupruby[style=\itxx]
> > \type{\setupruby[style=\itxx]}\quad xxxxxxxxx \ruby{aaa}{bbb} xxxxxxxxx
> > \stop
> >
> > \start \setupruby[color=blue]
> > \type{\setupruby[color=blue]}\quad xxxxxxxxx \ruby{aaa}{bbb} xxxxxxxxx
> > \stop
> >
> > \start \setupruby[voffset=-1.2ex]
> > \type{\setupruby[voffset=-1.2ex]}\quad xxxxxxxxx \ruby{aaa}{bbb} xxxxxxxxx
> > \stop
> >
> > \stoptext
> > %%%% end example
> >
> > > What about vertical text?
> >
> >
> > ConTeXt has a mechanism to produce vertical text but there is nothing
> > yet which can
> > be used out of the box to produce a complete document with vertical
> > paragraphs.
> >
> > Wolfgang
> >
> > ___________________________________________________________________________________
> > If your question is of interest to others as well, please add an entry to the Wiki!
> >
> > maillist : ntg-context at ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
> > webpage : https://www.pragma-ade.nl / http://context.aanhet.net
> > archive : https://bitbucket.org/phg/context-mirror/commits/
> > wiki : https://contextgarden.net
> > ___________________________________________________________________________________
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context at ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : https://contextgarden.net
> ___________________________________________________________________________________


More information about the ntg-context mailing list