X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=src%2Fltj-lineskip.lua;h=f5c439e559dd4fe83835990e5925e673f0807149;hb=f078ac2f7998a102c7ec765e725f2269eed9f872;hp=d4efaf9ec63df6e800a6d5400eddfd9b5843b91c;hpb=82d4e7398109ece5c609f16eec4a870546e53dc9;p=luatex-ja%2Fluatexja.git diff --git a/src/ltj-lineskip.lua b/src/ltj-lineskip.lua index d4efaf9..f5c439e 100644 --- a/src/ltj-lineskip.lua +++ b/src/ltj-lineskip.lua @@ -8,6 +8,7 @@ luatexja.lineskip = luatexja.lineskip or {} local to_direct = node.direct.todirect local ltjl = luatexja.lineskip local id_glue = node.id('glue') +local id_penalty = node.id('penalty') local id_hlist = node.id('hlist') local setfield = node.direct.setfield local getfield = node.direct.getfield @@ -30,7 +31,7 @@ ltjl.copy_glue = copy_glue function ltjl.p_dummy(before, after) return nil, 0 end -function ltjl.l_dummy(dist, g, adj, normal, bw) +function ltjl.l_dummy(dist, g, adj, normal, bw, loc) if dist < tex.lineskiplimit then copy_glue(g, tex.lineskip, 1, tex.lineskip.width + adj) else @@ -55,7 +56,9 @@ do local p, n = node_prev(x), node_next(x) if p then local pid = getid(p) - while (12<=pid) and (pid<=14) and node_prev(p) do p = node_prev(p); pid = getid(p) end + while (id_glue<=pid) and (pid<=id_penalty) and node_prev(p) do + p = node_prev(p); pid = getid(p) + end if pid==id_hlist and getid(n)==id_hlist then local normal = bw - getfield(p, 'depth') - getfield(n, 'height') local lmin, adj = ltj_profiler(p, n, false, bw) @@ -66,11 +69,12 @@ do end return true end - luatexbase.add_to_callback('post_linebreak_filter', + ltjb.add_to_callback('post_linebreak_filter', adjust_glue, 'ltj.lineskip', 10000) end do + local p_dummy = ltjl.p_dummy local make_dir_whatsit = luatexja.direction.make_dir_whatsit local get_dir_count = luatexja.direction.get_dir_count local node_write = node.direct.write @@ -85,8 +89,10 @@ do - getfield(new_b, mirrored and 'depth' or 'height') local lmin, adj = nil, 0 local tail = to_direct(tex.nest[tex.nest.ptr].tail) - if tail and getid(tail)==id_glue and getsubtype(tail)==3 then - tail = node_prev(tail) + if p_dummy~=ltj_profiler then + while tail and (id_glue<=getid(tail)) and (getid(tail)<=id_penalty) do + tail = node_prev(tail) + end end if tail then if getid(tail)==id_hlist and getid(new_b)==id_hlist then @@ -96,7 +102,7 @@ do end end local g = node_new(id_glue) - ltj_skip(lmin or normal, g, adj, normal, bw) + ltj_skip(lmin or normal, g, adj, normal, bw, loc) node_write(g) end node_write(new_b)