-local function enlarge(box, new_width, pre, middle, post, prenw, postnw)
- -- pre, middle, post: 伸縮比率
- -- prenw, postnw: 前後の自然長 (sp)
- local h = box.head; local hh = box.height; local hd = box.depth
- local hx = h
- while hx do
- if has_attr(hx, attr_icflag) == KANJI_SKIP
- or has_attr(hx, attr_icflag) == XKANJI_SKIP
- or has_attr(hx, attr_icflag) == FROM_JFM then
- -- この 3 種類の空白をのばす
- if hx.id == id_kern then
- local k = node_new(id_glue);
- local ks = node_new(id_glue_spec);
- ks.width = hx.kern;
- ks.stretch_order = 2; ks.stretch = round(middle*65536);
- ks.shrink_order = 0; ks.shrink = 0;
- k.subtype = 0; k.spec = ks
- h = node_insert_after(h, hx, k);
- h = node_remove(h, hx); node_free(hx); hx = k;
- else -- glue
- hx.spec = node_copy(hx.spec);
- hx.spec.stretch_order=2; hx.spec.stretch = round(middle*65536);
- hx.spec.shrink_order=0; hx.spec.shrink = 0;
- end
+local enlarge
+do
+ local FROM_JFM = luatexja.icflag_table.FROM_JFM
+ local PROCESSED = luatexja.icflag_table.PROCESSED
+ local KANJI_SKIP = luatexja.icflag_table.KANJI_SKIP
+ local KANJI_SKIP_JFM = luatexja.icflag_table.KANJI_SKIP_JFM
+ local XKANJI_SKIP = luatexja.icflag_table.XKANJI_SKIP
+ local XKANJI_SKIP_JFM= luatexja.icflag_table.XKANJI_SKIP_JFM
+ enlarge = function (box, new_width, pre, middle, post, prenw, postnw)
+ -- pre, middle, post: 伸縮比率
+ -- prenw, postnw: 前後の自然長 (sp)
+ local h = getlist(box);
+ local hh, hd = getfield(box, 'height'), getfield(box, 'depth')
+ local hx = h
+ while hx do
+ local hic = has_attr(hx, attr_icflag)
+ if (hic == KANJI_SKIP) or (hic == KANJI_SKIP_JFM)
+ or (hic == XKANJI_SKIP) or (hic == XKANJI_SKIP_JFM)
+ or ((hic<=FROM_JFM+2) and (hic>=FROM_JFM-2)) then
+ -- この 5 種類の空白をのばす
+ if getid(hx) == id_kern then
+ local k = node_new(id_glue)
+ local ks = node_new(id_glue_spec)
+ setfield(ks, 'width', getfield(hx, 'kern'))
+ setfield(ks, 'stretch_order', 2)
+ setfield(ks, 'stretch', round(middle*65536))
+ setfield(ks, 'shrink_order', 0); setfield(ks, 'shrink', 0)
+ setfield(k, 'subtype', 0); setfield(k, 'spec', ks)
+ h = insert_after(h, hx, k);
+ h = node_remove(h, hx); node_free(hx); hx = k
+ else -- glue
+ local old_spec = getfield(hx, 'spec')
+ local ks = node_copy(old_spec)
+ setfield(ks, 'stretch_order', 2)
+ setfield(ks, 'stretch', round(middle*65536))
+ setfield(ks, 'shrink_order', 0); setfield(ks, 'shrink', 0)
+ setfield(hx, 'spec', ks)
+ -- decrease old_spec's reference count
+ local b = node_new(id_glue)
+ setfield(b, 'spec', old_spec); node_free(b)
+ end
+ end
+ hx = node_next(hx)