OSDN Git Service

ltj-jfmglue.lua: fix the call of check_box
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Thu, 2 Oct 2014 10:35:01 +0000 (19:35 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Thu, 2 Oct 2014 10:35:01 +0000 (19:35 +0900)
src/ltj-adjust.lua
src/ltj-direction.lua
src/ltj-jfmglue.lua
src/ltj-pretreat.lua

index 22c0db7..46d1e02 100644 (file)
@@ -3,7 +3,7 @@
 --
 luatexbase.provides_module({
   name = 'luatexja.adjust',
-  date = '2014/05/08',
+  date = '2014/09/30',
   description = 'Advanced line adjustment for LuaTeX-ja',
 })
 module('luatexja.adjust', package.seeall)
@@ -178,29 +178,29 @@ local function aw_step1(p, res, total)
    local x = node_tail(head); if not x then return false end
    -- x: \rightskip
    x = node_prev(x); if not x then return false end
-   if getid(x) == id_glue and getsubtype(x) == 15 then
+   local xi, xc = getid(x)
+   if xi == id_glue and getsubtype(x) == 15 then
       -- 段落最終行のときは,\penalty10000 \parfillskip が入るので,
       -- その前の node が本来の末尾文字となる
-      x = node_prev(node_prev(x))
+      x = node_prev(node_prev(x)); xi = getid(x)
    end
    -- local xi = getid(x)
    -- while (get_attr_icflag(x) == PACKED)
    --    and  ((xi == id_penalty) or (xi == id_kern) or (xi == id_kern)) do
    --       x = node_prev(x); xi = getid(x)
    -- end
-   local xi, xc = getid(x)
    if xi == id_glyph and has_attr(x, attr_curjfnt) == getfont(x) then
       -- 和文文字
       xc = x
    elseif xi == id_hlist and get_attr_icflag(x) == PACKED then
       -- packed JAchar
       xc = ltjd_glyph_from_packed(x)
-      while getid(xc) == id_whatsit do xc = node_next(xc) end
+      while getid(xc) == id_whatsit do xc = node_next(xc) end -- これはなんのために?
    else
      return false-- それ以外は対象外.
    end
    local xk = ltjf_font_metric_table[getfont(xc)]
-           .char_type[has_attr(xc, attr_jchar_class) or 0]['end_' .. res.name] or 0
+     .char_type[has_attr(xc, attr_jchar_class) or 0]['end_' .. res.name] or 0
 
    if xk>0 and total>=xk then
       total = total - xk
index a9bdfbd..a12be0a 100644 (file)
@@ -876,7 +876,7 @@ do
    local function glyph_from_packed(h)
       local b = getlist(h)
       return (getid(b)==id_kern or (getid(b)==id_whatsit and getsubtype(b)==sid_save) )
-        and node_next(node_next(node_next(node_next(b)))) or b
+        and node_next(node_next(node_next(b))) or b
    end
    luatexja.direction.glyph_from_packed = glyph_from_packed
 end
index e449b3a..58d09ac 100644 (file)
@@ -320,22 +320,23 @@ end
 local ltjw_apply_ashift_math = ltjw.apply_ashift_math
 local function calc_np_aux_glyph_common(lp)
    Np.nuc = lp
-   local npi = (getfont(lp) == (has_attr(lp, attr_curjfnt) or -1))
-        and id_jglyph or id_glyph
-      Np.id = npi
-      if npi==id_jglyph then
-        set_np_xspc_jachar(Np, lp)
-        lp, head, npi = capsule_glyph(lp, Np.met, Np.class, head, tex_dir)
-        Np.first = (Np.first~=Np.nuc) and Np.first or npi
-        Np.nuc = npi
-      else
-        set_np_xspc_alchar(Np, getchar(lp), lp, 1)
-        set_attr(lp, attr_icflag, PROCESSED)
-        setfield(lp, 'yoffset',
-                    getfield(lp, 'yoffset') - (has_attr(lp,attr_ablshift) or 0))
-        lp = node_next(lp)
-      end
-      return true, check_next_ickern(lp);
+   Np.id = npi
+   if (getfont(lp) == (has_attr(lp, attr_curjfnt) or -1)) then
+      Np.id = id_jglyph
+      set_np_xspc_jachar(Np, lp)
+      local npi
+      lp, head, npi = capsule_glyph(lp, Np.met, Np.class, head, tex_dir)
+      Np.first = (Np.first~=Np.nuc) and Np.first or npi
+      Np.nuc = npi
+   else
+      Np.id = id_glyph
+      set_np_xspc_alchar(Np, getchar(lp), lp, 1)
+      set_attr(lp, attr_icflag, PROCESSED)
+      setfield(lp, 'yoffset',
+              getfield(lp, 'yoffset') - (has_attr(lp,attr_ablshift) or 0))
+      lp = node_next(lp)
+   end
+   return true, check_next_ickern(lp);
 end
 local calc_np_auxtable = {
    [id_glyph] = function (lp)
@@ -347,10 +348,11 @@ local calc_np_auxtable = {
       head, lp, op, flag = ltjd_make_dir_whatsit(head, lp, list_dir, 'jfm hlist')
       set_attr(op, attr_icflag, PROCESSED)
       Np.first = Np.first or op; Np.last = op; Np.nuc = op;
-      local npi = (flag or getfield(op, 'shift')~=0) and id_box_like or id_hlist
-      Np.id = npi
-      if npi==id_hlist then
-        Np.last_char = check_box_high(Np, getlist(lp), nil)
+      if (flag or getfield(op, 'shift')~=0) then
+        Np.id = id_box_like
+      else
+        Np.id = id_hlist
+        Np.last_char = check_box_high(Np, getlist(op), nil)
       end
       return true, lp
    end,
index 598c804..dd71d23 100644 (file)
@@ -119,12 +119,13 @@ do
 end
 
 -- mode: true iff this function is called from hpack_filter
+local ltjs_report_stack_level = ltjs.report_stack_level
 local function set_box_stack_level(head, mode)
    local box_set, cl = 0, tex.currentgrouplevel + 1
    for _,p  in pairs(wt) do
       if mode and getfield(p, 'value')==cl then box_set = 1 end; node_free(p)
    end
-   ltjs.report_stack_level(tex_getcount('ltj@@stack') + box_set)
+   ltjs_report_stack_level(tex_getcount('ltj@@stack') + box_set)
    for _,p  in pairs(wtd) do
       node_free(p)
    end