[NTG-context] Is rendering furigana over horizontal or vertical japanese text doable in ConTeXt?
Wolfgang Schuster
wolfgang.schuster.lists at gmail.com
Sun Aug 21 12:10:03 CEST 2022
黄复雄 via ntg-context schrieb am 21.08.2022 um 10:24:
> 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}
> ```
The ruby command has no problem with chinese but you need a font which
has support for it.
As can be seen in my previous example you can use the style-key to
switch to a different font
for the annotation (e.g. \setupruby[style=\pinyinfont]).
%%%% begin example
\definefallbackfamily [documentfont] [rm] [Noto Serif CJK SC]
[preset=range:chinese]
\definefallbackfamily [documentfont] [ss] [Noto Sans CJK SC]
[preset=range:chinese]
\definefallbackfamily [documentfont] [tt] [Noto Sans Mono CJK SC]
[preset=range:chinese]
\definefontfamily [documentfont] [rm] [Noto Serif]
\definefontfamily [documentfont] [ss] [Noto Sans]
\definefontfamily [documentfont] [tt] [Noto Sans Mono]
\setupbodyfont [documentfont]
\setupruby[color=darkgray]
\starttext
\ruby{寖備}{jìn bèi} \ss \ruby{寖備}{jìn bèi} \tt \ruby{寖備}{jìn bèi}
\stoptext
%%%% end example
Wolfgang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.pdf
Type: application/pdf
Size: 16822 bytes
Desc: not available
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20220821/f4560765/attachment.pdf>
More information about the ntg-context
mailing list