• R/O
  • HTTP
  • SSH
  • HTTPS

luatexja: Commit

ソースコードの管理場所


Commit MetaInfo

Revision7d92978e8573163cbe0cfd20b555121cab335d0d (tree)
Time2022-08-16 16:21:59
AuthorHironori Kitagawa <h_kitagawa2001@yaho...>
CommiterHironori Kitagawa

Log Message

use getFOO/setFOO helpers instead of getfield/setfield

Squashed commit of the following:

commit 3ecefd04fb3c2e0dea1764b813ed8840c033d0d0
Author: Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Date: Tue Aug 16 16:20:02 2022 +0900

removed trailing spaces

commit c0c3f5dfabdd5148288a5602ebe7caccb3bd2a8b
Author: Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Date: Sun Aug 14 16:50:55 2022 +0900

{g/s}etlist whenever possible

commit f9e21bbe9598663f8a19bb4152e65c3f7a6e71b4
Author: Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Date: Sun Aug 14 14:23:09 2022 +0900

node.direct.free -> node.direct.flush_node if possible

commit 908d5f6d2e51863129109ed661c4dbaa9b517f9c
Author: Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Date: Sun Aug 14 07:58:42 2022 +0900

fix memory leak of luatexja.jfont.append_italic()

commit 52cce4c3dfc5c9adec707951d8c522bd349a8cb7
Author: Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Date: Sat Aug 13 18:11:39 2022 +0900

ltj-direction.lua: format change

commit 2dc75338b41e7f938b6c36ea1d1307aed1263096
Author: Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Date: Sat Aug 13 11:51:00 2022 +0900

more getfield(n, FOO) -> getFOO(n)

commit 68c576690e0aa423e3c0dd73d6c30ec9b9ddcb22
Author: Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Date: Fri Aug 12 22:05:48 2022 +0900

use {g,s}et{nucleus,sub,sup,shift,penalty,subtype, ...}

commit d49c708434627a038cf20bcb6a2bc8e323fe6109
Author: Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Date: Fri Aug 12 18:14:16 2022 +0900

Use helpers: setnext,{g/s}et{lang.kern}

commit ba1a9ceec35115400ff7ab8b1c71d9b7ceff8ee0
Author: Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Date: Fri Aug 12 05:20:21 2022 +0900

clear boxes which are unused

commit 43093c57ff8c9df3b891c8ca8b0b9b345cac1af3
Author: Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Date: Thu Aug 11 16:10:15 2022 +0900

WIP: unnecessary attribute list

Change Summary

Incremental Difference

--- a/doc/luatexja.dtx
+++ b/doc/luatexja.dtx
@@ -11912,12 +11912,16 @@ direction~whatsit内部のノードリストに,\textit{dir\_box}として格
1191211912 {\fboxsep0pt\fcolorbox{cyan}{white}%
1191311913 {\large\KOZM\ltjjachar"#1#2#3#4}}\ (\texttt{U+#1#2#3#4})%"
1191411914 }
11915+ \def\DH#1#2#3#4{%
11916+ {\fboxsep0pt\fcolorbox{cyan}{white}%
11917+ {\large\ltjjachar"#1#2#3#4}}\ (\texttt{U+#1#2#3#4})%"
11918+ }
1191511919 \caption{\LuaTeX-ja標準で行われる縦組形への置換}
1191611920 \label{tab:vert_replace}\small\centering
1191711921 \begin{tabular}{*{3}{l@{}>{${}\longmapsto{}$}c@{}l}}
1191811922 \toprule
11919- \D 3001&&\D FE11&\D 3002&&\D FE12&\D 3016&&\D FE17\\
11920- \D 3017&&\D FE18&\D 2026&&\D FE19&\D 2025&&\D FE30\\
11923+ \D 3001&&\D FE11&\D 3002&&\D FE12&\D 3016&&\DH FE17\\
11924+ \D 3017&&\DH FE18&\D 2026&&\D FE19&\D 2025&&\D FE30\\
1192111925 \D 2014&&\D FE31&\D 2013&&\D FE32&\D FF3F&&\D FE33\\
1192211926 \D FF08&&\D FE35&\D FF09&&\D FE36&\D FF5B&&\D FE37\\
1192311927 \D FF5D&&\D FE38&\D 3014&&\D FE39&\D 3015&&\D FE3A\\
--- a/src/ltj-adjust.lua
+++ b/src/ltj-adjust.lua
@@ -12,18 +12,26 @@ luatexja.adjust = luatexja.adjust or {}
1212 local to_node = node.direct.tonode
1313 local to_direct = node.direct.todirect
1414
15-local setfield = node.direct.setfield
16-local setglue = luatexja.setglue
1715 local getfield = node.direct.getfield
1816 local getlist = node.direct.getlist
1917 local getid = node.direct.getid
2018 local getfont = node.direct.getfont
2119 local getsubtype = node.direct.getsubtype
20+local getlang = node.direct.getlang
21+local getkern = node.direct.getkern
22+local getshift = node.direct.getshift
23+local getwidth = node.direct.getwidth
24+local getdepth = node.direct.getdepth
25+local setfield = node.direct.setfield
26+local setpenalty = node.direct.setpenalty
27+local setglue = luatexja.setglue
28+local setkern = node.direct.setkern
29+local setlist = node.direct.setlist
2230
2331 local node_traverse_id = node.direct.traverse_id
2432 local node_new = node.direct.new
2533 local node_next = node.direct.getnext
26-local node_free = node.direct.free
34+local node_free = node.direct.flush_node or node.direct.free
2735 local node_prev = node.direct.getprev
2836 local node_tail = node.direct.tail
2937 local has_attr = node.direct.has_attribute
@@ -130,7 +138,7 @@ function get_total_stretched(p)
130138 if not total_sh.order then
131139 total_sh.order, total_sh[-65536] = -1,0.1 -- dummy
132140 end
133- return getfield(p,'width') - dimensions(ph)
141+ return getwidth(p) - dimensions(ph)
134142 end
135143 end
136144
@@ -152,7 +160,7 @@ local function aw_step1(p, total)
152160 -- 無限大のグルーで処理が行われているときは処理中止.
153161 return total, false
154162 end
155- if xi == id_glyph and getfield(x, 'lang')==lang_ja then
163+ if xi == id_glyph and getlang(x)==lang_ja then
156164 -- 和文文字
157165 xc = x
158166 elseif xi == id_hlist and get_attr_icflag(x) == PACKED then
@@ -186,7 +194,7 @@ local function aw_step1(p, total)
186194 end)
187195 if eadt[eadt_ratio[1][1]]~=0 then
188196 local kn = node_new(id_kern, 1)
189- setfield(kn, 'kern', eadt[eadt_ratio[1][1]]); set_attr(kn, attr_icflag, LINEEND)
197+ setkern(kn, eadt[eadt_ratio[1][1]]); set_attr(kn, attr_icflag, LINEEND)
190198 insert_after(head, x, kn)
191199 return eadt_ratio[1][3], true
192200 else
@@ -196,6 +204,7 @@ end
196204
197205 -- step 1 最終行用
198206 local min, max = math.min, math.max
207+local setsubtype = node.direct.setsubtype
199208 local function aw_step1_last(p, total)
200209 local head = getlist(p)
201210 local x = node_tail(head); if not x then return total, false end
@@ -204,7 +213,7 @@ local function aw_step1_last(p, total)
204213 if getid(pf) ~= id_glue or getsubtype(pf) ~= 15 then return total, false end
205214 x = node_prev(node_prev(pf))
206215 local xi, xc = getid(x)
207- if xi == id_glyph and getfield(x, 'lang')==lang_ja then
216+ if xi == id_glyph and getlang(x)==lang_ja then
208217 -- 和文文字
209218 xc = x
210219 elseif xi == id_hlist and get_attr_icflag(x) == PACKED then
@@ -235,11 +244,11 @@ local function aw_step1_last(p, total)
235244 return total, false
236245 end
237246 -- 続行条件2: min(eadt[1], 0)<= \parfillskip <= max(eadt[#eadt], 0)
238- local pfw = getfield(pf, 'width')
247+ local pfw = getwidth(pf)
239248 + (total>0 and getfield(pf, 'stretch') or -getfield(pf, 'shrink')) *getfield(p, 'glue_set')
240249 if pfw<min(0,eadt[1]) or max(0,eadt[#eadt])<pfw then return total, false end
241250 -- \parfillskip を 0 にする
242- total = total + getfield(pf, 'width')
251+ total = total + getwidth(pf)
243252 total_st.order, total_sh.order = 0, 0
244253 if getfield(pf, 'stretch_order')==0 then
245254 local i = at2pr_st[-1]
@@ -253,7 +262,7 @@ local function aw_step1_last(p, total)
253262 total_sh[i] = total_sh[i] - getfield(pf, 'shrink')
254263 total_sh.order = (total_sh[0]==0) and -1 or 0
255264 end
256- setfield(pf, 'subtype', 1); setglue(pf)
265+ setsubtype(pf, 1); setglue(pf)
257266 local eadt_ratio = {}
258267 for i, v in ipairs(eadt) do
259268 local t = total - v
@@ -273,7 +282,7 @@ local function aw_step1_last(p, total)
273282 end)
274283 if eadt[eadt_ratio[1][1]]~=0 then
275284 local kn = node_new(id_kern, 1)
276- setfield(kn, 'kern', eadt[eadt_ratio[1][1]]); set_attr(kn, attr_icflag, LINEEND)
285+ setkern(kn, eadt[eadt_ratio[1][1]]); set_attr(kn, attr_icflag, LINEEND)
277286 insert_after(head, x, kn)
278287 return eadt_ratio[1][3], true
279288 else
@@ -289,9 +298,9 @@ local node_hpack = node.direct.hpack
289298 local function repack(p)
290299 local orig_of, orig_hfuzz, orig_hbad = tex.overfullrule, tex.hfuzz, tex.hbadness
291300 tex.overfullrule=0; tex.hfuzz=1073741823; tex.hbadness=10000
292- local f = node_hpack(getlist(p), getfield(p, 'width'), 'exactly')
301+ local f = node_hpack(getlist(p), getwidth(p), 'exactly')
293302 tex.overfullrule=orig_of; tex.hfuzz=orig_hfuzz; tex.hbadness=orig_hbad
294- setfield(f, 'head', nil)
303+ setlist(f, nil)
295304 setfield(p, 'glue_set', getfield(f, 'glue_set'))
296305 setfield(p, 'glue_order', getfield(f, 'glue_order'))
297306 setfield(p, 'glue_sign', getfield(f, 'glue_sign'))
@@ -358,27 +367,27 @@ do
358367 if not eadt then return end
359368 if eadt[1]~=0 then
360369 local x = node_new(id_kern, 1)
361- setfield(x, 'kern', eadt[1]); set_attr(x, attr_icflag, LINEEND)
370+ setkern(x, eadt[1]); set_attr(x, attr_icflag, LINEEND)
362371 insert_before(head, np.first, x)
363372 end
364373 local eadt_num = #eadt
365374 for i=2,eadt_num do
366375 local x = node_new(id_penalty)
367- setfield(x, 'penalty', 0); set_attr(x, attr_icflag, KINSOKU)
376+ setpenalty(x, 0); set_attr(x, attr_icflag, KINSOKU)
368377 insert_before(head, np.first, x); Bp[#Bp+1] = x
369378 local x = node_new(id_kern, 1)
370- setfield(x, 'kern', eadt[i]-eadt[i-1]); set_attr(x, attr_icflag, LINEEND)
379+ setkern(x, eadt[i]-eadt[i-1]); set_attr(x, attr_icflag, LINEEND)
371380 insert_before(head, np.first, x)
372381 end
373382 if eadt_num>1 or eadt[1]~=0 then
374383 local x = node_new(id_penalty)
375- setfield(x, 'penalty', 0); set_attr(x, attr_icflag, KINSOKU)
384+ setpenalty(x, 0); set_attr(x, attr_icflag, KINSOKU)
376385 insert_before(head, np.first, x); Bp[#Bp+1] = x
377386 local x = node_new(id_kern, 1)
378- setfield(x, 'kern', -eadt[eadt_num]); set_attr(x, attr_icflag, LINEEND)
387+ setkern(x, -eadt[eadt_num]); set_attr(x, attr_icflag, LINEEND)
379388 insert_before(head, np.first, x)
380389 local x = node_new(id_penalty)
381- setfield(x, 'penalty', 10000); set_attr(x, attr_icflag, KINSOKU)
390+ setpenalty(x, 10000); set_attr(x, attr_icflag, KINSOKU)
382391 insert_before(head, np.first, x); Bp[#Bp+1] = x
383392 end
384393 end
@@ -496,7 +505,7 @@ do
496505 local insert = table.insert
497506 local rangedimensions, max = node.direct.rangedimensions, math.max
498507 local function profile_inner(box, range, ind, vmirrored, adj)
499- local w_acc, d_before = getfield(box,'shift'), 0
508+ local w_acc, d_before = getshift(box), 0
500509 local x = getlist(box); local xn = node_next(x)
501510 while x do
502511 local w, h, d
@@ -528,7 +537,7 @@ do
528537 end
529538 if lmin==1/0 then lmin = bw end
530539 return lmin,
531- bw - lmin - getfield(before, 'depth')
540+ bw - lmin - getdepth(before)
532541 - getfield(after, mirrored and 'depth' or 'height')
533542 end
534543 end
--- a/src/ltj-direction.lua
+++ b/src/ltj-direction.lua
@@ -9,25 +9,30 @@ luatexja.direction = {}
99 local attr_dir = luatexbase.attributes['ltj@dir']
1010 local attr_icflag = luatexbase.attributes['ltj@icflag']
1111
12+local dnode = node.direct
1213 local cat_lp = luatexbase.catcodetables['latex-package']
13-local to_node = node.direct.tonode
14-local to_direct = node.direct.todirect
15-local has_attr = node.direct.has_attribute
16-local set_attr = node.direct.set_attribute
17-local insert_before = node.direct.insert_before
18-local insert_after = node.direct.insert_after
19-local getid = node.direct.getid
20-local getsubtype = node.direct.getsubtype
21-local getlist = node.direct.getlist
22-local setfield = node.direct.setfield
23-local getfield = node.direct.getfield
24-local node_new = node.direct.new
25-local node_tail = node.direct.tail
26-local node_free = node.direct.free
27-local node_remove = node.direct.remove
28-local node_next = node.direct.getnext
29-local traverse = node.direct.traverse
30-local traverse_id = node.direct.traverse_id
14+local to_node = dnode.tonode
15+local to_direct = dnode.todirect
16+local has_attr = dnode.has_attribute
17+local set_attr = dnode.set_attribute
18+local insert_before = dnode.insert_before
19+local insert_after = dnode.insert_after
20+local getid = dnode.getid
21+local getsubtype = dnode.getsubtype
22+local getlist = dnode.getlist
23+local getfield = dnode.getfield
24+local getwhd = dnode.getwhd
25+local setfield = dnode.setfield
26+local setwhd = dnode.setwhd
27+local setnext = dnode.setnext
28+local setlist = dnode.setlist
29+
30+local node_new = dnode.new
31+local node_free = dnode.flush_node or dnode.free
32+local node_remove = dnode.remove
33+local node_next = dnode.getnext
34+local traverse = dnode.traverse
35+local traverse_id = dnode.traverse_id
3136 local start_time_measure, stop_time_measure
3237 = ltjb.start_time_measure, ltjb.stop_time_measure
3338 local abs = math.abs
@@ -37,8 +42,6 @@ local id_hlist = node.id 'hlist'
3742 local id_vlist = node.id 'vlist'
3843 local id_whatsit = node.id 'whatsit'
3944 local sid_save = node.subtype 'pdf_save'
40-local sid_restore= node.subtype 'pdf_restore'
41-local sid_matrix = node.subtype 'pdf_setmatrix'
4245 local sid_user = node.subtype 'user_defined'
4346
4447 local tex_nest = tex.nest
@@ -63,14 +66,14 @@ local page_direction
6366 --
6467 local dir_pool
6568 do
66- local node_copy = node.direct.copy
69+ local node_copy = dnode.copy
6770 dir_pool = {}
6871 for _,i in pairs({dir_tate, dir_yoko, dir_dtou, dir_utod}) do
6972 local w = node_new(id_whatsit, sid_user)
70- set_attr(w, attr_dir, i)
73+ dnode.setattributelist(w, nil)
74+ set_attr(w, attr_dir, i); set_attr(w, attr_icflag, 0)
7175 setfield(w, 'user_id', DIR)
72- setfield(w, 'type', 110)
73- setfield(w, 'next', nil)
76+ setfield(w, 'type', 110); setnext(w, nil)
7477 dir_pool[i] = function () return node_copy(w) end
7578 end
7679 end
@@ -221,7 +224,7 @@ do
221224 page_direction = v -- for first call of \yoko (in luatexja-core.sty)
222225 else
223226 if luatexja.debug then
224- luatexja.ext_show_node_list(node.direct.tonode(h),'>> ', texio.write_nl)
227+ luatexja.ext_show_node_list(dnode.tonode(h),'>> ', texio.write_nl)
225228 end
226229 ltjb.package_error(
227230 'luatexja',
@@ -283,7 +286,8 @@ do
283286 if hd then
284287 for p in traverse_id(15, hd) do -- unset
285288 if get_box_dir(p, 0)==0 then
286- setfield(p, 'head', create_dir_whatsit(getlist(p), 'fin_row', ltjs.list_dir))
289+ setfield(p, 'head', create_dir_whatsit(getfield(p, 'head'), 'fin_row', ltjs.list_dir))
290+ -- We cannot use setlist and getlist, since they don't support unset_node
287291 end
288292 end
289293 set_attr(hd, attr_icflag, PROCESSED_BEGIN_FLAG)
@@ -307,7 +311,7 @@ do
307311 -- start 側は ltj-debug.lua に
308312 local new_dir = ltjs.list_dir
309313 for line in traverse_id(id_hlist, to_direct(h)) do
310- setfield(line, 'head', create_dir_whatsit(getlist(line), gc, new_dir) )
314+ setlist(line, create_dir_whatsit(getlist(line), gc, new_dir) )
311315 end
312316 ensure_tex_attr(attr_dir, 0)
313317 return h
@@ -351,7 +355,7 @@ do
351355 local n = node_next(hd)
352356 local w = create_dir_whatsit(hd, gc, ltjs.list_dir)
353357 -- move dir whatsit after hd
354- setfield(hd, 'next', w); setfield(w, 'next', n);
358+ setnext(hd, w); setnext(w, n)
355359 return hd
356360 else return create_dir_whatsit(hd, gc, ltjs.list_dir)
357361 end
@@ -361,6 +365,10 @@ end
361365 -- dir_node に包む方法を書いたテーブル
362366 local dir_node_aux
363367 do
368+ local setkern = dnode.setkern
369+ local setshift = dnode.setshift
370+ local sid_restore= node.subtype 'pdf_restore'
371+ local sid_matrix = node.subtype 'pdf_setmatrix'
364372 local floor = math.floor
365373 local get_h =function (w,h,d) return h end
366374 local get_d =function (w,h,d) return d end
@@ -372,6 +380,21 @@ do
372380 local get_w_neg =function (w,h,d) return -w end
373381 local get_w =function (w,h,d) return w end
374382 local zero = function() return 0 end
383+ local function gen_kern(arg, b, w,h,d,dw,dh,dd)
384+ local nn = node_new(id_kern)
385+ setkern(nn, arg(w, h, d, dw, dh, dd)); return nn
386+ end
387+ local function gen_whatsit(arg)
388+ return node_new(id_whatsit, arg)
389+ end
390+ local function gen_rotate(arg)
391+ local nn = node_new(id_whatsit, sid_matrix)
392+ setfield(nn, 'data', arg); return nn
393+ end
394+ local function gen_box(arg, b, w,h,d,dw,dh,dd)
395+ local nn = b; setnext(b, nil)
396+ setshift(nn, arg(w, h, d, dw, dh, dd)); return nn
397+ end
375398 dir_node_aux = {
376399 [dir_yoko] = { -- yoko を
377400 [dir_tate] = { -- tate 中で組む
@@ -379,20 +402,20 @@ do
379402 height = get_w_half,
380403 depth = get_w_half_rem,
381404 [id_hlist] = {
382- { 'whatsit', sid_save },
383- { 'rotate', '0 1 -1 0' },
384- { 'kern', function(w,h,d,nw,nh,nd) return -nd end },
385- { 'box' , get_h},
386- { 'kern', function(w,h,d,nw,nh,nd) return nd-w end },
387- { 'whatsit', sid_restore },
405+ { gen_whatsit, sid_save },
406+ { gen_rotate, '0 1 -1 0' },
407+ { gen_kern, function(w,h,d,nw,nh,nd) return -nd end },
408+ { gen_box , get_h},
409+ { gen_kern, function(w,h,d,nw,nh,nd) return nd-w end },
410+ { gen_whatsit, sid_restore },
388411 },
389412 [id_vlist] = {
390- { 'whatsit', sid_save },
391- { 'rotate', '0 1 -1 0' },
392- { 'kern' , zero },
393- { 'box' , function(w,h,d,nw,nh,nd) return -nh-nd end },
394- { 'kern', get_h_d_neg},
395- { 'whatsit', sid_restore },
413+ { gen_whatsit, sid_save },
414+ { gen_rotate, '0 1 -1 0' },
415+ { gen_kern , zero },
416+ { gen_box , function(w,h,d,nw,nh,nd) return -nh-nd end },
417+ { gen_kern, get_h_d_neg},
418+ { gen_whatsit, sid_restore },
396419 },
397420 },
398421 [dir_dtou] = { -- dtou 中で組む
@@ -400,19 +423,19 @@ do
400423 height = get_w,
401424 depth = zero,
402425 [id_hlist] = {
403- { 'whatsit', sid_save },
404- { 'rotate', '0 -1 1 0' },
405- { 'kern', function(w,h,d,nw,nh,nd) return -nh end },
406- { 'box', get_d_neg },
407- { 'kern', function(w,h,d,nw,nh,nd) return nh-w end },
408- { 'whatsit', sid_restore },
426+ { gen_whatsit, sid_save },
427+ { gen_rotate, '0 -1 1 0' },
428+ { gen_kern, function(w,h,d,nw,nh,nd) return -nh end },
429+ { gen_box, get_d_neg },
430+ { gen_kern, function(w,h,d,nw,nh,nd) return nh-w end },
431+ { gen_whatsit, sid_restore },
409432 },
410433 [id_vlist] = {
411- { 'whatsit', sid_save },
412- { 'rotate', '0 -1 1 0' },
413- { 'kern', get_h_d_neg },
414- { 'box', zero },
415- { 'whatsit', sid_restore },
434+ { gen_whatsit, sid_save },
435+ { gen_rotate, '0 -1 1 0' },
436+ { gen_kern, get_h_d_neg },
437+ { gen_box, zero },
438+ { gen_whatsit, sid_restore },
416439 },
417440 },
418441 },
@@ -422,19 +445,19 @@ do
422445 height = get_w,
423446 depth = zero,
424447 [id_hlist] = {
425- { 'whatsit', sid_save },
426- { 'rotate', '0 -1 1 0' },
427- { 'kern', function (w,h,d,nw,nh,nd) return -nh end },
428- { 'box' , get_d_neg },
429- { 'kern', function (w,h,d,nw,nh,nd) return nh-w end },
430- { 'whatsit', sid_restore },
448+ { gen_whatsit, sid_save },
449+ { gen_rotate, '0 -1 1 0' },
450+ { gen_kern, function (w,h,d,nw,nh,nd) return -nh end },
451+ { gen_box , get_d_neg },
452+ { gen_kern, function (w,h,d,nw,nh,nd) return nh-w end },
453+ { gen_whatsit, sid_restore },
431454 },
432455 [id_vlist] = {
433- { 'whatsit', sid_save },
434- { 'rotate', '0 -1 1 0' },
435- { 'kern', get_h_d_neg },
436- { 'box', zero },
437- { 'whatsit', sid_restore },
456+ { gen_whatsit, sid_save },
457+ { gen_rotate, '0 -1 1 0' },
458+ { gen_kern, get_h_d_neg },
459+ { gen_box, zero },
460+ { gen_whatsit, sid_restore },
438461 },
439462 },
440463 [dir_dtou] = { -- dtou 中で組む
@@ -442,18 +465,18 @@ do
442465 height = get_d,
443466 depth = get_h,
444467 [id_hlist] = {
445- { 'whatsit', sid_save },
446- { 'rotate', '-1 0 0 -1' },
447- { 'kern', get_w_neg },
448- { 'box', function (w,h,d,nw,nh,nd) return h-nd end },
449- { 'whatsit', sid_restore },
468+ { gen_whatsit, sid_save },
469+ { gen_rotate, '-1 0 0 -1' },
470+ { gen_kern, get_w_neg },
471+ { gen_box, function (w,h,d,nw,nh,nd) return h-nd end },
472+ { gen_whatsit, sid_restore },
450473 },
451474 [id_vlist] = {
452- { 'whatsit', sid_save },
453- { 'rotate', '-1 0 0 -1' },
454- { 'kern', get_h_d_neg },
455- { 'box', get_w_neg },
456- { 'whatsit', sid_restore },
475+ { gen_whatsit, sid_save },
476+ { gen_rotate, '-1 0 0 -1' },
477+ { gen_kern, get_h_d_neg },
478+ { gen_box, get_w_neg },
479+ { gen_whatsit, sid_restore },
457480 },
458481 },
459482 },
@@ -463,20 +486,20 @@ do
463486 height = get_w,
464487 depth = zero,
465488 [id_hlist] = {
466- { 'whatsit', sid_save },
467- { 'rotate', '0 1 -1 0' },
468- { 'kern', function (w,h,d,nw,nh,nd) return -nd end },
469- { 'box', get_h },
470- { 'kern', function (w,h,d,nw,nh,nd) return nd-w end },
471- { 'whatsit', sid_restore },
489+ { gen_whatsit, sid_save },
490+ { gen_rotate, '0 1 -1 0' },
491+ { gen_kern, function (w,h,d,nw,nh,nd) return -nd end },
492+ { gen_box, get_h },
493+ { gen_kern, function (w,h,d,nw,nh,nd) return nd-w end },
494+ { gen_whatsit, sid_restore },
472495 },
473496 [id_vlist] = {
474- { 'kern', zero },
475- { 'whatsit', sid_save },
476- { 'rotate', '0 1 -1 0' },
477- { 'box', function (w,h,d,nw,nh,nd) return -nd-nh end },
478- { 'kern', get_h_d_neg },
479- { 'whatsit', sid_restore },
497+ { gen_kern, zero },
498+ { gen_whatsit, sid_save },
499+ { gen_rotate, '0 1 -1 0' },
500+ { gen_box, function (w,h,d,nw,nh,nd) return -nd-nh end },
501+ { gen_kern, get_h_d_neg },
502+ { gen_whatsit, sid_restore },
480503 },
481504 },
482505 [dir_tate] = { -- tate 中で組む
@@ -484,19 +507,19 @@ do
484507 height = get_d,
485508 depth = get_h,
486509 [id_hlist] = {
487- { 'whatsit', sid_save },
488- { 'rotate', '-1 0 0 -1' },
489- { 'kern', get_w_neg },
490- { 'box', function (w,h,d,nw,nh,nd) return h-nd end },
491- { 'whatsit', sid_restore },
510+ { gen_whatsit, sid_save },
511+ { gen_rotate, '-1 0 0 -1' },
512+ { gen_kern, get_w_neg },
513+ { gen_box, function (w,h,d,nw,nh,nd) return h-nd end },
514+ { gen_whatsit, sid_restore },
492515 },
493516 [id_vlist] = {
494- { 'whatsit', sid_save },
495- { 'rotate', ' -1 0 0 -1' },
496- { 'kern', function (w,h,d,nw,nh,nd) return -nh-nd end },
497- { 'box', get_w_neg },
498- { 'kern', function (w,h,d,nw,nh,nd) return nh+nd-h-d end },
499- { 'whatsit', sid_restore },
517+ { gen_whatsit, sid_save },
518+ { gen_rotate, ' -1 0 0 -1' },
519+ { gen_kern, function (w,h,d,nw,nh,nd) return -nh-nd end },
520+ { gen_box, get_w_neg },
521+ { gen_kern, function (w,h,d,nw,nh,nd) return nh+nd-h-d end },
522+ { gen_whatsit, sid_restore },
500523 },
501524 },
502525 },
@@ -508,8 +531,7 @@ end
508531 function get_box_dir(b, default)
509532 start_time_measure 'get_box_dir'
510533 local dir = has_attr(b, attr_dir) or 0
511- local bh = getfield(b,'head')
512- -- b は insert node となりうるので getlist() は使えない
534+ local bh = getfield(b, 'head') -- We cannot use getlist since b may be an unset_node.
513535 local c
514536 if bh~=0 then -- bh != nil
515537 for bh in traverse_id(id_whatsit, bh) do
@@ -548,7 +570,7 @@ do
548570 local d = hd
549571 nh, hd = node_remove(nh, hd)
550572 if is_copy==true and (not dir_backup) then
551- dir_backup = d; setfield(dir_backup, 'next', nil)
573+ dir_backup = d; setnext(dir_backup, nil)
552574 else
553575 node_free(d)
554576 end
@@ -556,7 +578,7 @@ do
556578 hd = node_next(hd)
557579 end
558580 end
559- setfield(bd, 'head', nh)
581+ setlist(bd, nh)
560582 end
561583 end
562584 if luatexja.global_temp and tex.globaldefs~=luatexja.global_temp then
@@ -569,8 +591,8 @@ do
569591 if b then
570592 local bd = to_direct(b)
571593 if dir_backup then
572- setfield(dir_backup, 'next', getlist(bd))
573- setfield(bd, 'head', dir_backup)
594+ setnext(dir_backup, getlist(bd))
595+ setlist(bd, dir_backup)
574596 dir_backup = nil
575597 end
576598 end
@@ -587,23 +609,26 @@ local function unwrap_dir_node(b, head, box_dir)
587609 if head then
588610 nh = insert_before(head, b, bh)
589611 nh, nb = node_remove(nh, b)
590- setfield(b, 'next', nil)
591- node_free(b)
612+ setnext(b, nil); node_free(b)
592613 end
593614 local shift_old, b_dir, wh = nil, get_box_dir(bh, 0)
594615 if wh then
595- node.direct.flush_list(getfield(wh, 'value'))
616+ dnode.flush_list(getfield(wh, 'value'))
596617 setfield(wh, 'value', nil)
597618 end
598619 return nh, nb, bh, b_dir
599620 end
600621
601622 -- is_manual: 寸法変更に伴うものか?
602-local function create_dir_node(b, b_dir, new_dir, is_manual)
623+local create_dir_node
624+do
625+ local getdir = dnode.getdir
626+ local setdir = dnode.setdir
627+ local setshift = dnode.setshift
628+
629+create_dir_node = function(b, b_dir, new_dir, is_manual)
603630 local info = dir_node_aux[b_dir%dir_math_mod][new_dir%dir_math_mod]
604- local w = getfield(b, 'width')
605- local h = getfield(b, 'height')
606- local d = getfield(b, 'depth')
631+ local w, h, d = getwhd(b)
607632 local db = node_new(getid(b)) -- dir_node
608633 set_attr(db, attr_dir,
609634 new_dir + (is_manual and dir_node_manual or dir_node_auto))
@@ -611,13 +636,11 @@ local function create_dir_node(b, b_dir, new_dir, is_manual)
611636 set_attr(b, attr_icflag, PROCESSED)
612637 ensure_tex_attr(attr_dir, 0)
613638 ensure_tex_attr(attr_icflag, 0)
614- setfield(db, 'dir', getfield(b, 'dir'))
615- setfield(db, 'shift', 0)
616- setfield(db, 'width', info.width(w,h,d))
617- setfield(db, 'height', info.height(w,h,d))
618- setfield(db, 'depth', info.depth(w,h,d))
639+ setdir(db, getdir(b)); setshift(db, 0)
640+ setwhd(db, info.width(w,h,d), info.height(w,h,d), info.depth(w,h,d))
619641 return db
620642 end
643+end
621644
622645 -- 異方向のボックスの処理
623646 local make_dir_whatsit, process_dir_node
@@ -633,14 +656,14 @@ do
633656 -- 既に b の中身にあるwhatsit
634657 if (box_dir<dir_node_auto) and (not dn) then
635658 bh = create_dir_whatsit(bh, 'make_dir_whatsit', dir_yoko)
636- dn = bh; setfield(b, 'head', bh)
659+ dn = bh; setlist(b, bh)
637660 end
638661 if box_dir%dir_math_mod==new_dir then
639662 if box_dir>=dir_node_auto then
640663 -- dir_node としてカプセル化されている
641664 local _, dnc = get_box_dir(b, 0)
642665 if dnc then -- free all other dir_node
643- node.direct.flush_list(getfield(dnc, 'value'))
666+ dnode.flush_list(getfield(dnc, 'value'))
644667 setfield(dnc, 'value', nil)
645668 end
646669 set_attr(b, attr_dir, box_dir%dir_math_mod + dir_node_auto)
@@ -670,18 +693,13 @@ do
670693 db=x; break
671694 end
672695 end
673- node.direct.flush_list(getfield(dn, 'value'))
696+ dnode.flush_list(getfield(dn, 'value'))
674697 setfield(dn, 'value', nil)
675698 db = db or create_dir_node(b, box_dir, new_dir, false)
676- local w = getfield(b, 'width')
677- local h = getfield(b, 'height')
678- local d = getfield(b, 'depth')
679- local dn_w = getfield(db, 'width')
680- local dn_h = getfield(db, 'height')
681- local dn_d = getfield(db, 'depth')
699+ local w, h, d = getwhd(b)
682700 nh, nb = insert_before(head, b, db), nil
683701 nh, nb = node_remove(nh, b)
684- setfield(b, 'next', nil); setfield(db, 'head', b)
702+ setnext(b, nil); setlist(db, b)
685703 ret, flag = db, true
686704 return nh, nb, ret, flag
687705 end
@@ -701,7 +719,7 @@ do
701719 end
702720
703721 -- lastbox
704- local node_prev = (node.direct~=node) and node.direct.getprev or node.prev
722+ local node_prev = dnode.getprev
705723 local id_glue = node.id 'glue'
706724 local function lastbox_hook()
707725 start_time_measure 'box_primitive_hook'
@@ -715,20 +733,20 @@ do
715733 if p and getid(p)==id_glue and getsubtype(p)==12 then -- tabskip
716734 local np = node_next(p); local npid = getid(np)
717735 if npid==id_hlist or npid==id_vlist then
718- setfield(b, 'head', create_dir_whatsit(p, 'align', get_box_dir(np, 0)))
736+ setlist(b, create_dir_whatsit(p, 'align', get_box_dir(np, 0)))
719737 end
720738 end
721739 local box_dir = get_box_dir(b, 0)
722740 if box_dir>= dir_node_auto then -- unwrap dir_node
723741 local p = node_prev(b)
724742 local dummy1, dummy2, nb = unwrap_dir_node(b, nil, box_dir)
725- setfield(p, 'next', nb); tex_nest[tex_nest.ptr].tail = to_node(nb)
726- setfield(b, 'next', nil); setfield(b, 'head', nil)
743+ setnext(p, nb); tex_nest[tex_nest.ptr].tail = to_node(nb)
744+ setnext(b, nil); setlist(b, nil)
727745 node_free(b); b = nb
728746 end
729747 local _, wh = get_box_dir(b, 0) -- clean dir_node attached to the box
730748 if wh then
731- node.direct.flush_list(getfield(wh, 'value'))
749+ dnode.flush_list(getfield(wh, 'value'))
732750 setfield(wh, 'value', nil)
733751 end
734752 end
@@ -756,9 +774,7 @@ do
756774 end
757775 end
758776 if not_found then
759- local w = getfield(s, 'width')
760- local h = getfield(s, 'height')
761- local d = getfield(s, 'depth')
777+ local w, h, d = getwhd(s)
762778 setdimen('ltj@tempdima',
763779 dir_node_aux[s_dir][l_dir][key](w,h,d))
764780 end
@@ -797,7 +813,7 @@ do
797813 if s_dir ~= l_dir then
798814 if not wh then
799815 wh = create_dir_whatsit(getlist(s), 'set_box_dim', s_dir)
800- setfield(s, 'head', wh)
816+ setlist(s, wh)
801817 end
802818 local db
803819 local dnh = getfield(wh, 'value')
@@ -808,7 +824,7 @@ do
808824 end
809825 if not db then
810826 db = create_dir_node(s, s_dir, l_dir, true)
811- setfield(db, 'next', dnh)
827+ setnext(db, dnh)
812828 setfield(wh, 'value',to_node(db))
813829 end
814830 setfield(db, key, scan_dimen())
@@ -817,15 +833,12 @@ do
817833 setfield(s, key, scan_dimen())
818834 if wh then
819835 -- change dimension of dir_nodes which are created "automatically"
820- local bw, bh, bd
821- = getfield(s,'width'), getfield(s, 'height'), getfield(s, 'depth')
836+ local bw, bh, bd = getwhd(s)
822837 for x in traverse(getfield(wh, 'value')) do
823838 local x_dir = has_attr(x, attr_dir)
824839 if x_dir<dir_node_manual then
825840 local info = dir_node_aux[s_dir][x_dir%dir_node_auto]
826- setfield(x, 'width', info.width(bw,bh,bd))
827- setfield(x, 'height', info.height(bw,bh,bd))
828- setfield(x, 'depth', info.depth(bw,bh,bd))
841+ setwhd(x, info.width(bw,bh,bd), info.height(bw,bh,bd), info.depth(bw,bh,bd))
829842 end
830843 end
831844 end
@@ -849,16 +862,12 @@ do
849862 else
850863 local sid, b = getid(s), getlist(s)
851864 local info = dir_node_aux[get_box_dir(b,dir_yoko)%dir_math_mod][b_dir%dir_node_auto]
852- local bw, bh, bd
853- = getfield(b,'width'), getfield(b, 'height'), getfield(b, 'depth')
854- local sw, sh, sd
855- = getfield(s,'width'), getfield(s, 'height'), getfield(s, 'depth')
865+ local bw, bh, bd = getwhd(b)
866+ local sw, sh, sd = getwhd(s)
856867 if set_box_dim_common(key, b, l_dir) and b_dir<dir_node_manual then
857868 -- re-calculate dimension of s, if s is created "automatically"
858869 if b_dir<dir_node_manual then
859- setfield(s, 'width', info.width(bw,bh,bd))
860- setfield(s, 'height', info.height(bw,bh,bd))
861- setfield(s, 'depth', info.depth(bw,bh,bd))
870+ setwhd(s, info.width(bw,bh,bd), info.height(bw,bh,bd), info.depth(bw,bh,bd))
862871 end
863872 end
864873 end
@@ -889,7 +898,7 @@ do
889898 end
890899
891900 do
892- local getbox, setbox, copy_list = tex.getbox, tex.setbox, node.direct.copy_list
901+ local getbox, setbox, copy_list = tex.getbox, tex.setbox, dnode.copy_list
893902 -- raise, lower
894903 function luatexja.direction.raise_box()
895904 start_time_measure 'box_primitive_hook'
@@ -923,6 +932,7 @@ end
923932 -- adjust
924933 do
925934 local id_adjust = node.id 'adjust'
935+ local last_node = dnode.last_node
926936 local scan_keyword = token.scan_keyword
927937 function luatexja.direction.adjust_begin()
928938 if scan_keyword 'pre' then tex.sprint(cat_lp, '\\ltj@@vadjust@pre')
@@ -940,7 +950,7 @@ do
940950 'luatexja',
941951 'Direction Incompatible',
942952 "\\vadjust's argument and outer vlist must have same direction.")
943- node.direct.last_node()
953+ node_free(last_node())
944954 end
945955 end
946956 stop_time_measure 'box_primitive_hook'
@@ -960,7 +970,7 @@ do
960970 a = node.tail(tex.lists.page_head); ad = to_direct(a)
961971 end
962972 if a and getid(ad)==id_ins then
963- local h = getfield(ad, 'head')
973+ local h = getlist(ad)
964974 if getid(h)==id_whatsit and
965975 getsubtype(h)==sid_user and getfield(h, 'user_id')==DIR then
966976 local n = h; h = node_remove(h,h)
@@ -972,7 +982,7 @@ do
972982 end
973983 end
974984 ensure_tex_attr(attr_dir, 0)
975- setfield(ad, 'head', h)
985+ setlist(ad, h)
976986 end
977987 stop_time_measure 'box_primitive_hook'
978988 end
@@ -995,7 +1005,7 @@ do
9951005 and node_next(bh) then
9961006 ltjs.list_dir = has_attr(bh, attr_dir)
9971007 local q = node_next(p)
998- setfield(p, 'head', node_remove(bh,bh,bh))
1008+ setlist(p, (node_remove(bh,bh,bh)))
9991009 split_dir_head = bh
10001010 end
10011011 end
@@ -1053,38 +1063,22 @@ do
10531063 local function finalize_dir_node(db,new_dir)
10541064 local b = getlist(db)
10551065 while b and ((getid(b)~=id_hlist) and (getid(b)~=id_vlist)) do
1056- local ob = b; b = node_remove(b,b); setfield(db, 'head', b);
1066+ local ob = b; b = node_remove(b,b); setlist(db, b);
10571067 node_free(ob)
10581068 end
10591069 finalize_inner(b)
1060- local w = getfield(b, 'width')
1061- local h = getfield(b, 'height')
1062- local d = getfield(b, 'depth')
1063- local dn_w = getfield(db, 'width')
1064- local dn_h = getfield(db, 'height')
1065- local dn_d = getfield(db, 'depth')
1070+ local w, h, d = getwhd(b)
1071+ local dw, dh, dd = getwhd(db)
10661072 local db_head, db_tail
10671073 local t = dir_node_aux[get_box_dir(b, dir_yoko)%dir_math_mod][new_dir]
10681074 t = t and t[getid(b)]; if not t then return end
10691075 for _,v in ipairs(t) do
1070- local cmd, arg, nn = v[1], v[2]
1071- if cmd=='kern' then
1072- nn = node_new(id_kern, 1)
1073- setfield(nn, 'kern', arg(w, h, d, dn_w, dn_h, dn_d))
1074- elseif cmd=='whatsit' then
1075- nn = node_new(id_whatsit, arg)
1076- elseif cmd=='rotate' then
1077- nn = node_new(id_whatsit, sid_matrix)
1078- setfield(nn, 'data', arg)
1079- elseif cmd=='box' then
1080- nn = b; setfield(b, 'next', nil)
1081- setfield(nn, 'shift', arg(w, h, d, dn_w, dn_h, dn_d))
1082- end
1076+ local nn = v[1](v[2], b, w, h, d, dw, dh, dd)
10831077 if db_head then
10841078 insert_after(db_head, db_tail, nn)
10851079 db_tail = nn
10861080 else
1087- setfield(db, 'head', nn)
1081+ setlist(db, nn)
10881082 db_head, db_tail = nn, nn
10891083 end
10901084 end
@@ -1092,6 +1086,7 @@ do
10921086
10931087 tex.setattribute(attr_dir, dir_yoko)
10941088 local shipout_temp = node_new(id_hlist)
1089+ dnode.setattributelist(shipout_temp, nil)
10951090 tex.setattribute(attr_dir, 0)
10961091
10971092 finalize_inner = function (box)
@@ -1107,17 +1102,17 @@ do
11071102 end
11081103 end
11091104 end
1110- local copy = node.direct.copy
1105+ local copy = dnode.copy
11111106 function luatexja.direction.shipout_lthook (head)
11121107 start_time_measure 'box_primitive_hook'
11131108 local a = to_direct(head)
11141109 local a_dir = get_box_dir(a, dir_yoko)
11151110 if a_dir~=dir_yoko then
11161111 local b = create_dir_node(a, a_dir, dir_yoko, false)
1117- setfield(b, 'head', a); a = b
1112+ setlist(b, a); a = b
11181113 end
1119- setfield(shipout_temp, 'head', a); finalize_inner(shipout_temp)
1120- a = copy(getlist(shipout_temp)); setfield(shipout_temp, 'head',nil)
1114+ setlist(shipout_temp, a); finalize_inner(shipout_temp)
1115+ a = copy(getlist(shipout_temp)); setlist(shipout_temp, nil)
11211116 stop_time_measure 'box_primitive_hook'
11221117 return to_node(a)
11231118 end
--- a/src/ltj-inputbuf.lua
+++ b/src/ltj-inputbuf.lua
@@ -8,8 +8,6 @@ luatexja.load_module 'charrange'; local ltjc = luatexja.charrange
88 local utflen = utf.len
99 local utfbyte = utf.byte
1010 local utfchar = utf.char
11-local node_new = node.new
12-local node_free = node.free
1311 local id_glyph = node.id 'glyph'
1412 local getcatcode, getcount = tex.getcatcode, tex.getcount
1513 local ltjc_is_japanese_char_curlist = ltjc.is_japanese_char_curlist
--- a/src/ltj-jfmglue.lua
+++ b/src/ltj-jfmglue.lua
@@ -3,7 +3,7 @@
33 --
44 luatexbase.provides_module({
55 name = 'luatexja.jfmglue',
6- date = '2022-02-09',
6+ date = '2022-08-16',
77 description = 'Insertion process of JFM glues, [x]kanjiskip and others',
88 })
99 luatexja.jfmglue = luatexja.jfmglue or {}
@@ -19,23 +19,29 @@ local pairs = pairs
1919 --local to_node = node.direct.tonode
2020 --local to_direct = node.direct.todirect
2121
22-local setfield = node.direct.setfield
23-local setglue = luatexja.setglue
2422 local getfield = node.direct.getfield
2523 local getid = node.direct.getid
2624 local getfont = node.direct.getfont
2725 local getlist = node.direct.getlist
2826 local getchar = node.direct.getchar
27+local getglue = luatexja.getglue
2928 local getsubtype = node.direct.getsubtype
29+local getshift = node.direct.getshift
30+local getwidth = node.direct.getwidth
31+local getdepth = node.direct.getdepth
32+local getpenalty = node.direct.getpenalty
33+local setfield = node.direct.setfield
34+local setglue = luatexja.setglue
35+local setshift = node.direct.setshift
3036 local if_lang_ja
3137 do
3238 local lang_ja = luatexja.lang_ja
3339 local getlang = node.direct.getlang
3440 -- glyph with font number 0 (\nullfont) is always considered an ALchar node
35- if_lang_ja = getlang
36- and function (n) return (getlang(n)==lang_ja)and(getfont(n)~=0) end
37- or function (n) return (getfield(n,'lang')==lang_ja)and(getfont(n)~=0) end
41+ if_lang_ja = function (n) return (getlang(n)==lang_ja)and(getfont(n)~=0) end
3842 end
43+local setpenalty = node.direct.setpenalty
44+local setkern = node.direct.setkern
3945
4046 local has_attr = node.direct.has_attribute
4147 local set_attr = node.direct.set_attribute
@@ -48,7 +54,7 @@ local ltjf_find_char_class = ltjf.find_char_class
4854 local node_new = luatexja.dnode_new
4955 local node_copy = node.direct.copy
5056 local node_tail = node.direct.tail
51-local node_free = node.direct.free
57+local node_free = node.direct.flush_node or node.direct.free
5258 local node_remove = node.direct.remove
5359 local node_inherit_attr = luatexja.node_inherit_attr
5460
@@ -131,8 +137,6 @@ end
131137 -- penalty 値の計算
132138 local add_penalty
133139 do
134-local setpenalty = node.direct.setpenalty or function(n, a) setfield(n,'penalty',a) end
135-local getpenalty = node.direct.getpenalty or function(n) return getfield(n,'penalty') end
136140 function add_penalty(p,e)
137141 local pp = getpenalty(p)
138142 if (pp>-10000) and (pp<10000) then
@@ -206,7 +210,7 @@ local function check_box(box_ptr, box_end)
206210 if find_first_char then first_char = s; find_first_char = false end
207211 last_char = s; found_visible_node = true
208212 else
209- if getfield(p, 'shift')==0 then
213+ if getshift(p)==0 then
210214 last_char = nil
211215 if check_box(getlist(p), nil) then found_visible_node = true end
212216 find_first_char = false
@@ -311,6 +315,8 @@ do -- 002 ---------------------------------------
311315 local attr_jchar_class = luatexbase.attributes['ltj@charclass']
312316 local attr_jchar_code = luatexbase.attributes['ltj@charcode']
313317 local font_getfont = font.getfont
318+ local setwhd = node.direct.setwhd
319+ local setdir = node.direct.setdir
314320 local function calc_np_notdef(lp)
315321 if not font_getfont(getfont(lp)).characters[getchar(lp)] then
316322 local ln = node_next(lp)
@@ -342,8 +348,8 @@ function calc_np_aux_glyph_common(lp, acc_flag)
342348 local first_glyph, last_glyph = lp
343349 set_attr(lp, attr_icflag, PROCESSED); Np.last = lp
344350 local y_adjust = has_attr(lp,attr_ablshift) or 0
345- local node_depth = getfield(lp, 'depth') + min(y_adjust, 0)
346- local adj_depth = (y_adjust>0) and (getfield(lp, 'depth') + y_adjust) or 0
351+ local node_depth = getdepth(lp) + min(y_adjust, 0)
352+ local adj_depth = (y_adjust>0) and (getdepth(lp) + y_adjust) or 0
347353 setfield(lp, 'yoffset', getfield(lp, 'yoffset') - y_adjust); lp = node_next(lp)
348354 local lx=lp
349355 while lx do
@@ -355,8 +361,8 @@ function calc_np_aux_glyph_common(lp, acc_flag)
355361 -- 欧文文字
356362 last_glyph = lx; set_attr(lx, attr_icflag, PROCESSED); Np.last = lx
357363 y_adjust = has_attr(lx,attr_ablshift) or 0
358- node_depth = max(getfield(lx, 'depth') + min(y_adjust, 0), node_depth)
359- adj_depth = (y_adjust>0) and max(getfield(lx, 'depth') + y_adjust, adj_depth) or adj_depth
364+ node_depth = max(getdepth(lx) + min(y_adjust, 0), node_depth)
365+ adj_depth = (y_adjust>0) and max(getdepth(lx) + y_adjust, adj_depth) or adj_depth
360366 setfield(lx, 'yoffset', getfield(lx, 'yoffset') - y_adjust); lx = node_next(lx)
361367 elseif lid==id_kern then
362368 local ls = getsubtype(lx)
@@ -366,7 +372,7 @@ function calc_np_aux_glyph_common(lp, acc_flag)
366372 if getid(lx)==id_glyph then
367373 setfield(lx, 'yoffset', getfield(lx, 'yoffset') - (has_attr(lx,attr_ablshift) or 0))
368374 else -- アクセントは上下にシフトされている
369- setfield(lx, 'shift', getfield(lx, 'shift') + (has_attr(lx,attr_ablshift) or 0))
375+ setshift(lx, getshift(lx) + (has_attr(lx,attr_ablshift) or 0))
370376 end
371377 set_attr(lx, attr_icflag, PROCESSED)
372378 lx = node_next(lx); set_attr(lx, attr_icflag, PROCESSED)
@@ -385,8 +391,7 @@ function calc_np_aux_glyph_common(lp, acc_flag)
385391 local r
386392 if adj_depth>node_depth then
387393 r = node_new(id_rule,3,first_glyph)
388- setfield(r, 'width', 0); setfield(r, 'height', 0)
389- setfield(r, 'depth',adj_depth); setfield(r, 'dir', tex_dir)
394+ setwhd(r, 0, 0, adj_depth); setdir(r, tex_dir)
390395 set_attr(r, attr_icflag, PROCESSED)
391396 end
392397 if last_glyph then
@@ -436,7 +441,7 @@ calc_np_auxtable = {
436441 head, lp, op, flag = ltjd_make_dir_whatsit(head, lp, list_dir, 'jfm hlist')
437442 set_attr(op, attr_icflag, PROCESSED)
438443 Np.first = Np.first or op; Np.last = op; Np.nuc = op;
439- if (flag or getfield(op, 'shift')~=0) then
444+ if (flag or getshift(op)~=0) then
440445 Np.id = id_box_like
441446 else
442447 Np.id = id_hlist
@@ -522,7 +527,7 @@ calc_np_auxtable = {
522527 if getid(lp)==id_glyph then -- アクセント本体
523528 setfield(lp, 'yoffset', getfield(lp, 'yoffset') - (has_attr(lp,attr_ablshift) or 0))
524529 else -- アクセントは上下にシフトされている
525- setfield(lp, 'shift', getfield(lp, 'shift') + (has_attr(lp,attr_ablshift) or 0))
530+ setshift(lp, getshift(lp) + (has_attr(lp,attr_ablshift) or 0))
526531 end
527532 set_attr(lp, attr_icflag, PROCESSED); lp = node_next(lp)
528533 set_attr(lp, attr_icflag, PROCESSED); lp = node_next(lp)
@@ -692,7 +697,7 @@ local function handle_penalty_normal(post, pre, g)
692697 if (a~=0 and not(g and getid(g)==id_kern)) then
693698 local p = node_new(id_penalty, nil, Nq.nuc, Np.nuc)
694699 if a<-10000 then a = -10000 elseif a>10000 then a = 10000 end
695- setfield(p, 'penalty', a); head = insert_before(head, Np.first, p)
700+ setpenalty(p, a); head = insert_before(head, Np.first, p)
696701 Bp[1]=p; set_attr(p, attr_icflag, KINSOKU)
697702 end
698703 else for _, v in pairs(Bp) do add_penalty(v,a) end
@@ -706,7 +711,7 @@ local function handle_penalty_always(post, pre, g)
706711 if not (g and getid(g)==id_glue) or a~=0 then
707712 local p = node_new(id_penalty, nil, Nq.nuc, Np.nuc)
708713 if a<-10000 then a = -10000 elseif a>10000 then a = 10000 end
709- setfield(p, 'penalty', a); head = insert_before(head, Np.first, p)
714+ setpenalty(p, a); head = insert_before(head, Np.first, p)
710715 Bp[1]=p; set_attr(p, attr_icflag, KINSOKU)
711716 end
712717 else for _, v in pairs(Bp) do add_penalty(v,a) end
@@ -718,7 +723,7 @@ local function handle_penalty_suppress(post, pre, g)
718723 if #Bp == 0 then
719724 if g and getid(g)==id_glue then
720725 local p = node_new(id_penalty, nil, Nq.nuc, Np.nuc)
721- setfield(p, 'penalty', 10000); head = insert_before(head, Np.first, p)
726+ setpenalty(p, 10000); head = insert_before(head, Np.first, p)
722727 Bp[1]=p; set_attr(p, attr_icflag, KINSOKU)
723728 end
724729 else
@@ -733,7 +738,7 @@ local function handle_penalty_jwp()
733738 if a~=0 then
734739 local p = node_new(id_penalty, widow_Np.nuc)
735740 if a<-10000 then a = -10000 elseif a>10000 then a = 10000 end
736- setfield(p, 'penalty', a); head = insert_before(head, widow_Np.first, p)
741+ setpenalty(p, a); head = insert_before(head, widow_Np.first, p)
737742 widow_Bp[1]=p; set_attr(p, attr_icflag, KINSOKU)
738743 end
739744 else for _, v in pairs(widow_Bp) do add_penalty(v,a) end
@@ -746,7 +751,7 @@ local function new_jfm_glue(mc, bc, ac)
746751 local g = mc[bc][ac]
747752 if g then
748753 if g[1] then
749- local k = node_new(id_kern, 1); setfield(k, 'kern', g[1])
754+ local k = node_new(id_kern, 1); setkern(k, g[1])
750755 set_attr(k, attr_icflag, FROM_JFM)
751756 return k, g.ratio, false, false, false
752757 else
@@ -779,6 +784,7 @@ do
779784 local bg_ak = 2*id_glue - id_kern
780785 local bk_ag = 2*id_kern - id_glue
781786 local bk_ak = 2*id_kern - id_kern
787+ local getkern = node.direct.getkern
782788
783789 local function blend_diffmet(b, a, rb, ra)
784790 return round(luatexja.jfmglue.diffmet_rule((1-rb)*b+rb*a, (1-ra)*b+ra*a))
@@ -800,24 +806,24 @@ do
800806 db, da = 0, 1
801807 end
802808 if not gb then
803- if ga then gb = node_new(id_kern, 1); setfield(gb, 'kern', 0)
809+ if ga then gb = node_new(id_kern, 1); setkern(gb, 0)
804810 else return nil end
805811 elseif not ga then
806- ga = node_new(id_kern, 1); setfield(ga, 'kern', 0)
812+ ga = node_new(id_kern, 1); setkern(ga, 0)
807813 end
808814 local gbw, gaw, gbst, gast, gbsto, gasto, gbsh, gash, gbsho, gasho
809815 if getid(gb)==id_glue then
810816 gbw, gbst, gbsh, gbsto, gbsho = getglue(gb)
811817 else
812- gbw = getfield(gb, 'kern')
818+ gbw = getkern(gb)
813819 end
814820 if getid(ga)==id_glue then
815821 gaw, gast, gash, gasto, gasho = getglue(ga)
816822 else
817- gaw = getfield(ga, 'kern')
823+ gaw = getkern(ga)
818824 end
819825 if not (gbst or gast) then -- 両方とも kern
820- setfield(gb, 'kern', blend_diffmet(gbw, gaw, db, da))
826+ setkern(gb, blend_diffmet(gbw, gaw, db, da))
821827 node_free(ga); return gb
822828 else
823829 local gr = gb
@@ -858,7 +864,7 @@ do
858864 local st = bp and (bp*getfield(kanji_skip, 'stretch')) or 0
859865 local sh = bh and (bh*getfield(kanji_skip, 'shrink')) or 0
860866 setglue(g,
861- bn and (bn*getfield(kanji_skip, 'width')) or 0,
867+ bn and (bn*getwidth(kanji_skip)) or 0,
862868 st, sh,
863869 (st==0) and 0 or getfield(kanji_skip, 'stretch_order'),
864870 (sh==0) and 0 or getfield(kanji_skip, 'shrink_order'))
@@ -942,13 +948,14 @@ do
942948 elseif flag then
943949 return node_copy(xkanji_skip)
944950 else
945- local g = node_new(id_glue);
951+ local g = node_new(id_glue)
952+ local w, st, sh, sto, sho = getglue(xkanji_skip)
946953 setglue(g,
947- bn and (bn*getfield(xkanji_skip, 'width')) or 0,
948- bp and (bp*getfield(xkanji_skip, 'stretch')) or 0,
949- bh and (bh*getfield(xkanji_skip, 'shrink')) or 0,
950- bp and getfield(xkanji_skip, 'stretch_order') or 0,
951- bh and getfield(xkanji_skip, 'shrink_order') or 0)
954+ bn and (bn*w) or 0,
955+ bp and (bp*st) or 0,
956+ bh and (bh*sh) or 0,
957+ bp and sto or 0,
958+ bh and sho or 0)
952959 set_attr(g, attr_icflag, XKANJI_SKIP_JFM)
953960 return g
954961 end
@@ -1153,7 +1160,7 @@ local function handle_list_head(par_indented)
11531160 set_attr(g, attr_icflag, BOXBDD)
11541161 if getid(g)==id_glue and #Bp==0 then
11551162 local h = node_new(id_penalty, nil, Np.nuc)
1156- setfield(h, 'penalty', 10000); set_attr(h, attr_icflag, BOXBDD)
1163+ setpenalty(h, 10000); set_attr(h, attr_icflag, BOXBDD)
11571164 end
11581165 head = insert_before(head, Np.first, g)
11591166 end
@@ -1196,18 +1203,15 @@ do
11961203 attr_ablshift = is_dir_tate and attr_tablshift or attr_yablshift
11971204 local TEMP = node_new(id_glue)
11981205 -- TEMP is a dummy node, which will be freed at the end of the callback.
1199- -- ithout this node, set_attr(kanji_skip, ...) somehow creates an "orphaned" attribute list.
1200-
1206+ -- Without this node, set_attr(kanji_skip, ...) somehow creates an "orphaned" attribute list.
12011207 do
12021208 kanji_skip, kanjiskip_jfm_flag = skip_table_to_glue(KSK)
12031209 set_attr(kanji_skip, attr_icflag, KANJI_SKIP)
12041210 end
1205-
12061211 do
12071212 xkanji_skip, xkanjiskip_jfm_flag = skip_table_to_glue(XSK)
12081213 set_attr(xkanji_skip, attr_icflag, XKANJI_SKIP)
12091214 end
1210-
12111215 if mode then
12121216 -- the current list is to be line-breaked:
12131217 -- hbox from \parindent is skipped.
@@ -1218,7 +1222,7 @@ do
12181222 or (lpi==id_local)) do
12191223 if (lpi==id_hlist) and (lps==3) then
12201224 Np.char, par_indented = 'parbdd', 'parbdd'
1221- Np.width = getfield(lp, 'width')
1225+ Np.width = getwidth(lp)
12221226 end
12231227 lp=node_next(lp); lpi, lps = getid(lp), getsubtype(lp) end
12241228 return lp, node_tail(head), par_indented, TEMP
@@ -1375,6 +1379,7 @@ do
13751379 local attr_tablshift = luatexbase.attributes['ltj@tablshift']
13761380 local getcount, abs, scan_keyword = tex.getcount, math.abs, token.scan_keyword
13771381 local tex_nest = tex.nest
1382+ local tex_getattr = tex.getattribute
13781383 local get_current_jfont
13791384 do
13801385 local attr_curjfnt = luatexbase.attributes['ltj@curjfnt']
@@ -1382,7 +1387,7 @@ do
13821387 local dir_tate = luatexja.dir_table.dir_tate
13831388 local get_dir_count = ltjd.get_dir_count
13841389 function get_current_jfont()
1385- return tex.getattribute((get_dir_count()==dir_tate) and attr_curtfnt or attr_curjfnt)
1390+ return tex_getattr((get_dir_count()==dir_tate) and attr_curtfnt or attr_curjfnt)
13861391 end
13871392 end
13881393 -- \insertxkanjiskip
@@ -1417,7 +1422,6 @@ do
14171422 insert_k_skip_common(KSK, "kanjiskip", KANJI_SKIP, KANJI_SKIP_JFM)
14181423 end
14191424 -- callback
1420- local getglue = luatexja.getglue
14211425 local function special_jaglue(lx)
14221426 local lxi = get_attr_icflag(lx)
14231427 if lxi==SPECIAL_JAGLUE then
--- a/src/ltj-jfont.lua
+++ b/src/ltj-jfont.lua
@@ -3,7 +3,7 @@
33 --
44 luatexbase.provides_module({
55 name = 'luatexja.jfont',
6- date = '2021-11-06',
6+ date = '2022-08-16',
77 description = 'Loader for Japanese fonts',
88 })
99
@@ -18,11 +18,12 @@ local getid = node.direct.getid
1818 local to_direct = node.direct.todirect
1919
2020 local node_new = node.direct.new
21-local node_free = node.direct.free
21+local node_free = node.direct.flush_node or node.direct.free
2222 local has_attr = node.direct.has_attribute
2323 local set_attr = node.direct.set_attribute
2424 local round = tex.round
2525 local font_getfont = font.getfont
26+local setkern = node.direct.setkern
2627
2728 local attr_icflag = luatexbase.attributes['ltj@icflag']
2829 local attr_curjfnt = luatexbase.attributes['ltj@curjfnt']
@@ -1036,7 +1037,7 @@ do
10361037 has_attr(p, (get_dir_count()==dir_tate) and attr_curtfnt or attr_curjfnt)
10371038 ]
10381039 local g = new_ic_kern()
1039- setfield(g, 'kern', j.char_type[find_char_class(getchar(p), j)].italic)
1040+ setkern(g, j.char_type[find_char_class(getchar(p), j)].italic)
10401041 node_write(g); ensure_tex_attr(attr_icflag, 0)
10411042 else
10421043 local f = getfont(p)
@@ -1044,7 +1045,7 @@ do
10441045 if h then
10451046 if h.characters[getchar(p)] and h.characters[getchar(p)].italic then
10461047 local g = new_ic_kern()
1047- setfield(g, 'kern', h.characters[getchar(p)].italic)
1048+ setkern(g, h.characters[getchar(p)].italic)
10481049 node_write(g); ensure_tex_attr(attr_icflag, 0)
10491050 end
10501051 end
--- a/src/ltj-lineskip.lua
+++ b/src/ltj-lineskip.lua
@@ -18,12 +18,15 @@ local node_prev = node.direct.getprev
1818 local node_next = node.direct.getnext
1919 local getid = node.direct.getid
2020 local getsubtype = node.direct.getsubtype
21+local getdepth = node.direct.getdepth
22+local getheight = node.direct.getheight
2123 local texget = tex.get
2224
2325 local node_getglue = node.getglue
24-local setglue = node.direct.setglue
26+local setglue = luatexja.setglue
27+local setsubtype = node.direct.setsubtype
2528 local function copy_glue (new_glue, old_glue_name, subtype, new_w)
26- setfield(new_glue, 'subtype', subtype)
29+ setsubtype(new_glue, subtype)
2730 local w,st,sp,sto,spo = texget(old_glue_name, true)
2831 setglue(new_glue, new_w or w, st, sp, sto, spo)
2932 end
@@ -61,7 +64,7 @@ local function adjust_glue(nh)
6164 p = node_prev(p); pid = getid(p)
6265 end
6366 if pid==id_hlist and getid(n)==id_hlist then
64- local normal = bw - getfield(p, 'depth') - getfield(n, 'height')
67+ local normal = bw - getdepth(p) - getheight(n)
6568 local lmin, adj = ltj_profiler(p, n, false, bw)
6669 ltj_skip(lmin or normal, x, adj, normal, bw)
6770 end
@@ -96,7 +99,7 @@ local function dir_adjust_append_vlist(b, loc, prev, mirrored)
9699 end
97100 if tail then
98101 if getid(tail)==id_hlist and getid(new_b)==id_hlist then
99- if getfield(tail, 'depth')==prev then
102+ if getdepth(tail)==prev then
100103 lmin, adj = ltj_profiler(tail, new_b, mirrored, bw)
101104 end
102105 end
--- a/src/ltj-math.lua
+++ b/src/ltj-math.lua
@@ -14,8 +14,15 @@ local getfield = node.direct.getfield
1414 local getid = node.direct.getid
1515 local getsubtype = node.direct.getsubtype
1616 local getlist = node.direct.getlist
17--- getlist cannot be used for sub_box nodes. Use instead λp. getfield(p, 'head')
1817 local getchar = node.direct.getchar
18+local getnucleus = node.direct.getnucleus
19+local getsup = node.direct.getsup
20+local getsub = node.direct.getsub
21+local setnext = node.direct.setnext
22+local setnucleus = node.direct.setnucleus
23+local setsup = node.direct.setsup
24+local setsub = node.direct.setsub
25+local setlist = node.direct.setlist
1926
2027 local to_node = node.direct.tonode
2128 local to_direct = node.direct.todirect
@@ -24,7 +31,7 @@ local node_traverse = node.direct.traverse
2431 local node_new = node.direct.new
2532 local node_next = node.direct.getnext
2633 local node_remove = node.direct.remove
27-local node_free = node.direct.free
34+local node_free = node.direct.flush_node or node.direct.free
2835 local has_attr = node.direct.has_attribute
2936 local set_attr = node.direct.set_attribute
3037 local tex_getcount = tex.getcount
@@ -66,13 +73,13 @@ local list_dir
6673
6774 -- vcenter noad は軸に揃えるため,欧文ベースライン補正がかかる
6875 local function conv_vcenter(sb)
69- local h = getfield(sb, 'head'); local hd = getlist(h)
76+ local h = getlist(sb) ; local hd = getlist(h)
7077 if getid(hd)==id_whatsit and getsubtype(hd)==sid_user
7178 and getfield(hd, 'user_id')==DIR then
7279 local d = node_next(hd)
7380 if getid(d)==id_vlist and has_attr(d, attr_dir)>=dir_node_auto then
74- node_free(hd); setfield(h, 'head', nil); node_free(h)
75- setfield(sb, 'head', d); set_attr(d, attr_icflag, 0)
81+ node_free(hd); setlist(h, nil); node_free(h)
82+ setlist(sb, d); set_attr(d, attr_icflag, 0)
7683 end
7784 end
7885 return sb
@@ -85,12 +92,12 @@ local function conv_jchar_to_hbox(head, sty)
8592 local pid = getid(p)
8693 if pid == id_simple or pid == id_accent then
8794 if getsubtype(p)==12 then
88- conv_vcenter(getfield(p, 'nucleus'))
95+ conv_vcenter(getnucleus(p))
8996 else
90- setfield(p, 'nucleus', cjh_A(getfield(p, 'nucleus'), sty))
97+ setnucleus(p, cjh_A(getnucleus(p), sty))
9198 end
92- setfield(p, 'sub', cjh_A(getfield(p, 'sub'), sty+1))
93- setfield(p, 'sup', cjh_A(getfield(p, 'sup'), sty+1))
99+ setsub(p, cjh_A(getsub(p), sty+1))
100+ setsup(p, cjh_A(getsup(p), sty+1))
94101 elseif pid == id_choice then
95102 setfield(p, 'display', cjh_A(getfield(p, 'display'), 0))
96103 setfield(p, 'text', cjh_A(getfield(p, 'text'), 0))
@@ -100,9 +107,9 @@ local function conv_jchar_to_hbox(head, sty)
100107 setfield(p, 'num', cjh_A(getfield(p, 'num'), sty+1))
101108 setfield(p, 'denom', cjh_A(getfield(p, 'denom'), sty+1))
102109 elseif pid == id_radical then
103- setfield(p, 'nucleus', cjh_A(getfield(p, 'nucleus'), sty))
104- setfield(p, 'sub', cjh_A(getfield(p, 'sub'), sty+1))
105- setfield(p, 'sup', cjh_A(getfield(p, 'sup'), sty+1))
110+ setnucleus(p, cjh_A(getnucleus(p), sty))
111+ setsub(p, cjh_A(getsub(p), sty+1))
112+ setsup(p, cjh_A(getsup(p), sty+1))
106113 if getfield(p, 'degree') then
107114 setfield(p, 'degree', cjh_A(getfield(p, 'degree'), sty + 1))
108115 end
@@ -124,14 +131,16 @@ local MJS = luatexja.stack_table_index.MJS
124131 local MJSS = luatexja.stack_table_index.MJSS
125132 local capsule_glyph_math = ltjw.capsule_glyph_math
126133 local is_ucs_in_japanese_char = ltjc.is_ucs_in_japanese_char_direct
134+local setfont = node.direct.setfont
135+local setchar = node.direct.setchar
127136
128137 cjh_A = function (p, sty)
129138 if not p then return nil
130139 else
131140 local pid = getid(p)
132141 if pid == id_sub_mlist then
133- if getfield(p, 'head') then
134- setfield(p, 'head', conv_jchar_to_hbox(getfield(p, 'head'), sty))
142+ if getlist(p) then
143+ setlist(p, conv_jchar_to_hbox(getlist(p), sty))
135144 end
136145 elseif pid == id_mchar then
137146 local pc, fam = getchar (p), has_attr(p, attr_jfam) or -1
@@ -139,19 +148,19 @@ cjh_A = function (p, sty)
139148 local f = ltjs.get_stack_table(MJT + 0x100 * sty + fam, -1, tex_getcount('ltj@@stack'))
140149 if f ~= -1 then
141150 local q = node_new(id_sub_box)
142- local r = node_new(id_glyph); setfield(r, 'next', nil)
143- setfield(r, 'char', pc); setfield(r, 'font', f); setfield(r, 'subtype', 256)
151+ local r = node_new(id_glyph, 256); setnext(r, nil)
152+ setchar(r, pc); setfont(r, f)
144153 local k = has_attr(r,attr_ykblshift) or 0; set_attr(r, attr_ykblshift, 0)
145154 -- ltj-setwidth 内で実際の位置補正はおこなうので,補正量を退避
146155 local met = ltjf_font_metric_table[f]
147156 r = capsule_glyph_math(r, met, met.char_type[ltjf_find_char_class(pc, met)]);
148- setfield(q, 'head', r); node_free(p); p=q; set_attr(r, attr_yablshift, k)
157+ setlist(q, r); node_free(p); p=q; set_attr(r, attr_yablshift, k)
149158 end
150159 end
151- elseif pid == id_sub_box and getfield(p, 'head') then
160+ elseif pid == id_sub_box and getlist(p) then
152161 -- \hbox で直に与えられた内容は上下位置を補正する必要はない
153- local h = getfield(p, 'head'); h = ltjd_make_dir_whatsit(h, h, list_dir, 'math')
154- setfield(p, 'head', h); set_attr(h, attr_icflag, PROCESSED)
162+ local h = getlist(p); h = ltjd_make_dir_whatsit(h, h, list_dir, 'math')
163+ setlist(p, h); set_attr(h, attr_icflag, PROCESSED)
155164 end
156165 end
157166 return p
--- a/src/ltj-otf.lua
+++ b/src/ltj-otf.lua
@@ -21,12 +21,16 @@ local getid = node.direct.getid
2121 local getfont = node.direct.getfont
2222 local getchar = node.direct.getchar
2323 local getsubtype = node.direct.getsubtype
24+local setchar = node.direct.setchar
25+local setfont = node.direct.setfont
26+local setlang = node.direct.setlang
27+
2428 local to_node = node.direct.tonode
2529 local to_direct = node.direct.todirect
2630 local node_new = node.direct.new
2731 local node_remove = node.direct.remove
2832 local node_next = node.direct.getnext
29-local node_free = node.direct.free
33+local node_free = node.direct.flush_node or node.direct.free
3034 local has_attr = node.direct.has_attribute
3135 local set_attr = node.direct.set_attribute
3236 local unset_attr = node.direct.unset_attribute
@@ -162,11 +166,10 @@ local function extract(head)
162166 if getsubtype(p)==sid_user then
163167 local puid = getfield(p, 'user_id')
164168 if puid==OTF then
165- local g = node_new(id_glyph)
166- setfield(g, 'subtype', 0)
167- setfield(g, 'char', getfield(p, 'value'))
168- local v = has_attr(p, attr_curfnt); setfield(g, 'font', v)
169- setfield(g, 'lang', lang_ja)
169+ local g = node_new(id_glyph, 0)
170+ setchar(g, getfield(p, 'value'))
171+ setfont(g, has_attr(p, attr_curfnt))
172+ setlang(g, lang_ja)
170173 set_attr(g, attr_kblshift, has_attr(p, attr_kblshift))
171174 head = node_insert_after(head, p, g)
172175 head = node_remove(head, p)
--- a/src/ltj-pretreat.lua
+++ b/src/ltj-pretreat.lua
@@ -17,7 +17,7 @@ local getfont = node.direct.getfont
1717 local getchar = node.direct.getchar
1818 local getfield = node.direct.getfield
1919 local getsubtype = node.direct.getsubtype
20-local getlang = node.direct.getlang or function (n) return getfield(n,'lang') end
20+local getlang = node.direct.getlang
2121
2222 local pairs = pairs
2323 local floor = math.floor
@@ -26,7 +26,7 @@ local set_attr = node.direct.set_attribute
2626 local node_traverse = node.direct.traverse
2727 local node_remove = node.direct.remove
2828 local node_next = node.direct.getnext
29-local node_free = node.direct.free
29+local node_free = node.direct.flush_node or node.direct.free
3030 local node_end_of_math = node.direct.end_of_math
3131 local tex_getcount = tex.getcount
3232
@@ -51,9 +51,9 @@ local PROCESSED_BEGIN_FLAG = luatexja.icflag_table.PROCESSED_BEGIN_FLAG
5151 local dir_tate = luatexja.dir_table.dir_tate
5252 local lang_ja = luatexja.lang_ja
5353
54-local setlang = node.direct.setlang or function(n,l) setfield(n,'lang',l) end
55-local setfont = node.direct.setfont or function(n,l) setfield(n,'font',l) end
56-local setchar = node.direct.setchar or function(n,l) setfield(n,'char',l) end
54+local setlang = node.direct.setlang
55+local setfont = node.direct.setfont
56+local setchar = node.direct.setchar
5757
5858 ------------------------------------------------------------------------
5959 -- MAIN PROCESS STEP 1: replace fonts
@@ -86,7 +86,7 @@ do
8686 { __index = function() return node_next end, })
8787 local id_boundary = node.id('boundary')
8888 local node_new, insert_before = node.direct.new, node.direct.insert_before
89- local setsubtype = node.direct.setsubtype or function(n,l) setfield(n,'subtype',l) end
89+ local setsubtype = node.direct.setsubtype
9090 local function suppress_hyphenate_ja (h)
9191 start_time_measure('ltj_hyphenate')
9292 head = to_direct(h)
@@ -135,10 +135,13 @@ do
135135 end
136136
137137 -- mode: true iff this function is called from hpack_filter
138+local set_box_stack_level
139+do
138140 local ltjs_report_stack_level = ltjs.report_stack_level
139141 local ltjf_font_metric_table = ltjf.font_metric_table
140142 local font_getfont = font.getfont
141-local function set_box_stack_level(head, mode)
143+local traverse_id = node.direct.traverse_id
144+function set_box_stack_level(head, mode)
142145 local box_set, cl = 0, tex.currentgrouplevel + 1
143146 if mode then
144147 for _,p in pairs(wt) do
@@ -150,7 +153,7 @@ local function set_box_stack_level(head, mode)
150153 ltjs_report_stack_level(tex_getcount('ltj@@stack') + box_set)
151154 for _,p in pairs(wtd) do node_free(p) end
152155 if ltjs.list_dir == dir_tate then
153- for p in node.direct.traverse_id(id_glyph,to_direct(head)) do
156+ for p in traverse_id(id_glyph,to_direct(head)) do
154157 if has_attr(p, attr_icflag, 0) and getlang(p)==lang_ja then
155158 local nf = ltjf_replace_altfont( has_attr(p, attr_curtfnt) or getfont(p) , ltjs_orig_char_table[p])
156159 setfont(p, nf)
@@ -163,6 +166,7 @@ local function set_box_stack_level(head, mode)
163166 end
164167 return head
165168 end
169+end
166170
167171 -- CALLBACKS
168172 ltjb.add_to_callback('hpack_filter',
--- a/src/ltj-ruby.lua
+++ b/src/ltj-ruby.lua
@@ -3,7 +3,7 @@
33 --
44 luatexbase.provides_module({
55 name = 'luatexja.ruby',
6- date = '2022-06-25',
6+ date = '2022-08-14',
77 description = 'Ruby annotation',
88 })
99 luatexja.ruby = {}
@@ -13,21 +13,36 @@ luatexja.load_module 'base'; local ltjb = luatexja.base
1313 local to_node = node.direct.tonode
1414 local to_direct = node.direct.todirect
1515
16-local setfield = node.direct.setfield
17-local setglue = luatexja.setglue
1816 local getfield = node.direct.getfield
1917 local getid = node.direct.getid
2018 local getfont = node.direct.getfont
2119 local getlist = node.direct.getlist
2220 local getchar = node.direct.getchar
2321 local getsubtype = node.direct.getsubtype
22+local getkern = node.direct.getkern
23+local getwidth = node.direct.getwidth
24+local getheight = node.direct.getheight
25+local getdepth = node.direct.getdepth
26+local getwhd = node.direct.getwhd
27+local setfield = node.direct.setfield
28+local setglue = luatexja.setglue
29+local setkern = node.direct.setkern
30+local setnext = node.direct.setnext
31+local setshift = node.direct.setshift
32+local setwidth = node.direct.setwidth
33+local setheight = node.direct.setheight
34+local setdepth = node.direct.setdepth
35+local setwhd = node.direct.setwhd
36+local setlist = node.direct.setlist
2437
2538 local node_new = node.direct.new
2639 local node_remove = node.direct.remove
2740 local node_next = node.direct.getnext
28-local node_copy, node_free, node_tail = node.direct.copy, node.direct.free, node.direct.tail
41+local node_copy, node_tail = node.direct.copy, node.direct.tail
42+local node_free = node.direct.flush_node or node.direct.free
2943 local has_attr, set_attr = node.direct.has_attribute, node.direct.set_attribute
3044 local insert_before, insert_after = node.direct.insert_before, node.direct.insert_after
45+local hpack = node.direct.hpack
3146
3247 local id_hlist = node.id 'hlist'
3348 local id_vlist = node.id 'vlist'
@@ -157,25 +172,22 @@ do
157172 end
158173 set_attr(nh, attr_icflag,
159174 get_attr_icflag(nh) + PROCESSED_BEGIN_FLAG)
160- setfield(node_tail(h), 'next', nh)
161- setfield(f, 'head', nil); node_free(f)
162- setfield(b, 'head', nil); node_free(b)
175+ setnext(node_tail(h), nh)
176+ setlist(f, nil); node_free(f)
177+ setlist(b, nil); node_free(b)
163178 local g = luatexja.jfmglue.main(h,false)
164- return node.direct.hpack(g)
179+ return hpack(g)
165180 else
166181 return f
167182 end
168183 elseif b then
169184 return b
170185 else
171- local h = node_new(id_hlist)
172- setfield(h, 'subtype', 0)
173- setfield(h, 'width', 0)
174- setfield(h, 'height', 0)
175- setfield(h, 'depth', 0)
186+ local h = node_new(id_hlist, 0)
187+ setwhd(h, 0, 0, 0)
176188 setfield(h, 'glue_set', 0)
177189 setfield(h, 'glue_order', 0)
178- setfield(h, 'head', nil)
190+ setlist(h, nil)
179191 return h
180192 end
181193 end
@@ -205,7 +217,7 @@ do
205217 -- pre, middle, post: 伸縮比率
206218 -- prenw, postnw: 前後の自然長 (sp)
207219 local h = getlist(box);
208- local hh, hd = getfield(box, 'height'), getfield(box, 'depth')
220+ local _, hh, hd = getwhd(box)
209221 local hx = h
210222 while hx do
211223 local hic = has_attr(hx, attr_icflag) or 0
@@ -214,14 +226,13 @@ do
214226 or ((hic<=FROM_JFM+63) and (hic>=FROM_JFM)) then
215227 -- この 5 種類の空白をのばす
216228 if getid(hx) == id_kern then
217- local k = node_new(id_glue)
218- setglue(k, getfield(hx, 'kern'), round(middle*65536), 0,
229+ local k = node_new(id_glue, 0)
230+ setglue(k, getkern(hx), round(middle*65536), 0,
219231 2, 0)
220- setfield(k, 'subtype', 0);
221232 h = insert_after(h, hx, k);
222233 h = node_remove(h, hx); node_free(hx); hx = k
223234 else -- glue
224- setglue(hx, getfield(hx, 'width'), round(middle*65536), 0,
235+ setglue(hx, getwidth(hx), round(middle*65536), 0,
225236 2, 0)
226237 end
227238 end
@@ -236,10 +247,9 @@ do
236247 setglue(k, postnw, round(post*65536), 0, 2, 0)
237248 insert_after(h, node_tail(h), k);
238249 -- hpack
239- setfield(box, 'head', nil); node_free(box)
240- box = node.direct.hpack(h, new_width, 'exactly')
241- setfield(box, 'height', hh)
242- setfield(box, 'depth', hd)
250+ setlist(box, nil); node_free(box)
251+ box = hpack(h, new_width, 'exactly')
252+ setheight(box, hh); setdepth(box, hd)
243253 return box
244254 end
245255 end
@@ -280,7 +290,7 @@ function luatexja.ruby.texiface(rst, rtlr, rtlp)
280290 else
281291 local f, eps = true, rst.eps
282292 for i = 1,#rtlr do
283- if getfield(rtlr[i], 'width') > getfield(rtlp[i], 'width') + eps then
293+ if getwidth(rtlr[i]) > getwidth(rtlp[i]) + eps then
284294 f = false; break
285295 end
286296 end
@@ -304,8 +314,8 @@ end
304314 -- r, p の中身のノードは再利用される
305315 local function enlarge_parent(r, p, tmp_tbl, no_begin, no_end)
306316 -- r: ルビ部分の格納された box,p: 同,親文字
307- local rwidth = getfield(r, 'width')
308- local sumprot = rwidth - getfield(p, 'width') -- >0
317+ local rwidth = getwidth(r)
318+ local sumprot = rwidth - getwidth(p) -- >0
309319 local pre_intrusion, post_intrusion
310320 local ppre, pmid, ppost = tmp_tbl.ppre, tmp_tbl.pmid, tmp_tbl.ppost
311321 local mapre, mapost = tmp_tbl.mapre, tmp_tbl.mapost
@@ -338,12 +348,11 @@ local function enlarge_parent(r, p, tmp_tbl, no_begin, no_end)
338348 pre_intrusion = min(mapre, pre_intrusion + round(ppre*getfield(p, 'glue_set')*65536))
339349 post_intrusion = min(mapost, post_intrusion + round(ppost*getfield(p, 'glue_set')*65536))
340350 end
341- setfield(r, 'shift', -pre_intrusion)
351+ setshift(r, -pre_intrusion)
342352 local rwidth = rwidth - pre_intrusion - post_intrusion
343- setfield(r, 'width', rwidth)
344- setfield(p, 'width', rwidth)
353+ setwidth(r, rwidth); setwidth(p, rwidth)
345354 local ps = getlist(p)
346- setfield(ps, 'width', getfield(ps, 'width') - pre_intrusion)
355+ setwidth(ps, getwidth(ps) - pre_intrusion)
347356 local orig_post_intrusion, post_jfmgk = post_intrusion, false
348357 if no_end then
349358 if orig_post_intrusion > tmp_tbl.after_jfmgk then
@@ -370,47 +379,46 @@ local function new_ruby_box(r, p, tmp_tbl, no_begin, no_end)
370379 imode = floor(imode/2); rpost = imode%8;
371380 imode = (imode-rpost)/8; rmid = imode%8;
372381 imode = (imode-rmid)/8; rpre = imode%8
373- if getfield(r, 'width') > getfield(p, 'width') then -- change the width of p
382+ if getwidth(r) > getwidth(p) then -- change the width of p
374383 r, p, post_intrusion, post_jfmgk = enlarge_parent(r, p, tmp_tbl, no_begin, no_end)
375- elseif getfield(r, 'width') < getfield(p, 'width') then -- change the width of r
376- r = enlarge(r, getfield(p, 'width'), rpre, rmid, rpost, 0, 0)
384+ elseif getwidth(r) < getwidth(p) then -- change the width of r
385+ r = enlarge(r, getwidth(p), rpre, rmid, rpost, 0, 0)
377386 post_intrusion = 0
378387 local need_repack = false
379388 -- margin が大きくなりすぎた時の処理
380389 if round(rpre*getfield(r, 'glue_set')*65536) > max_margin then
381390 local ps = getlist(r); need_repack = true
382- setfield(ps, 'width', max_margin)
391+ setwidth(ps, max_margin)
383392 setfield(ps, 'stretch', 1) -- 全く伸縮しないのも困る
384393 end
385394 if round(rpost*getfield(r, 'glue_set')*65536) > max_margin then
386395 local ps = node_tail(getlist(r)); need_repack = true
387- setfield(ps, 'width', max_margin)
396+ setwidth(ps, max_margin)
388397 setfield(ps, 'stretch', 1) -- 全く伸縮しないのも困る
389398 end
390399 if need_repack then
391400 local rt = r
392- r = node.direct.hpack(getlist(r), getfield(r, 'width'), 'exactly')
393- setfield(rt, 'head', nil); node_free(rt);
401+ r = hpack(getlist(r), getwidth(r), 'exactly')
402+ setlist(rt, nil); node_free(rt);
394403 end
395404 end
396405 local a, k = node_new(id_rule), node_new(id_kern, 1)
397- setfield(a, 'width', 0); setfield(a, 'height', 0)
398- setfield(a, 'depth', 0); setfield(k, 'kern', tmp_tbl.intergap)
406+ setwhd(a, 0, 0, 0); setkern(k, tmp_tbl.intergap)
399407 insert_after(r, r, a); insert_after(r, a, k);
400- insert_after(r, k, p); setfield(p, 'next', nil)
401- if tmp_tbl.rubydepth >= 0 then setfield(r, 'depth', tmp_tbl.rubydepth) end
402- if tmp_tbl.baseheight >= 0 then setfield(p, 'height', tmp_tbl.baseheight) end
403- a = node.direct.vpack(r); setfield(a, 'shift', 0)
408+ insert_after(r, k, p); setnext(p, nil)
409+ if tmp_tbl.rubydepth >= 0 then setdepth(r, tmp_tbl.rubydepth) end
410+ if tmp_tbl.baseheight >= 0 then setheight(p, tmp_tbl.baseheight) end
411+ a = node.direct.vpack(r); setshift(a, 0)
404412 set_attr(a, attr_ruby, post_intrusion)
405413 set_attr(a, attr_ruby_post_jfmgk, post_jfmgk and 1 or 0)
406- if rsmash or getfield(a, 'height')<getfield(p, 'height') then
414+ if rsmash or getheight(a)<getheight(p) then
407415 local k = node_new(id_kern, 1)
408- setfield(k, 'kern', -getfield(a, 'height')+getfield(p, 'height'))
409- setfield(a, 'head', k); insert_before(r, r, k)
410- setfield(a, 'height', getfield(p, 'height'))
416+ setkern(k, -getheight(a)+getheight(p))
417+ setlist(a, k); insert_before(r, r, k)
418+ setheight(a, getheight(p))
411419 end
412420
413- return a, getfield(r, 'width'), post_intrusion, post_jfmgk
421+ return a, getwidth(r), post_intrusion, post_jfmgk
414422 end
415423
416424
@@ -474,7 +482,7 @@ local function pre_low_cal_box(w, cmp)
474482 -- w.value の node list 更新.
475483 local nt = wv
476484 node.direct.flush_list(node_next(wv))
477- for i = 1, 2*cmp+1 do setfield(nt, 'next', kf[i]); nt = kf[i] end
485+ for i = 1, 2*cmp+1 do setnext(nt, kf[i]); nt = kf[i] end
478486
479487 if cmp==1 then solve_1(coef)
480488 elseif cmp==2 then solve_2(coef)
@@ -506,10 +514,8 @@ local function pre_low_app_node(head, w, cmp, coef, ht, dp)
506514 nt = w
507515 for i = 1, cmp do
508516 -- rule
509- local nta = node_new(id_rule);
510- setfield(nta, 'width', coef[i*2][2*cmp+2])
511- setfield(nta, 'height', ht); setfield(nta, 'depth', dp)
512- setfield(nta, 'subtype', 0)
517+ local nta = node_new(id_rule, 0);
518+ setwhd(nta, coef[i*2][2*cmp+2], ht, dp)
513519 insert_after(head, nt, nta)
514520 set_attr(nta, attr_ruby, 2*i+1)
515521 -- glue
@@ -561,7 +567,7 @@ local function pre_high(ahead)
561567 local coef = pre_low_cal_box(n, rst.count)
562568 local s = node_tail(nv) --ルビ文字
563569 head, n = pre_low_app_node(
564- head, n, rst.count, coef, getfield(s, 'height'), getfield(s, 'depth')
570+ head, n, rst.count, coef, getheight(s), getdepth(s)
565571 )
566572 else
567573 n = first_whatsit(node_next(n))
@@ -602,7 +608,7 @@ do
602608 local deg, hn = (fn-1)/2, wv
603609 for i = 1, deg do hn = node_next(hn) end;
604610 node_remove(wv, hn)
605- setfield(hn, 'next', nil)
611+ setnext(hn, nil)
606612 insert_after(ch, rs[1], hn)
607613 set_attr(hn, attr_icflag, PROCESSED)
608614 write_aux(wv, has_attr(hn, attr_ruby), has_attr(hn, attr_ruby_post_jfmgk))
@@ -612,7 +618,7 @@ do
612618 for i = 1, cmp+deg-1 do hn = node_next(hn) end
613619 -- -1 is needed except the case hn = 3,
614620 -- because a ending-line form is removed already from the list
615- node_remove(wv, hn); setfield(hn, 'next', nil)
621+ node_remove(wv, hn); setnext(hn, nil)
616622 insert_after(ch, rs[1], hn)
617623 set_attr(hn, attr_icflag, PROCESSED)
618624 if fn == 2*cmp-1 then
@@ -646,19 +652,19 @@ local function post_high_break(head)
646652 if i==0 then
647653 ha = node_next(ha)
648654 elseif i==1 then
649- setfield(h, 'head', post_lown(rs, rw, cmp, getlist(h)))
655+ setlist(h, post_lown(rs, rw, cmp, getlist(h)))
650656 for i = 2, #rs do rs[i] = nil end -- rs[1] is set by the next statement
651657 rs[1], rw = ha, nil; ha = node_next(ha)
652658 elseif i==2 then
653659 rw = ha
654660 cmp = getfield(getfield(rw, 'value'), 'value').count
655661 local hb, hc = node_remove(getlist(h), rw)
656- setfield(h, 'head', hb); ha = hc
662+ setlist(h, hb); ha = hc
657663 else -- i>=3
658664 rs[#rs+1] = ha; ha = node_next(ha)
659665 end
660666 end
661- setfield(h, 'head', post_lown(rs, rw, cmp, getlist(h)))
667+ setlist(h, post_lown(rs, rw, cmp, getlist(h)))
662668 end
663669 return head
664670 end
@@ -759,8 +765,8 @@ do
759765 local ic = get_attr_icflag(p)
760766 if ic and (ic>FROM_JFM) and (ic<KANJI_SKIP) then ic = FROM_JFM end
761767 if t.intrude_jfmgk[ic] then
762- if getid(p)==id_kern then t[index] = t[index] + getfield(p, 'kern')
763- else t[index] = t[index] + getfield(p, 'width') end
768+ if getid(p)==id_kern then t[index] = t[index] + getkern(p)
769+ else t[index] = t[index] + getwidth(p) end
764770 end
765771 end
766772 local RIPOST = luatexja.stack_table_index.RIPOST
--- a/src/ltj-setwidth.lua
+++ b/src/ltj-setwidth.lua
@@ -15,21 +15,23 @@ local getfont = node.direct.getfont
1515 local getlist = node.direct.getlist
1616 local getchar = node.direct.getchar
1717 local getsubtype = node.direct.getsubtype
18-local getwidth = node.direct.getwidth or function(n) return getfield(n,'width') end
19-local getdepth = node.direct.getdepth or function(n) return getfield(n,'depth') end
20-local getwhd = node.direct.getwhd or function(n)
21- return getfield(n,'width'), getfield(n,'height'),getfield(n,'depth') end
18+local getwidth = node.direct.getwidth
19+local getshift = node.direct.getshift
20+local getoffsets = node.direct.getoffsets
21+local getheight = node.direct.getheight
22+local getdepth = node.direct.getdepth
23+local getwhd = node.direct.getwhd
2224
23-local setwhd = node.direct.setwhd or function(n,w,h,d)
24- setfield(n,'width',w); setfield(n,'height',h); setfield(n,'depth',d) end
25-local setchar = node.direct.setchar or function(n,c) setfield(n,'char',c) end
26-local setnext = node.direct.setnext or function(n,c) setfield(n,'next',c) end
27-local setdir = node.direct.setdir or function(n,c) setfield(n,'dir',c) end
28-local setkern = node.direct.setkern or function(n,c) setfield(n,'kern',c) end
29-local setoffsets = node.direct.setoffsets or function(n,x,y)
30- setfield(n,'xoffset',x); setfield(n,'yoffset',y) end
31-local getoffsets = node.direct.getoffsets or function(n)
32- return getfield(n,'xoffset'), getfield(n,'yoffset') end
25+local setwhd = node.direct.setwhd
26+local setchar = node.direct.setchar
27+local setnext = node.direct.setnext
28+local setdir = node.direct.setdir
29+local setkern = node.direct.setkern
30+local setshift = node.direct.setshift
31+local setoffsets = node.direct.setoffsets
32+local setheight = node.direct.setheight
33+local setdepth = node.direct.setdepth
34+local setlist = node.direct.setlist
3335
3436 local node_traverse_id = node.direct.traverse_id
3537 local node_traverse = node.direct.traverse
@@ -142,8 +144,7 @@ local function capsule_glyph_yoko(p, met, char_data, head, dir)
142144 setnext(p, nil)
143145 local box = node_new(id_hlist, nil, p)
144146 setwhd(box, fwidth, fheight, fdepth)
145- setfield(box, 'head', p)
146- setfield(box, 'shift', kbl)
147+ setlist(box, p); setshift(box, kbl)
147148 setdir(box, dir)
148149 set_attr(box, attr_icflag, PACKED)
149150 head = q and node_insert_before(head, q, box)
@@ -172,8 +173,7 @@ local function capsule_glyph_tate_rot(p, met, char_data, head, dir, asc)
172173 setnext(p, nil)
173174 local box = node_new(id_hlist, nil, p)
174175 setwhd(box, fwidth, fheight, fdepth)
175- setfield(box, 'head', p)
176- setfield(box, 'shift', kbl)
176+ setlist(box, p); setshift(box, kbl)
177177 setdir(box, dir)
178178 set_attr(box, attr_icflag, PACKED)
179179 head = q and node_insert_before(head, q, box)
@@ -217,8 +217,7 @@ local function capsule_glyph_tate(p, met, char_data, head, dir)
217217 local q
218218 head, q = node_remove(head, p)
219219 local box = node_new(id_hlist, nil, p)
220- setwhd(box, fwidth, fheight, fdepth)
221- setfield(box, 'shift', y_shift)
220+ setwhd(box, fwidth, fheight, fdepth); setshift(box, y_shift)
222221 setdir(box, dir)
223222 -- print(yo, ascender, char_data.align, fwidth-pwidth)
224223 setoffsets(p, -fshift.down,
@@ -230,7 +229,7 @@ local function capsule_glyph_tate(p, met, char_data, head, dir)
230229 local k2 = node_new(id_kern, 1); setkern(k2, pwnh)
231230 local k3 = node_new(id_kern, 1); setkern(k3, -getwidth(p)-pwnh)
232231 local wr = node_new(id_whatsit, sid_restore)
233- setfield(box, 'head', ws)
232+ setlist(box, ws)
234233 setnext(ws, wm); setnext(wm, k2);
235234 setnext(k2, p); setnext(p, k3);
236235 setnext(k3, wr);
@@ -256,8 +255,7 @@ local function capsule_glyph_math(p, met, char_data)
256255 setfield(p, 'xoffset', getfield(p, 'xoffset') + char_data.align*(fwidth-pwidth) - fshift.left)
257256 local box = node_new(id_hlist, nil, p);
258257 setwhd(box, fwidth, fheight, fdepth)
259- setfield(box, 'head', p)
260- setfield(box, 'shift', y_shift)
258+ setlist(box, p); setshift(box, y_shift)
261259 setdir(box, tex.mathdir)
262260 set_attr(box, attr_icflag, PACKED)
263261 return box
@@ -272,11 +270,10 @@ function luatexja.setwidth.apply_ashift_math(head, last, attr_ablshift)
272270 return
273271 elseif (has_attr(p, attr_icflag) or 0) ~= PROCESSED then
274272 if pid==id_hlist or pid==id_vlist then
275- setfield(p, 'shift', getfield(p, 'shift') + (has_attr(p,attr_ablshift) or 0))
273+ setshift(p, getshift(p) + (has_attr(p,attr_ablshift) or 0))
276274 elseif pid==id_rule then
277275 local v = has_attr(p,attr_ablshift) or 0
278- setfield(p, 'height', getfield(p, 'height')-v)
279- setfield(p, 'depth', getdepth(p)+v)
276+ setheight(p, getheight(p)-v); setdepth(p, getdepth(p)+v)
280277 set_attr(p, attr_icflag, PROCESSED)
281278 elseif pid==id_glyph then
282279 -- 欧文文字; 和文文字は pid == id_hlist の場合で処理される
--- a/src/luatexja.lua
+++ b/src/luatexja.lua
@@ -40,21 +40,36 @@ do
4040 end
4141 end
4242 do
43- local setfield = node.direct.setfield
43+ local dnode = node.direct
44+ local setfield = dnode.setfield
4445 luatexja.setglue = node.direct.setglue or
4546 function(g,w,st,sh,sto,sho)
4647 setfield(g,'width', w or 0); setfield(g,'stretch',st or 0); setfield(g,'shrink', sh or 0)
4748 setfield(g,'stretch_order',sto or 0)
4849 setfield(g,'shrink_order', sho or 0)
4950 end
50- local getfield = node.direct.getfield
51+ for _,v in pairs({'char', 'depth', 'dir', 'font', 'height', 'kern', 'lang', 'next',
52+ 'nucleus', 'offsets', 'penalty', 'shift', 'sub', 'subtype', 'sup'}) do
53+ if not dnode['set'..v] then
54+ dnode['set'..v] = function(n, ...) return setfield(n, v, ...) end
55+ end
56+ end
57+ local getfield = dnode.getfield
5158 luatexja.getglue = node.direct.getglue or
5259 function(g)
5360 return getfield(g,'width'), getfield(g,'stretch'), getfield(g,'shrink'),
5461 getfield(g,'stretch_order'), getfield(g,'shrink_order')
5562 end
63+ for _,v in pairs({'box', 'components', 'char', 'depth', 'font', 'height', 'kern', 'lang',
64+ 'list', 'next', 'nucleus', 'offsets', 'penalty', 'prev', 'shift', 'sub',
65+ 'subtype', 'sup', 'whd', 'width', 'dir'}) do
66+ if not dnode['get'..v] then
67+ dnode['get'..v] = function(n, ...) return getfield(n, v, ...) end
68+ end
69+ end
5670 end
5771
72+
5873 --- 以下は全ファイルで共有される定数
5974 local icflag_table = {}
6075 luatexja.icflag_table = icflag_table
--- a/src/patches/lltjfont.sty
+++ b/src/patches/lltjfont.sty
@@ -557,6 +557,7 @@
557557 {Use \string\KanjiEncodingPair, falling back to `\reserved@b'...}%
558558 \expandafter\edef\reserved@a{\reserved@b}%
559559 \fi}
560+
560561 \def\set@fontsize#1#2#3{%
561562 \@defaultunits\@tempdimb#2pt\relax\@nnil
562563 \edef\f@size{\strip@pt\@tempdimb}%
--- a/src/patches/lltjp-atbegshi.sty
+++ b/src/patches/lltjp-atbegshi.sty
@@ -3,7 +3,7 @@
33 %
44
55 \NeedsTeXFormat{LaTeX2e}
6-\ProvidesPackage{lltjp-atbegshi}[2021-04-29 Patching \string\shipout\space hooks for LuaTeX-ja]
6+\ProvidesPackage{lltjp-atbegshi}[2022-08-12 Patching \string\shipout\space hooks for LuaTeX-ja]
77
88 % concept: execute all hooks inside yoko direction \vbox
99
@@ -37,6 +37,7 @@
3737 % however, an infinite loop occurs if we uncomment the line below
3838 % so we can't.
3939 %\box_use:N \l__platex_shipout_dummy_box
40+ \box_clear:N \l__platex_shipout_dummy_box
4041 }
4142 }
4243
@@ -53,6 +54,7 @@
5354 \vbox_set:Nn \l__platex_shipout_dummy_box {
5455 \platex_direction_yoko: \__platex_original_shipout_execute_cont:
5556 }
57+ \box_clear:N \l__platex_shipout_dummy_box
5658 }
5759 }
5860 \fi:
@@ -104,7 +106,7 @@
104106 {\setbox8\vbox\bgroup\yoko\let\AtBegShi@OrgProtect\protect}
105107 \pxabgs@patch@cmd\pxabgs@AtBegShi@Output
106108 {\AtBeginShipoutOriginalShipout\box\AtBeginShipoutBox}%
107- {\AtBeginShipoutOriginalShipout\box\AtBeginShipoutBox\egroup}
109+ {\AtBeginShipoutOriginalShipout\box\AtBeginShipoutBox\egroup\setbox8\box\voidb@x}
108110 \pxabgs@patch@cmd\pxabgs@AtBegShi@Output
109111 {%
110112 \begingroup
--- a/src/patches/lltjp-everyshi.sty
+++ b/src/patches/lltjp-everyshi.sty
@@ -12,7 +12,7 @@
1212 \@EveryShipout@Hook
1313 \@EveryShipout@AtNextHook
1414 \global\setbox\luatexoutputbox=\box\luatexoutputbox
15- }%
15+ }\setbox8\box\voidb@x%
1616 \gdef\@EveryShipout@AtNextHook{}%
1717 \@EveryShipout@Org@Shipout\box\luatexoutputbox
1818 }
Show on old repository browser