OSDN Git Service

ltjsclasses: sync with jsclasses
[luatex-ja/luatexja.git] / src / ltj-jfmglue.lua
index 371c17f..a2c61a2 100644 (file)
@@ -3,7 +3,7 @@
 --
 luatexbase.provides_module({
   name = 'luatexja.jfmglue',
-  date = '2016/03/31',
+  date = '2016/04/03',
   description = 'Insertion process of JFM glues and kanjiskip',
 })
 module('luatexja.jfmglue', package.seeall)
@@ -301,8 +301,7 @@ end
 local ltjw_apply_ashift_math = ltjw.apply_ashift_math
 local ltjw_apply_ashift_disc = ltjw.apply_ashift_disc
 local min, max = math.min, math.max
-local rule_subtype = (status.luatex_version>=85) and 3 or 0
-local function calc_np_aux_glyph_common(lp)
+local function calc_np_aux_glyph_common(lp, acc_flag)
    Np.nuc = lp
    Np.first= (Np.first or lp)
    if getfield(lp, 'lang') == lang_ja then
@@ -362,7 +361,7 @@ local function calc_np_aux_glyph_common(lp)
       end
       local r
       if adj_depth>node_depth then
-           r = node_new(id_rule,rule_subtype)
+           r = node_new(id_rule,3)
            setfield(r, 'width', 0); setfield(r, 'height', 0)
            setfield(r, 'depth',adj_depth); setfield(r, 'dir', tex_dir)
            set_attr(r, attr_icflag, PROCESSED)
@@ -380,7 +379,7 @@ local function calc_np_aux_glyph_common(lp)
               node_free(r)
            elseif (ct.left_protruding or 0) == 0 then
               head = insert_before(head, npn, r)
-              Np.first = (Np.first==npn) and r or npn
+              Np.first = acc_flag and Np.first or ((Np.first==npn) and r or npn)
            elseif (ct.right_protruding or 0) == 0 then
               insert_after(head, npn, r); Np.last, lp = r, r
            else
@@ -396,7 +395,10 @@ local function calc_np_aux_glyph_common(lp)
       return true, lp
    end
 end
-local calc_np_auxtable = {
+local calc_np_auxtable
+do
+local dir_tate = luatexja.dir_table.dir_tate
+calc_np_auxtable = {
    [id_glyph] = calc_np_aux_glyph_common,
    [id_hlist] = function(lp)
       local op, flag
@@ -423,10 +425,6 @@ local calc_np_auxtable = {
       Np.id = id_box_like;
       return true, node_next(lp)
    end,
-   skip = function(lp)
-      set_attr(lp, attr_icflag, PROCESSED)
-      return false, node_next(lp)
-   end,
    [id_whatsit] = function(lp)
       local lps = getsubtype(lp)
       if lps==sid_user then
@@ -490,7 +488,7 @@ local calc_np_auxtable = {
         set_attr(lp, attr_icflag, PROCESSED); lp = node_next(lp)
         set_attr(lp, attr_icflag, PROCESSED); lp = node_next(lp)
         set_attr(lp, attr_icflag, PROCESSED);
-        return calc_np_aux_glyph_common(lp)
+        return calc_np_aux_glyph_common(lp, true)
       else
         Np.first = Np.first or lp
         Np.id = id_kern; set_attr(lp, attr_icflag, PROCESSED)
@@ -502,17 +500,13 @@ local calc_np_auxtable = {
       return false, node_next(lp)
    end,
 }
-calc_np_auxtable[id_rule]   = calc_np_auxtable.box_like
-if status.luatex_version>=85 then
-  calc_np_auxtable[15]        = calc_np_auxtable.box_like
-else
-  calc_np_auxtable[13]        = calc_np_auxtable.box_like
 end
-calc_np_auxtable[id_ins]    = calc_np_auxtable.skip
-calc_np_auxtable[id_mark]   = calc_np_auxtable.skip
-calc_np_auxtable[id_adjust] = calc_np_auxtable.skip
-if node.id('local_par') then
-   calc_np_auxtable[node.id('local_par')] = calc_np_auxtable.skip
+calc_np_auxtable[id_rule]   = calc_np_auxtable.box_like
+calc_np_auxtable[15]        = calc_np_auxtable.box_like
+
+local function calc_np_aux_skip (lp)
+   set_attr(lp, attr_icflag, PROCESSED)
+   return false, node_next(lp)
 end
 
 function calc_np(last, lp)
@@ -538,7 +532,7 @@ function calc_np(last, lp)
            return calc_np_pbox(lp, last)
          end -- id_pbox
       else
-        k, lp = calc_np_auxtable[getid(lp)](lp)
+        k, lp = (calc_np_auxtable[getid(lp)] or calc_np_aux_skip)(lp)
         if k then return lp end
       end
    end
@@ -815,7 +809,7 @@ do
       if Np.auto_kspc or Nq.auto_kspc then
         local pm, qm = Np.met, Nq.met
         if (pm.char_type==qm.char_type) and (qm.var==pm.var) then
-           return get_kanjiskip_low(true, qm, 1, 1, 1)
+            return get_kanjiskip_low(true, qm, 1, 1, 1)
         else
            local gb = get_kanjiskip_low(true, qm, 1, 1, 1)
            local ga = get_kanjiskip_low(true, pm, 1, 1, 1)