OSDN Git Service

Modified check_box function; sync with ptex-base_130104_math-spc_beta.diff
[luatex-ja/luatexja.git] / src / ltj-jfmglue.lua
index 7c5dfbb..7f78741 100644 (file)
@@ -54,20 +54,16 @@ local sid_start_thread = node.subtype('pdf_start_thread')
 local sid_end_link = node.subtype('pdf_end_link')
 local sid_end_thread = node.subtype('pdf_end_thread')
 
-local ITALIC = 1
--- 実装予定: non-packed jchar 2
-local PACKED = 2
-local KINSOKU = 3
-local FROM_JFM = 6
--- FROM_JFM: 4, 5, 6, 7, 8 →優先度高
--- 6 が標準
-local KANJI_SKIP = 9
-local XKANJI_SKIP = 10
-local PROCESSED = 11
-local IC_PROCESSED = 12
-local BOXBDD = 15
-local PROCESSED_BEGIN_FLAG = 32
-
+local ITALIC       = luatexja.icflag_table.ITALIC
+local PACKED       = luatexja.icflag_table.PACKED
+local KINSOKU      = luatexja.icflag_table.KINSOKU
+local FROM_JFM     = luatexja.icflag_table.FROM_JFM
+local KANJI_SKIP   = luatexja.icflag_table.KANJI_SKIP
+local XKANJI_SKIP  = luatexja.icflag_table.XKANJI_SKIP
+local PROCESSED    = luatexja.icflag_table.PROCESSED
+local IC_PROCESSED = luatexja.icflag_table.IC_PROCESSED
+local BOXBDD       = luatexja.icflag_table.BOXBDD
+local PROCESSED_BEGIN_FLAG = luatexja.icflag_table.PROCESSED_BEGIN_FLAG
 local kanji_skip
 local xkanji_skip
 
@@ -188,6 +184,11 @@ local function check_box(box_ptr, box_end)
               end
            end
         end
+      elseif pid==id_math then
+        if find_first_char then 
+           first_char = p; find_first_char = false
+        end
+        last_char = p; found_visible_node = true
       elseif not (pid==id_ins   or pid==id_mark
                  or pid==id_adjust or pid==id_whatsit
                  or pid==id_penalty) then
@@ -206,11 +207,16 @@ end
 function check_box_high(Nx, box_ptr, box_end)
    first_char = nil;  last_char = nil;  find_first_char = true
    if check_box(box_ptr, box_end) then
+      local first_char = first_char
       if first_char then
-         if first_char.font == (has_attr(first_char, attr_curjfnt) or -1) then 
-            set_np_xspc_jachar(Nx, first_char)
-         else
-            set_np_xspc_alchar(Nx, first_char.char,first_char, ligature_head)
+         if first_char.id==glyph_node then
+           if first_char.font == (has_attr(first_char, attr_curjfnt) or -1) then 
+              set_np_xspc_jachar(Nx, first_char)
+           else
+              set_np_xspc_alchar(Nx, first_char.char,first_char, ligature_head)
+           end
+        else -- math_node
+           set_np_xspc_alchar(Nx, -1,first_char)
          end
       end
    end
@@ -455,10 +461,14 @@ do
    function after_hlist(Nx)
       local s = Nx.last_char
       if s then
-        if s.font == (has_attr(s, attr_curjfnt) or -1) then 
-           set_np_xspc_jachar(Nx, s)
+        if s.id==glyph_node then
+           if s.font == (has_attr(s, attr_curjfnt) or -1) then 
+              set_np_xspc_jachar(Nx, s)
+           else
+              set_np_xspc_alchar(Nx, s.char, s, ligature_tail)
+           end
         else
-           set_np_xspc_alchar(Nx, s.char, s, ligature_tail)
+           set_np_xspc_alchar(Nx, -1, s)
         end
       else
         Nx.pre, Nx.met = nil, nil
@@ -526,7 +536,7 @@ local function new_jfm_glue(m, bc, ac)
    local g, d = z.glue[ac], 0 
    if g then
       g,d = node_copy(g[1]), g[2]; 
-      g.spec = node.copy(g.spec); -- node_copy は spec を copy しない(参照を増やすのみ)
+      g.spec = node_copy(g.spec); -- node_copy は spec をコピーする
    else
       local k = z.kern[ac]
       if k then