summaryrefslogtreecommitdiff
path: root/macros/luatex/generic/luatexja/src/ltj-jfmglue.lua
diff options
context:
space:
mode:
Diffstat (limited to 'macros/luatex/generic/luatexja/src/ltj-jfmglue.lua')
-rw-r--r--macros/luatex/generic/luatexja/src/ltj-jfmglue.lua54
1 files changed, 25 insertions, 29 deletions
diff --git a/macros/luatex/generic/luatexja/src/ltj-jfmglue.lua b/macros/luatex/generic/luatexja/src/ltj-jfmglue.lua
index 7437492772..9ce7816070 100644
--- a/macros/luatex/generic/luatexja/src/ltj-jfmglue.lua
+++ b/macros/luatex/generic/luatexja/src/ltj-jfmglue.lua
@@ -3,7 +3,7 @@
--
luatexbase.provides_module({
name = 'luatexja.jfmglue',
- date = '2021-02-11',
+ date = '2021-09-18',
description = 'Insertion process of JFM glues, [x]kanjiskip and others',
})
luatexja.jfmglue = luatexja.jfmglue or {}
@@ -45,11 +45,12 @@ local node_next = node.direct.getnext
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'
@@ -383,7 +384,7 @@ function calc_np_aux_glyph_common(lp, acc_flag)
lp=lx
local r
if adj_depth>node_depth then
- r = node_new(id_rule,3)
+ r = node_new(id_rule,3,first_glyph)
setfield(r, 'width', 0); setfield(r, 'height', 0)
setfield(r, 'depth',adj_depth); setfield(r, 'dir', tex_dir)
set_attr(r, attr_icflag, PROCESSED)
@@ -689,7 +690,7 @@ local function handle_penalty_normal(post, pre, g)
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)
@@ -703,7 +704,7 @@ local function handle_penalty_always(post, pre, g)
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)
@@ -716,7 +717,7 @@ local function handle_penalty_suppress(post, pre, g)
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
@@ -730,7 +731,7 @@ local function handle_penalty_jwp()
local a = table_current_stack[luatexja.stack_table_index.JWP]
if #widow_Bp == 0 then
if a~=0 then
- local p = node_new(id_penalty)
+ local p = node_new(id_penalty, widow_Np.nuc)
if a<-10000 then a = -10000 elseif a>10000 then a = 10000 end
setfield(p, 'penalty', a); head = insert_before(head, widow_Np.first, p)
widow_Bp[1]=p; set_attr(p, attr_icflag, KINSOKU)
@@ -759,8 +760,7 @@ end
-- Nq.last (kern w) .... (glue/kern g) Np.first
local function real_insert(g)
if g then
- head = insert_before(head, Np.first, g)
- Np.first = g
+ head, Np.first = insert_before(head, Np.first, node_inherit_attr(g, Nq.nuc, Np.nuc))
local ngk = Np.gk
if not ngk then Np.gk = g
elseif type(ngk)=="table" then ngk[#ngk+1]=g
@@ -1151,7 +1151,7 @@ local function handle_list_head(par_indented)
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, Np.nuc)
setfield(h, 'penalty', 10000); set_attr(h, attr_icflag, BOXBDD)
end
head = insert_before(head, Np.first, g)
@@ -1424,31 +1424,27 @@ do
return lx
end
end
+ local function special_jaglue_after_inner(lx, lxi, lxi_jfm, kn, bk)
+ local w, st, sh, sto, sho = getglue(kn)
+ if w~=1073741823 then
+ setglue(lx, w, st, sh, sto, sho); set_attr(lx, attr_icflag, lxi)
+ else
+ local m = ltjf_font_metric_table[has_attr(lx, attr_tablshift)]
+ setglue(lx, bk[1], bk[2], bk[3], 0, 0)
+ set_attr(lx, attr_icflag, lxi_jfm)
+ end
+ end
local function special_jaglue_after(lx)
if get_attr_icflag(lx)==SPECIAL_JAGLUE then
lxi=has_attr(lx, attr_yablshift)
if lxi>=PROCESSED_BEGIN_FLAG then
lxi = lxi%PROCESSED_BEGIN_FLAG
if lxi == KANJI_SKIP then
- local w, st, sh, sto, sho = getglue(kanji_skip)
- if w~=1073741823 then
- setglue(lx, w, st, sh, sto, sho); set_attr(lx, attr_icflag, KANJI_SKIP)
- else
- local m = ltjf_font_metric_table[has_attr(lx, attr_tablshift)]
- local bk = m.kanjiskip or null_skip_table
- setglue(lx, bk[1], bk[2], bk[3], 0, 0)
- set_attr(lx, attr_icflag, KANJI_SKIP_JFM)
- end
- elseif lxi == XKANJI_SKIP then
- local w, st, sh, sto, sho = getglue(xkanji_skip)
- if w~=1073741823 then
- setglue(lx, w, st, sh, sto, sho); set_attr(lx, attr_icflag, XKANJI_SKIP)
- else
- local m = ltjf_font_metric_table[has_attr(lx, attr_tablshift)]
- local bk = m.xkanjiskip or null_skip_table
- setglue(lx, bk[1], bk[2], bk[3], 0, 0)
- set_attr(lx, attr_icflag, XKANJI_SKIP_JFM)
- end
+ special_jaglue_after_inner(lx, lxi, KANJI_SKIP_JFM, kanji_skip,
+ ltjf_font_metric_table[has_attr(lx, attr_tablshift)].kanjiskip or null_skip_table)
+ else -- lxi == XKANJI_SKIP
+ special_jaglue_after_inner(lx, lxi, XKANJI_SKIP_JFM, xkanji_skip,
+ ltjf_font_metric_table[has_attr(lx, attr_tablshift)].xkanjiskip or null_skip_table)
end
else
set_attr(lx, attr_icflag, lxi)