From 60c3a83c4cedcb7ff90f956165c843a1474d6fd6 Mon Sep 17 00:00:00 2001 From: Hironori Kitagawa Date: Thu, 14 Mar 2013 12:44:50 +0900 Subject: [PATCH] Fixed several bugs caused by the previous commit MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit たぶんまだバグがたくさん残っています.後でチェックします. --- src/ltj-jfmglue.lua | 21 ++++++++++++--------- src/ltj-stack.lua | 25 ++----------------------- src/luatexja-core.sty | 7 ++++++- 3 files changed, 20 insertions(+), 33 deletions(-) diff --git a/src/ltj-jfmglue.lua b/src/ltj-jfmglue.lua index 7f4b95c..8d8a7b7 100644 --- a/src/ltj-jfmglue.lua +++ b/src/ltj-jfmglue.lua @@ -161,7 +161,9 @@ local function check_box(box_ptr, box_end) first_char = p; find_first_char = false end last_char = p; found_visible_node = true; p=node_next(p) - if (not p) or p==box_end then return found_visible_node end + if (not p) or p==box_end then + return found_visible_node + end until p.id~=id_glyph pid = p.id -- p must be non-nil end @@ -220,7 +222,7 @@ function check_box_high(Nx, box_ptr, box_end) if check_box(box_ptr, box_end) then local first_char = first_char if first_char then - if first_char.id==glyph_node then + if first_char.id==id_glyph then if first_char.font == (has_attr(first_char, attr_curjfnt) or -1) then set_np_xspc_jachar(Nx, first_char) else @@ -278,7 +280,7 @@ end local calc_np_auxtable = { - [id_glyph] = function (lp) + [id_glyph] = function (lp) Np.first, Np.nuc = (Np.first or lp), lp; Np.id = (lp.font == (has_attr(lp, attr_curjfnt) or -1)) and id_jglyph or id_glyph --set_attr_icflag_processed(lp) treated in ltj-setwidth.lua @@ -354,7 +356,7 @@ local calc_np_auxtable = { if lp.subtype==2 then 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); Np = node_next(lp) + set_attr(lp, attr_icflag, PROCESSED); lp = node_next(lp) set_attr(lp, attr_icflag, PROCESSED); Np.nuc = lp Np.id = (lp.font == (has_attr(lp, attr_curjfnt) or -1)) and id_jglyph or id_glyph return true, check_next_ickern(node_next(lp)); @@ -392,7 +394,7 @@ function calc_np(lp, last) for k = 1,#Bp do Bp[k] = nil end while lp ~= last do local lpa = has_attr(lp, attr_icflag) or 0 - -- unbox 由来ノードの検出 + -- unbox 由来ノードの検出 if lpa>=PACKED then if lpa == BOXBDD then local lq = node_next(lp) @@ -443,7 +445,7 @@ do function set_np_xspc_alchar(Nx, c,x, lig) if c~=-1 then local xc, xs = x.components, x.subtype - if lig == ligature_head then + if lig == 1 then while xc and xs and xs%4>=2 do x = xc; xc, xs = x.components, x.subtype end @@ -484,7 +486,7 @@ do function after_hlist(Nx) local s = Nx.last_char if s then - if s.id==glyph_node then + if s.id==id_glyph then if s.font == (has_attr(s, attr_curjfnt) or -1) then set_np_xspc_jachar(Nx, s) else @@ -960,7 +962,8 @@ function main(ahead, mode) end lp = calc_np(lp, last) while Np do - extract_np(); adjust_nq() + extract_np(); + adjust_nq(); local pid, pm = Np.id, Np.met -- 挿入部 if pid == id_jglyph then @@ -1024,4 +1027,4 @@ luatexbase.add_to_callback("luatexja.jfmglue.whatsit_getinfo", whatsit_callback, luatexbase.add_to_callback("luatexja.jfmglue.whatsit_after", whatsit_after_callback, "luatexja.beginpar.np_info_after", 1) -end \ No newline at end of file +end diff --git a/src/ltj-stack.lua b/src/ltj-stack.lua index 3dfe2bb..2a2d73a 100644 --- a/src/ltj-stack.lua +++ b/src/ltj-stack.lua @@ -15,32 +15,12 @@ luatexja.load_module('base'); local ltjb = luatexja.base local node_new = node.new local id_whatsit = node.id('whatsit') local sid_user = node.subtype('user_defined') -local hmode = 118 -- in luatexref-t.pdf, this must be 127 +hmode = 0 -- dummy charprop_stack_table={}; local charprop_stack_table = charprop_stack_table charprop_stack_table[0]={} --- modified from table.fastcopy -local next = next -local function stack_table_copy_aux(old) - local new = {} - for i,v in next, old do - new[i] = v - end - return new -end -local function stack_table_copy(old) - if old then - local new = {} - for i,v in next, old do - new[i] = stack_table_copy_aux(v) - end - return new - else - return {} - end -end function get_stack_level() local i = tex.getcount('ltj@@stack') @@ -54,7 +34,7 @@ function get_stack_level() for k,v in pairs(charprop_stack_table) do -- clear the stack above i if k>=i then charprop_stack_table[k]=nil end end - charprop_stack_table[i] = stack_table_copy(charprop_stack_table[i-1]) + charprop_stack_table[i] = table.fastcopy(charprop_stack_table[i-1]) tex.setcount('ltj@@stack', i) if gd>0 then tex.globaldefs = gd end if tex.nest[tex.nest.ptr].mode == hmode or @@ -83,7 +63,6 @@ end -- EXT function set_stack_table(g,m,c,p,lb,ub) - print(g,m,c) local i = get_stack_level() if type(p)~='number' or pub then ltjb.package_error('luatexja', diff --git a/src/luatexja-core.sty b/src/luatexja-core.sty index f0eedea..853872e 100644 --- a/src/luatexja-core.sty +++ b/src/luatexja-core.sty @@ -184,7 +184,6 @@ \input ltj-base.sty % \fi % - %%%%%%%% \asluastring \def\asluastring#1{'\luaescapestring{\detokenize{#1}}'} @@ -241,6 +240,12 @@ \newcount\ltj@@stack \newcount\ltj@@group@level \ltj@@group@level=0 \ltj@@stack=0 +\setbox0\hbox{% + \directlua{% This value depends on the version of LuaTeX. + luatexja.stack.hmode = -tex.nest[tex.nest.ptr].mode + } +} + % prebreakpenalty = {, } \define@key[ltj]{japaram}{kcatcode}{% \expandafter\ltj@@set@stack#1:{KCAT}{0}{0x7FFFFFFF}} -- 2.11.0