X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=src%2Fluatexja.lua;h=ec5f902c8c3609f3bb206dddd546003d2c33ef00;hb=ab23049deb6fb90ca689fdf4924b3783f08f8f2e;hp=2125969ec3e76f6b0a8cb7b88db640d4c42896fe;hpb=011b5162a7b1eeb3d7a547dda3846427bba88460;p=luatex-ja%2Fluatexja.git diff --git a/src/luatexja.lua b/src/luatexja.lua index 2125969..ec5f902 100644 --- a/src/luatexja.lua +++ b/src/luatexja.lua @@ -1,5 +1,6 @@ require('lualibs') +tableunpack = table.unpack ------------------------------------------------------------------------ -- naming: @@ -19,6 +20,16 @@ function luatexja.load_lua(fn) end end +local setfield = node.direct.setfield +luatexja.setglue = node.direct.setglue or + function(g,w,st,sh,sto,sho) + setfield(g,'width', w or 0) + setfield(g,'stretch',st or 0) + setfield(g,'shrink', sh or 0) + setfield(g,'stretch_order',sto or 0) + setfield(g,'shrink_order', sho or 0) + end + -- check token library if newtoken then luatexja.token = newtoken @@ -130,6 +141,7 @@ local function print_scaled(s) until s<=delta return out end +luatexja.print_scaled = print_scaled local function print_glue(d,order) local out=print_scaled(d) @@ -290,10 +302,9 @@ end do local start_time_measure, stop_time_measure = ltjb.start_time_measure, ltjb.stop_time_measure - local Dnode = node.direct or node local nullfunc = function (n) return n end - local to_node = (Dnode ~= node) and Dnode.tonode or nullfunc - local to_direct = (Dnode ~= node) and Dnode.todirect or nullfunc + local to_node = node.direct.tonode + local to_direct = node.direct.todirect local ensure_tex_attr = ltjb.ensure_tex_attr -- mode = true iff main_process is called from pre_linebreak_filter @@ -317,22 +328,20 @@ do end -- callbacks - luatexbase.add_to_callback( + ltjb.add_to_callback( 'pre_linebreak_filter', function (head,groupcode) return main_process(head, true, tex.textdir, groupcode) - end,'ltj.pre_linebreak_filter', - luatexbase.priority_in_callback('pre_linebreak_filter', - 'luaotfload.node_processor') + 1) - luatexbase.add_to_callback( + end,'ltj.main', + luatexbase.priority_in_callback('pre_linebreak_filter', 'luaotfload.node_processor')+1) + ltjb.add_to_callback( 'hpack_filter', function (head,groupcode,size,packtype, dir) return main_process(head, false, dir, groupcode) - end,'ltj.hpack_filter', - luatexbase.priority_in_callback('hpack_filter', - 'luaotfload.node_processor') + 1) - luatexbase.add_to_callback('pre_linebreak_filter', adjust_icflag, 'ltj.adjust_icflag', 1) - luatexbase.add_to_callback('hpack_filter', adjust_icflag, 'ltj.adjust_icflag', 1) + end,'ltj.main', + luatexbase.priority_in_callback('hpack_filter', 'luaotfload.node_processor')+1) + ltjb.add_to_callback('pre_linebreak_filter', adjust_icflag, 'ltj.adjust_icflag', 1) + ltjb.add_to_callback('hpack_filter', adjust_icflag, 'ltj.adjust_icflag', 1) end @@ -353,7 +362,6 @@ local has_attr = node.has_attribute local id_penalty = node.id('penalty') local id_glyph = node.id('glyph') -local id_glue_spec = node.id('glue_spec') local id_glue = node.id('glue') local id_kern = node.id('kern') local id_hlist = node.id('hlist') @@ -423,7 +431,7 @@ local function debug_show_node_X(p,print_fn, limit) .. ', dir=' .. tostring(node.has_attribute(p, attr_dir)) print_fn(s) elseif pt == 'glue' then - s = base .. ' ' .. print_spec(p.spec) + s = base .. ' ' .. print_spec(p) if get_attr_icflag(p)>icflag_table.KINSOKU and get_attr_icflag(p)