OSDN Git Service

\ltj@kcatN (N>=1) are unset by default
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Thu, 18 Aug 2022 20:14:25 +0000 (05:14 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Thu, 18 Aug 2022 20:14:25 +0000 (05:14 +0900)
doc/luatexja.dtx
src/ltj-charrange.lua
src/luatexja-core.sty

index d2aefcf..864b440 100644 (file)
@@ -6059,44 +6059,6 @@ that is, without executing \cs{ltj@setpar@global} in advance, is \emph{not} supp
 \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>
 
 
@@ -9152,9 +9114,11 @@ The character class of a \textbf{JAchar}. This attribute is only set on a
 \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}
@@ -9171,17 +9135,21 @@ The amount of shifting the baseline of Japanese fonts in scaled point ($2^{-16}\
 \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}
@@ -12003,6 +11971,17 @@ ISO 32000-1:2008, \textit{Document management -- Portable document format -- Par
 \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>
index 66d5ece..a942012 100644 (file)
@@ -3,7 +3,7 @@
 --
 luatexbase.provides_module({
   name = 'luatexja.charrange',
-  date = '2022-08-17',
+  date = '2022-08-19',
   description = 'Handling the range of Japanese characters',
 })
 luatexja.charrange = {}
@@ -23,15 +23,22 @@ local kcat_attr_table = {}
 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 has_attr(p, ka)&pw==0 end
+      nfn_table[i] = function(p) return has_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 (has_attr(p, ka) or 0)&pw==0 end
+   nfn_table[i] = function(p) return (has_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'
@@ -99,7 +106,9 @@ function luatexja.charrange.toggle_char_range(g, i) -- i: external range number
       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
 
index 7fdf646..7509f1e 100644 (file)
 \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
 \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