\cs{ltj@setpar@global}を直前に実行せず,単独で
\cs{ltjsetkanjiskip}, \cs{ltjsetxkanjiskip}を実行することは想定されていないので注意.
-
-
-\paragraph{ベースライン補正量の設定}
-\pLaTeX の\Pkg{ascmac}パッケージでは,縦組の欧文ベースライン補正量の一時待避・復帰処理に
-\ \cs{@saveybaselineshift}\ という寸法レジスタを用い
-\begin{lstlisting}
-\@savetbaselineshift\tbaselineshift\tbaselineshift\z@
-...
-\tbaselineshift\@savetbaselineshift
-\end{lstlisting}
-という処理を行っている.
-
-これを\LuaTeX-ja 用に \cs{ltjsetparameter} を使って書き直すと,
-\begin{lstlisting}
-\@savetbaselineshift\ltjgetparameter{talbaselineshift}
-\ltjsetparameter{talbaselineshift=\z@}
-...
-\ltjsetparameter{talbaselineshift=\@savetbaselineshift}
-\end{lstlisting}
-となる.
-
-さて,縦組の欧文ベースライン補正量\Param{talbaselineshift}は,
-実際には \cs{ltj@tablshift} という属性レジスタに格納されている
-(\ref{sec-para}\nobreak 節参照).属性レジスタは長さではなく整数値を格納する\footnote{%
- 従って,\texttt{\textbackslash @savetbaselineshift=\textbackslash ltj@tablshift}\
- のように記述することはできない.属性レジスタを \cs{tbaselineshift} という名称にしなかっ
- たのはそのためである.
-}ものであり,\cs{ltj@tablshift} は補正量を sp 単位で保持することから,
-上記のコードと同じ内容をより速い以下のコードで実現することができる.
-\begin{lstlisting}
-\@savetbaselineshift\ltj@tablshift sp%
-\ltj@tablshift\z@
-...
-\ltj@tablshift\@savetbaselineshift
-\end{lstlisting}
-この手法は \Pkg{ascmac} パッケージの\LuaTeX-ja対応パッチ \Pkg{lltjp-tascmac.sty} で
-実際に用いられている.\Pkg{lltjp-tascmac.sty} は自動的に読み込まれるので,
-ユーザは何も気にせず普通に \Pkg{ascmac} パッケージを \cs{usepackage} で読みこめば良い.
%</ja>
\attr{ltj@yablshift}
%<*en>
The amount of shifting the baseline of alphabetic fonts in scaled point ($2^{-16}\,\textrm{pt}$).
+``unset'' means zero.
%</en>
%<*ja>
スケールド・ポイント($2^{-16}\,\textrm{pt}$)を単位とした欧文フォントのベースラインの移動量.
+この属性が「未設定」(\texttt{-"7FFFFFFF})のときは0であるとみなされる.\cs{ltj@ykblshift}他も同様.
%</ja>
\attr{ltj@ykblshift}
\attr{ltj@autospc}
%<*en>
Whether the auto insertion of \Param{kanjiskip} is allowed at the node.
+0 means ``not allowed'', and the other value (including ``unset'') means ``allowed''.
%</en>
%<*ja>
そのノードで\Param{kanjiskip}の自動挿入が許されるかどうか.
+0は「許可しない」,0以外の値(「未設定」も含む)は「許可する」.
%</ja>
\attr{ltj@autoxspc}
%<*en>
Whether the auto insertion of \Param{xkanjiskip} is allowed at the node.
+0 means ``not allowed'', and the other value (including ``unset'') means ``allowed''.
%</en>
%<*ja>
そのノードで\Param{xkanjiskip}の自動挿入が許されるかどうか.
+0は「許可しない」,0以外の値(「未設定」も含む)は「許可する」.
%</ja>
\attr{ltj@icflag}
\bibitem{bxghost} Takuto ASAKURA. \newblock The \textsf{BXghost} Package. \url{https://github.com/wtsnjp/BXghost}
\end{thebibliography}
+{\catcode`\%=12\relax\catcode`\~=12\relax
+\typeout{attributes:}
+\directlua{
+ for i=0,65535 do
+ local a = tex.getattribute(i)
+ if a~=-0x7FFFFFFF then
+ texio.write_nl('term and log',
+ string.format('attr %6d, %d', i, a))
+ end
+ end
+}}
\end{document}
%</!showexpl>
%<*showexpl>
[1] = { -- fw. opening punctuations
chars = {
- 0x2018, 0x201C, 0x3008, 0x300A, 0x300C, 0x300E, 0x3010, 0x3014, 0x3016,
+ 0x2018, 0x201C, 0x3008, 0x300A, 0x300C, 0x300E, 0x3010, 0x3014, 0x3016,
0x3018, 0x301D, 0xFF08, 0xFF3B, 0xFF5B, 0xFF5F
},
align = 'right', left = 0.0, down = 0.0,
[2] = { -- fw. closing/colon punctuations
chars = {
- 0x2019, 0x201D, 0x3001, 0x3009, 0x300B, 0x300D, 0x300F, 0x3011, 0x3015,
+ 0x2019, 0x201D, 0x3001, 0x3009, 0x300B, 0x300D, 0x300F, 0x3011, 0x3015,
0x3017, 0x3019, 0x301F, 0xFF09, 0xFF0C, 0xFF3D, 0xFF5D, 0xFF60,
- 0xFF1A, 0xFF1B
+ 0xFF1A, 0xFF1B
},
align = 'left', left = 0.0, down = 0.0,
width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
[1] = { -- fw. opening punctuations
chars = {
- 0x2018, 0x201C, 0x3008, 0x300A, 0x300C, 0x300E, 0x3010, 0x3014, 0x3016,
+ 0x2018, 0x201C, 0x3008, 0x300A, 0x300C, 0x300E, 0x3010, 0x3014, 0x3016,
0x3018, 0x301D, 0xFF08, 0xFF3B, 0xFF5B, 0xFF5F
},
align = 'right', left = 0.0, down = 0.0,
[2] = { -- fw. closing/colon/dot punctuations, except 4 & 7
chars = {
- 0x2019, 0x201D, 0x3009, 0x300B, 0x300D, 0x300F, 0x3011, 0x3015,
+ 0x2019, 0x201D, 0x3009, 0x300B, 0x300D, 0x300F, 0x3011, 0x3015,
0x3017, 0x3019, 0x301F, 0xFF09, 0xFF0C, 0xFF3D, 0xFF5D, 0xFF60,
0xFF0E, 0xFF1A, 0xFF1B, 0xFF01, 0xFF1F
},
[1] = { -- 開き括弧類
chars = {
- '‘', '“', '〈', '《', '「', '『', '【', '〔', '〖',
+ '‘', '“', '〈', '《', '「', '『', '【', '〔', '〖',
'〘', '〝', '(', '[', '{', '⦅'
},
align = 'right', left = 0.0, down = 0.0,
[2] = { -- 閉じ括弧類
chars = {
- '’', '”', '、', '〉', '》', '」', '』', '】', '〕',
+ '’', '”', '、', '〉', '》', '」', '』', '】', '〕',
'〗', '〙', '〟', ')', ',', ']', '}', '⦆'
},
align = 'left', left = 0.0, down = 0.0,
[1] = { -- fw. opening punctuations
chars = {
- 0x2018, 0x201C, 0x3008, 0x300A, 0x300C, 0x300E, 0x3010, 0x3014, 0x3016,
+ 0x2018, 0x201C, 0x3008, 0x300A, 0x300C, 0x300E, 0x3010, 0x3014, 0x3016,
0x3018, 0x301D, 0xFF08, 0xFF3B, 0xFF5B, 0xFF5F
},
align = 'right', left = 0.0, down = 0.0,
[2] = { -- fw. closing/colon/dot punctuations, except 4 & 7
chars = {
- 0x2019, 0x201D, 0x3009, 0x300B, 0x300D, 0x300F, 0x3011, 0x3015,
+ 0x2019, 0x201D, 0x3009, 0x300B, 0x300D, 0x300F, 0x3011, 0x3015,
0x3017, 0x3019, 0x301F, 0xFF09, 0xFF0C, 0xFF3D, 0xFF5D, 0xFF60,
- 0xFF0E, 0xFF1A, 0xFF1B
+ 0xFF0E, 0xFF1A, 0xFF1B
},
align = 'left', left = 0.0, down = 0.0,
width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
[3] = {
chars = {
'∴', '♀', '♂', '〃', '々', 'ぁ', 'ぃ', 'ぅ', 'ぇ', 'ぉ', 'っ', 'ゃ', 'ゅ ',
- 'ょ', 'ゎ', 'ゕ', 'ゖ', 'ゞ', 'ァ', 'ィ', 'ゥ', 'ェ', 'ォ', 'ッ', 'ャ', 'ュ', 'ョ',
- 'ヮ', 'ヵ', 'ヶ', 'ㇰ', 'ㇱ', 'ㇲ', 'ㇳ', 'ㇴ', 'ㇵ', 'ㇶ', 'ㇷ', 'ㇸ', 'ㇹ', 'ㇺ',
+ 'ょ', 'ゎ', 'ゕ', 'ゖ', 'ゞ', 'ァ', 'ィ', 'ゥ', 'ェ', 'ォ', 'ッ', 'ャ', 'ュ', 'ョ',
+ 'ヮ', 'ヵ', 'ヶ', 'ㇰ', 'ㇱ', 'ㇲ', 'ㇳ', 'ㇴ', 'ㇵ', 'ㇶ', 'ㇷ', 'ㇸ', 'ㇹ', 'ㇺ',
'ㇻ', 'ㇼ', 'ㇽ', 'ㇾ', 'ㇿ', '$', '¢', '£'
},
align = 'middle', left = 0.0, down = 0.0,
},
[12] = {
chars = {
- 'ア', 'イ', 'ウ', 'オ', 'ケ', 'ゲ', 'サ', 'ザ', 'ソ', 'ゾ', 'チ', 'ヂ', 'ツ',
+ 'ア', 'イ', 'ウ', 'オ', 'ケ', 'ゲ', 'サ', 'ザ', 'ソ', 'ゾ', 'チ', 'ヂ', 'ツ',
'ヅ', 'ト', 'ド', 'ナ', 'フ', 'ブ', 'プ', 'ミ', 'メ', 'ラ', 'リ', 'ワ', 'ヲ'
},
align = 'left', left = 0.0, down = 0.0,
[1] = { -- fw. opening punctuations
chars = {
- 0x2018, 0x201C, 0x3008, 0x300A, 0x300C, 0x300E, 0x3010, 0x3014, 0x3016,
+ 0x2018, 0x201C, 0x3008, 0x300A, 0x300C, 0x300E, 0x3010, 0x3014, 0x3016,
0x3018, 0x301D, 0xFF08, 0xFF3B, 0xFF5B, 0xFF5F
},
align = 'right', left = 0.0, down = 0.0,
[2] = { -- fw. closing/colon/dot punctuations, except 4 & 7
chars = {
- 0x2019, 0x201D, 0x3009, 0x300B, 0x300D, 0x300F, 0x3011, 0x3015,
+ 0x2019, 0x201D, 0x3009, 0x300B, 0x300D, 0x300F, 0x3011, 0x3015,
0x3017, 0x3019, 0x301F, 0xFF09, 0xFF0C, 0xFF3D, 0xFF5D, 0xFF60,
0xFF0E, 0xFF1A, 0xFF1B, 0xFF01, 0xFF1F
},
[207] = { 0, 0, 0, kanjiskip_shrink=1 },
[8] = { 0, 0, 0, kanjiskip_shrink=1 },
},
- kern = { [307] = 0 },
+ kern = { [307] = 0 },
round_threshold = 0.01,
},
[6] = { 0, 0, 0, kanjiskip_shrink=1 },
[8] = { 0, 0, 0, kanjiskip_shrink=1 },
},
- kern = { [307] = 0 },
+ kern = { [307] = 0 },
},
[107] = { -- 1/3 角
[207] = { 0, 0, 0, kanjiskip_shrink=1 },
[8] = { 0, 0, 0, kanjiskip_shrink=1 },
},
- kern = { [307] = 0 },
+ kern = { [307] = 0 },
round_threshold = 0.01,
},
%
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{lltjext}[2021-04-20 v1.2k-ltj-13 Macros for vertical writing]
+\ProvidesPackage{lltjext}[2022-08-24 v1.2k-ltj-14 Macros for vertical writing]
\RequirePackage{luatexja}
\newcount\ltj@ext@dir
\let\ltj@lltjext@orig@tabular=\tabular
\def\ltj@@pic@reset@blshift{%
\ltj@yablshift\z@\ltj@ykblshift\z@
\ltj@tablshift\z@\ltj@tkblshift\z@
+ %\unsetattribute\ltj@yablshift\unsetattribute\ltj@ykblshift
+ %\unsetattribute\ltj@tablshift\unsetattribute\ltj@tkblshift
}%
\def\@@picture<#1>(#2,#3)(#4,#5){%
\edef\ltj@@pic@save@blshift{%
local getlang = node.direct.getlang
local getkern = node.direct.getkern
local getshift = node.direct.getshift
-local getwidth = node.direct.getwidth
+local getwidth = node.direct.getwidth
local getdepth = node.direct.getdepth
local setfield = node.direct.setfield
local setpenalty = node.direct.setpenalty
local node_free = node.direct.flush_node or node.direct.free
local node_prev = node.direct.getprev
local node_tail = node.direct.tail
-local has_attr = node.direct.has_attribute
+local get_attr = node.direct.get_attribute
local set_attr = node.direct.set_attribute
local insert_after = node.direct.insert_after
do
local PROCESSED_BEGIN_FLAG = luatexja.icflag_table.PROCESSED_BEGIN_FLAG
get_attr_icflag = function(p)
- return (has_attr(p, attr_icflag) or 0) % PROCESSED_BEGIN_FLAG
+ return (get_attr(p, attr_icflag) or 0) % PROCESSED_BEGIN_FLAG
end
end
for i=0,63 do tmp[#tmp+1] = { (i%8)-4, FROM_JFM+i } end
else -- stretch
for i=0,63 do tmp[#tmp+1] = { math.floor(i/8)-4, FROM_JFM+i } end
- end
+ end
local pt = priority_table[glue_sign]
tmp[#tmp+1] = { pt[2]/10, XKANJI_SKIP }
tmp[#tmp+1] = { pt[2]/10, XKANJI_SKIP_JFM }
for q in node_traverse_id(id_glue, ph) do
local a = getfield(q, 'stretch_order')
if a==0 then
- local b = at2pr_st[get_attr_icflag(q)];
+ local b = at2pr_st[get_attr_icflag(q)];
total_st[b] = total_st[b]+getfield(q, 'stretch')
end
total_st[a*65536] = total_st[a]+getfield(q, 'stretch')
local a = getfield(q, 'shrink_order')
if a==0 then
- local b = at2pr_sh[get_attr_icflag(q)];
+ local b = at2pr_sh[get_attr_icflag(q)];
total_sh[b] = total_sh[b]+getfield(q, 'shrink')
end
total_sh[a*65536] = total_sh[a]+getfield(q, 'shrink')
return total, false-- それ以外は対象外.
end
local eadt = ltjf_font_metric_table[getfont(xc)]
- .char_type[has_attr(xc, attr_jchar_class) or 0].end_adjust
- if not eadt then
+ .char_type[get_attr(xc, attr_jchar_class) or 0].end_adjust
+ if not eadt then
return total, false
end
local eadt_ratio = {}
eadt_ratio[i] = {i, t/total_sh[65536*total_sh.order], t, v}
end
end
- table.sort(eadt_ratio,
- function (a,b)
+ table.sort(eadt_ratio,
+ function (a,b)
for i=2,4 do
local at, bt = abs(a[i]), abs(b[i])
if at~=bt then return at<bt end
end
end
local eadt = ltjf_font_metric_table[getfont(xc)]
- .char_type[has_attr(xc, attr_jchar_class) or 0].end_adjust
- if not eadt then
+ .char_type[get_attr(xc, attr_jchar_class) or 0].end_adjust
+ if not eadt then
return total, false
end
-- 続行条件2: min(eadt[1], 0)<= \parfillskip <= max(eadt[#eadt], 0)
local pfw = getwidth(pf)
- + (total>0 and getfield(pf, 'stretch') or -getfield(pf, 'shrink')) *getfield(p, 'glue_set')
+ + (total>0 and getfield(pf, 'stretch') or -getfield(pf, 'shrink')) *getfield(p, 'glue_set')
if pfw<min(0,eadt[1]) or max(0,eadt[#eadt])<pfw then return total, false end
-- \parfillskip を 0 にする
total = total + getwidth(pf)
total_st.order, total_sh.order = 0, 0
- if getfield(pf, 'stretch_order')==0 then
- local i = at2pr_st[-1]
- total_st[0] = total_st[0] - getfield(pf, 'stretch')
- total_st[i] = total_st[i] - getfield(pf, 'stretch')
+ if getfield(pf, 'stretch_order')==0 then
+ local i = at2pr_st[-1]
+ total_st[0] = total_st[0] - getfield(pf, 'stretch')
+ total_st[i] = total_st[i] - getfield(pf, 'stretch')
total_st.order = (total_st[0]==0) and -1 or 0
end
- if getfield(pf, 'shrink_order')==0 then
- local i = at2pr_sh[-1]
- total_sh[0] = total_sh[0] - getfield(pf, 'shrink')
- total_sh[i] = total_sh[i] - getfield(pf, 'shrink')
+ if getfield(pf, 'shrink_order')==0 then
+ local i = at2pr_sh[-1]
+ total_sh[0] = total_sh[0] - getfield(pf, 'shrink')
+ total_sh[i] = total_sh[i] - getfield(pf, 'shrink')
total_sh.order = (total_sh[0]==0) and -1 or 0
end
setsubtype(pf, 1); setglue(pf)
eadt_ratio[i] = {i, t/total_sh[65536*total_sh.order], t, v}
end
end
- table.sort(eadt_ratio,
- function (a,b)
+ table.sort(eadt_ratio,
+ function (a,b)
for i=2,4 do
local at, bt = abs(a[i]), abs(b[i])
if at~=bt then return at<bt end
local id = (total>0) and 1 or 2
local res = total_stsh[id]
local pnum = priority_num[id]
- if total==0 or res.order > 0 then
+ if total==0 or res.order > 0 then
-- もともと伸縮の必要なしか,残りの伸縮量は無限大
if added_flag then return repack(p) end
end
total = abs(total)
for i = 1, pnum do
if total <= res[i] then
- local a = at2pr[id]
+ local a = at2pr[id]
for j = i+1,pnum do
clear_stretch(p, j, a, name)
end
local insert_before = node.direct.insert_before
local KINSOKU = luatexja.icflag_table.KINSOKU
insert_lineend_kern = function (head, nq, np, Bp)
- if nq.met then
+ if nq.met then
local eadt = nq.met.char_type[nq.class].end_adjust
if not eadt then return end
if eadt[1]~=0 then
local function enable_cb(status_le, status_pr, status_lp, status_ls)
if (status_le>0 or status_pr>0) and (not is_reg) then
ltjb.add_to_callback('post_linebreak_filter',
- adjust_width, 'Adjust width',
+ adjust_width, 'Adjust width',
luatexbase.priority_in_callback('post_linebreak_filter', 'ltj.lineskip')-1)
is_reg = true
elseif is_reg and (status_le==0 and status_pr==0) then
return luatexja.adjust.profile_hgap_factor
end
do
- local insert = table.insert
+ local insert, texget = table.insert, tex.get
local rangedimensions, max = node.direct.rangedimensions, math.max
local function profile_inner(box, range, ind, vmirrored, adj)
local w_acc, d_before = getshift(box), 0
local x = getlist(box); local xn = node_next(x)
while x do
local w, h, d
- if xn then w, h, d= rangedimensions(box,x,xn)
- else w, h, d= rangedimensions(box,x) end
+ if xn then w, h, d = rangedimensions(box,x,xn)
+ else w, h, d = rangedimensions(box,x) end
if vmirrored then h=d end
local w_new = w_acc + w
- if w>=0 then
- range:insert(ind, h, w_acc-adj, w_new)
- else
- range:insert(ind, h, w_new-adj, w_acc)
+ if w>=0 then range:insert(ind, h, w_acc-adj, w_new)
+ else range:insert(ind, h, w_new-adj, w_acc)
end
w_acc = w_new; x = xn; if x then xn = node_next(x) end
end
- end
+ end
function ltjl.p_profile(before, after, mirrored, bw)
- local range, tls
- = init_range(), luatexja.adjust.profile_hgap_factor*tex.get('lineskip', false)
+ local range, tls
+ = init_range(), luatexja.adjust.profile_hgap_factor*texget('lineskip', false)
profile_inner(before, range, 3, true, tls)
profile_inner(after, range, 4, mirrored, tls)
range = range:flatten()
if bw-h-d<lmin then lmin=bw-h-d end
end
if lmin==1/0 then lmin = bw end
- return lmin,
+ return lmin,
bw - lmin - getdepth(before)
- getfield(after, mirrored and 'depth' or 'height')
end
do
local ltja = luatexja.adjust
- local copy_glue = ltjl.copy_glue
+ local copy_glue, texget = ltjl.copy_glue, tex.get
local floor, max = math.floor, math.max
function ltjl.l_step(dist, g, adj, normal, bw, loc)
if loc=='alignment' then
end
if dist < tex.lineskiplimit then
local f = max(1, bw*ltja.step_factor)
- copy_glue(g, 'baselineskip', 1, normal - f * floor((dist-tex.get('lineskip', false))/f))
+ copy_glue(g, 'baselineskip', 1, normal - f * floor((dist-texget('lineskip', false))/f))
else
copy_glue(g, 'baselineskip', 2, normal)
end
local sid_user = node.subtype 'user_defined'
local node_remove = node.direct.remove
local node_write = node.direct.write
+ local getvalue = node.direct.getdata
+ local setvalue = node.direct.setdata
local GHOST_JACHAR = luatexbase.newuserwhatsitid('ghost of a jachar', 'luatexja')
luatexja.userid_table.GHOST_JACHAR = GHOST_JACHAR
function ltja.create_ghost_jachar_node(cl)
local tn = node_new(id_whatsit, sid_user)
setfield(tn, 'user_id', GHOST_JACHAR)
setfield(tn, 'type', 100)
- setfield(tn, 'value', cl)
+ setvalue(tn, cl)
node_write(tn)
end
local attr_curjfnt = luatexbase.attributes['ltj@curjfnt']
local dir_tate = luatexja.dir_table.dir_tate
local get_dir_count = ltjd.get_dir_count
local ltjf_font_metric_table = ltjf.font_metric_table
+ local has_attr = node.direct.has_attribute
local function get_current_metric(n)
- local fn = has_attr(n, (get_dir_count()==dir_tate) and attr_curtfnt or attr_curjfnt)
+ local fn = get_attr(n, (get_dir_count()==dir_tate) and attr_curtfnt or attr_curjfnt)
return fn and ltjf_font_metric_table[fn]
end
local function whatsit_callback(Np, lp, Nq)
if Np and Np.nuc then return Np
elseif Np and getfield(lp, 'user_id') == GHOST_JACHAR then
Np.first = lp; Np.nuc = lp; Np.last = lp; Np.class = 0
- if getfield(lp,'value')<2 then
+ if getvalue(lp)<2 then
if Nq and Nq.met then Np.met = Nq.met; else Np.met = get_current_metric(lp) end
Np.pre = 0; Np.post = 0; Np.xspc = 3
else Np.met, Np.pre = nil, nil; end
- Np.auto_kspc, Np.auto_xspc = (has_attr(lp, attr_autospc)==1), (has_attr(lp, attr_autoxspc)==1)
+ Np.auto_kspc, Np.auto_xspc
+ = not has_attr(lp, attr_autospc, 0), not has_attr(lp, attr_autoxspc, 0)
return Np
else return Np end
end
if not s and getfield(Nq.nuc, 'user_id') == GHOST_JACHAR then
local x, y = node_prev(Nq.nuc), Nq.nuc
Nq.first, Nq.nuc, Nq.last = x, x, x
- if getfield(y,'value')%2==0 then
+ if getvalue(y)%2==0 then
if Np and Nq.met then Nq.met = Np.met; else Nq.met = get_current_metric(y) end
Nq.pre = 0; Nq.post = 0; Nq.xspc = 3
else Nq.met, Nq.pre = nil, nil; end
local cat_lp = luatexbase.catcodetables['latex-package']
---------------------
+--------------------
local ltjb = {}
luatexja.base = ltjb
_error_set_message = function (msgcont, main, help)
err_main = message_cont(main, msgcont):gsub(BEL, LF)
err_help = (help and help~="") and into_lines(help)
- or {"Sorry, I don't know how to help in this situation.",
+ or {"Sorry, I don't know how to help in this situation.",
"Maybe you should try asking a human?" }
end
--- Extension to tex.print(). Each argument string may contain
-- newline characters, in which case the string is output (to
-- TeX input stream) as multiple lines.
--- @param ... (string) string to output
+-- @param ... (string) string to output
local function mprint(...)
local arg = {...}
local lines = {}
local function in_unicode(c, admit_math)
local low = admit_math and -1 or 0
if type(c)~='number' or c<low or c>0x10FFFF then
- local s = 'A character number must be between ' .. tostring(low)
+ local s = 'A character number must be between ' .. tostring(low)
.. ' and 0x10ffff.\n'
.. (admit_math and "(-1 is used for denoting `math boundary')\n" or '')
.. 'So I changed this one to zero.'
-- * return value: non-nil iff the cache is up-to-date
-- save_cache (filename, t): no return value
-- save_cache_luc (filename, t): no return value
--- save_cache always calls save_cache_luc.
+-- save_cache always calls save_cache_luc.
-- But sometimes we want to create only the precompiled cache,
-- when its 'text' version is already present in LuaTeX-ja distribution.
if s then
local sa = load(s)
local f = io.open(fullpath, 'wb')
- if f and sa then
- f:write(dump(sa, true))
+ if f and sa then
+ f:write(dump(sa, true))
texio.write('log', '(save cache: ' .. fullpath .. ')')
f:close()
end
break
end
end
- if (not result) or outdate(result) then
- return nil
- else
- return result
+ if (not result) or outdate(result) then
+ return nil
+ else
+ return result
end
end
-
+
local function load_cache(filename, outdate)
remove_file_if_exist(savepath .. '/' .. filename .. '.lua')
local r = load_cache_a(filename .. luc_suffix, outdate, false)
- if r then
+ if r then
return r
else
local r = load_cache_a(filename .. '.lua.gz', outdate, true)
%% Registers
%\newcount\ltj@tempcnta % defined at luatexja-core.sty
+%\newcount\ltj@tempdima % defined at luatexja-core.sty
\newcount\ltj@tempcntb
\newcount\ltj@tempcntc
-\newdimen\ltj@tempdima
% \newskip\ltj@tempskipa unused
% \newtoks\ltj@temptoks unused
--
luatexbase.provides_module({
name = 'luatexja.charrange',
- date = '2022-08-17',
+ date = '2022-08-19',
description = 'Handling the range of Japanese characters',
})
luatexja.charrange = {}
luatexja.load_module 'base'; local ltjb = luatexja.base
local getchar = node.direct.getchar
-local has_attr = node.direct.has_attribute
-local has_attr_node = node.has_attribute
+local get_attr = node.direct.get_attribute
+local get_attr_node = node.get_attribute
local tex_getattr = tex.getattribute
local UNSET = -0x7FFFFFFF
local pow_table = {}
local fn_table = {} -- used in is_ucs_in_japanese_char_direct
local nfn_table = {} -- used in is_ucs_in_japanese_char_node
-for i = 0, 31*ATTR_RANGE-1 do
+do
+ local ka = luatexbase.attributes['ltj@kcat0']
+ for i = 0, 30 do
+ local pw = 2^i; kcat_attr_table[i], pow_table[i] = ka, pw
+ fn_table[i] = function(p) return get_attr(p, ka)&pw==0 end
+ nfn_table[i] = function(p) return get_attr_node(p, ka)&pw==0 end
+ end
+end
+for i = 31, 31*ATTR_RANGE-1 do
local ka, pw = luatexbase.attributes['ltj@kcat'..floor(i/31)], 2^(i%31)
kcat_attr_table[i], pow_table[i] = ka, pw
- fn_table[i] = function(p) return has_attr(p, ka)&pw==0 end
- nfn_table[i] = function(p) return has_attr_node(p, ka)&pw==0 end
+ fn_table[i] = function(p) return (get_attr(p, ka) or 0)&pw==0 end
+ nfn_table[i] = function(p) return (get_attr_node(p, ka) or 0)&pw==0 end
end
fn_table[-1] = function() return false end -- for char --U+007F
nfn_table[-1] = function() return false end -- for char --U+007F
-pow_table[31*ATTR_RANGE] = 2^31
-- jcr_table_main[chr_code] = index
-- index : internal 0, 1, 2, ..., 216 0: 'other'
local function get_range_setting(i) -- i: internal range number
local a = tex_getattr(kcat_attr_table[i])
- return floor((a==UNSET and 0 or a)/pow_table[i])%2
+ return (a==UNSET and 0 or a)&pow_table[i]
end
-- glyph_node p は和文文字か?
end
function luatexja.charrange.is_japanese_char_curlist(c) -- assume that c>=0x80
- return get_range_setting(jcr_table_main[c])~= jcr_noncjk
+ return get_range_setting(jcr_table_main[c])==0
end
-- EXT
local kc
if i>0 then kc=0 else kc=1; i=-i end; if i>=31*ATTR_RANGE then i=0 end
local attr, p = kcat_attr_table[i], pow_table[i]
- tex.setattribute(g, attr, (tex_getattr(attr)&~p)+kc*p)
+ local a = tex_getattr(attr); if a==UNSET then a=0 end
+ a = (a&~p)+kc*p; if a==0 and i>30 then a=UNSET end
+ tex.setattribute(g, attr, a)
end
end
luatexja.load_module 'base'; local ltjb = luatexja.base
luatexja.load_module 'stack'; local ltjs = luatexja.stack
-local stack_table_index = luatexja.stack_table_index
-- load jisx0208 table
local cache_ver = 3
-- \kuten, \jis, \euc, \sjis, \ucs, \kansuji
-local utfchar=utf.char
+local utfchar, floor = utf.char, math.floor
+local texwrite, getcount = tex.write, tex.getcount
+local cnt_stack = luatexbase.registernumber 'ltj@@stack'
+local KSJ = luatexja.stack_table_index.KSJ
+local get_stack_table = ltjs.get_stack_table
local function to_kansuji(num)
if not num then num=0; return
- elseif num<0 then
- num = -num; tex.write '-'
+ elseif num<0 then num = -num; texwrite '-'
end
local s = ""
repeat
- s = utfchar(
- ltjs.get_stack_table(luatexja.stack_table_index.KSJ + num%10,
- '', tex.getcount 'ltj@@stack')) .. s
- num=math.floor(num/10)
+ s = utfchar(get_stack_table(KSJ + num%10, '', getcount(cnt_stack))) .. s
+ num=num//10
until num==0
- tex.write(s)
+ texwrite(s)
end
local function error_invalid_charcode(i)
-- \ucs: 単なる identity
local function from_ucs(i)
if type(i)~='number' then error_invalid_charcode(i); i=0 end
- tex.write(i)
+ texwrite(i)
end
-- \kuten: 面区点 (それぞれで16進2桁を使用)=> Unicode 符号位置
local function from_kuten(i)
if type(i)~='number' then error_invalid_charcode(i); i=0 end
if (i%256==0)or(i%256>94) then
- tex.write '0'
- else
- tex.write(tostring(jisx0208.table_jisx0208_uptex[math.floor(i/256)*94+(i%256)-94] or 0))
+ texwrite '0'
+ else
+ texwrite(tostring(jisx0208.table_jisx0208_uptex[(i//256)*94+(i%256)-94] or 0))
end
end
-- \euc: EUC-JP による符号位置 => Unicode 符号位置
local function from_euc(i)
- if type(i)~='number' then
+ if type(i)~='number' then
error_invalid_charcode(i); i=0
elseif i>=0x10000 or i<0xa0a0 then
i=0
-- \sjis: Shift_JIS による符号位置 => Unicode 符号位置
local function from_sjis(i)
if (type(i)~='number') or i>=0x10000 or i<0 then
- error_invalid_charcode(i); tex.write '0'; return
+ error_invalid_charcode(i); texwrite '0'; return
end
- local c2 = math.floor(i/256)
- local c1 = i%256
+ local c2, c1 = i//256, i%256
local shift_jisx0213_s1a3_table = {
{ [false]= 1, [true]= 8},
{ [false]= 3, [true]= 4},
'So I changed this one to zero.')
c=0
end
- return ltjs.get_stack_table(stack_table_index.KSJ + c, 0, t)
+ return get_stack_table(KSJ + c, 0, t)
end
local function pformat(fmt, ...)
if type(fmt) == "string" then
return do_pformat(fmt, ...)
- else
+ else
return tosource(fmt)
end
end
end
local function print_measure()
- stop_time_measure('RUN')
+ stop_time_measure 'RUN'
local temp = {}
for i,v in pairs(time_stat) do
temp[#temp+1] = { i, v[1], v[2], v[2]/v[1] }
luatexja.base.start_time_measure = start_time_measure
luatexja.base.stop_time_measure = stop_time_measure
luatexbase.add_to_callback('stop_run', print_measure, 'luatexja.time_measure', 1)
- luatexbase.add_to_callback('pre_linebreak_filter',
- function(p)
- start_time_measure('tex_linebreak'); return p
- end,
+ luatexbase.add_to_callback('pre_linebreak_filter',
+ function(p)
+ start_time_measure 'tex_linebreak'; return p
+ end,
'measure_tex_linebreak', 20000)
end
end
local cat_lp = luatexbase.catcodetables['latex-package']
local to_node = dnode.tonode
local to_direct = dnode.todirect
-local has_attr = dnode.has_attribute
+local get_attr = dnode.get_attribute
local set_attr = dnode.set_attribute
local insert_before = dnode.insert_before
local insert_after = dnode.insert_after
local getlist = dnode.getlist
local getfield = dnode.getfield
local getwhd = dnode.getwhd
+local getvalue = node.direct.getdata
local setfield = dnode.setfield
local setwhd = dnode.setwhd
local setnext = dnode.setnext
local setlist = dnode.setlist
+local setvalue = node.direct.setdata
local node_new = dnode.new
local node_free = dnode.flush_node or dnode.free
local sid_save = node.subtype 'pdf_save'
local sid_user = node.subtype 'user_defined'
+local getnest = tex.getnest
local tex_nest = tex.nest
-local tex_getcount = tex.getcount
+local getcount = tex.getcount
local ensure_tex_attr = ltjb.ensure_tex_attr
local PROCESSED = luatexja.icflag_table.PROCESSED
local PROCESSED_BEGIN_FLAG = luatexja.icflag_table.PROCESSED_BEGIN_FLAG
local dir_node_auto = luatexja.dir_table.dir_node_auto
local dir_node_manual = luatexja.dir_table.dir_node_manual
local function get_attr_icflag(p)
- return (has_attr(p, attr_icflag) or 0) % PROCESSED_BEGIN_FLAG
+ return (get_attr(p, attr_icflag) or 0) % PROCESSED_BEGIN_FLAG
end
local page_direction
dir_pool = {}
for _,i in pairs({dir_tate, dir_yoko, dir_dtou, dir_utod}) do
local w = node_new(id_whatsit, sid_user)
- dnode.setattributelist(w, nil)
+ dnode.setattributelist(w, nil)
set_attr(w, attr_dir, i); set_attr(w, attr_icflag, 0)
setfield(w, 'user_id', DIR)
setfield(w, 'type', 110); setnext(w, nil)
local get_dir_count, get_adjust_dir_count
do
- local node_attr = node.has_attribute
+ local node_attr = node.get_attribute
local function get_dir_count_inner(h)
if h then
if h.id==id_whatsit and h.subtype==sid_user and h.user_id==DIR then
end
function get_dir_count()
for i=tex_nest.ptr, 1, -1 do
- local h = tex_nest[i].head.next
+ local h = getnest(i).head.next
if h then
local t = get_dir_count_inner(h)
if t~=0 then return t end
end
function get_adjust_dir_count()
for i=tex_nest.ptr, 1, -1 do
- local v = tex_nest[i]
+ local v = getnest(i)
local h, m = v.head.next, v.mode
if abs(m)== ltjs.vmode and h then
local t = get_dir_count_inner(h)
local node_next_node, node_tail_node = node.next, node.tail
local insert_after_node = node.insert_after
function luatexja.direction.set_list_direction_hook(v)
- local lv = tex_nest.ptr -- must be >= 1
if not v then
v = get_dir_count()
- if abs(tex_nest[lv-1].mode) == ltjs.mmode and v == dir_tate then
+ if abs(getnest(tex_nest.ptr-1).mode) == ltjs.mmode and v == dir_tate then
v = dir_utod
end
elseif v=='adj' then
v = get_adjust_dir_count()
end
- local h = tex_nest[lv].head
+ local h = getnest().head
local hn = node.next(h)
hn = (hn and hn.id==id_local) and hn or h
local w = to_node(dir_pool[v]())
insert_after_node(h, hn, w)
- tex_nest[lv].tail = node_tail_node(w)
+ getnest().tail = node_tail_node(w)
ensure_tex_attr(attr_icflag, 0)
ensure_tex_attr(attr_dir, 0)
end
local lv = tex_nest.ptr
if not v then
v,name = get_dir_count(), nil
- if lv>=1 and abs(tex_nest[lv-1].mode) == ltjs.mmode and v == dir_tate then
+ if lv>=1 and abs(getnest(lv-1).mode) == ltjs.mmode and v == dir_tate then
v = dir_utod
end
elseif v=='adj' then
v,name = get_adjust_dir_count(), nil
end
- local current_nest = tex_nest[lv]
+ local current_nest = getnest()
if tex.currentgrouptype==6 then
ltjb.package_error(
'luatexja',
end
end
if hd==wh[1] then
- ltjs.list_dir = has_attr(hd, attr_dir)
+ ltjs.list_dir = get_attr(hd, attr_dir)
local x = node_next(hd)
while x and getid(x)==id_glue and getsubtype(x)==3 do
node_remove(hd,x); node_free(x); x = node_next(hd)
-- 2nd ret val はその DIR whatsit
function get_box_dir(b, default)
start_time_measure 'get_box_dir'
- local dir = has_attr(b, attr_dir) or 0
+ local dir = get_attr(b, attr_dir) or 0
local bh = getfield(b, 'head') -- We cannot use getlist since b may be an unset_node.
local c
if bh~=0 then -- bh != nil
for bh in traverse_id(id_whatsit, bh) do
if getsubtype(bh)==sid_user and getfield(bh, 'user_id')==DIR then
- c = bh; dir = (dir==0) and has_attr(bh, attr_dir) or dir
+ c = bh; dir = (dir==0) and get_attr(bh, attr_dir) or dir
end
end
end
end
do
+ local ltj_tempcnta = luatexbase.registernumber 'ltj@tempcnta'
local getbox = tex.getbox
local dir_backup
function luatexja.direction.unbox_check_dir(is_copy)
start_time_measure 'box_primitive_hook'
local list_dir = get_dir_count()%dir_math_mod
- local b = getbox(tex_getcount 'ltj@tempcnta')
+ local b = getbox(getcount(ltj_tempcnta))
if b and getlist(to_direct(b)) then
local box_dir = get_box_dir(to_direct(b), dir_yoko)
if box_dir%dir_math_mod ~= list_dir then
stop_time_measure 'box_primitive_hook'
end
function luatexja.direction.uncopy_restore_whatsit()
- local b = getbox(tex_getcount 'ltj@tempcnta')
+ local b = getbox(getcount(ltj_tempcnta))
if b then
local bd = to_direct(b)
if dir_backup then
end
local shift_old, b_dir, wh = nil, get_box_dir(bh, 0)
if wh then
- dnode.flush_list(getfield(wh, 'value'))
- setfield(wh, 'value', nil)
+ dnode.flush_list(getvalue(wh)); setvalue(wh, nil)
end
return nh, nb, bh, b_dir
end
-- dir_node としてカプセル化されている
local _, dnc = get_box_dir(b, 0)
if dnc then -- free all other dir_node
- dnode.flush_list(getfield(dnc, 'value'))
- setfield(dnc, 'value', nil)
+ dnode.flush_list(getvalue(dnc)); setvalue(dnc, nil)
end
set_attr(b, attr_dir, box_dir%dir_math_mod + dir_node_auto)
return head, node_next(b), b, true
end
box_dir = box_dir%dir_math_mod
local db
- local dnh = getfield(dn, 'value')
+ local dnh = getvalue(dn)
for x in traverse(dnh) do
- if has_attr(x, attr_dir)%dir_math_mod == new_dir then
- setfield(dn, 'value', to_node(node_remove(dnh, x)))
+ if get_attr(x, attr_dir)%dir_math_mod == new_dir then
+ setvalue(dn, to_node(node_remove(dnh, x)))
db=x; break
end
end
- dnode.flush_list(getfield(dn, 'value'))
- setfield(dn, 'value', nil)
+ dnode.flush_list(getvalue(dn)); setvalue(dn, nil)
db = db or create_dir_node(b, box_dir, new_dir, false)
local w, h, d = getwhd(b)
nh, nb = insert_before(head, b, db), nil
local id_glue = node.id 'glue'
local function lastbox_hook()
start_time_measure 'box_primitive_hook'
- local bn = tex_nest[tex_nest.ptr].tail
+ local bn = getnest().tail
if bn then
- local b, head = to_direct(bn), to_direct(tex_nest[tex_nest.ptr].head)
+ local b, head = to_direct(bn), to_direct(getnest().head)
local bid = getid(b)
if bid==id_hlist or bid==id_vlist then
local p = getlist(b)
if box_dir>= dir_node_auto then -- unwrap dir_node
local p = node_prev(b)
local dummy1, dummy2, nb = unwrap_dir_node(b, nil, box_dir)
- setnext(p, nb); tex_nest[tex_nest.ptr].tail = to_node(nb)
+ setnext(p, nb); getnest().tail = to_node(nb)
setnext(b, nil); setlist(b, nil)
node_free(b); b = nb
end
local _, wh = get_box_dir(b, 0) -- clean dir_node attached to the box
if wh then
- dnode.flush_list(getfield(wh, 'value'))
- setfield(wh, 'value', nil)
+ dnode.flush_list(getvalue(wh)); setvalue(wh, nil)
end
end
end
-- \wd, \ht, \dp の代わり
do
local getbox, setdimen = tex.getbox, tex.setdimen
+ local ltj_tempdima = luatexbase.registernumber 'ltj@tempdima'
local function get_box_dim_common(key, s, l_dir)
-- s: not dir_node.
local s_dir, wh = get_box_dir(s, dir_yoko)
s_dir = s_dir%dir_math_mod
if s_dir ~= l_dir then
local not_found = true
- for x in traverse(getfield(wh, 'value')) do
- if l_dir == has_attr(x, attr_dir)%dir_node_auto then
- setdimen('ltj@tempdima', getfield(x, key))
+ for x in traverse(getvalue(wh)) do
+ if l_dir == get_attr(x, attr_dir)%dir_node_auto then
+ setdimen(ltj_tempdima, getfield(x, key))
not_found = false; break
end
end
if not_found then
local w, h, d = getwhd(s)
- setdimen('ltj@tempdima',
- dir_node_aux[s_dir][l_dir][key](w,h,d))
+ setdimen(ltj_tempdima, dir_node_aux[s_dir][l_dir][key](w,h,d))
end
else
- setdimen('ltj@tempdima', getfield(s, key))
+ setdimen(ltj_tempdima, getfield(s, key))
end
end
local function get_box_dim(key, n)
if b_dir<dir_node_auto then
get_box_dim_common(key, s, l_dir)
elseif b_dir%dir_math_mod==l_dir then
- setdimen('ltj@tempdima', getfield(s, key))
+ setdimen(ltj_tempdima, getfield(s, key))
else
get_box_dim_common(key, getlist(s), l_dir)
end
else
- setdimen('ltj@tempdima', 0)
+ setdimen(ltj_tempdima, 0)
end
tex.sprint(cat_lp, '\\ltj@tempdima')
tex.globaldefs = gt
setlist(s, wh)
end
local db
- local dnh = getfield(wh, 'value')
+ local dnh = getvalue(wh)
for x in traverse(dnh) do
- if has_attr(x, attr_dir)%dir_node_auto==l_dir then
+ if get_attr(x, attr_dir)%dir_node_auto==l_dir then
db = x; break
end
end
if not db then
db = create_dir_node(s, s_dir, l_dir, true)
- setnext(db, dnh)
- setfield(wh, 'value',to_node(db))
+ setnext(db, dnh); setvalue(wh, to_node(db))
end
setfield(db, key, scan_dimen())
return false
if wh then
-- change dimension of dir_nodes which are created "automatically"
local bw, bh, bd = getwhd(s)
- for x in traverse(getfield(wh, 'value')) do
- local x_dir = has_attr(x, attr_dir)
+ for x in traverse(getvalue(wh)) do
+ local x_dir = get_attr(x, attr_dir)
if x_dir<dir_node_manual then
local info = dir_node_aux[s_dir][x_dir%dir_node_auto]
setwhd(x, info.width(bw,bh,bd), info.height(bw,bh,bd), info.depth(bw,bh,bd))
-- adjust
do
local id_adjust = node.id 'adjust'
- local last_node = dnode.last_node
+ local last_node = dnode.last_node
local scan_keyword = token.scan_keyword
function luatexja.direction.adjust_begin()
if scan_keyword 'pre' then tex.sprint(cat_lp, '\\ltj@@vadjust@pre')
function luatexja.direction.check_adjust_direction()
start_time_measure 'box_primitive_hook'
local list_dir = get_adjust_dir_count()
- local a = tex_nest[tex_nest.ptr].tail
+ local a = getnest().tail
local ad = to_direct(a)
if a and getid(ad)==id_adjust then
local adj_dir = get_box_dir(ad)
function luatexja.direction.populate_insertion_dir_whatsit()
start_time_measure 'box_primitive_hook'
local list_dir = get_dir_count()
- local a = tex_nest[tex_nest.ptr].tail
+ local a = getnest().tail
local ad = to_direct(a)
if (not a) or getid(ad)~=id_ins then
a = node.tail(tex.lists.page_head); ad = to_direct(a)
if split_dir_whatsit then split_dir_watsit = nil end
if p then
local bh = getlist(p)
- if getid(bh)==id_whatsit and getsubtype(bh)==sid_user and getfield(bh, 'user_id')==DIR
+ if getid(bh)==id_whatsit and getsubtype(bh)==sid_user and getfield(bh, 'user_id')==DIR
and node_next(bh) then
- ltjs.list_dir = has_attr(bh, attr_dir)
+ ltjs.list_dir = get_attr(bh, attr_dir)
setlist(p, (node_remove(bh,bh)))
split_dir_head, split_dir_2nd = bh, false
else
local w = node_next(bh)
if getid(w)==id_whatsit and getsubtype(w)==sid_user and getfield(w, 'user_id')==DIR then
- ltjs.list_dir = has_attr(w, attr_dir)
+ ltjs.list_dir = get_attr(w, attr_dir)
setlist(p, (node_remove(bh,w)))
split_dir_head, split_dir_2nd = w, true
end
end
end
sprint(cat_lp, '\\ltj@@orig@vsplit' .. tostring(n))
- end
+ end
local function dir_adjust_vpack(h, gc)
start_time_measure 'direction_vpack'
local hd = to_direct(h)
split_dir_whatsit = hd
elseif gc=='split_off' then
if split_dir_head then
- ltjs.list_dir = has_attr(split_dir_head, attr_dir)
+ ltjs.list_dir = get_attr(split_dir_head, attr_dir)
if split_dir_2nd then hd = insert_after(hd, hd, split_dir_head)
else hd = insert_before(hd, hd, split_dir_head)
end
local function dir_adjust_pre_output(h, gc)
return to_node(create_dir_whatsit_vbox(to_direct(h), gc))
end
- ltjb.add_to_callback('pre_output_filter', dir_adjust_pre_output,
+ ltjb.add_to_callback('pre_output_filter', dir_adjust_pre_output,
'ltj.direction', 10000)
end
tex.setattribute(attr_dir, dir_yoko)
local shipout_temp = node_new(id_hlist)
- dnode.setattributelist(shipout_temp, nil)
+ dnode.setattributelist(shipout_temp, nil)
tex.setattribute(attr_dir, 0)
finalize_inner = function (box)
local id_glyph = node.id 'glyph'
local getcatcode, getcount = tex.getcatcode, tex.getcount
local ltjc_is_japanese_char_curlist = ltjc.is_japanese_char_curlist
-
+local cnt_lineend = luatexbase.registernumber 'ltjlineendcomment'
local substituter
do
local uchar = utf.char
if (te ~= -1) and (getcatcode(te)==5) then
local ct = getcatcode(c)
if (ct==11) or (ct==12) then
- local lec = getcount 'ltjlineendcomment'
+ local lec = getcount(cnt_lineend)
-- Is the catcode of \ltjlineendcomment (new comment char) is 14 (comment)?
if ltjc_is_japanese_char_curlist(c) and (getcatcode(lec)==14) then
stop_time_measure 'inputbuf'; return buffer .. utfchar(lec)
--
luatexbase.provides_module({
name = 'luatexja.jfmglue',
- date = '2022-08-16',
+ date = '2022-08-18',
description = 'Insertion process of JFM glues, [x]kanjiskip and others',
})
luatexja.jfmglue = luatexja.jfmglue or {}
end
local setpenalty = node.direct.setpenalty
local setkern = node.direct.setkern
-
-local has_attr = node.direct.has_attribute
+local call_callback = luatexbase.call_callback
+
+local get_attr = node.direct.get_attribute
local set_attr = node.direct.set_attribute
local insert_before = node.direct.insert_before
local insert_after = node.direct.insert_after
local ltjs_orig_char_table = ltjs.orig_char_table
local function get_attr_icflag(p)
- return (has_attr(p, attr_icflag) or 0)%PROCESSED_BEGIN_FLAG
+ return (get_attr(p, attr_icflag) or 0)%PROCESSED_BEGIN_FLAG
end
-------------------- Helper functions
end
-- 文字クラスの決定
-local slow_find_char_class
+local slow_find_char_class, skip_table_to_glue
do
local start_time_measure = ltjb.start_time_measure
local stop_time_measure = ltjb.stop_time_measure
- slow_find_char_class = function (c, m, oc)
+ local fast_get_stack_skip = ltjs.fast_get_stack_skip
+ function slow_find_char_class (c, m, oc)
local cls = ltjf_find_char_class(oc, m)
if oc~=c and c and cls==0 then
return ltjf_find_char_class(c, m)
return cls
end
end
-end
-
-local function skip_table_to_glue(n)
- local g, st = node_new(id_glue), ltjs.fast_get_stack_skip(n)
- setglue(g, st.width, st.stretch, st.shrink, st.stretch_order, st.shrink_order)
- return g, (st.width==1073741823)
+ function skip_table_to_glue(n)
+ local g, st = node_new(id_glue), fast_get_stack_skip(n)
+ setglue(g, st[1], st[2], st[3], st[4], st[5])
+ return g, (st[1]==1073741823)
+ end
end
function (stat, Nq, Np) return false end)
-- calc next Np
-local calc_np
+local calc_np
do -- 001 -----------------------------------------------
local traverse = node.direct.traverse
local function check_next_ickern(lp)
local lx = Np.nuc
- while lp and getid(lp) == id_kern and ( getsubtype(lp)==0 or
+ while lp and getid(lp) == id_kern and ( getsubtype(lp)==0 or
getsubtype(lp)==3 or ITALIC == get_attr_icflag(lp)) do
set_attr(lp, attr_icflag, IC_PROCESSED)
lx, lp = lp, node_next(lp)
else
nc, lp = lp, node_next(lp)
end
- first, lpa = false, (lp and has_attr(lp, attr_icflag) or 0)
+ first, lpa = false, (lp and get_attr(lp, attr_icflag) or 0)
-- get_attr_icflag() ではいけない!
end
Np.nuc = nc
local function calc_np_notdef(lp)
if not font_getfont(getfont(lp)).characters[getchar(lp)] then
local ln = node_next(lp)
- if ltju.specified_feature(getfont(lp), 'notdef') and ln and getid(ln)==id_glyph then
+ if ltju.specified_feature(getfont(lp), 'notdef') and ln and getid(ln)==id_glyph then
set_attr(lp, attr_icflag, PROCESSED)
- set_attr(ln, attr_jchar_code, has_attr(lp, attr_jchar_code) or getchar(lp))
- set_attr(ln, attr_jchar_class, has_attr(lp, attr_jchar_class) or 0)
+ set_attr(ln, attr_jchar_code, get_attr(lp, attr_jchar_code) or getchar(lp))
+ set_attr(ln, attr_jchar_class, get_attr(lp, attr_jchar_class) or 0)
Np.nuc, lp = ln, ln
end
end
return lp
- end
+ end
function calc_np_aux_glyph_common(lp, acc_flag)
Np.nuc, Np.first = lp, (Np.first or lp)
if if_lang_ja(lp) then -- JAchar
-- loop
local first_glyph, last_glyph = lp
set_attr(lp, attr_icflag, PROCESSED); Np.last = lp
- local y_adjust = has_attr(lp,attr_ablshift) or 0
+ local y_adjust = get_attr(lp,attr_ablshift) or 0
local node_depth = getdepth(lp) + min(y_adjust, 0)
local adj_depth = (y_adjust>0) and (getdepth(lp) + y_adjust) or 0
setfield(lp, 'yoffset', getfield(lp, 'yoffset') - y_adjust); lp = node_next(lp)
if lid==id_glyph and not if_lang_ja(lx) then
-- 欧文文字
last_glyph = lx; set_attr(lx, attr_icflag, PROCESSED); Np.last = lx
- y_adjust = has_attr(lx,attr_ablshift) or 0
+ y_adjust = get_attr(lx,attr_ablshift) or 0
node_depth = max(getdepth(lx) + min(y_adjust, 0), node_depth)
adj_depth = (y_adjust>0) and max(getdepth(lx) + y_adjust, adj_depth) or adj_depth
setfield(lx, 'yoffset', getfield(lx, 'yoffset') - y_adjust); lx = node_next(lx)
set_attr(lx, attr_icflag, PROCESSED)
lx = node_next(lx) -- lx: アクセント本体
if getid(lx)==id_glyph then
- setfield(lx, 'yoffset', getfield(lx, 'yoffset') - (has_attr(lx,attr_ablshift) or 0))
+ setfield(lx, 'yoffset', getfield(lx, 'yoffset') - (get_attr(lx,attr_ablshift) or 0))
else -- アクセントは上下にシフトされている
- setshift(lx, getshift(lx) + (has_attr(lx,attr_ablshift) or 0))
+ setshift(lx, getshift(lx) + (get_attr(lx,attr_ablshift) or 0))
end
set_attr(lx, attr_icflag, PROCESSED)
lx = node_next(lx); set_attr(lx, attr_icflag, PROCESSED)
Np.last_char = npn
if r then
local nf, nc = getfont(npn), getchar(npn)
- local ct = (font.getfont(nf) or font.fonts[nf] ).characters[nc]
+ local ct = (font_getfont(nf) or font.fonts[nf] ).characters[nc]
if not ct then -- variation selector
node_free(r)
elseif (ct.left_protruding or 0) == 0 then
local sid_start_thread = node.subtype 'pdf_start_thread'
local sid_end_link = node.subtype 'pdf_end_link'
local sid_end_thread = node.subtype 'pdf_end_thread'
+local getvalue = node.direct.getdata
calc_np_auxtable = {
[id_glyph] = calc_np_aux_glyph_common,
[id_hlist] = function(lp)
if lps==sid_user then
if getfield(lp, 'user_id')==luatexja.userid_table.IHB then
local lq = node_next(lp);
- head = node_remove(head, lp); node_free(lp); non_ihb_flag = getfield(lp, 'value')~=1
+ head = node_remove(head, lp); node_free(lp); non_ihb_flag = getvalue(lp)~=1
return false, lq;
elseif getfield(lp, 'user_id')==luatexja.userid_table.JA_AL_BDD then
local lq = node_next(lp);
return false, lq;
else
set_attr(lp, attr_icflag, PROCESSED)
- luatexbase.call_callback("luatexja.jfmglue.whatsit_getinfo",
+ call_callback("luatexja.jfmglue.whatsit_getinfo",
Np, lp, Nq)
if Np.nuc then
Np.id = id_pbox_w; Np.first = Np.nuc; Np.last = Np.nuc;
end,
[id_glue] = function(lp)
Np.first, Np.nuc, Np.last = (Np.first or lp), lp, lp;
- Np.id = getid(lp);
- local f = luatexbase.call_callback("luatexja.jfmglue.special_jaglue", lp)
+ Np.id = getid(lp);
+ local f = call_callback("luatexja.jfmglue.special_jaglue", lp)
if f then
set_attr(lp, attr_icflag, PROCESSED)
end
Np.first = Np.first or lp
set_attr(lp, attr_icflag, PROCESSED); lp = node_next(lp)
if getid(lp)==id_glyph then -- アクセント本体
- setfield(lp, 'yoffset', getfield(lp, 'yoffset') - (has_attr(lp,attr_ablshift) or 0))
+ setfield(lp, 'yoffset', getfield(lp, 'yoffset') - (get_attr(lp,attr_ablshift) or 0))
else -- アクセントは上下にシフトされている
- setshift(lp, getshift(lp) + (has_attr(lp,attr_ablshift) or 0))
+ setshift(lp, getshift(lp) + (get_attr(lp,attr_ablshift) or 0))
end
set_attr(lp, attr_icflag, PROCESSED); lp = node_next(lp)
set_attr(lp, attr_icflag, PROCESSED); lp = node_next(lp)
local k
-- We assume lp = node_next(Np.last)
if Nq and Nq.id==id_pbox_w then
- luatexbase.call_callback("luatexja.jfmglue.whatsit_last_minute", false, Nq, Np)
+ call_callback("luatexja.jfmglue.whatsit_last_minute", false, Nq, Np)
end
Np, Nq, non_ihb_flag = Nq, Np, true
-- We clear `predefined' entries of Np before pairs() loop,
Np.post, Np.pre, Np.xspc, Np.gk = nil, nil, nil, nil
Np.first, Np.id, Np.last, Np.met, Np.class= nil, nil, nil, nil
Np.auto_kspc, Np.auto_xspc, Np.char, Np.nuc = nil, nil, nil, nil
- -- auto_kspc, auto_xspc: normally true/false,
+ -- auto_kspc, auto_xspc: normally true/false,
-- but the number 0 when Np is ''the beginning of the box/paragraph''.
for k in pairs(Np) do Np[k] = nil end
for k = 1,#Bp do Bp[k] = nil end
while lp ~= last do
- local lpa = has_attr(lp, attr_icflag) or 0
+ local lpa = get_attr(lp, attr_icflag) or 0
-- unbox 由来ノードの検出
if (lpa>=PACKED) and (lpa%PROCESSED_BEGIN_FLAG<=BOXBDD) then
if lpa%PROCESSED_BEGIN_FLAG == BOXBDD then
local dir_tate = luatexja.dir_table.dir_tate
-- 和文文字のデータを取得
+ local has_attr = node.direct.has_attribute
local attr_jchar_class = luatexbase.attributes['ltj@charclass']
local attr_jchar_code = luatexbase.attributes['ltj@charcode']
local attr_autospc = luatexbase.attributes['ltj@autospc']
Nx.post = table_current_stack[POST + c] or 0
Nx.xspc = table_current_stack[XSP + c] or 3
Nx.kcat = table_current_stack[KCAT + c] or 0
- Nx.auto_kspc, Nx.auto_xspc = (has_attr(x, attr_autospc)==1), (has_attr(x, attr_autoxspc)==1)
+ Nx.auto_kspc, Nx.auto_xspc
+ = not has_attr(x, attr_autospc, 0), not has_attr(x, attr_autoxspc, 0)
return m, mc, cls
end
function set_np_xspc_jachar_hbox(Nx, x)
local m = ltjf_font_metric_table[getfont(x)]
- local c = has_attr(x, attr_jchar_code) or getchar(x)
- Nx.met, Nx.char = m, c; Nx.class = has_attr(x, attr_jchar_class) or 0;
+ local c = get_attr(x, attr_jchar_code) or getchar(x)
+ Nx.met, Nx.char = m, c; Nx.class = get_attr(x, attr_jchar_class) or 0;
local mc = m.char_type; Nx.char_type = mc
Nx.pre = table_current_stack[PRE + c] or 0
Nx.post = table_current_stack[POST + c] or 0
Nx.xspc = table_current_stack[XSP + c] or 3
Nx.kcat = table_current_stack[KCAT + c] or 0
- Nx.auto_kspc, Nx.auto_xspc = (has_attr(x, attr_autospc)==1), (has_attr(x, attr_autoxspc)==1)
+ Nx.auto_kspc, Nx.auto_xspc
+ = not has_attr(x, attr_autospc, 0), not has_attr(x, attr_autoxspc, 0)
end
-- 欧文文字のデータを取得
end
Nx.met = nil
Nx.xspc = table_current_stack[XSP + c] or 3
- Nx.auto_xspc = (has_attr(x, attr_autoxspc)==1)
+ Nx.auto_xspc = not has_attr(x, attr_autoxspc, 0)
end
local set_np_xspc_alchar = set_np_xspc_alchar
-- change the information for the next loop
-- change penalties (or create a new penalty, if needed)
local function handle_penalty_normal(post, pre, g)
- luatexbase.call_callback('luatexja.adjust_jfmglue', head, Nq, Np, Bp)
+ call_callback('luatexja.adjust_jfmglue', head, Nq, Np, Bp)
local a = (pre or 0) + (post or 0)
if #Bp == 0 then
if (a~=0 and not(g and getid(g)==id_kern)) then
end
local function handle_penalty_always(post, pre, g)
- luatexbase.call_callback('luatexja.adjust_jfmglue', head, Nq, Np, Bp)
+ call_callback('luatexja.adjust_jfmglue', head, Nq, Np, Bp)
local a = (pre or 0) + (post or 0)
if #Bp == 0 then
if not (g and getid(g)==id_glue) or a~=0 then
end
local function handle_penalty_suppress(post, pre, g)
- luatexbase.call_callback('luatexja.adjust_jfmglue', head, Nq, Np, Bp)
+ 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, nil, Nq.nuc, Np.nuc)
setpenalty(p, 10000); head = insert_before(head, Np.first, p)
Bp[1]=p; set_attr(p, attr_icflag, KINSOKU)
end
- else
+ else
local a = (pre or 0) + (post or 0)
for _, v in pairs(Bp) do add_penalty(v,a) end
end
local g = mc[bc][ac]
if g then
if g[1] then
- local k = node_new(id_kern, 1); setkern(k, g[1])
+ local k = node_new(id_kern, 1); setkern(k, g[1])
set_attr(k, attr_icflag, FROM_JFM)
return k, g.ratio, false, false, false
else
local f = node_new(id_glue)
set_attr(f, attr_icflag, g.priority)
- setglue(f, g.width, g.stretch, g.shrink)
+ setglue(f, g[2], g[3], g[4])
return f, g.ratio, g.kanjiskip_natural, g.kanjiskip_stretch, g.kanjiskip_shrink
end
end
if kanjiskip_jfm_flag then
local g = node_new(id_glue);
local bk = qm.kanjiskip or null_skip_table
- setglue(g, bn and (bn*bk[1]) or 0,
- bp and (bp*bk[2]) or 0,
+ setglue(g, bn and (bn*bk[1]) or 0,
+ bp and (bp*bk[2]) or 0,
bh and (bh*bk[3]) or 0, 0, 0)
set_attr(g, attr_icflag, KANJI_SKIP_JFM)
return g
local sh = bh and (bh*getfield(kanji_skip, 'shrink')) or 0
setglue(g,
bn and (bn*getwidth(kanji_skip)) or 0,
- st, sh,
+ st, sh,
(st==0) and 0 or getfield(kanji_skip, 'stretch_order'),
(sh==0) and 0 or getfield(kanji_skip, 'shrink_order'))
set_attr(g, attr_icflag, KANJI_SKIP_JFM)
end
end
end
-
+
get_kanjiskip = function()
- if Np.auto_kspc==0 or Nq.auto_kspc==0 then return nil
+ if Np.auto_kspc==0 or Nq.auto_kspc==0 then return nil
elseif Np.auto_kspc or Nq.auto_kspc then
local pm, qm = Np.met, Nq.met
if (pm.char_type==qm.char_type) and (qm.var==pm.var) then
else
local gb = get_kanjiskip_low(false, qm, 1, 1, 1)
if gb then
- return calc_ja_ja_aux(gb,
- get_kanjiskip_low(false, pm, 1, 1, 1) or node_copy(kanji_skip), 0, 1)
+ return calc_ja_ja_aux(gb,
+ get_kanjiskip_low(false, pm, 1, 1, 1) or node_copy(kanji_skip), 0, 1)
else
local ga = get_kanjiskip_low(false, pm, 1, 1, 1)
return (ga and calc_ja_ja_aux(node_copy(kanji_skip), ga, 0, 1))
or node_copy(kanji_skip)
end
end
- else
+ else
local g = node_new(id_glue)
set_attr(g, attr_icflag, kanjiskip_jfm_flag and KANJI_SKIP_JFM or KANJI_SKIP)
return g
return g, (Np.auto_kspc or Nq.auto_kspc) and get_kanjiskip_low(true, qm, kn, kp, kh)
else
local npn, nqn = Np.nuc, Nq.nuc
- local gb, db, bn, bp, bh
+ local gb, db, bn, bp, bh
= new_jfm_glue(qmc, Nq.class,
slow_find_char_class(Np.char,
qm, getchar(npn)))
- local ga, da, an, ap, ah
+ local ga, da, an, ap, ah
= new_jfm_glue(pmc,
slow_find_char_class(Nq.char,
pm, getchar(nqn)),
return node_copy(xkanji_skip)
else
local g = node_new(id_glue)
- local w, st, sh, sto, sho = getglue(xkanji_skip)
+ local w, st, sh, sto, sho = getglue(xkanji_skip)
setglue(g,
bn and (bn*w) or 0,
bp and (bp*st) or 0,
end
end
end
-
+
get_xkanjiskip = function(Nn)
if Np.auto_xspc==0 or Nq.auto_xspc==0 then
- return nil
+ return nil
elseif (Nq.xspc>=2) and (Np.xspc%2==1) and (Nq.auto_xspc or Np.auto_xspc) then
return get_xkanjiskip_low(true, Nn.met, 1, 1, 1)
else
local g, _, kn, kp, kh = new_jfm_glue(
pm.char_type,
fast_find_char_class(
- (((Nq.id==id_glue)or(Nq.id==id_kern)) and 'glue' or 'jcharbdd'), pm),
+ (((Nq.id==id_glue)or(Nq.id==id_kern)) and 'glue' or 'jcharbdd'), pm),
Np.class)
local k
if insert_ksp then
local g, k
if non_ihb_flag then g, k = calc_ja_ja_glue() end -- M->K
if not g then g = get_kanjiskip() end
- handle_penalty_normal(Nq.post, Np.pre, g);
+ handle_penalty_normal(Nq.post, Np.pre, g);
real_insert(g); real_insert(k)
elseif Nq.met then -- qid==id_hlist
local g, k
elseif Nq.pre then
local g, k; if non_ihb_flag then g, k = get_NA_skip() end -- N_A->X
if not g then g = get_xkanjiskip(Np) end
- handle_penalty_normal((qid==id_hlist and 0 or Nq.post), Np.pre, g);
+ handle_penalty_normal((qid==id_hlist and 0 or Nq.post), Np.pre, g);
real_insert(g); real_insert(k)
else
local g = non_ihb_flag and (get_OA_skip()) -- O_A
[id_hlist] = function() after_hlist(Nq) end,
[id_pbox] = function() after_hlist(Nq) end,
[id_disc] = function() after_hlist(Nq) end,
- [id_glue] = function()
- luatexbase.call_callback("luatexja.jfmglue.special_jaglue_after", Nq.nuc)
+ [id_glue] = function()
+ call_callback("luatexja.jfmglue.special_jaglue_after", Nq.nuc)
end,
[id_pbox_w]= function()
- local hh = luatexbase.call_callback("luatexja.jfmglue.whatsit_after", false, Nq, Np, head)
+ local hh = call_callback("luatexja.jfmglue.whatsit_after", false, Nq, Np, head)
-- hh: new head of false (nott processed)
if hh then head = hh end
end,
-- Insert \jcharwidowpenalty
if widow_Np.first then handle_penalty_jwp() end
else
- Np = Nq
+ Np = Nq
-- the current list is the contents of a hbox
local npi, pm = Np.id, Np.met
if npi == id_jglyph or (npi==id_pbox and pm) then
{}, {}, {first=nil},
{ auto_kspc=nil, auto_xspc=nil, char=nil, class=nil,
first=nil, id=nil, last=nil, met=nil, nuc=nil,
- post=nil, pre=nil, xspc=nil, gk=nil },
+ post=nil, pre=nil, xspc=nil, gk=nil },
{ auto_kspc=nil, auto_xspc=nil, char=nil, class=nil,
first=nil, id=nil, last=nil, met=nil, nuc=nil,
post=nil, pre=nil, xspc=nil, gk=nil },
local is_dir_tate = list_dir==dir_tate
capsule_glyph = is_dir_tate and ltjw.capsule_glyph_tate or ltjw.capsule_glyph_yoko
attr_ablshift = is_dir_tate and attr_tablshift or attr_yablshift
- local TEMP = node_new(id_glue)
- -- TEMP is a dummy node, which will be freed at the end of the callback.
+ local TEMP = node_new(id_glue)
+ -- TEMP is a dummy node, which will be freed at the end of the callback.
-- Without this node, set_attr(kanji_skip, ...) somehow creates an "orphaned" attribute list.
do
kanji_skip, kanjiskip_jfm_flag = skip_table_to_glue(KSK)
-- the current list is to be line-breaked:
-- hbox from \parindent is skipped.
local lp, par_indented, lpi, lps = head, 'boxbdd', getid(head), getsubtype(head)
- while lp and
+ while lp and
((lpi==id_whatsit and lps~=sid_user)
or ((lpi==id_hlist) and (lps==3))
or (lpi==id_local)) do
lp = calc_np(last, lp)
if Np then
handle_list_head(par_indented)
- lp = calc_np(last,lp);
+ lp = calc_np(last,lp);
while Np do
adjust_nq();
local pid, pm = Np.id, Np.met
end
-- adjust attr_icflag for avoiding error
if tex_getattr(attr_icflag)~=0 then ensure_tex_attr(attr_icflag, 0) end
- node_free(kanji_skip);
+ node_free(kanji_skip);
node_free(xkanji_skip); node_free(TEMP)
return head
end
end
do
- local IHB = luatexja.userid_table.IHB
+ local IHB = luatexja.userid_table.IHB
local BPAR = luatexja.userid_table.BPAR
local BOXB = luatexja.userid_table.BOXB
local node_prev = node.direct.getprev
local node_write = node.direct.write
+ local setvalue = node.direct.setdata
-- \inhibitglue, \disinhibitglue
local function ihb_node(v)
local tn = node_new(id_whatsit, sid_user)
setfield(tn, 'user_id', IHB)
setfield(tn, 'type', 100)
- setfield(tn, 'value', v)
+ setvalue(tn, v)
node_write(tn)
end
function luatexja.jfmglue.create_inhibitglue_node()
local tn = node_new(id_whatsit, sid_user)
setfield(tn, 'user_id', BPAR)
setfield(tn, 'type', 100)
- setfield(tn, 'value', 1)
+ setvalue(tn, 1)
node_write(tn)
end
local tn = node_new(id_whatsit, sid_user)
setfield(tn, 'user_id', BOXB)
setfield(tn, 'type', 100)
- setfield(tn, 'value', 1)
+ setvalue(tn, 1)
node_write(tn)
end
end
Np.met = Nq.met; Np.pre = 0; Np.post = 0; Np.xspc = 0
Np.auto_xspc, Np.auto_kspc = 0, 0
- end
+ end
return Np
else
return Np
local attr_yablshift = luatexbase.attributes['ltj@yablshift']
local attr_tablshift = luatexbase.attributes['ltj@tablshift']
local getcount, abs, scan_keyword = tex.getcount, math.abs, token.scan_keyword
- local tex_nest = tex.nest
+ local getnest = tex.getnest
local tex_getattr = tex.getattribute
local get_current_jfont
+ local cnt_stack = luatexbase.registernumber 'ltj@@stack'
do
local attr_curjfnt = luatexbase.attributes['ltj@curjfnt']
local attr_curtfnt = luatexbase.attributes['ltj@curtfnt']
local dir_tate = luatexja.dir_table.dir_tate
- local get_dir_count = ltjd.get_dir_count
+ local get_dir_count = ltjd.get_dir_count
function get_current_jfont()
return tex_getattr((get_dir_count()==dir_tate) and attr_curtfnt or attr_curjfnt)
end
end
+ local get_stack_skip = ltjs.get_stack_skip
-- \insertxkanjiskip
-- SPECIAL_JAGLUE のノード:
-- * (X)KANJI_SKIP(_JFM): その場で値が決まっている
-- * PROCESSED_BEGIN_FLAG + (X)KANJI_SKIP: 段落終了時に決める
local function insert_k_skip_common(ind, name, ica, icb)
- if abs(tex_nest[tex_nest.ptr].mode) ~= ltjs.hmode then return end
+ if abs(getnest().mode) ~= ltjs.hmode then return end
local g = node_new(id_glue); set_attr(g, attr_icflag, SPECIAL_JAGLUE)
- local is_late = scan_keyword("late")
+ local is_late = scan_keyword 'late'
if not is_late then
- local st = ltjs.get_stack_skip(ind, getcount('ltj@@stack'))
- if st.width==1073741823 then
+ local st = get_stack_skip(ind, getcount(cnt_stack))
+ if st[1]==1073741823 then
local bk = ltjf_font_metric_table[get_current_jfont()][name]
if bk then
setglue(g, bk[1] or 0, bk[2] or 0, bk[3] or 0, 0, 0)
end
set_attr(g, attr_yablshift, icb); node_write(g); return
end
- setglue(g, st.width, st.stretch, st.shrink, st.stretch_order, st.shrink_order)
+ setglue(g, st[1], st[2], st[3], st[4], st[5])
set_attr(g, attr_yablshift, ica)
else
set_attr(g, attr_yablshift, PROCESSED_BEGIN_FLAG + ica)
- set_attr(g, attr_tablshift, get_current_jfont())
+ set_attr(g, attr_tablshift, get_current_jfont())
end
node_write(g)
end
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)]
+ local m = ltjf_font_metric_table[get_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)
+ lxi=get_attr(lx, attr_yablshift)
if lxi>=PROCESSED_BEGIN_FLAG then
lxi = lxi%PROCESSED_BEGIN_FLAG
if lxi == KANJI_SKIP then
- 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)
+ special_jaglue_after_inner(lx, lxi, KANJI_SKIP_JFM, kanji_skip,
+ ltjf_font_metric_table[get_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)
+ special_jaglue_after_inner(lx, lxi, XKANJI_SKIP_JFM, xkanji_skip,
+ ltjf_font_metric_table[get_attr(lx, attr_tablshift)].xkanjiskip or null_skip_table)
end
else
set_attr(lx, attr_icflag, lxi)
--
luatexbase.provides_module({
name = 'luatexja.jfont',
- date = '2022-08-16',
+ date = '2022-08-20',
description = 'Loader for Japanese fonts',
})
local node_new = node.direct.new
local node_free = node.direct.flush_node or node.direct.free
-local has_attr = node.direct.has_attribute
+local get_attr = node.direct.get_attribute
local set_attr = node.direct.set_attribute
local round = tex.round
local font_getfont = font.getfont
local attr_icflag = luatexbase.attributes['ltj@icflag']
local attr_curjfnt = luatexbase.attributes['ltj@curjfnt']
local attr_curtfnt = luatexbase.attributes['ltj@curtfnt']
-local id_glyph = node.id('glyph')
-local id_kern = node.id('kern')
+local id_glyph = node.id 'glyph'
+local id_kern = node.id 'kern'
local cat_lp = luatexbase.catcodetables['latex-package']
local FROM_JFM = luatexja.icflag_table.FROM_JFM
v.end_adjust = nil
elseif #(v.end_adjust)==0 then
v.end_adjust = nil
- else
+ else
table.sort(v.end_adjust)
end
end
else
v.end_adjust = nil
- if v.end_stretch and v.end_stretch~=0.0 then
- v.end_adjust = (v.end_adjust or {})
+ if v.end_stretch and v.end_stretch~=0.0 then
+ v.end_adjust = (v.end_adjust or {})
v.end_adjust[#(v.end_adjust)+1] = v.end_stretch
end
- if v.end_shrink and v.end_ahrink~=0.0 then
- v.end_adjust = (v.end_adjust or {})
+ if v.end_shrink and v.end_ahrink~=0.0 then
+ v.end_adjust = (v.end_adjust or {})
v.end_adjust[#(v.end_adjust)+1] = -v.end_shrink
end
if v.end_adjust then v.end_adjust[#(v.end_adjust)+1] = 0.0 end
elseif xp and type(xp)~='number' then
defjfm_res = nil
else
- xp = (xp or 0)*9+36
- if xp<0 or xp>=64 then defjfm_res=nil end
+ xp = (xp or 0)*9+36
+ if xp<0 or xp>=64 then defjfm_res=nil end
end
x.priority = xp
end
end
end
if t.version<3 then
- -- In version 3, 'jcharbdd' is divided into
- -- 'alchar': ALchar (or math boundary)
+ -- In version 3, 'jcharbdd' is divided into
+ -- 'alchar': ALchar (or math boundary)
-- 'nox_alchar': ALchar (or math boundary), where xkanjiskip won't inserted
-- 'glue': glue/kern, 'jcharbdd': other cases (和文B, rule, ...)
t.chars.alchar = t.chars.jcharbdd
if type(i) == 'number' then -- char_type
for k,w in pairs(v.glue) do
v[k] = {
- nil,
+ nil, w[1], w[2], w[3],
ratio=w.ratio,
priority=FROM_JFM + w.priority,
- width = w[1], stretch = w[2], shrink = w[3],
kanjiskip_natural = w.kanjiskip_natural,
kanjiskip_stretch = w.kanjiskip_stretch,
kanjiskip_shrink = w.kanjiskip_shrink,
local load_jfont_metric, check_callback_order
local font_extra_info = {} -- defined later
do
- local cstemp
local global_flag -- true if \globaljfont, false if \jfont
load_jfont_metric = function()
if jfm_name=='' then
-- EXT
local utfbyte = utf.byte
- function luatexja.jfont.jfontdefX(g, dir, csname)
+ function luatexja.jfont.jfontdefX(g, dir)
jfm_dir, is_def_jfont = dir, true
- cstemp = csname:sub( (utfbyte(csname,1,1) == tex.escapechar) and 2 or 1, -1)
- cstemp = cstemp:sub(1, ((cstemp:sub(-1,-1)==' ') and (cstemp:len()>=2)) and -2 or -1)
global_flag = g and '\\global' or ''
- tex.sprint(cat_lp, '\\expandafter\\font\\csname ',
- (cstemp==' ') and '\\space' or cstemp, '\\endcsname')
+ tex.sprint(cat_lp, '\\expandafter\\font\\ltj@temp')
end
luatexbase.create_callback("luatexja.define_jfont", "data", function (ft, fn) return ft end)
local fastcopy=table.fastcopy
function luatexja.jfont.jfontdefY()
local j = load_jfont_metric(jfm_dir)
- local fn = font.id(cstemp)
- local f = font_getfont(fn)
+ local fn = token.get_next().mode; local f = font_getfont(fn)
if not j then
ltjb.package_error('luatexja', "bad JFM `" .. jfm_name .. "'",
'The JFM file you specified is not valid JFM file.\n'..
'So defining Japanese font is cancelled.')
- tex.sprint(cat_lp, global_flag, '\\expandafter\\let\\csname ',
- (cstemp==' ') and '\\space' or cstemp,
- '\\endcsname=\\relax')
+ tex.sprint(cat_lp, global_flag, '\\expandafter\\let\\ltj@temp\\relax')
return
end
if not f then return end
}
if auto_enable_vrt2 then
local vert_name = ltju.exist_feature(fn, 'vrt2') and 'vrt2' or 'vert'
- local rot = fmtable.rotation
+ local rot = fmtable.rotation
ltju.enable_feature(fn, vert_name)
ltju.loop_over_feat(f, {[vert_name]=true}, function (i,k) rot[i] = nil end)
end
fmtable = luatexbase.call_callback("luatexja.define_jfont", fmtable, fn)
font_metric_table[fn]=fmtable
- tex.sprint(cat_lp, global_flag, '\\protected\\expandafter\\def\\csname ',
- (cstemp==' ') and '\\space' or cstemp, '\\endcsname{\\ltj@cur'..
- (jfm_dir == 'yoko' and 'j' or 't') .. 'fnt', fn, '\\relax}')
+ tex.sprint(cat_lp, global_flag, '\\protected\\expandafter\\def\\ltj@temp',
+ '{\\ltj@cur'.. (jfm_dir == 'yoko' and 'j' or 't') .. 'fnt', fn, '\\relax}')
jfm_spec = nil
end
end
to_be_checked[i]=nil
if ltj_cb<lotf_cb then
local f = ltb.remove_from_callback(n,'luaotfload.letterspace')
- ltb.add_to_callback(n, f, 'luaotfload.letterspace',
+ ltb.add_to_callback(n, f, 'luaotfload.letterspace',
ltb.priority_in_callback(n, 'luaotfload.node_processor') + 1)
end
end
local parser=luaotfload.parsers.font_request
function is_feature_specified(s,fname)
local t = lpegmatch(parser,s); return t and t.features and t.features[fname]
- end
+ end
-- extract jfm_name, jfm_spec and jfm_var
-- normalize position of 'jfm=' and 'jfmvar=' keys
local function extract_jfm_spec(name)
jfm_ksp = (is_feature_specified(name,'ltjksp')~=false)
if jfm_dir == 'tate' then
vert_activated = (is_feature_specified(name,'vert')~=false) and (is_feature_specified(name,'vrt2')~=false)
- auto_enable_vrt2
+ auto_enable_vrt2
= (is_feature_specified(name,'vert')==nil) and (is_feature_specified(name,'vrt2')==nil)
else
vert_activated, auto_enable_vrt2 = nil, nil
local lo, hi = 1, #t
while lo < hi do
local mi = ceil((lo+hi)/2)
- if t[mi]<=i then lo=mi else hi=mi-1 end
+ if t[mi]<=i then lo=mi else hi=mi-1 end
end
return lo%2==1
end
local bname = tfmdata.psname or nameonly(tfmdata.filename)
if not font_extra_basename[bname] then
-- if the cache is present, read it
- --
+ --
local newtime = file_attributes(tfmdata.filename,"modification")
local v = "extra_" .. string.lower(bname)
local dest = load_cache(
v,
- function (t)
+ function (t)
return (t.lotf_version~=luaotfload.version)
- or (t.version~=cache_ver) or (t.modtime~=newtime)
+ or (t.version~=cache_ver) or (t.modtime~=newtime)
end
)
-- if the cache is not found or outdated, save the cache
dummytable.vorigin, dummytable.vheight = dtvo, dtvh
end
end
-
+
local function prepare_extra_data_font(id, res, name)
if type(res)=='table' and (res.psname or res.filename) then
if (res.embedding=='no') and (type(name)=='string') and (name:sub(1,5)=='psft:') then
[0x3014]=0xFE39, [0x3015]=0xFE3A, [0x3010]=0xFE3B, [0x3011]=0xFE3C,
[0x300A]=0xFE3D, [0x300B]=0xFE3E, [0x3008]=0xFE3F, [0x3009]=0xFE40,
[0x300C]=0xFE41, [0x300D]=0xFE42, [0x300E]=0xFE43, [0x300F]=0xFE44,
- [0xFF3B]=0xFE47, [0xFF3D]=0xFE48,
+ [0xFF3B]=0xFE47, [0xFF3D]=0xFE48,
}
local vert_jpotf_table, vert_feat = {}, {vert=true}
local utfbyte, utfsub = utf.byte, utf.sub
luatexja.jfont.register_vert_replace = function(t)
for i,v in pairs(t) do
- local ic = (type(i)=='number') and i or
+ local ic = (type(i)=='number') and i or
((type(i)=='string') and utfbyte(utfsub(i,1,1)) or nil)
if ic then
- vert_jpotf_table[ic] = (type(v)=='number') and v or
+ vert_jpotf_table[ic] = (type(v)=='number') and v or
((type(v)=='string') and utfbyte(utfsub(v,1,1)) or nil)
end
- end
+ end
end
luatexbase.add_to_callback(
local is_ucs_in_japanese_char = ltjc.is_ucs_in_japanese_char_direct
local ensure_tex_attr = ltjb.ensure_tex_attr
local node_write = node.direct.write
- local fonts, tex_nest = font.fonts, tex.nest
+ local fonts, getnest = font.fonts, tex.getnest
local new_ic_kern = function(g) return node_new(id_kern,3) end
local dir_tate = luatexja.dir_table.dir_tate
-- EXT: italic correction
function luatexja.jfont.append_italic()
- local p = to_direct(tex_nest[tex_nest.ptr].tail)
+ local p = to_direct(getnest().tail)
local TEMP = node_new(id_kern)
if p and getid(p)==id_glyph then
if is_ucs_in_japanese_char(p) then
local j = font_metric_table[
- has_attr(p, (get_dir_count()==dir_tate) and attr_curtfnt or attr_curjfnt)
+ get_attr(p, (get_dir_count()==dir_tate) and attr_curtfnt or attr_curjfnt)
]
local g = new_ic_kern()
setkern(g, j.char_type[find_char_class(getchar(p), j)].italic)
\directlua{%
local s = table.copy(luatexja.stack.charprop_stack_table[0])
- luatexja.base.save_cache('ltj-kinsoku_default', {s, version=3})
+ luatexja.base.save_cache('ltj-kinsoku_default', {s, version=4})
}
luatexja.lineskip = luatexja.lineskip or {}
local to_direct = node.direct.todirect
+local to_node = node.direct.tonode
local ltjl = luatexja.lineskip
local id_glue = node.id 'glue'
local id_penalty = node.id 'penalty'
local id_hlist = node.id 'hlist'
-local setfield = node.direct.setfield
-local getfield = node.direct.getfield
local getlist = node.direct.getlist
local node_new = node.direct.new
local node_prev = node.direct.getprev
local p, n = node_prev(x), node_next(x)
if p then
local pid = getid(p)
- while (id_glue<=pid) and (pid<=id_penalty) and node_prev(p) do
+ while (id_glue<=pid) and (pid<=id_penalty) and node_prev(p) do
p = node_prev(p); pid = getid(p)
end
if pid==id_hlist and getid(n)==id_hlist then
local p_dummy = ltjl.p_dummy
local make_dir_whatsit = luatexja.direction.make_dir_whatsit
local get_dir_count = luatexja.direction.get_dir_count
-local node_write = node.direct.write
-local tex_nest = tex.nest
+local getwhd = node.direct.getwhd
+local setnext = node.direct.setnext
+local getnest = tex.getnest
local function dir_adjust_append_vlist(b, loc, prev, mirrored)
local old_b = to_direct(b)
- local new_b = loc=='box' and
+ local new_b = loc=='box' and
make_dir_whatsit(old_b, old_b, get_dir_count(), 'append_vlist') or old_b
+ local _, ht, dp = getwhd(new_b)
if prev > -65536000 then
local bw = texget('baselineskip', false)
- local normal = bw - prev - getfield(new_b, mirrored and 'depth' or 'height')
+ local normal = bw - prev - (mirrored and dp or ht)
local lmin, adj = nil, 0
- local tail = to_direct(tex_nest[tex_nest.ptr].tail)
+ local tail = to_direct(getnest().tail)
if p_dummy~=ltj_profiler then
while tail and (id_glue<=getid(tail)) and (getid(tail)<=id_penalty) do
tail = node_prev(tail)
end
if tail then
if getid(tail)==id_hlist and getid(new_b)==id_hlist then
- if getdepth(tail)==prev then
+ if getdepth(tail)==prev then
lmin, adj = ltj_profiler(tail, new_b, mirrored, bw)
end
end
end
local g = node_new(id_glue)
- ltj_skip(lmin or normal, g, adj, normal, bw, loc); node_write(g)
+ ltj_skip(lmin or normal, g, adj, normal, bw, loc)
+ setnext(g, new_b); return to_node(g), (mirrored and ht or dp)
+ else return to_node(new_b), (mirrored and ht or dp)
end
- node_write(new_b)
- tex.prevdepth = getfield(new_b, mirrored and 'height' or 'depth')
- return nil -- do nothing on tex side
end
ltjb.add_to_callback('append_to_vlist_filter', dir_adjust_append_vlist, 'ltj.lineskip', 10000)
end
return provides_feature(id, t.properties.script, t.properties.language, name)
else return false
end
-end
+end
function aux.enable_feature(id, name)
local t = getfont(id)
elseif t.hb then -- HARF
local hbfont, u = t.hb.shared.font, t.hb.shared.upem
local h = hbfont:get_h_extents()
- if h and u then
+ if h and u then
a, d = h.ascender and h.ascender/u, h.descender and -h.descender/u
end
end
end
local rawdata = tfmdata.shared.rawdata
local ascender = rawdata.metadata.ascender or 0
- local default_vheight
+ local default_vheight
= rawdata.metadata.defaultvheight
or (rawdata.metadata.descender and (ascender+rawdata.metadata.descender) or units)
local units = tfmdata.units
for _,i in pairs(t.resources.sequences) do
if i.order[1] and feature_name[i.order[1]] then
local f = i.features and i.features[i.order[1]]
- if i.type == 'gsub_single' and i.steps
+ if i.type == 'gsub_single' and i.steps
and f and (universal or (f[t.properties.script] and f[t.properties.script][t.properties.language])) then
for _,j in pairs(i.steps) do
- if type(j)=='table' then
+ if type(j)=='table' then
if type(j.coverage)=='table' then
for i,k in pairs(j.coverage) do
local s = func(i,k); if s then return s end
local vert_vrt2 = { vert=true, vrt2=true }
function aux.replace_vert_variant(id, c)
- return loop_over_feat(id, vert_vrt2,
+ return loop_over_feat(id, vert_vrt2,
function (i,k) if i==c then return k end end)
or c
end
--for name, func in pairs(aux) do
--- if type(func)=="function" then
+-- if type(func)=="function" then
-- aux[name] = function(...)
-- print('LOTF_AUX', name, ...);
-- local a = func(...); print('RESULT', a); return a
search = function (t, key, prefix)
if type(t)=="table" then
prefix = prefix or ''
- for i,v in pairs(t) do
- if i==key then print(prefix..'.'..i, v)
+ for i,v in pairs(t) do
+ if i==key then print(prefix..'.'..i, v)
else search(v,key,prefix..'.'..tostring(i)) end
end
end
local node_next = node.direct.getnext
local node_remove = node.direct.remove
local node_free = node.direct.flush_node or node.direct.free
-local has_attr = node.direct.has_attribute
+local get_attr = node.direct.get_attribute
local set_attr = node.direct.set_attribute
-local tex_getcount = tex.getcount
+local getcount = tex.getcount
+local cnt_stack = luatexbase.registernumber 'ltj@@stack'
local attr_jchar_class = luatexbase.attributes['ltj@charclass']
local attr_dir = luatexbase.attributes['ltj@dir']
-- vcenter noad は軸に揃えるため,欧文ベースライン補正がかかる
local function conv_vcenter(sb)
local h = getlist(sb) ; local hd = getlist(h)
- if getid(hd)==id_whatsit and getsubtype(hd)==sid_user
+ if getid(hd)==id_whatsit and getsubtype(hd)==sid_user
and getfield(hd, 'user_id')==DIR then
local d = node_next(hd)
- if getid(d)==id_vlist and has_attr(d, attr_dir)>=dir_node_auto then
+ if getid(d)==id_vlist and get_attr(d, attr_dir)>=dir_node_auto then
node_free(hd); setlist(h, nil); node_free(h)
setlist(sb, d); set_attr(d, attr_icflag, 0)
end
setlist(p, conv_jchar_to_hbox(getlist(p), sty))
end
elseif pid == id_mchar then
- local pc, fam = getchar (p), has_attr(p, attr_jfam) or -1
+ local pc, fam = getchar (p), get_attr(p, attr_jfam) or -1
if (not is_math_letters[pc]) and is_ucs_in_japanese_char(p) and fam>=0 then
- local f = ltjs.get_stack_table(MJT + 0x100 * sty + fam, -1, tex_getcount('ltj@@stack'))
+ local f = ltjs.get_stack_table(MJT + 0x100 * sty + fam, -1, getcount(cnt_stack))
if f ~= -1 then
local q = node_new(id_sub_box)
local r = node_new(id_glyph, 256); setnext(r, nil)
- setchar(r, pc); setfont(r, f)
- local k = has_attr(r,attr_ykblshift) or 0; set_attr(r, attr_ykblshift, 0)
+ setfont(r, f, pc)
+ local k = get_attr(r,attr_ykblshift) or 0; set_attr(r, attr_ykblshift, 0)
-- ltj-setwidth 内で実際の位置補正はおこなうので,補正量を退避
local met = ltjf_font_metric_table[f]
r = capsule_glyph_math(r, met, met.char_type[ltjf_find_char_class(pc, met)]);
local getfont = node.direct.getfont
local getchar = node.direct.getchar
local getsubtype = node.direct.getsubtype
+local getvalue = node.direct.getdata
local setchar = node.direct.setchar
local setfont = node.direct.setfont
local setlang = node.direct.setlang
+local setvalue = node.direct.setdata
local to_node = node.direct.tonode
local to_direct = node.direct.todirect
local node_remove = node.direct.remove
local node_next = node.direct.getnext
local node_free = node.direct.flush_node or node.direct.free
-local has_attr = node.direct.has_attribute
+local get_attr = node.direct.get_attribute
local set_attr = node.direct.set_attribute
local unset_attr = node.direct.unset_attribute
local node_insert_after = node.direct.insert_after
elseif v<0xF0000 then -- 素直に Unicode にマップ可能
return v
else -- privete use area
- local r, aj = nil, ltjr_cidfont_data["Adobe-Japan1"]
+ local r, aj = nil, ltjr_cidfont_data["Adobe-Japan1"]
-- 先に ltj_vert_table を見る
for i,w in pairs(aj.ltj_vert_table) do
if w==v then r=i; break end
local function append_jglyph(char)
local p = node_new(id_whatsit,sid_user)
setfield(p, 'user_id', OTF); setfield(p, 'type', 100)
- setfield(p, 'value', char); node_write(p)
+ setvalue(p, char); node_write(p)
end
local myutf
local puid = getfield(p, 'user_id')
if puid==OTF then
local g = node_new(id_glyph, 0)
- setchar(g, getfield(p, 'value'))
- setfont(g, has_attr(p, attr_curfnt))
+ setfont(g, get_attr(p, attr_curfnt), getvalue(p))
setlang(g, lang_ja)
- set_attr(g, attr_kblshift, has_attr(p, attr_kblshift))
+ set_attr(g, attr_kblshift, get_attr(p, attr_kblshift))
head = node_insert_after(head, p, g)
head = node_remove(head, p)
node_free(p); p = g
local pairs = pairs
local floor = math.floor
+local get_attr = node.direct.get_attribute
local has_attr = node.direct.has_attribute
local set_attr = node.direct.set_attribute
local node_traverse = node.direct.traverse
local node_next = node.direct.getnext
local node_free = node.direct.flush_node or node.direct.free
local node_end_of_math = node.direct.end_of_math
-local tex_getcount = tex.getcount
+local getcount = tex.getcount
-local id_glyph = node.id('glyph')
-local id_math = node.id('math')
-local id_whatsit = node.id('whatsit')
-local sid_user = node.subtype('user_defined')
+local id_glyph = node.id 'glyph'
+local id_math = node.id 'math'
+local id_whatsit = node.id 'whatsit'
+local sid_user = node.subtype 'user_defined'
local attr_dir = luatexbase.attributes['ltj@dir']
local attr_curjfnt = luatexbase.attributes['ltj@curjfnt']
if uid==STCK then
wt[#wt+1] = p; node_remove(head, p)
elseif uid==DIR then
- if has_attr(p, attr_icflag)<PROCESSED_BEGIN_FLAG then
- ltjs.list_dir = has_attr(p, attr_dir)
+ if get_attr(p, attr_icflag)<PROCESSED_BEGIN_FLAG then
+ ltjs.list_dir = get_attr(p, attr_dir)
else -- こっちのケースは通常使用では起こらない
wtd[#wtd+1] = p; node_remove(head, p)
end
return node_next(p)
end,
}
- setmetatable(suppress_hyphenate_ja_aux,
+ setmetatable(suppress_hyphenate_ja_aux,
{ __index = function() return node_next end, })
- local id_boundary = node.id('boundary')
+ local id_boundary = node.id 'boundary'
local node_new, insert_before = node.direct.new, node.direct.insert_before
local setsubtype = node.direct.setsubtype
local function suppress_hyphenate_ja (h)
- start_time_measure('ltj_hyphenate')
+ start_time_measure 'ltj_hyphenate'
head = to_direct(h)
for i = 1,#wt do wt[i]=nil end
for i = 1,#wtd do wtd[i]=nil end
setfield(b, 'type', 100); setfield(b, 'user_id', JA_AL_BDD);
insert_before(head, p, b)
end
- local pf = has_attr(p, attr_curjfnt)
+ local pf = get_attr(p, attr_curjfnt)
pf = (pf and pf>0 and pf) or getfont(p)
setfont(p, ltjf_replace_altfont(pf, pc))
setlang(p, lang_ja)
p = (suppress_hyphenate_ja_aux[pid])(p)
end
end
- stop_time_measure('ltj_hyphenate'); start_time_measure('tex_hyphenate')
+ stop_time_measure 'ltj_hyphenate'; start_time_measure 'tex_hyphenate'
lang.hyphenate(h, nil)
- stop_time_measure('tex_hyphenate')
+ stop_time_measure 'tex_hyphenate'
return h
end
local ltjf_font_metric_table = ltjf.font_metric_table
local font_getfont = font.getfont
local traverse_id = node.direct.traverse_id
+local cnt_stack = luatexbase.registernumber 'ltj@@stack'
+local texget, getvalue = tex.get, node.direct.getdata
function set_box_stack_level(head, mode)
- local box_set, cl = 0, tex.currentgrouplevel + 1
+ local box_set = 0
if mode then
- for _,p in pairs(wt) do
- if getfield(p, 'value')==cl then box_set = 1 end; node_free(p)
+ local cl = (texget 'currentgrouplevel') + 1
+ for i=1,#wt do
+ local p = wt[i]
+ if getvalue(p)==cl then box_set = 1 end; node_free(p)
end
else
- for _,p in pairs(wt) do node_free(p) end
+ for i=1,#wt do node_free(wt[i]) end
end
- ltjs_report_stack_level(tex_getcount('ltj@@stack') + box_set)
+ ltjs_report_stack_level(getcount(cnt_stack) + box_set)
for _,p in pairs(wtd) do node_free(p) end
if ltjs.list_dir == dir_tate then
for p in traverse_id(id_glyph,to_direct(head)) do
if has_attr(p, attr_icflag, 0) and getlang(p)==lang_ja then
- local nf = ltjf_replace_altfont( has_attr(p, attr_curtfnt) or getfont(p) , ltjs_orig_char_table[p])
+ local nf = ltjf_replace_altfont( get_attr(p, attr_curtfnt) or getfont(p) , ltjs_orig_char_table[p])
setfont(p, nf)
if ltjf_font_metric_table[nf].vert_activated then
local pc = getchar(p); pc = ltjf_font_metric_table[nf].vform[pc]
--
-- ltj-rmlgbm.lua
--
-luatexja.load_module('base'); local ltjb = luatexja.base
+luatexja.load_module 'base'; local ltjb = luatexja.base
local cidfont_data = {}
local cache_chars = {}
do
local traverse_id, is_node = node.direct.traverse_id, node.is_node
local to_direct = node.direct.todirect
- local id_glyph = node.id('glyph')
+ local id_glyph = node.id 'glyph'
local getfont = node.direct.getfont
local getchar = node.direct.getchar
local setchar = node.direct.setchar
local fontdata = font_getfont(fnum)
if head and luatexja.jfont.font_metric_table[fnum] and luatexja.jfont.font_metric_table[fnum].vert_activated then
local vt = fontdata.ltj_vert_table
- local nh = is_node(head) and to_direct(head) or head
+ local nh = is_node(head) and to_direct(head) or head
for n in traverse_id(id_glyph, head) do
if getfont(n)==fnum then
local c = getchar(n); setchar(n, vt[c] or c)
local getheight = node.direct.getheight
local getdepth = node.direct.getdepth
local getwhd = node.direct.getwhd
+local getvalue = node.direct.getdata
local setfield = node.direct.setfield
local setglue = luatexja.setglue
local setkern = node.direct.setkern
local setdepth = node.direct.setdepth
local setwhd = node.direct.setwhd
local setlist = node.direct.setlist
+local setvalue = node.direct.setdata
local node_new = node.direct.new
local node_remove = node.direct.remove
local node_next = node.direct.getnext
local node_copy, node_tail = node.direct.copy, node.direct.tail
local node_free = node.direct.flush_node or node.direct.free
-local has_attr, set_attr = node.direct.has_attribute, node.direct.set_attribute
+local get_attr, set_attr = node.direct.get_attribute, node.direct.set_attribute
local insert_before, insert_after = node.direct.insert_before, node.direct.insert_after
local hpack = node.direct.hpack
local real_file = kpse.find_file(fname)
if real_file then dofile(real_file) end
cache_handle = io.open(fname, 'w')
- if cache_handle then
+ if cache_handle then
cache_handle:write('local lrob=luatexja.ruby.old_break_info\n')
end
end
-- ルビ組版が行われている段落/hboxでの設定が使われる.
-- ルビ文字を格納しているボックスでの設定ではない!
local function get_attr_icflag(p)
- return (has_attr(p, attr_icflag) or 0) % PROCESSED_BEGIN_FLAG
+ return (get_attr(p, attr_icflag) or 0) % PROCESSED_BEGIN_FLAG
end
local concat
do
local function expand_3bits(num)
local t = {}; local a = num
- for i = 1, 10 do
- t[i] = a%8; a = floor(a/8)
- end
+ for i = 1, 10 do t[i], a = a%8, a//8 end
return t
end
----------------------------------------------------------------
local _, hh, hd = getwhd(box)
local hx = h
while hx do
- local hic = has_attr(hx, attr_icflag) or 0
+ local hic = get_attr(hx, attr_icflag) or 0
if (hic == KANJI_SKIP) or (hic == KANJI_SKIP_JFM)
or (hic == XKANJI_SKIP) or (hic == XKANJI_SKIP_JFM)
or ((hic<=FROM_JFM+63) and (hic>=FROM_JFM)) then
local w = node_new(id_whatsit, sid_user)
setfield(w, 'type', 110); setfield(w, 'user_id', RUBY_PRE)
local wv = node_new(id_whatsit, sid_user)
- setfield(w, 'value', to_node(wv))
setfield(wv, 'type', 108)
- setfield(wv, 'value', rst); rst.count = floor(#rtlr)
+ setvalue(w, to_node(wv)); setvalue(wv, rst); rst.count = #rtlr
setfield(wv, 'user_id', RUBY_PRE) -- dummy
local n = wv
for i = 1, #rtlr do
local pre_intrusion, post_intrusion
local ppre, pmid, ppost = tmp_tbl.ppre, tmp_tbl.pmid, tmp_tbl.ppost
local mapre, mapost = tmp_tbl.mapre, tmp_tbl.mapost
- local intmode = floor(tmp_tbl.mode/4)%4
+ local intmode = (tmp_tbl.mode//4)%4
if no_begin then mapre = mapre + tmp_tbl.before_jfmgk end
if no_end then mapost = mapost + tmp_tbl.after_jfmgk end
if (tmp_tbl.mode%4 >=2) and (tmp_tbl.pre<0) and (tmp_tbl.post<0) then
if n < sumprot then
pre_intrusion = n/2; post_intrusion = n/2
else
- pre_intrusion = floor(sumprot/2); post_intrusion = sumprot - pre_intrusion
+ pre_intrusion = sumprot//2; post_intrusion = sumprot - pre_intrusion
end
p = enlarge(p, rwidth, ppre, pmid, ppost, pre_intrusion, post_intrusion)
pre_intrusion = min(mapre, pre_intrusion + round(ppre*getfield(p, 'glue_set')*65536))
local ppre, pmid, ppost = tmp_tbl.ppre, tmp_tbl.pmid, tmp_tbl.ppost
local mapre, mapost = tmp_tbl.mapre, tmp_tbl.mapost
local rpre, rmid, rpost, rsmash
- imode = floor(tmp_tbl.mode/0x100000); rsmash = (imode%2 ==1)
- imode = floor(imode/2); rpost = imode%8;
+ imode = tmp_tbl.mode//0x100000; rsmash = (imode%2 ==1)
+ imode = imode//2; rpost = imode%8;
imode = (imode-rpost)/8; rmid = imode%8;
imode = (imode-rmid)/8; rpre = imode%8
if getwidth(r) > getwidth(p) then -- change the width of p
local post_intrusion_backup, post_jfmgk_backup
local max_allow_pre, max_allow_post
-
+local flush_list = node.direct.flush_list
-- 中付き熟語ルビ,cmp containers
-- 「文字の構成を考えた」やつはどうしよう
local function pre_low_cal_box(w, cmp)
-- kf[i] : container 1--i からなる行末形
-- kf[cmp+i] : container i--cmp からなる行頭形
-- kf[2cmp+1] : 行中形
- local wv = getfield(w, 'value')
- local rst = getfield(wv, 'value')
+ local wv = getvalue(w)
+ local rst = getvalue(wv)
local mdt -- nt*: node temp
local coef = {} -- 連立一次方程式の拡大係数行列
local rtb = expand_3bits(rst.stretch)
-- w.value の node list 更新.
local nt = wv
- node.direct.flush_list(node_next(wv))
+ flush_list(node_next(wv))
for i = 1, 2*cmp+1 do setnext(nt, kf[i]); nt = kf[i] end
if cmp==1 then solve_1(coef)
local n = first_whatsit(head)
while n do
if getsubtype(n) == sid_user and getfield(n, 'user_id') == RUBY_PRE then
- local nv = getfield(n, 'value')
- local rst = getfield(nv, 'value')
+ local nv = getvalue(n)
+ local rst = getvalue(nv)
max_allow_pre = rst.pre or 0
- local atr = has_attr(n, attr_ruby) or 0
+ local atr = get_attr(n, attr_ruby) or 0
if max_allow_pre < 0 then
-- 直前のルビで intrusion がおこる可能性あり.
-- 前 run のデータが残っていればそれを使用,
local post_lown
do
local function write_aux(wv, num, bool)
- local id = has_attr(wv, attr_ruby_id) or 0
+ local id = get_attr(wv, attr_ruby_id) or 0
if id>0 and cache_handle then
cache_handle:write(
'lrob[' .. tostring(id) .. ']=' .. num .. '\nlrob[' .. tostring(-id) .. ']=' .. tostring(bool) .. '\n')
post_lown = function (rs, rw, cmp, ch)
-- ch: the head of `current' hlist
if #rs ==0 or not rw then return ch end
- local hn = has_attr(rs[1], attr_ruby)
- local fn = has_attr(rs[#rs], attr_ruby)
- local wv = getfield(rw, 'value')
+ local hn = get_attr(rs[1], attr_ruby)
+ local fn = get_attr(rs[#rs], attr_ruby)
+ local wv = getvalue(rw)
if hn==1 then
if fn==2*cmp+2 then
local hn = node_tail(wv)
node_remove(wv, hn)
insert_after(ch, rs[1], hn)
set_attr(hn, attr_icflag, PROCESSED)
- write_aux(wv, has_attr(hn, attr_ruby), has_attr(hn, attr_ruby_post_jfmgk))-- 行中形
+ write_aux(wv, get_attr(hn, attr_ruby), get_attr(hn, attr_ruby_post_jfmgk))-- 行中形
else
local deg, hn = (fn-1)/2, wv
for i = 1, deg do hn = node_next(hn) end;
setnext(hn, nil)
insert_after(ch, rs[1], hn)
set_attr(hn, attr_icflag, PROCESSED)
- write_aux(wv, has_attr(hn, attr_ruby), has_attr(hn, attr_ruby_post_jfmgk))
+ write_aux(wv, get_attr(hn, attr_ruby), get_attr(hn, attr_ruby_post_jfmgk))
end
else
local deg, hn = max((hn-1)/2,2), wv
insert_after(ch, rs[1], hn)
set_attr(hn, attr_icflag, PROCESSED)
if fn == 2*cmp-1 then
- write_aux(wv, has_attr(hn, attr_ruby), has_attr(hn, attr_ruby_post_jfmgk))
+ write_aux(wv, get_attr(hn, attr_ruby), get_attr(hn, attr_ruby_post_jfmgk))
end
end
for i = 1,#rs do
end
end
+local traverse_id = node.direct.traverse_id
local function post_high_break(head)
local rs = {} -- rs: sequence of ruby_nodes,
local rw = nil -- rw: main whatsit
local cmp = -2 -- dummy
- for h in node.direct.traverse_id(id_hlist, to_direct(head)) do
+ for h in traverse_id(id_hlist, to_direct(head)) do
for i = 1, #rs do rs[i] = nil end
local ha = getlist(h)
while ha do
or (hai == id_rule and getsubtype(ha)==0)
or (hai == id_whatsit and getsubtype(ha)==sid_user
and getfield(ha, 'user_id', RUBY_POST)))
- and has_attr(ha, attr_ruby) or 0
+ and get_attr(ha, attr_ruby) or 0
if i==0 then
ha = node_next(ha)
elseif i==1 then
rs[1], rw = ha, nil; ha = node_next(ha)
elseif i==2 then
rw = ha
- cmp = getfield(getfield(rw, 'value'), 'value').count
+ cmp = getvalue(getvalue(rw)).count
local hb, hc = node_remove(getlist(h), rw)
setlist(h, hb); ha = hc
else -- i>=3
or (hai == id_rule and getsubtype(ha)==0)
or (hai == id_whatsit and getsubtype(ha)==sid_user
and getfield(ha, 'user_id', RUBY_POST)))
- and has_attr(ha, attr_ruby) or 0
+ and get_attr(ha, attr_ruby) or 0
if i==0 then
ha = node_next(ha)
elseif i==1 then
rs[1], rw = ha, nil; ha = node_next(ha)
elseif i==2 then
rw = ha
- cmp = getfield(getfield(rw, 'value'), 'value').count
+ cmp = getvalue(getvalue(rw)).count
head, ha = node_remove(head, rw)
else -- i >= 3
rs[#rs+1] = ha; ha = node_next(ha)
do
local RIPRE = luatexja.stack_table_index.RIPRE
local RIPOST = luatexja.stack_table_index.RIPOST
- local abs = math.abs
+ local abs = math.abs
local function whatsit_callback(Np, lp, Nq)
if Np.nuc then return Np
elseif getfield(lp, 'user_id') == RUBY_PRE then
Np.first, Np.nuc, Np.last = lp, lp, lp
- local lpv = getfield(lp, 'value')
- local rst = getfield(lpv, 'value')
+ local lpv = getvalue(lp)
+ local rst = getvalue(lpv)
local x = node_next(node_next(lpv))
Np.last_char = luatexja.jfmglue.check_box_high(Np, getlist(x), nil)
if Nq.id ~=id_pbox_w then
Np.first = last_glue
next_cluster_array[Nq.nuc] = last_glue -- ルビ処理用のグルー
end
- local nqnv = getfield(Nq.nuc, 'value')
- local rst = getfield(nqnv, 'value')
- if Nq.gk then
+ local nqnv = getvalue(Nq.nuc)
+ local rst = getvalue(nqnv)
+ if Nq.gk then
if type(Nq.gk)=="table" then
for _,v in ipairs(Nq.gk) do add_gk(rst, 'before_jfmgk', v) end
else add_gk(rst, 'before_jfmgk', Nq.gk) end
end
rst.post = p
end
- Np.prev_ruby = has_attr(getfield(Nq.nuc, 'value'), attr_ruby_id)
+ Np.prev_ruby = get_attr(getvalue(Nq.nuc), attr_ruby_id)
-- 前のクラスタがルビであったことのフラグ
else -- 直前が文字以外
- local nqnv = getfield(Nq.nuc, 'value')
- local rst = getfield(nqnv, 'value')
+ local nqnv = getvalue(Nq.nuc)
+ local rst = getvalue(nqnv)
if rst.post < 0 then -- auto
rst.post = 0
end
"luatexja.ruby.np_info_after", 1)
local function w (s, Nq, Np)
if not s and getfield(Nq.nuc, 'user_id') == RUBY_PRE then
- local rst = getfield(getfield(Nq.nuc, 'value'), 'value')
- if Np.gk then
+ local rst = getvalue(getvalue(Nq.nuc))
+ if Np.gk then
if type(Np.gk)=="table" then
for _,v in ipairs(Np.gk) do add_gk(rst, 'after_jfmgk', v) end
else add_gk(rst, 'after_jfmgk', Np.gk) end
local node_remove = node.direct.remove
local node_tail = node.direct.tail
local node_next = node.direct.getnext
-local has_attr = node.direct.has_attribute
+local get_attr = node.direct.get_attribute
local set_attr = node.direct.set_attribute
local node_insert_before = node.direct.insert_before
local node_insert_after = node.direct.insert_after
local PROCESSED_BEGIN_FLAG = luatexja.icflag_table.PROCESSED_BEGIN_FLAG
local floor = math.floor
get_pr_begin_flag = function (p)
- local i = has_attr(p, attr_icflag) or 0
+ local i = get_attr(p, attr_icflag) or 0
return i - i%PROCESSED_BEGIN_FLAG
end
end
if not char_data then return node_next(p), head, p end
fshift.down = char_data.down; fshift.left = char_data.left
fshift = call_callback("luatexja.set_width", fshift, met, char_data)
- local kbl = has_attr(p, attr_ykblshift) or 0
+ local kbl = get_attr(p, attr_ykblshift) or 0
--
-- f*: whd specified in JFM
local pwidth, pheight,pdepth = getwhd(p)
local function capsule_glyph_tate_rot(p, met, char_data, head, dir, asc)
fshift.down = char_data.down; fshift.left = char_data.left
fshift = call_callback("luatexja.set_width", fshift, met, char_data)
- local kbl = has_attr(p, attr_tkblshift) or 0
+ local kbl = get_attr(p, attr_tkblshift) or 0
-- f*: whd specified in JFM
local pwidth, pheight,pdepth = getwhd(p)
local fwidth = char_data.width or pwidth
if met.rotation and met.vert_activated then
local f = font_getfont(pf)
local r, l = met.rotation[pc], f.properties and f.properties.language
- if ((r==true) or (type(r)=="table" and not r[l])) and (has_attr(p, attr_vert_ori) or 0)<=0 then
- return capsule_glyph_tate_rot(p, met, char_data, head, dir,
+ if ((r==true) or (type(r)=="table" and not r[l])) and (get_attr(p, attr_vert_ori) or 0)<=0 then
+ return capsule_glyph_tate_rot(p, met, char_data, head, dir,
0.5*(get_ascender(pf)-get_descender(pf)))
end
end
fshift = call_callback("luatexja.set_width", fshift, met, char_data)
local fheight = char_data.height or 0
local fdepth = char_data.depth or 0
- local y_shift = xo + (has_attr(p,attr_tkblshift) or 0)
+ local y_shift = xo + (get_attr(p,attr_tkblshift) or 0)
local q
head, q = node_remove(head, p)
local box = node_new(id_hlist, nil, p)
fshift = call_callback("luatexja.set_width", fshift, met, char_data)
local fheight, fdepth = char_data.height, char_data.depth
local y_shift
- = - getfield(p, 'yoffset') + (has_attr(p,attr_ykblshift) or 0)
+ = - getfield(p, 'yoffset') + (get_attr(p,attr_ykblshift) or 0)
setfield(p, 'yoffset', -fshift.down)
setfield(p, 'xoffset', getfield(p, 'xoffset') + char_data.align*(fwidth-pwidth) - fshift.left)
local box = node_new(id_hlist, nil, p);
local pid = getid(p)
if p==last then
return
- elseif (has_attr(p, attr_icflag) or 0) ~= PROCESSED then
+ elseif (get_attr(p, attr_icflag) or 0) ~= PROCESSED then
if pid==id_hlist or pid==id_vlist then
- setshift(p, getshift(p) + (has_attr(p,attr_ablshift) or 0))
+ setshift(p, getshift(p) + (get_attr(p,attr_ablshift) or 0))
elseif pid==id_rule then
- local v = has_attr(p,attr_ablshift) or 0
+ local v = get_attr(p,attr_ablshift) or 0
setheight(p, getheight(p)-v); setdepth(p, getdepth(p)+v)
set_attr(p, attr_icflag, PROCESSED)
elseif pid==id_glyph then
-- 欧文文字; 和文文字は pid == id_hlist の場合で処理される
-- (see conv_jchar_to_hbox_A in ltj-math.lua)
setfield(p, 'yoffset',
- getfield(p, 'yoffset') - (has_attr(p,attr_ablshift) or 0))
+ getfield(p, 'yoffset') - (get_attr(p,attr_ablshift) or 0))
end
set_attr(p, attr_icflag, PROCESSED)
end
if not head then return end
local y_adjust, node_depth, adj_depth = 0, 0, 0
for lp in node_traverse_id(id_glyph, head) do
- y_adjust = has_attr(lp,attr_ablshift) or 0
+ y_adjust = get_attr(lp,attr_ablshift) or 0
local ld = getdepth(lp)
node_depth = max(ld + min(y_adjust, 0), node_depth)
adj_depth = (y_adjust>0) and max(ld + y_adjust, adj_depth) or adj_depth
--
luatexbase.provides_module({
name = 'luatexja.stack',
- date = '2022-08-17',
+ date = '2022-08-20',
description = 'LuaTeX-ja stack system',
})
luatexja.stack = {}
local fastcopy = table.fastcopy
local setcount, getcount = tex.setcount, tex.getcount
local scan_int, scan_keyword = token.scan_int, token.scan_keyword
-local tex_nest = tex.nest
+local getnest = tex.getnest
+local cnt_stack = luatexbase.registernumber 'ltj@@stack'
+local cnt_grplvl = luatexbase.registernumber 'ltj@@group@level'
ltjs.hmode = 0 -- dummy
-local charprop_stack_table={};
-
+local charprop_stack_table={}
ltjs.charprop_stack_table = charprop_stack_table
charprop_stack_table[0]={}
local function get_stack_level()
- local i = getcount 'ltj@@stack'
+ local i = getcount(cnt_stack)
local j = tex.currentgrouplevel
- if j > getcount 'ltj@@group@level' then
+ if j > getcount(cnt_grplvl) then
i = i+1 -- new stack level
local gd = tex.globaldefs
if gd~=0 then tex.globaldefs = 0 end
-- 'tex.globaldefs = 0' is local even if \globaldefs > 0.
- setcount('ltj@@group@level', j)
+ setcount(cnt_grplvl, j)
for k,v in pairs(charprop_stack_table) do -- clear the stack above i
if k>=i then charprop_stack_table[k]=nil end
end
charprop_stack_table[i] = fastcopy(charprop_stack_table[i-1])
- setcount('ltj@@stack', i)
+ setcount(cnt_stack, i)
if gd~=0 then tex.globaldefs = gd end
- if tex_nest[tex_nest.ptr].mode == -ltjs.hmode then -- rest. hmode のみ
+ if getnest().mode == -ltjs.hmode then -- rest. hmode のみ
local g = node_new(id_whatsit, sid_user)
g.user_id=STCK; g.type=100; g.value=j; node.write(g)
end
function ltjs.set_stack_skip(m,sp)
local i = get_stack_level()
if not sp then return end
- if not charprop_stack_table[i][m] then
- charprop_stack_table[i][m] = {}
- end
local w,st,sh,sto,sho = getglue(sp)
- local c = charprop_stack_table[i][m]
- c.width, c.stretch, c.shrink, c.stretch_order, c.shrink_order = w, st, sh, sto, sho
+ if charprop_stack_table[i][m] then
+ local c = charprop_stack_table[i][m]
+ c[1], c[2], c[3], c[4], c[5] = w, st, sh, sto, sho
+ else
+ charprop_stack_table[i][m] = { w,st,sh,sto,sho }
+ end
if luatexja.isglobal=='global' then
for j,v in pairs(charprop_stack_table) do
- if not v[m] then v[m] = {} end
+ if not v[m] then v[m] = { true,true,true,true,true } end
local c = v[m]
- c.width, c.stretch, c.shrink, c.stretch_order, c.shrink_order = w, st, sh, sto, sho
+ c[1], c[2], c[3], c[4], c[5] = w, st, sh, sto, sho
end
end
end
ltjs.orig_char_table = orig_char_table
ltjs.list_dir = nil -- dummy
ltjs.table_current_stack = nil -- dummy
-local dummy_skip_table = { width = 0, stretch = 0, shrink = 0, stretch_order = 0, shrink_order = 0 }
+local dummy_skip_table = { 0,0,0,0,0 }
function ltjs.report_stack_level(bsl)
ltjs.table_current_stack = charprop_stack_table[bsl]
return bsl
%% Right brace \} Tilde \~}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{ltjsarticle}
- [2022/04/11 ltjsclasses ]
+ [2022/08/23 ltjsclasses ]
\def\jsc@clsname{ltjsarticle}
\def\Cjascale{0.924715}
\RequirePackage{luatexja}
\begingroup\catcode`\%=12\relax
\directlua{
local getdimen, mpt=tex.getdimen, tex.getdimen('jsc@mpt')/65536
+ local floor, cnt_dimen_at = math.floor, luatexbase.registernumber 'dimen@'
+ local print_scaled, sprint = luatexja.print_scaled, tex.sprint
local t = lua.get_functions_table()
t[\the\ltjs@@magnify@font@calc] = function()
- tex.sprint(-2,math.floor(0.5+mpt*getdimen('dimen@')))
+ sprint(-2,floor(0.5+mpt*getdimen(cnt_dimen_at)))
end
function luatexja.ltjs_unmagnify_fsize(a)
- local s = luatexja.print_scaled(math.floor(0.5+a/mpt*65536))
- tex.sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s )
+ local s = print_scaled(floor(0.5+a/mpt*65536))
+ sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s )
end
}
\endgroup
%% Right brace \} Tilde \~}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{ltjsbook}
- [2022/04/11 ltjsclasses ]
+ [2022/08/23 ltjsclasses ]
\def\jsc@clsname{ltjsbook}
\def\Cjascale{0.924715}
\RequirePackage{luatexja}
\begingroup\catcode`\%=12\relax
\directlua{
local getdimen, mpt=tex.getdimen, tex.getdimen('jsc@mpt')/65536
+ local floor, cnt_dimen_at = math.floor, luatexbase.registernumber 'dimen@'
+ local print_scaled, sprint = luatexja.print_scaled, tex.sprint
local t = lua.get_functions_table()
t[\the\ltjs@@magnify@font@calc] = function()
- tex.sprint(-2,math.floor(0.5+mpt*getdimen('dimen@')))
+ sprint(-2,floor(0.5+mpt*getdimen(cnt_dimen_at)))
end
function luatexja.ltjs_unmagnify_fsize(a)
- local s = luatexja.print_scaled(math.floor(0.5+a/mpt*65536))
- tex.sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s )
+ local s = print_scaled(floor(0.5+a/mpt*65536))
+ sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s )
end
}
\endgroup
%<*driver>
\ProvidesFile{ltjsclasses.dtx}
%</driver>
- [2022/04/11 ltjsclasses ]
+ [2022/08/23 ltjsclasses ]
%<*driver>
\IfFileExists{luatex85.sty}{\RequirePackage{luatex85}}{}
\documentclass[disablejfam]{ltjsarticle}
\begingroup\catcode`\%=12\relax
\directlua{
local getdimen, mpt=tex.getdimen, tex.getdimen('jsc@mpt')/65536
+ local floor, cnt_dimen_at = math.floor, luatexbase.registernumber 'dimen@'
+ local print_scaled, sprint = luatexja.print_scaled, tex.sprint
local t = lua.get_functions_table()
t[\the\ltjs@@magnify@font@calc] = function()
- tex.sprint(-2,math.floor(0.5+mpt*getdimen('dimen@')))
+ sprint(-2,floor(0.5+mpt*getdimen(cnt_dimen_at)))
end
function luatexja.ltjs_unmagnify_fsize(a)
- local s = luatexja.print_scaled(math.floor(0.5+a/mpt*65536))
- tex.sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s )
+ local s = print_scaled(floor(0.5+a/mpt*65536))
+ sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s )
end
}
\endgroup
%% Right brace \} Tilde \~}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{ltjskiyou}
- [2022/04/11 ltjsclasses ]
+ [2022/08/23 ltjsclasses ]
\def\jsc@clsname{ltjskiyou}
\def\Cjascale{0.924715}
\RequirePackage{luatexja}
\begingroup\catcode`\%=12\relax
\directlua{
local getdimen, mpt=tex.getdimen, tex.getdimen('jsc@mpt')/65536
+ local floor, cnt_dimen_at = math.floor, luatexbase.registernumber 'dimen@'
+ local print_scaled, sprint = luatexja.print_scaled, tex.sprint
local t = lua.get_functions_table()
t[\the\ltjs@@magnify@font@calc] = function()
- tex.sprint(-2,math.floor(0.5+mpt*getdimen('dimen@')))
+ sprint(-2,floor(0.5+mpt*getdimen(cnt_dimen_at)))
end
function luatexja.ltjs_unmagnify_fsize(a)
- local s = luatexja.print_scaled(math.floor(0.5+a/mpt*65536))
- tex.sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s )
+ local s = print_scaled(floor(0.5+a/mpt*65536))
+ sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s )
end
}
\endgroup
%% Right brace \} Tilde \~}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{ltjspf}
- [2022/04/11 ltjsclasses ]
+ [2022/08/23 ltjsclasses ]
\def\jsc@clsname{ltjspf}
\def\Cjascale{0.903375}
\RequirePackage{luatexja}
\begingroup\catcode`\%=12\relax
\directlua{
local getdimen, mpt=tex.getdimen, tex.getdimen('jsc@mpt')/65536
+ local floor, cnt_dimen_at = math.floor, luatexbase.registernumber 'dimen@'
+ local print_scaled, sprint = luatexja.print_scaled, tex.sprint
local t = lua.get_functions_table()
t[\the\ltjs@@magnify@font@calc] = function()
- tex.sprint(-2,math.floor(0.5+mpt*getdimen('dimen@')))
+ sprint(-2,floor(0.5+mpt*getdimen(cnt_dimen_at)))
end
function luatexja.ltjs_unmagnify_fsize(a)
- local s = luatexja.print_scaled(math.floor(0.5+a/mpt*65536))
- tex.sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s )
+ local s = print_scaled(floor(0.5+a/mpt*65536))
+ sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s )
end
}
\endgroup
%% Right brace \} Tilde \~}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{ltjsreport}
- [2022/04/11 ltjsclasses ]
+ [2022/08/23 ltjsclasses ]
\def\jsc@clsname{ltjsreport}
\def\Cjascale{0.924715}
\RequirePackage{luatexja}
\begingroup\catcode`\%=12\relax
\directlua{
local getdimen, mpt=tex.getdimen, tex.getdimen('jsc@mpt')/65536
+ local floor, cnt_dimen_at = math.floor, luatexbase.registernumber 'dimen@'
+ local print_scaled, sprint = luatexja.print_scaled, tex.sprint
local t = lua.get_functions_table()
t[\the\ltjs@@magnify@font@calc] = function()
- tex.sprint(-2,math.floor(0.5+mpt*getdimen('dimen@')))
+ sprint(-2,floor(0.5+mpt*getdimen(cnt_dimen_at)))
end
function luatexja.ltjs_unmagnify_fsize(a)
- local s = luatexja.print_scaled(math.floor(0.5+a/mpt*65536))
- tex.sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s )
+ local s = print_scaled(floor(0.5+a/mpt*65536))
+ sprint(-2, (s:match('%.0$')) and s:sub(1,-3) or s )
end
}
\endgroup
\expandafter\let\csname ifltj@in@latex\expandafter\endcsname
\csname iftrue\endcsname
\NeedsTeXFormat{LaTeX2e}
- \ProvidesPackage{luatexja-core}[2022-08-17 Core of LuaTeX-ja]
+ \ProvidesPackage{luatexja-core}[2022-08-24 Core of LuaTeX-ja]
\fi %</LaTeX>
%% Load prerequisite packages.
\newdimen\ltj@dimen@jQ \ltj@dimen@jQ=0.25mm
\let\jQ=\ltj@dimen@jQ \let\jH=\jQ
-%%%%%%%% error message
-\def\ltj@defnum{0}
-\def\ltj@defdimen{0}
-
%%%%%%%% Attributes for Japanese typesetting.
\newattribute\ltj@icflag % attribute for italic correction
\newattribute\ltj@curjfnt % index for ``current horizontal Japanese font''
\newlanguage\ltj@@japanese
\ltj@dir\z@
\ltj@icflag\z@
-\ltj@charclass\z@
\ltj@curjfnt\m@ne
\ltj@curtfnt\m@ne
\ltj@yablshift\z@
\ltj@tablshift\z@
\ltj@tkblshift\z@
+\newcount\ltj@tempcnta\newdimen\ltj@tempdima
+\newcount\ltj@@stack \newcount\ltj@@group@level
+\ltj@@group@level\z@\ltj@@stack\z@
+
%%%%%%%% Attributes for character ranges
-\newcount\ltj@tempcnta
\ltj@tempcnta\z@
\loop\ifnum\ltj@tempcnta<7
\expandafter\newattribute%
\csname ltj@kcat\the\ltj@tempcnta\endcsname
- \csname ltj@kcat\the\ltj@tempcnta\endcsname=\z@
\advance\ltj@tempcnta\@ne
\repeat
+\csname ltj@kcat0\endcsname=\z@
%%%%%%%% Loading luatexja.lua
%%%%%%%% \jfont\CS={...:...;jfm=metric;...}, \globaljfont
\protected\def\jfont#1{%
- \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(false, 'yoko','\luatexluaescapestring{\noexpand#1}')}}
+ \def\ltj@temp{#1}\afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(false, 'yoko')}}
\protected\def\globaljfont#1{%
- \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(true, 'yoko','\luatexluaescapestring{\noexpand#1}')}}
+ \def\ltj@temp{#1}\afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(true, 'yoko')}}
\newluafunction\ltj@@jfont@inner
\directlua{
local t = lua.get_functions_table()
t[\the\ltj@@jfont@inner] = luatexja.jfont.jfontdefY
}
-\def\ltj@@jfont{\luafunction\ltj@@jfont@inner}
+\def\ltj@@jfont{\expandafter\expandafter\expandafter\luafunction\expandafter\ltj@@jfont@inner\ltj@temp}
%%%%%%%% \tfont\CS={...:...;jfm=metric;...}, \globaltfont
\protected\def\tfont#1{%
- \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(false, 'tate','\luatexluaescapestring{\noexpand#1}')}}
+ \def\ltj@temp{#1}\afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(false, 'tate')}}
\protected\def\globaltfont#1{%
- \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(true, 'tate','\luatexluaescapestring{\noexpand#1}')}}
+ \def\ltj@temp{#1}\afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(true, 'tate')}}
%%%%%%%% \zw, \zh
\newluafunction\ltj@zw@inner
\newluafunction\ltj@@ins@xk@inner
\newluafunction\ltj@@ins@k@inner
\directlua{
- local t = lua.get_functions_table()
+ local t, ltjj = lua.get_functions_table(), luatexja.jfmglue
t[\the\ltj@reset@globaldefs@inner]
= function() luatexja.global_temp = tex.globaldefs; tex.globaldefs = 0 end
t[\the\ltj@restore@globaldefs@inner]
= function() tex.globaldefs = luatexja.global_temp end
- t[\the\ltj@@disihb@inner] = luatexja.jfmglue.create_disinhibitglue_node
- t[\the\ltj@@ihb@inner] = luatexja.jfmglue.create_inhibitglue_node
- t[\the\ltj@@fakeparbegin@inner] = luatexja.jfmglue.create_beginpar_node
- t[\the\ltj@@fakeboxbdd@inner] = luatexja.jfmglue.create_boxbdd_node
- t[\the\ltj@@ins@xk@inner] = luatexja.jfmglue.insert_xk_skip
- t[\the\ltj@@ins@k@inner] = luatexja.jfmglue.insert_k_skip
+ t[\the\ltj@@disihb@inner] = ltjj.create_disinhibitglue_node
+ t[\the\ltj@@ihb@inner] = ltjj.create_inhibitglue_node
+ t[\the\ltj@@fakeparbegin@inner] = ltjj.create_beginpar_node
+ t[\the\ltj@@fakeboxbdd@inner] = ltjj.create_boxbdd_node
+ t[\the\ltj@@ins@xk@inner] = ltjj.insert_xk_skip
+ t[\the\ltj@@ins@k@inner] = ltjj.insert_k_skip
}
\protected\luadef\ltj@reset@globaldefs \ltj@reset@globaldefs@inner
\protected\luadef\ltj@restore@globaldefs\ltj@restore@globaldefs@inner
}
%%%%%%%% \ltjsetparameter
-\newcount\ltj@@stack \newcount\ltj@@group@level
-\ltj@@group@level\z@\ltj@@stack\z@
-
\setbox\z@\hbox{%
\directlua{% This value depends on the version of LuaTeX.
- luatexja.stack.hmode = -tex.nest[tex.nest.ptr].mode
+ luatexja.stack.hmode = -tex.getnest().mode
}%
}
\setbox\z@\vbox{%
\directlua{% This value depends on the version of LuaTeX.
- luatexja.stack.vmode = -tex.nest[tex.nest.ptr].mode
+ luatexja.stack.vmode = -tex.getnest().mode
}%
}
\setbox\z@\box\voidb@x
\define@key[ltj]{japaram}{postbreakpenalty}{\ltj@@set@stack{POST}{-10000}{10000}#1\relax}
\def\ltj@@set@stack#1#2#3{%
\directlua{luatexja.stack.set_stack_perchar(luatexja.stack_table_index.#1,#2,#3)}}
-%\def\ltj@@set@stack#1,#2:#3#4#5{%
-% \directlua{luatexja.stack.set_stack_perchar(luatexja.stack_table_index.#3,
-% \ltj@safe@num@or{nil}{#1},\ltj@safe@num@or{nil}{#2},#4,#5)}}
% jatextfont = {<char_code>, <font_cs>}
% only horizontal font is supported
% {y,t}{ja,al}baselineshift = <dimen>
% yjabaselineshift = <dimen>
-\define@key[ltj]{japaram}{yalbaselineshift}{%
- \directlua{tex.setattribute(luatexja.isglobal,
- luatexbase.attributes['ltj@yablshift'], token.scan_dimen())}#1\relax}
-\define@key[ltj]{japaram}{yjabaselineshift}{%
- \directlua{tex.setattribute(luatexja.isglobal,
- luatexbase.attributes['ltj@ykblshift'], token.scan_dimen())}#1\relax}
-\define@key[ltj]{japaram}{talbaselineshift}{%
- \directlua{tex.setattribute(luatexja.isglobal,
- luatexbase.attributes['ltj@tablshift'], token.scan_dimen())}#1\relax}
-\define@key[ltj]{japaram}{tjabaselineshift}{%
- \directlua{tex.setattribute(luatexja.isglobal,
- luatexbase.attributes['ltj@tkblshift'], token.scan_dimen())}#1\relax}
+\def\ltj@set@blshift@#1{\directlua{%
+ local n = token.scan_dimen()
+ tex.setattribute(luatexja.isglobal,
+ luatexbase.attributes['#1'], (n==0) and 0 or n)
+ %次期バージョンで ... and -0x7FFFFFFF or ... に変える
+}}
+\define@key[ltj]{japaram}{yalbaselineshift}{\ltj@set@blshift@{ltj@yablshift}#1\relax}
+\define@key[ltj]{japaram}{yjabaselineshift}{\ltj@set@blshift@{ltj@ykblshift}#1\relax}
+\define@key[ltj]{japaram}{talbaselineshift}{\ltj@set@blshift@{ltj@tablshift}#1\relax}
+\define@key[ltj]{japaram}{tjabaselineshift}{\ltj@set@blshift@{ltj@tkblshift}#1\relax}
% jaxspmode = {<char_code>, <mode>}
% mode: inhibit, preonly, postonly, allow
% autospacing = <bool> (default: true)
\define@boolkey[ltj]{japaram}{autospacing}[true]{%
\ifltj@japaram@autospacing
- \directlua{luatexja.ext_print_global()}\ltj@autospc\@ne
+ \directlua{luatexja.ext_print_global()}\unsetattribute\ltj@autospc
\else
\directlua{luatexja.ext_print_global()}\ltj@autospc\z@
\fi}
% autoxspacing = <bool> (default: true)
\define@boolkey[ltj]{japaram}{autoxspacing}[true]{%
\ifltj@japaram@autoxspacing
- \directlua{luatexja.ext_print_global()}\ltj@autoxspc\@ne
+ \directlua{luatexja.ext_print_global()}\unsetattribute\ltj@autoxspc
\else
\directlua{luatexja.ext_print_global()}\ltj@autoxspc\z@
\fi}
\setbox\z@\hbox{%
\primitive\everymath{}%
$\directlua{% This value depends on the version of LuaTeX.
- luatexja.stack.mmode = -tex.nest[tex.nest.ptr].mode
+ luatexja.stack.mmode = -tex.getnest().mode
}$%
}
\setbox\z@\box\voidb@x
setfield(g,'stretch_order',sto or 0)
setfield(g,'shrink_order', sho or 0)
end
- for _,v in pairs({'char', 'depth', 'dir', 'font', 'height', 'kern', 'lang', 'next',
+ for _,v in pairs({'char', 'depth', 'dir', 'font', 'height', 'kern', 'lang', 'next',
'nucleus', 'offsets', 'penalty', 'shift', 'sub', 'subtype', 'sup'}) do
- if not dnode['set'..v] then
+ if not dnode['set'..v] then
dnode['set'..v] = function(n, ...) return setfield(n, v, ...) end
end
end
return getfield(g,'width'), getfield(g,'stretch'), getfield(g,'shrink'),
getfield(g,'stretch_order'), getfield(g,'shrink_order')
end
- for _,v in pairs({'box', 'components', 'char', 'depth', 'font', 'height', 'kern', 'lang',
+ for _,v in pairs({'box', 'components', 'char', 'depth', 'font', 'height', 'kern', 'lang',
'list', 'next', 'nucleus', 'offsets', 'penalty', 'prev', 'shift', 'sub',
'subtype', 'sup', 'whd', 'width', 'dir'}) do
- if not dnode['get'..v] then
+ if not dnode['get'..v] then
dnode['get'..v] = function(n, ...) return getfield(n, v, ...) end
end
end
'Use lua*tex instead dvilua*tex.')
end
load_module 'rmlgbm'; local ltjr = luatexja.rmlgbm -- must be 1st
-if luatexja_debug then load_module('debug') end
+if luatexja_debug then load_module 'debug' end
load_module 'lotf_aux'; local ltju = luatexja.lotf_aux
load_module 'charrange'; local ltjc = luatexja.charrange
load_module 'stack'; local ltjs = luatexja.stack
end
local function print_spec(p)
- local out=print_scaled(p.width)..'pt'
- if p.stretch~=0 then
- out=out..' plus '..print_glue(p.stretch,p.stretch_order)
+ local out=print_scaled(p.width or p[1])..'pt'
+ if (p.stretch or p[2])~=0 then
+ out=out..' plus '..print_glue(p.stretch or p[2], p.stretch_order or p[4])
end
- if p.shrink~=0 then
- out=out..' minus '..print_glue(p.shrink,p.shrink_order)
+ if (p.shrink or p[3])~=0 then
+ out=out..' minus '..print_glue(p.shrink or p[3], p.shrink_order or p[5])
end
return out
end
------------------------------------------------------------------------
-- CODE FOR GETTING/SETTING PARAMETERS
------------------------------------------------------------------------
+local getcount, texwrite = tex.getcount, tex.write
+local cnt_stack = luatexbase.registernumber 'ltj@@stack'
-- EXT: print parameters that don't need arguments
do
local tex_getattr = tex.getattribute
- local function getattr(a)
- local r = tex_getattr(a)
- return (r==-0x7FFFFFFF) and 0 or r
- end
+ local function getattr(a, d)
+ local r = tex_getattr(a); d = d or 0
+ return (r==-0x7FFFFFFF) and d or r
+ end
luatexja.unary_pars = {
yalbaselineshift = function(t)
return print_scaled(getattr('ltj@yablshift'))..'pt'
return ltjs.get_stack_table(stack_ind.JWP, 0, t)
end,
autospacing = function(t)
- return getattr('ltj@autospc')
+ return getattr('ltj@autospc', 1)
end,
autoxspacing = function(t)
- return getattr('ltj@autoxspc')
+ return getattr('ltj@autoxspc', 1)
end,
differentjfm = function(t)
local f, r = luatexja.jfmglue.diffmet_rule, '???'
end,
direction = function()
local v = ltjd.get_dir_count()
- if math.abs(tex.nest[tex.nest.ptr].mode) == ltjs.mmode and v == dir_table.dir_tate then
+ if math.abs(tex.getnest().mode) == ltjs.mmode and v == dir_table.dir_tate then
v = dir_table.dir_utod
end
return v
function luatexja.ext_get_parameter_unary()
local k= scan_arg()
if unary_pars[k] then
- tex.write(tostring(unary_pars[k](tex.getcount('ltj@@stack'))))
+ texwrite(tostring(unary_pars[k](getcount(cnt_stack))))
end
- ltjb.stop_time_measure('get_par')
+ ltjb.stop_time_measure 'get_par'
end
end
c=0 -- external range 217 == internal range 0
elseif c==31*ltjc.ATTR_RANGE then c=0
end
- -- 負の値は <U+0080 の文字の文字範囲,として出てくる.この時はいつも欧文文字なので 1 を返す
- return (c<0) and 1 or ltjc.get_range_setting(c)
+ -- 負の値は <U+0080 の文字の文字範囲,として出てくる.この時はいつも欧文文字なので 1 を返す
+ if c<0 then return 1 else return (ltjc.get_range_setting(c)==0) and 0 or 1 end
end,
prebreakpenalty = function(c, t)
return ltjs.get_stack_table(stack_ind.PRE + ltjb.in_unicode(c, true), 0, t)
binary_pars.alxspmode = binary_pars.jaxspmode
function luatexja.ext_get_parameter_binary(k, c)
if binary_pars[k] then
- tex.write(tostring(binary_pars[k](c,tex.getcount('ltj@@stack'))))
+ texwrite(tostring(binary_pars[k](c, getcount(cnt_stack))))
end
- ltjb.stop_time_measure('get_par')
+ ltjb.stop_time_measure 'get_par'
end
end
ensure_tex_attr(attr_icflag, 0)
if gc == 'fin_row' then return head
else
- start_time_measure('jfmglue')
+ start_time_measure 'jfmglue'
slide(head);
local p = ltjj.main(to_direct(head),mode, dir)
- stop_time_measure('jfmglue')
+ stop_time_measure 'jfmglue'
return to_node(p)
end
end
-- lastnodechar
do
- local id_glyph = node.id('glyph')
+ local getnest = tex.getnest
+ local id_glyph = node.id 'glyph'
function luatexja.pltx_composite_last_node_char()
- local n = tex.nest[tex.nest.ptr].tail
+ local n = getnest()
local r = '-1'
if n then
if n.id==id_glyph then
- while n.componetns and n.subtype and n.subtype%4 >= 2 do
+ while n.components and n.subtype and n.subtype%4 >= 2 do
n = node.tail(n)
end
r = tostring(n.char)
end
do
- local cache_ver = 3 -- must be same as ltj-kinsoku.tex
+ local cache_ver = 4 -- must be same as ltj-kinsoku.tex
local cache_outdate_fn = function (t) return t.version~=cache_ver end
local t = ltjs.charprop_stack_table
function luatexja.load_kinsoku()
else
t[0] = {}; tex.print(cat_lp, '\\input ltj-kinsoku.tex\\relax')
end
- luatexja.load_kinsoku=nil; ltjs.charprop_stack_table = nil
+ luatexja.load_kinsoku=nil
end
end
local node_type = node.type
local node_next = node.next
-local has_attr = node.has_attribute
+local get_attr = node.get_attribute
-local id_penalty = node.id('penalty')
-local id_glyph = node.id('glyph')
-local id_glue = node.id('glue')
-local id_kern = node.id('kern')
-local id_hlist = node.id('hlist')
-local id_vlist = node.id('vlist')
-local id_rule = node.id('rule')
-local id_math = node.id('math')
-local id_whatsit = node.id('whatsit')
-local sid_user = node.subtype('user_defined')
+local id_penalty = node.id 'penalty'
+local id_glyph = node.id 'glyph'
+local id_glue = node.id 'glue'
+local id_kern = node.id 'kern'
+local id_hlist = node.id 'hlist'
+local id_vlist = node.id 'vlist'
+local id_rule = node.id 'rule'
+local id_math = node.id 'math'
+local id_whatsit = node.id 'whatsit'
+local sid_user = node.subtype 'user_defined'
local prefix, inner_depth
local utfchar = utf.char
local function debug_show_node_X(p,print_fn, limit, inner_depth)
local k = prefix
local s
- local pt, pic = node_type(p.id), (has_attr(p, attr_icflag) or 0) % icflag_table.PROCESSED_BEGIN_FLAG
+ local pt, pic = node_type(p.id), (get_attr(p, attr_icflag) or 0) % icflag_table.PROCESSED_BEGIN_FLAG
local base = prefix .. string.format('%X', pic) .. ' ' .. pt .. ' ' .. tostring(p.subtype) .. ' '
if pt == 'glyph' then
- s = base .. ' '
- .. (p.char<0xF0000 and utfchar(p.char) or '')
+ s = base .. ' '
+ .. (p.char<0xF0000 and utfchar(p.char) or '')
.. string.format(' (U+%X) ', p.char)
.. tostring(p.font) .. ' (' .. print_scaled(p.height) .. '+'
.. print_scaled(p.depth) .. ')x' .. print_scaled(p.width)
if pt=='ins' then
s = base .. '(' .. print_scaled(p.height) .. '+'
.. print_scaled(p.depth) .. ')'
- .. ', dir=' .. tostring(node.has_attribute(p, attr_dir))
+ .. ', dir=' .. tostring(node.get_attribute(p, attr_dir))
else
s = base .. '(' .. print_scaled(p.height) .. '+'
.. print_scaled(p.depth) .. ')x' .. print_scaled(p.width)
- .. ', dir=' .. tostring(node.has_attribute(p, attr_dir))
+ .. ', dir=' .. tostring(node.get_attribute(p, attr_dir))
end
if (p.shift or 0)~=0 then
s = s .. ', shifted ' .. print_scaled(p.shift)
elseif pt=='rule' then
s = base .. '(' .. print_scaled(p.height) .. '+'
.. print_scaled(p.depth) .. ')x' .. print_scaled(p.width)
- .. ', dir=' .. tostring(node.has_attribute(p, attr_dir))
+ .. ', dir=' .. tostring(node.get_attribute(p, attr_dir))
print_fn(s)
elseif pt=='disc' then
print_fn(s)
else
s = s .. ' userid:' .. t .. '(node list)'
if p.user_id==uid_table.DIR then
- s = s .. ' dir: ' .. tostring(node.has_attribute(p, attr_dir))
+ s = s .. ' dir: ' .. tostring(node.get_attribute(p, attr_dir))
end
print_fn(s)
local bid = inner_depth
%
% lltjp-tascmac.sty
% based on tascmac.sty [2016/04/15 v2.0b (community edition)]
-% \tbaselineshift=\z@ ==> \ltj@tablshift=\z@
-% \ybaselineshift=\z@ ==> \ltj@yablshift=\z@
-% \dimen...=\tbaselineshift ==> \dimen...=\ltj@tablshift sp
-% \dimen...=\ybaselineshift ==> \dimen...=\ltj@yablshift sp
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{lltjp-tascmac}[2020/12/24 Patch to (t)ascmac for LuaTeX-ja]
+\ProvidesPackage{lltjp-tascmac}[2022-08-24 Patch to (t)ascmac for LuaTeX-ja]
\RequirePackage{tascmac}
}
%% boxnote environment
+\def\ltj@backup@attr#1#2{\ifnum#1=-"7FFFFFFF #2\z@\else #2=#1sp\fi#1=0 }
+\def\ltj@restore@attr#1#2{#1#2}
+%\def\ltj@backup@attr#1#2{\ifnum#1=-"7FFFFFFF #2\z@\else #2=#1sp\fi\unsetattribute#1}
+%\def\ltj@restore@attr#1#2{\ifdim#2=\z@ \unsetattribute#1\else #1#2\fi}
\def\boxnote{\par\vspace{.3\baselineskip}%
- \@saveybaselineshift\ltj@yablshift sp\ltj@yablshift\z@
- \@savetbaselineshift\ltj@tablshift sp\ltj@tablshift\z@
+ \ltj@backup@attr\ltj@yablshift\@saveybaselineshift
+ \ltj@backup@attr\ltj@tablshift\@savetbaselineshift
\setbox\@nbox=\hbox{\@ascgrp\vrule width1.08pt depth35pt b\hss a\hss b}
\@whiledim \wd\@nbox<\hsize \do{
\setbox\@nbox=\hbox{\@ascgrp\unhbox\@nbox \hss a\hss b}}
\vrule width1.08pt depth35pt}%
\@bw=\wd\@nbox\advance\@bw -40pt
\begin{lrbox}{\@nbody}\begin{minipage}{\@bw}% (KN:1998/02/27)
- \ltj@yablshift\@saveybaselineshift \ltj@tablshift\@savetbaselineshift}%
+ \ltj@restore@attr\ltj@yablshift\@saveybaselineshift
+ \ltj@restore@attr\ltj@tablshift\@savetbaselineshift}%
%% screen environment
\def\screen{%
- \@saveybaselineshift\ltj@yablshift sp\ltj@yablshift\z@
- \@savetbaselineshift\ltj@tablshift sp\ltj@tablshift\z@
+ \ltj@backup@attr\ltj@yablshift\@saveybaselineshift
+ \ltj@backup@attr\ltj@tablshift\@savetbaselineshift
\@ifnextchar[{\@screen}{\@screen[0]}}
\def\@screen[#1]{\ifcase#1\def\@r{20}\def\@s{9.8pt}\def\@sx{10pt}\or
\def\@r{18}\def\@s{8.8pt}\def\@sx{9pt}\or
\def\@r{4}\def\@s{1.8pt}\def\@sx{2pt}\fi
\par\vspace{.3\baselineskip}\@scw\linewidth \advance\@scw -\@r pt
\setbox\scb@x=\hbox to\@scw\bgroup\begin{minipage}{\@scw}% (KN:1998/02/27)
- \ltj@yablshift\@saveybaselineshift \ltj@tablshift\@savetbaselineshift}%
+ \ltj@restore@attr\ltj@yablshift\@saveybaselineshift
+ \ltj@restore@attr\ltj@tablshift\@savetbaselineshift}%
%% itembox environment
\def\@itembox[#1]#2{%
- \@saveybaselineshift\ltj@yablshift sp\ltj@yablshift\z@
- \@savetbaselineshift\ltj@tablshift sp\ltj@tablshift\z@
+ \ltj@backup@attr\ltj@yablshift\@saveybaselineshift
+ \ltj@backup@attr\ltj@tablshift\@savetbaselineshift
\par\vspace{.3\baselineskip}%
\setbox\@iboxstr=\hbox{%
- \ltj@yablshift\@saveybaselineshift \ltj@tablshift\@savetbaselineshift #2}%
+ \ltj@restore@attr\ltj@yablshift\@saveybaselineshift
+ \ltj@restore@attr\ltj@tablshift\@savetbaselineshift #2}%
\@itemh\ht\@iboxstr\advance\@itemh\dp\@iboxstr
\vspace{.5\@itemh}\bgroup\@scw\linewidth
\advance\@scw-20pt\@iboxpos={#1}%
\setbox\scb@x=\hbox to\@scw\bgroup\begin{minipage}{\@scw}%
- \ltj@yablshift\@saveybaselineshift
- \ltj@tablshift\@savetbaselineshift
+ \ltj@restore@attr\ltj@yablshift\@saveybaselineshift
+ \ltj@restore@attr\ltj@tablshift\@savetbaselineshift
\vspace*{.5\@itemh}}%
%% \keytop
\def\@keytop[#1]#2{%
{\setbox0=\hbox{\shortstack{#2}}\ltj@yablshift\z@\ltj@tablshift\z@%
+ %\unsetattribute\ltj@yablshift\unsetattribute\ltj@tablshift%
\dimen0=\wd0\advance\dimen0 5pt\dimen1=\dp0\advance\dimen1 2.5pt%
\setbox\scscb@x=\hbox to\dimen0{%
\@scw\wd0\hfil\vtop{\offinterlineskip
%% \mask
\def\mask#1#2{{\setbox\@bwsp=\hbox{#1}%
+% \setbox0=\hbox{\unsetattribute\ltj@yablshift\unsetattribute\ltj@tablshift \@ascgrp#2}%
\setbox0=\hbox{\ltj@yablshift\z@\ltj@tablshift\z@ \@ascgrp#2}%
\dimen0=\wd\@bwsp\dimen1=\ht\@bwsp\advance\dimen1\dp\@bwsp\dimen2=-\dimen1
\setdim@{\dimen0}{\wd0}\setdim@{\dimen1}{\ht0}%
%% \maskbox
\def\Maskbox#1#2#3#4#5#6{{%
+% \setbox0=\hbox{\unsetattribute\ltj@yablshift\unsetattribute\ltj@tablshift \@ascgrp#3}%
\setbox0=\hbox{\ltj@yablshift\z@\ltj@tablshift\z@ \@ascgrp#3}%
\dimen0=#1\@setdim{\dimen0}{\wd0}\dimen1=#2\@setdim{\dimen1}{\ht0}%
\ifx#4c\skip0=0pt plus1fil\skip1=\skip0\fi
%% shadebox environment
\def\shadebox{\par\vspace{.3\baselineskip}%
- \@saveybaselineshift\ltj@yablshift sp\ltj@yablshift\z@
- \@savetbaselineshift\ltj@tablshift sp\ltj@tablshift\z@
+ \ltj@backup@attr\ltj@yablshift\@saveybaselineshift
+ \ltj@backup@attr\ltj@tablshift\@savetbaselineshift
\dimen0\linewidth \advance\dimen0-20pt
\advance\dimen0-2\fboxrule \advance\dimen0-\shaderule
\setbox\@tempboxa=\hbox\bgroup\minipage{\dimen0}%
- \ltj@yablshift\@saveybaselineshift \ltj@tablshift\@savetbaselineshift}
+ \ltj@restore@attr\ltj@yablshift\@saveybaselineshift
+ \ltj@restore@attr\ltj@tablshift\@savetbaselineshift}%
%% \yen
%