X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=src%2Fltj-direction.lua;h=e29503bef4ad5a6f0034e9e69041114a5cebf066;hb=0526b27bf88ed7f2adedef267f4d9226f6f5a692;hp=a9bdfbd8ab9a3a28fabe8f3f197aef667b7aa91b;hpb=c004010f7a45f5e5c0d46556fe9065515d6bd60a;p=luatex-ja%2Fluatexja.git diff --git a/src/ltj-direction.lua b/src/ltj-direction.lua index a9bdfbd..e29503b 100644 --- a/src/ltj-direction.lua +++ b/src/ltj-direction.lua @@ -483,14 +483,20 @@ local function get_box_dir(b, default) local bh = getfield(b,'head') -- b は insert node となりうるので getlist() は使えない local c - for i=1,2 do - if bh and getid(bh)==id_whatsit - and getsubtype(bh)==sid_user and getfield(bh, 'user_id')==DIR then + for bh in traverse_id(id_whatsit, bh) do + if getsubtype(bh)==sid_user and getfield(bh, 'user_id')==DIR then c = bh - dir = (dir==0) and has_attr(bh, attr_dir) or dir + dir = (dir==0) and has_attr(bh, attr_dir) or dir end - bh = node_next(bh) end + -- for i=1,2 do + -- if bh and getid(bh)==id_whatsit + -- and getsubtype(bh)==sid_user and getfield(bh, 'user_id')==DIR then + -- c = bh + -- dir = (dir==0) and has_attr(bh, attr_dir) or dir + -- end + -- bh = node_next(bh) + -- end stop_time_measure('get_box_dir') return (dir==0 and default or dir), c end @@ -876,29 +882,64 @@ 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 --- adjust and insertion -local id_adjust = node.id('adjust') -function luatexja.direction.check_adjust_direction() - start_time_measure('box_primitive_hook') - local list_dir = get_adjust_dir_count() - local a = tex_nest[tex_nest.ptr].tail - local ad = to_direct(a) - if a and getid(ad)==id_adjust then - local adj_dir = get_box_dir(ad) - if list_dir~=adj_dir then - ltjb.package_error( - 'luatexja', - 'Direction Incompatible', - "\\vadjust's argument and outer vlist must have same direction.") - Dnode.last_node() +-- adjust +do + local id_adjust = node.id('adjust') + function luatexja.direction.check_adjust_direction() + start_time_measure('box_primitive_hook') + local list_dir = get_adjust_dir_count() + local a = tex_nest[tex_nest.ptr].tail + local ad = to_direct(a) + if a and getid(ad)==id_adjust then + local adj_dir = get_box_dir(ad) + if list_dir~=adj_dir then + ltjb.package_error( + 'luatexja', + 'Direction Incompatible', + "\\vadjust's argument and outer vlist must have same direction.") + Dnode.last_node() + end + end + stop_time_measure('box_primitive_hook') + end +end + +-- insert +do + local id_ins = node.id('ins') + local id_rule = node.id('rule') + function luatexja.direction.populate_insertion_dir_whatsit() + start_time_measure('box_primitive_hook') + local list_dir = get_dir_count() + local a = tex_nest[tex_nest.ptr].tail + local ad = to_direct(a) + if a and getid(ad)==id_ins then + local h = getfield(ad, 'head') + if getid(h)==id_whatsit and + getsubtype(h)==sid_user and getfield(h, 'user_id')==DIR then + local n = h; h = node_remove(h,h) + node_free(n) + end + for box_rule in traverse(h) do + if getid(box_rule)