ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Is rendering furigana over horizontal or vertical japanese text doable in ConTeXt?
@ 2022-08-15 11:02 amano.kenji via ntg-context
  2022-08-15 11:43 ` Taco Hoekwater via ntg-context
  0 siblings, 1 reply; 15+ messages in thread
From: amano.kenji via ntg-context @ 2022-08-15 11:02 UTC (permalink / raw)
  To: ConTeXt users; +Cc: amano.kenji

Typesetting furigana over kanji characters is common for japanese educational materials.

Is this doable in ConTeXt?
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@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
___________________________________________________________________________________

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

* Re: Is rendering furigana over horizontal or vertical japanese text doable in ConTeXt?
  2022-08-15 11:02 Is rendering furigana over horizontal or vertical japanese text doable in ConTeXt? amano.kenji via ntg-context
@ 2022-08-15 11:43 ` Taco Hoekwater via ntg-context
  2022-08-15 12:00   ` amano.kenji via ntg-context
  0 siblings, 1 reply; 15+ messages in thread
From: Taco Hoekwater via ntg-context @ 2022-08-15 11:43 UTC (permalink / raw)
  To: amano.kenji, mailing list for ConTeXt users; +Cc: Taco Hoekwater



> On 15 Aug 2022, at 13:02, amano.kenji via ntg-context <ntg-context@ntg.nl> wrote:
> 
> Typesetting furigana over kanji characters is common for japanese educational materials.

Yes, using the \ruby command. That used to require a module, but is now in the core. 

The wiki page on CJK fonts should probably be updated (new fonts, broken ftp links, etc.) 
but at least it mentions this:

  https://wiki.contextgarden.net/CJK_fonts

Best wishes,
Taco

— 
Taco Hoekwater              E: taco@bittext.nl
genderfluid (all pronouns)



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

maillist : ntg-context@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
___________________________________________________________________________________

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

* Re: Is rendering furigana over horizontal or vertical japanese text doable in ConTeXt?
  2022-08-15 11:43 ` Taco Hoekwater via ntg-context
@ 2022-08-15 12:00   ` amano.kenji via ntg-context
  2022-08-15 15:39     ` Wolfgang Schuster via ntg-context
  0 siblings, 1 reply; 15+ messages in thread
From: amano.kenji via ntg-context @ 2022-08-15 12:00 UTC (permalink / raw)
  To: Taco Hoekwater; +Cc: amano.kenji, mailing list for ConTeXt users

Is there any documentation about \ruby? What about vertical text?

------- Original Message -------
On Monday, August 15th, 2022 at 11:43 AM, Taco Hoekwater <taco@bittext.nl> wrote:


> > On 15 Aug 2022, at 13:02, amano.kenji via ntg-context ntg-context@ntg.nl wrote:
> >
> > Typesetting furigana over kanji characters is common for japanese educational materials.
>
>
> Yes, using the \ruby command. That used to require a module, but is now in the core.
>
> The wiki page on CJK fonts should probably be updated (new fonts, broken ftp links, etc.)
> but at least it mentions this:
>
> https://wiki.contextgarden.net/CJK_fonts
>
> Best wishes,
> Taco
>
> —
> Taco Hoekwater E: taco@bittext.nl
> genderfluid (all pronouns)
>
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@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
___________________________________________________________________________________

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

* Re: Is rendering furigana over horizontal or vertical japanese text doable in ConTeXt?
  2022-08-15 12:00   ` amano.kenji via ntg-context
@ 2022-08-15 15:39     ` Wolfgang Schuster via ntg-context
  2022-08-16 11:33       ` amano.kenji via ntg-context
  0 siblings, 1 reply; 15+ messages in thread
From: Wolfgang Schuster via ntg-context @ 2022-08-15 15:39 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Wolfgang Schuster

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@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
___________________________________________________________________________________

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

* Re: Is rendering furigana over horizontal or vertical japanese text doable in ConTeXt?
  2022-08-15 15:39     ` Wolfgang Schuster via ntg-context
@ 2022-08-16 11:33       ` amano.kenji via ntg-context
  2022-08-16 15:05         ` Wolfgang Schuster via ntg-context
  2022-08-21  8:24         ` 黄复雄 via ntg-context
  0 siblings, 2 replies; 15+ messages in thread
From: amano.kenji via ntg-context @ 2022-08-16 11:33 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: amano.kenji

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@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@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@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
___________________________________________________________________________________

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

* Re: Is rendering furigana over horizontal or vertical japanese text doable in ConTeXt?
  2022-08-16 11:33       ` amano.kenji via ntg-context
@ 2022-08-16 15:05         ` Wolfgang Schuster via ntg-context
  2022-08-21  8:24         ` 黄复雄 via ntg-context
  1 sibling, 0 replies; 15+ messages in thread
From: Wolfgang Schuster via ntg-context @ 2022-08-16 15:05 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Wolfgang Schuster

amano.kenji schrieb am 16.08.2022 um 13:33:
> At least, furigana seems covered.
>
> How do I know which document to consult? There are many PDF files that come with ConTeXt.

You can start with the following thread from 2020: 
https://mailman.ntg.nl/pipermail/ntg-context/2020/098389.html

Useful documents are (both are part of your context installation):

- http://www.pragma-ade.nl/general/manuals/followingup.pdf
- https://www.pragma-ade.nl/general/manuals/lowlevel-boxes.pdf

Wolfgang

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

maillist : ntg-context@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
___________________________________________________________________________________

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

* Re: Is rendering furigana over horizontal or vertical japanese text doable in ConTeXt?
  2022-08-16 11:33       ` amano.kenji via ntg-context
  2022-08-16 15:05         ` Wolfgang Schuster via ntg-context
@ 2022-08-21  8:24         ` 黄复雄 via ntg-context
  2022-08-21 10:00           ` Hans Hagen via ntg-context
  2022-08-21 10:10           ` Wolfgang Schuster via ntg-context
  1 sibling, 2 replies; 15+ messages in thread
From: 黄复雄 via ntg-context @ 2022-08-21  8:24 UTC (permalink / raw)
  To: amano.kenji, mailing list for ConTeXt users; +Cc: 黄复雄

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@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@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@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@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@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
___________________________________________________________________________________

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

* Re: Is rendering furigana over horizontal or vertical japanese text doable in ConTeXt?
  2022-08-21  8:24         ` 黄复雄 via ntg-context
@ 2022-08-21 10:00           ` Hans Hagen via ntg-context
  2022-08-21 10:10           ` Wolfgang Schuster via ntg-context
  1 sibling, 0 replies; 15+ messages in thread
From: Hans Hagen via ntg-context @ 2022-08-21 10:00 UTC (permalink / raw)
  To: mailing list for ConTeXt users, amano.kenji; +Cc: Hans Hagen

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

On 8/21/2022 10:24 AM, 黄复雄 via ntg-context wrote:
> Currently, the ruby module does not seem to support cjk fonts? I have
> a preliminary implementation of furigana(pinyin in Chinese) as:
Actually a few years ago I added some basic new features for doing 
vertical scripts effciently but (as often with these things) there was 
not that much follow up because no one seems to need / use it (or be 
triggered by the fact that it can be used).

The attached files show two methods ... manual work as well as semi 
automatic (one needs to patch one font file for some recent optimizations).

As you can see, rubies work ok. Now, before trying to improve this, it 
makes more sense to think about what kind of vertical support is 
actually needed becaus in order for that to work ok it really has to 
work with other mechanism as well and there is only so much that tex can 
do.

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------

[-- Attachment #2: test-directions-005.pdf --]
[-- Type: application/pdf, Size: 21019 bytes --]

[-- Attachment #3: test-directions-005.tex --]
[-- Type: text/plain, Size: 6922 bytes --]

\noheaderandfooterlines

% in font-imp-scripts, line 145, comment a few lines
%
%                 orientate = function(character)
%                     local width  = character.width or 0
%                     local height = character.height or 0
%                     local depth  = character.depth or 0
% --                     character.width       = height + depth + rightshift + rightshift
%                     character.height      = width - downshift
%                     character.depth       = shift
% --                     character.xoffset     = height + rightshift
% --                     character.yoffset     = - downshift
% --                     character.orientation = orientation
%                 end

\dontcomplain

\setuplayout[middle]

\starttext

\startluacode
    local nuts          = nodes.nuts

    local nextglyph     = nuts.traversers.glyph
    local nextnode      = nuts.traversers.node

    local newhlist      = nuts.pool.hlist
    local newglue       = nuts.pool.glue
    local newpenalty    = nuts.pool.penalty

    local getprev       = nuts.getprev
    local setnext       = nuts.setnext
    local getnext       = nuts.getnext
    local setprev       = nuts.setprev
    local getboth       = nuts.getboth
    local setboth       = nuts.setboth
    local setlink       = nuts.setlink
    local getlist       = nuts.getlist
    local setlist       = nuts.setlist
    local setwhd        = nuts.setwhd
    local getwhd        = nuts.getwhd
    local getid         = nuts.getid
    local getchar       = nuts.getchar

    local getbox        = nuts.getbox

    local getdimensions = nuts.dimensions

    local setorientation  = nuts.setorientation
    local getorientation  = nuts.getorientation

    local glyph_code    = nodes.nodecodes.glyph
    local kern_code     = nodes.nodecodes.kern

    function document.manipulate_one(boxnumber)

        local box  = getbox(1000)
        local list = getlist(b)
        local all  = { }

        for n, c, f in nextglyph, list do
            if c > 200 then
                all[n] = true
            end
        end

        local o = 4 * 65536

        for n, how in next, all do
            local prev, next = getboth(n)
            setboth(n)
            local l = newhlist(n)
            local w, h, d = getwhd(n)
            setlink(prev,l,next)
            if how then
                setwhd(l,h+d+o,w,0)
                setorientation(l,0x003,0,0,h,d-o)
            end
            if n == list then
                setlist(box,l)
            end
        end

    end

    local function flushrange(head,current,first,last)
        local prev = getprev(first)
        local next = getnext(last)
        local list = newhlist(first)
        setprev(first)
        setnext(last)
        local w, h, d = getdimensions(first)
        setwhd(list,h+d,w,0)
        setlink(prev,list,next)
        setorientation(list,0x001,0,0,h,d)
        if first == head then
            return list, list
        else
            return head, list
        end
    end

    local function flushchar(head,current)
        local next = getnext(current)
        local glue = newglue(n,655360)
        setlink(current,glue,next)
        return head, glue
    end

    function document.manipulate_two(boxnumber)

        local box     = getbox(1000)
        local head    = getlist(box)
        local first   = false
        local last    = false
        local current = head
        while current do
            local id = getid(current)
            if id == glyph_code then
                if getchar(current) < 200 then
                    if first then
                        last = current
                    else
                        first = current
                        last  = current
                    end
                else
                    if first then
                        head, current = flushrange(head,current,first,last)
                        first = false
                    end
                    head, current = flushchar(head,current)
                end
            elseif id == kern_code then
                if first then
                    last = current
                end
            elseif first then
                head, current = flushrange(head,current,first,last)
                first = false
            end
            current = getnext(current)
        end
        if first then
            head, current = flushrange(head,current,first,last)
        end
        setlist(box,head)
    end

\stopluacode

% % % % % % % % % %

\setuptolerance[verytolerant,stretch]

\definefont[NotoCJK][NotoSanstc-Regular*default @ 24pt] \setupinterlinespace[40pt]

\unexpanded\def\stripe#1{\hbox orientation 0 yoffset 3pt{\strut #1}}

\setbox1000\hbox{\NotoCJK\startscript[hangul]\dorecurse{20}{通用规范汉字表 \stripe{test #1} }\stopscript}

\ctxlua{document.manipulate_one(1000)}

\ruledvbox orientation 1 to \textwidth \bgroup
    \hsize \textheight
    \unhbox1000
    \vfill
\egroup

\page

\setbox1000\hbox{\NotoCJK\startscript[hangul]\dorecurse{20}{通用规\ruby{范}{x}汉字表 \stripe{test #1} }\stopscript}

\ctxlua{document.manipulate_one(1000)}

\ruledvbox orientation 1 to \textwidth \bgroup
    \hsize \textheight
    \unhbox1000
    \vfill
\egroup

\page

\setupinterlinespace[40pt]

\definefontfeature
    [vertical]
    [vertical={%
        orientation=3,%
        down=.1,%
        right=.1,%
        ranges={%
            cjkcompatibility,%
            cjkcompatibilityforms,%
            cjkcompatibilityideographs,%
            cjkcompatibilityideographssupplement,%
            cjkradicalssupplement,%
          % cjkstrokes,%
            cjksymbolsandpunctuation,%
            cjkunifiedideographs,%
            cjkunifiedideographsextensiona,%
            cjkunifiedideographsextensionb,%
            cjkunifiedideographsextensionc,%
            cjkunifiedideographsextensiond,%
            cjkunifiedideographsextensione,%
            cjkunifiedideographsextensionf,%
        }%
    }]

\definefont[NotoCJKvertical][NotoSanstc-Regular*default,vertical @ 24pt]

\showglyphs

\unexpanded\def\stripe#1{\hbox orientation 0 yoffset 3pt{\strut #1}}

\setbox1000\hbox{\NotoCJKvertical\startscript[hangul]\dorecurse{20}{通用规范汉字表 \stripe{test #1} }\stopscript}

\ruledvbox orientation 1 to \textwidth \bgroup
    \hsize \textheight
    \unhbox1000
    \vfill
\egroup

\page

\setbox1000\hbox{\NotoCJKvertical\startscript[hangul]\dorecurse{20}{通用规\ruby{范}{x}汉字表 \stripe{test #1} }\stopscript}

\ruledvbox orientation 1 to \textwidth \bgroup
    \hsize \textheight
    \unhbox1000
    \vfill
\egroup

% \stopscript

\stoptext

[-- Attachment #4: test-directions-006.pdf --]
[-- Type: application/pdf, Size: 19235 bytes --]

[-- Attachment #5: test-directions-006.tex --]
[-- Type: text/plain, Size: 5413 bytes --]

\dontcomplain

% in font-imp-scripts, line 145, comment a few lines
%
%                 orientate = function(character)
%                     local width  = character.width or 0
%                     local height = character.height or 0
%                     local depth  = character.depth or 0
% --                     character.width       = height + depth + rightshift + rightshift
%                     character.height      = width - downshift
%                     character.depth       = shift
% --                     character.xoffset     = height + rightshift
% --                     character.yoffset     = - downshift
% --                     character.orientation = orientation
%                 end

\setuplayout[middle]

\starttext

\startluacode
    local nuts           = nodes.nuts

    local nextglyph      = nuts.traversers.glyph

    local newhlist       = nuts.pool.hlist

    local getboth        = nuts.getboth
    local setboth        = nuts.setboth
    local setlink        = nuts.setlink
    local getlist        = nuts.getlist
    local setlist        = nuts.setlist
    local setwhd         = nuts.setwhd
    local getwhd         = nuts.getwhd
    local setorientation = nuts.setorientation

    local getbox         = nuts.getbox

    local xheights       = fonts.hashes.xheights

    local function is_vertical(c)
        return c >= 0x04E00 and c <= 0x09FFF
    end

    function document.manipulate_one(boxnumber)

        local box  = getbox(boxnumber)
        local list = getlist(box)
        local all  = { }

        for n, c, f in nextglyph, list do
            if is_vertical(c) then
                all[n] = f
            end
        end

        for n, f in next, all do
            local o = .2 * xheights[f]
            local prev, next = getboth(n)
            setboth(n)
            local l = newhlist(n)
            local w, h, d = getwhd(n)
            setlink(prev,l,next)
            setwhd(l,h+d+o,w,0)
            setorientation(l,0x003,o/2,-o/2,0,h,d-o)
            if n == list then
                setlist(box,l)
            end
        end

    end

\stopluacode

\startluacode
    function document.manipulate_two(boxnumber)

        local box = tex.getbox(boxnumber)
        local n   = box.list

        local function is_vertical(c)
            return c >= 0x04E00 and c <= 0x09FFF
        end

        while n do
            if n.id == node.id("glyph") and is_vertical(n.char) then
                local o = .2 * fonts.hashes.identifiers[n.font].parameters.xheight
                local prev, next = n.prev, n.next
                n.next, n.prev = nil, nil
                local l = nodes.new("hlist")
                l.list = n
                local w, h, d = n.width, n.height, n.depth
                if prev then
                    prev.next, l.prev = l, prev
                else
                    box.list = l
                end
                if next then
                    l.next, next.prev = next, l
                end
                l.width, l.height, l.depth  = h + d + o, w, 0
                l.orientation = 0x003
--              l.xoffset, l.yoffset = o/2, -o/2
              l.hoffset, l.doffset = h, d - o
                n = next
            else
                n = n.next
            end
        end

    end

\stopluacode

% % % % % % % % % %

\unexpanded\def\stripe#1{\hbox orientation 0 yoffset 3pt{\strut #1}}

\setuptolerance[verytolerant,stretch]

\definefont[NotoCJK][NotoSanstc-Regular*default @ 24pt] \setupinterlinespace[40pt]

% % % % % % % % % %

\setbox1000\hbox{\NotoCJK\startscript[hangul]\dorecurse{20}{通用规范汉字表 \stripe{test #1} }\stopscript}
\ctxlua{document.manipulate_one(1000)}
\ruledvbox orientation 1 to \textwidth \bgroup
    \hsize \textheight
    \unhbox1000
    \vfill
\egroup
\page

\setbox1000\hbox{\NotoCJK\startscript[hangul]\dorecurse{20}{通用规范汉字表 \stripe{test #1} }\stopscript}
\ctxlua{document.manipulate_two(1000)}
\ruledvbox orientation 1 to \textwidth \bgroup
    \hsize \textheight
    \unhbox1000
    \vfill
\egroup
\page

\setupinterlinespace[40pt]

\definefontfeature
    [vertical]
    [vertical={%
        orientation=3,%
        down=.1,%
        right=.1,%
        ranges={%
            cjkcompatibility,%
            cjkcompatibilityforms,%
            cjkcompatibilityideographs,%
            cjkcompatibilityideographssupplement,%
            cjkradicalssupplement,%
          % cjkstrokes,%
            cjksymbolsandpunctuation,%
            cjkunifiedideographs,%
            cjkunifiedideographsextensiona,%
            cjkunifiedideographsextensionb,%
            cjkunifiedideographsextensionc,%
            cjkunifiedideographsextensiond,%
            cjkunifiedideographsextensione,%
            cjkunifiedideographsextensionf,%
        }%
    }]

\definefont[NotoCJKvertical][NotoSanstc-Regular*default,vertical @ 24pt]

\showglyphs

\unexpanded\def\stripe#1{\hbox orientation 0 yoffset 3pt{\strut #1}}

\setbox1000\hbox{\NotoCJKvertical\startscript[hangul]\dorecurse{20}{通用规范汉字表 \stripe{test #1} }\stopscript}

\ruledvbox orientation 1 to \textwidth \bgroup
    \hsize \textheight
    \unhbox1000
    \vfill
\egroup

% \stopscript

\stoptext

[-- Attachment #6: Type: text/plain, Size: 496 bytes --]

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

maillist : ntg-context@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
___________________________________________________________________________________

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

* Re: Is rendering furigana over horizontal or vertical japanese text doable in ConTeXt?
  2022-08-21  8:24         ` 黄复雄 via ntg-context
  2022-08-21 10:00           ` Hans Hagen via ntg-context
@ 2022-08-21 10:10           ` Wolfgang Schuster via ntg-context
  2022-08-21 16:19             ` Hans Hagen via ntg-context
                               ` (2 more replies)
  1 sibling, 3 replies; 15+ messages in thread
From: Wolfgang Schuster via ntg-context @ 2022-08-21 10:10 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Wolfgang Schuster

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

黄复雄 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


[-- Attachment #2: test.pdf --]
[-- Type: application/pdf, Size: 16822 bytes --]

[-- Attachment #3: Type: text/plain, Size: 496 bytes --]

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

maillist : ntg-context@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
___________________________________________________________________________________

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

* Re: Is rendering furigana over horizontal or vertical japanese text doable in ConTeXt?
  2022-08-21 10:10           ` Wolfgang Schuster via ntg-context
@ 2022-08-21 16:19             ` Hans Hagen via ntg-context
  2022-08-22  5:21               ` 黄复雄 via ntg-context
  2022-08-22  2:09             ` 黄复雄 via ntg-context
  2022-08-22  4:52             ` 黄复雄 via ntg-context
  2 siblings, 1 reply; 15+ messages in thread
From: Hans Hagen via ntg-context @ 2022-08-21 16:19 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Hans Hagen

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

On 8/21/2022 12:10 PM, Wolfgang Schuster via ntg-context wrote:
> 黄复雄 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:
attached a variant (no pdf attached) using wolfgangs font definition 
plus some more

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------

[-- Attachment #2: test-directions-008.tex --]
[-- Type: text/plain, Size: 3124 bytes --]

% in font-imp-scripts, line 145, comment a few lines
%
%                 orientate = function(character)
%                     local width  = character.width or 0
%                     local height = character.height or 0
%                     local depth  = character.depth or 0
% --                     character.width       = height + depth + rightshift + rightshift
%                     character.height      = width - downshift
%                     character.depth       = shift
% --                     character.xoffset     = height + rightshift
% --                     character.yoffset     = - downshift
% --                     character.orientation = orientation
%                 end

\definefontfeature
    [vertical]
    [vertical={%
        orientation=3,%
        down=.1,%
        right=.1,%
        ranges={%
            cjkcompatibility,%
            cjkcompatibilityforms,%
            cjkcompatibilityideographs,%
            cjkcompatibilityideographssupplement,%
            cjkradicalssupplement,%
          % cjkstrokes,%
            cjksymbolsandpunctuation,%
            cjkunifiedideographs,%
            cjkunifiedideographsextensiona,%
            cjkunifiedideographsextensionb,%
            cjkunifiedideographsextensionc,%
            cjkunifiedideographsextensiond,%
            cjkunifiedideographsextensione,%
            cjkunifiedideographsextensionf,%
        }%
    }]

\definefont[NotoCJKvertical]    [NotoSanstc-Regular*default,vertical @ 24pt]
\definefont[NotoCJKverticalBold][NotoSanstc-Bold*default,vertical @ 48pt]

\definefallbackfamily [documentfont] [rm] [Noto Serif CJK SC]     [preset=range:chinese,features={default,vertical}]
\definefallbackfamily [documentfont] [ss] [Noto Sans CJK SC]      [preset=range:chinese,features={default,vertical}]
\definefallbackfamily [documentfont] [tt] [Noto Sans Mono CJK SC] [preset=range:chinese,features={default,vertical}]

\definefontfamily [documentfont] [rm] [Noto Serif]
\definefontfamily [documentfont] [ss] [Noto Sans]
\definefontfamily [documentfont] [tt] [Noto Sans Mono]

\setupbodyfont [documentfont,24pt]

\setuppapersize
 [A4,landscape,rotated,270]
 [A4,portrait]

\setuplayout[middle]

\showframe

\setuphead
  [chapter]
  [numbercolor=darkred,
   conversion=chinesenumerals]

\setuptolerance
  [verytolerant,stretch]

\setupinterlinespace
  [40pt]

\setuplayout
  [color=darkblue]

\setuppagenumbering
  [location=footer]

\defineconversionset
  [pagenumber]
  []
  [chinesenumerals]

\protected\def\stripe#1{\hbox orientation 0 yoffset 3pt{\strut #1}}

\setscript[hangul]

\starttext

% \startscript[hangul]

    \chapter{通用规}

    \placefigure
      [left,none]
      {汉字表}
      {\framed
         [width=4cm,
          height=2\lineheight,
          frame=off,
          backgroundcolor=darkgreen,
          foregroundcolor=white,
          background=color]
         {汉字表}}

    \dorecurse{40}{%
        通用规\ruby{范}{x}汉字表 \stripe{test #1}
    }

% \stopscript

\stoptext

[-- Attachment #3: Type: text/plain, Size: 496 bytes --]

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

maillist : ntg-context@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
___________________________________________________________________________________

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

* Re: Is rendering furigana over horizontal or vertical japanese text doable in ConTeXt?
  2022-08-21 10:10           ` Wolfgang Schuster via ntg-context
  2022-08-21 16:19             ` Hans Hagen via ntg-context
@ 2022-08-22  2:09             ` 黄复雄 via ntg-context
  2022-08-22  4:52             ` 黄复雄 via ntg-context
  2 siblings, 0 replies; 15+ messages in thread
From: 黄复雄 via ntg-context @ 2022-08-22  2:09 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: 黄复雄

Dear Wolfgang,
thank you very much for your guidance.
After changing the font settings according to my computer Win10 OS,
the ruby module worked.
But there is another problem, when I use `\setscript[hanzi]`, as follows

%%%begin example
\setscript[hanzi]

\usetypescriptfile[mscore]
\usebodyfont   [mschinese,20pt]
\definefont[pinyinfont][name:ahpinying*default at 9pt]
\setupruby[color=darkgray, style=\pinyinfont]

\starttext
\ruby{寖備}{jìn bèi} \ss \ruby{寖備}{jìn bèi} % \tt \ruby{寖備}{jìn bèi}
\stoptext
%%%end example

ruby errors out as follows(that's why I didn't succeed with ruby before):

%%%begin error
resolvers       | formats | executing runner 'run luametatex format':
D:/venvs/context-win64/tex/texmf-win64/bin/luametatex
--jobname="d:/ah21/TEX/vertical-and-ruby-examples/ruby.lmtx"
--fmt=D:/venvs/context-win64/tex/texmf-cache/luametatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luametatex/cont-en.fmt
--lua=D:/venvs/context-win64/tex/texmf-cache/luametatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luametatex/cont-en.lui
 --c:currentrun=1
--c:fulljobname="d:/ah21/TEX/vertical-and-ruby-examples/ruby.lmtx"
--c:input="d:/ah21/TEX/vertical-and-ruby-examples/ruby.lmtx"
--c:kindofrun=1 --c:maxnofruns=9
--c:texmfbinpath="D:/venvs/context-win64/tex/texmf-win64/bin"
system          >
system          > ConTeXt  ver: 2022.07.27 17:56 LMTX  fmt: 2022.8.22
int: english/english
system          >
system          > 'cont-new.mkxl' loaded
open source     > level 1, order 1, name
'D:/venvs/context-win64/tex/texmf-context/tex/context/base/mkxl/cont-new.mkxl'
system          > beware: some patches loaded from cont-new.mkiv
close source    > level 1, order 1, name
'D:/venvs/context-win64/tex/texmf-context/tex/context/base/mkxl/cont-new.mkxl'
system          > files > jobname
'd:/ah21/TEX/vertical-and-ruby-examples/ruby', input
'd:/ah21/TEX/vertical-and-ruby-examples/ruby.lmtx', result
'd:/ah21/TEX/vertical-and-ruby-examples/ruby'
fonts           > latin modern fonts are not preloaded
languages       > language 'en' is active
open source     > level 1, order 2, name
'd:/ah21/TEX/vertical-and-ruby-examples/ruby.lmtx'
fonts           > bodyfont '20pt' is defined (can better be done global)
fonts           > bodyfont '24pt' is defined (can better be done global)
fonts           > bodyfont '16pt' is defined (can better be done global)
open source     > level 2, order 3, name
'D:/venvs/context-win64/tex/texmf-context/tex/context/fonts/mkiv/type-imp-mscore.mkiv'
close source    > level 2, order 3, name
'D:/venvs/context-win64/tex/texmf-context/tex/context/fonts/mkiv/type-imp-mscore.mkiv'
open source     > level 2, order 4, name
'D:/venvs/context-win64/tex/texmf-context/tex/context/fonts/mkiv/type-imp-cambria.mkiv'
open source     > level 3, order 5, name
'D:/venvs/context-win64/tex/texmf-context/tex/context/fonts/mkiv/type-imp-dejavu.mkiv'
close source    > level 3, order 5, name
'D:/venvs/context-win64/tex/texmf-context/tex/context/fonts/mkiv/type-imp-dejavu.mkiv'
close source    > level 2, order 5, name
'D:/venvs/context-win64/tex/texmf-context/tex/context/fonts/mkiv/type-imp-cambria.mkiv'
tex error       > tex error on line 1 in file
d:/ah21/TEX/vertical-and-ruby-examples/ruby.lmtx:

lua error:

        registered function call [209]:
...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:268:
attempt to index a nil value (local 'ruby')
stack traceback:
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:268:
in upvalue 'whatever'
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:370:
in upvalue 'attach'
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:363:
in upvalue 'whatever'
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:370:
in upvalue 'attach'
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:363:
in upvalue 'whatever'
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:370:
in upvalue 'attach'
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:363:
in upvalue 'whatever'
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:370:
in upvalue 'attach'
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:363:
in upvalue 'whatever'
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:370:
in upvalue 'attach'
        ...     (skipping 14 levels)
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:370:
in upvalue 'attach'
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:363:
in upvalue 'whatever'
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:370:
in upvalue 'attach'
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:363:
in upvalue 'whatever'
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:370:
in upvalue 'attach'
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:363:
in upvalue 'whatever'
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:370:
in upvalue 'attach'
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:363:
in upvalue 'whatever'
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:370:
in upvalue 'typesetters_rubies_attach'
        [string "local tonut  = nodes.tonut..."]:20: in function
<[string "local tonut  = nodes.tonut..."]:11>
        (...tail calls...)
        [string
"D:/venvs/context-win64/tex/texmf-context/tex/..."]:38: in function
<[string "D:/venvs/context-win64/tex/texmf-context/tex/..."]:37>
        (...tail calls...)

 1 >>  \setscript[hanzi]
 2
 3     \usetypescriptfile[mscore]
 4     \usebodyfont   [mschinese,20pt]
 5     %
 6     \definefont[pinyinfont][name:ahpinying*default at 9pt]
 7     %
 8     \setupruby[color=darkgray, style=\pinyinfont]
 9
10     \starttext
11     \ruby{寖備}{jìn bèi} \ss \ruby{寖備}{jìn bèi} %\tt \ruby{寖備}{jìn bèi}
mtx-context     | fatal error: return code: 1
%%%end error

Best regards,
                     Huang Fusyong(黄复雄)

Wolfgang Schuster via ntg-context <ntg-context@ntg.nl> 于2022年8月21日周日 18:11写道:
>
> 黄复雄 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
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@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@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
___________________________________________________________________________________

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

* Re: Is rendering furigana over horizontal or vertical japanese text doable in ConTeXt?
  2022-08-21 10:10           ` Wolfgang Schuster via ntg-context
  2022-08-21 16:19             ` Hans Hagen via ntg-context
  2022-08-22  2:09             ` 黄复雄 via ntg-context
@ 2022-08-22  4:52             ` 黄复雄 via ntg-context
  2 siblings, 0 replies; 15+ messages in thread
From: 黄复雄 via ntg-context @ 2022-08-22  4:52 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: 黄复雄

Dear Wolfgang,
thank you very much for your guidance.
After changing the font settings according to my computer Win10 OS,
the ruby module worked.
But there is another problem, when I use `\setscript[hanzi]`, as follows

%%%begin example
\setscript[hanzi]

\usetypescriptfile[mscore]
\usebodyfont   [mschinese,20pt]
\definefont[pinyinfont][name:ahpinying*default at 9pt]
\setupruby[color=darkgray, style=\pinyinfont]

\starttext
\ruby{寖備}{jìn bèi} \ss \ruby{寖備}{jìn bèi} % \tt \ruby{寖備}{jìn bèi}
\stoptext
%%%end example

ruby errors out as follows(that's why I didn't succeed with ruby before):

%%%begin error
……
tex error       > tex error on line 1 in file
d:/ah21/TEX/vertical-and-ruby-examples/ruby.lmtx:

lua error:

        registered function call [209]:
...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:268:
attempt to index a nil value (local 'ruby')
stack traceback:
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:268:
in upvalue 'whatever'
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:370:
in upvalue 'attach'
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:363:
in upvalue 'whatever'
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:370:
in upvalue 'attach'
        ...     (skipping 27 levels)
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:363:
in upvalue 'whatever'
        ...n64/tex/texmf-context/tex/context/base/mkxl/typo-rub.lmt:370:
in upvalue 'typesetters_rubies_attach'
        [string "local tonut  = nodes.tonut..."]:20: in function
<[string "local tonut  = nodes.tonut..."]:11>
        (...tail calls...)
        [string
"D:/venvs/context-win64/tex/texmf-context/tex/..."]:38: in function
<[string "D:/venvs/context-win64/tex/texmf-context/tex/..."]:37>
        (...tail calls...)

 1 >>  \setscript[hanzi]
……
%%%end error

Best regards,
                     Huang Fusyong(黄复雄)

Wolfgang Schuster via ntg-context <ntg-context@ntg.nl> 于2022年8月21日周日 18:11写道:
>
> 黄复雄 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
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@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@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
___________________________________________________________________________________

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

* Re: Is rendering furigana over horizontal or vertical japanese text doable in ConTeXt?
  2022-08-21 16:19             ` Hans Hagen via ntg-context
@ 2022-08-22  5:21               ` 黄复雄 via ntg-context
  2022-08-22  7:16                 ` Hans Hagen via ntg-context
  0 siblings, 1 reply; 15+ messages in thread
From: 黄复雄 via ntg-context @ 2022-08-22  5:21 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: 黄复雄

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

Dear Hans.
Thank you very much for so many examples and guidance.

In fact, I have read one of the examples in the followingup.pdf,
and the https://github.com/Fusyong/vertical-typesetting module I made
is based on the example.

The examples all worked after I changed the font settings according to
my Win10 OS;
and surprisingly, the ruby module also worked with \setscript[hanzi]
 (they don't work together in the example Mr. Wolfgang provided).
The only problem is that the offsets of glyphs are a bit inaccurate,
which may be related to the font,
and I will look into it further.
The examples I have adjusted are attached,
and the output PDF of them is not attached for being too big to the
limit of 100 KB.
(Just now I received a reply from the mailing list system asking to
adjust a over-length email,
I mistakenly thought it was about the one to Mr. Wolfgang, so that one
was duplicated and submitted,
please deal with it.)

By the way, I've finished checking and adjusting type-imp-mscore.mkiv,
scrp-cjk.lua, and char-scr.lua so far,
but the changes are a bit much (or maybe you can say a bit reckless),
so I'm hesitant to get back to you in order to minimize your troubles.
And as mentioned partly in an earlier email, I've made 3 modules that
support Chinese
(about vertical-typesetting,  Jiazhu or inline cutting note and punctuation)
and I'd be happy to contribute them to the ConTeXt project repository
when they're ripe,
if that's in line with the project policy. Your comments and guidance
are very welcome.

Best regards,
                     Huang Fusyong(黄复雄)

Hans Hagen via ntg-context <ntg-context@ntg.nl> 于2022年8月22日周一 00:20写道:
>
> On 8/21/2022 12:10 PM, Wolfgang Schuster via ntg-context wrote:
> > 黄复雄 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:
> attached a variant (no pdf attached) using wolfgangs font definition
> plus some more
>
> -----------------------------------------------------------------
>                                            Hans Hagen | PRAGMA ADE
>                Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>         tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
> -----------------------------------------------------------------___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@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
> ___________________________________________________________________________________

[-- Attachment #2: test-directions-006.lmtx --]
[-- Type: application/octet-stream, Size: 5407 bytes --]

\dontcomplain

% in font-imp-scripts, line 145, comment a few lines
%
%                 orientate = function(character)
%                     local width  = character.width or 0
%                     local height = character.height or 0
%                     local depth  = character.depth or 0
% --                     character.width       = height + depth + rightshift + rightshift
%                     character.height      = width - downshift
%                     character.depth       = shift
% --                     character.xoffset     = height + rightshift
% --                     character.yoffset     = - downshift
% --                     character.orientation = orientation
%                 end

\setuplayout[middle]

\starttext

\startluacode
    local nuts           = nodes.nuts

    local nextglyph      = nuts.traversers.glyph

    local newhlist       = nuts.pool.hlist

    local getboth        = nuts.getboth
    local setboth        = nuts.setboth
    local setlink        = nuts.setlink
    local getlist        = nuts.getlist
    local setlist        = nuts.setlist
    local setwhd         = nuts.setwhd
    local getwhd         = nuts.getwhd
    local setorientation = nuts.setorientation

    local getbox         = nuts.getbox

    local xheights       = fonts.hashes.xheights

    local function is_vertical(c)
        return c >= 0x04E00 and c <= 0x09FFF
    end

    function document.manipulate_one(boxnumber)

        local box  = getbox(boxnumber)
        local list = getlist(box)
        local all  = { }

        for n, c, f in nextglyph, list do
            if is_vertical(c) then
                all[n] = f
            end
        end

        for n, f in next, all do
            local o = .2 * xheights[f]
            local prev, next = getboth(n)
            setboth(n)
            local l = newhlist(n)
            local w, h, d = getwhd(n)
            setlink(prev,l,next)
            setwhd(l,h+d+o,w,0)
            setorientation(l,0x003,o/2,-o/2,0,h,d-o)
            if n == list then
                setlist(box,l)
            end
        end

    end

\stopluacode

\startluacode
    function document.manipulate_two(boxnumber)

        local box = tex.getbox(boxnumber)
        local n   = box.list

        local function is_vertical(c)
            return c >= 0x04E00 and c <= 0x09FFF
        end

        while n do
            if n.id == node.id("glyph") and is_vertical(n.char) then
                local o = .2 * fonts.hashes.identifiers[n.font].parameters.xheight
                local prev, next = n.prev, n.next
                n.next, n.prev = nil, nil
                local l = nodes.new("hlist")
                l.list = n
                local w, h, d = n.width, n.height, n.depth
                if prev then
                    prev.next, l.prev = l, prev
                else
                    box.list = l
                end
                if next then
                    l.next, next.prev = next, l
                end
                l.width, l.height, l.depth  = h + d + o, w, 0
                l.orientation = 0x003
--              l.xoffset, l.yoffset = o/2, -o/2
              l.hoffset, l.doffset = h, d - o
                n = next
            else
                n = n.next
            end
        end

    end

\stopluacode

% % % % % % % % % %

\unexpanded\def\stripe#1{\hbox orientation 0 yoffset 3pt{\strut #1}}

\setuptolerance[verytolerant,stretch]

\definefont[NotoCJK][file:simsun.ttc*default @ 24pt] \setupinterlinespace[40pt]

% % % % % % % % % %

\setbox1000\hbox{\NotoCJK\startscript[hangul]\dorecurse{20}{通用规范汉字表 \stripe{test #1} }\stopscript}
\ctxlua{document.manipulate_one(1000)}
\ruledvbox orientation 1 to \textwidth \bgroup
    \hsize \textheight
    \unhbox1000
    \vfill
\egroup
\page

\setbox1000\hbox{\NotoCJK\startscript[hangul]\dorecurse{20}{通用规范汉字表 \stripe{test #1} }\stopscript}
\ctxlua{document.manipulate_two(1000)}
\ruledvbox orientation 1 to \textwidth \bgroup
    \hsize \textheight
    \unhbox1000
    \vfill
\egroup
\page

\setupinterlinespace[40pt]

\definefontfeature
    [vertical]
    [vertical={%
        orientation=3,%
        down=.1,%
        right=.1,%
        ranges={%
            cjkcompatibility,%
            cjkcompatibilityforms,%
            cjkcompatibilityideographs,%
            cjkcompatibilityideographssupplement,%
            cjkradicalssupplement,%
          % cjkstrokes,%
            cjksymbolsandpunctuation,%
            cjkunifiedideographs,%
            cjkunifiedideographsextensiona,%
            cjkunifiedideographsextensionb,%
            cjkunifiedideographsextensionc,%
            cjkunifiedideographsextensiond,%
            cjkunifiedideographsextensione,%
            cjkunifiedideographsextensionf,%
        }%
    }]

\definefont[NotoCJKvertical][file:simsun.ttc*default,vertical @ 24pt]

\showglyphs

\unexpanded\def\stripe#1{\hbox orientation 0 yoffset 3pt{\strut #1}}

\setbox1000\hbox{\NotoCJKvertical\startscript[hangul]\dorecurse{20}{通用规范汉字表 \stripe{test #1} }\stopscript}

\ruledvbox orientation 1 to \textwidth \bgroup
    \hsize \textheight
    \unhbox1000
    \vfill
\egroup

% \stopscript

\stoptext

[-- Attachment #3: test-directions-005.lmtx --]
[-- Type: application/octet-stream, Size: 6926 bytes --]

\noheaderandfooterlines

% in font-imp-scripts, line 145, comment a few lines
%
%                 orientate = function(character)
%                     local width  = character.width or 0
%                     local height = character.height or 0
%                     local depth  = character.depth or 0
% --                     character.width       = height + depth + rightshift + rightshift
%                     character.height      = width - downshift
%                     character.depth       = shift
% --                     character.xoffset     = height + rightshift
% --                     character.yoffset     = - downshift
% --                     character.orientation = orientation
%                 end

\dontcomplain
\showglyphs

\setuplayout[middle]

\starttext

\startluacode
    local nuts          = nodes.nuts

    local nextglyph     = nuts.traversers.glyph
    local nextnode      = nuts.traversers.node

    local newhlist      = nuts.pool.hlist
    local newglue       = nuts.pool.glue
    local newpenalty    = nuts.pool.penalty

    local getprev       = nuts.getprev
    local setnext       = nuts.setnext
    local getnext       = nuts.getnext
    local setprev       = nuts.setprev
    local getboth       = nuts.getboth
    local setboth       = nuts.setboth
    local setlink       = nuts.setlink
    local getlist       = nuts.getlist
    local setlist       = nuts.setlist
    local setwhd        = nuts.setwhd
    local getwhd        = nuts.getwhd
    local getid         = nuts.getid
    local getchar       = nuts.getchar

    local getbox        = nuts.getbox

    local getdimensions = nuts.dimensions

    local setorientation  = nuts.setorientation
    local getorientation  = nuts.getorientation

    local glyph_code    = nodes.nodecodes.glyph
    local kern_code     = nodes.nodecodes.kern

    function document.manipulate_one(boxnumber)

        local box  = getbox(1000)
        local list = getlist(b)
        local all  = { }

        for n, c, f in nextglyph, list do
            if c > 200 then
                all[n] = true
            end
        end

        local o = 4 * 65536

        for n, how in next, all do
            local prev, next = getboth(n)
            setboth(n)
            local l = newhlist(n)
            local w, h, d = getwhd(n)
            setlink(prev,l,next)
            if how then
                setwhd(l,h+d+o,w,0)
                setorientation(l,0x003,0,0,h,d-o)
            end
            if n == list then
                setlist(box,l)
            end
        end

    end

    local function flushrange(head,current,first,last)
        local prev = getprev(first)
        local next = getnext(last)
        local list = newhlist(first)
        setprev(first)
        setnext(last)
        local w, h, d = getdimensions(first)
        setwhd(list,h+d,w,0)
        setlink(prev,list,next)
        setorientation(list,0x001,0,0,h,d)
        if first == head then
            return list, list
        else
            return head, list
        end
    end

    local function flushchar(head,current)
        local next = getnext(current)
        local glue = newglue(n,655360)
        setlink(current,glue,next)
        return head, glue
    end

    function document.manipulate_two(boxnumber)

        local box     = getbox(1000)
        local head    = getlist(box)
        local first   = false
        local last    = false
        local current = head
        while current do
            local id = getid(current)
            if id == glyph_code then
                if getchar(current) < 200 then
                    if first then
                        last = current
                    else
                        first = current
                        last  = current
                    end
                else
                    if first then
                        head, current = flushrange(head,current,first,last)
                        first = false
                    end
                    head, current = flushchar(head,current)
                end
            elseif id == kern_code then
                if first then
                    last = current
                end
            elseif first then
                head, current = flushrange(head,current,first,last)
                first = false
            end
            current = getnext(current)
        end
        if first then
            head, current = flushrange(head,current,first,last)
        end
        setlist(box,head)
    end

\stopluacode

% % % % % % % % % %

\setuptolerance[verytolerant,stretch]

\definefont[NotoCJK][file:simsun.ttc*default @ 24pt] \setupinterlinespace[40pt]

\unexpanded\def\stripe#1{\hbox orientation 0 yoffset 3pt{\strut #1}}

\setbox1000\hbox{\NotoCJK\startscript[hanzi]\dorecurse{20}{通用规范汉字表 \stripe{test #1} }\stopscript}

\ctxlua{document.manipulate_one(1000)}

\ruledvbox orientation 1 to \textwidth \bgroup
    \hsize \textheight
    \unhbox1000
    \vfill
\egroup

\page

\setbox1000\hbox{\NotoCJK\startscript[hanzi]\dorecurse{20}{通用规\ruby{范}{x}汉字表 \stripe{test #1} }\stopscript}

\ctxlua{document.manipulate_one(1000)}

\ruledvbox orientation 1 to \textwidth \bgroup
    \hsize \textheight
    \unhbox1000
    \vfill
\egroup

\page

\setupinterlinespace[40pt]

\definefontfeature
    [vertical]
    [vertical={%
        orientation=3,%
        down=0.1,%
        right=.1,%
        ranges={%
            cjkcompatibility,%
            cjkcompatibilityforms,%
            cjkcompatibilityideographs,%
            cjkcompatibilityideographssupplement,%
            cjkradicalssupplement,%
          % cjkstrokes,%
            cjksymbolsandpunctuation,%
            cjkunifiedideographs,%
            cjkunifiedideographsextensiona,%
            cjkunifiedideographsextensionb,%
            cjkunifiedideographsextensionc,%
            cjkunifiedideographsextensiond,%
            cjkunifiedideographsextensione,%
            cjkunifiedideographsextensionf,%
        }%
    }]

\definefont[NotoCJKvertical][file:simsun.ttc*default,vertical @ 24pt]

\showglyphs

\unexpanded\def\stripe#1{\hbox orientation 0 yoffset 3pt{\strut #1}}

\setbox1000\hbox{\NotoCJKvertical\startscript[hanzi]\dorecurse{20}{通用规范汉字表 \stripe{test #1} }\stopscript}

\ruledvbox orientation 1 to \textwidth \bgroup
    \hsize \textheight
    \unhbox1000
    \vfill
\egroup

\page

\setbox1000\hbox{\NotoCJKvertical\startscript[hanzi]\dorecurse{20}{通用规\ruby{范}{x}汉字表 \stripe{test #1} }\stopscript}

\ruledvbox orientation 1 to \textwidth \bgroup
    \hsize \textheight
    \unhbox1000
    \vfill
\egroup

% \stopscript

\stoptext

[-- Attachment #4: test-directions-008.lmtx --]
[-- Type: application/octet-stream, Size: 3363 bytes --]

% in font-imp-scripts, line 145, comment a few lines
%
%                 orientate = function(character)
%                     local width  = character.width or 0
%                     local height = character.height or 0
%                     local depth  = character.depth or 0
% --                     character.width       = height + depth + rightshift + rightshift
%                     character.height      = width - downshift
%                     character.depth       = shift
% --                     character.xoffset     = height + rightshift
% --                     character.yoffset     = - downshift
% --                     character.orientation = orientation
%                 end

\definefontfeature
    [vertical]
    [vertical={%
        orientation=3,%
        down=.1,%
        right=.1,%
        ranges={%
            cjkcompatibility,%
            cjkcompatibilityforms,%
            cjkcompatibilityideographs,%
            cjkcompatibilityideographssupplement,%
            cjkradicalssupplement,%
          % cjkstrokes,%
            cjksymbolsandpunctuation,%
            cjkunifiedideographs,%
            cjkunifiedideographsextensiona,%
            cjkunifiedideographsextensionb,%
            cjkunifiedideographsextensionc,%
            cjkunifiedideographsextensiond,%
            cjkunifiedideographsextensione,%
            cjkunifiedideographsextensionf,%
        }%
    }]

% \definefont[NotoCJKvertical]    [file:simsun.ttc*default,vertical @ 24pt]
% \definefont[NotoCJKverticalBold][file:simhei.ttf*default,vertical @ 48pt]

% \definefallbackfamily [documentfont] [rm] [Noto Serif CJK SC]     [preset=range:chinese,features={default,vertical}]
% \definefallbackfamily [documentfont] [ss] [Noto Sans CJK SC]      [preset=range:chinese,features={default,vertical}]
% \definefallbackfamily [documentfont] [tt] [Noto Sans Mono CJK SC] [preset=range:chinese,features={default,vertical}]

% \definefontfamily [documentfont] [rm] [Noto Serif]
% \definefontfamily [documentfont] [ss] [Noto Sans]
% \definefontfamily [documentfont] [tt] [Noto Sans Mono]

% \setupbodyfont [NotoCJKvertical,24pt]

\definefont[NotoCJKvertical]    [file:simsun.ttc*default,vertical @ 24pt]
% \usetypescriptfile[mscore]
\setupbodyfont [NotoCJKvertical,20pt]
% \usebodyfont   [NotoCJKvertical,20pt]

\setuppapersize
 [A4,landscape,rotated,270]
 [A4,portrait]

\setuplayout[middle]

\showframe

\setuphead
  [chapter]
  [numbercolor=darkred,
   conversion=chinesenumerals]

\setuptolerance
  [verytolerant,stretch]

\setupinterlinespace
  [40pt]

\setuplayout
  [color=darkblue]

\setuppagenumbering
  [location=footer]

\defineconversionset
  [pagenumber]
  []
  [chinesenumerals]

\protected\def\stripe#1{\hbox orientation 0 yoffset 3pt{\strut #1}}

\setscript[hanzi]

\showglyphs

\starttext

\NotoCJKvertical

% \startscript[hangul]

    \chapter{通用规}

    \placefigure
      [left,none]
      {汉字表}
      {\framed
         [width=4cm,
          height=2\lineheight,
          frame=off,
          backgroundcolor=darkgreen,
          foregroundcolor=white,
          background=color]
         {汉字表}}

    \dorecurse{40}{%
        通用规\ruby{范}{x}汉字表 \stripe{test #1}
    }

% \stopscript

\stoptext

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

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

maillist : ntg-context@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
___________________________________________________________________________________

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

* Re: Is rendering furigana over horizontal or vertical japanese text doable in ConTeXt?
  2022-08-22  5:21               ` 黄复雄 via ntg-context
@ 2022-08-22  7:16                 ` Hans Hagen via ntg-context
  2022-09-03 10:44                   ` 黄复雄 via ntg-context
  0 siblings, 1 reply; 15+ messages in thread
From: Hans Hagen via ntg-context @ 2022-08-22  7:16 UTC (permalink / raw)
  To: 黄复雄 via ntg-context; +Cc: Hans Hagen

On 8/22/2022 7:21 AM, 黄复雄 via ntg-context wrote:
> Dear Hans.
> Thank you very much for so many examples and guidance.
> 
> In fact, I have read one of the examples in the followingup.pdf,
> and the https://github.com/Fusyong/vertical-typesetting module I made
> is based on the example.
> 
> The examples all worked after I changed the font settings according to
> my Win10 OS;
> and surprisingly, the ruby module also worked with \setscript[hanzi]
>   (they don't work together in the example Mr. Wolfgang provided).

I noticed an issu ewith multiple glyphs but am not sure why ... (so we 
need very small examples to figure it out).

> The only problem is that the offsets of glyphs are a bit inaccurate,
> which may be related to the font,
> and I will look into it further.

in the vertical feature one can tune a bit.

> The examples I have adjusted are attached,
> and the output PDF of them is not attached for being too big to the
> limit of 100 KB.
> (Just now I received a reply from the mailing list system asking to
> adjust a over-length email,
> I mistakenly thought it was about the one to Mr. Wolfgang, so that one
> was duplicated and submitted,
> please deal with it.)

there are indeed limits

> By the way, I've finished checking and adjusting type-imp-mscore.mkiv,
> scrp-cjk.lua, and char-scr.lua so far,
> but the changes are a bit much (or maybe you can say a bit reckless),
> so I'm hesitant to get back to you in order to minimize your troubles.
> And as mentioned partly in an earlier email, I've made 3 modules that
> support Chinese
> (about vertical-typesetting,  Jiazhu or inline cutting note and punctuation)
> and I'd be happy to contribute them to the ConTeXt project repository
> when they're ripe,
> if that's in line with the project policy. Your comments and guidance
> are very welcome.

hm, i can have a look at it but we shouldn't break japanese and korean

once you finished all we can see how it can either be integrated or 
become some third party module (has to do with maintainance)

can you also make a noto typescript for the different chinese setups 
(for some reason the CJK noto's failed so i used the non CJK ones as i 
couldn't locate the right files; one cannot longher download al-of-noto 
in one zip )

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@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
___________________________________________________________________________________

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

* Re: Is rendering furigana over horizontal or vertical japanese text doable in ConTeXt?
  2022-08-22  7:16                 ` Hans Hagen via ntg-context
@ 2022-09-03 10:44                   ` 黄复雄 via ntg-context
  0 siblings, 0 replies; 15+ messages in thread
From: 黄复雄 via ntg-context @ 2022-09-03 10:44 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: 黄复雄

> I noticed an issue with multiple glyphs but am not sure why ... (so we
> need very small examples to figure it out).

I have observed a phenomenon that
when the base text contains glues/spaces, an error occurs,
as in the following example. Coincidentally, when using \setscript[hanzi],
the macro will inject glue between Chinese, and I will get the same error.

%%%begin example
\starttext
\ruby{a a}{b}
\stoptext
%%%end example

Best Regards,
                                      黄复雄(Huang Fuysong)
 ___________________________________________________________________________________
 If your question is of interest to others as well, please add an
entry to the Wiki!

 maillist : ntg-context@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@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
___________________________________________________________________________________

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

end of thread, other threads:[~2022-09-03 10:44 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-15 11:02 Is rendering furigana over horizontal or vertical japanese text doable in ConTeXt? amano.kenji via ntg-context
2022-08-15 11:43 ` Taco Hoekwater via ntg-context
2022-08-15 12:00   ` amano.kenji via ntg-context
2022-08-15 15:39     ` Wolfgang Schuster via ntg-context
2022-08-16 11:33       ` amano.kenji via ntg-context
2022-08-16 15:05         ` Wolfgang Schuster via ntg-context
2022-08-21  8:24         ` 黄复雄 via ntg-context
2022-08-21 10:00           ` Hans Hagen via ntg-context
2022-08-21 10:10           ` Wolfgang Schuster via ntg-context
2022-08-21 16:19             ` Hans Hagen via ntg-context
2022-08-22  5:21               ` 黄复雄 via ntg-context
2022-08-22  7:16                 ` Hans Hagen via ntg-context
2022-09-03 10:44                   ` 黄复雄 via ntg-context
2022-08-22  2:09             ` 黄复雄 via ntg-context
2022-08-22  4:52             ` 黄复雄 via ntg-context

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).