summaryrefslogtreecommitdiff
path: root/macros/luatex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-04-10 03:04:32 +0000
committerNorbert Preining <norbert@preining.info>2023-04-10 03:04:32 +0000
commit834896467ed7eeede69922bc224147f7b5274828 (patch)
tree3be439ebb2cf9fb9d6707e478e1415ddf1b54bb3 /macros/luatex
parent5967b720d9dc6cac6adaa93e1479c61428db2eac (diff)
CTAN sync 202304100304
Diffstat (limited to 'macros/luatex')
-rw-r--r--macros/luatex/generic/luatexja/README8
-rw-r--r--macros/luatex/generic/luatexja/doc/luatexja-en.pdfbin717552 -> 701830 bytes
-rw-r--r--macros/luatex/generic/luatexja/doc/luatexja-ja.pdfbin1149508 -> 1148687 bytes
-rw-r--r--macros/luatex/generic/luatexja/doc/luatexja.dtx168
-rw-r--r--macros/luatex/generic/luatexja/src/ltj-base.lua12
-rw-r--r--macros/luatex/generic/luatexja/src/ltj-direction.lua7
-rw-r--r--macros/luatex/generic/luatexja/src/ltj-inputbuf.lua8
-rw-r--r--macros/luatex/generic/luatexja/src/ltj-jfont.lua58
-rw-r--r--macros/luatex/generic/luatexja/src/ltj-pretreat.lua26
-rw-r--r--macros/luatex/generic/luatexja/src/ltj-rmlgbm.lua33
-rw-r--r--macros/luatex/generic/luatexja/src/ltj-setwidth.lua7
-rw-r--r--macros/luatex/generic/luatexja/src/luatexja-core.sty22
-rw-r--r--macros/luatex/generic/luatexja/src/luatexja.lua94
-rw-r--r--macros/luatex/generic/luatexja/src/patches/lltjcore.sty16
-rw-r--r--macros/luatex/generic/luatexja/src/patches/lltjfont.sty16
15 files changed, 266 insertions, 209 deletions
diff --git a/macros/luatex/generic/luatexja/README b/macros/luatex/generic/luatexja/README
index 3d22e5b989..8f5f043144 100644
--- a/macros/luatex/generic/luatexja/README
+++ b/macros/luatex/generic/luatexja/README
@@ -1,4 +1,4 @@
-The LuaTeX-ja Package 20230211.0
+The LuaTeX-ja Package 20230409.0
--------------------------------
Copyright (c) 2011--2023 The LuaTeX-ja project
License: modified BSD (see COPYING)
@@ -42,9 +42,9 @@ Installation
2. If you must/want to install manually:
a. Download the source archive from CTAN,
- or tagged as 20230211.0 in the Git repository by
+ or tagged as 20230409.0 in the Git repository by
<http://git.osdn.jp/view?p=luatex-ja/luatexja.git
- ;a=snapshot;h=refs/tags/20230211.0;sf=tgz>
+ ;a=snapshot;h=refs/tags/20230409.0;sf=tgz>
b. Extract the archive and process following three files by LuaLaTeX
to generate classes for Japanese typesetting:
@@ -93,4 +93,4 @@ Notes
This file and ltj-kinsoku.lua are not used anymore.
(Do not remove ltj-kinsoku.tex.)
-Last commit date: Sat Feb 11 18:49:41 2023 +0900
+Last commit date: Sun Apr 9 08:12:48 2023 +0900
diff --git a/macros/luatex/generic/luatexja/doc/luatexja-en.pdf b/macros/luatex/generic/luatexja/doc/luatexja-en.pdf
index eefcf7ec7e..47df10cd7d 100644
--- a/macros/luatex/generic/luatexja/doc/luatexja-en.pdf
+++ b/macros/luatex/generic/luatexja/doc/luatexja-en.pdf
Binary files differ
diff --git a/macros/luatex/generic/luatexja/doc/luatexja-ja.pdf b/macros/luatex/generic/luatexja/doc/luatexja-ja.pdf
index f073b1b74c..0cad34ccec 100644
--- a/macros/luatex/generic/luatexja/doc/luatexja-ja.pdf
+++ b/macros/luatex/generic/luatexja/doc/luatexja-ja.pdf
Binary files differ
diff --git a/macros/luatex/generic/luatexja/doc/luatexja.dtx b/macros/luatex/generic/luatexja/doc/luatexja.dtx
index 864306f916..a6139ec9c2 100644
--- a/macros/luatex/generic/luatexja/doc/luatexja.dtx
+++ b/macros/luatex/generic/luatexja/doc/luatexja.dtx
@@ -3526,7 +3526,10 @@ causes a error. We denote control sequences which are defined in
%<*en>
\begin{description}
\item[\meta{JFM name}]
- The name of a (horizontal) JFM. \LuaTeX-ja searches and loads \texttt{jfm-\meta{JFM name}.lua}.
+ The name of a (horizontal) JFM. \LuaTeX-ja searches and loads \texttt{jfm-\meta{JFM name}.lua}
+ \footnote{When \LuaTeX-ja (version~20230409 or later)
+ is used under \LaTeXe, \LuaTeX-ja searches a JFM also in directories
+ which are specified in \cs{input@path}.}.
\item[\meta{JFM features}]
An optional comma-separated list of JFM options.
Enclosing braces (\verb+{}+) are optional, but this does not escape any characters.
@@ -3552,7 +3555,9 @@ because their \meta{identifier} are different.
%<*ja>
\begin{description}
\item[\meta{JFM name}]
- (横組用)JFMの名称.\LuaTeX-jaは\texttt{jfm-\meta{JFM name}.lua}というファイルを探索して読み込む.
+ (横組用)JFMの名称.\LuaTeX-jaは\texttt{jfm-\meta{JFM name}.lua}というファイルを探索して読み込む
+ \footnote{\LuaTeX-ja 20230409.0以降では,\LaTeXe 下で読み込まれた場合には
+ \cs{input@path}で指定された箇所も加えてJFMを探索する.}.
\item[\meta{JFM features}]
省略可能なコンマ区切りリスト.全体を囲む \verb+{}+ は省略可能であるが,
囲ったからといって\meta{JFM features}の中で使用可能な文字が増えるわけではない.
@@ -3859,7 +3864,7 @@ JFM中における\texttt{kanjiskip\_natural}, \texttt{kanjiskip\_stretch},\
「JFM由来のグルーの他に,\Param{kanjiskip}の自然長/伸び量/縮み量の一部が
同じ場所に挿入される」という状況が起こりうる.
この機能を無効化し,バージョン20150922.0以前と同じような組版を得るためには,
-他のOpenType機能と同じように\texttt{-ltjksp}指定を行えば良い(\autoref{fig:ltjksp}参照).
+他のOpenType機能と同じように\>\mbox{\texttt{-ltjksp}}\>指定を行えば良い(\autoref{fig:ltjksp}参照).
なお,
\begin{lstlisting}
\jfont\G=HaranoAjiMincho-Regular:jfm=ujis;-ltjksp;+ltjksp at \zw
@@ -3875,7 +3880,7 @@ JFM中における\texttt{kanjiskip\_natural}, \texttt{kanjiskip\_stretch},\
\texttt{kanjiskip\_shrink} keys (Page~\pageref{pg:ksp_nat}) makes tha
\LuaTeX-ja inserts not only a glue which is specified by a JFM, and also
the natural width/stretch part/shrink part of \Param{kanjiskip}.
-This functionality is disabled by \texttt{-ltjksp} specification,
+This functionality is disabled by \mbox{\texttt{-ltjksp}} specification,
as shown in~\autoref{fig:ltjksp}.
%</en>
\begin{figure}
@@ -3888,10 +3893,56 @@ as shown in~\autoref{fig:ltjksp}.
\G\leavevmode%
\vrule\hbox to 15\zw{あ「い」う,えお}\vrule
\end{LTXexample}
-\caption{\texttt{ltjksp} `feature''}
+\caption{\texttt{ltjksp} ``feature''}
\label{fig:ltjksp}
\end{figure}
+%<*ja>
+\paragraph{\texttt{ltjpci}「機能」}
+\label{pg:ltjpci}
+\Pkg{luaotfload}~v3.19以降では,標準でUnicode(文字から作られるノードたち)がNFCに正規化される
+ようになっている.これにより,ソース中でたとえば「か」と合成用濁点(\texttt{U+3099})を続けて入力した場合,
+両者それぞれからノードが生成されるが,結果的には「が」を表す1ノードになるわけである.
+
+しかし,NFCに正規化することで,
+たとえば「\UTF{FA19}」(\texttt{U+FA19})が「神」(\texttt{U+795E})にというふうに,
+CJK互換漢字がCJK統合漢字に変換されてしまうという問題がある.
+異体字セレクタを用いればこのようなことは起きないが,古くからあるフォントでは異体字セレクタをサポートしていない.
+
+以上の事情に対応するため,\LuaTeX-jaでは,標準で
+\emph{CJK互換漢字・CJK互換漢字補助の文字には\Pkg{luaotfload}パッケージによる処理は働かない}ようにしている.
+この機能を無効化するには,他のOpenType機能と同じように\texttt{-ltjpci}指定を行えば良い(\autoref{fig:ltjpci}参照).
+\texttt{ltjksp}と同様に,\texttt{-ltjpci}, \texttt{+ltjpci}を複数回指定した場合は,
+最後に指定したものが有効となる.
+%</ja>
+%<*en>
+\paragraph{\texttt{ltjpci} ``feature''}
+\label{pg:ltjpci}
+By default, The \Pkg{luaotfload} package (since v3.19) normalizes Unicode sequences to NFC.
+However, this normalization converts CJK compatibility ideographs to their canonical equivalents,
+such as ``\UTF{FA19}''~(\texttt{U+FA19}) to ``神''. One can use variation selectors,
+but old fonts does not support them.
+
+So, \emph{\LuaTeX-ja now protects CJK compatibility ideographs from processing
+ by the \Pkg{luaotfload} package by defualt}.
+This functionality is disabled by \mbox{\texttt{-ltjpci}} specification,
+as shown in~\autoref{fig:ltjpci}.
+%</en>
+\begin{figure}
+\begin{LTXexample}[width=12\zw]
+\def\TEST{\leavevmode\char"FA10\char"FA12\char"FA15
+ \char"FA19.か\char"3099.は\char"309A.\par}
+\jfont\A=HaranoAjiMincho-Regular:jfm=ujis; at 15pt
+\A\TEST % default
+\jfont\G=HaranoAjiMincho-Regular:jfm=ujis;-ltjpci at 15pt
+\G\TEST % ltjpci off
+\jfont\H=HaranoAjiMincho-Regular:jfm=ujis;-normalize at 15pt
+\H\TEST % normalization off
+\end{LTXexample}
+\caption{\texttt{ltjpci} ``feature''}
+\label{fig:ltjpci}
+\end{figure}
+
%<en>\subsection{\cs{tfont}}
%<ja>\subsection{\cs{tfont} 命令}
\label{ssec:tfont}
@@ -9978,101 +10029,10 @@ u
その行はそこで改行するようにした方がいいだろう.
%</ja>
-\begin{table}[t]
-%<ja> \caption{「基底文字+合成用濁点・半濁点」から合成済み文字への変換をサポートする組み合わせ}
-%<en> \caption{Normalization of Kana Character Sequences with Combining (Semi)-voiced Sound Mark}\medskip
- \label{tab:kana_composite}
- \def\D#1{%
- {\fboxsep0pt\fcolorbox{cyan}{white}%
- {\hbox to 1\zw{\hss#1}}}} %"
- \def\DC#1{\D{\unitlength=1\zw
- \begin{picture}(1,0)
- \put(0.5,0.38){\arc[0,15]{0.25}}\put(0.5,0.38){\arc[30,45]{0.25}}\put(0.5,0.38){\arc[60,75]{0.25}}
- \put(0.5,0.38){\arc[90,105]{0.25}}\put(0.5,0.38){\arc[120,135]{0.25}}\put(0.5,0.38){\arc[150,165]{0.25}}
- \put(0.5,0.38){\arc[180,195]{0.25}}\put(0.5,0.38){\arc[210,225]{0.25}}\put(0.5,0.38){\arc[240,255]{0.25}}
- \put(0.5,0.38){\arc[270,285]{0.25}}\put(0.5,0.38){\arc[300,315]{0.25}}\put(0.5,0.38){\arc[330,345]{0.25}}
- \end{picture}\llap{#1\kern-.7\zw}}}
- \def\CDJ#1#2{$\mbox{\D{\char"#1}}+\mbox{\DC{゛}}\rightarrow \mbox{\D{\char"#2}}$}
- \def\CHJ#1#2{$\mbox{\D{\char"#1}}+\mbox{\DC{゜}}\rightarrow \mbox{\D{\char"#2}}$}
- \small\centering
- \begin{tabular}{@{}llllll@{}}
- \CDJ{3046}{3094}&
- \CDJ{304B}{304C}&
- \CDJ{304D}{304E}&
- \CDJ{304F}{3050}&
- \CDJ{3051}{3052}&
- \CDJ{3053}{3054}\\
- \CDJ{3055}{3056}&
- \CDJ{3057}{3058}&
- \CDJ{3059}{305A}&
- \CDJ{305B}{305C}&
- \CDJ{305D}{305E}&
- \CDJ{305F}{3060}\\
- \CDJ{3061}{3062}&
- \CDJ{3064}{3065}&
- \CDJ{3066}{3067}&
- \CDJ{3068}{3069}&
- \CDJ{306F}{3070}&
- \CDJ{3072}{3073}\\
- \CDJ{3075}{3076}&
- \CDJ{3078}{3079}&
- \CDJ{307B}{307C}&
- \CDJ{309D}{309E}&
- \CDJ{30A6}{30F4}&
- \CDJ{30AB}{30AC}\\
- \CDJ{30AD}{30AE}&
- \CDJ{30AF}{30B0}&
- \CDJ{30B1}{30B2}&
- \CDJ{30B3}{30B4}&
- \CDJ{30B5}{30B6}&
- \CDJ{30B7}{30B8}\\
- \CDJ{30B9}{30BA}&
- \CDJ{30BB}{30BC}&
- \CDJ{30BD}{30BE}&
- \CDJ{30BF}{30C0}&
- \CDJ{30C1}{30C2}&
- \CDJ{30C4}{30C5}\\
- \CDJ{30C6}{30C7}&
- \CDJ{30C8}{30C9}&
- \CDJ{30CF}{30D0}&
- \CDJ{30D2}{30D3}&
- \CDJ{30D5}{30D6}&
- \CDJ{30D8}{30D9}\\
- \CDJ{30DB}{30DC}&
- \CDJ{30EF}{30F7}&
- \CDJ{30F0}{30F8}&
- \CDJ{30F1}{30F9}&
- \CDJ{30F2}{30FA}&
- \CDJ{30FD}{30FE}\\
- \CHJ{306F}{3071}&
- \CHJ{3072}{3074}&
- \CHJ{3075}{3077}&
- \CHJ{3078}{307A}&
- \CHJ{307B}{307D}&
- \CHJ{30CF}{30D1}\\
- \CHJ{30D2}{30D4}&
- \CHJ{30D5}{30D7}&
- \CHJ{30D8}{30DA}&
- \CHJ{30DB}{30DD}
- \end{tabular}
-\end{table}
-%<*en>
-\subsection{Composition of Kana from Combining Character Sequences}
-In (u)\pTeX, Hiragana and Katakana in the NFD form%
-\footnote{namely, character sequences which contains
- ``COMBINING KATAKANA-HIRAGANA VOICED SOUND MARK''~(\texttt{U+3099}) and
- ``COMBINING KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK''~(\texttt{U+309A}).}
-are normalized to precomposed characters before (u)\pTeX\ looks into the input line.
-Character sequences which are involved in this normalization are shown in \autoref{tab:kana_composite}.
-
-The above normalization process is also performed in \LuaTeX-ja version~20220103.0 or later, because
-fonts might not have these transformation as an OpenType feature.
-%</en>
-
%<*ja>
-\subsection{濁点・半濁点付き仮名文字の正規化}
+\subsection{濁点・半濁点付き仮名の正規化→\Pkg{luaotfload}~v3.19以降ではそちらで}
\TeX~Live~2016以降の(u)\pTeX では,合成用濁点(\texttt{U+3099})・合成用半濁点(\texttt{U+309A})を用いて
-表現された平仮名・片仮名を合成済み文字に変換する(具体的には\autoref{tab:kana_composite}の組み合わせ)という処理を行っている.
+表現された平仮名・片仮名を合成済み文字に変換するという処理を行っている.
この処理を行っている要因としては,
\begin{itemize}
\item 無用なトラブルを避けるため.
@@ -10082,14 +10042,14 @@ fonts might not have these transformation as an OpenType feature.
合成用濁点・半濁点は利用できない.そのため上記の変換処理はさらに前から行われていた.
\end{itemize}
-一方,\LuaTeX(-ja)では入力の変換は基本的に行わず,文字の合成は使用しているフォントのOpenType機能に委ねるという立場である.
-しかし,\autoref{tab:kana_composite}に挙げた変換はUnicode正規化の範疇であり,この内容を持っているフォントは多くない.
-よって,前段落で述べた2つの理由(と\upTeX との互換性という意味も込めて)も考慮して,
-バージョン20220103.0以降では,\LuaTeX-jaは入力行に対して\autoref{tab:kana_composite}の変換を行う.
+\LuaTeX(-ja)では入力の変換は基本的に行わず,
+文字の合成は使用しているフォントのOpenType機能に委ねるという立場であったが,
+\Pkg{luaotfload}~v3.19以降では,標準でNFCへのUnicode正規化を行っている.
+そのため,バージョン2023****.0以降では,\LuaTeX-jaによる自前の変換\footnote{バージョン20220103.0で実装した.}は
+行わないようにしている.
%</ja>
-
-%<*ja>
+%<*ja>
%<en>\section{Insertion of JFM glues, \Param{kanjiskip} and \Param{xkanjiskip}}
%<ja>\section{JFMグルーの挿入,\Param{kanjiskip}と\Param{xkanjiskip}}
\label{sec-jfmglue}
diff --git a/macros/luatex/generic/luatexja/src/ltj-base.lua b/macros/luatex/generic/luatexja/src/ltj-base.lua
index 4a95616777..2af3908554 100644
--- a/macros/luatex/generic/luatexja/src/ltj-base.lua
+++ b/macros/luatex/generic/luatexja/src/ltj-base.lua
@@ -285,12 +285,17 @@ do
end
end
+ local compress, decompress = gzip.compress, gzip.decompress
local function save_cache(filename, t)
local fullpath = savepath .. '/' .. filename .. '.lua.gz'
local s = serialize(t, 'return', false, serial_spec)
if s then
- gzip.save(fullpath, s, 1)
- texio.write('log', '(save cache: ' .. fullpath .. ')')
+ local f = io.open(fullpath, 'wb')
+ if f then
+ f:write(compress(s, 31))
+ texio.write('log', '(save cache: ' .. fullpath .. ')')
+ f:close()
+ end
save_cache_luc(filename, t, s)
end
end
@@ -302,7 +307,8 @@ do
if isreadable(fn) then
texio.write('log','(load cache: ' .. filename .. ')')
if compressed then
- result = loadstring(gzip.load(fn))
+ local f = io.open(fn, 'rb'); result = f:read'*a'; f:close()
+ result = loadstring(decompress(result, 31))
else
result = loadfile(fn)
end
diff --git a/macros/luatex/generic/luatexja/src/ltj-direction.lua b/macros/luatex/generic/luatexja/src/ltj-direction.lua
index 0fbe0c664c..6576ace2cf 100644
--- a/macros/luatex/generic/luatexja/src/ltj-direction.lua
+++ b/macros/luatex/generic/luatexja/src/ltj-direction.lua
@@ -1008,8 +1008,8 @@ do
local n = h; h = node_remove(h,h)
node_free(n)
end
- for box_rule in traverse(h) do
- if getid(box_rule)<id_rule then
+ for box_rule, bi in traverse(h) do
+ if bi<id_rule then
h = insert_before(h, box_rule, dir_pool[list_dir]())
end
end
@@ -1129,8 +1129,7 @@ do
tex.setattribute(attr_dir, 0)
finalize_inner = function (box)
- for n in traverse(getlist(box)) do
- local nid = getid(n)
+ for n, nid in traverse(getlist(box)) do
if (nid==id_hlist or nid==id_vlist) then
local ndir = get_box_dir(n, dir_yoko)
if ndir>=dir_node_auto then -- n is dir_node
diff --git a/macros/luatex/generic/luatexja/src/ltj-inputbuf.lua b/macros/luatex/generic/luatexja/src/ltj-inputbuf.lua
index dc6ec46a56..66a466ec0c 100644
--- a/macros/luatex/generic/luatexja/src/ltj-inputbuf.lua
+++ b/macros/luatex/generic/luatexja/src/ltj-inputbuf.lua
@@ -14,6 +14,10 @@ local ltjc_is_japanese_char_curlist = ltjc.is_japanese_char_curlist
local cnt_lineend = luatexbase.registernumber 'ltjlineendcomment'
local substituter
do
+if tonumber(luaotfload.version) < 3.19 then
+ ltjb.package_info_no_line('luatexja',
+ 'We are using luaotfload <v3.19, so I compose kana from combining character sequences manually'
+ )
local uchar = utf.char
local cd, cp = uchar(0x3099), uchar(0x309A)
substituter = (utf.substituter or utf.subtituter) -- typo in lualibs?
@@ -47,8 +51,10 @@ do
['ワ'..cd] = uchar(0x30F7), ['ヰ'..cd] = uchar(0x30F8),
['ヱ'..cd] = uchar(0x30F9), ['ヲ'..cd] = uchar(0x30FA),
}
+else
+ substituter = function(s) return s end
+end
end
-
--- the following function is modified from jafontspec.lua (by K. Maeda).
--- Instead of "%", we use U+FFFFF for suppressing spaces.
--DEBUG require"socket"
diff --git a/macros/luatex/generic/luatexja/src/ltj-jfont.lua b/macros/luatex/generic/luatexja/src/ltj-jfont.lua
index a14edd2b79..26c76d88a1 100644
--- a/macros/luatex/generic/luatexja/src/ltj-jfont.lua
+++ b/macros/luatex/generic/luatexja/src/ltj-jfont.lua
@@ -3,7 +3,7 @@
--
luatexbase.provides_module({
name = 'luatexja.jfont',
- date = '2022-08-20',
+ date = '2023-04-06',
description = 'Loader for Japanese fonts',
})
@@ -43,7 +43,7 @@ local font_metric_table = ltju.font_metric_table -- [font number] -> jfm_name, j
luatexbase.create_callback("luatexja.load_jfm", "data", function (ft, jn) return ft end)
-local jfm_spec, jfm_name, jfm_var, jfm_ksp
+local jfm_spec, jfm_name, jfm_var, jfm_ksp, jfm_pci
local defjfm_res
local jfm_dir, is_def_jfont, vert_activated, auto_enable_vrt2
@@ -288,7 +288,7 @@ do
jfm_name, jfm_spec = 'ujis', 'ujis'
end
for j,v in ipairs(metrics) do if v.name==jfm_spec then return j end end
- luatexja.load_lua('jfm-' .. jfm_name .. '.lua')
+ defjfm_res=nil; luatexja.load_lua('jfm-' .. jfm_name .. '.lua')
if defjfm_res then
defjfm_res.name = jfm_spec; table.insert(metrics, defjfm_res)
return #metrics
@@ -323,7 +323,7 @@ do
update_jfm_cache(j, f.size); check_callback_order()
local sz = metrics[j].size_cache[f.size]
local fmtable = { jfm = j, size = f.size, var = jfm_var,
- with_kanjiskip = jfm_ksp,
+ with_kanjiskip = jfm_ksp, protect_compat_ig = jfm_pci,
zw = sz.zw, zh = sz.zh,
chars = sz.chars, char_type = sz.char_type,
kanjiskip = sz.kanjiskip, xkanjiskip = sz.xkanjiskip,
@@ -397,20 +397,31 @@ do
local jf_field = C(jf_field_char^1)
local jf_assignment = jf_field * ws * equals * ws * jf_field
local jf_switch = P'-' * jf_field * Cc(false) + P'+'^-1 * jf_field * Cc(true)
- local jf_feature_expr = Cg(jf_assignment + jf_switch) * ws * comma^0 * ws
+ local jf_feature_expr =
+ P{
+ 'FE',
+ FE = Cg(V'AT'+ jf_assignment + jf_switch) * ws * comma^0 * ws,
+ AT = jf_field * ws * equals * ws * Cf(Ct'' * P'{' * ws * (V'FE')^0 * P'}', rawset),
+ }
local jf_feature_list = ws * ( P'{' * ws * jf_feature_expr^0 * P'}' + jf_feature_expr^0 )
local jf_list = C((1-slash)^1) * (slash * Cf(Ct'' * jf_feature_list, rawset))^-1
local jf_value = (1 - semicolon)^1
+ local norm
+ norm = function (t)
+ local flag
+ if type(t)=='table' then
+ for i,v in pairs(t) do
+ flag=true
+ if v=='true' then t[i]=true elseif v=='false' then t[i]=false
+ elseif type(v)=='table' then norm(v) end
+ end
+ return flag and t
+ end
+ end
local function rem(name,value)
if name=='jfm' then
- local flag, t; jfm_name, t = lpegmatch(jf_list, value)
- if type(t)=='table' then
- for i,v in pairs(t) do
- flag=true
- if v=='true' then t[i]=true elseif v=='false' then t[i]=false end
- end
- end
- luatexja.jfont.jfm_feature = flag and t
+ local t; jfm_name, t = lpegmatch(jf_list, value)
+ luatexja.jfont.jfm_feature = norm(t)
elseif name=='jfmvar' then jfm_var = value end
return ''
end
@@ -451,6 +462,7 @@ do
-- print('NN>', name)
end
jfm_ksp = (is_feature_specified(name,'ltjksp')~=false)
+ jfm_pci = (is_feature_specified(name,'ltjpci')~=false)
if jfm_dir == 'tate' then
vert_activated = (is_feature_specified(name,'vert')~=false) and (is_feature_specified(name,'vrt2')~=false)
auto_enable_vrt2
@@ -619,11 +631,23 @@ function luatexja.jfont.clear_alt_font(bfnt)
end
------ used in ltjp.suppress_hyphenate_ja callback
-function luatexja.jfont.replace_altfont(pf, pc)
- local a = alt_font_table[pf]
- return a and a[pc] or pf
+do
+ local compat_ig = {}
+ for i=0xf900, 0xfaff do compat_ig[i] = true end
+ for i=0x2f800, 0x2fa1f do compat_ig[i] = true end
+ local protect_glyph = node.direct.protect_glyph
+--
+ local getfont, setfont = node.direct.getfont, node.direct.setfont
+ function luatexja.jfont.replace_altfont(a, pc, p)
+ local pf = get_attr(p, a); pf = (pf and pf>0 and pf) or getfont(p)
+ local af = alt_font_table[pf]
+ pf = af and af[pc] or pf; setfont(p, pf)
+ if compat_ig[pc] and font_metric_table[pf].protect_compat_ig then
+ protect_glyph(p)
+ end
+ return pf
+ end
end
-
------ for LaTeX interface
local alt_font_table_latex = {}
diff --git a/macros/luatex/generic/luatexja/src/ltj-pretreat.lua b/macros/luatex/generic/luatexja/src/ltj-pretreat.lua
index 508de5bb99..43ecac806c 100644
--- a/macros/luatex/generic/luatexja/src/ltj-pretreat.lua
+++ b/macros/luatex/generic/luatexja/src/ltj-pretreat.lua
@@ -110,10 +110,7 @@ do
setfield(b, 'type', 100); setfield(b, 'user_id', JA_AL_BDD);
insert_before(head, p, b)
end
- 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)
+ setlang(p, lang_ja);
ltjs_orig_char_table[p], prev_chartype = pc, 2
elseif prev_chartype==2 then
local b = node_new(id_whatsit,sid_user);
@@ -140,8 +137,7 @@ local set_box_stack_level
do
local ltjs_report_stack_level = ltjs.report_stack_level
local ltjf_font_metric_table = ltjf.font_metric_table
-local font_getfont = font.getfont
-local traverse_id = node.direct.traverse_id
+local traverse_glyph = node.direct.traverse_glyph
local cnt_stack = luatexbase.registernumber 'ltj@@stack'
local texget, getvalue = tex.get, node.direct.getdata
function set_box_stack_level(head, mode)
@@ -158,16 +154,20 @@ function set_box_stack_level(head, mode)
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( 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]
- if pc then setchar(p, pc) end
+ for p in traverse_glyph(to_direct(head)) do
+ if getlang(p)==lang_ja and has_attr(p, attr_icflag, 0) then
+ local pf = ltjf_replace_altfont(attr_curtfnt, getchar(p), p)
+ if ltjf_font_metric_table[pf].vert_activated then
+ local pc = ltjf_font_metric_table[pf].vform[pc]; if pc then setchar(p, pc) end
end
end
end
+ else
+ for p in traverse_glyph(to_direct(head)) do
+ if getlang(p)==lang_ja and has_attr(p, attr_icflag, 0) then
+ ltjf_replace_altfont(attr_curjfnt, getchar(p), p)
+ end
+ end
end
return head
end
diff --git a/macros/luatex/generic/luatexja/src/ltj-rmlgbm.lua b/macros/luatex/generic/luatexja/src/ltj-rmlgbm.lua
index 36fb7f7877..ee43ca8595 100644
--- a/macros/luatex/generic/luatexja/src/ltj-rmlgbm.lua
+++ b/macros/luatex/generic/luatexja/src/ltj-rmlgbm.lua
@@ -3,9 +3,19 @@
--
luatexja.load_module 'base'; local ltjb = luatexja.base
+local get_modtime
+do
+ local find_file = kpse.find_file
+ local lfs = require"lfs"
+ local file_attributes = lfs.attributes
+ get_modtime = function (f)
+ f = f and find_file(f, 'cmap files')
+ return f and file_attributes(f, 'modification')
+ end
+end
local cidfont_data = {}
local cache_chars = {}
-local cache_ver = 11
+local cache_ver = 12
local identifiers = fonts.hashes.identifiers
local cid_reg, cid_order, cid_supp, cid_name
@@ -213,7 +223,11 @@ do
k.characters[46].width = math.floor(655360/14);
end
ltjb.save_cache("ltj-cid-auto-" .. string.lower(cid_name),
- {version = cache_ver, k})
+ {version = cache_ver,
+ cid2ucs_modtime = get_modtime(cid_name..'-UCS2'),
+ ucs2cid = kx[1]..'-H',
+ ucs2cid_modtime = get_modtime(kx[1]..'-H'),
+ k})
k.shared.rawdata.resources=k.resources
k.shared.rawdata.descriptions=k.descriptions
end
@@ -222,7 +236,7 @@ end
--
local cidf_vert_processor
do
- local traverse_id, is_node = node.direct.traverse_id, node.is_node
+ local traverse_glyph, is_node = node.direct.traverse_glyph, node.is_node
local to_direct = node.direct.todirect
local id_glyph = node.id 'glyph'
local getfont = node.direct.getfont
@@ -235,10 +249,9 @@ do
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
- for n in traverse_id(id_glyph, head) do
- if getfont(n)==fnum then
- local c = getchar(n); setchar(n, vt[c] or c)
- end
+ for n in traverse_glyph(head) do
+ local c = getchar(n)
+ if getfont(n)==fnum then setchar(n, vt[c] or c) end
end
return head, false
end
@@ -249,7 +262,11 @@ end
local dummy_vht, dummy_vorg = {}, {}
setmetatable(dummy_vht, {__index = function () return 1 end } )
setmetatable(dummy_vorg, {__index = function () return 0.88 end } )
-local function cid_cache_outdated(t) return t.version~=cache_ver end
+local function cid_cache_outdated(t)
+ return (t.version~=cache_ver)
+ or (t.cid2ucs_modtime ~= get_modtime(cid_name..'-UCS2'))
+ or (t.ucs2cid_modtime ~= get_modtime(t.ucs2cid))
+end
local function read_cid_font()
local dat = ltjb.load_cache("ltj-cid-auto-" .. string.lower(cid_name),
cid_cache_outdated)
diff --git a/macros/luatex/generic/luatexja/src/ltj-setwidth.lua b/macros/luatex/generic/luatexja/src/ltj-setwidth.lua
index dd83d7e3d5..38dec61d2e 100644
--- a/macros/luatex/generic/luatexja/src/ltj-setwidth.lua
+++ b/macros/luatex/generic/luatexja/src/ltj-setwidth.lua
@@ -33,7 +33,6 @@ local setheight = node.direct.setheight
local setdepth = node.direct.setdepth
local setlist = node.direct.setlist
-local node_traverse_id = node.direct.traverse_id
local node_traverse = node.direct.traverse
local node_copy = node.direct.copy
local node_remove = node.direct.remove
@@ -281,8 +280,7 @@ end
-- 数式の位置補正
function luatexja.setwidth.apply_ashift_math(head, last, attr_ablshift)
- for p in node_traverse(head) do
- local pid = getid(p)
+ for p, pid in node_traverse(head) do
if p==last then
return
elseif (get_attr(p, attr_icflag) or 0) ~= PROCESSED then
@@ -309,11 +307,12 @@ do
local attr_tablshift = luatexbase.attributes['ltj@tablshift']
local attr_ablshift
local disc, tex_dir
+ local traverse_glyph = node.direct.traverse_glyph
local function ashift_disc_inner(field)
local head = getfield(disc, field)
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
+ for lp in traverse_glyph(head) do
y_adjust = get_attr(lp,attr_ablshift) or 0
local ld = getdepth(lp)
node_depth = max(ld + min(y_adjust, 0), node_depth)
diff --git a/macros/luatex/generic/luatexja/src/luatexja-core.sty b/macros/luatex/generic/luatexja/src/luatexja-core.sty
index 15d02be31b..b0c5c805c0 100644
--- a/macros/luatex/generic/luatexja/src/luatexja-core.sty
+++ b/macros/luatex/generic/luatexja/src/luatexja-core.sty
@@ -65,7 +65,7 @@
\expandafter\let\csname ifltj@in@latex\expandafter\endcsname
\csname iftrue\endcsname
\NeedsTeXFormat{LaTeX2e}
- \ProvidesPackage{luatexja-core}[2023-02-11 Core of LuaTeX-ja]
+ \ProvidesPackage{luatexja-core}[2023-04-06 Core of LuaTeX-ja]
\fi %</LaTeX>
%% Load prerequisite packages.
@@ -221,22 +221,24 @@
\luadef\ltj@@start@time@measure\ltj@@start@time@measure@inner
\luadef\ltj@@stop@time@measure\ltj@@stop@time@measure@inner
+\let\ltj@@convert@input@path@to@lua\relax % defined in LaTeX only (ltj-latex.sty)
+
%%%%%%%% \jfont\CS={...:...;jfm=metric;...}, \globaljfont
-\protected\def\jfont#1{%
- \def\ltj@temp{#1}\afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(false, 'yoko')}}
-\protected\def\globaljfont#1{%
- \def\ltj@temp{#1}\afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(true, 'yoko')}}
+%%%%%%%% \tfont\CS={...:...;jfm=metric;...}, \globaltfont
+\begingroup
+\def\ltj@@jfdef#1#2#3{%
+ \protected\gdef#1##1{%
+ \ltj@@convert@input@path@to@lua\def\ltj@temp{##1}%
+ \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(#2, '#3')}}}
+\ltj@@jfdef\jfont{false}{yoko}\ltj@@jfdef\globaljfont{true}{yoko}
+\ltj@@jfdef\tfont{false}{tate}\ltj@@jfdef\globaltfont{true}{tate}
+\endgroup
\newluafunction\ltj@@jfont@inner
\directlua{
(lua.get_functions_table())[\the\ltj@@jfont@inner] = luatexja.jfont.jfontdefY
}
\def\ltj@@jfont{\expandafter\expandafter\expandafter\luafunction\expandafter\ltj@@jfont@inner\ltj@temp}
-%%%%%%%% \tfont\CS={...:...;jfm=metric;...}, \globaltfont
-\protected\def\tfont#1{%
- \def\ltj@temp{#1}\afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(false, 'tate')}}
-\protected\def\globaltfont#1{%
- \def\ltj@temp{#1}\afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(true, 'tate')}}
%%%%%%%% \zw, \zh
\newluafunction\ltj@zw@inner
diff --git a/macros/luatex/generic/luatexja/src/luatexja.lua b/macros/luatex/generic/luatexja/src/luatexja.lua
index 31bd0662b3..f4536580e3 100644
--- a/macros/luatex/generic/luatexja/src/luatexja.lua
+++ b/macros/luatex/generic/luatexja/src/luatexja.lua
@@ -1,14 +1,23 @@
require 'lualibs'
------------------------------------------------------------------------
-local function load_lua(fn)
- local found = kpse.find_file(fn, 'tex')
- if not found then
+do
+ local ipath = {}
+ function luatexja.input_path_clear() for i in ipairs(ipath) do ipath[i]=nil end end
+ function luatexja.input_path_add(s) ipath[#ipath+1]=s end
+ function luatexja.load_lua(fn)
+ local found = kpse.find_file(fn, 'tex')
+ if not found then
+ for _,v in ipairs(ipath) do
+ found = kpse.find_file(v .. fn, 'tex'); if found then break end
+ end
+ end
+ if not found then
tex.error("LuaTeX-ja error: File `" .. fn .. "' not found")
- else
+ else
texio.write_nl('(' .. found .. ')'); dofile(found)
- end
+ end
+ end
end
-luatexja.load_lua = load_lua
function luatexja.load_module(name) require('ltj-' .. name.. '.lua') end
do
@@ -100,9 +109,9 @@ dir_table.dir_utod = dir_table.dir_tate + dir_table.dir_math_mod
local load_module = luatexja.load_module
load_module 'base'; local ltjb = luatexja.base
if tex.outputmode==0 then
- ltjb.package_error('luatexja',
- 'DVI output is not supported in LuaTeX-ja',
- 'Use lua*tex instead dvilua*tex.')
+ ltjb.package_error('luatexja',
+ 'DVI output is not supported in LuaTeX-ja',
+ '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
@@ -350,21 +359,28 @@ end
-- lastnodechar
do
- local getnest = tex.getnest
- local id_glyph = node.id 'glyph'
- function luatexja.pltx_composite_last_node_char()
- local n = getnest().tail
- local r = '-1'
- if n then
- if n.id==id_glyph then
- while n.components and n.subtype and n.subtype%4 >= 2 do
- n = node.tail(n)
- end
- r = tostring(n.char)
- end
+ local get_attr, traverse_glyph = node.get_attribute, node.traverse_glyph
+ local getnest = tex.getnest
+ local id_hlist = node.id 'hlist'
+ local id_glyph = node.id 'glyph'
+ local PACKED, PROCESSED_BEGIN_FLAG = icflag_table.PACKED, icflag_table.PROCESSED_BEGIN_FLAG
+ function luatexja.pltx_composite_last_node_char()
+ local n = getnest().tail
+ local r = '-1'
+ if n then
+ if n.id==id_hlist
+ and (get_attr(n, attr_icflag) or 0) % PROCESSED_BEGIN_FLAG == PACKED then
+ for i in traverse_glyph(n.head) do n = i; break end
end
- tex.sprint(-2, r)
- end
+ if n.id==id_glyph then
+ while n.components and n.subtype and n.subtype%4 >= 2 do
+ n = node.tail(n)
+ end
+ r = tostring(n.char)
+ end
+ end
+ tex.sprint(-2, r)
+ end
end
do
@@ -580,24 +596,24 @@ local function debug_show_node_X(p,print_fn, limit, inner_depth)
p=node_next(p)
end
function luatexja.ext_show_node_list(head,depth,print_fn, lim)
- prefix = depth
- inner_depth = 0
- if head then
- while head do
- debug_show_node_X(head, print_fn, lim or 1/0, inner_depth); head = node_next(head)
- end
- else
- print_fn(prefix .. ' (null list)')
- end
+ prefix = depth
+ inner_depth = 0
+ if head then
+ while head do
+ debug_show_node_X(head, print_fn, lim or 1/0, inner_depth); head = node_next(head)
+ end
+ else
+ print_fn(prefix .. ' (null list)')
+ end
end
function luatexja.ext_show_node(head,depth,print_fn, lim)
- prefix = depth
- inner_depth = 0
- if head then
- debug_show_node_X(head, print_fn, lim or 1/0, inner_depth)
- else
- print_fn(prefix .. ' (null list)')
- end
+ prefix = depth
+ inner_depth = 0
+ if head then
+ debug_show_node_X(head, print_fn, lim or 1/0, inner_depth)
+ else
+ print_fn(prefix .. ' (null list)')
+ end
end
end
diff --git a/macros/luatex/generic/luatexja/src/patches/lltjcore.sty b/macros/luatex/generic/luatexja/src/patches/lltjcore.sty
index af49aef7fa..fff34327c7 100644
--- a/macros/luatex/generic/luatexja/src/patches/lltjcore.sty
+++ b/macros/luatex/generic/luatexja/src/patches/lltjcore.sty
@@ -3,7 +3,7 @@
%
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{lltjcore}[2022-05-30 Patch to LaTeX2e Kernel for LuaTeX-ja]
+\ProvidesPackage{lltjcore}[2023-02-26 Patch to LaTeX2e Kernel for LuaTeX-ja]
\RequirePackage{etoolbox}
%%% expl3
@@ -201,6 +201,20 @@
\patchcmd\@outputpage{\reset@font}{\@tombowreset@@paper\reset@font}{}{}
\patchcmd\@outputpage{\@begindvi}{\@begindvi\@outputtombow}{}{}
+%
+\pretocmd\@floatboxreset{\pltx@save@float@dir}{}{}
+\patchcmd\@endfloatbox{\outer@nobreak}{\outer@nobreak\pltx@check@float@dir}{}{}
+\def\pltx@save@float@dir{%
+ \edef\pltx@float@dir@first{\ltjgetparameter{direction}}}
+\def\pltx@check@float@dir{%
+ \ifx\pltx@float@dir@first\@undefined\else
+ \ifnum\ltjgetparameter{direction}=\pltx@float@dir@first\else
+ \pltx@err@float@dir
+ \fi
+ \fi}
+\def\pltx@err@float@dir{%
+ \@latex@error{Direction change inside float!?\MessageBreak
+ Use \noexpand\layoutcaption provided in \string\usepackage{lltjext}}\@ehc}
%%% Remove extra xkanjiskip
\renewcommand\@makefnmark{%
\unless\ifnum\ltjgetparameter{direction}=3
diff --git a/macros/luatex/generic/luatexja/src/patches/lltjfont.sty b/macros/luatex/generic/luatexja/src/patches/lltjfont.sty
index f1435f7152..f86dec1de6 100644
--- a/macros/luatex/generic/luatexja/src/patches/lltjfont.sty
+++ b/macros/luatex/generic/luatexja/src/patches/lltjfont.sty
@@ -3,7 +3,7 @@
%
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{lltjfont}[2021-05-26 Patch to NFSS2 for LuaTeX-ja]
+\ProvidesPackage{lltjfont}[2023-04-06 Patch to NFSS2 for LuaTeX-ja]
%%%%%%%% LaTeX2e version detection
\newcount\ltj@@latex@plv \ltj@@latex@plv=-1
@@ -1433,4 +1433,18 @@
\ltj@@getjfontnumber#1%
\directlua{luatexja.jfont.pickup_alt_font_b(\the\ltj@tempcntc,'\luatexluaescapestring{#2}')}%
}
+
+%%%% send \input@path data to lua
+\def\ltj@@convert@input@path@to@lua{%
+ \ltj@@cipath@clear
+ \ifdefined\input@path
+ \expandafter\@tfor\expandafter\ltj@temp\expandafter:\expandafter=\input@path\do{\ltj@@cipath@add{\ltj@temp}}%
+ \fi
+}
+\newluafunction\ltj@@cipath@clear@inner
+\directlua{
+ (lua.get_functions_table())[\the\ltj@@cipath@clear@inner] = luatexja.input_path_clear
+}
+\protected\luadef\ltj@@cipath@clear\ltj@@cipath@clear@inner
+\def\ltj@@cipath@add#1{\directlua{luatexja.input_path_add('\luatexluaescapestring{#1}')}}
\endinput