OSDN Git Service

Support "\insert[x]kanjiskip late"
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Tue, 22 Dec 2020 23:05:11 +0000 (08:05 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Tue, 22 Dec 2020 23:05:11 +0000 (08:05 +0900)
      \insertxkanjiskip     :   use the value at the execution
      \insertxkanjiskip late:   use the value at the end of a box/pararaph

Squashed commit of the following:

commit 96026cefb70dfef7335d6a8669f17fc0f1b784b7
Author: Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Date:   Wed Dec 23 08:04:41 2020 +0900

    Updated doc

commit c7eb8464c3c11991daad7c7f368ccf4e3980aad6
Author: Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Date:   Tue Dec 22 11:45:46 2020 +0900

    more \insert[x]kanjiskip

      \insertxkanjiskip     :   use the value at the execution
      \insertxkanjiskip late:   use the value at the end of a box/pararaph

commit 35c25be9b8ce22b32b3440013af2fed18923a03a
Author: Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Date:   Mon Dec 21 16:00:36 2020 +0900

    WIP

doc/luatexja.dtx
src/ltj-jfmglue.lua
src/luatexja-core.sty
src/luatexja.lua
test/test04-jfm-20201222.txt [moved from test/test04-jfm-20201221.txt with 83% similarity]
test/test04-jfm.pdf
test/test04-jfm.tex

index 32f2876..2fb7648 100644 (file)
   #1\mathstrut\cr\noalign{\vskip1pt\hrule height.4pt\vskip1pt}%
   width:\hfill\ #2\cr height:\hfill\ #3\cr depth:\hfill\ #4\cr
   }}}}}\,}
-
+\protected\def\+{\insertxkanjiskip late}
 \makeatletter
 \def\Param#1{\texorpdfstring{\@Param{#1}}{#1}} % parameter name
 \protected\def\@Param#1{\eghostguarded{\hyperlink{fld:#1}{\underline{\smash{\textsf{#1}}}}}}
@@ -2268,7 +2268,7 @@ JFMは「望ましい\Param{kanjiskip}の値」や
 It is not desirable that \Param{xkanjiskip} is inserted into every
 boundary between \textbf{JAchar}s and \textbf{ALchar}s. For example,
 \Param{xkanjiskip} should not be inserted after opening parenthesis
-(\textit{e.g.}, compare ``(あ'' and ``(\hskip\ltjgetparameter{xkanjiskip}あ'').
+(\textit{e.g.}, compare ``(あ'' and ``(\+あ'').
 \LuaTeX-ja can control whether \Param{xkanjiskip} can be inserted
 before/after a character, by changing \Param{jaxspmode} for \textbf{JAchar}s and
 \Param{alxspmode} parameters \textbf{ALchar}s respectively.
@@ -2276,7 +2276,7 @@ before/after a character, by changing \Param{jaxspmode} for \textbf{JAchar}s and
 %<*ja>
 \Param{xkanjiskip}がすべての\textbf{JAchar}と\textbf{ALchar}の境界に
 挿入されるのは望ましいことではない.例えば,\Param{xkanjiskip}は開き括弧の
-後には挿入されるべきではない(「(あ」と「(\hskip\ltjgetparameter{xkanjiskip}あ」を
+後には挿入されるべきではない(「(あ」と「(\+あ」を
 比べてみよ).
 \LuaTeX-jaでは\Param{xkanjiskip}をある文字の前/後に挿入するかどうかを,
 \textbf{JAchar}に対しては\Param{jaxspmode}を,\textbf{ALchar}に対しては
@@ -6077,14 +6077,14 @@ To change characters of Chinese numerals for each digit, set \Param{kansujichar}
 %</en>
 
 
-\subsection{\cs{inhibitglue}}
+\subsection{\cs{inhibitglue}, \cs{disinhibitglue}}
 %<*en>
-\cs{inhibitglue} suppresses the insertion of \textbf{JAglue}.
+\cs{inhibitglue} suppresses the insertion of a glue/kern soecified in JFM at the place.
 The following is an example, using a special JFM that there will be a glue between
 the beginning of a box and ``あ'', and also between ``あ''~and~``ウ''.
 %</en>
 %<*ja>
-\cs{inhibitglue} は\textbf{JAglue}の挿入を抑制する.
+\cs{inhibitglue} は発行箇所でのJFM由来グルー/カーンの挿入を抑制する.
 以下は,ボックスの始めと「あ」の間,「あ」「ウ」の間にグルーが入る特別なJFMを用いた例で
 ある.
 %</ja>
@@ -6095,6 +6095,7 @@ the beginning of a box and ``あ'', and also between ``あ''~and~``ウ''.
 \inhibitglue\par\noindent あ1
 \par\inhibitglue\noindent あ2
 \par\noindent\inhibitglue あ3
+\par )4)\inhibitglue 5
 \par\hrule\noindent あoff\inhibitglue ice
 \end{LTXexample}
 
@@ -6118,11 +6119,20 @@ With the help of this example, we remark the specification of \cs{inhibitglue}:
 %</ja>
 
 %<*en>
+\item \cs{inhibitglue} does \emph{not} suppress \Param{kanjiskip} or \cs{xkanjiskip}.
+%</en>
+%<*ja>
+\item \cs{inhibitglue}は\Param{kanjiskip}, \Param{xkanjiskip}の挿入は抑制しない.
+  例えば上の例の6行目では,「)」と「5」の間には本来はJFM由来の半角空きが挿入されるはずだが,
+  それが\cs{inhibitglue}で無効になったため,\Param{xkanjiskip}が代わりに挿入されている.
+%</ja>
+
+%<*en>
 \item The call of \cs{inhibitglue} in the (restricted) horizontal
       mode is only effective on the spot; does not get over boundary of
       paragraphs. Moreover, \cs{inhibitglue} cancels ligatures and
       kernings, as shown in the last line of above example.
-%</en>
+%</en>i
 %<*ja>
 \item \cs{inhibitglue} の(制限された)水平モード中での呼び出しはその場でのみ
   有効であり,段落の境界を乗り越えない.
@@ -6146,6 +6156,24 @@ With the help of this example, we remark the specification of \cs{inhibitglue}:
 %</ja>
 \end{itemize}
 
+%<*en>
+\cs{disinhibitglue} suppresses the effect of \cs{inhbitglue}.
+In other words, \cs{disinhibitglue} allows the insertion of a glue/kern specified by JFM.
+If \cs{inhibitglue}~and~\cs{disinhibitglue} both specified at the same time,
+the latest one is effective.
+This commans is added in the version 2020****.0.
+
+Note that \cs{disinhibitglue} also cancels ligatures and kernings.
+%</en>
+%<*ja>
+\cs{disinhibitglue}は\cs{inhibitglue}の効果を無効化する.
+言い換えれば,(\cs{inhibitglue}で抑制されたはずの))JFM由来グルー/カーンの挿入を許可する.
+同じ箇所に\cs{inhibitglue}と\cs{disinhibitglue}が両方ある場合は,後ろの指定が有効になる.
+この命令はバージョン2020****.0で追加された.
+
+なお,\cs{disinhibitglue}もリガチャやカーニングを打ち消すことに注意されたい.これは
+(\cs{inhibitglue}と同様に)whatsitノードを使って実装されていることによる.
+%</ja>
 
 \subsection{\cs{ltjfakeboxbdd}, \cs{ltjfakeparbegin}}
 %<*en>
@@ -6206,6 +6234,77 @@ As an example, the example above can be improved as follows:
 \end{LTXexample}
 
 
+\subsection{\cs{insertxkanjiskip}, \cs{insertkanjiskip}}
+%<*en>
+There are some situations which one wants to insert \Param{xkanjiskip} manually.
+A simple approach is to use \cs{hskip}\cs{ltjgetparamter\{xkanjiskip\}}, but this approach has
+several weak points. To cope with these weak points, \LuaTeX-ja defines a command \cs{insertxkanjiskip} which
+inserts \Param{xkanjiskip} glue manually, from the version 2020****.0.
+\begin{itemize}
+  \item ``\cs{insertxkanjiskip}'' (without any keyword) uses the value of \Param{xkanjiskip} at the place.
+  \item ``\cs{insertxkanjiskip late}'' (with ``\texttt{late}''~keyword) uses the value of \Param{xkanjiskip}
+  at the end of a paragraph/hbox.
+\end{itemize}
+See the example below.
+%</en>
+%<*ja>
+\TeX で日本語の文章を作成していると,
+しばしば「手動で和欧文間空白\Param{xkanjiskip}を挿入したい」という状況に遭遇する.
+このような場合,\cs{hskip}\cs{ltjgetparamter\{xkanjiskip\}}\+とするのがよくある対応であったが,これらには
+次のような難点がある:
+\begin{itemize}
+  \item \cs{xkanjiskip}は「段落やhboxでの終端での値がその段落/hbox全体で用いられる」となっているため,
+  \cs{hskip}\cs{ltjgetparamter\{xkanjiskip\}}\+以降に\Param{xkanjiskip}の値が変わる場合に対応できない.
+  \item \LuaTeX-jaでは,\cs{xkanjiskip}の自然長が$\cs{maxdimen}=(2^{30}-1)\,\mbox{sp}$であった場合,
+  JFMで指定された値を実際に利用することになっているが,それに対応できていない.
+  \item \Pkg{luatexja-adjust}(\ref{ssec:adj}節)による優先度行長調整では,
+  \cs{hskip}\cs{ltjgetparamter\{xkanjiskip\}}\+は手動で挿入したグルーであるから,
+  自動で挿入された\Param{xkanjiskip}とは
+  伸縮の優先順序が異なってしまう.
+\end{itemize}
+
+これらの難点に対処した,\Param{xkanjiskip}をグルーとして手動挿入する命令が\cs{insertxkanjiskip}である.
+これはバージョン2020****.0で追加された.
+以下の実行例に示すように,
+\begin{itemize}
+  \item 単独で\cs{insertxkanjiskip}とした場合は,その時点での\Param{xkanjiskip}の値を使用する
+  \item 「\cs{insertxkanjiskip~late}」と\texttt{late}キーワードを後置した場合は,
+  段落/hbox終了時にそのときの\Param{xkanjiskip}の値に自動設定される
+  (段落/hbox途中での値は未定義)
+  \item どちらであっても,実行箇所に本来なら自動挿入されるはずのJFM由来グルー/カーンは挿入されない
+\end{itemize}
+となっている.
+%</ja>
+\begin{LTXexample}[width=0.3333\textwidth]
+\ltjsetparameter{xkanjiskip=0.25\zw}
+あ(%                        0.5\zw  (from JFM)
+あ\insertxkanjiskip (%      0.25\zw (xkanjiskip at here)
+あ\insertxkanjiskip late (% 0.25\zw (xkanjiskip at EOP)
+あa%                         1.25\zw (xkanjiskip at EOP)
+\\%
+\ltjsetparameter{xkanjiskip=1.25\zw}
+あ\insertxkanjiskip (%      1.25\zw (xkanjiskip at here)
+あa%                         1.25\zw (xkanjiskip at EOP)
+%% At the end of the paragraph (EOP), xkanjiskip is 1.25\zw.
+\end{LTXexample}
+
+%<*en>
+There is a similar command \cs{insertkanjiskip} (\Param{kanjiskip} instead~of \Param{xkanjiskip}) is also defined.
+Note that any shorthand form of \cs{insert}[\texttt{x}]\texttt{kanjiskip} are not defined by \LuaTeX-ja.
+%</en>
+%<*ja>
+\cs{insertxkanjiskip}(または\texttt{late}つき)の短縮形
+\footnote{ちょうど\cs{inhibitglue}の短縮形\cs{\ltjalchar`\<}\+に対応するもの.}は
+\LuaTeX-jaでは定義していない.短縮形を使いたい人は,面倒でも各自で
+\begin{lstlisting}
+ \protected\def\+{\insertxkanjiskip late}
+\end{lstlisting}
+などと定義してほしい.
+
+最後になるが,以上の説明の\Param{xkanjiskip}をすべて標準の和文間空白\Param{kanjiskip}に置き換えた
+\cs{insertkanjiskip}命令も準備されている.
+%</ja>
+
 \subsection{\cs{ltjdeclarealtfont}}
 \label{ssec:altfont}
 %<*en>
@@ -10199,9 +10298,9 @@ $q$と$r$の間は(実フォントが同じなのに)\texttt{jfmvar} キー
 結果として,2つの\textbf{JAchar}間には常に何らかのグルー/カーンが挿入されることとなる.
 \begin{enumerate}
 \item 両クラスタ(厳密には$\mathit{Nq}.\mathit{tail}$,$\mathit{Np}.\mathit{head}$)の中身の文字コードに対する
-\Param{autospacing}パラメタが両方ともfalseだった場合は,長さ0のglueとする.
-\item ã\83¦ã\83¼ã\82¶å\81´ã\81\8bã\82\89è¦\8bã\81\9f\Param{kanjiskip}ã\83\91ã\83©ã\83¡ã\82¿ã\81®è\87ªç\84¶é\95·ã\81\8c$\cs{maxdimen}=(2^{30}-1)\,{\rm sp}$で
-なければ,\Param{kanjiskip}パラメタの値を持つglueを採用する.
+\Param{autospacing}ã\83\91ã\83©ã\83¡ã\83¼ã\82¿ã\81\8c両æ\96¹ã\81¨ã\82\82falseã\81 ã\81£ã\81\9få ´å\90\88ã\81¯ï¼\8cé\95·ã\81\95\81®glueã\81¨ã\81\99ã\82\8bï¼\8e
+\item ã\83¦ã\83¼ã\82¶å\81´ã\81\8bã\82\89è¦\8bã\81\9f\Param{kanjiskip}ã\83\91ã\83©ã\83¡ã\83¼ã\82¿ã\81®è\87ªç\84¶é\95·ã\81\8c$\cs{maxdimen}=(2^{30}-1)\,\mbox{sp}$で
\81ªã\81\91ã\82\8cã\81°ï¼\8c\Param{kanjiskip}ã\83\91ã\83©ã\83¡ã\83¼ã\82¿ã\81®å\80¤ã\82\92æ\8c\81ã\81¤glueã\82\92æ\8e¡ç\94¨ã\81\99ã\82\8bï¼\8e
 \item 2.でない場合は,\textit{Nq}, \textit{Np}で使われているJFMに指定されている\Param{kanjiskip}の値を用いる.
 どちらか片方のクラスタだけが\textbf{JAchar}(\textsf{和文A}・\textsf{和文B})のときは,そちらのクラスタで使われている
 JFM由来の値だけを用いる.もし両者で使われているJFMが異なった場合は,上の[M]~3.と同様の方法を用いて調整する.
@@ -10338,7 +10437,7 @@ If this attempt fails, \LuaTeX-ja use the method ``\textsf{\Param{kanjiskip}~[K]
     \item $\mathit{Np}.\mathit{id}$が\textit{id\_math}のとき(つまりクラスタ\textit{Np}が文中数式を表す)
     ときは,$x=-1$.
     \item \textit{Np}の中身の中身の文字コードについて,「直前への\Param{xkanjiskip}の挿入」が禁止されている
-(つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメタが偶数)ときは,
+ï¼\88ã\81¤ã\81¾ã\82\8aï¼\8c\Param{jaxspmode}~(or \Param{alxspmode})ã\83\91ã\83©ã\83¡ã\83¼ã\82¿ã\81\8cå\81¶æ\95°ï¼\89ã\81¨ã\81\8dã\81¯ï¼\8c
     $x=\text{\texttt{'nox\_alchar'}}$.
     \item 以上のいずれでもないときは,$x=\text{\texttt{'alchar'}}$.
   \end{itemize}
@@ -10350,14 +10449,14 @@ If this attempt fails, \LuaTeX-ja use the method ``\textsf{\Param{kanjiskip}~[K]
 \begin{enumerate}
 \item 以下のいずれかの場合は,\Param{xkanjiskip}の挿入は抑止される.しかし,実際には行分割を許容するために,長さ0のglueを採用する:
 \begin{itemize}
-\item 両クラスタにおいて,それらの中身の文字コードに対する\Param{autoxspacing}パラメタが共にfalseである.
+\item ä¸¡ã\82¯ã\83©ã\82¹ã\82¿ã\81«ã\81\8aã\81\84ã\81¦ï¼\8cã\81\9dã\82\8cã\82\89ã\81®ä¸­èº«ã\81®æ\96\87å­\97ã\82³ã\83¼ã\83\89ã\81«å¯¾ã\81\99ã\82\8b\Param{autoxspacing}ã\83\91ã\83©ã\83¡ã\83¼ã\82¿ã\81\8cå\85±ã\81«falseã\81§ã\81\82ã\82\8bï¼\8e
 \item \textit{Nq}の中身の文字コードについて,「直後への\Param{xkanjiskip}の挿入」が禁止されている
-(つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメタが2以上).
+ï¼\88ã\81¤ã\81¾ã\82\8aï¼\8c\Param{jaxspmode}~(or \Param{alxspmode})ã\83\91ã\83©ã\83¡ã\83¼ã\82¿ã\81\8c2以ä¸\8aï¼\89ï¼\8e
 \item \textit{Np}の中身の文字コードについて,「直前への\Param{xkanjiskip}の挿入」が禁止されている
-(つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメタが偶数).
+ï¼\88ã\81¤ã\81¾ã\82\8aï¼\8c\Param{jaxspmode}~(or \Param{alxspmode})ã\83\91ã\83©ã\83¡ã\83¼ã\82¿ã\81\8cå\81¶æ\95°ï¼\89ï¼\8e
 \end{itemize}
-\item ユーザ側から見た\Param{xkanjiskip}パラメタの自然長が$\cs{maxdimen}=(2^{30}-1)\,{\rm sp}$で
-なければ,\Param{xkanjiskip}パラメタの値を持つglueを採用する.
+\item ã\83¦ã\83¼ã\82¶å\81´ã\81\8bã\82\89è¦\8bã\81\9f\Param{xkanjiskip}ã\83\91ã\83©ã\83¡ã\83¼ã\82¿ã\81®è\87ªç\84¶é\95·ã\81\8c$\cs{maxdimen}=(2^{30}-1)\,{\rm sp}$ã\81§
\81ªã\81\91ã\82\8cã\81°ï¼\8c\Param{xkanjiskip}ã\83\91ã\83©ã\83¡ã\83¼ã\82¿ã\81®å\80¤ã\82\92æ\8c\81ã\81¤glueã\82\92æ\8e¡ç\94¨ã\81\99ã\82\8bï¼\8e
 \item 2.でない場合は,\textit{Nq}, \textit{Np}(\textsf{和文A}/\textsf{和文B}なのは片方だけ)
 で使われているJFMに指定されている\Param{xkanjiskip}の値を用いる.
 \end{enumerate}
@@ -10385,7 +10484,7 @@ $x$は\textit{Nq}から\textsf{欧文境界B~[\NB]}におけるそれと同じ
 \texttt{'nox\_alchar'}か\texttt{'alchar'}は
 \begin{quote}
   \textit{Nq}の中身の文字コードについて,「直後への\Param{xkanjiskip}の挿入」が禁止されている
-(つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメタが2以上).
+ï¼\88ã\81¤ã\81¾ã\82\8aï¼\8c\Param{jaxspmode}~(or \Param{alxspmode})ã\83\91ã\83©ã\83¡ã\83¼ã\82¿ã\81\8c2以ä¸\8aï¼\89ï¼\8e
 \end{quote}
   か否かで判断する.
 \end{enumerate}
index c5727da..019e24a 100644 (file)
@@ -3,7 +3,7 @@
 --
 luatexbase.provides_module({
   name = 'luatexja.jfmglue',
-  date = '2020-12-20',
+  date = '2020-12-22',
   description = 'Insertion process of JFM glues, [x]kanjiskip and others',
 })
 luatexja.jfmglue = luatexja.jfmglue or {}
@@ -78,6 +78,7 @@ local FROM_JFM     = luatexja.icflag_table.FROM_JFM
 local PROCESSED    = luatexja.icflag_table.PROCESSED
 local IC_PROCESSED = luatexja.icflag_table.IC_PROCESSED
 local BOXBDD       = luatexja.icflag_table.BOXBDD
+local SPECIAL_JAGLUE = luatexja.icflag_table.SPECIAL_JAGLUE
 local PROCESSED_BEGIN_FLAG = luatexja.icflag_table.PROCESSED_BEGIN_FLAG
 
 local attr_icflag = luatexbase.attributes['ltj@icflag']
@@ -499,7 +500,11 @@ calc_np_auxtable = {
    end,
    [id_glue] = function(lp)
       Np.first, Np.nuc, Np.last = (Np.first or lp), lp, lp;
-      Np.id = getid(lp); set_attr(lp, attr_icflag, PROCESSED)
+      Np.id = getid(lp); 
+      local f = luatexbase.call_callback("luatexja.jfmglue.special_jaglue", lp)
+      if f then
+         set_attr(lp, attr_icflag, PROCESSED)
+      end
       return true, node_next(lp)
    end,
    [id_disc] = function(lp)
@@ -562,7 +567,7 @@ function calc_np(last, lp)
    while lp ~= last  do
       local lpa = has_attr(lp, attr_icflag) or 0
       -- unbox 由来ノードの検出
-      if lpa>=PACKED then
+      if (lpa>=PACKED) and (lpa%PROCESSED_BEGIN_FLAG<=BOXBDD) then
          if lpa%PROCESSED_BEGIN_FLAG == BOXBDD then
             local lq = node_next(lp)
             head = node_remove(head, lp); node_free(lp); lp = lq
@@ -1095,13 +1100,15 @@ local adjust_nq
 do
    local adjust_nq_aux = {
       [id_glyph] = function() after_alchar(Nq) end, -- after_alchar(Nq)
-      [id_hlist]  = function() after_hlist(Nq) end,
+      [id_hlist] = function() after_hlist(Nq) end,
       [id_pbox]  = function() after_hlist(Nq) end,
       [id_disc]  = function() after_hlist(Nq) end,
-      [id_pbox_w]  = function()
-                        luatexbase.call_callback("luatexja.jfmglue.whatsit_after",
-                                                 false, Nq, Np)
-                     end,
+      [id_glue]  = function() 
+                      luatexbase.call_callback("luatexja.jfmglue.special_jaglue_after", Nq.nuc)
+                   end,
+      [id_pbox_w]= function()
+                      luatexbase.call_callback("luatexja.jfmglue.whatsit_after", false, Nq, Np)
+                   end,
    }
 
    adjust_nq = function()
 end
 
 do
+   local node_prev = node.direct.getprev
    local node_write = node.direct.write
    local XKANJI_SKIP   = luatexja.icflag_table.XKANJI_SKIP
    local XKANJI_SKIP_JFM   = luatexja.icflag_table.XKANJI_SKIP_JFM
-   local XSK  = luatexja.stack_table_index.XSK
    local KANJI_SKIP   = luatexja.icflag_table.KANJI_SKIP
    local KANJI_SKIP_JFM   = luatexja.icflag_table.KANJI_SKIP_JFM
+   local XSK  = luatexja.stack_table_index.XSK
    local KSK  = luatexja.stack_table_index.KSK
-   local get_dir_count = ltjd.get_dir_count
-   local dir_tate = luatexja.dir_table.dir_tate
-   local attr_curjfnt = luatexbase.attributes['ltj@curjfnt']
-   local attr_curtfnt = luatexbase.attributes['ltj@curtfnt']
+   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 get_current_jfont
+   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        
+       function get_current_jfont()
+           return tex.getattribute((get_dir_count()==dir_tate) and attr_curtfnt or attr_curjfnt)
+       end
+   end
    -- \insertxkanjiskip
-   function luatexja.jfmglue.insert_xk_skip()
-       local st = ltjs.get_stack_skip(XSK, tex.getcount('ltj@@stack'))
-       if st.width==1073741823 then
-           local j = ltjf_font_metric_table[
-             tex.getattribute((get_dir_count()==dir_tate) and attr_curtfnt or attr_curjfnt)
-           ]
-           if j.xkanjiskip then
-               local g, bk = node_new(id_glue), j.xkanjiskip
-               setglue(g, bk[1] or 0, bk[2] or 0, bk[3] or 0, 0, 0)
-               set_attr(g, attr_icflag, XKANJI_SKIP_JFM); node_write(g)
-               return
+   -- 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
+       local g = node_new(id_glue); set_attr(g, attr_icflag, SPECIAL_JAGLUE)
+       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 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)
+           set_attr(g, attr_yablshift, ica)
+       else
+           set_attr(g, attr_yablshift, PROCESSED_BEGIN_FLAG + ica)
+           set_attr(g, attr_tablshift, get_current_jfont())               
        end
-       local g = node_new(id_glue)
-       setglue(g, st.width, st.stretch, st.shrink, st.stretch_order, st.shrink_order)
-       set_attr(g, attr_icflag, XKANJI_SKIP); node_write(g)
+       node_write(g)
+   end
+   function luatexja.jfmglue.insert_xk_skip()
+       insert_k_skip_common(XSK, "xkanjiskip", XKANJI_SKIP, XKANJI_SKIP_JFM)
    end
-   -- \insertkanjiskip
    function luatexja.jfmglue.insert_k_skip()
-       local st = ltjs.get_stack_skip(KSK, tex.getcount('ltj@@stack'))
-       if st.width==1073741823 then
-           local j = ltjf_font_metric_table[
-             tex.getattribute((get_dir_count()==dir_tate) and attr_curtfnt or attr_curjfnt)
-           ]
-           if j.kanjiskip then
-               local g, bk = node_new(id_glue), j.kanjiskip
-               setglue(g, bk[1] or 0, bk[2] or 0, bk[3] or 0, 0, 0)
-               set_attr(g, attr_icflag, KANJI_SKIP_JFM); node_write(g)
-               return
+       insert_k_skip_common(KSK, "kanjiskip", KANJI_SKIP, KANJI_SKIP_JFM)
+   end
+   -- callback
+   local getglue = luatexja.getglue
+   local function special_jaglue(lx)
+       local lxi = get_attr_icflag(lx)
+       if lxi==SPECIAL_JAGLUE then
+           non_ihb_flag = false; return false
+       else
+           return lx
+       end
+   end
+   local function special_jaglue_after(lx)
+       if get_attr_icflag(lx)==SPECIAL_JAGLUE then
+           lxi=has_attr(lx, attr_yablshift)
+           if lxi>=PROCESSED_BEGIN_FLAG then
+               lxi = lxi%PROCESSED_BEGIN_FLAG
+               if lxi == KANJI_SKIP then
+                   local w, st, sh, sto, sho = getglue(kanji_skip)
+                   if w~=1073741823 then
+                       setglue(lx, w, st, sh, sto, sho); set_attr(lx, attr_icflag, KANJI_SKIP)
+                   else
+                       local m = ltjf_font_metric_table[has_attr(lx, attr_tablshift)]
+                       local bk = m.kanjiskip or null_skip_table
+                       setglue(lx, bk[1], bk[2], bk[3], 0, 0)
+                       set_attr(lx, attr_icflag, KANJI_SKIP_JFM)
+                   end
+               elseif lxi == XKANJI_SKIP then
+                   local w, st, sh, sto, sho = getglue(xkanji_skip)
+                   if w~=1073741823 then
+                       setglue(lx, w, st, sh, sto, sho); set_attr(lx, attr_icflag, XKANJI_SKIP)
+                   else
+                       local m = ltjf_font_metric_table[has_attr(lx, attr_tablshift)]
+                       local bk = m.xkanjiskip or null_skip_table
+                       setglue(lx, bk[1], bk[2], bk[3], 0, 0)
+                       set_attr(lx, attr_icflag, XKANJI_SKIP_JFM)
+                   end
+               end
+           else
+               set_attr(lx, attr_icflag, lxi)
+           end
+           Np.first = lx
+           if node_prev(lx) then
+               local lxp = node_prev(lx)
+               if lxp and getid(lxp)==id_penalty and get_attr_icflag(lxp)==KINSOKU then
+                   Bp[#Bp+1]=lxp
+               end
            end
+           non_ihb_flag = false; return false
        end
-       local g = node_new(id_glue)
-       setglue(g, st.width, st.stretch, st.shrink, st.stretch_order, st.shrink_order)
-       set_attr(g, attr_icflag, KANJI_SKIP); node_write(g)
+       return true
    end
+   luatexbase.create_callback("luatexja.jfmglue.special_jaglue", "list",
+                              special_jaglue)
+   luatexbase.create_callback("luatexja.jfmglue.special_jaglue_after", "list",
+                              special_jaglue_after)
 end
 
 
index 988d933..3ad5657 100644 (file)
@@ -65,7 +65,7 @@
   \expandafter\let\csname ifltj@in@latex\expandafter\endcsname
     \csname iftrue\endcsname
   \NeedsTeXFormat{LaTeX2e}
-  \ProvidesPackage{luatexja-core}[2020-12-20 Core of LuaTeX-ja]
+  \ProvidesPackage{luatexja-core}[2020-12-22 Core of LuaTeX-ja]
 \fi                             %</LaTeX>
 
 %% Load prerequisite packages.
 \protected\def\inhibitglue{\ifhmode\relax\luafunction\ltj@@ihb@inner\fi}
 \protected\def\ltjfakeparbegin{\ifhmode\relax\luafunction\ltj@@fakeparbegin@inner\fi}
 \protected\def\ltjfakeboxbdd{\ifhmode\relax\luafunction\ltj@@fakeboxbdd@inner\fi}
-\protected\def\insertxkanjiskip{\ifhmode\relax\luafunction\ltj@@ins@xk@inner\fi}
-\protected\def\insertkanjiskip{\ifhmode\relax\luafunction\ltj@@ins@k@inner\fi}
+\protected\luadef\insertxkanjiskip \ltj@@ins@xk@inner
+\protected\luadef\insertkanjiskip  \ltj@@ins@k@inner
 
 
 %%%%%%%% \ltjdefcharrange<name>{100-200,3000-,5000,...}
index 1c039a7..b4e2e68 100644 (file)
@@ -42,6 +42,9 @@ icflag_table.LINEEND         = 72
 icflag_table.PROCESSED       = 73
 icflag_table.IC_PROCESSED    = 74
 icflag_table.BOXBDD          = 75
+icflag_table.SPECIAL_JAGLUE  = 76
+-- 段落組版中のノードリストでは通常のノード (not whatsit) だが
+-- 和文処理グルー挿入プロセスで長さが決定されるもの
 icflag_table.PROCESSED_BEGIN_FLAG = 4096 -- sufficiently large power of 2
 
 local stack_ind = {}
similarity index 83%
rename from test/test04-jfm-20201221.txt
rename to test/test04-jfm-20201222.txt
index 754a097..7b0dc50 100644 (file)
@@ -968,15 +968,154 @@ l.376 ...\tenmin\setbox1=\hbox{\tate }あ\unhbox1い
 2 hlist 0 (5.0+5.0)x10.0, dir=0 (packed)
 .0 glyph 256  感 (U+611F) 75 (8.48+0.66)x10.0
 ======
- [12])
-(see the transcript file for additional information)</opt/texlive/texmf-local/f
-onts/truetype/sysfnt/OTF/ipaexm.ttf></opt/texlive/texmf-local/fonts/truetype/sy
-sfnt/OTF/ipaexg.ttf></usr/share/fonts/OTF/ipamp.ttf></usr/share/fonts/mine/KozM
-inPr6N-Regular.otf></usr/share/fonts/OTF/ipam.ttf></opt/texlive/2020/texmf-dist
-/fonts/type1/public/amsfonts/cm/cmbx10.pfb></opt/texlive/2020/texmf-dist/fonts/
-type1/public/amsfonts/cm/cmmi10.pfb></opt/texlive/2020/texmf-dist/fonts/type1/p
-ublic/amsfonts/cm/cmr10.pfb></opt/texlive/2020/texmf-dist/fonts/type1/public/am
-sfonts/cm/cmti10.pfb></opt/texlive/2020/texmf-dist/fonts/type1/public/amsfonts/
-cm/cmtt10.pfb>
-Output written on test04-jfm.pdf (12 pages, 714251 bytes).
+======
+49 whatsit 8  userid:4 (direction) (node list) dir: 4
+2 hlist 0 (8.8+1.2)x10.0, dir=0 (packed)
+.0 glyph 256  あ (U+3042) 66 (8.11035+0.36133)x8.99902
+45 glue 0  0.0pt plus 0.4pt (kanjiskip, JFM specified)
+28 glue 0  5.0pt minus 5.0pt (from JFM: priority 36)
+2 hlist 0 (8.8+1.2)x5.0, dir=0 (packed)
+.0 glyph 256  ( (U+FF08) 66 (8.32031+0.71777)x5.09766 off: (-0.09766,0.0)
+3 penalty 0  10000 (for kinsoku)
+45 glue 0  0.0pt minus 0.4pt (kanjiskip, JFM specified)
+28 glue 0  0.0pt (from JFM: priority 36)
+2 hlist 0 (8.8+1.2)x10.0, dir=0 (packed)
+.0 glyph 256  あ (U+3042) 66 (8.11035+0.36133)x8.99902
+45 glue 0  0.0pt plus 0.4pt (kanjiskip, JFM specified)
+28 glue 0  5.0pt minus 5.0pt (from JFM: priority 36)
+2 hlist 0 (8.8+1.2)x5.0, dir=0 (packed)
+.0 glyph 256  ( (U+FF08) 66 (8.32031+0.71777)x5.09766 off: (-0.09766,0.0)
+3 penalty 0  10000 (for kinsoku)
+45 glue 0  0.0pt minus 0.4pt (kanjiskip, JFM specified)
+28 glue 0  0.0pt (from JFM: priority 36)
+2 hlist 0 (8.8+1.2)x10.0, dir=0 (packed)
+.0 glyph 256  あ (U+3042) 66 (8.11035+0.36133)x8.99902
+45 glue 0  0.0pt plus 0.4pt (kanjiskip, JFM specified)
+28 glue 0  5.0pt minus 5.0pt (from JFM: priority 36)
+2 hlist 0 (8.8+1.2)x5.0, dir=0 (packed)
+.0 glyph 256  ( (U+FF08) 66 (8.32031+0.71777)x5.09766 off: (-0.09766,0.0)
+======
+======
+49 whatsit 8  userid:4 (direction) (node list) dir: 4
+2 hlist 0 (8.8+1.2)x10.0, dir=0 (packed)
+.0 glyph 256  あ (U+3042) 66 (8.11035+0.36133)x8.99902
+44 glue 0  0.0pt plus 0.4pt minus 0.4pt (kanjiskip)
+2 hlist 0 (8.8+1.2)x5.0, dir=0 (packed)
+.0 glyph 256  ( (U+FF08) 66 (8.32031+0.71777)x5.09766 off: (-0.09766,0.0)
+3 penalty 0  10000 (for kinsoku)
+45 glue 0  0.0pt minus 0.4pt (kanjiskip, JFM specified)
+28 glue 0  0.0pt (from JFM: priority 36)
+2 hlist 0 (8.8+1.2)x10.0, dir=0 (packed)
+.0 glyph 256  あ (U+3042) 66 (8.11035+0.36133)x8.99902
+44 glue 0  0.0pt plus 0.4pt minus 0.4pt (kanjiskip)
+2 hlist 0 (8.8+1.2)x5.0, dir=0 (packed)
+.0 glyph 256  ( (U+FF08) 66 (8.32031+0.71777)x5.09766 off: (-0.09766,0.0)
+======
+======
+49 whatsit 8  userid:4 (direction) (node list) dir: 4
+2 hlist 0 (8.8+1.2)x10.0, dir=0 (packed)
+.0 glyph 256  あ (U+3042) 66 (8.11035+0.36133)x8.99902
+46 glue 0  2.40553pt plus 1.0pt minus 1.0pt (xkanjiskip)
+2 hlist 0 (8.8+1.2)x5.0, dir=0 (packed)
+.0 glyph 256  ( (U+FF08) 66 (8.32031+0.71777)x5.09766 off: (-0.09766,0.0)
+3 penalty 0  10000 (for kinsoku)
+46 glue 0  2.40553pt plus 1.0pt minus 1.0pt (xkanjiskip)
+2 hlist 0 (8.8+1.2)x10.0, dir=0 (packed)
+.0 glyph 256  あ (U+3042) 66 (8.11035+0.36133)x8.99902
+3 penalty 0  10000 (for kinsoku)
+46 glue 0  2.40553pt plus 1.0pt minus 1.0pt (xkanjiskip)
+2 hlist 0 (8.8+1.2)x5.0, dir=0 (packed)
+.0 glyph 256  ) (U+FF09) 66 (8.32031+0.71777)x5.09766
+45 glue 0  0.0pt plus 0.4pt (kanjiskip, JFM specified)
+28 glue 0  5.0pt minus 5.0pt (from JFM: priority 36)
+2 hlist 0 (8.8+1.2)x5.0, dir=0 (packed)
+.0 glyph 256  ( (U+FF08) 66 (8.32031+0.71777)x5.09766 off: (-0.09766,0.0)
+3 penalty 0  10000 (for kinsoku)
+46 glue 0  2.40553pt plus 1.0pt minus 1.0pt (xkanjiskip)
+2 hlist 0 (8.8+1.2)x5.0, dir=0 (packed)
+.0 glyph 256  ) (U+FF09) 66 (8.32031+0.71777)x5.09766
+======
+ [12]======
+49 whatsit 8  userid:4 (direction) (node list) dir: 4
+2 hlist 0 (8.8+1.2)x10.0, dir=0 (packed)
+.0 glyph 256  あ (U+3042) 66 (8.11035+0.36133)x8.99902
+46 glue 0  2.40553pt plus 1.0pt minus 1.0pt (xkanjiskip)
+2 hlist 0 (8.8+1.2)x10.0, dir=0 (packed)
+.0 glyph 256  あ (U+3042) 66 (8.11035+0.36133)x8.99902
+46 glue 0  6.2pt plus 3.0pt (xkanjiskip)
+49 glyph 256  a (U+61) 68 (5.2002+0.03906)x5.49805
+46 glue 0  6.2pt plus 3.0pt (xkanjiskip)
+2 hlist 0 (8.8+1.2)x10.0, dir=0 (packed)
+.0 glyph 256  あ (U+3042) 66 (8.11035+0.36133)x8.99902
+46 glue 0  6.2pt plus 3.0pt (xkanjiskip)
+49 glyph 256  c (U+63) 68 (5.22949+0.04883)x5.43945
+46 glue 0  6.2pt plus 3.0pt (xkanjiskip)
+2 hlist 0 (8.8+1.2)x10.0, dir=0 (packed)
+.0 glyph 256  あ (U+3042) 66 (8.11035+0.36133)x8.99902
+46 glue 0  6.2pt plus 3.0pt (xkanjiskip)
+2 hlist 0 (8.8+1.2)x10.0, dir=0 (packed)
+.0 glyph 256  あ (U+3042) 66 (8.11035+0.36133)x8.99902
+======
+======
+49 whatsit 8  userid:4 (direction) (node list) dir: 4
+2 hlist 0 (8.8+1.2)x10.0, dir=0 (packed)
+.0 glyph 256  あ (U+3042) 66 (8.11035+0.36133)x8.99902
+46 glue 0  6.2pt plus 3.0pt (xkanjiskip)
+2 hlist 0 (8.8+1.2)x10.0, dir=0 (packed)
+.0 glyph 256  あ (U+3042) 66 (8.11035+0.36133)x8.99902
+46 glue 0  6.2pt plus 3.0pt (xkanjiskip)
+49 glyph 256  a (U+61) 68 (5.2002+0.03906)x5.49805
+46 glue 0  6.2pt plus 3.0pt (xkanjiskip)
+2 hlist 0 (8.8+1.2)x10.0, dir=0 (packed)
+.0 glyph 256  あ (U+3042) 66 (8.11035+0.36133)x8.99902
+46 glue 0  6.2pt plus 3.0pt (xkanjiskip)
+49 glyph 256  c (U+63) 68 (5.22949+0.04883)x5.43945
+46 glue 0  6.2pt plus 3.0pt (xkanjiskip)
+2 hlist 0 (8.8+1.2)x10.0, dir=0 (packed)
+.0 glyph 256  あ (U+3042) 66 (8.11035+0.36133)x8.99902
+46 glue 0  6.2pt plus 3.0pt (xkanjiskip)
+2 hlist 0 (8.8+1.2)x10.0, dir=0 (packed)
+.0 glyph 256  あ (U+3042) 66 (8.11035+0.36133)x8.99902
+======
+======
+49 whatsit 8  userid:4 (direction) (node list) dir: 4
+2 hlist 0 (8.8+1.2)x10.0, dir=0 (packed)
+.0 glyph 256  あ (U+3042) 66 (8.11035+0.36133)x8.99902
+47 glue 0  2.5pt plus 2.5pt minus 1.25pt (xkanjiskip, JFM specified)
+49 glyph 256  c (U+63) 68 (5.22949+0.04883)x5.43945
+47 glue 0  2.5pt plus 2.5pt minus 1.25pt (xkanjiskip, JFM specified)
+2 hlist 0 (8.8+1.2)x10.0, dir=0 (packed)
+.0 glyph 256  あ (U+3042) 66 (8.11035+0.36133)x8.99902
+47 glue 0  2.5pt plus 2.5pt minus 1.25pt (xkanjiskip, JFM specified)
+2 hlist 0 (8.8+1.2)x10.0, dir=0 (packed)
+.0 glyph 256  あ (U+3042) 66 (8.11035+0.36133)x8.99902
+47 glue 0  2.5pt plus 2.5pt minus 1.25pt (xkanjiskip, JFM specified)
+2 hlist 0 (8.8+1.2)x10.0, dir=0 (packed)
+.0 glyph 256  あ (U+3042) 66 (8.11035+0.36133)x8.99902
+======
+======
+49 whatsit 8  userid:4 (direction) (node list) dir: 4
+2 hlist 0 (8.8+1.2)x5.0, dir=0 (packed)
+.0 glyph 256  ) (U+FF09) 66 (8.32031+0.71777)x5.09766
+45 glue 0  0.0pt plus 0.4pt (kanjiskip, JFM specified)
+28 glue 0  5.0pt minus 5.0pt (from JFM: priority 36)
+2 hlist 0 (8.8+1.2)x10.0, dir=0 (packed)
+.0 glyph 256  あ (U+3042) 66 (8.11035+0.36133)x8.99902
+3 penalty 0  10000 (for kinsoku)
+45 glue 0  0.0pt minus 0.4pt (kanjiskip, JFM specified)
+28 glue 0  0.0pt (from JFM: priority 36)
+2 hlist 0 (8.8+1.2)x5.0, dir=0 (packed)
+.0 glyph 256  ) (U+FF09) 66 (8.32031+0.71777)x5.09766
+======
+ [13])
+(see the transcript file for additional information)</opt/texlive/2020/texmf-di
+st/fonts/truetype/public/ipaex/ipaexm.ttf></opt/texlive/2020/texmf-dist/fonts/t
+ruetype/public/ipaex/ipaexg.ttf></opt/texlive/2020/texmf-dist/fonts/truetype/pu
+blic/ipaex/ipamp.ttf></opt/fonts/kozuka/KozMinPr6N-Regular.otf></usr/share/font
+s/cjk/ipam.ttf></opt/texlive/2020/texmf-dist/fonts/type1/public/amsfonts/cm/cmb
+x10.pfb></opt/texlive/2020/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi10.pfb
+></opt/texlive/2020/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb></opt/t
+exlive/2020/texmf-dist/fonts/type1/public/amsfonts/cm/cmti10.pfb></opt/texlive/
+2020/texmf-dist/fonts/type1/public/amsfonts/cm/cmtt10.pfb>
+Output written on test04-jfm.pdf (13 pages, 716694 bytes).
 Transcript written on test04-jfm.log.
index 56c5c37..4593aea 100644 (file)
Binary files a/test/test04-jfm.pdf and b/test/test04-jfm.pdf differ
index 69b604b..0f9b958 100644 (file)
@@ -408,9 +408,31 @@ end}}
 \head{その他: kanjiskip with inf stretch}
 \jfont\knx=KozMinPr6N-Regular.otf:jfm=test2;-kern
 
-\ltjsetparameter{kanjiskip=1pt plus 1.25fil minus 2.75fill}
+{\ltjsetparameter{kanjiskip=1pt plus 1.25fil minus 2.75fill}
 \ltjsetparameter{differentjfm=average}
 \setbox0=\hbox{感感」\knx 感}
+\dumplist0}
+
+\head{inhibitglue and disinhibitglue}
+\setbox0=\hbox{あ(あ\disinhibitglue (あ\inhibitglue\disinhibitglue (}
+\dumplist0
+\setbox0=\hbox{あ\inhibitglue (あ\disinhibitglue\inhibitglue (}
+\dumplist0
+
+\head{insertxkanjiskip and insertkanjiskip}
+\setbox0=\hbox{あ\insertxkanjiskip (\insertxkanjiskip あ\insertxkanjiskip )(\insertxkanjiskip )}
+\dumplist0
+
+\setbox0=\hbox{あ\insertxkanjiskip あaあ\ltjsetparameter{xkanjiskip=6.2pt plus 3pt}cあ\insertxkanjiskip あ}
+\dumplist0
+
+\setbox0=\hbox{あ\insertxkanjiskip lateあaあ\ltjsetparameter{xkanjiskip=6.2pt plus 3pt}cあ\insertxkanjiskip lateあ}
+\dumplist0
+
+\setbox0=\hbox{あ\ltjsetparameter{xkanjiskip=\maxdimen plus 3pt}cあ\insertxkanjiskip あ\insertxkanjiskip lateあ}
+\dumplist0
+
+\setbox0=\hbox{)\insertxkanjiskip\unskip あ)}
 \dumplist0
 
 \end