texlive[51803] Master/texmf-dist: luatexko (1aug19)

commits+karl at tug.org commits+karl at tug.org
Fri Aug 2 23:18:39 CEST 2019


Revision: 51803
          http://tug.org/svn/texlive?view=revision&revision=51803
Author:   karl
Date:     2019-08-02 23:18:39 +0200 (Fri, 02 Aug 2019)
Log Message:
-----------
luatexko (1aug19)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/luatex/luatexko/ChangeLog
    trunk/Master/texmf-dist/doc/luatex/luatexko/README
    trunk/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.pdf
    trunk/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.tex
    trunk/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua
    trunk/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua
    trunk/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua
    trunk/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty

Modified: trunk/Master/texmf-dist/doc/luatex/luatexko/ChangeLog
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/luatexko/ChangeLog	2019-08-01 23:58:09 UTC (rev 51802)
+++ trunk/Master/texmf-dist/doc/luatex/luatexko/ChangeLog	2019-08-02 21:18:39 UTC (rev 51803)
@@ -1,3 +1,10 @@
+2019-08-01      Dohyun Kim <nomos at ktug org>
+
+	Version 2.4
+
+	* luatexko.lua: allow linebreak before/after a normal hbox
+	* luatexko.{sty,lua}: moveleft horizontal box inside vertical writing
+
 2019-06-21      Dohyun Kim <nomos at ktug org>
 
 	Version 2.3

Modified: trunk/Master/texmf-dist/doc/luatex/luatexko/README
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/luatexko/README	2019-08-01 23:58:09 UTC (rev 51802)
+++ trunk/Master/texmf-dist/doc/luatex/luatexko/README	2019-08-02 21:18:39 UTC (rev 51803)
@@ -1,4 +1,4 @@
-LuaTeX-ko Package version 2.3 (2019/06/21)
+LuaTeX-ko Package version 2.4 (2019/08/01)
 ===========================================
 
 This is a Lua(La)TeX macro package that supports typesetting Korean

Modified: trunk/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.tex	2019-08-01 23:58:09 UTC (rev 51802)
+++ trunk/Master/texmf-dist/doc/luatex/luatexko/luatexko-doc.tex	2019-08-02 21:18:39 UTC (rev 51803)
@@ -12,6 +12,25 @@
 \usepackage[hmargin=3.8cm]{geometry}
 \usepackage[svgnames]{xcolor}
 \usepackage[hangul]{luatexko}
+\directlua{
+  fonts.protrusions.setups.notoserifcjk = {
+    [171]     = { 0.5, 0   },
+    [187]     = { 0,   0.5 },
+    [1002965] = { 0,   0.5 },
+    [1002968] = { 0.5, 0   },
+    [1002969] = { 0,   0.5 },
+    [1002970] = { 0,   1   },
+    [1002971] = { 0,   0.5 },
+    [1002972] = { 0,   1   },
+    [1002974] = { 0,   0.5 },
+    [1002975] = { 0,   0.5 },
+    [1002976] = { 0,   0.5 },
+    [1002985] = { 1,   0   },
+    [1002986] = { 0,   1   },
+    [1002988] = { 0.5, 0   },
+    [1002989] = { 0,   0.5 },
+  }
+}
 \setmainhangulfont{Noto Serif CJK KR}[
   Scale=0.98,
   AutoFakeSlant,
@@ -21,7 +40,7 @@
   UprightFont=* Light,
   BoldFont=* Bold,
   InterLatinCJK=.125em,
-  Expansion, Protrusion,
+  Expansion, Protrusion=notoserifcjk,
 ]
 \setsanshangulfont{Noto Sans CJK KR}[
   Scale=0.98,
@@ -77,7 +96,7 @@
 \author{Dohyun Kim \normalsize |<nomos at ktug org>| \and
         Soojin Nam \normalsize |<jsunam at gmail com>| \and
   \normalsize <\url{http://github.com/dohyunkim/luatexko}>}
-\date{Version 2.3\quad 2019/06/21}
+\date{Version 2.4\quad 2019/08/01}
 \maketitle
 
 \begin{quote}\small
@@ -334,10 +353,7 @@
 
 \section{고문헌}\label{sec:classic}
 
-\begin{figure}
-  \centering
-  \fbox{\parbox{37em}{\typesetclassic\sffamily
-  \addhangulfontfeature{CompressPunctuations}
+\def\analectstext{%
 子曰:「學而時習之,不亦說乎?有朋自遠方來,不亦樂乎?人不知而不慍,
 不亦君子乎?」\par
 有子曰:「其爲人也孝弟,而好犯上者,鮮矣!不好犯上,而好作亂者,未之有也!
@@ -347,6 +363,12 @@
 不習乎?」\par
 子曰:「道千乘之國,敬事而信,節用而愛人,使民以時。」\par
 子曰:「弟子入則孝,出則弟;謹而信,汎愛衆;而親仁,行有餘力,則以學文。」
+}
+\begin{figure}
+  \centering
+  \fbox{\parbox{37em}{\typesetclassic\sffamily
+  \addhangulfontfeature{CompressPunctuations}
+  \analectstext
   }}
 \caption{고문헌 조판 보기. typesetclassic 환경을 이용했다.}\label{fig:gomun}
 \end{figure}
@@ -391,7 +413,7 @@
 기본으로 셋팅되어 있다. 일종의 고문헌 조판으로 보는 것이다.
 
 \begin{figure}
-\framebox[\linewidth]{\begin{vertical}{20em}\sffamily
+\framebox[\linewidth]{\begin{vertical}{19.6em}\sffamily
   \addhangulfontfeature{Vertical=Alternates, RawFeature=vertical}
   \linespread{1.5}\selectfont
   \hunmintxt
@@ -399,14 +421,39 @@
 \caption{세로쓰기의 예. 박스 높이 |20em|을 지시했다.}\label{fig:vertical}
 \end{figure}
 
+\begin{figure}
+\framebox[\linewidth]{\begin{vertical}{18.62em}\sffamily
+  \addhangulfontfeature{Vertical=Alternates, RemoveClassicSpaces,
+  InterCharStretch=1pt, CompressPunctuations, RawFeature=vertical}
+  \linespread{1.5}\selectfont
+  \analectstext
+\end{vertical}}
+\caption{세로쓰기의 다른 예. 박스 높이 |19em|을 지시했다.
+  글꼴옵션으로 |RemoveClassicSpaces|, |CompressPunctuations|와 더불어
+  |InterCharStretch=1pt|를 추가했다. 공백이 없는 문서는 자간늘이기 값을
+  넉넉하게 주는 것이 좋다.}\label{fig:vertical3}
+\end{figure}
+
 문서의 일부를 세로쓰기하려면 \cs{begin{vertical}{<dimen>}} \ldots\ \cs{end{vertical}}
 환경을 이용한다. |<dimen>|으로 세로쓰기 박스의 높이를 지시한다.%
 \footnote{%
   플레인텍에서는 \cs{vertical{<dimen>}} \ldots\ \cs{endvertical}. }
-그림~\ref{fig:vertical} 및 그림~\ref{fig:vertical2} 참조.
+그림~\ref{fig:vertical},~\ref{fig:vertical3} 및 \ref{fig:vertical2} 참조.
 
+문서 전체를 세로쓰기한다면 이 환경을 쓰는 대신
+\cs{verticaltypesetting} 명령을 전처리부에 선언한다.
+이때 면주는 가로로 식자되며 면주 폰트의 설정은 사용자의 몫이다.
+
+세로쓰기 도중에 문서의 일부를 가로쓰기하려면
+\cs{begin{horizontal}{<dimen>}} \ldots\ \cs{end{horizontal}}
+환경을 이용한다. |<dimen>|은 가로쓰기 박스의 너비를 지시한다.%
+\footnote{%
+  플레인텍에서는 \cs{horizontal{<dimen>}} \ldots\ \cs{endhorizontal}. }
+가로쓰기 영역의 폰트 설정은 사용자의 몫이다.%
+\footnote{폰트 지시는 |horizontal| 환경 안에서 행하는 것을 권장한다.}
+
 \begin{figure}
-\framebox[\linewidth]{\begin{vertical}{17em}\sffamily
+\framebox[\linewidth]{\begin{vertical}{16.66em}\sffamily
   \addhangulfontfeature{Vertical=Alternates, CharRaise=3.2pt,
   CompressPunctuations, CharacterWidth=Full, RawFeature=vertical}
   \parindent-1em\leftskip1em \linespread{1.5}\selectfont
@@ -431,17 +478,6 @@
   반각 크기로 강제했다.}\label{fig:vertical2}
 \end{figure}
 
-문서 전체를 세로쓰기한다면 이 환경을 쓰는 대신
-\cs{verticaltypesetting} 명령을 전처리부에 선언한다.
-이때 면주는 가로로 식자되며 면주 폰트의 설정은 사용자의 몫이다.
-
-세로쓰기 도중에 문서의 일부를 가로쓰기하려면
-\cs{begin{horizontal}{<dimen>}} \ldots\ \cs{end{horizontal}}
-환경을 이용한다. |<dimen>|은 가로쓰기 박스의 너비를 지시한다.%
-\footnote{%
-  플레인텍에서는 \cs{horizontal{<dimen>}} \ldots\ \cs{endhorizontal}. }
-가로쓰기 영역의 폰트 설정은 사용자의 몫이다.
-
 \section{드러냄표}\label{sec:dotemph}
 
 \cs{dotemph} 명령으로 \dotemph{드러냄표}%

Modified: trunk/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua	2019-08-01 23:58:09 UTC (rev 51802)
+++ trunk/Master/texmf-dist/tex/luatex/luatexko/luatexko-normalize.lua	2019-08-02 21:18:39 UTC (rev 51803)
@@ -13,8 +13,8 @@
 
 luatexbase.provides_module({
   name        = "luatexko-normalize",
-  version     = "2.3",
-  date        = "2019/06/21",
+  version     = "2.4",
+  date        = "2019/08/01",
   author      = "Dohyun Kim, Soojin Nam",
   description = "Hangul normalization",
   license     = "LPPL v1.3+",

Modified: trunk/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua	2019-08-01 23:58:09 UTC (rev 51802)
+++ trunk/Master/texmf-dist/tex/luatex/luatexko/luatexko-uhc2utf8.lua	2019-08-02 21:18:39 UTC (rev 51803)
@@ -13,8 +13,8 @@
 
 luatexbase.provides_module({
   name        = "luatexko-uhc2utf8",
-  version     = "2.3",
-  date        = "2019/06/21",
+  version     = "2.4",
+  date        = "2019/08/01",
   author      = "Dohyun Kim, Soojin Nam",
   description = "UHC (CP949) input encoding",
   license     = "LPPL v1.3+",

Modified: trunk/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua	2019-08-01 23:58:09 UTC (rev 51802)
+++ trunk/Master/texmf-dist/tex/luatex/luatexko/luatexko.lua	2019-08-02 21:18:39 UTC (rev 51803)
@@ -13,8 +13,8 @@
 
 luatexbase.provides_module {
   name        = 'luatexko',
-  date        = '2019/06/21',
-  version     = '2.3',
+  date        = '2019/08/01',
+  version     = '2.4',
   description = 'typesetting Korean with LuaTeX',
   author      = 'Dohyun Kim, Soojin Nam',
   license     = 'LPPL v1.3+',
@@ -52,12 +52,13 @@
 local fontgetfont   = font.getfont
 local getparameters = font.getparameters
 
-local texcount  = tex.count
-local texround  = tex.round
-local texset    = tex.set
-local texsp     = tex.sp
-local texsprint = tex.sprint
+local texattribute = tex.attribute
+local texcount     = tex.count
+local texset       = tex.set
+local texsp        = tex.sp
 
+local set_macro = token.set_macro
+
 local stringformat = string.format
 
 local tableconcat = table.concat
@@ -142,6 +143,10 @@
   [0x302E] = true, [0x302F] = true,
 }
 
+local function is_compat_jamo (c)
+  return c >= 0x3131 and c <= 0x318E
+end
+
 local function is_unicode_var_sel (c)
   return c >= 0xFE00  and c <= 0xFE0F
   or     c >= 0xE0100 and c <= 0xE01EF
@@ -180,10 +185,10 @@
 
 local function is_hangul_jamo (c)
   return is_hangul(c)
+  or     is_compat_jamo(c)
   or     is_chosong(c)
   or     is_jungsong(c)
   or     is_jongsong(c)
-  or     c >= 0x3131 and c <= 0x318E
 end
 
 local stretch_f = 5/100 -- should be consistent for ruby
@@ -306,7 +311,7 @@
           newsp = nodes.simple_font_handler(newsp)
           newwd = newsp and newsp.width or false
           if newwd then
-            newwd = { texround(newwd), texround(newwd/2), texround(newwd/3) }
+            newwd = { texsp(newwd), texsp(newwd/2), texsp(newwd/3) }
           end
           char_font_options.hangulspaceskip[newfont] = newwd
           if newsp then
@@ -337,13 +342,22 @@
             hangul_space_skip(curr, p.font)
             curr.font = p.font
           end
+
+          if not active_processes.reorderTM and
+             hangul_tonemark[c] and
+             option_in_font(curr.font, "script") == "hang" then
+            luatexko.activate("reorderTM") -- activate reorderTM here
+            active_processes.reorderTM = true
+          end
+
         else
           local hf  = has_attribute(curr, hangulfontattr) or false
           local hjf = has_attribute(curr, hanjafontattr)  or false
-          local fontdata  = get_font_data(curr.font)
-          local format    = fontdata.format
-          local no_legacy = format == "opentype" or format == "truetype"
-          if hf and no_legacy and force_hangul[c] and curr.lang ~= nohyphen then
+          local fontdata = get_font_data(curr.font)
+          local format   = fontdata.format
+          local encode   = fontdata.encodingbytes
+          local widefont = encode == 2 or format == "opentype" or format == "truetype"
+          if hf and widefont and force_hangul[c] and curr.lang ~= nohyphen then
             curr.font = hf
           elseif hf and luatexko.hangulbyhangulfont and is_hangul_jamo(c) then
             hangul_space_skip(curr, hf)
@@ -363,13 +377,6 @@
           end
         end
 
-        if not active_processes.reorderTM
-          and hangul_tonemark[c]
-          and option_in_font(curr.font, "script") == "hang" then
-          luatexko.activate("reorderTM") -- activate reorderTM here
-          active_processes.reorderTM = true
-        end
-
         props.unicode = c
       end
     elseif id == discid then
@@ -469,11 +476,11 @@
   [0xFF1E] = true, [0xFF5E] = true, [0xFF70] = true,
 },{ __index = function (_,c)
   return is_hangul_jamo(c) and not is_chosong(c)
-  or is_noncjk_char(c)
-  or is_hanja(c)
-  or is_cjk_combining(c)
-  or is_kana(c)
-  or charclass[c] >= 2
+  or     is_noncjk_char(c)
+  or     is_hanja(c)
+  or     is_cjk_combining(c)
+  or     is_kana(c)
+  or     charclass[c] >= 2
 end })
 luatexko.breakableafter = breakable_after
 
@@ -498,10 +505,12 @@
   [0xFF6F] = 1000,  [0x1B150] = 1000, [0x1B151] = 1000, [0x1B152] = 1000,
   [0x1B164] = 1000, [0x1B165] = 1000, [0x1B166] = 1000, [0x1B167] = 1000,
 },{ __index = function(_,c)
-  return is_hangul_jamo(c) and not is_jungsong(c) and not is_jongsong(c)
-  or is_hanja(c)
-  or is_kana(c)
-  or charclass[c] == 1
+  return is_hangul(c)
+  or     is_compat_jamo(c)
+  or     is_chosong(c)
+  or     is_hanja(c)
+  or     is_kana(c)
+  or     charclass[c] == 1
 end
 })
 luatexko.breakablebefore = breakable_before
@@ -521,16 +530,52 @@
 end
 
 local function ruby_char_font (rb)
-  local n, c, f = has_glyph(rb.list), 0, 0
+  local n = has_glyph(rb.list)
   if n then
-    c, f = my_node_props(n).unicode or n.char, n.font or 0
+    local c, f = my_node_props(n).unicode or n.char, n.font
     if is_chosong(c) or hangul_tonemark[c] then
       c = 0xAC00
     end
+    return c, f
   end
-  return c, f
 end
 
+local function hbox_ini_char_font (box)
+  local curr = box.list
+  while curr do
+    local id = curr.id
+    if id == glyphid then
+      local c = my_node_props(curr).unicode or curr.char
+      if c and not is_cjk_combining(c) then
+        return c, curr.font
+      end
+    elseif id == hlistid and curr.list then
+      return hbox_ini_char_font(curr)
+    elseif is_blocking_node(curr) then
+      return
+    end
+    curr = getnext(curr)
+  end
+end
+
+local function hbox_fin_char_font (box)
+  local curr = nodeslide(box.list)
+  while curr do
+    local id = curr.id
+    if id == glyphid then
+      local c = my_node_props(curr).unicode or curr.char
+      if c and not is_cjk_combining(c) then
+        return c, curr.font
+      end
+    elseif id == hlistid and curr.list then
+      return hbox_fin_char_font(curr)
+    elseif is_blocking_node(curr) then
+      return
+    end
+    curr = getprev(curr)
+  end
+end
+
 local function get_actualtext (curr)
   local actual = my_node_props(curr).startactualtext
   if type(actual) == "table" then
@@ -626,20 +671,35 @@
   while curr do
     local id = curr.id
     if id == glyphid then
-      local cc = my_node_props(curr).unicode or curr.char
-      local old = has_attribute(curr, classicattr)
-      head, pc, pcl = maybe_linebreak(head, curr, pc, pcl, cc, old, curr.font, par)
+      local c = my_node_props(curr).unicode or curr.char
+      if c and not is_unicode_var_sel(c) then
+        local old = has_attribute(curr, classicattr)
+        head, pc, pcl = maybe_linebreak(head, curr, pc, pcl, c, old, curr.font, par)
+      end
 
-    elseif id == hlistid and has_attribute(curr, rubyattr) then
-      local cc, fi = ruby_char_font(curr) -- rubybase
+    elseif id == hlistid and curr.list then
       local old = has_attribute(curr, classicattr)
-      head, pc, pcl = maybe_linebreak(head, curr, pc, pcl, cc, old, fi, par)
+      if has_attribute(curr, rubyattr) then
+        local c, f = ruby_char_font(curr) -- rubybase
+        if c and f then
+          head, pc, pcl = maybe_linebreak(head, curr, pc, pcl, c, old, f, par)
+        else
+          pc, pcl = false, 0
+        end
+      else
+        local c, f = hbox_ini_char_font(curr)
+        if c and f then
+          head = maybe_linebreak(head, curr, pc, pcl, c, old, f, par)
+        end
+        pc = hbox_fin_char_font(curr)
+        pcl = pc and get_char_class(pc, old) or 0
+      end
 
     elseif id == whatsitid and curr.mode == directmode then
-      local glyf, cc, fin = get_actualtext(curr)
-      if cc and fin and glyf then
+      local glyf, c, fin = get_actualtext(curr)
+      if c and fin and glyf then
         local old = has_attribute(glyf, classicattr)
-        head = maybe_linebreak(head, curr, pc, pcl, cc, old, glyf.font, par)
+        head = maybe_linebreak(head, curr, pc, pcl, c, old, glyf.font, par)
         pc, pcl, curr = fin, 0, goto_end_actualtext(curr)
       end
 
@@ -712,34 +772,8 @@
   or     rawget(breakable_after,  c) and c >= 0x2000
 end
 
-local function is_cjk (n, c) -- node, char
-  if n and c then
-    if is_unicode_var_sel(c) then
-      local p = getprev(n)
-      if p and p.id == glyphid then
-        local pc = my_node_props(p).unicode or p.char or 0
-        return is_cjk_char(pc)
-      end
-    end
-    return is_cjk_char(c)
-  end
-end
-
-local function is_noncjk (n, c) -- node, char
-  if n and c then
-    if is_unicode_var_sel(c) then
-      local p = getprev(n)
-      if p and p.id == glyphid then
-        local pc = my_node_props(p).unicode or p.char or 0
-        return is_noncjk_char(pc)
-      end
-    end
-    return is_noncjk_char(c)
-  end
-end
-
 local function do_interhangul_option (head, curr, pc, c, fontid, par)
-  local cc = (is_hangul(c) or is_chosong(c)) and 1 or 0
+  local cc = (is_hangul(c) or is_compat_jamo(c) or is_chosong(c)) and 1 or 0
 
   if cc*pc == 1 and curr.lang ~= nohyphen then
     local dim = get_font_opt_dimen(fontid, "interhangul")
@@ -757,17 +791,32 @@
     local id = curr.id
     if id == glyphid then
       local c = my_node_props(curr).unicode or curr.char
-      head, pc = do_interhangul_option(head, curr, pc, c, curr.font, par)
+      if c and not is_unicode_var_sel(c) then
+        head, pc = do_interhangul_option(head, curr, pc, c, curr.font, par)
 
-      if is_chosong(c) then
-        pc = 0
-      elseif is_jungsong(c) or is_jongsong(c) or hangul_tonemark[c] then
-        pc = 1
+        if is_chosong(c) then
+          pc = 0
+        elseif is_jungsong(c) or is_jongsong(c) or hangul_tonemark[c] then
+          pc = 1
+        end
       end
 
-    elseif id == hlistid and has_attribute(curr, rubyattr) then
-      local c, fi = ruby_char_font(curr)
-      head, pc = do_interhangul_option(head, curr, pc, c, fi, par)
+    elseif id == hlistid and curr.list then
+      if has_attribute(curr, rubyattr) then
+        local c, f = ruby_char_font(curr)
+        if c and f then
+          head, pc = do_interhangul_option(head, curr, pc, c, f, par)
+        else
+          pc = 0
+        end
+      else
+        local c, f = hbox_ini_char_font(curr)
+        if c and f then
+          head = do_interhangul_option(head, curr, pc, c, f, par)
+        end
+        c = hbox_fin_char_font(curr)
+        pc = c and is_hangul_jamo(c) and 1 or 0
+      end
 
     elseif id == whatsitid and curr.mode == directmode then
       local glyf, c = get_actualtext(curr)
@@ -787,7 +836,7 @@
 end
 
 local function do_interlatincjk_option (head, curr, pc, pf, pcl, c, cf, par)
-  local cc = is_cjk(curr, c) and 1 or is_noncjk(curr, c) and 2 or 0
+  local cc = is_cjk_char(c) and 1 or is_noncjk_char(c) and 2 or 0
   local old = has_attribute(curr, classicattr)
   local ccl = get_char_class(c, old)
 
@@ -794,14 +843,14 @@
   if cc*pc == 2 and curr.lang ~= nohyphen then
     local brb = cc == 2 or breakable_before[c] -- numletter != br_before
     if brb then
-      local fid = cc == 1 and cf or pf
-      local dim = get_font_opt_dimen(fid, "interlatincjk")
+      local f = cc == 1 and cf or pf
+      local dim = get_font_opt_dimen(f, "interlatincjk")
       if dim then
         local ict = old and intercharclass[pcl][ccl] -- under classic env. only
         if ict then
-          dim = get_font_opt_dimen(fid, "intercharacter") or 0
+          dim = get_font_opt_dimen(f, "intercharacter") or 0
         end
-        head = insert_glue_before(head, curr, par, true, brb, old, ict, dim, fid)
+        head = insert_glue_before(head, curr, par, true, brb, old, ict, dim, f)
       end
     end
   end
@@ -815,12 +864,33 @@
     local id = curr.id
     if id == glyphid then
       local c = my_node_props(curr).unicode or curr.char
-      head, pc, pf, pcl = do_interlatincjk_option(head, curr, pc, pf, pcl, c, curr.font, par)
-      pc = breakable_after[c] and pc or 0
+      if c and not is_unicode_var_sel(c) then
+        head, pc, pf, pcl = do_interlatincjk_option(head, curr, pc, pf, pcl, c, curr.font, par)
+        pc = breakable_after[c] and pc or 0
+      end
 
-    elseif id == hlistid and has_attribute(curr, rubyattr) then
-      local c, cf = ruby_char_font(curr)
-      head, pc, pf, pcl = do_interlatincjk_option(head, curr, pc, pf, pcl, c, cf, par)
+    elseif id == hlistid and curr.list then
+      if has_attribute(curr, rubyattr) then
+        local c, f = ruby_char_font(curr)
+        if c and f then
+          head, pc, pf, pcl = do_interlatincjk_option(head, curr, pc, pf, pcl, c, f, par)
+        else
+          pc, pf, pcl = 0, 0, 0
+        end
+      else
+        local c, f = hbox_ini_char_font(curr)
+        if c and f then
+          head = do_interlatincjk_option(head, curr, pc, pf, pcl, c, f, par)
+        end
+        c, f = hbox_fin_char_font(curr)
+        if c and breakable_after[c] then
+          pc = is_cjk_char(c) and 1 or is_noncjk_char(c) and 2 or 0
+        else
+          pc = 0
+        end
+        pcl = c and get_char_class(c, has_attribute(curr, classicattr)) or 0
+        pf  = f or 0
+      end
 
     elseif id == whatsitid and curr.mode == directmode then
       local glyf, c = get_actualtext(curr)
@@ -833,16 +903,17 @@
       if pc == 1 then
         head = do_interlatincjk_option(head, curr, pc, pf, pcl, 0x30, pf, par)
       end
-      pc, pcl, curr = 2, 0, end_of_math(curr)
+      pc, pf, pcl = 2, 0, 0
+      curr = end_of_math(curr)
 
     elseif id == dirid then
       if pc == 1 and curr.dir:sub(1,1) == "+" then
         head = do_interlatincjk_option(head, curr, pc, pf, pcl, 0x30, pf, par)
-        pc, pcl = 0, 0
+        pc, pf, pcl = 0, 0, 0
       end
 
     elseif is_blocking_node(curr) then
-      pc, pcl = 0
+      pc, pf, pcl = 0, 0, 0
     end
     curr = getnext(curr)
   end
@@ -861,18 +932,28 @@
         for k, v in pairs{ p = getprev(curr), n = getnext(curr) } do
           local ok
           while v do
-            local vid = v.id
-            if vid ~= whatsitid -- skip whatsit or kern except userkern
-              and ( vid ~= kernid or v.subtype == userkern ) then
+            local id = v.id
+            if id ~= whatsitid -- skip whatsit or kern except userkern
+              and ( id ~= kernid or v.subtype == userkern ) then
 
               local vchar, vfont
-              if vid == glyphid and v.lang ~= nohyphen then
-                vchar, vfont = v.char, v.font
-              elseif vid == hlistid and has_attribute(v, rubyattr) then
-                vchar, vfont = ruby_char_font(v)
+              if id == glyphid and v.lang ~= nohyphen then
+                local c = my_node_props(v).unicode or v.char or 0
+                if is_unicode_var_sel(c) then
+                  v = getprev(v) or v
+                end
+                vchar, vfont = my_node_props(v).unicode or v.char, v.font
+              elseif id == hlistid and v.list then
+                if has_attribute(v, rubyattr) then
+                  vchar, vfont = ruby_char_font(v)
+                elseif k == "p" then
+                  vchar, vfont = hbox_fin_char_font(v)
+                else
+                  vchar, vfont = hbox_ini_char_font(v)
+                end
               end
               if vchar and vfont and option_in_font(vfont, opt_name) then
-                ok = is_cjk(v, vchar)
+                ok = is_cjk_char(vchar)
               end
 
               break
@@ -1037,7 +1118,11 @@
       local dotattr = has_attribute(curr, dotemphattr)
       if dotattr then
         local c = my_node_props(curr).unicode or curr.char
-        if is_hangul(c) or is_hanja(c) or is_chosong(c) or is_kana(c) then
+        if is_hangul(c)      or
+           is_compat_jamo(c) or
+           is_chosong(c)     or
+           is_hanja(c)       or
+           is_kana(c)        then
           local currwd = curr.width
           if currwd >= get_en_size(curr.font) then
             local box = nodecopy(dotemphbox[dotattr])
@@ -1178,7 +1263,7 @@
   local str = get_font_opt_dimen(fid, "intercharstretch")
   if str then
     local em = get_en_size(fid) * 2
-    texsprint(stringformat("\\def\\luatexkostretchfactor{%.4f}", str/em/2))
+    set_macro("luatexkostretchfactor", stringformat("%.4f", str/em/2))
   end
 end
 luatexko.getrubystretchfactor = getrubystretchfactor
@@ -1517,10 +1602,12 @@
   local scale    = parameters.factor or 655.36
   local quad     = parameters.quad or 655360
   local ascender = parameters.ascender or quad*0.8
-  local goffset  = fontdata_opt_dim(fontdata, "charraise")
-  if not goffset then
-    goffset  = (parameters.x_height or quad/2) / 2
-  end
+
+  local goffset = fontdata_opt_dim(fontdata, "charraise") or
+                  (parameters.x_height or quad/2)/2
+  -- declare shift amount of horizontal box inside vertical env.
+  fontdata.horizboxmoveleftamount = quad/2-goffset
+
   for i,v in pairs(fontdata.characters) do
     local voff = goffset - (v.width or 0)/2
     local bbox = descriptions[i] and descriptions[i].boundingbox or {0,0,0,0}
@@ -1585,6 +1672,22 @@
   end
 end
 
+local function get_horizbox_moveleft ()
+  for _, v in ipairs{ fontcurrent(),
+                      texattribute.luatexkohangulfontattr,
+                      texattribute.luatexkohanjafontattr,
+                      texattribute.luatexkofallbackfontattr } do
+    if v and v > 0 then
+      local amount = get_font_data(v).horizboxmoveleftamount
+      if amount then
+        set_macro("luatexkohorizboxmoveleft", texsp(amount).."sp")
+        break
+      end
+    end
+  end
+end
+luatexko.gethorizboxmoveleft = get_horizbox_moveleft
+
 -- charraise
 
 local function process_charriase_font (fontdata)
@@ -1807,11 +1910,17 @@
   local curr = head
   while curr do
     local id = curr.id
-    if id == glyphid then
-      if curr.subtype == 1      and
-        curr.lang ~= nohyphen   and
-        is_cjk(curr, curr.char) then
-        curr.lang = langkor
+    if id == glyphid and curr.subtype == 1 and curr.lang ~= nohyphen then
+      local c = curr.char
+      if c then
+        if is_unicode_var_sel(c) then
+          local p = getprev(curr)
+          if p.id == glyphid then
+            curr.lang = p.lang
+          end
+        elseif is_cjk_char(c) then
+          curr.lang = langkor
+        end
       end
     elseif id == mathid then
       curr = end_of_math(curr)
@@ -1858,25 +1967,3 @@
 end
 luatexko.currenthashangulchars = current_has_hangul_chars
 
-local function get_gid_of_charslot (fd, slot)
-  if type(fd) == "number" then
-    fd = get_font_data(fd)
-  end
-  local character = fd.characters[slot]
-  return character and character.index
-end
-luatexko.get_gid_of_charslot = get_gid_of_charslot
-
-local function get_charslots_of_gid (fd, gid)
-  if type(fd) == "number" then
-    fd = get_font_data(fd)
-  end
-  local t = {}
-  for i, v in pairs(fd.characters) do
-    if v.index == gid then
-      t[#t + 1] = i
-    end
-  end
-  return t
-end
-luatexko.get_charslots_of_gid = get_charslots_of_gid

Modified: trunk/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty	2019-08-01 23:58:09 UTC (rev 51802)
+++ trunk/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty	2019-08-02 21:18:39 UTC (rev 51803)
@@ -13,7 +13,7 @@
 
 \ifdefined\luatexkohangulfontattr \endinput\fi
 \ifdefined\selectfont
-  \ProvidesPackage{luatexko}[2019/06/21 v2.3 typesetting Korean with LuaTeX]
+  \ProvidesPackage{luatexko}[2019/08/01 v2.4 typesetting Korean with LuaTeX]
   \RequirePackage{luatexbase}
   \RequirePackage{fontspec}
 \else
@@ -257,7 +257,9 @@
       \pdfliteral{q 0 -1 1 0 0 0 cm}\box#1\pdfliteral{Q}%
       \vfil }}}
 % horizontal box inside vertical writing
+\def\luatexkohorizboxmoveleft{0.5ex}
 \protected\def\horizontal#1{%
+  \directlua{ luatexko.gethorizboxmoveleft() }%
   \leavevmode
   \setbox\z@\vbox\bgroup
     \hsize#1\relax
@@ -265,7 +267,7 @@
 \protected\def\endhorizontal{%
   \egroup
   \luatexkounrotatebox\z@
-  \box\z@ }
+  \lower\luatexkohorizboxmoveleft\box\z@ }
 \protected\def\luatexkounrotatebox#1{%
   \setbox#1\hbox to\dimexpr\ht#1+\dp#1{%
     \vbox to\wd#1{%



More information about the tex-live-commits mailing list