--
luatexbase.provides_module({
name = 'luatexja.jfmglue',
- date = '2021-02-11',
+ date = '2021-09-12',
description = 'Insertion process of JFM glues, [x]kanjiskip and others',
})
luatexja.jfmglue = luatexja.jfmglue or {}
local ltjd_make_dir_whatsit = ltjd.make_dir_whatsit
local ltjf_font_metric_table = ltjf.font_metric_table
local ltjf_find_char_class = ltjf.find_char_class
-local node_new = node.direct.new
+local node_new = luatexja.dnode_new
local node_copy = node.direct.copy
local node_tail = node.direct.tail
local node_free = node.direct.free
local node_remove = node.direct.remove
+local node_inherit_attr = luatexja.node_inherit_attr
local id_glyph = node.id 'glyph'
local id_hlist = node.id 'hlist'
local a = (pre or 0) + (post or 0)
if #Bp == 0 then
if (a~=0 and not(g and getid(g)==id_kern)) then
- local p = node_new(id_penalty)
+ local p = node_new(id_penalty, nil, Nq.nuc, Np.nuc)
if a<-10000 then a = -10000 elseif a>10000 then a = 10000 end
setfield(p, 'penalty', a); head = insert_before(head, Np.first, p)
Bp[1]=p; set_attr(p, attr_icflag, KINSOKU)
local a = (pre or 0) + (post or 0)
if #Bp == 0 then
if not (g and getid(g)==id_glue) or a~=0 then
- local p = node_new(id_penalty)
+ local p = node_new(id_penalty, nil, Nq.nuc, Np.nuc)
if a<-10000 then a = -10000 elseif a>10000 then a = 10000 end
setfield(p, 'penalty', a); head = insert_before(head, Np.first, p)
Bp[1]=p; set_attr(p, attr_icflag, KINSOKU)
luatexbase.call_callback('luatexja.adjust_jfmglue', head, Nq, Np, Bp)
if #Bp == 0 then
if g and getid(g)==id_glue then
- local p = node_new(id_penalty)
+ local p = node_new(id_penalty, nil, Nq.nuc, Np.nuc)
setfield(p, 'penalty', 10000); head = insert_before(head, Np.first, p)
Bp[1]=p; set_attr(p, attr_icflag, KINSOKU)
end
-- Nq.last (kern w) .... (glue/kern g) Np.first
local function real_insert(g)
if g then
+ node_inherit_attr(g, Nq.nuc, Np.nuc)
head = insert_before(head, Np.first, g)
Np.first = g
local ngk = Np.gk
if g then
set_attr(g, attr_icflag, BOXBDD)
if getid(g)==id_glue and #Bp==0 then
- local h = node_new(id_penalty)
+ local h = node_new(id_penalty, nil, Nq.nuc, Np.nuc)
setfield(h, 'penalty', 10000); set_attr(h, attr_icflag, BOXBDD)
end
head = insert_before(head, Np.first, g)
local node_traverse_id = node.direct.traverse_id
local node_traverse = node.direct.traverse
-local node_new = node.direct.new
local node_copy = node.direct.copy
local node_remove = node.direct.remove
local node_tail = node.direct.tail
local node_insert_before = node.direct.insert_before
local node_insert_after = node.direct.insert_after
local round = tex.round
+local node_new = luatexja.dnode_new
local id_glyph = node.id 'glyph'
local id_kern = node.id 'kern'
end
end
+
local ltjw = {} --export
luatexja.setwidth = ltjw
setoffsets(p, xo - fshift.left, yo - kbl - fshift.down)
return node_next(p), head, p
elseif ht_diff >= 0 and dp_diff >=0 then -- rule
- local box = node_new(id_rule,rule_subtype)
+ local box = node_new(id_rule,rule_subtype, p)
local xo, yo = getoffsets(p)
setoffsets(p, xo, yo - kbl - fshift.down)
setwhd(box, 0, fheight - kbl, fdepth + kbl)
setoffsets(p, xo + char_data.align*(fwidth-pwidth) - fshift.left,
yo - fshift.down);
setnext(p, nil)
- local box = node_new(id_hlist)
+ local box = node_new(id_hlist, nil, p)
setwhd(box, fwidth, fheight, fdepth)
setfield(box, 'head', p)
setfield(box, 'shift', kbl)
function luatexja.load_module(name) require('ltj-' .. name.. '.lua') end
do
+ local dnode = node.direct
+ local getfield, traverse = dnode.getfield, dnode.traverse
+ local node_new, set_attr, get_attr = dnode.new, dnode.set_attribute, dnode.get_attribute
+ local set_attrlist, get_attrlist = dnode.setattributelist, dnode.getattributelist
+ local unset_attr = dnode.unset_attribute
+ local attr_icflag = luatexbase.attributes['ltj@icflag']
+ local function node_inherit_attr(n, b, a)
+ if b or a then
+ local attrlist = get_attrlist(b or a)
+ local nic = get_attr(n, attr_icflag)
+ set_attrlist(n, attrlist); set_attr(n, attr_icflag, nic)
+ if b and a then
+ for na in traverse(attrlist) do
+ local id = getfield(na, 'number')
+ if id and id~=attr_icflag and getfield(na, 'value')~=get_attr(a, id) then
+ unset_attr(n, id)
+ end
+ end
+ end
+ end
+ end
+ luatexja.node_inherit_attr = node_inherit_attr
+ luatexja.dnode_new = function (id, subtype, b, a)
+ local n = node_new(id, subtype); node_inherit_attr(n, b, a); return n
+ end
+end
+do
local setfield = node.direct.setfield
luatexja.setglue = node.direct.setglue or
function(g,w,st,sh,sto,sho)