X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=src%2Fltj-direction.lua;h=e29503bef4ad5a6f0034e9e69041114a5cebf066;hb=0526b27bf88ed7f2adedef267f4d9226f6f5a692;hp=a12be0a5d85648efaee3a11f5db991dd8fb05fe1;hpb=a3a97a5f517ec12a67a90cf6c0b52cb1915fc041;p=luatex-ja%2Fluatexja.git diff --git a/src/ltj-direction.lua b/src/ltj-direction.lua index a12be0a..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 @@ -881,24 +887,59 @@ do 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)