-local function aw_step2_dummy(p, _, added_flag)
- if added_flag then -- 行末に kern 追加したので,それによる補正
- local f = node_hpack(getlist(p), getfield(p, 'width'), 'exactly')
- setfield(f, 'head', nil)
- setfield(p, 'glue_set', getfield(f, 'glue_set'))
- setfield(p, 'glue_order', getfield(f, 'glue_order'))
- setfield(p, 'glue_sign', getfield(f, 'glue_sign'))
- node_free(f)
- return
+local aw_step2, aw_step2_dummy
+do
+local node_hpack = node.direct.hpack
+local function repack(p)
+ local f = node_hpack(getlist(p), getfield(p, 'width'), 'exactly')
+ setfield(f, 'head', nil)
+ setfield(p, 'glue_set', getfield(f, 'glue_set'))
+ setfield(p, 'glue_order', getfield(f, 'glue_order'))
+ setfield(p, 'glue_sign', getfield(f, 'glue_sign'))
+ node_free(f)
+ return
+end
+function aw_step2_dummy(p, _, added_flag)
+ if added_flag then return repack(p) end
+end
+
+local function clear_stretch(p, ind, ap, name)
+ for q in node_traverse_id(id_glue, getlist(p)) do
+ local f = ap[get_attr_icflag(q)]
+ if f == ind then
+ setfield(q, name..'_order', 0)
+ setfield(q, name, 0)
+ end
+ end
+end
+
+local function set_stretch(p, after, before, ind, ap, name)
+ if before > 0 then
+ local ratio = after/before
+ for q in node_traverse_id(id_glue, getlist(p)) do
+ local f = ap[get_attr_icflag(q)]
+ if (f==ind) and getfield(q, name..'_order')==0 then
+ setfield(q, name, getfield(q, name)*ratio)
+ end
+ end