OSDN Git Service

ltj-setwidth.lua: better? criteria for rotating glyphs
[luatex-ja/luatexja.git] / doc / luatexja.dtx
1 %<*!showexpl>
2 %#! lualatex -shell-escape
3 %% KozMinPr6N-Regular.otf is needed to typeset this document.
4
5 %%%%% section ==> 章
6 %%%%% subsection => 節
7 \IfFileExists{luatex85.sty}{\RequirePackage{luatex85}}{}
8
9 %<en>\documentclass[a4paper,titlepage]{article}
10 %<ja>\documentclass[a4paper,10ptj,titlepage]{ltjsarticle}
11
12 %%%%%%%%
13 \makeatletter
14 %%%%%%%%
15 \def\pgfsysdriver{pgfsys-pdftex.def}
16 \usepackage{metalogo,amsmath,array,tikz,pict2e,multienum,float,mathtools}
17 \usepackage{booktabs,multicol,luatexja-ruby}
18 \usepackage[all]{xy}
19 \usepackage{lltjext,alltt,comment}
20
21 %%%%%%%% fonts
22 \usepackage{luatexja-otf}
23 \usepackage[no-math]{fontspec}
24 \setmainfont[Ligatures=TeX,RawFeature=-notdef]{Linux Libertine O}
25 \setmonofont[RawFeature=-notdef, Ligatures=CommonOff, %CharacterVariant={31,45,61,36},
26 %<en>  Scale=0.8132073118633364, FakeStretch=1.183236,
27 %<ja>  Scale=MatchLowercase, FakeStretch=1.137121,
28   Contextuals=AlternateOff, Kerning=Off,
29   Ligatures={CommonOff,RequiredOff,ContextualOff,RareOff,HistoricOff,TeXOff},
30   ItalicFont=Iosevka Slab Oblique,
31   BoldFont=Iosevka Slab Bold, BoldItalicFont=Iosevka Slab Bold Oblique,
32 ]{Iosevka Slab}
33 \setsansfont[Scale=MatchLowercase,Ligatures=TeX,RawFeature=-notdef]{Linux Biolinum O}
34 \usepackage[match]{luatexja-fontspec}
35 \usepackage[haranoaji]{luatexja-preset}
36 \usepackage{unicode-math}
37 \setmonojfont{HaranoAjiGothic-Regular.otf}
38 \setmathfont[Scale=MatchLowercase]{XITSMath}
39 \newjfontface\KOZM{KozMinPr6N-Regular.otf}
40
41 \setLaTeXa{\scshape a}
42 %<*ja>
43 \def\emph#1{\textbf{\textgt{#1}}}
44 \def\headfont{\normalfont\bfseries\gtfamily}\normalsize
45 %</ja>
46 %<*en>
47 \frenchspacing\sloppy
48 \usepackage[margin=25mm,lmargin=30mm,rmargin=30mm,footskip=6mm]{geometry}
49 \usepackage{luatexja-adjust}\ltjdisableadjust
50 \parskip=\smallskipamount
51 \makeatletter
52 \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
53     {3.25ex \@plus1ex \@minus.2ex}%
54     {-1em}%
55     {\normalfont\normalsize\bfseries\raisebox{.2ex}{$\mdlgblksquare\mkern1mu$}}}
56 %</en>
57 %<*ja>
58 \usepackage[textwidth=44\zw, lines=41, footskip=6mm]{geometry}
59 \usepackage{luatexja-adjust}%\ltjdisableadjust
60 \advance\leftmargini-1\zw
61 %</ja>
62 %<en>\long\def\fakefn#1#2{\par\noindent{\footnotesize\hbox to1.8em{\hss#1}#2\par}}
63 %<*ja>
64 \long\def\fakefn#1#2{%
65   \par{\footnotesize\advance\leftskip 3\zw\parindent1\zw\noindent
66   \llap{#1\hskip.3\zw}#2\par}}
67 %</ja>
68 %%%%%%%% listings
69
70 %%%%%%%% IVS
71
72 \def\IVS#1{\char\numexpr "E0100+#1\relax}%"
73 \def\IVSA#1#2#3#4#5{%
74   \hbox to1em{\hss\textcolor{blue}{\raisebox{3.5pt}{\normalfont\ttfamily%
75     \fboxsep=0.5pt\fbox{\hbox to0.75em{\hss\tiny \oalign{0#1#2\crcr#3#4#5\crcr}\hss}}}}\hss}%
76 }
77 {\catcode`\%=11
78   \gdef\IVSB#1{\expandafter\IVSA\directlua{
79     local cat_str = luatexbase.catcodetables['string']
80     tex.sprint(cat_str, string.format('%X', 0xE00EF+#1))
81 }}}
82 \def\UCSA#1#2#3#4{%
83   \hbox to1em{\hss\textcolor{blue}{\raisebox{3.5pt}{\normalfont\ttfamily%
84     \fboxsep=0.5pt\fbox{\hbox to0.75em{\hss\tiny \oalign{#1#2\crcr#3#4\crcr}\hss}}}}\hss}%
85 }
86 \def\UCSB#1#2{%
87   \hbox to1em{\hss\textcolor{red}{\raisebox{3.5pt}{\normalfont\ttfamily%
88     \fboxsep=0.5pt\fbox{\hbox to0.75em{\hss\tiny \oalign{\hss#1\hss\crcr\hss#2\hss\crcr}\hss}}}}\hss}%
89 }
90
91 \usepackage{listings,showexpl,enumitem}
92 \lstset{
93   basicstyle=\ttfamily\small, pos=r, breaklines=true,
94   numbers=none, rframe={}, basewidth=0.5em, numberstyle=\tiny, numbersep=0.5em,
95   explpreset={numberstyle=\tiny, numbers=left, numbersep=1em, columns=fixed},
96   morecomment=[l]{\%}, commentstyle=\color{green}
97 }
98 % Suppress output from showexpl to stdout.
99 \makeatletter
100 \let\SX@Info\relax
101
102 %%%%%%%% colors
103 %% modified from http://jfly.iam.u-tokyo.ac.jp/colorset/
104 \usepackage{transparent}
105 \definecolor{red}{rgb}{1, 0.16, 0}
106 \definecolor{blue}{rgb}{0, 0.25, 1}
107 \definecolor{gray}{rgb}{.50, .53, .56}
108 \definecolor{green}{rgb}{.21, .63, .42}
109 \definecolor{cyan}{rgb}{0.40, .80, 1}
110 \definecolor{b_gray}{rgb}{0.78, 0.78, 0.80}
111 \definecolor{b_pink}{rgb}{1, 0.82, 0.82}
112 \definecolor{b_green}{rgb}{.53, .91, .69}
113 \definecolor{b_cyan}{rgb}{0.70, .92, 98}
114
115 %%%%%%%% hyperref
116 \usepackage{hyperref,bookmark}
117 %<*en>
118 \title{The \LuaTeX-ja package}
119 \author{The \LuaTeX-ja project team}
120 \date{\LuaTeXjaversion~(\today)}
121 %</en>
122 %<*ja>
123 \title{\LuaTeX-jaパッケージ}
124 \author{\LuaTeX-jaプロジェクトチーム}
125 \date{\LuaTeXjaversion(\today)}
126 %</ja>
127 \hypersetup{%
128         unicode,
129         colorlinks,
130         allbordercolors=1 1 1,
131         allcolors=blue,
132 %<*en>
133         pdfauthor={The LuaTeX-ja project team},
134         pdftitle={The LuaTeX-ja package}
135 %</en>
136 %<*ja>
137         pdfauthor={LuaTeX-jaプロジェクトチーム},
138         pdftitle={LuaTeX-jaパッケージ}
139 %</ja>
140 }
141 \usepackage{bxghost}
142 %<*ja>
143 \def\HyRef@autoref#1#2{%
144   \begingroup
145     \Hy@safe@activestrue
146     \expandafter\HyRef@autosetref\csname r@#2\endcsname{#2}{#1}%
147   \endgroup\eghostguarded{}%" 欧文ゴースト
148 }
149 \def\figureautorefname{図}
150 \def\tableautorefname{表}
151 %</ja>
152
153 %%%%%%%% definition env.
154 \usepackage{amsthm}
155 \theoremstyle{definition}
156 %<en>\newtheorem{defn}{Definition}
157 %<ja>\newtheorem{defn}{定義}
158 \DeclareMathOperator\nint{nint}
159
160 %%%%%%%% logo
161 \usepackage{metalogo}
162 \DeclareRobustCommand\eTeX{\ensuremath{\varepsilon}-\kern-.125em\TeX}
163 \DeclareRobustCommand\LuaTeX{Lua\TeX}
164 \DeclareRobustCommand\pdfTeX{pdf\TeX}
165 \DeclareRobustCommand\pTeX{p\kern-.15em\TeX}
166 \DeclareRobustCommand\upTeX{up\kern-.15em\TeX}
167 \DeclareRobustCommand\pLaTeX{p\kern-.05em\LaTeX}
168 \DeclareRobustCommand\pLaTeXe{p\kern-.05em\LaTeXe}
169 \DeclareRobustCommand\epTeX{\ensuremath{\varepsilon}-\pTeX}
170
171 %%%%%%%% other macros
172 \newlist{cslist}{description}{2}
173 \setlist[cslist]{%
174     style=nextline,font=\mdseries\ttfamily,
175     before*=\def\<{\char`\<}\def\>{\char`\>}\def\{{\char`\{}\def\}{\char`\}},
176     topsep=\medskipamount,
177 %<ja> leftmargin=2\zw,
178 %<en> leftmargin=2em,
179 }
180
181 \def\labelenumii{(\arabic{enumii})}
182 \long\def\@makecaption#1#2{%
183   \vskip\abovecaptionskip
184   \sbox\@tempboxa{{\small #1. #2}}%
185   \ifdim \wd\@tempboxa >\hsize
186     {\small #1. #2}\par
187   \else
188     \global \@minipagefalse
189     \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
190   \fi
191   \vskip\belowcaptionskip}
192
193 \def\_{\leavevmode \kern .06em\vbox {\hrule \@width .333em}}
194 \def\cs#1{\texttt{\upshape
195   \texorpdfstring{\hbox{\ltjsetparameter{autoxspacing=false}\textbackslash#1}}{\textbackslash#1}}}
196 \ltjsetparameter{alxspmode={`\\,allow}}
197 \def\text@#1{%
198   \ifnum\mathstyle<\scriptstyle
199         \mbox{#1}
200   \else\ifnum\mathstyle<\scriptscriptstyle
201         \mbox{\let\f@size\sf@size\selectfont#1}
202   \else
203         \mbox{\let\f@size\ssf@size\selectfont#1}
204   \fi\fi
205 }
206 %%%%%%%%
207 \makeatother
208 %%%%%%%%
209
210 \def\Node#1#2{\,\vcenter{\hbox{\fboxsep=1pt\fbox{\vbox{\small\halign{\hfil##\hfil\cr
211   #1\mathstrut\cr\noalign{\vskip1pt\hrule height.4pt\vskip1pt}\strut#2\cr}}}}}\,}
212 \def\HNode#1#2#3#4{\,\vcenter{\hbox{\fboxsep=1pt\fbox{\vbox{\small\halign{\hfil##\hfil\cr
213   #1\mathstrut\cr\noalign{\vskip1pt\hrule height.4pt\vskip1pt}%
214   width:\hfill\ #2\cr height:\hfill\ #3\cr depth:\hfill\ #4\cr
215   }}}}}\,}
216 \protected\def\+{\insertxkanjiskip late}
217 \makeatletter
218 \def\Param#1{\texorpdfstring{\@Param{#1}}{#1}} % parameter name
219 \protected\def\@Param#1{\eghostguarded{\hyperlink{fld:#1}{\underline{\smash{\textsf{#1}}}}}}
220 \protected\def\DParam#1{\eghostguarded{\hypertarget{fld:#1}{\underline{\smash{\textsf{#1}}}}}} % parameter name (definition)
221 \def\Pkg#1{\texorpdfstring{\textsf{#1}}{#1}} % packages/classes
222
223 \begin{document}
224 \lstset{
225   vscmd=\IVSB
226 }
227
228 \def\meta#1{{\normalfont\rmfamily\itshape$\langle$#1\/$\rangle$}}
229 \maketitle
230
231 \tableofcontents
232 \bigskip
233
234 %<*en>
235 \textbf{This documentation is far from complete. It may have many
236 grammatical (and contextual) errors.} Also, several parts
237 are written in Japanese only.
238 %</en>
239
240 \clearpage
241 %<en>\part{User's manual}
242 %<ja>\part{ユーザーズマニュアル}
243
244 %<en>\section{Introduction}
245 %<ja>\section{はじめに}
246
247
248 %<*en>
249 The \LuaTeX-ja package is a macro package for typesetting high-quality
250 Japanese documents when using \LuaTeX.
251 %</en>
252 %<*ja>
253 \LuaTeX-jaパッケージは,次世代標準\TeX である\LuaTeX の上で,\pTeX と同等
254 /それ以上の品質の日本語組版を実現させようとするマクロパッケージである.
255 %</ja>
256 %<en>\subsection{Backgrounds}
257 %<ja>\subsection{背景}
258
259 %<*en>
260 Traditionally, ASCII \pTeX, an extension of \TeX, and its derivatives
261 are used to typeset Japanese documents in \TeX. \pTeX\ is an engine
262 extension of \TeX: so it can produce high-quality Japanese documents
263 without using very complicated macros. But this point is a mixed
264 blessing: \pTeX\ is left behind from other extensions of \TeX,
265 especially \eTeX\ and \pdfTeX, and from changes about
266 Japanese processing in computers (\textit{e.g.}, the UTF-8 encoding).
267 %</en>
268 %<*ja>
269 従来,「\TeX を用いて日本語組版を行う」といったとき,エンジンとしては
270 ASCII \pTeX やそれの拡張物が用いられることが一般的であった.\pTeX は\TeX
271 のエンジン拡張であり,(少々仕様上不便な点はあるものの)商業印刷の分野に
272 も用いられるほどの高品質な日本語組版を可能としている.だが,それは弱点に
273 もなってしまった.\pTeX という(組版的に)満足なものがあったため,海外で
274 行われている数々の\TeX の拡張――例えば\eTeX や\pdfTeX ――や,TrueType,
275 OpenType, Unicodeといった計算機で日本語を扱う際の状況の変化に追従すること
276 を怠ってしまったのだ.
277 %</ja>
278
279 %<*en>
280 Recently extensions of \pTeX, namely \upTeX\ (Unicode-implementation
281 of \pTeX) and \epTeX\ (merging of \pTeX\ and
282 \eTeX\ extension), have developed to fill those gaps to some
283 extent, but gaps still exist.
284 %</en>
285 %<*ja>
286 ここ数年,若干状況は改善されてきた.現在手に入る大半の\pTeX バイナリでは
287 外部UTF-8入力が利用可能となり,さらにUnicode化を推進し,\pTeX の内部処理
288 までUnicode化した\upTeX も開発されている.また,\pTeX に\eTeX 拡張をマー
289 ジした\epTeX も登場し,\TeX\ Live\ 2011では\pLaTeX が\epTeX の上で動作す
290 るようになった.だが,\pdfTeX 拡張の主要部分(PDF直接出力やmicro-typesetting)を
291 \pTeX に対応させようという動きはなく,海外とのgapは未だにあるのが現状であ
292 る.
293 %</ja>
294
295 %<*en>
296 However, the appearance of \LuaTeX\ changed the whole situation. With
297 using Lua ``callbacks'', users can customize the internal processing of
298 \LuaTeX. So there is no need to modify sources of engines to
299 support Japanese typesetting: to do this, we only have to write Lua
300 scripts for appropriate callbacks.
301 %</en>
302 %<*ja>
303 しかし,\LuaTeX の登場で,状況は大きく変わることになった.Luaコードで
304 ``callback''を書くことにより,\LuaTeX の内部処理に割り込みをかけることが可
305 能となった.これは,エンジン拡張という真似をしなくても,Luaコードとそれに
306 関する\TeX マクロを書けば,エンジン拡張とほぼ同程度のことができるようになっ
307 たということを意味する.\LuaTeX-jaは,このアプローチによってLuaコード・
308 \TeX マクロによって日本語組版を\LuaTeX の上で実現させようという目的で開発
309 が始まったパッケージである.
310 %</ja>
311
312 %<en>\subsection{Major changes from \pTeX}
313 %<ja>\subsection{\pTeX からの主な変更点}
314 \label{ssec:chgptex}
315
316 %<*en>
317 The \LuaTeX-ja package is under much influence of \pTeX\ engine. The initial
318 target of development was to implement features of \pTeX. However,
319 implementing all feature of \pTeX\ is impossible,
320 since all process of \LuaTeX-ja must be implemented only by Lua and \TeX\ macros.
321 Hence \emph{\LuaTeX-ja is not a just porting of \pTeX; unnatural
322 specifications/behaviors of \pTeX\ were not adopted}.
323 %</en>
324 %<*ja>
325 \LuaTeX-jaは,\pTeX に多大な影響を受けている.初期の開発目標は,\pTeX の機
326 能をLuaコードにより実装することであった.しかし,(\pTeX はエンジン拡張であったのに対し)
327 \LuaTeX-jaはLuaコードと\TeX マクロを用いて全てを実装していなければならないため,\pTeX
328 の完全な移植は不可能であり,また\pTeX における実装がいささか不可解になっ
329 ているような状況も発見された.そのため,\emph{\LuaTeX-jaは,もはや
330 \pTeX の完全な移植は目標とはしない.\pTeX における不自然な仕様・挙動があ
331 れば,そこは積極的に改める.}
332 %</ja>
333
334 %<*en>
335 The followings are major changes from \pTeX.
336 For more detailed information, see Part~\ref{part-imp} or other sections of this manual.
337 %</en>
338 %<*ja>
339 以下は \pTeX からの主な変更点である.
340 より詳細については第\ref{part-imp}部など本文書の残りを参照.
341 %</ja>
342
343 %<*en>
344 \paragraph{Command names} \pTeX\ addes several primitives, such as \cs{kanjiskip},
345 \cs{prebreakpenalty},~and \cs{ifydir}. They can be used as follows:
346 %</en>
347 %<*ja>
348 \paragraph{命令の名称} 例えば\pTeX で追加された次のようなプリミティブ
349 %</ja>
350 \begin{lstlisting}
351 \kanjiskip=10pt  \dimen0=kanjiskip
352 \tbaselineshift=0.1zw
353 \dimen0=\tbaselineshift
354 \prebreakpenalty`ぁ=100
355 \ifydir ... \fi
356 \end{lstlisting}
357 %<en> However, we cannot use them under \LuaTeX-ja.
358 %<en> Instead of them, we have to write as the following.
359 %<ja> は\LuaTeX-jaには存在しない.\LuaTeX-jaでは以下のように記述することになる.
360 \begin{lstlisting}
361 \ltjsetparameter{kanjiskip=10pt}  \dimen0=\ltjgetparameter{kanjiskip}
362 \ltjsetparameter{talbaselineshift=0.1\zw}
363 \dimen0=\ltjgetparameter{talbaselineshift}
364 \ltjsetparameter{prebreakpenalty={`ぁ,100}}
365 \ifnum\ltjgetparameter{direction}=4 ... \fi
366 \end{lstlisting}
367 %<*en>
368 Note that \pTeX\ adds new two useful units, namely \texttt{zw}~and~\texttt{zh}.
369 As shown above, \emph{they are changed to \cs{zw}~and~\cs{zh} respectively} in \LuaTeX-ja.%
370 \footnote{\LuaTeX-ja 20200127.0 introduces \cs{ltj@zw}~and~\cs{ltj@zh}, which are copy of
371   \cs{zw}~and~\cs{zh}.}
372 %</en>
373 %<*ja>
374 特に注意してほしいのは,\pTeX で追加された\texttt{zw}と\texttt{zh}という単位は
375 \LuaTeX-ja では使用できず,\emph{\cs{zw}, \cs{zh} と制御綴の形にしないといけない}という点である
376 \footnote{%
377   別のパッケージやユーザが\cs{zw},~\cs{zh}を書き換えてしまうことに対応するため,
378   \LuaTeX-ja 20200127.0以降では,\cs{ltj@zw},~\cs{ltj@zh}がそれぞれ\cs{zw},~\cs{zh}の
379   コピーとして定義されている.
380 }.
381 %</ja>
382
383 %<*en>
384 \paragraph{Linebreak after a Japanese character}
385 In \pTeX, a line break after Japanese character is ignored (and
386       doesn't yield a space), since line breaks (in source files) are
387       permitted almost everywhere in Japanese texts. However, \LuaTeX-ja
388       doesn't have this feature completely, because of a specification
389       of \LuaTeX. For the detail, see Section~\ref{sec-lbreak}.
390 %</en>
391 %<*ja>
392 \paragraph{和文文字直後の改行}
393 日本語の文書中では改行はほとんどどこでも許されるので,\pTeX では和文文字
394       直後の改行は無視される(スペースが入らない)ようになっていた.しかし,
395       \LuaTeX-ja では \LuaTeX の仕様のためにこの機能は完全には実装されていない.
396       詳しくは\ref{sec-lbreak}章を参照.
397 %</ja>
398
399 %<*en>
400 \paragraph{Spaces related to Japanese characters}
401 The insertion process of glues/kerns between two Japanese
402       characters and between a Japanese character and other characters
403       (we refer glues/kerns of both kinds as \textbf{JAglue}) is rewritten from
404       scratch.
405 %</en>
406 %<*ja>
407 \paragraph{和文関連の空白}
408 2つの和文文字の間や,和文文字と欧文文字の間に入るグルー/カーン
409       (両者をあわせて\textbf{JAglue}と呼ぶ)の挿入処理が0から書き直されている.
410 %</ja>
411
412 \begin{itemize}
413 %<*en>
414 \item As \LuaTeX's internal ligature handling is \emph{node-based}
415       (\textit{e.g.}, \verb+of{}fice+ doesn't prevent ligatures), the
416       insertion process of \textbf{JAglue} is now \emph{node-based}.
417 %</en>
418 %<*ja>
419 \item \LuaTeX の内部での合字の扱いは「ノード」を単位として行われるようになっている(例えば,
420       \verb+of{}fice+ で合字は抑制されない).それに合わせ,\textbf{JAglue}の挿入処理も
421       ノード単位で実行される.
422 %</ja>
423
424 %<*en>
425 \item Furthermore, nodes between two characters which have no effects in
426       line break (\textit{e.g.}, \cs{special} node) and kerns from
427       italic correction are ignored in the insertion process.
428 %</en>
429 %<*ja>
430 \item さらに,2つの文字の間にある行末では効果を持たないノード(例えば \cs{special} ノード)や,
431   イタリック補正に伴い挿入されるカーンは挿入処理中では無視される.
432 %</ja>
433
434 %<*en>
435 \item \emph{Caution: due to above two points, many methods which did for the
436       dividing the process of the insertion of \textbf{JAglue} in \pTeX\ are not
437       effective anymore.} In concrete terms, the following two methods are not effective anymore:
438 %</en>
439 %<*ja>
440 \item \emph{注意:上の2つの変更により,従来\textbf{JAglue}の挿入処理を分断するのに
441       使われていたいくつかの方法は用いることができない.具体的には,次の方法はもはや無効である:}
442 %</ja>
443 \begin{lstlisting}
444 ちょ{}っと    ちょ\/っと
445 \end{lstlisting}
446 %<*en>
447       If you want to do so, please put an empty horizontal box (hbox) between it instead:
448 %</en>
449 %<*ja>
450       もし同じことをやりたければ,空の水平ボックス(hbox)を間に挟めばよい:
451 %</ja>
452 \begin{lstlisting}
453 ちょ\hbox{}っと
454 \end{lstlisting}
455
456 %<*en>
457 \item In the process, two Japanese fonts which only differ in their ``real''
458       fonts are identified.
459 %</en>
460 %<*ja>
461 \item 処理中では,2つの和文フォントは,実フォントが異なるだけの場合には同一視
462       される.
463 %</ja>
464 \end{itemize}
465
466 %<*en>
467 \paragraph{Directions}
468 From version~20150420.0, \LuaTeX-ja supports vertical writing.
469 We implement this feature by using callbacks of \LuaTeX; so it must \emph{not} be confused
470 with $\Omega$-style direction support of \LuaTeX\ itself.
471 Due to implementation, the dimension returned by \cs{wd},~\cs{ht}, or~\cs{dp} depends
472 on the content of the register \emph{only}. This is major difference with \pTeX.
473 %</en>
474 %<*ja>
475 \paragraph{組方向}
476 バージョン20150420.0からは,不安定ながらも\LuaTeX-ja における縦組みをサポートしている.
477 なお,\LuaTeX 本体も$\Omega$流の組方向をサポートしているが,それとは全くの別物であること
478 に注意してほしい.
479 特に,異なった組方向のボックスを扱う場合には
480 \cs{wd}, \cs{ht}, \cs{dp}等の仕様が\pTeX と異なるので注意.詳細は第\ref{sec-direction}章を参照.
481 %</ja>
482
483 %<*en>
484 \paragraph{\cs{discretionary}}
485 Japanese characters in discretionary break (\cs{discretionary}) is not supported.
486 %</en>
487 %<*ja>
488 \paragraph{\cs{discretionary}}
489  \cs{discretionary} 内に直接和文文字を記述することは,\pTeX においても想定されていなかった
490  感があるが.\LuaTeX-jaにおいても想定していない.和文文字をどう
491       しても使いたい場合は \cs{hbox} で括ること.
492 %</ja>
493
494 %<*en>
495 \paragraph{Greek and Cyrillic letters, and ISO~8859-1 symbols}
496 By default, \LuaTeX-ja uses Japanese fonts to typeset Greek and Cyrillic letters,
497       To change this behavior,
498       put \verb!\ltjsetparameter{jacharrange={-2,-3}}! in the preamble.
499       For the detailed description, see Subsection~\ref{ssec:setrange}.
500
501 From version~20150906.0, characters which belongs both ISO~8859-1 and JIS~X~0208,
502 such as \P~and~\S, are now typeset in alphabetic fonts.
503 %</en>
504 %<*ja>
505 \paragraph{ギリシャ文字・キリル文字とISO~8859-1の記号}
506 標準では,\LuaTeX-jaはギリシャ文字やキリル文字を和文フォントを使っ
507       て組む.ギリシャ語などを本格的に組むなどこの状況が望ましくない場合,
508       プリアンブルに
509 \begin{lstlisting}
510  \ltjsetparameter{jacharrange={-2,-3}}
511 \end{lstlisting}
512       を入れると
513       上記種類の文字は欧文フォントを用いて組まれるようになる.
514       詳しい説明は\ref{ssec:setrange}節を参照してほしい.
515
516 また,\P,~\S といったISO~8859-1の上位領域とJIS~X~0208の共通部分の文字は
517       バージョン20150906.0から標準で欧文扱いとなった.\LaTeXe\ 2017/01/01以降では
518 標準でTUエンコーディングのLatin Modernフォントが使われるので,
519 特に何もせずソース中にそのまま記述してもこれらの文字が出力される.
520 和文扱いで出力するには \verb+\ltjjachar`§+ のように \cs{ltjjachar} 命令
521 を使えばよい.
522 %</ja>
523
524 %<en>\subsection{Notations}
525 %<ja>\subsection{用語と記法}
526
527 %<*en>
528 In this document, the following terms and notations are used:
529 %</en>
530 %<*ja>
531 本ドキュメントでは,以下の用語と記法を用いる:
532 %</ja>
533 \begin{itemize}
534 %<*en>
535 \item Characters are classified into following two types.
536       Note that the classification can be customized by a user
537       (see Subsection~\ref{ssec:setrange}).
538 %</en>
539 %<*ja>
540 \item 文字は次の2種類に分けられる.この類別は固定されているものではなく,ユーザが後から変更可能である
541       (\ref{ssec:setrange}節を参照).
542 %</ja>
543 \begin{itemize}
544 %<*en>
545 \item \textbf{JAchar}: standing for characters which is used in Japanese typesetting,
546       such as Hiragana,~Katakana, Kanji, and~other Japanese punctuation marks.
547 %</en>
548 %<*ja>
549 \item \textbf{JAchar}: ひらがな,カタカナ,漢字,和文用の約物といった
550       日本語組版に使われる文字のことを指す.
551 %</ja>
552
553 %<en>\item \textbf{ALchar}: standing for all other characters like latin alphabets.
554 %<ja>\item \textbf{ALchar}: ラテンアルファベットを始めとする,その他全ての文字を指す.
555 \end{itemize}
556
557 %<*en>
558 We say \emph{alphabetic fonts} for fonts used in \textbf{ALchar},
559 and \emph{Japanese fonts} for fonts used in \textbf{JAchar}.
560 %</en>
561 %<*ja>
562 そして,\textbf{ALchar}の出力に用いられるフォントを\emph{欧文フォント}と呼び,
563 \textbf{JAchar}の出力に用いられるフォントを\emph{和文フォント}と呼ぶ.
564 %</ja>
565 %<*en>
566 \item A word in a sans-serif font with underline (like \Param{prebreakpenalty})
567       means an internal parameter for Japanese typesetting, and it
568       is used as a key in \cs{ltjsetparameter} command.
569 %</en>
570 %<*ja>
571 \item 下線つきローマン体で書かれた語(例:\Param{prebreakpenalty})は日本語組版用の
572       パラメータを表し,これらは \cs{ltjsetparameter} 命令のキーとして
573       用いられる.
574 %</ja>
575 %<*en>
576 \item A word in a sens-serif font without underline (like \Pkg{fontspec})
577       means a package or a class of \LaTeX.
578 %</en>
579 %<*ja>
580 \item 下線なしサンセリフ体の語(例:\Pkg{fontspec})は\LaTeX の
581       パッケージやクラスを表す.
582 %</ja>
583 %<*en>
584 \item In this document, natural numbers start from~zero.
585   $\omega$ denotes the set of all natural numbers which can be used in \TeX.
586 %</en>
587 %<*ja>
588 \item 本ドキュメントでは,自然数は0から始まる.(\TeX で扱える)自然数全体の集合は$\omega$と表記する.
589 %</ja>
590 \end{itemize}
591
592 %<en>\subsection{About the project}
593 %<ja>\subsection{プロジェクトについて}
594
595 %<en>\paragraph{Project Wiki} Project Wiki is under construction.
596 %<ja>\paragraph{プロジェクトWiki} プロジェクトWikiは構築中である.
597 %<*en>
598 \begin{itemize}
599 \item \url{https://github.com/luatexja/luatexja/wiki/Home(en)} (English)
600 \item \url{https://github.com/luatexja/luatexja/wiki} (Japanese)
601 \item \url{https://github.com/luatexja/luatexja/wiki/Home(zh)} (Chinese)
602 \end{itemize}
603 %</en>
604 %<*ja>
605 \begin{itemize}
606 \item \url{https://github.com/luatexja/luatexja/wiki}(日本語)
607 \item \url{https://github.com/luatexja/luatexja/wiki/Home(en)}(英語)
608 \item \url{https://github.com/luatexja/luatexja/wiki/Home(zh)}(中国語)
609 \end{itemize}
610 %</ja>
611
612 %<en>This project is hosted by GitHub.
613 %<ja>本プロジェクトはGitHubのサービスを用いて運営されている.
614
615 %<en>\paragraph{Members}\
616 %<ja>\clearpage\paragraph{開発メンバー}\
617
618 %<*en>
619 \begin{multienumerate}
620 \def\labelenumi{$\bullet$}
621 \mitemxxx{Hironori KITAGAWA}{Kazuki MAEDA}{Takayuki YATO}
622 \mitemxxx{Yusuke KUROKI}{Noriyuki ABE}{Munehiro YAMAMOTO}
623 \mitemxxx{Tomoaki HONDA}{Shuzaburo SAITO}{MA Qiyuan}
624 \end{multienumerate}
625 %</en>
626 %<*ja>
627 \begin{multienumerate}
628 \def\labelenumi{$\bullet$}
629 \mitemxxx{北川 弘典}{前田 一貴}{八登 崇之}
630 \mitemxxx{黒木 裕介}{阿部 紀行}{山本 宗宏}
631 \mitemxxx{本田 知亮}{齋藤 修三郎}{馬 起園}
632 \end{multienumerate}
633 %</ja>
634
635 % \paragraph{Acknowledgments} -- 挿入するならここ
636
637 %<en>\clearpage
638 %<en>\section{Getting Started}
639 %<ja>\section{使い方}
640 %<en>\subsection{Installation}
641 %<ja>\subsection{インストール}
642 \label{ssec:install}
643 %<en>The following packages are needed for the \LuaTeX-ja\ package.
644 %<ja>\LuaTeX-jaパッケージの動作には次のパッケージ類が必要である.
645 \begin{itemize}
646 \item \href{http://www.luatex.org/}{\LuaTeX}\ 1.10.0 (or later)
647 %<en>  (DVI output (\cs{outputmode=0} is not supported.)
648 %<ja>  (DVI出力(\cs{outputmode=0})は対応していない.)
649 \item recent \href{https://github.com/latex3/luaotfload}{\Pkg{luaotfload}} (v3.1 or later recommended)
650 \item \Pkg{adobemapping} (Adobe cmap and pdfmapping files)
651 \item \LaTeXe\ 2020-02-02 patch level 5 or later
652 %<en>  (if you want to use \LuaTeX-ja with \LaTeXe)
653 %<ja>  (\LaTeXe 下で\LuaTeX-jaを使う場合)
654 \item \href{https://github.com/josephwright/etoolbox/}{\Pkg{etoolbox}}
655 %<en>  (if you want to use \LuaTeX-ja with \LaTeXe)
656 %<ja>  (\LaTeXe 下で\LuaTeX-jaを使う場合)
657 \item \Pkg{everysel} (only for \LaTeXe\ 2020-02-02~and~2020-10-01)
658 \item \Pkg{filehook}, \Pkg{atbegshi}  (only for \LaTeXe\ 2020-02-02)
659 \item \Pkg{ltxcmds}, \Pkg{pdftexcmds}
660 \item \href{https://github.com/wspr/fontspec/}{\Pkg{fontspec}} v2.7c (or later)
661 %<*en>
662 \item \emph{Harano Aji fonts} (\url{https://github.com/trueroad/HaranoAjiFonts})\\
663   More specifically, HaranoAjiMincho-Regular~and~HaranoAjiGothic-Medium.
664 %</en>
665 %<*ja>
666 \item \emph{原ノ味フォント(\url{https://github.com/trueroad/HaranoAjiFonts})}\\
667 \LuaTeX-jaの最低限の動作には原ノ味明朝Regular~(HaranoAjiMincho-Regular)と
668 原ノ味角ゴシックMedium~(HaranoAjiGothic-Medium)があれば十分である.
669 %</ja>
670 \end{itemize}
671
672 %<*en>
673 Now \LuaTeX-ja is available from
674 CTAN (in the \texttt{macros/luatex/generic/luatexja} directory), and
675 the following distributions:
676   \begin{itemize}
677   \item \href{https://www.tug.org/texlive/}{\TeX~Live} (in \texttt{texmf-dist/tex/luatex/luatexja})
678   \item MiK\TeX\ (in \texttt{luatexja.tar.xz})
679   \end{itemize}
680 Harano Aji fonts are also available in these distributions
681 (\texttt{haranoaji} in \TeX~Live and MiK\TeX).
682 %</en>
683 %<*ja>
684 現在,\LuaTeX-jaはCTAN (\texttt{macros/luatex/generic/luatexja})に収録されている他,
685 以下のディストリビューションにも収録されている:
686   \begin{itemize}
687   \item MiK\TeX\ (\texttt{luatexja.tar.lzma})
688   \item \TeX~Live (\texttt{texmf-dist/tex/luatex/luatexja})
689   \end{itemize}
690 これらのディストリビューションは原ノ味フォントも収録している
691 (\TeX~Live, MiK\TeX では\texttt{haranoaji}).
692 %</ja>
693
694 %<*en>
695 \paragraph{HarfBuzz~and~\LuaTeX-ja}
696 Using \LuaTeX-ja with LuaHB\TeX (\LuaTeX\ integrated with
697 \href{https://github.com/harfbuzz/harfbuzz}{HarfBuzz}) is not well tested.
698 Maybe documents can typeset without an error,
699 but with unwanted results (especially, vertical typesetting and \cs{CID}).
700
701 Especially,
702 \emph{We don't recommend defining a Japanese font with HarfBuzz},
703 by specifying \texttt{Renderer=Harfbuzz}~etc.\ (\Pkg{fontspec}) or~{mode=harf} (otherwise).
704 %</en>
705 %<*ja>
706 \paragraph{HarfBuzzと\LuaTeX-ja}
707 現時点では,HarfBuzzの機能を用いたときの\LuaTeX-jaの使用は十分にテストされていない.
708 エラーが発生せずにタイプセットできるかもしれないが,特に縦組時や
709 \cs{CID}などで意図しない結果となりうる可能性が大きい.
710 特に,\emph{\texttt{Renderer=Harfbuzz}等(\Pkg{fontspec})や\texttt{mode=harf}指定(それ以外)を通じて
711   和文フォントに対してHarfBuzzを用いることは推奨しない}.
712 %</ja>
713
714 %<en>\paragraph{Manual installation}
715 %<ja>\paragraph{手動インストール方法}
716
717 \begin{enumerate}
718 %<*en>
719 \item Download the source, by one of the following method.
720       At the present, \LuaTeX-ja has no \emph{stable} release.
721
722 \begin{itemize}
723 \item Clone the Git repository by
724 \begin{lstlisting}
725 $ git clone https://github.com/luatexja/luatexja.git
726 \end{lstlisting}
727 \item Download the \texttt{zip} archive of HEAD in the \texttt{master} branch from
728 \begin{flushleft}
729 \url{https://github.com/luatexja/luatexja/archive/refs/heads/master.zip}.
730 \end{flushleft}
731 \end{itemize}
732
733 Note that the \texttt{master} branch, and hence the archive in CTAN, are not updated frequently;
734 the forefront of development is not the \texttt{master} branch.
735 %</en>
736 %<*ja>
737 \item ソースを以下のいずれかの方法で取得する.現在公開されているのはあくまでも
738       開発版であって,安定版でないことに注意.
739
740 \begin{itemize}
741 \item Gitリポジトリを次のコマンドでクローンする:
742 \begin{lstlisting}
743 $ git clone https://github.com/luatexja/luatexja.git
744 \end{lstlisting}
745 \item \texttt{master} ブランチのスナップショット(\texttt{zip} 形式)をダウンロードする:
746 \begin{flushleft}
747 \url{https://github.com/luatexja/luatexja/archive/refs/heads/master.zip}.
748 \end{flushleft}
749 \end{itemize}
750 \texttt{master} ブランチ(従って,CTAN内のアーカイブも)はたまにしか更新されないことに注意.
751 主な開発は\texttt{master}の外で行われ,比較的まとまってきたらそれを \texttt{master} に
752 反映させることにしている.
753 %</ja>
754
755 %<*en>
756 \item Extract the archive. You will see \texttt{src/} and several other sub-directories.
757 But only the contents in \texttt{src/} are needed to work \LuaTeX-ja.
758 %</en>
759 %<*ja>
760 \item 「Gitリポジトリをクローン」以外の方法でアーカイブを取得したならば,それを展開する.
761       \texttt{src/} をはじめとしたいくつかのディレクトリができるが,
762       動作には \texttt{src/} 以下の内容だけで十分.
763 %</ja>
764
765 %<*en>
766 \item If you downloaded this package from CTAN, you have to run following commands
767     to generate classes:
768 %</en>
769 %<*ja>
770 \item もしCTANから本パッケージを取得したのであれば,日本語用クラスファイルを生成するために,
771 以下を実行する必要がある:
772 %</ja>
773 \begin{lstlisting}
774 $ cd src
775 $ lualatex ltjclasses.ins
776 $ lualatex ltjsclasses.ins
777 $ lualatex ltjltxdoc.ins
778 \end{lstlisting}
779
780 %<*en>
781 \item Copy all the contents of \texttt{src/} into one of your \texttt{TEXMF} tree.
782       \texttt{TEXMF/tex/luatex/luatexja/} is an example location.
783       If you cloned entire Git repository, making a symbolic link of \texttt{src/}
784       instead copying is also good.
785 %</en>
786 %<*ja>
787 \item \texttt{src} の中身を自分の \texttt{TEXMF} ツリーにコピーする.
788       場所の例としては,例えば
789 \begin{quote}
790  \texttt{TEXMF/tex/luatex/luatexja/}
791 \end{quote}
792       がある.
793       シンボリックリンクが利用できる環境で,かつリポジトリを直接取得したのであれば,
794       (更新を容易にするために)コピーではなくリンクを貼ることを勧める.
795 %</ja>
796 %<*en>
797 \item If \texttt{mktexlsr} is needed to update the file name database, make it so.
798 %</en>
799 %<*ja>
800 \item 必要があれば,\texttt{mktexlsr} を実行する.
801 %</ja>
802 \end{enumerate}
803
804 %<*en>
805 \subsection{Cautions}
806 For changes from \pTeX, see Subsection~\ref{ssec:chgptex}.
807 %</en>
808 %<*ja>
809 \subsection{注意点}
810 \pTeX からの変更点として,\ref{ssec:chgptex}節も熟読するのが望ましい.
811 ここでは一般的な注意点を述べる.
812 %</ja>
813 \begin{itemize}
814 %<*en>
815 \item The encoding of your source file must be UTF-8. Other
816       encodings, such as EUC-JP or Shift-JIS, are not supported.
817 %</en>
818 %<*ja>
819 \item 原稿のソースファイルの文字コードはUTF-8固定である.
820       従来日本語の文字コードとして用いられてきたEUC-JPやShift-JISは使用できない.
821 %</ja>
822 %<*en>
823 \item \LuaTeX-ja is very slower than \pTeX, and uses a lot of memory.
824 %</en>
825 %<*ja>
826 \item \LuaTeX-jaは動作が\pTeX に比べて非常に遅い.
827   コードを調整して徐々に速くしているが,まだ満足できる速度ではない.
828   また,和文フォントを読み込むために多量のメモリを消費することにも注意が必要である.
829 %</ja>
830
831 \item
832 %<*en>
833 Note that when \LuaTeX-ja is loaded in plain \LuaTeX,
834 we cannot use color specification on font loading, such as
835 \begin{lstlisting}
836   \font\hoge=lmroman10-regular.otf:color=FF0000 % \font primitive
837 \end{lstlisting}
838 This is because codes for shifting baseline in math mode (\LuaTeX-ja) collide with and prevents loading
839 codes for font color (\Pkg{luaotfload}) in these environments.
840 \emph{We recommend to use \LaTeX\ 2020-02-02 (or later)}, since we can avoid this collision in there.
841 %</en>
842 %<*ja>
843 なお,\LuaTeX-jaをplain~\LuaTeX で用いる場合,
844 以下のような\emph{フォント読み込み時の色指定}(\cs{textcolor}命令ではなく!)\emph{は利用できない}.
845 \begin{lstlisting}
846   \font\hoge=lmroman10-regular.otf:color=FF0000 % \font primitive
847 \end{lstlisting}
848 これは,\LuaTeX-jaによる数式内のベースライン補正(\ref{ssec:baseline}節)のコードが
849 \Pkg{luaotfload}パッケージのフォント色処理のコードと衝突するためである.
850 \LaTeX\ 2020-02-02以降では衝突回避のための仕組みが備わっているので.\emph{\LaTeX\ 2020-02-02以降での使用を勧める}.
851 %</ja>
852 \end{itemize}
853
854 %<en>\subsection{Using in plain \TeX}
855 %<ja>\subsection{plain \TeX で使う}
856 \label{ssec:plain}
857
858 %<en>To use \LuaTeX-ja in plain \TeX, simply put the following at the beginning of the document:
859 %<ja>\LuaTeX-jaを plain \TeX で使うためには,単に次の行をソースファイルの冒頭に追加すればよい:
860 \begin{lstlisting}
861 \input luatexja.sty
862 \end{lstlisting}
863 %<en>This does minimal settings (like \texttt{ptex.tex}) for typesetting Japanese documents:
864 %<ja>これで(\texttt{ptex.tex}のように)日本語組版のための最低限の設定がなされる:
865
866 \begin{itemize}
867 %<*en>
868 \item The following 12~Japanese fonts are preloaded:
869 \begin{center}\small
870 \begin{tabular}{llllll}
871 \toprule
872 \textbf{direction}&
873 \textbf{classification}&\textbf{font name}&\bfseries ``10\,pt''&\bfseries ``7\,pt''&\bfseries ``5\,pt''\\\midrule
874 \smash{\raisebox{-1ex}{\emph{yoko} (horizontal)}}&
875 \emph{mincho}&HaranoAjiMincho-Regular&\cs{tenmin}&\cs{sevenmin}&\cs{fivemin}\\
876 &\emph{gothic}&HaranoAjiGothic-Medium&\cs{tengt} &\cs{sevengt} &\cs{fivegt}\\
877 \midrule
878 \smash{\raisebox{-1ex}{\emph{tate} (vertical)}}&
879 \emph{mincho}&HaranoAjiMincho-Regular&\cs{tentmin}&\cs{seventmin}&\cs{fivetmin}\\
880 &\emph{gothic}&HaranoAjiGothic-Medium&\cs{tentgt} &\cs{seventgt} &\cs{fivetgt}\\
881 \bottomrule
882 \end{tabular}
883 \end{center}
884 %</en>
885 %<*ja>
886 \item 以下の12個の和文フォントが定義される:
887 \begin{center}\small
888 \begin{tabular}{llllll}
889 \toprule
890 \emph{組方向}&\emph{字体}&\emph{フォント名}&\bfseries``10\,pt''&\bfseries``7\,pt''&\bfseries``5\,pt''\\\midrule
891 \smash{\raisebox{-0.7\zh}{横組}}&
892 明朝体&原ノ味明朝Regular&\cs{tenmin}&\cs{sevenmin}&\cs{fivemin}\\
893 &\textgt{ゴシック体}&原ノ味角ゴシックMedium&\cs{tengt} &\cs{sevengt} &\cs{fivegt}\\
894 \midrule
895 \smash{\raisebox{-0.7\zh}{縦組}}&
896 明朝体&原ノ味明朝Regular&\cs{tentmin}&\cs{seventmin}&\cs{fivetmin}\\
897 &\textgt{ゴシック体}&原ノ味角ゴシックMedium&\cs{tentgt} &\cs{seventgt} &\cs{fivetgt}\\
898 \bottomrule
899 \end{tabular}
900 \end{center}
901 %</ja>
902 \begin{itemize}
903 %<*en>
904 \item The ``default'' Japanese fonts (and~JFMs for them) can be 
905   modified by defining \cs{ltj@stdmcfont} etc.\ \emph{before}
906   one inputs \texttt{luatexja.sty} (Subsection~\ref{ssec:cfg}).
907 %</en>
908 %<*ja>
909 \item 標準和文フォントやJFMを原ノ味フォントから別のものに置き換えるには,
910   \cs{ltj@stdmcfont}等を\texttt{luatexja.sty}読み込み\emph{前}に定義すればよい.
911   \ref{ssec:cfg}節を参照.
912 %</ja>
913
914 %<*en>
915 \item A character in an alphabetic font is generally smaller than a
916       Japanese font in the same size. So actual size specification of
917       these Japanese fonts is in fact smaller than that of alphabetic
918       fonts, namely scaled by 0.962216.
919 %</en>
920 %<*ja>
921 \item 欧文フォントの文字は和文フォントの文字よりも,同じ文字サイズでも
922       一般に小さくデザインされている.そこで,標準ではこれらの和文フォントの実際のサイズは指定された値よりも
923       小さくなるように設定されており,具体的には指定の0.962216倍にスケールされる.
924       この0.962216という数値も,\pTeX におけるスケーリングを踏襲した値である.
925 %</ja>
926 \end{itemize}
927
928 %<*en>
929 \item The amount of glue that are inserted between a \textbf{JAchar} and
930       an \textbf{ALchar} (the parameter \Param{xkanjiskip}) is set to
931 %</en>
932 %<*ja>
933 \item \textbf{JAchar}と\textbf{ALchar}の間に入るグルー(\Param{xkanjiskip})の
934       量は次のように設定されている:
935 %</ja>
936 \[
937  (0.25\cdot 0.962216\cdot 10\,\mathrm{pt})^{+1\,\text{pt}}_{-1\,\text{pt}}
938  = 2.40554\,\mathrm{pt}^{+1\,\text{pt}}_{-1\,\text{pt}}.
939 \]
940 \end{itemize}
941
942 %<en>\subsection{Using in \LaTeX}
943 %<ja>\subsection{\LaTeX で使う}
944 \label{ssec:ltx}
945
946 %<*en>
947 Using in \LaTeXe\ is basically same. To set up the minimal environment
948 for Japanese, you only have to load \texttt{luatexja.sty}:
949 %</en>
950 %<*ja>
951 \LaTeXe を用いる場合も基本的には同じである.日本語組版のための最低限の環境を
952 設定するためには,\texttt{luatexja.sty}を読み込むだけでよい:
953 %</ja>
954 \begin{lstlisting}
955 \usepackage{luatexja}
956 \end{lstlisting}
957 %<*en>
958 It also does minimal settings (counterparts in \pLaTeX\ are \texttt{%
959 plfonts.dtx} and \texttt{pldefs.ltx}).
960 %</en>
961 %<*ja>
962 これで\pLaTeX の\texttt{plfonts.dtx}と\texttt{pldefs.ltx}に相当する最低限の設定が
963 なされる.
964 %</ja>
965
966 \begin{itemize}
967 %<*en>
968 \item Font encodings for Japanese fonts are \texttt{JY3}~(for horizontal direction) and
969 \texttt{JT3}~(for vertical direction).
970 %</en>
971 %<*ja>
972 \item 和文フォントのエンコーディングとしては,横組用には \texttt{JY3},縦組用には\
973 \texttt{JT3}が用いられる.
974 %</ja>
975
976 %<*en>
977 \item Traditionally, Japanese documents use only two families: \emph{mincho}~(明朝体) and
978  \emph{gothic}~(\textgt{ゴシック体}). \emph{mincho} is used in the main text, while \emph{gothic}
979       is used in the headings or for emphasis.
980 \begin{center}\small
981 \begin{tabular}{lllc}
982 \toprule
983 \textbf{classification}&\textbf{commands}&&\textbf{family}\\\midrule
984 \emph{mincho} (明朝体)&\verb+\textmc{...}+&\verb+{\mcfamily ...}+&\cs{mcdefault}\\
985 \emph{gothic} (\textgt{ゴシック体})&\verb+\textgt{...}+&\verb+{\gtfamily ...}+&\cs{gtdefault}\\
986 (Japanese counterpart for typewriter font)&---&---&\cs{jttdefault}\\
987 \bottomrule
988 \end{tabular}
989 \end{center}
990   Here \cs{jttdefault} specifies the Japanese font family in \cs{verb}~or~\texttt{verbatim}
991   environment, and its default value is \cs{mcdefault} (mincho family).%
992   \footnote{%
993         When \Pkg{ltjsclasses} classes are used, or
994         \Pkg{luatexja-fontspec} (or \Pkg{luatexja-preset}) is loaded with \texttt{match} option,
995         \cs{ttfamily} changes the current Japanese font amily to \cs{jttdefault}.
996         These classes and packages also redefine \cs{jttdefault} to
997         \cs{gtdefault} (\emph{gothic}~family).
998   } \LuaTeX-ja does not define commands to only switch current Japanese font family to
999   \cs{jttdefault}.
1000
1001 \item
1002 By default, the following fonts are used for these two families.
1003 \begin{center}\small
1004 \begin{tabular}{lllll}
1005 \toprule
1006 \textbf{classification}&\textbf{family}&\textbf{\cs{mdseries}}&\textbf{\cs{bfseries}}&\textbf{scale}\\\midrule
1007 \emph{mincho} (明朝体)&\texttt{mc}&HaranoAjiMincho-Regular&HaranoAjiGothic-Medium&0.962216\\
1008 \emph{gothic} (\textgt{ゴシック体})&\texttt{gt}&HaranoAjiGothic-Medium&HaranoAjiGothic-Medium&0.962216\\
1009 \bottomrule
1010 \end{tabular}
1011 \end{center}
1012 \item Note that the bold series (series \texttt{bx}~or~\texttt{b}) in both family
1013      are same as the medium series of gothic family.
1014      There is no italic nor slanted shape for these \texttt{mc}~and~\texttt{gt}.
1015 %</en>
1016 %<*ja>
1017 \item \pLaTeX と同様に,標準では「明朝体」「ゴシック体」の2種類を用いる.
1018 \begin{center}\small
1019 \begin{tabular}{llll}
1020 \toprule
1021 \emph{字体}&\emph{命令}&&\emph{ファミリ名}\\\midrule
1022 明朝体&\verb+\textmc{...}+&\verb+{\mcfamily ...}+&\cs{mcdefault}\\
1023 \textgt{ゴシック体}&\verb+\textgt{...}+&\verb+{\gtfamily ...}+&\cs{gtdefault}\\
1024 (タイプライタ体と合わせる和文)&---&&\cs{jttdefault}\\
1025 \bottomrule
1026 \end{tabular}
1027 \end{center}
1028   \cs{jttdefault}は\cs{verb}や\texttt{verbatim}環境中の和文文字に使われる和文フォントファミリであり,
1029   標準値は\cs{mcdefault},つまり明朝体である
1030   \footnote{%
1031         \Pkg{ltjsclasses}を使用したり,また\Pkg{luatexja-fontspec}や\Pkg{luatexja-preset}パッケージを
1032         \texttt{match}オプションを指定して読み込んだときは,単なる\cs{ttfamily}によっても和文フォントが
1033         \cs{jttdefault}に変更される.また,これらのクラスファイルやパッケージは
1034         \cs{jttdefault}を \cs{gtdefault}(ゴシック体)に再定義する.
1035   }.和文フォントファミリ(のみ)を\cs{jttdefault}に切り替える命令は準備していない.
1036
1037 \item 標準では,次のフォントが用いられる:
1038 \begin{center}\small
1039 \begin{tabular}{lllll}
1040 \toprule
1041 \emph{字体}&\emph{ファミリ}&\textbf{\cs{mdseries}}&\textbf{\cs{bfseries}}&\emph{スケール}\\\midrule
1042 明朝体&\texttt{mc}&原ノ味明朝Regular&原ノ味角ゴシックMedium&0.962216\\
1043 \textgt{ゴシック体}&\texttt{gt}&原ノ味角ゴシックMedium&原ノ味角ゴシックMedium&0.962216\\
1044 \bottomrule
1045 \end{tabular}
1046 \end{center}
1047
1048 明朝・ゴシックどちらのファミリにおいても,太字(\cs{bfseries})のフォントは
1049 ゴシック体中字(\cs{gtfamily}\cs{mdseries})で使われるフォントと同じであることに注意.
1050 また,どちらのファミリでもイタリック体・スラント体は定義されない.
1051
1052  \item 和文の太字を表すシリーズ名は,(元々のComputer Modernが
1053   太字に\texttt{bx}を用いていたことから)伝統的に\texttt{bx}~(Bold Extended)が使われてきた.
1054   しかし,太字にシリーズ\texttt{b}を使うフォントも増えてきたため,
1055   バージョン20180616.0以降では和文の太字として\texttt{bx},~\texttt{b}の両方を扱えるようにした.
1056 %</ja>
1057
1058 %<*en>
1059  \item From version~20181102.0, one can specifies \texttt{disablejfam} option at
1060   loading \LuaTeX-ja. This option prevents loading a patch for \LaTeX, which are
1061   needed to support Japanese characters in math mode.
1062
1063   Without \texttt{disablejfam} option, one can typeset Japanese characters in
1064   math mode as~\verb+$あ$+ (see Page~\pageref{para:jachar_in_math}) as before.
1065   Japanese characters in math mode are typeset by the font family \texttt{mc}.
1066 %</en>
1067 %<*ja>
1068  \item バージョン20181102.0以降では,\texttt{disablejfam}オプションを\LuaTeX-ja読み込み時に
1069   指定できるようになった.このオプションは,数式モード中に直に和文文字を書けるようにするための
1070   \LaTeX へのパッチを読み込まない.
1071
1072   \texttt{disablejfam}のない状況では,以前と同様に和文文字を数式モード中に
1073   直に書くことができる(但し\pageref{para:jachar_in_math}ページの記述も参照).
1074   その際には明朝体(\texttt{mc})で出力される.
1075 %</ja>
1076
1077 %<*en>
1078 \item If you use the \Pkg{beamer} class with the default font theme (which uses sans serif
1079       fonts) and with \LuaTeX-ja, you might want to change default Japanese fonts to
1080       the gothic family. The following line  changes  the default Japanese font family
1081       to it:
1082 %</en>
1083 %<*ja>
1084 \item \Pkg{beamer}クラスを既定のフォント設定で使う場合,既定欧文フォントがサンセリフなの
1085       で,既定和文フォントもゴシック体にしたいと思うかもしれない.その場合はプリアンブルに
1086 次を書けばよい:
1087 %</ja>
1088 \begin{lstlisting}
1089  \renewcommand{\kanjifamilydefault}{\gtdefault}
1090 \end{lstlisting}
1091
1092 %<*ja>
1093 \item \pLaTeX と同様に,\texttt{mc},~\texttt{gt}両ファミリには「従属欧文」書体が定義されている.
1094   これらは\cs{userelfont}を\cs{selectfont}(や,その他の「実際に」
1095   フォントを変更する命令)の前で実行することにより使うことができる.
1096
1097   \pLaTeX では標準の欧文フォントはOT1エンコーディングのComputer Modern Roman (\texttt{cmr})%
1098   であったが,2017年以降の\LuaLaTeX ではTUエンコーディングのLatin Modern Roman (\texttt{lmr})%
1099   に変更されている.そのため,前段落で述べた「従属欧文」も,Latin Modern Romanに設定している.
1100 %</ja>
1101
1102 \end{itemize}
1103
1104 %<*en>
1105 However, above settings are not sufficient for Japanese-based
1106 documents. To typeset Japanese-based documents, you are better to use
1107 class files other than \texttt{article.cls}, \texttt{book.cls}, and so on.  At
1108 the present, \LuaTeX-ja has the counterparts of \Pkg{jclasses} (standard
1109 classes in \pLaTeX) and \Pkg{jsclasses} (classes by Haruhiko
1110 Okumura), namely, \Pkg{ltjclasses}\footnote{%
1111   \texttt{ltjarticle.cls},~\texttt{ltjbook.cls}, \texttt{ltjreport.cls},
1112   \texttt{ltjtarticle.cls}, \texttt{ltjtbook.cls}, \texttt{ltjtreport.cls}.
1113   The latter \texttt{ltjt*.cls} are for vertically written Japanese documents.
1114 } and \Pkg{ltjsclasses}\footnote{%
1115   \texttt{ltjsarticle.cls},~\texttt{ltjsbook.cls}, \texttt{ltjsreport.cls},~\texttt{ltjskiyou.cls}.}.
1116
1117 Original \Pkg{jsclasses} use \cs{mag}~primitive to set the main document font size.
1118 However, \LuaTeX\ does not support \cs{mag} in PDF~output,
1119 so \Pkg{ltjsclasses} uses the \texttt{nomag*} option\footnote{Same effect as 
1120   the \Pkg{BXjscls} classes (by Takayuki Yato) and \Pkg{jsclasses}.
1121   However, these classes uses only \TeX\ code, but \Pkg{ltjsclasses} uses Lua code.}
1122  by default to set the main font size. If this causes some unexpected behavior, specify
1123 \texttt{nomag} option in \cs{documentclass}.
1124 %</en>
1125 %<*ja>
1126 しかしながら,上記の設定は日本語の文書にとって十分とは言えない.
1127 日本語文書を組版するためには,\texttt{article.cls}, \texttt{book.cls}といった
1128 欧文用のクラスファイルではなく,和文用のクラスファイルを用いた方がよい.
1129 現時点では,\Pkg{jclasses}(\pLaTeX の標準クラス)と\Pkg{jsclasses}%
1130 (奥村晴彦氏による「\pLaTeXe 新ドキュメントクラス」)に対応するものとして,
1131 \Pkg{ltjclasses}\footnote{%
1132   横組用は \texttt{ltjarticle.cls},~\texttt{ltjbook.cls}, \texttt{ltjreport.cls} であり,
1133   縦組用は \texttt{ltjtarticle.cls}, \texttt{ltjtbook.cls}, \texttt{ltjtreport.cls} である.
1134 },
1135 \Pkg{ltjsclasses}\footnote{%
1136   \texttt{ltjsarticle.cls},~\texttt{ltjsbook.cls}, \texttt{ltjsreport.cls},~\texttt{ltjskiyou.cls}.}%
1137 がそれぞれ\LuaTeX-ja標準で用意されている.
1138
1139 元々の\Pkg{jsclasses}では本文のフォントサイズを設定するのに\cs{mag}プリミティブが使われていたが,
1140 \LuaTeX ではPDF出力時の\cs{mag}のサポートが廃止された.
1141 そのため,\Pkg{ltjsclasses}では\texttt{nomag*}オプション
1142 \footnote{\Pkg{jsclasses}や,八登崇之氏による\Pkg{BXjscls}クラスにおける同名のオプションと
1143   同じ.上記クラスは\TeX コードのみで実装しているが,\Pkg{ltjsclasses}ではLuaコードも用いている.}が標準で
1144 有効になっており,これを使って本文フォントサイズの設定を行っている.
1145 しかし,この\texttt{nomag*}オプションでは(バージョン20180121.0より前で\Pkg{unicode-math}パッケージ使用時に起きたように)予想外の意図しない現象に遭遇する危険がある.そのような場合は
1146 \cs{documentclass}において\texttt{nomag}オプションを指定してほしい.
1147 %</ja>
1148
1149 %<*ja>
1150 \paragraph{脚注とボトムフロートの出力順序}
1151 オリジナルの\LaTeX では脚注はボトムフロートの上に出力され,また\cs{raggedbottom}命令でページの高さが不揃いであることを許した場合には
1152 脚注の下端の垂直位置もページに応じて変わるようになっている.
1153 一方,日本語の組版では脚注はボトムフロートの下に来るのが一般的であるので,
1154 \pLaTeX ではそのように変更されており,
1155 さらに\cs{raggedbottom}命令を実行した後でも脚注は常にページの下端に固定されるようになっている.
1156
1157 \LuaTeX-jaでは「欧文クラスの中にちょっとだけ日本語を入れる」という利用も考慮し,
1158 脚注とボトムフロートの順序,及び\cs{raggedbottom}時の脚注の垂直位置は\LaTeX 通りとした.
1159 これらを制御するには以下の手段がある:
1160 \begin{itemize}
1161  \item \pLaTeX のように,脚注をボトムフロートの下に組む場合には
1162   \Pkg{stfloats}パッケージを利用して
1163   \begin{lstlisting}
1164     \usepackage{stfloats}\fnbelowfloat
1165   \end{lstlisting}
1166   とする.この状況から「脚注をボトムフロートの上に組む」という\LaTeX の標準の挙動に戻したければ,
1167   \Pkg{stfloats}パッケージの\cs{fnunderfloat}命令を使用する.
1168   \item \cs{raggedbottom}時の脚注の垂直位置は,\cs{iffnfixbottom}という真偽値で制御する.
1169   \begin{description}
1170     \item[偽(\cs{fnfixbottomfalse})の場合] \LaTeX 標準と同じく,本文と脚注の間の空白は\cs{skip}\cs{footins}のみ.
1171     従って脚注の垂直位置はページにより変動する.
1172     \item[真(\cs{fnfixbottomtrue})の場合] \pLaTeX や\Pkg{footmisc}パッケージを\texttt{bottom}オプションで
1173     読み込んだ場合のように,脚注は常にページの下端に固定される.
1174   \end{description}
1175 \item ただし,\LuaTeX-jaが提供する「互換クラス」(\Pkg{ltjclasses}, \Pkg{ltjsclasses})では,
1176   \pLaTeX と合わせるために以下のようにしている:
1177   \begin{itemize}
1178     \item \cs{fnfixbottomtrue}が自動的に実行される
1179     \item \Pkg{stfloats}パッケージが\LuaTeX から参照できる場所にあった場合は
1180     自動的に読み込み,\cs{fnbelowfloat}を実行する.
1181   \end{itemize}
1182 \end{itemize}
1183 なお,\Pkg{stfloats}パッケージを使う代わりに,
1184 \Pkg{footmisc}パッケージを \texttt{bottom}オプションを指定して読み込む
1185 という「解決法」もある.
1186 %</ja>
1187 %%% ↑は英訳しない
1188
1189 %<*en>
1190 \paragraph{\Pkg{geometry} package and classes for vertical writing}
1191 It is well-known that the \Pkg{geometry} package produces the following error, when classes for
1192 vertical writing is used:
1193 %</en>
1194 %<*ja>
1195 \paragraph{縦組での\Pkg{geometry}パッケージ}
1196 \pLaTeX の縦組用標準クラスファイルでは\Pkg{geometry}パッケージを利用することは出来ず,
1197 %</ja>
1198 \begin{lstlisting}
1199 ! Incompatible direction list can't be unboxed.
1200 \@begindvi ->\unvbox \@begindvibox
1201                                    \global \let \@begindvi \@empty
1202 \end{lstlisting}
1203 %<*en>
1204 Now, \LuaTeX-ja automatically applies the patch \Pkg{lltjp-geometry} to the
1205 \Pkg{geometry} package, when the direction of the document is \emph{tate} (vertical
1206 writing).
1207 This patch \Pkg{lltjp-geometry} also can be used in \pLaTeX; for the detail, please refer
1208 \url{lltjp-geometry.pdf}~(Japanese).
1209 %</en>
1210 %<*ja>
1211 というようなエラーが発生することが知られている.
1212 \LuaTeX-jaでは, \texttt{ltjtarticle.cls} といった縦組クラスの下でも
1213 \Pkg{geometry}パッケージが利用できるようにパッチ\Pkg{lltjp-geometry}パッケージを自動的に当てている.
1214
1215 なお,\Pkg{lltjp-geometry}パッケージは\pTeX 系列でも明示的に読み込むことによって
1216 使用可能である.詳細や注意事項は \url{lltjp-geometry.pdf} を参照のこと.
1217 %</ja>
1218
1219
1220 %<en>\section{Changing Fonts}
1221 %<ja>\section{フォントの変更}
1222
1223 \subsection{plain \TeX~and~\LaTeXe}
1224 \label{ssec:chgfnt}
1225
1226 \paragraph{plain \TeX}
1227 %<*en>
1228 To change Japanese fonts in plain \TeX, you must use the command
1229 \cs{jfont}~and~\cs{tfont}. So please see Subsection~\ref{ssec:jfont}.
1230 %</en>
1231 %<*ja>
1232 plain \TeX で和文フォントを変更するためには,
1233 \pTeX のように \cs{jfont} 命令や \cs{tfont} 命令を直接用いる.
1234 \ref{ssec:jfont}節を参照.
1235 %</ja>
1236
1237 \paragraph{\LaTeXe\ (NFSS2)}
1238 %<*en>
1239 For \LaTeXe, \LuaTeX-ja adopted most of the font selection system of \pLaTeXe\ (in \texttt{plfonts.dtx}).
1240 %</en>
1241 %<*ja>
1242 \LaTeX で用いる際には,\pLaTeXe\ (\texttt{plfonts.dtx})用のフォント選択機構の大部分を流用している.
1243 %</ja>
1244
1245 %<*en>
1246 \begin{center}\small
1247 \begin{tabular}{>{\bfseries}llllll}
1248 \toprule
1249 &\textbf{encoding}&\textbf{family}&\textbf{series}&\textbf{shape}&\textbf{selection}\\\midrule
1250 Alphabetic fonts
1251 &\cs{romanencoding}&\cs{romanfamily}&\cs{romanseries}&\cs{romanshape}
1252 &\cs{useroman}\\
1253 Japanese fonts
1254 &\cs{kanjiencoding}&\cs{kanjifamily}&\cs{kanjiseries}&\cs{kanjishape}
1255 &\cs{usekanji}\\
1256 both&---&--&\cs{fontseries}&\cs{fontshape}$^*$&---\\
1257 auto select&\cs{fontencoding}&\cs{fontfamily}&---&---&\cs{usefont}\\
1258 \bottomrule
1259 \end{tabular}
1260 \end{center}
1261 %</en>
1262 %<*ja>
1263 \begin{center}\small
1264 \begin{tabular}{llllll}
1265 \toprule
1266 &\emph{エンコーディング}&\emph{ファミリ}&\emph{シリーズ}&\emph{シェイプ}&\emph{選択}\\\midrule
1267 \emph{欧文}
1268 &\cs{romanencoding}&\cs{romanfamily}&\cs{romanseries}&\cs{romanshape}
1269 &\cs{useroman}\\
1270 \emph{和文}
1271 &\cs{kanjiencoding}&\cs{kanjifamily}&\cs{kanjiseries}&\cs{kanjishape}
1272 &\cs{usekanji}\\
1273 \emph{両方}&---&--&\cs{fontseries}&\cs{fontshape}$^*$&---\\
1274 \emph{自動選択}&\cs{fontencoding}&\cs{fontfamily}&---&---&\cs{usefont}\\
1275 \bottomrule
1276 \end{tabular}
1277 \end{center}
1278 %</ja>
1279
1280 \begin{itemize}
1281 %<*en>
1282 \item \cs{fontfamily}, \cs{fontseries}, and~\cs{fontshape} try to change
1283       attributes of Japanese fonts, as well as those of alphabetic fonts.
1284       Of course, \cs{selectfont} is needed to select current text fonts.
1285
1286       Note that \cs{fontshape} always changes current alphabetic font shape,
1287       but it does \emph{not} change current Japanese font shape if
1288       the target shape is unavailable for current Japanese encoding/family/series.
1289       For the detail, see Subsection~\ref{ssec:nfsspat}.
1290 %</en>
1291 %<*ja>
1292 \item \cs{fontfamily}, \cs{fontseries}, \cs{fontshape} は欧文・和文フォント両方の属性を変更しようとする.
1293       もちろん,それらを実際に反映させるには手動で \cs{selectfont} を実行する必要がある.
1294
1295       なお,\cs{fontshape\{\meta{shape}\}}は常に欧文フォントのシェイプを設定するが,
1296       もしも現在の和文フォントファミリ・シリーズで要求されたシェイプが利用不能だった場合には,和文フォントのシェイプは変更しない.
1297       詳細は\ref{ssec:nfsspat}節を参照すること.
1298 %</ja>
1299
1300 %<*en>
1301 \item \verb+\fontencoding{+\meta{encoding}\verb+}+ changes the encoding of alphabetic fonts
1302       or Japanese fonts depending on the argument. For example,
1303       \verb+\fontencoding{JY3}+ changes the encoding of Japanese fonts to
1304       \texttt{JY3}, and \verb+\fontencoding{T1}+ changes the encoding of
1305       alphabetic fonts to \texttt{T1}.
1306       \cs{fontfamily} also changes the current Japanese font family,
1307       the current alphabetic font family, \emph{or both}.
1308       For the detail, see Subsection~\ref{ssec:nfsspat}.
1309 %</en>
1310 %<*ja>
1311 \item  ここで,\cs{fontencoding\{\meta{encoding}\}}は,引数により和文側か欧文
1312       側かのどちらかのエンコーディングを変更する.例えば,
1313       \verb+\fontencoding{JY3}+ は和文フォントのエンコーディングを
1314       \texttt{JY3}に変更し,\verb+\fontencoding{T1}+ は欧文フォント側を
1315       \texttt{T1}へと変更する.\cs{fontfamily} も引数により和文側,欧文
1316       側,\emph{あるいは両方}のフォントファミリを変更する.詳細は
1317       \ref{ssec:nfsspat}節を参照すること.
1318 %</ja>
1319
1320 %<*en>
1321 \item For defining a Japanese font family, use
1322       \cs{DeclareKanjiFamily} instead of
1323       \cs{DeclareFontFamily}. (In previous version of \LuaTeX-ja,
1324       using \cs{DeclareFontFamily} didn't cause any problem. But this no longer applies
1325       the current version.)
1326 \item Defining a Japanese font shape can be done by usual \cs{DeclareFontShape}:
1327 %</en>
1328 %<*ja>
1329 \item 和文フォントファミリの定義には \cs{DeclareFontFamily} の
1330       代わりに \cs{DeclareKanjiFamily} を用いる.以前の
1331       実装では \cs{DeclareFontFamily} を用いても問題は生じなかったが,現在の実装では
1332       そうはいかない.
1333 \item 和文フォントのシェイプを定義するには,通常の \cs{DeclareFontShape} を使えば良い:
1334 %</ja>
1335 \begin{lstlisting}
1336 \DeclareFontShape{JY3}{mc}{b}{n}{<-> s*HaranoAjiMincho--Bold:jfm=ujis;-kern}{}
1337     % Harano Aji Mincho Bold
1338 \end{lstlisting}
1339 %<*ja>
1340 仮名書体を使う場合など,複数の和文フォントを組み合わせて使いたい場合は
1341 \ref{ssec:altfont}節の \cs{ltjdeclarealtfont} と,その\LaTeX 版の\
1342 \cs{DeclareAlternateKanjiFont}(\ref{ssec:nfsspat}節)を参照せよ.
1343 %</ja>
1344
1345 \end{itemize}
1346
1347 %<*en>
1348 \paragraph{Japanese characters in math mode}
1349 \label{para:jachar_in_math}
1350
1351 Since \pTeX\ supports Japanese characters in math mode, there are
1352 sources like the following:
1353 %</en>
1354 %<*ja>
1355 \paragraph{数式モード中の和文文字}
1356 \label{para:jachar_in_math}
1357   
1358 \pTeX では,特に何もしないでも数式中に和文文字を記述することができた.そのため,
1359 以下のようなソースが見られた:
1360 %</ja>
1361
1362 \begin{LTXexample}
1363 $f_{高温}$~($f_{\text{high temperature}}$).
1364 \[ y=(x-1)^2+2\quad よって\quad y>0 \]
1365 $5\in 素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
1366 \end{LTXexample}
1367 %<*en>
1368 We (the project members of \LuaTeX-ja) think that using
1369 Japanese characters in math mode are allowed if and only if these are used as identifiers.
1370 In this point of view,
1371 %</en>
1372 %<*ja>
1373 \LuaTeX-jaプロジェクトでは,数式モード中での和文文字はそれらが識別子として用いられる
1374 ときのみ許されると考えている.
1375 この観点から,
1376 %</ja>
1377
1378 \begin{itemize}
1379 %<*en>
1380 \item The lines 1~and~2 above are not correct, since ``高温'' in above is used as a textual label, and
1381 ``よって'' is used as a conjunction.
1382 %</en>
1383 %<*ja>
1384 \item 上記数式のうち1, 2行目は正しくない.なぜならば「高温」が意味のあるラベルと
1385       して,「よって」が接続詞として用いられているからである.
1386 %</ja>
1387 %<en>\item However, the line~3 is correct, since ``素'' is used as an identifier.
1388 %<ja>\item しかしながら,3行目は「素」が単なる識別子として用いられているので正しい.
1389 \end{itemize}
1390 %<en>Hence, in our opinion, the above input should be corrected as:
1391 %<ja>したがって,\LuaTeX-jaプロジェクトの意見としては,上記の入力は次のように直されるべきである:
1392 \begin{LTXexample}
1393 $f_{\text{高温}}$~%
1394 ($f_{\text{high temperature}}$).
1395 \[ y=(x-1)^2+2\quad
1396   \mathrel{\mbox{よって}}\quad y>0 \]
1397 $5\in 素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
1398 \end{LTXexample}
1399
1400 %<*en>
1401 We also believe that using Japanese characters as identifiers is rare,
1402 hence we don't describe how to change Japanese fonts in math mode in
1403 this chapter. For the method, please see Subsection~\ref{ssec:math}.
1404
1405 {\emshape When \LuaTeX-ja is loaded with \texttt{disablejfam}~option,
1406   one cannot write Japanese characters in math mode as~\verb+$素$+.
1407   At that case, one have to use \cs{mbox} (or~\cs{text} in the \Pkg{amsmath} package).
1408 }
1409 %</en>
1410 %<*ja>
1411 なお\LuaTeX-jaプロジェクトでは,和文文字が識別子として用いられることはほとんどない
1412 と考えており,したがってこの節では数式モード中の和文フォントを変更する方法については
1413 記述しない.この方法については\ref{ssec:math}節を参照のこと.
1414
1415 {\gtfamily\bfseries
1416   既に記述した通り,\texttt{disablejfam}オプションを指定して\LuaTeX-jaを読み込んだ場合は,
1417   \verb+$素$+ のように直接和文文字を数式モード中に記述することはできなくなる.
1418   \cs{mbox},あるいは\Pkg{amsmath}パッケージの提供する\cs{text}命令などを使うことになる.
1419 }
1420 %</ja>
1421
1422
1423
1424 %<en>\subsection{\Pkg{luatexja-fontspec} package}
1425 %<ja>\subsection{\Pkg{luatexja-fontspec}パッケージ}
1426 \label{ssec:fontspec}
1427 %<*en>
1428 To use the functionality of the \Pkg{fontspec} package to Japanese fonts,
1429 it is needed to load the \Pkg{luatexja-fontspec} package in the preamble, as follows:
1430 \begin{quote}
1431 \ttfamily \textbackslash usepackage[\meta{options}]\{luatexja-fontspec\}
1432 \end{quote}
1433 This \Pkg{luatexja-fontspec} package
1434 automatically loads \Pkg{luatexja} and \Pkg{fontspec}
1435 packages, if needed.
1436 %</en>
1437 %<*ja>
1438 \Pkg{fontspec}パッケージは,\LuaTeX・\XeTeX において
1439 TrueType・OpenTypeフォントを容易に扱うためのパッケージであり,このパッケージを読み込んでお
1440 けばUnicodeによる各種記号の直接入力もできるようになる.
1441 \LuaTeX-jaでは和文と欧文を区別しているため,\Pkg{fontspec}パッケージの機能は欧文フォントに
1442 対してのみ有効なものとなっている.
1443
1444 \LuaTeX-ja上において,\Pkg{fontspec}パッケージと同様の機能を和文フォントに対しても用いる場
1445 合は\Pkg{luatexja-fontspec}パッケージを読み込む:
1446 \begin{quote}
1447 \ttfamily \textbackslash usepackage[\meta{options}]\{luatexja-fontspec\}
1448 \end{quote}
1449 このパッケージは自動で\Pkg{luatexja}パッケージと\Pkg{fontspec}パッケージを読み込む.
1450 %</ja>
1451
1452 %<*en>
1453 In the \Pkg{luatexja-fontspec} package, several commands are defined as
1454 counterparts of original commands in the \Pkg{fontspec} package
1455 (see \autoref{tab:ltj_fntspc}):
1456 %</en>
1457 %<*ja>
1458 \Pkg{luatexja-fontspec}パッケージでは,\autoref{tab:ltj_fntspc}の
1459 「和文」行に示した命令を\Pkg{fontspec}パッケージの元のコマンド(「欧文」行)
1460 に対応するものとして定義している:
1461 %</ja>
1462 %<*en>
1463 \begin{table}
1464 \caption{Commands of \Pkg{luatexja-fontspec}}\label{tab:ltj_fntspc}
1465 \medskip
1466 {\centering\small
1467 \begin{tabular}{>{\bfseries}lllll}
1468 \toprule
1469 Japanese fonts
1470 &\cs{jfontspec}&\cs{setmainjfont}&\cs{setsansjfont}&\cs{setmonojfont}\\
1471 Alphabetic fonts
1472 &\cs{fontspec}&\cs{setmainfont}&\cs{setsansfont}&\cs{setmonofont}\\
1473 \midrule
1474 Japanese fonts
1475 &\cs{newjfontfamily}&\cs{renewjfontfamily}&\cs{setjfontfamily}\\
1476 Alphabetic fonts
1477 &\cs{newfontfamily}&\cs{renewfontfamily}&\cs{setfontfamily}\\
1478 \midrule
1479 Japanese fonts
1480 &\cs{newjfontface}&\cs{defaultjfontfeatures}&\cs{addjfontfeatures}\\
1481 Alphabetic fonts
1482 &\cs{newfontface}&\cs{defaultfontfeatures}&\cs{addfontfeatures}\\
1483 \bottomrule
1484 \end{tabular}\par}
1485 \end{table}
1486 %</en>
1487 %<*ja>
1488 \begin{table}
1489 \caption{\Pkg{luatexja-fontspec}で定義される命令}\label{tab:ltj_fntspc}
1490 \medskip
1491 {\centering\small
1492 \begin{tabular}{lllll}
1493 \toprule
1494 \emph{和文}
1495 &\cs{jfontspec}&\cs{setmainjfont}&\cs{setsansjfont}&\cs{setmonojfont}\\
1496 \emph{欧文}
1497 &\cs{fontspec}&\cs{setmainfont}&\cs{setsansfont}&\cs{setmonofont}\\
1498 \midrule
1499 \emph{和文}
1500 &\cs{newjfontfamily}&\cs{renewjfontfamily}&\cs{setjfontfamily}\\
1501 \emph{欧文}
1502 &\cs{newfontfamily}&\cs{renewfontfamily}&\cs{setfontfamily}\\
1503 \midrule
1504 \emph{和文}
1505 &\cs{newjfontface}&\cs{defaultjfontfeatures}&\cs{addjfontfeatures}\\
1506 \emph{欧文}
1507 &\cs{newfontface}&\cs{defaultfontfeatures}&\cs{addfontfeatures}\\
1508 \bottomrule
1509 \end{tabular}\par}
1510 \end{table}
1511 %</ja>
1512
1513 %<en> The package option of \Pkg{luatexja-fontspec} are the followings:
1514 %<ja> \Pkg{luatexja-fontspec} パッケージのオプションは以下の通りである:
1515 \begin{cslist}
1516  \item[match]
1517 %<*en>
1518 If this option is specified, usual family-changing commands such as
1519 \cs{rmfamily},~\cs{textrm}, \cs{sffamily},~\dots\ also change Japanese font family.
1520 %</en>
1521
1522 %<*ja>
1523 このオプションが指定されると,「\pLaTeXe 新ドキュメントクラス」のように\
1524 \cs{rmfamily}, \verb+\textrm{...}+, \cs{sffamily} 等が
1525 欧文フォントだけでなく和文フォントも変更するようになる.
1526 %</ja>
1527
1528  \item[pass=\meta{options}]
1529 %<en> \emph{(Obsoleted)}\ Specify options \meta{options} which will be passed to the \Pkg{fontspec} package.
1530 %<ja> \Pkg{fontspec} パッケージに渡すオプション \meta{options} を指定する.本オプションは時代遅れである.
1531
1532 \item[scale=\meta{float}]
1533 %<*en>
1534 Override the ratio of the font size of Japanese fonts to that of alphabetic fonts.
1535 The default value is determined as follows:
1536   \begin{itemize}
1537     \item The value of \cs{Cjascale} is used, if this control sequence is already defined.
1538     \item It is calculated automatically from the current Japanese font at the loading of the
1539     package, if \cs{Cjascale} is not defined.
1540   \end{itemize}
1541 \cs{Cjascale} is defined in \Pkg{ltjclasses} and \Pkg{ltjsclasses}.
1542 %</en>
1543 %<*ja>
1544 欧文に対する和文の比率を手動で上書きするときに使用する.
1545 標準では
1546 \begin{itemize}
1547   \item \cs{Cjascale}が定義されている場合
1548   \footnote{\LuaTeX-ja が用意しているクラスファイル(\Pkg{ltjclasses},~\Pkg{ltjsclasses})を
1549   使う場合はこちらに当てはまる.}は,それを用いる.
1550   \item \cs{Cjascale}が未定義の場合は,\Pkg{luatexja-fontspec}読み込み時の和文フォントから自動計算される.
1551 \end{itemize}
1552 %</ja>
1553 \end{cslist}
1554
1555 %<*en>
1556 All other options listed above are simply passed to the \Pkg{fontspec} package.
1557 This means that two lines below are equivalent, for example.
1558 %</en>
1559 %<*ja>
1560 上記にないオプションは全て \Pkg{fontspec} パッケージに渡される.
1561 例えば,下の2行は同じ意味になる:
1562 %</ja>
1563 \begin{lstlisting}
1564 \usepackage[no-math]{fontspec}\usepackage{luatexja-fontspec}
1565 \usepackage[no-math]{luatexja-fontspec}
1566 \end{lstlisting}
1567 %<*en>
1568 Note that kerning information in a font is not used
1569 (that is, \texttt{kern} feature is set off) by default in these seven (or~eight) commands.
1570 This is because of the compatibility with previous versions of \LuaTeX-ja
1571 (see \ref{para-kern}).
1572
1573 Below is an example of \cs{jfontspec}.
1574 %</en>
1575 %<*ja>
1576 これらの和文用のコマンドではフォント内のペアカーニング情報は標準では使用されない,
1577 言い換えれば \texttt{kern} featureは標準では無効化となっている.
1578 これは以前のバージョンの\LuaTeX-jaとの互換性のためである(\ref{para-kern}節を参照).
1579
1580 以下に\cs{jfontspec}の使用例を示す.
1581 %</ja>
1582
1583 \begin{LTXexample}[width=0.4\textwidth]
1584 \jfontspec[CJKShape=NLC]{HaranoAjiMincho-Regular}
1585 JIS~X~0213:2004→辻鯵\par
1586 \jfontspec[CJKShape=JIS1990]{HaranoAjiMincho-Regular}
1587 JIS~X~0208-1990→辻鯵\par
1588 \jfontspec[CJKShape=JIS1978]{HaranoAjiMincho-Regular}
1589 JIS~C~6226-1978→辻鯵
1590 \end{LTXexample}
1591
1592 %<en>\subsection{Presets of Japanese fonts}
1593 %<ja>\subsection{和文フォントのプリセット設定}
1594 \label{ssec:preset-abst}
1595
1596 %<*en>
1597 With \Pkg{luatexja-preset} package, 
1598 one use one of ``preset'' to simplify Japanese font setting.
1599 For details of package options, and those of each presets, please see Subsecion~\ref{ssec:preset}.
1600 The following presets are defined:
1601 %</en>
1602 %<*ja>
1603 よく使われている和文フォント設定を一行で指定できるようにしたのが
1604 \Pkg{luatexja-preset}パッケージである.オプションや各プリセットの詳細については
1605 \ref{ssec:preset}節を参照して欲しい.
1606 現時点では以下のプリセットが定義されている:
1607 %</ja>
1608 \begin{quote}
1609   \ttfamily
1610   \hyphenchar\font=-1 \exhyphenchar=-1
1611   haranoaji, hiragino-pro, hiragino-pron, ipa, ipa-hg, ipaex, ipaex-hg,
1612   kozuka-pr6, kozuka-pr6n, kozuka-pro, moga-mobo, moga-mobo-ex,
1613   bizud, morisawa-pr6n, morisawa-pro, ms, ms-hg, noembed, noto-otc, noto-otf, noto, noto-jp, 
1614   sourcehan, sourcehan-jp, ume, yu-osx, yu-win, yu-win10
1615 \end{quote}
1616
1617 %<ja> 例えば,本ドキュメントでは\Pkg{luatexja-preset}パッケージを
1618 %<en> For example, this document loads \Pkg{luatexja-preset} package by
1619 \begin{lstlisting}
1620 \usepackage[haranoaji]{luatexja-preset}
1621 \end{lstlisting}
1622 %<ja>として読み込み,原ノ味フォントを使うことを指定している.
1623 %<en> which means that Harano Aji fonts will be used in this document.
1624
1625
1626 %<*en>
1627 \subsection{\cs{CID}, \cs{UTF}, and macros in \Pkg{japanese-otf} package}
1628 Under \pLaTeX, \Pkg{japanese-otf} package (developed by Shuzaburo Saito) is
1629 used for typesetting characters which is in Adobe-Japan1-6 CID but not
1630 in JIS~X~0208. Since this package is widely used, \LuaTeX-ja
1631 supports some of functions in the \Pkg{japanese-otf} package,
1632 as an external package \Pkg{luatexja-otf}.
1633 %</en>
1634 %<*ja>
1635 \subsection{\cs{CID}, \cs{UTF}と\Pkg{otf}パッケージのマクロ}
1636 \pLaTeX では,JIS~X~0208にないAdobe-Japan1-6の文字を出力するために,
1637 齋藤修三郎氏による\Pkg{otf}パッケージが用いられていた.このパッケージは
1638 広く用いられているため,\LuaTeX-jaにおいても\Pkg{otf}パッケージの機能の
1639 一部を(\Pkg{luatexja-otf}という別のパッケージとして)実装した.
1640 %</ja>
1641
1642 \begin{LTXexample}[width=0.4\textwidth]
1643 森\UTF{9DD7}外と\CID{13966}田百\UTF{9592}とが
1644 \UTF{9AD9}島屋に\\
1645 \CID{7652}飾区の\CID{13706}野家,
1646 \CID{1481}城市,葛西駅,\\
1647 高崎と\CID{8705}\UTF{FA11},濱と\ajMayuHama\\
1648 \aj半角{カタカナ}\ajKakko3\ajMaruYobi{2}%
1649 \ajLig{令和}\ajLig{○問}\ajJIS
1650 \end{LTXexample}
1651
1652 %<*ja>
1653 \Pkg{otf}パッケージでは,それぞれ次のようなオプションが存在した:
1654 \begin{cslist}
1655 \item[deluxe] 明朝体・ゴシック体各3ウェイトと,丸ゴシック体を扱えるようになる.
1656 \item[expert] 仮名が横組・縦組専用のものに切り替わり,ルビ用仮名も
1657 \ \cs{rubyfamily}\ によって扱えるようになる.
1658 \item[bold] ゴシック体を標準で太いウェイトのものに設定する.
1659 \end{cslist}
1660 しかしこれらのオプションは\Pkg{luatexja-otf}パッケージには存在しない.
1661 \Pkg{otf}パッケージが文書中で使用する和文用TFMを自前の物に置き換えていたのに対し,
1662 \Pkg{luatexja-otf}パッケージでは,そのようなことは行わないからである.
1663
1664 これら3オプションについては,
1665 \Pkg{luatexja-preset} パッケージにプリセットを使う時に一緒に指定するか,
1666 あるいは対応する内容を\ref{ssec:chgfnt}節,\ref{ssec:nfsspat}節 (NFSS2) や
1667 \ref{ssec:fontspec}節 (\Pkg{fontspec}) の方法で手動で指定する必要がある.
1668 %</ja>
1669
1670 %<en>\section{Changing Internal Parameters}
1671 %<ja>\section{パラメータの変更}
1672
1673 %<*en>
1674 There are many internal parameters in \LuaTeX-ja. And due to the behavior of \LuaTeX,
1675 most of them are not stored as internal register of \TeX, but as an
1676 original storage system in \LuaTeX-ja. Hence, to assign or acquire those
1677 parameters, you have to use commands \cs{ltjsetparameter} and
1678 \cs{ltjgetparameter}.
1679 %</en>
1680 %<*ja>
1681 \LuaTeX-jaには多くのパラメータが存在する.そして\LuaTeX の仕様のために,
1682 その多くは\TeX のレジスタにではなく,\LuaTeX-ja独自の方法で保持されている.
1683 これらのパラメータを設定・取得するためには \cs{ltjsetparameter} と \cs{ltjgetparameter} を
1684 用いる.
1685 %</ja>
1686
1687 %<en>\subsection{Range of \textbf{JAchar}s}
1688 %<ja>\subsection{\textbf{JAchar}の範囲}
1689 \label{ssec:setrange}
1690
1691 %<*en>
1692 \LuaTeX-ja divides the Unicode codespace \texttt{U+0080}--\texttt{U+10FFFF}
1693 into \emph{character ranges},
1694 numbered 1 to 217. The grouping can be (globally) customized by \cs{ltjdefcharrange}.
1695 The next line adds whole characters in Supplementary Ideographic Plane
1696 and the character ``漢'' to the character range~100.
1697 %</en>
1698 %<*ja>
1699 \LuaTeX-jaは,Unicodeの \texttt{U+0080}--\texttt{U+10FFFF} の空間を
1700 1番から217番までの\emph{文字範囲}に分割している.
1701 区分けは \cs{ltjdefcharrange} を用いることで(グローバルに)変更することができ,
1702 例えば,次は追加漢字面(SIP)にある全ての文字と「漢」を「100番の文字範囲」に追加する.
1703 %</ja>
1704 \begin{lstlisting}
1705 \ltjdefcharrange{100}{"20000-"2FFFF,`漢}
1706 \end{lstlisting}
1707
1708 %<*en>
1709 A character can belong to only one character range.
1710 For example, whole SIP belong to the range~4 in the default setting of \LuaTeX-ja,
1711 and if one executes the above line, then SIP will belong to the range~100 and be
1712 removed from the range~4.
1713 %</en>
1714 %<*ja>
1715 各文字はただ一つの文字範囲に所属することができる.
1716 例えば,SIP内の文字は全て\LuaTeX-jaのデフォルトでは4番の文字範囲に
1717 属しているが,上記の指定を行えばSIP内の文字は100番に属すようになり,4番からは除かれる.
1718 %</ja>
1719
1720 %<*en>
1721 The distinction between \textbf{ALchar} and \textbf{JAchar} is performed by character ranges.
1722 This can be edited by setting the \textsf{jacharrange} parameter.
1723 For example, the code below is just the default setting of \LuaTeX-ja, and
1724 it sets
1725 \begin{itemize}
1726  \item a character which belongs character ranges 1,~4, 5, and~8 is \textbf{ALchar},
1727  \item a character which belongs character ranges 2,~3, 6, 7,~and~9 is \textbf{JAchar}.
1728 \end{itemize}
1729 %</en>
1730 %<*ja>
1731 \textbf{ALchar}と\textbf{JAchar}の区別は文字範囲ごとに行われる.
1732 これは\textsf{jacharrange}パラメータによって編集できる.
1733 例えば,以下は\LuaTeX-jaの初期設定であり,次の内容を設定している:
1734 \begin{itemize}
1735  \item 1番,4番,5番,8番の文字範囲に属する文字は\textbf{ALchar}.
1736  \item 2番,3番,6番,7番,9番の文字範囲に属する文字は\textbf{JAchar}.
1737 \end{itemize}
1738 %</ja>
1739 \begin{lstlisting}
1740 \ltjsetparameter{jacharrange={-1, +2, +3, -4, -5, +6, +7, -8, +9}}
1741 \end{lstlisting}
1742 %<*en>
1743 The argument to \textsf{jacharrange} parameter is a list of non-zero integer.
1744 Negative integer $-n$ in the list means that ``each character in the range~$n$ is an
1745 \textbf{ALchar}'',
1746 and positive integer $+n$ means that ``\dots\ is a \textbf{JAchar}''.
1747 %</en>
1748 %<*ja>
1749 \textsf{jacharrange}パラメータの引数は非零の整数のリストである.
1750 リスト中の負の整数$-n$は「文字範囲$n$に属する文字は\textbf{ALchar}として
1751 扱う」ことを意味し,正の整数$+n$は「\textbf{JAchar}として扱う」ことを意味する.
1752 %</ja>
1753
1754 %<*en>
1755 Note that characters \texttt{U+0000}--\texttt{U+007F} are always treated as an
1756 \textbf{ALchar} (this cannot be customized).
1757 %</en>
1758 %<*ja>
1759 なお,\texttt{U+0000}--\texttt{U+007F} は常に\textbf{ALchar}として扱われる(利用者が変更す
1760 ることは出来ない).
1761 %</ja>
1762
1763 %<*en>
1764 \paragraph{Default character ranges}
1765 \LuaTeX-ja predefines nine character ranges for convenience. They are
1766 determined from the following data:
1767 %</en>
1768 %<*ja>
1769 \paragraph{文字範囲の初期値}
1770 \LuaTeX-jaでは9つの文字範囲を予め定義しており,
1771 これらは以下のデータに基づいて決定している.
1772 %</ja>
1773 \begin{itemize}
1774 %<en>\item Blocks in Unicode~12.0.0.
1775 %<ja>\item Unicode~12.0のブロック.
1776 %<en>\item The \texttt{Adobe-Japan1-UCS2} mapping between a CID Adobe-Japan1- and Unicode.
1777 %<ja>\item Adobe-Japan1-7のCIDとUnicodeの間の対応表\texttt{Adobe-Japan1-UCS2}.
1778 %<en>\item The \Pkg{PXbase} bundle for \upTeX\ by Takayuki Yato.
1779 %<ja>\item 八登崇之氏による\upTeX 用の\Pkg{PXbase}バンドル.
1780 \end{itemize}
1781
1782 %<*en>
1783 Now we describe these nine ranges. The superscript ``J'' or ``A'' after the
1784 number shows whether each character in the range is treated as
1785 \textbf{JAchar}s or not by default. These settings are similar to the
1786 \texttt{prefercjk} settings defined in \texttt{PXbase} bundle.
1787 Any characters equal to or above \texttt{U+0080} which does not belong to
1788 these eight ranges belongs to the character range~217.
1789 %</en>
1790 %<*ja>
1791 以下ではこれら9つの文字範囲について記述する.添字のアルファベット「J」「A」
1792 は,その文字範囲内の文字が\textbf{JAchar}か\textbf{ALchar}かを表している.これらの初期設定は
1793 \texttt{PXbase}バンドルで定義されている\texttt{prefercjk}と類似のものであるが,
1794 8ビットフォント使用時のトラブルを防ぐために \texttt{U+0080}--\texttt{U+00FF} の文字は全部
1795 \textbf{ALchar}としている.
1796 なお,\texttt{U+0080} 以降でこれら9つの文字範囲に属さない文字は,217番の文字範囲に属することになっている.
1797 %</ja>
1798 \begin{description}
1799 %<*en>
1800 \item[Range~8${}^{\text{A}}$] The intersection of the upper half of ISO~8859-1
1801          (Latin-1 Supplement) and JIS~X~0208 (a basic character set for Japanese).
1802   The character list is indicated in \autoref{tab:rng8}.
1803 %</en>
1804 %<*ja>
1805 \item[範囲8${}^{\text{A}}$] ISO~8859-1の上位領域(ラテン1補助)と
1806   JIS~X~0208の共通部分.文字のリストは\autoref{tab:rng8}を参照.
1807 %</ja>
1808 \begin{table}[!tb]
1809 %<en>\caption{Characters in predefined character range~8.}\medskip
1810 %<ja>\caption{文字範囲8に指定されている文字.}
1811 \label{tab:rng8}
1812 \centering\footnotesize
1813 \def\ch#1{\char"#1~(\texttt{U+00#1})}%"
1814 \begin{tabular}{llll}
1815 \ch{A7}&{Section Sign}&
1816 \ch{A8}&{Diaeresis}\\
1817 \ch{B0}&{Degree sign}&
1818 \ch{B1}&{Plus-minus sign}\\
1819 \ch{B4}&{Spacing acute}&
1820 \ch{B6}&{Paragraph sign}\\
1821 \ch{D7}&{Multiplication sign}&
1822 \ch{F7}&{Division Sign}
1823 \end{tabular}
1824 \end{table}
1825
1826 %<*en>
1827 \item[Range~1${}^{\text{A}}$] Latin characters that some of them are included in Adobe-Japan1-7.
1828   This range consists of the Unicode ranges indicated in \autoref{tab:rng1},
1829   \emph{except characters in the range~8 above}.
1830 %</en>
1831 %<*ja>
1832 \item[範囲1${}^{\text{A}}$] ラテン文字のうち,Adobe-Japan1-7との共通部分があるもの.
1833                              この範囲は\autoref{tab:rng1}で示したUnicodeのブロックのうち
1834                              \emph{範囲8を除いた}部分で構成されている.
1835 %</ja>
1836 \begin{table}[!tb]
1837 %<en>\caption{Unicode blocks in predefined character range~1.}\medskip
1838 %<ja>\caption{文字範囲1に指定されているUnicodeブロック.}
1839 \label{tab:rng1}
1840 \centering\footnotesize
1841 \begin{tabular}{llll}
1842  \texttt{U+0080}--\texttt{U+00FF}&Latin-1 Supplement&
1843  \texttt{U+0100}--\texttt{U+017F}&Latin Extended-A\\
1844  \texttt{U+0180}--\texttt{U+024F}& Latin Extended-B&
1845  \texttt{U+0250}--\texttt{U+02AF}& IPA Extensions\\
1846  \texttt{U+02B0}--\texttt{U+02FF}& Spacing Modifier Letters&
1847  \texttt{U+0300}--\texttt{U+036F}& Combining Diacritical Marks\\
1848  \texttt{U+1E00}--\texttt{U+1EFF}&Latin Extended Additional
1849 \end{tabular}
1850 \end{table}
1851 %<*en>
1852 \item[Range~2${}^{\text{\kern.1emJ}}$] Greek and Cyrillic letters. JIS~X~0208 (hence most of Japanese
1853            fonts) has some of these characters.
1854 %</en>
1855 %<*ja>
1856 \item[範囲2${}^{\text{\kern.1emJ}}$] ギリシャ文字とキリル文字.JIS~X~0208(したがってほとんどの
1857                              和文フォント)には,これらの文字の一部が含まれている.
1858 %</ja>
1859 \begin{multicols}{2}
1860 \begin{itemize}
1861 \item \texttt{U+0370}--\texttt{U+03FF}: Greek and Coptic
1862 \item \texttt{U+0400}--\texttt{U+04FF}: Cyrillic
1863 \item \texttt{U+1F00}--\texttt{U+1FFF}: Greek Extended
1864 \\\
1865 \end{itemize}
1866 \end{multicols}
1867 %<*en>
1868 \item[Range~3${}^{\text{\kern.1emJ}}$] Miscellaneous symbols. The block list is
1869            indicated in \autoref{tab:rng3}.
1870 %</en>
1871 %<*ja>
1872 \item[範囲3${}^{\text{\kern.1emJ}}$] 記号類.ブロックのリストは\autoref{tab:rng3}%
1873                              に示してある.
1874 %</ja>
1875 \begin{table}[!tb]
1876 %<en>\caption{Unicode blocks in predefined character range~3.}\medskip
1877 %<ja>\caption{文字範囲3に指定されているUnicodeブロック.}
1878 \label{tab:rng3}
1879 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
1880 \centering\footnotesize
1881 \begin{tabular}{llll}
1882 "2070--"209F&Superscripts and Subscripts\\
1883 "20A0--"20CF&Currency Symbols&
1884 "20D0--"20FF&Comb.\ Diacritical Marks for Symbols\\
1885 "2100--"214F&Letterlike Symbols&
1886 "2150--"218F&Number Forms\\
1887 "2190--"21FF&Arrows&
1888 "2200--"22FF&Mathematical Operators\\
1889 "2300--"23FF&Miscellaneous Technical&
1890 "2400--"243F&Control Pictures\\
1891 "2500--"257F&Box Drawing&
1892 "2580--"259F&Block Elements\\
1893 "25A0--"25FF&Geometric Shapes&
1894 "2600--"26FF&Miscellaneous Symbols\\
1895 "2700--"27BF&Dingbats&
1896 "2900--"297F&Supplemental Arrows-B\\
1897 "2980--"29FF&Misc.\ Math Symbols-B&
1898 "2B00--"2BFF&Misc.\ Symbols and Arrows
1899 \end{tabular}
1900 \end{table}
1901 %<*en>
1902 \item[Range~9${}^{\text{J}}$] The intersection of the ``General Punctuation'' block
1903   (\texttt{U+2000}--\texttt{U+206F})
1904   and Adobe-Japan1-7 character collection.
1905   This character range characters in \autoref{tab:rng9}.
1906 %</en>
1907 %<*ja>
1908 \item[範囲9${}^{\text{J}}$] Unicodeの「一般句読点」ブロック(\texttt{U+2000}--\texttt{U+206F})と
1909   Adobe-Japan1-7の共通部分.
1910   この文字範囲は\autoref{tab:rng9}に示した文字で構成される.
1911 %</ja>
1912 \begin{table}[!tb]
1913 %<en>\caption{Characters in predefined character range~9.}\medskip
1914 %<ja>\caption{文字範囲9に指定されている文字.}
1915 \label{tab:rng9}
1916 \centering\footnotesize
1917 \def\ch#1{%
1918   {\fboxsep0pt\fcolorbox{cyan}{white}%
1919   {\normalsize\KOZM\UTF{20#1}}}\ (\texttt{U+20#1})} %"
1920 % 13: JIS X0213, AJ, Adobe-Japan-1 only
1921 \begin{tabular}{ll>{\color{white}}lll>{\color{white}}l}
1922   \ch{02}&{En space}&AJ&
1923   \ch{10}&{Hyphen}&\\
1924   \ch{11}&{Non-breaking hyphen}&AJ&
1925   \ch{13}&{En dash}&13\\
1926   \ch{14}&{Em dash}&&
1927   \ch{15}&{Horizontal bar}&\\
1928   \ch{16}&{Double vertical line}&&
1929   \ch{18}&{Left single quotation mark}&\\
1930   \ch{19}&{Right single quotation mark}&&
1931   \ch{1A}&{Single low-9 quotation mark}&AJ\\
1932   \ch{1C}&{Left double quotation mark}&&
1933   \ch{1D}&{Right double quotation mark}&\\
1934   \ch{1E}&{Double low-9 quotation mark}&AJ&
1935   \ch{20}&{Dagger}&\\
1936   \ch{21}&{Double dagger}&&
1937   \ch{22}&{Bullet}&13\\
1938   \ch{25}&{Two dot leader}&&
1939   \ch{26}&{Horizontal ellipsis}&\\
1940   \ch{30}&{Per mille sign}&&
1941   \ch{32}&{Prime}&\\
1942   \ch{33}&{Double prime}&&
1943   \ch{39}&{Single left-pointing angle quot.}&AJ\\
1944   \ch{3A}&{Single right-pointing angle quot.}&AJ&
1945   \ch{3B}&{Reference mark}&\\
1946   \ch{3C}&{Double exclamation mark}&13&
1947   \ch{3E}&{Overline}&\\
1948   \ch{3F}&{Undertie}&13&
1949   \ch{42}&{Asterism}&13\\
1950   \ch{44}&{Fraction slash}&AJ&
1951   \ch{47}&{Double question mark}&13\\
1952   \ch{48}&{Question exclamation mark}&13&
1953   \ch{49}&{Exclamation question mark}&13\\
1954   \ch{51}&{Two asterisks aligned vertically}&13
1955 \end{tabular}
1956 \end{table}
1957 %<*en>
1958 \item[Range~4${}^{\text{A}}$] Characters usually not in Japanese fonts. This range consists
1959            of almost all Unicode blocks which are not in other
1960            predefined ranges. Hence, instead of showing the block list,
1961            we put the definition of this range itself.
1962 %</en>
1963 %<*ja>
1964 \item[範囲4${}^{\text{A}}$] 通常和文フォントには含まれていない文字.
1965                              この範囲は他の範囲にないほとんど全てのUnicodeブロック
1966                              で構成されている.したがって,ブロックのリストを示す
1967                              代わりに,範囲の定義そのものを示す.
1968 %</ja>
1969 \begin{lstlisting}[escapechar=\!]
1970 \ltjdefcharrange{4}{%
1971    "500-"10FF, "1200-"1DFF, "2440-"245F, "27C0-"28FF, "2A00-"2AFF,
1972   "2C00-"2E7F, "4DC0-"4DFF, "A4D0-"A95F, "A980-"ABFF, "E000-"F8FF,
1973   "FB00-"FE0F, "FE20-"FE2F, "FE70-"FEFF, "10000-"1AFFF, "1B170-"1F0FF,
1974   "1F300-"1FFFF, ... !\rmfamily (and characters in \texttt{U+2000}--\texttt{U+206F} which are not in range 9)!
1975 } % non-Japanese
1976 \end{lstlisting}
1977 %<en>\item[Range~5${}^{\text{A}}$] Surrogates and Supplementary Private Use Areas.
1978 %<ja>\item[範囲5${}^{\text{A}}$] 代用符号と補助私用領域.
1979 %<en>\item[Range~6${}^{\text{\kern.1emJ}}$] Characters used in Japanese. The block list is indicated in \autoref{tab:rng6}.
1980 %<ja>\item[範囲6${}^{\text{\kern.1emJ}}$] 日本語で用いられる文字.ブロックのリストは\autoref{tab:rng6}に示す.
1981 \begin{table}[!tb]
1982 %<en>\caption{Unicode blocks in predefined character range~6.}\medskip
1983 %<ja>\caption{文字範囲6に指定されているUnicodeブロック.}
1984 \label{tab:rng6}
1985 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
1986 \centering\footnotesize
1987 \begin{tabular}{llll}
1988 "2460--"24FF&Enclosed Alphanumerics&
1989 "2E80--"2EFF&CJK Radicals Supplement\\
1990 "3000--"303F&CJK Symbols and Punctuation&
1991 "3040--"309F&Hiragana\\
1992 "30A0--"30FF&Katakana&
1993 "3190--"319F&Kanbun\\
1994 "31F0--"31FF&Katakana Phonetic Extensions&
1995 "3200--"32FF&Enclosed CJK Letters and Months\\
1996 "3300--"33FF&CJK Compatibility&
1997 "3400--"4DBF&CJK Unified Ideographs Ext-A\\
1998 "4E00--"9FFF&CJK Unified Ideographs&
1999 "F900--"FAFF&CJK Compatibility Ideographs\\
2000 "FE10--"FE1F&Vertical Forms&
2001 "FE30--"FE4F&CJK Compatibility Forms\\
2002 "FE50--"FE6F&Small Form Variants&
2003 "FF00--"FFEF&Halfwidth and Fullwidth Forms\\
2004 "{1B}000--"{1B}0FF&Kana Supplement&
2005 "{1B}100--"{1B}12F&Kana Extended-A\\
2006 %"{1B}130--"{1B}16F&Small Kana Extension
2007 "{1F}100--"{1F}1FF&Enclosed Alphanumeric Supp.&
2008 "{1F}200--"{1F}2FF&Enclosed Ideographic Supp.\\
2009 "{20}000--"{2F}FFF&(Supp. Ideographic Plane)&
2010 "{30}000--"{3F}FFF&(Tert. Ideographic Plane)\\
2011 "{E0}100--"{E0}1EF&Variation Selectors Supp.
2012 \end{tabular}
2013 \end{table}
2014 %<*en>
2015 \item[Range~7${}^{\text{\kern.1emJ}}$] Characters used in CJK languages, but not included in  Adobe-Japan1-7.
2016 The block list is indicated in \autoref{tab:rng7}.
2017 %</en>
2018 %<*ja>
2019 \item[範囲7${}^{\text{\kern.1emJ}}$] CJK言語で用いられる文字のうち,Adobe-Japan1-7に
2020                             含まれていないもの.
2021                             ブロックのリストは\autoref{tab:rng7}に示す.
2022 %</ja>
2023 \begin{table}[!tb]
2024 %<en>\caption{Unicode blocks in predefined character range~7.}\medskip
2025 %<ja>\caption{文字範囲7に指定されているUnicodeブロック.}
2026 \label{tab:rng7}
2027 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
2028 \centering\small
2029 \begin{tabular}{llll}
2030 "1100--"11FF&Hangul Jamo&
2031 "2F00--"2FDF&Kangxi Radicals\\
2032 "2FF0--"2FFF&Ideographic Description Characters&
2033 "3100--"312F&Bopomofo\\
2034 "3130--"318F&Hangul Compatibility Jamo&
2035 "31A0--"31BF&Bopomofo Extended\\
2036 "31C0--"31EF&CJK Strokes&
2037 "A000--"A48F&Yi Syllables\\
2038 "A490--"A4CF&Yi Radicals&
2039 "A960--"A97F&Hangul Jamo Extended-A\\
2040 "AC00--"D7AF&Hangul Syllables&
2041 "D7B0--"D7FF&Hangul Jamo Extended-B
2042 \end{tabular}
2043 \end{table}
2044 \end{description}
2045
2046 %<*en>
2047 \paragraph{Notes on \texttt{U+0080}--\texttt{U+00FF}}
2048 You should treat characters in \\texttt{U+0080}--\texttt{U+00FF} as \textbf{ALchar},
2049 when you use traditional 8-bit fonts, such as the \Pkg{marvosym} package.
2050
2051 For example, \cs{Frowny} which is provided by the \Pkg{marvosym} package has
2052 the same codepoint as \S\ (\text{U+00A7}).
2053 Hence, as previous versions of \LuaTeX-ja, if these characters are treated as
2054 \text{JAchar}s, then \cs{Frowny} produces ``\ltjjachar`§'' (in a Japanese font).
2055
2056 To avoid such situations, the default setting of \LuaTeX-ja is changed in version~20150906.0
2057 so that all characters \texttt{U+0080}--\texttt{U+00FF} are treated as \textbf{ALchar}.
2058
2059 If you want to output a character as \textbf{ALchar} and \textbf{JAchar} regardless the range
2060 setting, you can use \cs{ltjalchar} and \cs{ltjjachar} respectively, as the following example.
2061 \begin{LTXexample}[width=0.3\textwidth]
2062 \gtfamily\large % default, ALchar, JAchar
2063 ¶, \ltjalchar`¶, \ltjjachar`¶\\   % default: ALchar
2064 α, \ltjalchar`α, \ltjjachar`α  % default: JAchar
2065 \end{LTXexample}
2066 %</en>
2067 %<*ja>
2068 \paragraph{\texttt{U+0080}--\texttt{U+00FF}についての注意}
2069 \LuaTeX-jaで,\Pkg{marvosym}パッケージ等,Unicodeフォントでなく
2070 伝統的な8ビットフォントを用いる場合には注意が必要である.
2071
2072 例えば,\Pkg{marvosym}パッケージの提供する \cs{Frowny} も,符号位置は167,つまりUnicodeにおける
2073 \S\ (\text{U+00A7}) と同じ符号位置にある.
2074 即ち,以前のバージョンのように,「前節の文字範囲8内の文字は\textbf{JAchar}」という設定で
2075 あったとすると,上記の \cs{Frowny} は和文フォントで「\ltjjachar`§」を出力することになる.
2076
2077 このような事態を避けるために,バージョン20150906.0からは \texttt{U+0080}--\texttt{U+00FF} の範囲の
2078 文字は全て\textbf{ALchar}となるように初期設定を変更している.
2079
2080 なお,文字範囲の設定に関わらず1つの文字を\textbf{ALchar}, \textbf{JAchar}で出力したい場合には,
2081 以下の例のようにそれぞれ \cs{ltjalchar},~\cs{ltjjachar} に該当文字の文字コードを渡せばよい.
2082 \begin{LTXexample}[width=0.3\textwidth]
2083 \gtfamily\large % default, ALchar, JAchar
2084 ¶, \ltjalchar`¶, \ltjjachar`¶\\   % default: ALchar
2085 α, \ltjalchar`α, \ltjjachar`α  % default: JAchar
2086 \end{LTXexample}
2087 %</ja>
2088
2089 %<*ja>
2090 \paragraph{絵文字など,複数コードポイントの列で表現される字形をを利用する場合の注意}
2091 (\Pkg{luaotfload}による)OpenType機能や合字等の処理は,\LuaTeX-jaが
2092 段落・水平ボックスの中身全体に対して「この文字は\textbf{JAchar}だから和文フォントで組む」と
2093 フォントを置き換えた後に適用される.
2094 そのため,異体字セレクタや絵文字といった複数のコードポイントの列で表現される文字を
2095 組む場合には,列全体で\textbf{JAchar}の範囲か\textbf{ALchar}の範囲かが
2096 統一されていないといけない.
2097
2098 例えば,CJK統合漢字(とその拡張達)と
2099 IVS用の異体字セレクタ(\texttt{U+E0100}--\texttt{U+E01EF})は標準では
2100 どちらも同じ文字範囲6であるため,(フォントがサポートしていれば)IVSは正しく機能する.
2101 しかし,下の例のように異体字セレクタを\textbf{ALchar}の文字範囲(4)に移動させると,
2102 IVSは機能しなくなる:
2103 \ltjdefcharrange{4}{"E0100-"E01EF}
2104 \begin{LTXexample}
2105 \ltjdefcharrange{4}{"E0100-"E01EF}
2106 葛󠄀城市,葛󠄁飾区,葛西
2107 \end{LTXexample}
2108 \ltjdefcharrange{6}{"E0100-"E01EF}
2109
2110 また,標準では絵文字として使われる可能性が大きい一部の文字が\textbf{JAchar}となっている
2111 \footnote{同じUnicodeブロック内にAdobe-Japan1-6の文字があったため.}.
2112 絵文字を用いる場合にはこの点に留意する必要がある.
2113
2114 \begin{center}
2115   \begin{minipage}{.5\textwidth}\small\ttfamily
2116 \verb!\ltjsetparameter{jacharrange={+3}}!\\
2117 \verb!\font\nce=NotoColorEmoji.ttf:mode=harf\nce!\\
2118 \IVSA 1F469\UCSB{ZW}{J}\UCSA 2764\UCSB{VS}{16}\UCSB{ZW}J\IVSA 1F48B\UCSB{ZW}J\IVSA 1F468\ 
2119   \textcolor{green}{\% U+2764: JAchar}\\
2120 \verb!\ltjsetparameter{jacharrange={-3}}!\\
2121 \IVSA 1F469\UCSB{ZW}{J}\UCSA 2764\UCSB{VS}{16}\UCSB{ZW}J\IVSA 1F48B\UCSB{ZW}J\IVSA 1F468\ 
2122   \textcolor{green}{\% U+2764: ALchar}
2123   \end{minipage}%
2124   \begin{minipage}{.5\textwidth}
2125 \ltjsetparameter{jacharrange={+3}}
2126 \font\nce=NotoColorEmoji.ttf:mode=harf\nce
2127 👩‍❤️‍💋‍👨
2128 \ltjsetparameter{jacharrange={-3}}
2129 👩‍❤️‍💋‍👨
2130   \end{minipage}
2131 \end{center}
2132 \ltjsetparameter{jacharrange={+3}}
2133 %</ja>
2134
2135
2136 %<en>\subsection{\Param{kanjiskip} and \Param{xkanjiskip}}
2137 %<ja>\subsection{\Param{kanjiskip}と\Param{xkanjiskip}}
2138 \label{subs-kskip}
2139
2140 %<en>\textbf{JAglue} is divided into the following three categories:
2141 %<ja>\textbf{JAglue}は以下の3つのカテゴリに分類される:
2142 \begin{itemize}
2143 %<*en>
2144 \item Glues/kerns specified in JFM. If \cs{inhibitglue} is issued
2145       around a \textbf{JAchar}, this glue will not be inserted at the
2146       place.
2147 %</en>
2148 %<*ja>
2149 \item JFMで指定されたグルー/カーン.もし \cs{inhibitglue} が\textbf{JAchar}の周りで
2150       発行されていれば,このグルーは挿入されない.
2151 %</ja>
2152 %<*en>
2153 \item The default glue which inserted between two \textbf{JAchar}s (\Param{%
2154       kanjiskip}).
2155 %</en>
2156 %<*ja>
2157 \item デフォルトで2つの\textbf{JAchar}の間に挿入されるグルー(\Param{kanjiskip}).
2158 %</ja>
2159 %<*en>
2160 \item The default glue which inserted between a \textbf{JAchar} and an
2161       \textbf{ALchar} (\Param{xkanjiskip}).
2162 %</en>
2163 %<*ja>
2164 \item デフォルトで\textbf{JAchar}と\textbf{ALchar}の間に挿入されるグルー(\Param{xkanjiskip}).
2165 %</ja>
2166 \end{itemize}
2167 %<*en>
2168 The value (a skip) of \Param{kanjiskip} or
2169 \Param{xkanjiskip} can be changed as the following.
2170 Note that only their values \emph{at the end of a paragraph or a hbox are
2171 adopted in the whole paragraph or the whole hbox.
2172 }
2173 %</en>
2174 %<*ja>
2175 \Param{kanjiskip}や\Param{xkanjiskip}の値
2176 は以下のようにして変更可能である.
2177 %</ja>
2178 \begin{lstlisting}
2179 \ltjsetparameter{kanjiskip={0pt plus 0.4pt minus 0.4pt},
2180                  xkanjiskip={0.25\zw plus 1pt minus 1pt}}
2181 \end{lstlisting}
2182 %<*en>
2183 Here \cs{zw} is a internal dimension
2184 which stores fullwidth of the current Japanese font.
2185 This \cs{zw} can be used as the unit \texttt{zw} in \pTeX.
2186
2187 The value of these parameter can be get by \cs{ltjgetparameter}.
2188 Note that the result by \cs{ltjgetparameter} is \emph{not} the internal quantities,
2189 but \emph{a string} (hence \cs{the} cannot be prefixed).
2190 %</en>
2191 %<*ja>
2192 ここで,\cs{zw} は現在の和文フォントの全角幅を表す長さであり,
2193 \pTeX における長さ単位 \texttt{zw} と同じように使用できる.
2194
2195 これらのパラメータの値は以下のように取得できる.
2196 戻り値は内部値ではなく\emph{文字列}である(\cs{the} は前置できない)ことに注意してほしい:
2197 %</ja>
2198 \begin{LTXexample}
2199 kanjiskip: \ltjgetparameter{kanjiskip},\\
2200 xkanjiskip: \ltjgetparameter{xkanjiskip}
2201 \end{LTXexample}
2202
2203 %<*en>
2204 It may occur that JFM contains the data of ``ideal width of
2205 \Param{kanjiskip}''
2206 and/or ``ideal width of \Param{xkanjiskip}''.
2207 To use these data from JFM, set the value of \Param{kanjiskip} or
2208 \Param{xkanjiskip} to \cs{maxdimen}
2209 (these ``ideal width'' cannot be retrived by \cs{ltjgetparameter}).
2210 %</en>
2211 %<*ja>
2212 JFMは「望ましい\Param{kanjiskip}の値」や
2213 「望ましい\Param{xkanjiskip}の値」を持っていることがある.
2214 これらのデータを使うためには,\Param{kanjiskip}や%
2215 \Param{xkanjiskip}の値を \cs{maxdimen} の値に設定すればよいが,
2216 \cs{ltjgetparameter} によって取得することはできないので注意が必要である.
2217 %</ja>
2218
2219 %<en>\subsection{Insertion setting of \Param{xkanjiskip}}
2220 %<ja>\subsection{\Param{xkanjiskip} の挿入設定}
2221
2222 %<*en>
2223 It is not desirable that \Param{xkanjiskip} is inserted into every
2224 boundary between \textbf{JAchar}s and \textbf{ALchar}s. For example,
2225 \Param{xkanjiskip} should not be inserted after opening parenthesis
2226 (\textit{e.g.}, compare ``(あ'' and ``(\+あ'').
2227 \LuaTeX-ja can control whether \Param{xkanjiskip} can be inserted
2228 before/after a character, by changing \Param{jaxspmode} for \textbf{JAchar}s and
2229 \Param{alxspmode} parameters \textbf{ALchar}s respectively.
2230 %</en>
2231 %<*ja>
2232 \Param{xkanjiskip}がすべての\textbf{JAchar}と\textbf{ALchar}の境界に
2233 挿入されるのは望ましいことではない.例えば,\Param{xkanjiskip}は開き括弧の
2234 後には挿入されるべきではない(「(あ」と「(\+あ」を
2235 比べてみよ).
2236 \LuaTeX-jaでは\Param{xkanjiskip}をある文字の前/後に挿入するかどうかを,
2237 \textbf{JAchar}に対しては\Param{jaxspmode}を,\textbf{ALchar}に対しては
2238 \Param{alxspmode}をそれぞれ変えることで制御することができる.
2239 %</ja>
2240 \begin{LTXexample}
2241 \ltjsetparameter{jaxspmode={`あ,preonly}, alxspmode={`\!,postonly}}
2242 pあq い!う
2243 \end{LTXexample}
2244
2245 %<*en>
2246 The second argument \texttt{preonly} means that the insertion of
2247 \Param{xkanjiskip} is allowed before this character, but not after.
2248 the other possible values are \texttt{postonly}, \texttt{allow}, and \texttt{inhibit}.
2249 %</en>
2250 %<*ja>
2251 2つ目の引数の \texttt{preonly}は「\Param{xkanjiskip}の挿入はこの文字の
2252 前でのみ許され,後では許さない」ことを意味する.他に指定可能な値は
2253 \texttt{postonly}, \texttt{allow}, \texttt{inhibit}である.
2254 %</ja>
2255
2256 %<*en>
2257 \Param{jaxspmode} and \Param{alxspmode} use a same table to store the parameters
2258 on the current version. Therefore, line~1 in the code above can be rewritten
2259 as follows:
2260 %</en>
2261 %<*ja>
2262 なお,現行の
2263 仕様では,\Param{jaxspmode}, \Param{alxspmode}はテーブルを共有しており,
2264 上のコードの1行目を次のように変えても同じことになる:
2265 %</ja>
2266 \begin{lstlisting}
2267 \ltjsetparameter{alxspmode={`あ,preonly}, jaxspmode={`\!,postonly}}
2268 \end{lstlisting}
2269 %<*en>
2270 One can use also numbers to specify these two parameters (see Subsection~\ref{ssec:param}).
2271 %</en>
2272 %<*ja>
2273 また,これら2パラメータには数値で値を指定することもできる(\ref{ssec:param}節を参照).
2274 %</ja>
2275
2276 %<*en>
2277 If you want to enable/disable all insertions of \Param{kanjiskip} and
2278 \Param{xkanjiskip}, set \Param{autospacing} and \Param{autoxspacing}
2279 parameters to \texttt{true}/\texttt{false}, respectively.
2280 %</en>
2281 %<*ja>
2282 もし全ての\Param{kanjiskip}と\Param{xkanjiskip}の挿入を有効化/無効化
2283 したければ,それぞれ\Param{autospacing}と\Param{autoxspacing}を
2284 \texttt{true}/\texttt{false}に設定すればよい.
2285 %</ja>
2286
2287 %<en>\subsection{Shifting the baseline}
2288 %<ja>\subsection{ベースラインの移動}
2289 \label{ssec:baseline}
2290 %<*en>
2291 To make a match between a Japanese font and an alphabetic font, sometimes
2292 shifting of the baseline of one of the pair is needed. In \pTeX, this is achieved
2293 by setting \cs{ybaselineshift} (or \cs{tbaselineshift}) to a non-zero length (the
2294 baseline of \textbf{ALchar} is shifted below). However, for documents
2295 whose main language is not Japanese, it is good to shift the baseline of
2296 Japanese fonts, but not that of alphabetic fonts.
2297 Because of this, \LuaTeX-ja can independently set the shifting amount
2298 of the baseline of alphabetic fonts and that of Japanese fonts.
2299 \begin{center}
2300  \small
2301 \begin{tabular}{>{\bfseries}lcc}
2302 \toprule
2303 &\bfseries Horizontal writing (\emph{yoko} direction) etc.
2304 &\bfseries Vertical writing(\emph{tate} direction)\\
2305 \midrule
2306 Alphabetic fonts&\Param{yalbaselineshift}
2307      parameter&\Param{talbaselineshift} parameter\\
2308 Japanese fonts&\Param{yjabaselineshift}
2309      parameter&\Param{tjabaselineshift} parameter\\
2310 \bottomrule
2311 \end{tabular}
2312 \end{center}
2313 %</en>
2314 %<*ja>
2315 和文フォントと欧文フォントを合わせるためには,時々どちらかのベースラインの移動が
2316 必要になる.\pTeX ではこれは \cs{ybaselineshift}(または\cs{tbaselineshift})を設定することで
2317 なされていた(\textbf{ALchar}のベースラインがその分だけ下がる).しかし,日本語が主ではない
2318 文書に対しては,欧文フォントではなく和文フォントのベースラインを移動した方がよい.
2319 このため,\LuaTeX-jaでは欧文フォントのベースラインのシフト量
2320 と和文フォントのベースラインのシフト量を独立に設定できるようになっている.
2321 \begin{center}
2322  \small
2323 \begin{tabular}{>{\bfseries}lcc}
2324 \toprule
2325 &\bfseries 横組など&\bfseries 縦組\\
2326 \midrule
2327 欧文フォントのシフト量&\Param{yalbaselineshift}
2328      parameter&\Param{talbaselineshift} parameter\\
2329 和文フォントのシフト量&\Param{yjabaselineshift}
2330      parameter&\Param{tjabaselineshift} parameter\\
2331 \bottomrule
2332 \end{tabular}
2333 \end{center}
2334 %</ja>
2335
2336 %<*en>
2337 Here the horizontal line in the below example is the baseline of a line.
2338 %</en>
2339 %<*ja>
2340 下の例において引かれている水平線がベースラインである.
2341 %</ja>
2342 \begin{LTXexample}
2343 \vrule width 150pt height 0.2pt depth 0.2pt \hskip-120pt
2344 \ltjsetparameter{yjabaselineshift=0pt, yalbaselineshift=0pt}abcあいう
2345 \ltjsetparameter{yjabaselineshift=5pt, yalbaselineshift=2pt}abcあいう
2346 \end{LTXexample}
2347
2348 %<*en>
2349 There is an interesting side-effect: characters in different size can be
2350 vertically aligned center in a line, by setting two parameters appropriately.
2351 The following is an example (beware the value is not well tuned):
2352 %</en>
2353 %<*ja>
2354 この機能には面白い使い方がある:2つのパラメータを適切に設定することで,サイズの
2355 異なる文字を中心線に揃えることができる.
2356 以下は一つの例である(値はあまり調整されていないことに注意):
2357 %</ja>
2358 \begin{LTXexample}[width=0.4\textwidth]
2359 \vrule width 150pt height4.417pt depth-4.217pt%
2360 \kern-150pt
2361 \large xyz漢字
2362 {\scriptsize
2363   \ltjsetparameter{yjabaselineshift=-1.757pt,
2364     yalbaselineshift=-1.757pt}
2365   漢字xyzあいう
2366 }あいうabc
2367 \end{LTXexample}
2368
2369 %<*en>
2370 Note that setting positive \Param{yalbaselineshift}~or~\Param{talbaselineshift}
2371 parameters does not increase the depth of one-letter \emph{syllable} $p$ of \textbf{Alchar}, if
2372 its left-protrusion~(\cs{lpcode}) and right-protrusion~(\cs{rpcode}) are both non-zero.
2373 This is because
2374 \begin{itemize}
2375 \item These two parameters are implemented by setting \texttt{yoffset} field of a
2376 glyph node, and this does not increase the depth of the glyph.
2377 \item To cope with the above situation, \LuaTeX-ja automatically supplies
2378 a rule in every syllable.
2379 \item However, we cannot use this ``supplying a rule'' method if a syllable comprises just
2380       one letter whose \cs{lpcode}~and~\cs{rpcode} are both non-zero.
2381 \end{itemize}
2382
2383 This problem does not apply for \Param{yjabaselineshift}~nor~\Param{tjabaselineshift},
2384 becuse a \emph{JAchar} is encapsulated by a horizontal box if needed.
2385 %</en>
2386 %<*ja>
2387 なお,以下の場合には1文字の\textbf{ALchar}からなる「音節」の深さは増加しないことに注意.
2388 \begin{itemize}
2389  \item \Param{yalbaselineshift},~\Param{talbaselineshift}パラメータが正になっている.
2390  \item 「音節」を構成する唯一の文字$p$の
2391 左余白への突出量(\cs{lpcode}),右余白への突出量(\cs{rpcode})がどちらも非零である.
2392 \end{itemize}
2393 \emph{JAchar}は必要に応じて1文字ずつボックスにカプセル化されるため,
2394 \Param{yjabaselineshift},~\Param{tjabaselineshift}パラメータについてはこのような問題は起こらない.
2395 %</ja>
2396
2397 %<*ja>
2398 \paragraph{数式における挙動:\pTeX との違い}
2399 \textbf{ALchar}のベースラインを補正する\Param{yalbaselineshift}, \Param{talbaselineshift}パラメータは
2400 ほぼ\pTeX における \cs{ybaselineshift}, \cs{tbaselineshift} に対応しているものであるが,
2401 数式中の挙動は異なっているので注意が必要である(\autoref{tab:math_bsa}参照).
2402 \begin{itemize}
2403  \item バージョン20221002.0以降では,
2404   \pTeX~4.0.0と同様に数式が\Param{yalbaselineshift}だけシフトされる.
2405
2406   しかしそれでは数式中に直に書かれた\cs{hbox},~\cs{vbox}中の欧文には
2407   \Param{yalbaselineshift}が二重に適用されることになるので,
2408   数式中に直に書かれた\cs{hbox},~\cs{vbox}には
2409   \Param{yalbaselineshift}を打ち消す補正をしている.
2410
2411   なお,\cs{vcenter}によるボックスにはこの「打ち消す補正」は行われないので注意.
2412 \item \pTeX では数式のスタイルごとに「打ち消す補正」の割合を\cs{textbaselineshiftfactor},
2413   \cs{scriptbaselineshiftfactor}, \cs{scriptscriptbaselineshiftfactor}で
2414   指定できるようにしたが,\LuaTeX-jaでは2番の数式ファミリ(\cs{fam2})に使われているフォントの
2415   大きさから自動で計算する.
2416
2417 \item 数式中に直に書かれた和文文字(\autoref{tab:math_bsa}中の``あ'')については
2418   \pTeX と\LuaTeX-jaで違いが見られる.
2419   \pTeX では,欧文文字と変わらず欧文ベースライン補正(\cs{ybaselineshift})がかかり,
2420   また周囲に和欧文間空白(\cs{xkanjiskip})が入りうる.
2421   その一方,\LuaTeX-jaでは「和文ベースライン補正(\Param{yjabaselineshift})がかかる」見た目に
2422   なり,また周囲に和欧文間空白は入らない.
2423 \end{itemize}
2424 \begin{table}
2425 \small\centering
2426 \caption{数式関係のベースライン補正($\Param{yalbaselineshift}=10\,\textrm{pt}$)}
2427 \label{tab:math_bsa}
2428 \newdimen\origbaselineskip
2429 \origbaselineskip=\baselineskip
2430 \begin{tabular}{lp{35\zw}}
2431 \toprule
2432 \emph{入力}&\vspace*{\dimexpr-\origbaselineskip-\smallskipamount}
2433 \begin{lstlisting}
2434 数式abc: $あa\hbox{い}$, $\int_0^x t\,dt=x^2/2$,
2435 $\Phi\vdash F(x)\ \hbox{for all}\ x\in A$,
2436 $\sqrt{A}-\underline{X}+\frac{あ3}{2あ}-\vcenter{\hbox{aお}}$
2437 \end{lstlisting}\\
2438 \noalign{\vskip-\origbaselineskip}
2439 \midrule
2440 \emph{\pTeX~(p4.0.0)}&
2441 {\ltjsetparameter{yalbaselineshift=10pt}%
2442 \protected\def\>{\hskip\ltjgetparameter{xkanjiskip}}
2443 数式abc: $\lower10pt\hbox{あ}\>a\hbox{い}$, $\int_0^x t\,dt=x^2/2$,
2444 $\Phi\vdash F(x)\ \hbox{for all}\ x\in A$
2445 $\sqrt{A}-\underline{X}
2446   +\frac{\lower10pt\hbox{\scalebox{0.7}{あ}}\>3}{2\>\lower10pt\hbox{\scalebox{0.7}{あ}}}-\vcenter{\hbox{aお}}$
2447 \par}\\\noalign{\vskip-\origbaselineskip}\midrule
2448 \emph{\LuaTeX-ja}&
2449 {\ltjsetparameter{yalbaselineshift=10pt}%
2450 数式abc: $あa\hbox{い}$, $\int_0^x t\,dt=x^2/2$,
2451 $\Phi\vdash F(x)\ \hbox{for all}\ x\in A$,
2452 $\sqrt{A}-\underline{X}+\frac{あ\>3}{2あ}-\vcenter{\hbox{aお}}$
2453 \par}\\
2454 \noalign{\vskip-\origbaselineskip}
2455 \bottomrule
2456 \end{tabular}
2457 \end{table}
2458 %</ja>
2459
2460 %<*en>
2461 \subsection{\emph{kinsoku} parameters and OpenType features}
2462 Among parameters which related to Japanese word-wrapping process (\emph{kinsoku shori}),
2463 \begin{quote}
2464  \Param{jaxspmode},~\Param{alxspmode}, \Param{prebreakpenalty},
2465  \Param{postbreakpenalty}~and~\Param{kcatcode}
2466 \end{quote}
2467 are stored by each character codes.
2468
2469 OpenType font features are ignored in these parameters.
2470 For example, a fullwidth katakana ``ア'' on line~10 in the below input is replaced to
2471 its halfwidth variant ``ア'', by \verb+hwid+ feature.
2472 However, the penalty inserted after it is 10 which is the \Param{postbreakpenalty} of
2473 ``ア'', not 20.
2474 %</en>
2475 %<*ja>
2476 \subsection{禁則処理関連パラメータとOpenType機能}
2477 禁則処理や \Param{kanjiskip}, \Param{xkanjiskip} の挿入に関連したパラメータのうち
2478 \begin{quote}
2479  \Param{jaxspmode},~\Param{alxspmode}, \Param{prebreakpenalty},
2480  \Param{postbreakpenalty}, \Param{kcatcode}
2481 \end{quote}
2482 は,文字コードごとに設定する量である.
2483
2484 \Pkg{fontspec}パッケージを使う(\ref{ssec:fontspec}節)場合など,
2485 各種のOpenType機能を適用することもあると思うが,前段落に述べたパラメータ類は,
2486 \emph{OpenType機能の適用前の文字コードによって適用される.}
2487 例えば,以下の例において10行目の「ア」は,\verb+hwid+ featureの適用により半角カタカナの「ア」
2488 に置き換わる.しかし,その直後に挿入される \Param{postbreakpenalty}は,置換前の「ア」に対する値10である.
2489 %</ja>
2490
2491 \begin{LTXexample}[width=0.2\textwidth]
2492 \ltjsetparameter{postbreakpenalty={`ア, 10}}
2493 \ltjsetparameter{postbreakpenalty={`ア, 20}}
2494
2495 \newcommand\showpostpena[1]{%
2496   \leavevmode\setbox0=\hbox{#1\hbox{}}%
2497   \unhbox0\setbox0=\lastbox\the\lastpenalty}
2498
2499 \showpostpena{ア},
2500 \showpostpena{ア},
2501 {\addjfontfeatures{CharacterWidth=Half}\showpostpena{ア}}
2502 \end{LTXexample}
2503
2504 \clearpage
2505 %<en>\part{Reference}
2506 %<ja>\part{リファレンス}
2507 \label{part-ref}
2508 \suppressfloats[t]
2509 %<*ja>
2510 \section{\LuaTeX-jaにおける \cs{catcode}}
2511 \label{sec-catcode}
2512 \subsection{予備知識:\pTeX と\upTeX における \cs{kcatcode}}
2513 \pTeX,\upTeX においては,和文文字が制御綴内で利用できるかどうか
2514 は \cs{kcatcode} の値によって決定されるのであった.
2515 詳細は\autoref{tab:kcat}を参照されたい.
2516 %</ja>
2517 %<*en>
2518 \section{\cs{catcode} in \LuaTeX-ja}
2519 \label{sec-catcode}
2520 \subsection{Preliminaries: \cs{kcatcode} in \pTeX\ and \upTeX}
2521 In \pTeX~and~\upTeX, the value of \cs{kcatcode} determines
2522 whether a Japanese character can be used in a control word.
2523 For the detail, see \autoref{tab:kcat}.
2524 %</en>
2525
2526 \begin{table}[t]
2527 \small
2528 \caption{\cs{kcatcode} in \upTeX}
2529 \label{tab:kcat}
2530 %<en>\medskip
2531
2532 \noindent\hfill
2533 \begin{tabular}{llccc}
2534 \toprule
2535 \bfseries \cs{kcatcode}&
2536 %<*en>
2537 \bfseries meaning&
2538 \bfseries control word&
2539 \bfseries widow penalty&
2540 \bfseries linebreak\\
2541 %</en>
2542 %<*ja>
2543 \bfseries 意図&
2544 \bfseries 制御綴中に使用&
2545 \bfseries 文字ウィドウ処理&
2546 \bfseries 直後での改行\\
2547 %</ja>
2548 \midrule
2549 15&non-cjk&\multicolumn{3}{c}{(treated as usual \LaTeX)}\\
2550 16&kanji&Y&Y&ignored\\
2551 17&kana&Y&Y&ignored\\
2552 18&other&N&N&ignored\\
2553 19&hangul&Y&Y&space\\
2554 \bottomrule
2555 \end{tabular}\hfill\null
2556
2557 \medskip
2558
2559 %<*ja>
2560 文字ウィドウ処理:「漢字が一文字だけ次の行に行くのを防ぐ」
2561 \cs{jcharwidowpenalty} が,
2562 その文字の直前に挿入されうるか否か,を示す.
2563 %</ja>
2564 \end{table}
2565
2566 %<*en>
2567 \cs{kcatcode} can be set by a row of JIS~X~0208 in \pTeX,
2568 and generally by a Unicode block\footnote{%
2569   \upTeX\ divides \texttt{U+FF00}--\texttt{U+FFEF} (Halfwidth and Fullwidth Forms)
2570   into three subblocks, and \cs{kcatcode} can be set by a subblock.
2571 }
2572 in \upTeX. So characters which can be used in a control word
2573 slightly differ between \pTeX~and~\upTeX.
2574 %</en>
2575 %<*ja>
2576 \pTeX では \cs{kcatcode} はJIS~X~0208の区単位,
2577 \upTeX では概ねUnicodeブロック単位\footnote{%
2578   \texttt{U+FF00}--\texttt{U+FFEF} (Halfwidth and Fullwidth Forms)は
2579   「全角英数字」「半角カナ」「その他」と3つに分割されており,
2580   それぞれ別々に \cs{kcatcode} が指定できるようになっている.
2581 }で設定可能になっている.そのため,\pTeX と\upTeX の初期状態では
2582 制御綴内で使用可能な文字が微妙に異なっている.
2583 %</ja>
2584
2585 %<*en>
2586 \subsection{Case of \LuaTeX-ja}
2587 The role of \cs{kcatcode} in \pTeX~and~\upTeX\ can be
2588 divided into the following four kinds,
2589 and \LuaTeX-ja can control these four kinds separately:
2590 \begin{itemize}
2591  \item
2592 \emph{Distinction between \textbf{JAchar} or \textbf{ALchar}}
2593 is controlled by the character range, see Subsection~\ref{ssec:setrange}.
2594  \item
2595 \emph{Whether the character can be used in a control word}
2596 is controlled by setting \cs{catcode} to 11~(enabled) or 12~(disabled), as usual.
2597  \item
2598 \emph{Whether \Param{jcharwidowpenalty} can be inserted before the character}
2599 is controlled by the lowermost bit of the \Param{kcatcode} parameter.
2600  \item
2601 \emph{Linebreak after a \textbf{JAchar}} does not produce a space.
2602 \end{itemize}
2603 %</en>
2604 %<*ja>
2605 \subsection{\LuaTeX-jaの場合}
2606 \LuaTeX-jaでは,従来の\pTeX・\upTeX における \cs{kcatcode} の役割を
2607 分割している:
2608 \begin{description}
2609  \item[欧文/和文の区別 (\upTeX)]
2610 \cs{ltjdefcharrange} と\textsf{jacharrange}パラメータ(\ref{ssec:setrange}節)
2611  \item[制御綴中に使用可か]
2612 \LuaTeX 自身の \cs{catcode} でよい
2613  \item[\Param{jcharwidowpenalty}が挿入可か]
2614 \Param{kcatcode}パラメータの最下位ビット
2615  \item[直後の改行]
2616 日本語しか想定していないので,\textbf{JAchar}直後の改行で半角スペースが挿入されることはない.
2617 \end{description}
2618 %</ja>
2619
2620 %<*en>
2621 Default setting of \cs{catcode} of Unicode characters with \LuaTeX\ is slightly inconvenient
2622 for \pTeX~users to shifting to \LuaTeX-ja,
2623 because several fullwidth characters which can be used in a control word with \pTeX,
2624 such as ``\texttt{1}''~(FULLWIDTH DIGIT ONE), cannnot be used in a control word with \LuaTeX.
2625 Hence, \LuaTeX-ja changes the \cs{catcode} of some characters%
2626 ---whose line breaking class is ``ID''~(Ideographic) in UAX~\#14---,
2627 to allow these characters in the control word.
2628 %</en>
2629 %<*ja>
2630 最近の(2015-10-01以降の)\LuaLaTeX では漢字や仮名を制御綴内に
2631 使用することが可能であるが,全角英数字は使用できない.
2632 これでは\pTeX で使用できた\cs{1年目西暦}\footnote{科研費\LaTeX で使用されているそうです.}などが使えないため,
2633 \LuaTeX-jaへの移行で手間が生じることになる.
2634
2635 そのため,\LuaTeX-jaでは全角英数字など一部の文字
2636 \footnote{正確には,Unicodeの行分割アルゴリズム(UAX~\#14)で``ID''~(Ideographic)と指定されている文字.}の
2637 \cs{catcode}を11に変更し,これらの文字を制御綴中で使用可能にしている.
2638 %</ja>
2639
2640 \begin{table}
2641  \centering\small
2642 %<en>\caption{Difference of the set of non-kanji JIS~X~0208 characters which can be used in a control word}
2643 %<ja>\caption{制御綴中に使用出来るJIS~X~0208非漢字の違い}
2644 %<en>\medskip
2645 \label{tab:kcat-diff}
2646 \def\D#1#2#3#4{%
2647   {\fboxsep0pt\fcolorbox{cyan}{white}%
2648   {\large\char"#1#2#3#4}}\ (\texttt{U+#1#2#3#4})} %"
2649 \leavevmode\hbox to 0pt{\hss\begin{tabular}[t]{cccccc}
2650 \toprule
2651 %<en>&\textbf{row}&\textbf{col.}&\textbf{\pTeX}&\textbf{\upTeX}&\textbf{\LuaTeX-ja}\\
2652 %<ja>&\emph{区}&\emph{点}&\emph{\pTeX}&\emph{\upTeX}&\emph{\LuaTeX-ja}\\
2653 \midrule
2654 %\D 3000&1&1&N&N&Y\\
2655 \D 30FB&1&6&N&Y&N\\
2656 \D 309B&1&11&N&Y&N\\
2657 \D 309C&1&12&N&Y&N\\
2658 \D FF40&1&14&N&N&Y\\
2659 \D FF3E&1&16&N&N&Y\\
2660 \D FFE3&1&17&N&N&Y\\
2661 \D FF3F&1&18&N&N&Y\\
2662 \D 30FD&1&19&N&Y&Y\\
2663 \D 30FE&1&20&N&Y&Y\\
2664 \D 309D&1&21&N&Y&Y\\
2665 \D 309E&1&22&N&Y&Y\\
2666 \D 3003&1&23&N&N&Y\\
2667 \D 4EDD&1&24&N&Y&Y\\
2668 \D 3005&1&25&N&N&Y\\
2669 \D 3006&1&26&N&N&Y\\
2670 \D 3007&1&27&N&N&Y\\
2671 \D 30FC&1&28&N&Y&Y\\
2672 \bottomrule
2673 \end{tabular}\qquad
2674 \begin{tabular}[t]{cccccc}
2675 \toprule
2676 %<en>&\textbf{row}&\textbf{col.}&\textbf{\pTeX}&\textbf{\upTeX}&\textbf{\LuaTeX-ja}\\
2677 %<ja>&\emph{区}&\emph{点}&\emph{\pTeX}&\emph{\upTeX}&\emph{\LuaTeX-ja}\\
2678 \midrule
2679 \D FF0F&1&31&N&N&Y\\
2680 \D FF3C&1&32&N&N&Y\\
2681 \D FF5E&1&33&N&N&Y\\
2682 \D FF5C&1&35&N&N&Y\\
2683 \D FF0B&1&60&N&N&Y\\
2684 \D FF1D&1&65&N&N&Y\\
2685 \D FF1C&1&67&N&N&Y\\
2686 \D FF1E&1&68&N&N&Y\\
2687 \D FF03&1&84&N&N&Y\\
2688 \D FF06&1&85&N&N&Y\\
2689 \D FF0A&1&86&N&N&Y\\
2690 \D FF20&1&87&N&N&Y\\
2691 \D 3012&2&9&N&N&Y\\
2692 \D 3013&2&14&N&N&Y\\
2693 \D FFE2&2&44&N&N&Y\\
2694 \D 212B&2&82&N&N&Y\\
2695 %<en>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}Greek letters (row 6)}&Y&N&Y\\
2696 %<en>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}Cyrillic letters (row 7)}&N&N&Y\\
2697 %<ja>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}ギリシャ文字(6区)}&Y&N&Y\\
2698 %<ja>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}キリル文字(7区)}&N&N&Y\\
2699 \bottomrule
2700 \end{tabular}\hss}\par
2701 \end{table}
2702
2703 %<*en>
2704 \subsection{Non-kanji characters in a control word}
2705 {\def\D#1{%
2706   {\fboxsep0pt\fcolorbox{cyan}{white}{#1}}}%
2707 Because the engine differ, so non-kanji JIS~X~0208 characters
2708 which can be used in a control word differ in \pTeX, in \upTeX,~and~in \LuaTeX-ja.
2709 \autoref{tab:kcat-diff} shows the difference.
2710 Except for three characters \D{・},~\D{゛},~and~`\D{゜},
2711 \LuaTeX-ja admits more characters in a control word than \upTeX.}
2712
2713 Difference becomes larger, if we consider
2714 non-kanji JIS~X~0213 characters.
2715 For the detail, see \url{https://github.com/h-kitagawa/kct}.
2716 %</en>
2717 %<*ja>
2718 \subsection{制御綴中に使用出来るJIS非漢字の違い}
2719
2720 エンジンが異なるので,\pTeX, \upTeX, \LuaTeX-ja
2721 において制御綴中に使用可能なJIS~X~0208の文字は異なる.
2722 異なっているところだけを載せると,\autoref{tab:kcat-diff}のようになる.
2723 「・」「゛」「゜」を除けば,\LuaTeX-jaでは\upTeX より多くの文字が
2724 制御綴に使用可能になっている.
2725
2726 JIS~X~0213の範囲に広げると,差異はさらに大きくなる.
2727 詳細については例えば \url{https://github.com/h-kitagawa/kct} 中の\
2728 \texttt{kct-out.pdf} などを参照すること.
2729 %</ja>
2730
2731
2732 %<*en>
2733 \section{Directions}
2734 \LuaTeX\ supports four $\Omega$-style directions: \texttt{TLT},~\texttt{TRT}, \texttt{RTT}
2735 and \texttt{LTL}.
2736 However, neither directions are not well-suited for typesetting Japanese vertically, hence we
2737 implemented vertical writing by rotating \texttt{TLT}-box by 90~degrees.
2738 %</en>
2739 %<*ja>
2740 \section{縦組}
2741 \label{sec-direction}
2742 \LuaTeX 本体でも,$\Omega$・$\aleph$由来の機能として,複数の組方向をサポートしている.
2743 しかし,\LuaTeX がサポートするのは \texttt{TLT},~\texttt{TRT}, \texttt{RTT},~\texttt{LTL}\
2744 のみであり,日本語の縦組に使うのは望ましくない\footnote{%
2745 和文文字だけならば \texttt{RTT} を使えばなんとかなると思うが,
2746 欧文文字が入ってきた場合はうまくいかず,\texttt{RTR} という組方向が必要になる.
2747 }.そのため,\LuaTeX-jaでは横組(\texttt{TLT})で組んだボックスを回転させる方式で
2748 縦組を実装した.
2749 %</ja>
2750
2751 %<ja>\subsection{サポートする組方向}
2752 \begin{table}[t]
2753 %<ja>\caption{\LuaTeX-ja のサポートする組方向}
2754 %<en>\caption{Directions supported by \LuaTeX-ja}
2755 %<en>\medskip
2756 \label{tab-dir}
2757 \centering\small
2758 \def\obox#1{%
2759   \setbox0=\hbox{\yoko\hbox{#1%
2760   \large\ltjsetparameter{talbaselineshift=0pt}%
2761   \vrule height 25pt width 0.4pt depth 15pt\kern-.2pt%
2762   \raise25pt\hbox to 0pt{\hss\composite{*r^@{>>}}\hss}%
2763   \raise-15pt\hbox to 0pt{\hss\composite{*l^@{>|}}\hss}\kern.2pt%
2764   \vrule height.2pt depth.2pt width 60pt\hbox to 0pt{\hss\composite{*d^@{>}}\hss}\kern-60pt
2765   \hbox to 60pt{\,銀は、Ag\hss}}}%
2766   \raise\dimexpr 0.5\ltjgetdp0-0.5\ltjgetht0\box0%
2767 }
2768 %<*ja>
2769 \begin{tabular}{>{\bfseries}lcccc}
2770 \toprule
2771 &横組&縦組 &「dtou方向」&「utod方向」\\
2772 \midrule
2773 命令&\cs{yoko}&\cs{tate}&\cs{dtou}&\cs{utod}\\
2774 字送り方向&水平右向き(→)&垂直下向き(↓)&垂直上向き(↑)&垂直下向き(↓)\\
2775 行送り方向&垂直下向き(↓)&水平左向き(←)&水平右向き(→)&水平左向き(←)\\
2776 使用する和文フォント&横組用(\cs{jfont})&縦組用(\cs{tfont})&
2777 \multicolumn{2}{c}{%
2778   横組用(\cs{jfont})の$90^\circ$回転}\\[\smallskipamount]
2779 組版例\null $^*$ &\obox{\yoko}&\obox{\tate}&\obox{\dtou}&\obox{\utod}\\
2780 \noalign{\medskip}
2781 \bottomrule
2782 \end{tabular}
2783
2784 \medskip\raggedright
2785 \def\R#1{%
2786   \raise0.38\zw\hbox{%
2787     \vrule height.2pt  depth.2pt width2\zw%
2788     \hbox to 0pt{\hss\composite{*d^@{#1}}\hss}%
2789   }%
2790 }
2791 $^*$\ 幅(width),高さ(height),深さ(depth)の増加方向を,
2792 それぞれ「\R{>}」,「\R{>>}」,「\R{>|}」で表している.
2793 \raggedright
2794 %</ja>
2795
2796 %<*en>
2797 \begin{tabular}{>{\bfseries}lcccc}
2798 \toprule
2799 &horizontal (\emph{yoko}~direction)&vertical (\emph{tate}~direction)&%
2800   \emph{dtou} direction&\emph{utod} direction\\
2801 \midrule
2802 Commands&\cs{yoko}&\cs{tate}&\cs{dtou}&\cs{utod}\\
2803 Beginning of the page&Top&Right&Left&Right\\
2804 Beginning of the line&Left&Top&Bottom&Top\\
2805 Used Japanese font&horizontal (\cs{jfont})&vertical (\cs{tfont})&
2806 \multicolumn{2}{c}{%
2807   horizontal ($90^\circ$ rotated)}\\[\smallskipamount]
2808 Example&\obox{\yoko}&\obox{\tate}&\obox{\dtou}&\obox{\utod}\\
2809 \noalign{\medskip}
2810 (Notation used in $\Omega$)&TLT&RTR, RTT&LBL&RTR\\
2811 \bottomrule
2812 \end{tabular}
2813
2814 \medskip\raggedright
2815 \def\R#1{%
2816   \raise0.38\zw\hbox{%
2817     \vrule height.2pt  depth.2pt width2\zw%
2818     \hbox to 0pt{\hss\composite{*d^@{#1}}\hss}%
2819   }%
2820 }
2821 \raggedright
2822 %</en>
2823 \end{table}
2824
2825 %<*en>
2826 \LuaTeX-ja supports four directions, as shown in \autoref{tab-dir}.
2827 The second column (\emph{yoko} direction) is just horizontal writing,
2828 and the third column (\emph{tate} direction) is vertical writing.
2829 The fourth column (\emph{dtou} direction) is actually a hidden feature of \pTeX.
2830 We implemented this for debugging purpose.
2831 The fifth column (\emph{utod} direction) corresponds the ``\texttt{tate (math) direction}'' of \pTeX.
2832
2833 Directions can be changed by \cs{yoko},~\cs{tate}, \cs{dtou},~\cs{utod},
2834 only when the current list is null.
2835 These commands cannot be executed in unrestricted horizontal modes, nor math modes.
2836 The direction of a math formula is changed to
2837 \emph{utod}, when the direction outside the math formula is \emph{tate} (vertical writing).
2838 %</en>
2839
2840 %<*ja>
2841 \LuaTeX-jaがサポートする組方向は\autoref{tab-dir}に示す4つである.
2842 4列目の \cs{dtou} は聞き慣れない命令だと思うが,
2843 実は\pTeX に同名の命令が(ドキュメントには書かれていないが)存在する.
2844 Down-TO-Upの意味なのだろう.\cs{dtou} を使用する機会はないだろうが,
2845 \LuaTeX-jaではデバッグ用に実装している.
2846 5列目の \cs{utod} は,\pTeX で言う「縦数式ディレクション」に相当するものである.
2847
2848 組方向は,\cs{yoko},~\cs{tate}, \cs{dtou},~\cs{utod} をそれぞれ使用することで,
2849 現在作成中のリストやボックスが空の時にのみ変更可能である.
2850 ただし,現在のモードが非制限水平モードや(文中,別行立て問わず)数式モードであるときには
2851 組方向を変更することは出来ない.
2852 また,縦組中の数式内のボックスは\pTeX と同じように組方向が \cs{utod} となる.
2853
2854 なお,\LaTeX の下で\LuaTeX-jaを使用する場合,組方向変更命令には
2855 「新たな組方向下での和文フォントを必要なら読み込み(・選択する)」という
2856 処理が付け加えられている(\ref{ssec:ltx-jfm}節参照).
2857 %</ja>
2858
2859 %<*en>
2860 \subsection{Boxes in different direction}
2861
2862 As in \pTeX, one can use boxes of different direction in one document.
2863 The below is an example.
2864 \begin{LTXexample}
2865 ここは横組%     yoko
2866 \hbox{\tate %   tate
2867   \hbox{縦組}%  tate
2868   の中に
2869   \hbox{\yoko 横組の内容}% yoko
2870   を挿入する
2871 }
2872 また横組に戻る% yoko
2873 \end{LTXexample}
2874
2875 \autoref{tab-diffdir} shows how a box is arranged when
2876 the direction  inside the box and that outside the box differ.
2877 %</en>
2878 %<*ja>
2879 \subsection{異方向のボックス}
2880
2881 縦組の中に「42」などの2桁以上の算用数字を横組で組むなど,
2882 異なる組方向を混在させることがしばしば行われる.
2883 組方向の混在も\pTeX と同じようにできる:
2884 \begin{LTXexample}
2885 ここは横組%     yoko
2886 \hbox{\tate %   tate
2887   \hbox{縦組}%  tate
2888   の中に
2889   \hbox{\yoko 横組の内容}% yoko
2890   を挿入する
2891 }
2892 また横組に戻る% yoko
2893 \end{LTXexample}
2894
2895 異なる組方向のボックスを配置した場合にどう組まれるかの仕様も,\pTeX を
2896 踏襲している.\autoref{tab-diffdir}に示す.
2897 %</ja>
2898
2899 \begin{table}[t]
2900 %<ja>\caption{異方向のボックスの配置}
2901 %<en>\caption{Boxes in different direction}
2902 %<en>\medskip
2903 \label{tab-diffdir}
2904  \centering\small\unitlength3mm
2905  \def\TATEeg{%
2906    \hbox{\smash{\begin{picture}(0,0)(-2,0)
2907      \thicklines
2908      \polyline(-2,0)(-2,-7)(5,-7)(5,0)
2909      \put(0,0){\circle*{0.3}}
2910      \put(2.5,-4){\makebox(0,0){\hbox{\tate\bfseries \emph{tate}/\emph{utod}}}}
2911      \put(0,0){\vector(1,0){5}} \put(2.5,-0.2){\makebox(0,0)[t]{$h_{\mathrm{T}}$}}
2912      \put(0,0){\vector(-1,0){2}}\put(-1,-0.2){\makebox(0,0)[t]{$d_{\mathrm{T}}$}}
2913      \put(0,0){\vector(0,-1){7}}\put(0.2,-3.5){\makebox(0,0)[l]{$w_{\mathrm{T}}$}}
2914    \end{picture}}}%
2915  }
2916  \def\DTOUeg{%
2917    \hbox{\smash{\begin{picture}(0,0)(-5,0)
2918      \thicklines
2919      \polyline(-5,0)(-5,7)(2,7)(2,0)
2920      \put(0,0){\circle*{0.3}}
2921      \put(-2.5,4){\makebox(0,0){\hbox{\dtou\bfseries \emph{dtou}}}}
2922      \put(0,0){\vector(-1,0){5}} \put(-2.5,0.3){\makebox(0,0)[b]{$h_{\mathrm{D}}$}}
2923      \put(0,0){\vector(1,0){2}}\put(1,0.3){\makebox(0,0)[b]{$d_{\mathrm{D}}$}}
2924      \put(0,0){\vector(0,1){7}}\put(-0.2,3.5){\makebox(0,0)[r]{$w_{\mathrm{D}}$}}
2925    \end{picture}}}%
2926  }
2927  \def\YOKOeg{%
2928    \hbox{\smash{\begin{picture}(0,0)
2929      \thicklines
2930      \polyline(0,5)(7,5)(7,-2)(0,-2)
2931      \put(4,2.5){\makebox(0,0){\hbox{\yoko\bfseries \emph{yoko}}}}
2932      \put(0,0){\circle*{0.3}}
2933      \put(0,0){\vector(0,1){5}} \put(0.3,2.5){\makebox(0,0)[l]{$h_{\mathrm{Y}}$}}
2934      \put(0,0){\vector(0,-1){2}}\put(0.3,-1){\makebox(0,0)[l]{$d_{\mathrm{Y}}$}}
2935      \put(0,0){\vector(1,0){7}}\put(3.5,0.2){\makebox(0,0)[b]{$w_{\mathrm{Y}}$}}
2936    \end{picture}}}%
2937  }
2938 \begin{tabular}{ccc}
2939 \toprule
2940 %<ja>\emph{横組中に配置}&\emph{縦組中に配置}&%
2941 %<ja>\emph{組方向 \cs{dtou} 中に配置}\\
2942 %<en>\textbf{typeset in \emph{yoko} direction}
2943 %<en>&\textbf{typeset in \emph{tate} or \emph{utod} direction}
2944 %<en>&\textbf{typeset in \emph{dtou} direction}\\
2945 \midrule
2946  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
2947    \put(0,0){\line(1,0){3.8}}
2948    \put(4,7){\TATEeg}
2949    \put(11.2,0){\line(1,0){3.8}}
2950 %
2951    \put(2,7){\line(1,0){1.8}}
2952    \put(3,3.5){\vector(0,1){3.5}\vector(0,-1){3.5}}
2953    \put(2.8,3.5){\makebox(0,0)[r]{$H_{\mathrm{Y}}$}}
2954    \put(3,-2){\vector(0,1){2}}
2955    \put(2.8,-1){\makebox(0,0)[r]{$D_{\mathrm{Y}}$}}
2956 %
2957    \put(4,7.2){\line(0,1){1.8}}
2958    \put(11,7.2){\line(0,1){1.8}}
2959    \put(6,8){\vector(-1,0){2}}
2960    \put(9,8){\vector(1,0){2}}
2961    \put(7.5,8){\makebox(0,0){$W_{\mathrm{Y}}$}}
2962 %
2963  \end{picture}\vspace{-\baselineskip}
2964    \begin{align*}
2965    W_{\mathrm{Y}} &= h_{\mathrm{T}}+d_{\mathrm{T}},\\
2966    H_{\mathrm{Y}} &= w_{\mathrm{T}},\\
2967    D_{\mathrm{Y}} &=0\,\mathrm{pt}
2968    \end{align*}%
2969  }&
2970  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
2971    \put(7.5,-0.2){\line(0,-1){2.8}}
2972    \put(4,2){\YOKOeg}
2973    \put(7.5, 7.2){\line(0,1){3.8}}
2974 %
2975    \put(2,7){\line(1,0){1.8}}
2976    \put(2,0){\line(1,0){1.8}}
2977    \put(3,5){\vector(0,1){2}}
2978    \put(3,2){\vector(0,-1){2}}
2979    \put(3,3.5){\makebox(0,0){$W_{\mathrm{T}}$}}
2980 %
2981    \put(4,7.2){\line(0,1){1.8}}
2982    \put(11,7.2){\line(0,1){1.8}}
2983    \put(8,8){\vector(-1,0){0.5}}\put(8,8){\vector(1,0){3}}
2984    \put(7,8){\vector(-1,0){3}}\put(7,8){\vector(1,0){0.5}}
2985    \put(9.25,8.2){\makebox(0,0)[b]{$H_{\mathrm{T}}$}}
2986    \put(5.75,8.2){\makebox(0,0)[b]{$D_{\mathrm{T}}$}}
2987 %
2988  \end{picture}\vspace{-\baselineskip}
2989    \begin{align*}
2990    W_{\mathrm{T}} &= h_{\mathrm{Y}}+d_{\mathrm{Y}},\\
2991    H_{\mathrm{T}} &= w_{\mathrm{Y}}/2,\\
2992    D_{\mathrm{T}} &= w_{\mathrm{Y}}/2
2993    \end{align*}%
2994  }&
2995  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
2996    \put(11,-0.2){\line(0,-1){2.8}}
2997    \put(4,2){\YOKOeg}
2998    \put(11, 7.2){\line(0,1){3.8}}
2999 %
3000    \put(2,7){\line(1,0){1.8}}
3001    \put(2,0){\line(1,0){1.8}}
3002    \put(3,5){\vector(0,1){2}}
3003    \put(3,2){\vector(0,-1){2}}
3004    \put(3,3.5){\makebox(0,0){$W_{\mathrm{D}}$}}
3005 %
3006    \put(4,7.2){\line(0,1){1.8}}
3007    \put(11,7.2){\line(0,1){1.8}}
3008    \put(7.5,8){\vector(-1,0){3.5}}\put(7.5,8){\vector(1,0){3.5}}
3009    \put(13,8){\vector(-1,0){2}}
3010    \put(7.5,8.2){\makebox(0,0)[b]{$H_{\mathrm{D}}$}}
3011    \put(12,8.2){\makebox(0,0)[b]{$D_{\mathrm{D}}$}}
3012 %
3013  \end{picture}\vspace{-\baselineskip}
3014    \begin{align*}
3015    W_{\mathrm{D}} &= h_{\mathrm{Y}}+d_{\mathrm{Y}},\\
3016    H_{\mathrm{D}} &= w_{\mathrm{Y}},\\
3017    D_{\mathrm{D}} &= 0\,\mathrm{pt}
3018    \end{align*}%
3019  }%
3020 \\\midrule
3021  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3022    \put(0,0){\line(1,0){3.8}}
3023    \put(4,0){\DTOUeg}
3024    \put(11.2,0){\line(1,0){3.8}}
3025 %
3026    \put(2,7){\line(1,0){1.8}}
3027    \put(3,3.5){\vector(0,1){3.5}}\put(3,3.5){\vector(0,-1){3.5}}
3028    \put(2.8,3.5){\makebox(0,0)[r]{$H_{\mathrm{Y}}$}}
3029    \put(3,-2){\vector(0,1){2}}
3030    \put(2.8,-1){\makebox(0,0)[r]{$D_{\mathrm{Y}}$}}
3031 %
3032    \put(4,7.2){\line(0,1){1.8}}
3033    \put(11,7.2){\line(0,1){1.8}}
3034    \put(6,8){\vector(-1,0){2}}
3035    \put(9,8){\vector(1,0){2}}
3036    \put(7.5,8){\makebox(0,0){$W_{\mathrm{Y}}$}}
3037 %
3038  \end{picture}\vspace{-\baselineskip}
3039    \begin{align*}
3040    W_{\mathrm{Y}} &= h_{\mathrm{D}}+d_{\mathrm{D}},\\
3041    H_{\mathrm{Y}} &= w_{\mathrm{D}},\\
3042    D_{\mathrm{Y}} &= 0\,\mathrm{pt}
3043    \end{align*}%
3044  }&
3045  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3046    \put(9,-0.2){\line(0,-1){2.8}}
3047    \put(4,0){\DTOUeg}
3048    \put(9, 7.2){\line(0,1){3.8}}
3049 %
3050    \put(2,7){\line(1,0){1.8}}
3051    \put(2,0){\line(1,0){1.8}}
3052    \put(3,5){\vector(0,1){2}}
3053    \put(3,2){\vector(0,-1){2}}
3054    \put(3,3.5){\makebox(0,0){$W_{\mathrm{T}}$}}
3055 %
3056    \put(4,7.2){\line(0,1){1.8}}
3057    \put(11,7.2){\line(0,1){1.8}}
3058    \put(6.5,8){\vector(-1,0){2.5}}\put(6.5,8){\vector(1,0){2.5}}
3059    \put(10,8){\vector(-1,0){1}}\put(10,8){\vector(1,0){1}}
3060    \put(10,8.2){\makebox(0,0)[b]{$H_{\mathrm{T}}$}}
3061    \put(6.5,8.2){\makebox(0,0)[b]{$D_{\mathrm{T}}$}}
3062 %
3063  \end{picture}\vspace{-\baselineskip}
3064    \begin{align*}
3065    W_{\mathrm{T}} &= h_{\mathrm{D}}+d_{\mathrm{D}},\\
3066    H_{\mathrm{T}} &= d_{\mathrm{D}},\\
3067    D_{\mathrm{T}} &= h_{\mathrm{D}}
3068    \end{align*}%
3069  }&
3070  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3071    \put(6,-0.2){\line(0,-1){2.8}}
3072    \put(4,7){\TATEeg}
3073    \put(6, 7.2){\line(0,1){3.8}}
3074 %
3075    \put(2,7){\line(1,0){1.8}}
3076    \put(2,0){\line(1,0){1.8}}
3077    \put(3,5){\vector(0,1){2}}
3078    \put(3,2){\vector(0,-1){2}}
3079    \put(3,3.5){\makebox(0,0){$W_{\mathrm{D}}$}}
3080 %
3081    \put(4,7.2){\line(0,1){1.8}}
3082    \put(11,7.2){\line(0,1){1.8}}
3083    \put(5,8){\vector(-1,0){1}}\put(5,8){\vector(1,0){1}}
3084    \put(8.5,8){\vector(-1,0){2.5}}\put(8.5,8){\vector(1,0){2.5}}
3085    \put(5,8.2){\makebox(0,0)[b]{$H_{\mathrm{D}}$}}
3086    \put(8.5,8.2){\makebox(0,0)[b]{$D_{\mathrm{D}}$}}
3087 %
3088  \end{picture}\vspace{-\baselineskip}
3089    \begin{align*}
3090    W_{\mathrm{D}} &= w_{\mathrm{T}},\\
3091    H_{\mathrm{D}} &= d_{\mathrm{T}},\\
3092    D_{\mathrm{D}} &= h_{\mathrm{T}}
3093    \end{align*}%
3094  }\\
3095 \bottomrule
3096 \end{tabular}
3097 \end{table}
3098
3099
3100
3101 %<*en>
3102 \paragraph{\cs{wd} and direction}
3103 In \pTeX, \cs{wd},~\cs{ht},~\cs{dp} means the dimensions of a box register
3104 \emph{with respact to the current direction}.
3105 This means that the value of \cs{wd0} etc.\ might differ when the current direction is
3106 different, even if \cs{box0} stores the same box.
3107 However, this no longer applies in \LuaTeX-ja.
3108
3109 \begin{LTXexample}
3110 % yoko direction
3111 \setbox0=\hbox to 20pt{foo}
3112 \the\wd0,~\hbox{\tate\vrule\the\wd0}
3113 \wd0=100pt
3114 \the\wd0,~\hbox{\tate \the\wd0}
3115 \end{LTXexample}
3116
3117 To access box dimensions \emph{with respect to current direction},
3118 one have to use the following commands instead of \cs{wd} wtc.
3119 \begin{cslist}
3120
3121  \item[\cs{ltjgetwd}\meta{num}\textrm{, }\cs{ltjgetht}\meta{num}\textrm{, }%
3122   \cs{ltjgetdp}\meta{num}]
3123 These commands return \emph{an internal dimension} of \cs{box\meta{num}} with respect to
3124 the current direction. One can use these in \cs{dimexpr} primitive, as the followings.
3125 \begin{lstlisting}
3126 \dimexpr 2\ltjgetwd42-3pt\relax, \the\ltjgetwd1701
3127 \end{lstlisting}
3128 The following is an example.
3129 \begin{LTXexample}[width=0.3\textwidth]
3130 \parindent0pt
3131 \setbox32767=\hbox{\yoko よこぐみ}
3132 \fboxsep=0mm\fbox{\copy32767}
3133 \vbox{\hsize=20mm
3134 \yoko YOKO \the\ltjgetwd32767, \\
3135   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3136 \vbox{\hsize=20mm\raggedleft
3137 \tate TATE \the\ltjgetwd32767, \\
3138   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3139 \vbox{\hsize=20mm\raggedleft
3140 \dtou DTOU \the\ltjgetwd32767, \\
3141   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3142 \end{LTXexample}
3143
3144  \item[\cs{ltjsetwd}\meta{num}=\meta{dimen}\textrm{, }\cs{ltjsetht}\meta{num}=\meta{dimen}\textrm{, }%
3145   \cs{ltjsetdp}\meta{num}=\meta{dimen}]
3146 These commands set the dimension of \cs{box\meta{num}}. One does not need
3147         to group the argument \meta{num}; four calls of \cs{ltjsetwd} below have the same meaning.
3148 \begin{lstlisting}
3149 \ltjsetwd42 20pt,  \ltjsetwd42=20pt,  \ltjsetwd=42 20pt,  \ltjsetwd=42=20pt
3150 \end{lstlisting}
3151
3152 \end{cslist}
3153 %</en>
3154 %<*ja>
3155 \paragraph{\cs{wd} 達と組方向}
3156 ボックスレジスタ \cs{box}\meta{num} にセットされているボックスの幅・高さ・深さの取得や
3157 変更にはそれぞれ \cs{wd},~\cs{ht},~\cs{dp} プリミティブを用いるのであった.
3158 \pTeX ではこれらのプリミティブは,「現在の組方向におけるボックスの寸法」を指すもので,
3159 同じボックスに対しても現在の組方向によって返る値は異なるものであった.
3160
3161 \LuaTeX-jaにおいては状況が異なり,\cs{wd},~\cs{ht},~\cs{dp} が返す値は
3162 現在の組方向には依存しない.下の例のように,横組のボックスが格納されていれば
3163 \cs{wd}等は常に「横組におけるボックスの寸法」を意味する.
3164
3165 \begin{LTXexample}
3166 % yoko direction
3167 \setbox0=\hbox to 20pt{foo}
3168 \the\wd0,~\hbox{\tate\vrule\the\wd0}
3169 \wd0=100pt
3170 \the\wd0,~\hbox{\tate \the\wd0}
3171 \end{LTXexample}
3172
3173 \pTeX のように現在の組方向に応じたボックスの寸法の取得・設定を行うには,
3174 代わりに次の命令を使用する.
3175
3176 \begin{cslist}
3177
3178  \item[\cs{ltjgetwd}\meta{num}\textrm{, }\cs{ltjgetht}\meta{num}\textrm{, }%
3179   \cs{ltjgetdp}\meta{num}]
3180 現在の組方向に応じたボックスの寸法の取得を行う.結果は内部長さであるため,
3181 \begin{lstlisting}
3182 \dimexpr 2\ltjgetwd42-3pt\relax, \the\ltjgetwd1701
3183 \end{lstlisting}
3184 のように \cs{wd}\meta{num} の代わりとして扱うことができる.
3185 使用例は以下の通りである.
3186 \begin{LTXexample}[width=0.3\textwidth]
3187 \parindent0pt
3188 \setbox32767=\hbox{\yoko よこぐみ}
3189 \fboxsep=0mm\fbox{\copy32767}
3190 \vbox{\hsize=20mm
3191 \yoko YOKO \the\ltjgetwd32767, \\
3192   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3193 \vbox{\hsize=20mm\raggedleft
3194 \tate TATE \the\ltjgetwd32767, \\
3195   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3196 \vbox{\hsize=20mm\raggedleft
3197 \dtou DTOU \the\ltjgetwd32767, \\
3198   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3199 \end{LTXexample}
3200
3201  \item[\cs{ltjsetwd}\meta{num}=\meta{dimen}\textrm{, }\cs{ltjsetht}\meta{num}=\meta{dimen}\textrm{, }%
3202   \cs{ltjsetdp}\meta{num}=\meta{dimen}]
3203 現在の組方向に応じたボックスの寸法の設定を行う.\cs{afterassignment} を2回利用して
3204 実装しているので,次の4通りは全て同じ意味である.
3205 \begin{lstlisting}
3206 \ltjsetwd42 20pt,  \ltjsetwd42=20pt,  \ltjsetwd=42 20pt,  \ltjsetwd=42=20pt
3207 \end{lstlisting}
3208
3209 設定値は「横組」「縦組またはutod方向」「dtou方向」
3210 の3種ごとに独立して記録される.参考として,Gitリポジトリ内の
3211               \verb+test/test55-boxdim_diffdir.{tex,pdf}+ を挙げておく.
3212
3213 \end{cslist}
3214 %</ja>
3215
3216 %<*en>
3217 \subsection{Getting current direction}
3218 The \Param{direction} parameter returns the current direction, and
3219 the \Param{boxdir} parameter (with the argument \meta{num})
3220 returns the direction of a box register \cs{box}\meta{num}.
3221 The returned value of these parameters are a \emph{string}:
3222 \begin{center}
3223 \small
3224 \begin{tabular}{>{\bfseries}lccccc}
3225 \toprule
3226 Direction&\emph{yoko}&\emph{tate}&\emph{dtou}&\emph{utod}&(empty)\\
3227 \midrule
3228 Returned value&\texttt{4}&\texttt{3}&\texttt{1}&\texttt{11}&\texttt{0}\\
3229 \bottomrule
3230 \end{tabular}
3231 \end{center}
3232 \begin{LTXexample}[width=0.3\textwidth]
3233 \leavevmode\def\DIR{\ltjgetparameter{direction}}
3234 \hbox{\yoko \DIR}, \hbox{\tate\DIR},
3235 \hbox{\dtou\DIR}, \hbox{\utod\DIR},
3236 \hbox{\tate$\hbox{tate math: \DIR}$}
3237
3238 \setbox2=\hbox{\tate}\ltjgetparameter{boxdir}{2}
3239 \end{LTXexample}
3240 %</en>
3241 %<*ja>
3242 \subsection{組方向の取得}
3243 「現在の組方向」や「\meta{num}番のボックスの組方向」は,
3244 \pTeX では \cs{ifydir} や \cs{ifybox}\meta{num} といった条件判断文を使って
3245 判断することができた.
3246 しかし,\LuaTeX-jaはあくまでも\TeX マクロとLuaコードで
3247 記述されており,それでは新たな条件判断命令を作るのは難しい.
3248
3249 \LuaTeX-jaでは,\Param{direction}パラメータで現在の組方向を,
3250 \Param{boxdir}パラメータ(と追加の引数\meta{num})によって
3251 \cs{box}\meta{num}の組方向をそれぞれ取得できるようにした.
3252 戻り値は文字列である:
3253 \begin{center}
3254 \small
3255 \begin{tabular}{>{\bfseries}lccccc}
3256 \toprule
3257 組方向&\emph{横組}&\emph{tate縦組}&\emph{dtou方向}&\emph{utod方向}&(未割り当て)\\
3258 \midrule
3259 戻り値&\texttt{4}&\texttt{3}&\texttt{1}&\texttt{11}&\texttt{0}\\
3260 \bottomrule
3261 \end{tabular}
3262 \end{center}
3263
3264 \begin{LTXexample}[width=0.3\textwidth]
3265 \leavevmode\def\DIR{\ltjgetparameter{direction}}
3266 \hbox{\yoko\DIR}, \hbox{\tate\DIR},
3267 \hbox{\dtou\DIR}, \hbox{\utod\DIR},
3268 \hbox{\tate$\hbox{tate math: \DIR}$}
3269
3270 \setbox2=\hbox{\tate}\ltjgetparameter{boxdir}{2}
3271 \end{LTXexample}
3272
3273 これらを用いれば,例えば
3274 \pTeX の \cs{ifydir},~\cs{ifybox200} と同等の条件判断を
3275 \begin{lstlisting}
3276 \ifnum\ltjgetparameter{direction}=4
3277 \ifnum\ltjgetparameter{boxdir}{200}=4
3278 \end{lstlisting}
3279 のように行うことができる.
3280 \cs{iftdir} は少々面倒であるが,8で割った余りが3であるか否かを判断すれば良いから
3281 \begin{lstlisting}
3282 \ifnum\numexpr
3283   \ltjgetparameter{direction}-(\ltjgetparameter{direction}/8)*8=3
3284 \end{lstlisting}
3285 とすればよい.
3286 %</ja>
3287
3288 %<*en>
3289 \section{Redefined primitives by \LuaTeX-ja}
3290 The following primitives are redefined by \LuaTeX-ja (using~\verb+\protected\def+),
3291 for supporting Japanese typesetting and multiple directions:
3292 \begin{cslist}[style=standard]
3293  \item[\cs{/}]
3294  \item[\cs{unhbox}\meta{num}\textrm{, }\cs{unvbox}\meta{num}\textrm{, }\cs{unhcopy}\meta{num}\textrm{, }\cs{unvcopy}\meta{num}]
3295  \item[\cs{vadjust}\{\meta{material}\}]
3296  \item[\cs{insert}\meta{number}\{\meta{material}\}]
3297  \item[\cs{lastbox}]
3298  \item[\cs{raise}\meta{dimen}\meta{box}\textrm{, }\cs{lower}\meta{dimen}\meta{box}\textrm{, }
3299    \cs{moveleft}\meta{dimen}\meta{box}\textrm{, }\cs{moveright}\meta{dimen}\meta{box}\textrm{, }]
3300  \item[\cs{split}\meta{number}to\meta{dimen}\textrm{, }\cs{vcenter}\{\meta{material}\}]
3301 \end{cslist}
3302
3303 On each primitive \cs{\meta{primitive}} in the list above,
3304 its meaning just before loading \LuaTeX-ja is backed up into \cs{ltj@@orig@\meta{primitive}},
3305 and the meaning after redefinition by \LuaTeX-ja is stored in \cs{ltj@@\meta{primitive}}.
3306 For example, \autoref{fig:primitive_meaning} shows the situation of \cs{vadjust} primitive.
3307 %</en>
3308 %<*ja>
3309 \section{プリミティブの再定義}
3310 \LuaTeX-jaでは和文組版や異なる組方向に対応するために,以下に挙げるプリミティブは
3311 \ \verb+\protected\def+ により再定義を行っている.
3312
3313 \begin{cslist}
3314  \item[\cs{/}]
3315  和文フォントに対するイタリック補正のサポートが追加されている.
3316  \item[\cs{unhbox}\meta{number}\textrm{, }\cs{unvbox}\meta{number}\textrm{, }\cs{unhcopy}\meta{number}\textrm{, }\cs{unvcopy}\meta{number}]
3317  ボックスの組方向が現在のリストと異なる場合は事前にエラーメッセージを出力する.
3318  \pTeX と異なり,エラーを無視して無理矢理 \cs{unhbox}, \cs{unvbox} 等を
3319  続行させることもできるが,その場合の組版結果は保証しない.
3320  \item[\cs{vadjust}\{\meta{material}\}] 一旦プリミティブ本来の挙動を行う.その後,\meta{material}の組方向が
3321  周囲の垂直リストの組方向と一致しない場合にエラーを出力し,
3322  該当の \cs{vadjust} を無効にする.
3323  \item[\cs{insert}\meta{number}\{\meta{material}\}]
3324  一旦プリミティブ本来の挙動を行い,その後\meta{material}内の各ボックス・罫線の直前に組方向を示
3325               すdirection whatsitを挿入する.
3326  \item[\cs{lastbox}] ボックスの「中身」を現在の組方向に合わせるためのノード
3327               (\textit{dir\_box}という)を必要ならば除去し,
3328  正しく「中身」のボックスが返されるように前処理をする.
3329  \item[\cs{raise}\meta{dimen}\meta{box}\textrm{, }\cs{lower}\meta{dimen}\meta{box}\textrm{, }
3330    \cs{moveleft}\meta{dimen}\meta{box}\textrm{, }\cs{moveright}\meta{dimen}\meta{box}\textrm{, }]
3331   \leavevmode\vspace{-\baselineskip}
3332  \item[\cs{split}\meta{number}to\meta{dimen}\textrm{, }\cs{vcenter}\{\meta{material}\}]
3333  これらのプリミティブについては必要に応じて\textit{dir\_box}を作成する前処理を追加している.
3334 \end{cslist}
3335
3336 上記の一覧中にあるプリミティブ\cs{\meta{primitive}}については,
3337 \LuaTeX-ja読み込み前の意味が\cs{ltj@@orig@\meta{primitive}}に,
3338 そして\LuaTeX-jaによる再定義後の意味が\cs{ltj@@\meta{primitive}}に保存される.
3339 例えば,\cs{vadjust}については\autoref{fig:primitive_meaning}のようになっている.
3340 %</ja>
3341 \begin{figure}
3342 \begin{LTXexample}[width=.55\textwidth]
3343 \makeatletter\scriptsize\ttfamily
3344 \meaning\vadjust        \\ % current
3345 \meaning\ltj@@vadjust   \\ % LuaTeX-ja
3346 \meaning\ltj@@orig@vadjust % original
3347 \end{LTXexample}
3348 \caption{Redefining \cs{vadjust} primitive by \LuaTeX-ja}
3349 \label{fig:primitive_meaning}
3350 \end{figure}
3351
3352 %<*en>
3353 \subsection{Suppressing redefinitions}
3354 Sometimes redefining primitives by \LuaTeX-ja causes a problem.
3355 For example, the \Pkg{breqn} package~(v0.98k) assumes that \cs{vadjust}~and~\cs{insert} have
3356 their primitive meanings.
3357 So, this package cannot by loaded after \LuaTeX-ja by default.
3358
3359 \LuaTeX-ja version~20210517.0 has features for that problem. Namely:
3360 \begin{itemize}
3361   \item Primitives which is listed in \cs{ltj@stop@overwrite@primitive} are 
3362   retain their meanings at just before loading \LuaTeX-ja.
3363   \item After loading \LuaTeX-ja,
3364   one can specify primitives to \cs{ltj@overwrite@primitive}, to redefine them by \LuaTeX-ja.
3365 \end{itemize}
3366 See \autoref{fig:primitive_overwrite} for an example.
3367 %</en>
3368 %<*ja>
3369 \subsection{再定義の抑制}
3370 場合によっては\LuaTeX-jaによるプリミティブの再定義が不都合を起こすこともある.
3371 たとえば,\Pkg{breqn}パッケージ(少なくともv0.98k, 2020\nobreakdash-09\nobreakdash-24))は
3372 読み込み時に\cs{vadjust}, \cs{insert}がプリミティブのままであることを要請するので,
3373 このままでは\LuaTeX-jaの後で読み込むことはできない.
3374
3375 この状況に対応するため,バージョン20210517.0以降では
3376 \begin{itemize}
3377   \item 制御綴\cs{ltj@stop@overwrite@primitive}内に並べられたプリミティブは,
3378   \LuaTeX-ja読み込み直前時の意味のままとなる.
3379   \item \LuaTeX-ja読み込み後に
3380   \cs{ltj@overwrite@primitive}に引数として与えたプリミティブを与えることで,
3381   それらを「\LuaTeX-jaによって再定義する」際の意味に再定義する
3382 \end{itemize}
3383 機能を導入した.使用例については\autoref{fig:primitive_overwrite}を参照.
3384 %</ja>
3385 \begin{figure}
3386 \begin{lstlisting}
3387 \makeatletter
3388 \def\ltj@stop@overwrite@primitive{\insert\vadjust\/\unhbox\vcenter\fontseries}
3389 \makeatother
3390   %% Keep the meaning of \insert, \vadjust, \/, \unhbox and \vcenter.
3391   %% \fontseries will still be redefined by \LuaTeX-ja, because it is not primitive.
3392 \usepackage{luatexja}
3393 ...
3394 \usepackage{breqn}
3395 ...
3396 \makeatletter
3397 \ltj@overwrite@primitive\expandafter{\insert\vadjust\/\unhbox\vcenter}
3398 \makeatother
3399   %% Redefine \insert, \vadjust, \/, \unhbox and \vcenter.
3400 \end{lstlisting}
3401 \caption{\cs{ltj@stop@overwrite@primitive} and \cs{ltj@overwrite@primitive}}
3402 \label{fig:primitive_overwrite}
3403 \end{figure}
3404
3405 %<en>\section{Font Metric and Japanese Font}
3406 %<ja>\section{フォントメトリックと和文フォント}
3407 %<en>\subsection{\cs{jfont}}
3408 %<ja>\subsection{\cs{jfont} 命令}
3409 \label{ssec:jfont}
3410
3411 %<*en>
3412 To load a font as a Japanese font (for horizontal direction), you must use the
3413 \cs{jfont} instead of~\cs{font}, while
3414 \cs{jfont} admits the same syntax used in~\cs{font}.
3415 \LuaTeX-ja automatically loads \Pkg{luaotfload} package,
3416 so TrueType/OpenType fonts with features can be used for Japanese fonts:
3417 %</en>
3418 %<*ja>
3419 フォントを(横組用)和文フォントとして読み込むためには,\cs{jfont} を
3420 \ \cs{font} プリミティブの代わりに用いる.
3421 \cs{jfont} の文法は \cs{font} と同じである.
3422 \LuaTeX-jaは\Pkg{luaotfload}パッケージを自動的に読み込むので,
3423 TrueType/OpenTypeフォントにfeatureを指定したものを和文フォントとして用いる
3424 ことができる:
3425 %</ja>
3426 \begin{LTXexample}[width=0.25\textwidth]
3427 \jfont\tradmc={IPAexMincho:script=latn;%
3428   +trad;-kern;jfm=ujis} at 14pt
3429 \tradmc 当/体/医/区
3430 \end{LTXexample}
3431
3432 %<*en>
3433 It is required to specify a (horizontal) \emph{JFM} in at each calling of \cs{jfont}.
3434 A JFM is a Lua script which contains
3435 measurements of characters and glues/kerns that are automatically
3436 inserted for Japanese typesetting.
3437 The structure of JFM will be described in the next subsection.
3438 %</en>
3439 %<*ja>
3440 \cs{jfont}命令の実行ごとにどの(横組用)JFMを用いるのかを指定する必要がある.
3441 JFMは文字の寸法情報と和文組版で自動的に挿入される
3442 グルー/カーンの寸法情報を持っているLuaスクリプトで,その構造は次の節で述べる.
3443 %</ja>
3444
3445 %<*en>
3446 Note that the defined control sequence
3447 (\cs{tradmc} in the example above) using \cs{jfont} is not a
3448 \textit{font\_def} token,  but a macro.
3449 Hence the input like \verb+\fontname\tradmc+
3450 causes a error.  We denote control sequences which are defined in
3451 \cs{jfont} by \meta{jfont\_cs}.
3452 %</en>
3453 %<*ja>
3454 なお,\cs{jfont} で定義された制御綴(上の例だと \cs{tradmc})
3455 は\textit{font\_def}トークンではなくマクロである.従って,\verb+\fontname\tradmc+のような
3456 入力はエラーとなる.以下では \cs{jfont} で定義された
3457 制御綴を\meta{jfont\_cs}で表す.
3458 %</ja>
3459
3460 %<en>\paragraph{Specifying JFM}
3461 %<ja>\paragraph{JFMの指定}
3462 %<en> The general scheme for specifying a JFM is the following:
3463 %<ja> JFMの一般的な指定は次のようになっている:
3464 \begin{quote}
3465   \cs{jfont}\meta{jfont\_cs}\texttt{=...;jfm=}\meta{JFM name}[\texttt{/\{}\meta{JFM features}\texttt{\}}]%
3466   \texttt{;...;}[\texttt{jfmvar=}\meta{identifier}]\texttt{;...}
3467 \end{quote}
3468
3469 \begin{figure}
3470 \begin{LTXexample}[width=0.3\textwidth]
3471 \ltjsetparameter{differentjfm=both}
3472 \jfont\F=HaranoAjiMincho-Regular:jfm=ujis
3473 \jfont\G=HaranoAjiGothic-Medium:jfm=ujis
3474 \jfont\H=HaranoAjiGothic-Medium:jfm=ujis;jfmvar=hoge
3475 \F ){\G 【】}( % halfwidth space
3476    ){\H 『』}( % fullwidth space
3477
3478 ほげ,{\G 「ほげ」}(ほげ)\par
3479 ほげ,{\H 「ほげ」}(ほげ)% pTeX-like
3480
3481 \ltjsetparameter{differentjfm=paverage}
3482 \end{LTXexample}
3483 \caption{Example of \texttt{jfmvar} key}
3484 \label{fig:jfmvar}
3485 \end{figure}
3486
3487 %<*en>
3488 \begin{description}
3489 \item[\meta{JFM name}]
3490   The name of a (horizontal) JFM. \LuaTeX-ja searches and loads \texttt{jfm-\meta{JFM name}.lua}
3491   \footnote{When \LuaTeX-ja (version~20230409 or later)
3492     is used under \LaTeXe, \LuaTeX-ja searches a JFM also in directories
3493     which are specified in \cs{input@path}.}.
3494 \item[\meta{JFM features}]
3495   An optional comma-separated list of JFM options.
3496   Enclosing braces (\verb+{}+) are optional, but this does not escape any characters.
3497   The contents of this list can be accessed by a table \texttt{luatexja.jfont.jfm\_feature}
3498   from a JFM, at its loading. See \autoref{fig:jfmfeat} for an example.
3499
3500   Note that any JFM files which is shipped with \LuaTeX-ja does not use this feature.
3501 \item[\meta{identifier}]
3502   An optional string.
3503 \end{description}
3504
3505 LuaTeX-ja ``does not distinguish'' two Japanese fonts which uses same JFM and are the same size.
3506 Here ``uses same JFM'' means that all~of \meta{JFM name}, \meta{JFM features}~and~\meta{identifier} of two fonts
3507 agree.
3508
3509 For example, The first ``)'' and ``【'' in \autoref{fig:jfmvar} are typeset in different real fonts.
3510 However, because they use the same JFMs and their size are same,
3511 \LuaTeX-ja inserts penalties, glues and kerns as if these two character are typeset in a same font.
3512 Namely, the glue between these characters is halfwidth, as in ``)\nobreak【''.
3513 However, this does not applies with \cs{F}~and~\cs{H} in \autoref{fig:jfmvar},
3514 because their \meta{identifier} are different.
3515 %</en>
3516 %<*ja>
3517 \begin{description}
3518 \item[\meta{JFM name}]
3519   (横組用)JFMの名称.\LuaTeX-jaは\texttt{jfm-\meta{JFM name}.lua}というファイルを探索して読み込む
3520   \footnote{\LuaTeX-ja 20230409.0以降では,\LaTeXe 下で読み込まれた場合には
3521     \cs{input@path}で指定された箇所も加えてJFMを探索する.}.
3522 \item[\meta{JFM features}]
3523   省略可能なコンマ区切りリスト.全体を囲む \verb+{}+ は省略可能であるが,
3524   囲ったからといって\meta{JFM features}の中で使用可能な文字が増えるわけではない.
3525   \meta{JFM features}で指定された内容は,テーブル\texttt{luatexja.jfont.jfm\_feature}として
3526   JFM読み込み時に(JFMから)アクセス可能である.\autoref{fig:jfmfeat}に使用例を載せた.
3527
3528   なお,\LuaTeX-jaが標準で提供するJFMではこの機能は用いられていない.
3529 \item[\meta{identifier}]
3530   省略可能な文字列.
3531 \end{description}
3532
3533 \LuaTeX-jaはJFMとサイズが同じで,
3534   実フォントだけが異なる2つの和文フォントは「区別されない」.
3535 ここで「JFMが同じ」とは,両フォントの\meta{JFM name}, \meta{JFM features}, \meta{identifier}が
3536 全て一致することである.
3537
3538 例えば\autoref{fig:jfmvar}において,最初の「)」と「【」の実フォントは異なるが,
3539 JFMもサイズも同じなので,普通に「)\nobreak【」と入力した時と同じように組まれる,つまり両文字の間は半角空きとなる.
3540
3541 しかし,JFMとサイズが同じであっても,\texttt{jfmvar}キーの値\meta{identifier}の異なる
3542 2つの和文フォント,例えば\autoref{fig:jfmvar}で言う\cs{F}と\cs{H},
3543 は「区別される」.異なる和文フォントに異なる \texttt{jfmvar}キーを割り当て,
3544 かつ\Param{differentjfm}パラメータを\texttt{both}に設定すれば,
3545 \pTeX と似た状況で組版されることになる.
3546 %</ja>
3547
3548 \def\T#1{\texttt{#1}}
3549 \def\printjfmfeat#1{%
3550   \relax\texttt{\string#1}: 
3551   \directlua{%
3552     if myjfm then
3553     for i,v in pairs(myjfm) do
3554       tex.sprint('[\string\\T{' .. i .. '}]${}={}$')
3555       if type(v)=='string' then
3556         tex.sprint('``\string\\T{' .. tostring(v) .. "}'', ")
3557       else
3558         tex.sprint(tostring(v) ..', ')
3559       end
3560     end
3561     else tex.sprint('(nil)')
3562     end
3563   }\par
3564 }
3565 \begin{figure}
3566 \begin{LTXexample}[pos=t]
3567 \small\ltjsetparameter{differentjfm=both}\tabcolsep=.5\zw
3568   % \printjfmfeat is defined in the source of this document
3569 \jfont\A=HaranoAjiMincho-Regular:jfm=testf                   at 9pt \printjfmfeat\A
3570 \jfont\B=HaranoAjiMincho-Bold:jfm=testf/kern=0.5,-ps,+kana   at 9pt \printjfmfeat\B
3571 \jfont\C=HaranoAjiGothic-Regular:jfm=testf/kern=0.5,down=0.2 at 9pt \printjfmfeat\C
3572 \jfont\D=HaranoAjiGothic-Bold:jfm=testf/down=0.2,kern=0.5    at 9pt \printjfmfeat\D
3573 \def\TEST#1{\string#1&{#1あ漢}{\A イ字}&{#1あ漢}{\B イ字}&{#1あ漢}{\C イ字}&{#1あ漢}{\D イ字}}
3574 \vspace{-4\baselineskip}\hfill\ttfamily
3575 \begin{tabular}{lllll}
3576   &\string\A&\string\B&\string\C&\string\D\\\TEST\A\\\TEST\B\\\TEST\C\\\TEST\D\\
3577 \end{tabular}
3578   % No space between ``漢'' and ``イ'' iff two Japanese fonts uses same JFM
3579 \ltjsetparameter{differentjfm=paverage}
3580 \end{LTXexample}
3581
3582 \caption{Example of JFM features}
3583 \label{fig:jfmfeat}
3584 \end{figure}
3585
3586 %<en>\paragraph{Horizontal JFMs}
3587 %<ja>\paragraph{横組用JFM}
3588 \begin{table}[t]
3589 %<en>\caption{Differences between horizontal JFMs shipped with \LuaTeX-ja}
3590 %<ja>\caption{\LuaTeX-ja に同梱されている横組用JFMの違い}
3591 %<en>\medskip
3592 \label{tab-difjfm}
3593 \ltjsetparameter{jacharrange={+3}}
3594 \centering\small
3595 \def\r#1#2{%
3596   \hbox{\Large\vrule
3597   \parbox[b]{7\zw}{%
3598     \addjfontfeatures{YokoFeatures={JFM=#1}}\noindent
3599         \color{#2}\transparent{0.5}%
3600     ◆◆◆◆◆◆◆
3601     ある日モモちゃんがお使いで迷子になって泣きました.
3602   }\vrule}}
3603 \def\s#1#2{%
3604   \Large
3605   \parbox[b]{7\zw}{%
3606     \addjfontfeatures{YokoFeatures={JFM=#1}}\noindent
3607         \color{#2}\transparent{0.5}
3608     ちょっと!何
3609   }}
3610 \def\t#1#2#3{\hbox to 0pt{\hss%
3611   \setbox0=\hbox{\addjfontfeatures{YokoFeatures={JFM=#1}}\huge #3}%
3612   \textcolor{#2}{\transparent{0.5}\vrule width 0.4pt height\ht0 depth\dp0}\kern-.2pt\copy0
3613   \textcolor{#2}{\transparent{0.5}\kern-\wd0\vrule width\wd0height .2pt depth .2pt
3614   \kern-\wd0\raise\ht0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3615   \kern-\wd0\lower\dp0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3616   \kern-.2pt\vrule width 0.4pt height\ht0 depth \dp0}\hss}}
3617 {\Large\tabcolsep0pt
3618 \begin{tabular}{m{8\zw}m{8\zw}m{8\zw}}
3619 \leavevmode\hbox to 0pt{\r{ujis}{blue}\hss}\r{jis}{black}&
3620 \leavevmode\hbox to 0pt{\r{jis}{black}\hss}\r{min}{red}&
3621 \leavevmode\hbox to 0pt{\r{ujis}{blue}\hss}\r{min}{red}\\
3622 \leavevmode\hbox to 0pt{\s{ujis}{blue}\hss}\s{jis}{black}&
3623 \leavevmode\hbox to 0pt{\s{jis}{black}\hss}\s{min}{red}&
3624 \leavevmode\hbox to 0pt{\s{ujis}{blue}\hss}\s{min}{red}\\
3625 \leavevmode\qquad\t{ujis}{blue}{漢}\t{jis}{black}{漢}\qquad
3626            \t{ujis}{blue}{っ}\t{jis}{black}{っ}&
3627 \leavevmode\qquad\t{jis}{black}{漢}\t{min}{red}{漢}\qquad
3628            \t{jis}{black}{っ}\t{min}{red}{っ}&
3629 \leavevmode\qquad\t{ujis}{blue}{漢}\t{min}{red}{漢}\qquad
3630            \t{ujis}{blue}{っ}\t{min}{red}{っ}\\
3631 \end{tabular}\par}
3632
3633 (\textcolor{blue}{Blue: \texttt{jfm-ujis.lua}},
3634 \textcolor{black}{Black: \texttt{jfm-jis.lua}},
3635 \textcolor{red}{Red: \texttt{jfm-min.lua}})
3636 \ltjsetparameter{jacharrange={-3}}
3637 \end{table}
3638
3639 %<en> The following horizontal JFMs are shipped with \LuaTeX-ja.
3640 %<ja> 以下の横組用JFMが\LuaTeX-jaには同梱されている:
3641 \begin{description}
3642 %<*en>
3643 \item[\texttt{jfm-ujis.lua}] A standard horizontal JFM of \LuaTeX-ja. This file is
3644   based on \verb+upnmlminr-h.tfm+, a metric for UTF/OTF package that
3645   is used in \upTeX. When you are going to use the \Pkg{luatexja-otf} package, you should use this JFM.
3646 %</en>
3647 %<*ja>
3648 \item[\texttt{jfm-ujis.lua}] \LuaTeX-jaの標準JFMファイルであり,このJFMは\upTeX で
3649   用いられるUTF/OTFパッケージ用の和文用TFMである \verb+upnmlminr-h.tfm+ を
3650   元にしている.\Pkg{luatexja-otf}パッケージを使うときはこのJFMを指定するべきである.
3651 %</ja>
3652 %<*en>
3653 \item[\texttt{jfm-jis.lua}] A counterpart for \verb+jis.tfm+, ``JIS font
3654   metric'' which is widely used in \pTeX. A major difference between
3655   \texttt{jfm-ujis.lua} and this \texttt{jfm-jis.lua} is that
3656   most characters under \texttt{jfm-ujis.lua} are square-shaped,
3657   while that under \texttt{jfm-jis.lua} are horizontal
3658   rectangles.
3659 %</en>
3660 %<*ja>
3661 \item[\texttt{jfm-jis.lua}] \pTeX で広く用いられている「JISフォントメトリック」
3662   \verb+jis.tfm+ に相当するJFMである.\texttt{jfm-ujis.lua} とこの
3663   \texttt{jfm-jis.lua} の主な違いは,\texttt{jfm-ujis.lua} ではほとんどの文字が
3664   正方形状であるのに対し,\texttt{jfm-jis.lua} では横長の長方形状であることと,
3665   \texttt{jfm-ujis.lua} では「?」「!」の直後に半角空白が挿入されることである.
3666 %</ja>
3667 %<*en>
3668 \item[\texttt{jfm-min.lua}] A counterpart for \verb+min10.tfm+, which is one
3669   of the default Japanese font metric shipped with \pTeX.
3670 %</en>
3671 %<*ja>
3672 \item[\texttt{jfm-min.lua}] \pTeX に同梱されているデフォルトの和文用TFM
3673 (\verb+min10.tfm+)に相当し,行末で文字が揃うようにするために「っ」など一部の文字幅が変わっ
3674            ている.\verb+min10.tfm+ については\cite{min10}が詳しい.
3675 %</ja>
3676 %<*en>
3677 \item[\texttt{jfm-prop.lua}] A JFM for proportional typesetting.
3678   This JFM doesn't have any information of character dimension (width, height, depth), nor glues/kerns information.
3679 %</en>
3680 %<*ja>
3681 \item[\texttt{jfm-prop.lua}] プロポーショナル組用のJFM.
3682   文字幅・高さ・深さの情報も自動挿入されるグルー・カーンの情報は持たない(つまりグリフの文字幅をそのまま採用する).
3683 %</ja>
3684 %<*en>
3685 \item[\texttt{jfm-propw.lua}] Another JFM for proportional typesetting.
3686   In contrast to \texttt{jfm-prop.lua}, this JFM has informations of character height and depth.
3687 %</en>
3688 %<*ja>
3689 \item[\texttt{jfm-propw.lua}] プロポーショナル組用のさらなるJFM.
3690   \texttt{jfm-prop.lua}と異なり,高さ・深さの情報は持っている.
3691 %</ja>
3692 \end{description}
3693 %<*en>
3694 See \autoref{tab-difjfm} for the difference among \texttt{jfm-ujis.lua}, \texttt{jfm-jis.lua},
3695 \texttt{jfm-min.lua}.
3696 %</en>
3697 %<*ja>
3698 \texttt{jfm-ujis.lua}, \texttt{jfm-jis.lua},
3699 \texttt{jfm-min.lua}の違いは\autoref{tab-difjfm}に示した.表中の文例の一部には,
3700 \cite{min10}の図3,~4のものを用いた.
3701 %</ja>
3702
3703 \begin{figure}
3704 \begin{LTXexample}[pos=t]
3705 \newcommand\test{\vrule ダイナミックダイクマ\vrule\\}
3706 \jfont\KMFW = HaranoAjiMincho-Regular:jfm=prop;-kern at 17.28pt
3707 \jfont\KMFK = HaranoAjiMincho-Regular:jfm=prop at 17.28pt % kern is activated
3708 \jfont\KMPW = HaranoAjiMincho-Regular:jfm=prop;script=dflt;+palt;-kern at 17.28pt
3709 \jfont\KMPK = HaranoAjiMincho-Regular:jfm=prop;script=dflt;+palt;+kern at 17.28pt
3710 \begin{multicols}{2}
3711 \ltjsetparameter{kanjiskip=0pt}
3712 {\KMFW\test \KMFK\test \KMPW\test \KMPK\test}
3713
3714 \ltjsetparameter{kanjiskip=3pt}
3715 {\KMFW\test \KMFK\test \KMPW\test \KMPK\test}
3716 \end{multicols}
3717 \end{LTXexample}
3718 \caption{Kerning information and \Param{kanjiskip}}
3719 \label{fig:kern-jfm}
3720 \end{figure}
3721
3722 %<en>\paragraph{Using kerning information in a font}
3723 %<ja>\paragraph{ペアカーニング情報の使用}
3724 \label{para-kern}
3725 %<*en>
3726 Some fonts have information for inter-glyph spacing.
3727 \LuaTeX-ja 20140324.0 or later treats kerning spaces like an italic correction;
3728 any glue and/or kern from the JFM and a kerning space from the font can coexist.
3729 See \autoref{fig:kern-jfm} for detail.
3730
3731 At version~20220411.0, defaults Japanese fonts which are defined
3732 at the loading of \LuaTeX-ja, \Pkg{ltjclasses},~and~\Pkg{ltjsclasses}
3733 do not insert font-derived kerning spaces by default.
3734 This is because standard JFMs do not expect font-derived kerning spaces
3735 between Japanese characters.
3736
3737 Also note that in \cs{setmainjfont} etc.\ which are provided by \Pkg{luatexja-fontspec}
3738 package, kerning option is set \emph{off} (\texttt{Kerning=Off}) by default.
3739 This means the following two lines have the same meaning:
3740 \begin{lstlisting}
3741 \setmainjfont{HaranoAjiMincho-Regular}
3742 \setmainjfont[Kerning=Off]{HaranoAjiMincho-Regular}
3743 \end{lstlisting}
3744
3745 %</en>
3746 %<*ja>
3747 いくつかのフォントはグリフ間のスペースについての情報を持っている.
3748 このカーニング情報は以前の\LuaTeX-ja とはあまり相性が良くなかったが,
3749 バージョン20140324.0以降ではカーニングによる空白はイタリック補正と同様に扱うことになっている.
3750 つまり,カーニング由来の空白とJFM由来のグルー・カーンは同時に入ることがある.
3751 \autoref{fig:kern-jfm}を参照.
3752 \begin{itemize}
3753  \item \emph{\cs{jfont} や,NFSS2用の命令(\ref{ssec:chgfnt}節,\ref{ssec:nfsspat}節)では,
3754 カーニング情報を使用する設定(OpenType機能\texttt{kern})はとくに指定しなくても有効になる}.
3755 すなわち,以下の2行目と3行目,5行目と6行目はそれぞれ等価である:
3756 \begin{lstlisting}[numbers=left]
3757 \jfont\hoge=hogem:jfm=ujis;-kern at 3.5mm % ==> kern 無効(明示)
3758 \jfont\hoge=hogem:jfm=ujis at 3.5mm       % ==> kern 有効(暗黙)
3759 \jfont\hoge=hogem:jfm=ujis;+kern at 3.5mm % ==> kern 有効(明示)
3760 \DeclareFontShape{JY3}{fuga}{m}{n}{<-> s*hogem:jfm=-ujis}{}    % ==> kern 無効(明示)
3761 \DeclareFontShape{JY3}{fuga}{m}{n}{<-> s*hogem:jfm=ujis}{}     % ==> kern 有効(暗黙)
3762 \DeclareFontShape{JY3}{fuga}{m}{n}{<-> s*hogem:jfm=ujis+kern}{}% ==> kern 有効(明示)
3763 \end{lstlisting}
3764
3765 \item バージョン20220411.0以降では,\LuaTeX-ja読み込み時や,\Pkg{ltjclasses}, \Pkg{ltjsclasses}において
3766   和文フォントを
3767 \begin{lstlisting}
3768 \jfont\tenmin=\ltj@stdmcfont:-kern;jfm=\ltj@stdyokojfm\space at 9.62216pt
3769 \DeclareFontShape{JY3}{mc}{m}{n}{<-> s*[\ifdefined\Cjascale\Cjascale\else 0.962216\fi]
3770   \ltj@stdmcfont:-kern;jfm=\ltj@stdyokojfm}{}
3771 \end{lstlisting}
3772   とOpenType機能\texttt{kern}を明示的に無効化した状態で定義する.
3773   これは標準JFM(\texttt{jfm-ujis.lua}, \texttt{jfm-ujisv.lua})が
3774   フォント由来のカーニングが入ることを期待していないためである.
3775
3776  \item
3777 一方,\emph{\Pkg{luatexja-fontspec} の提供する \cs{setmainjfont}\
3778 などの命令の標準設定ではカーニング情報は使用しない}(\texttt{Kerning=Off}).
3779 すなわち,次の2行は等価である:
3780 \begin{lstlisting}
3781 \setmainjfont{HaranoAjiMincho-Regular}
3782 \setmainjfont[Kerning=Off]{HaranoAjiMincho-Regular}
3783 \end{lstlisting}
3784 これは前項目の理由の他に,以前のバージョンの\LuaTeX-jaとの互換性のためもある.
3785 \end{itemize}
3786 %</ja>
3787
3788 %<*ja>
3789 \paragraph{\texttt{extend}と\texttt{slant}}
3790 OpenType機能と見かけ上同じような形式で指定できるものに,
3791 \begin{description}
3792 \item[\texttt{extend=}\meta{extend}] 横方向に\meta{extend}倍拡大する.
3793 \item[\texttt{slant=}\meta{slant}] \meta{slant}に指定された割合だけ傾ける.
3794 \end{description}
3795 の2つがある.
3796 \texttt{extend}や\texttt{slant}を指定した場合は,それに応じたJFMを指定すべきである%
3797 \footnote{\LuaTeX-jaでは,これらに対するJFMを特に提供することはしない予定である.}.
3798 例えば,次の例では無理やり通常のJFMを使っているために,文字間隔やイタリック補正量が
3799 正しくない:
3800 %</ja>
3801 %<*en>
3802 \paragraph{\texttt{extend} and \texttt{slant}}
3803 The following setting can be specified as OpenType font features:
3804 \begin{cslist}[style=standard]
3805 \item[\texttt{extend=}\meta{extend}] expand the font horizontally by \meta{extend}.
3806 \item[\texttt{slant=}\meta{slant}] slant the font.
3807 \end{cslist}
3808 Note that \LuaTeX-ja doesn't adjust JFMs by these \texttt{extend} and \texttt{slant}
3809 settings; one have to write new JFMs on purpose.
3810 For example, the following example uses the standard JFM \texttt{jfm-ujis.lua}, hence
3811 the letterspacing and the width of italic corrections are not correct:
3812 %</en>
3813 \begin{LTXexample}[width=0.3\textwidth]
3814 \jfont\E=HaranoAjiMincho-Regular:extend=1.5;jfm=ujis;-kern
3815 \jfont\S=HaranoAjiMincho-Regular:slant=1;jfm=ujis;-kern
3816 \E あいうえお \S あいう\/ABC
3817 \end{LTXexample}
3818
3819 %<*ja>
3820 \paragraph{\texttt{ltjksp}「機能」}
3821 \label{pg:ltjksp}
3822 \LuaTeX-ja標準では,
3823 JFM中における\texttt{kanjiskip\_natural}, \texttt{kanjiskip\_stretch},\
3824 \texttt{kanjiskip\_shrink}キー(\pageref{pg:ksp_nat}ページ)の使用によって,
3825 「JFM由来のグルーの他に,\Param{kanjiskip}の自然長/伸び量/縮み量の一部が
3826 同じ場所に挿入される」という状況が起こりうる.
3827 この機能を無効化し,バージョン20150922.0以前と同じような組版を得るためには,
3828 他のOpenType機能と同じように\>\mbox{\texttt{-ltjksp}}\>指定を行えば良い(\autoref{fig:ltjksp}参照).
3829 なお,
3830 \begin{lstlisting}
3831  \jfont\G=HaranoAjiMincho-Regular:jfm=ujis;-ltjksp;+ltjksp at \zw
3832 \end{lstlisting}
3833 のように\texttt{+ltjksp}指定を行った場合は,\texttt{kanjiskip\_natural}など
3834 3キーは再び有効化される.\texttt{-ltjksp}, \texttt{+ltjksp}を複数回指定した場合は,
3835 最後に指定したものが有効となる.
3836 %</ja>
3837 %<*en>
3838 \paragraph{\texttt{ltjksp} ``feature''}
3839 \label{pg:ltjksp}
3840 \texttt{kanjiskip\_natural}, \texttt{kanjiskip\_stretch},\
3841 \texttt{kanjiskip\_shrink} keys (Page~\pageref{pg:ksp_nat}) makes tha
3842 \LuaTeX-ja inserts not only a glue which is specified by a JFM, and also
3843 the natural width/stretch part/shrink part of \Param{kanjiskip}.
3844 This functionality is disabled by \mbox{\texttt{-ltjksp}} specification,
3845 as shown in~\autoref{fig:ltjksp}.
3846 %</en>
3847 \begin{figure}
3848 \begin{LTXexample}[width=16\zw]
3849 \leavevmode
3850 \ltjsetparameter{kanjiskip=0pt plus 3\zw}
3851 \vrule\hbox to 15\zw{あ「い」う,えお}\vrule\\
3852 \jfont\G=HaranoAjiMincho-Regular%
3853   :jfm=ujis;-ltjksp at \zw
3854 \G\leavevmode%
3855 \vrule\hbox to 15\zw{あ「い」う,えお}\vrule
3856 \end{LTXexample}
3857 \caption{\texttt{ltjksp} ``feature''}
3858 \label{fig:ltjksp}
3859 \end{figure}
3860
3861 %<*ja>
3862 \paragraph{\texttt{ltjpci}「機能」}
3863 \label{pg:ltjpci}
3864 \Pkg{luaotfload}~v3.19以降では,標準でUnicode(文字から作られるノードたち)がNFCに正規化される
3865 ようになっている.これにより,ソース中でたとえば「か」と合成用濁点(\texttt{U+3099})を続けて入力した場合,
3866 両者それぞれからノードが生成されるが,結果的には「が」を表す1ノードになるわけである.
3867
3868 しかし,NFCに正規化することで,
3869 たとえば「\UTF{FA19}」(\texttt{U+FA19})が「神」(\texttt{U+795E})にというふうに,
3870 CJK互換漢字がCJK統合漢字に変換されてしまうという問題がある.
3871 異体字セレクタを用いればこのようなことは起きないが,古くからあるフォントでは異体字セレクタをサポートしていない.
3872
3873 以上の事情に対応するため,\LuaTeX-jaでは,標準で
3874 \emph{CJK互換漢字・CJK互換漢字補助の文字には\Pkg{luaotfload}パッケージによる処理は働かない}ようにしている.
3875 この機能を無効化するには,他のOpenType機能と同じように\texttt{-ltjpci}指定を行えば良い(\autoref{fig:ltjpci}参照).
3876 \texttt{ltjksp}と同様に,\texttt{-ltjpci}, \texttt{+ltjpci}を複数回指定した場合は,
3877 最後に指定したものが有効となる.
3878 %</ja>
3879 %<*en>
3880 \paragraph{\texttt{ltjpci} ``feature''}
3881 \label{pg:ltjpci}
3882 By default, The \Pkg{luaotfload} package (since v3.19) normalizes Unicode sequences to NFC.
3883 However, this normalization converts CJK compatibility ideographs to their canonical equivalents,
3884 such as ``\UTF{FA19}''~(\texttt{U+FA19}) to ``神''. One can use variation selectors,
3885 but old fonts does not support them.
3886
3887 So, \emph{\LuaTeX-ja now protects CJK compatibility ideographs from processing
3888  by the \Pkg{luaotfload} package by defualt}.
3889 This functionality is disabled by \mbox{\texttt{-ltjpci}} specification,
3890 as shown in~\autoref{fig:ltjpci}.
3891 %</en>
3892 \begin{figure}
3893 \begin{LTXexample}[width=12\zw]
3894 \def\TEST{\leavevmode\char"FA10\char"FA12\char"FA15
3895   \char"FA19.か\char"3099.は\char"309A.\par}
3896 \jfont\A=HaranoAjiMincho-Regular:jfm=ujis; at 15pt
3897 \A\TEST % default
3898 \jfont\G=HaranoAjiMincho-Regular:jfm=ujis;-ltjpci at 15pt
3899 \G\TEST % ltjpci off
3900 \jfont\H=HaranoAjiMincho-Regular:jfm=ujis;-normalize at 15pt
3901 \H\TEST % normalization off
3902 \end{LTXexample}
3903 \caption{\texttt{ltjpci} ``feature''}
3904 \label{fig:ltjpci}
3905 \end{figure}
3906
3907 %<en>\subsection{\cs{tfont}}
3908 %<ja>\subsection{\cs{tfont} 命令}
3909 \label{ssec:tfont}
3910
3911 \begin{comment}
3912 \begin{table}[t]
3913 %<en>\caption{Differences between vertical JFMs shipped with \LuaTeX-ja}
3914 %<ja>\caption{\LuaTeX-ja に同梱されている縦組用 JFM の違い}
3915 %<en>\medskip
3916 \label{tab-difjfm-tate}
3917 \ltjsetparameter{jacharrange={+3}}
3918 \small
3919 \def\r#1#2{%
3920   \hbox{\tate\Large\vrule
3921   \parbox{7\zw}{%
3922     \addjfontfeatures{TateFeatures={JFM=#1}}\noindent
3923         \color{#2}\transparent{0.5}
3924     ◆◆◆◆◆◆◆
3925     ある日モモちゃんが「お使い」で迷子になって泣きました。
3926   }\vrule}}
3927 \def\s#1#2{%
3928   \hbox{\tate\Large
3929   \parbox{7\zw}{%
3930     \addjfontfeatures{TateFeatures={JFM=#1}}\noindent
3931         \color{#2}\transparent{0.5}
3932     ちょっと!何
3933   }}}
3934 \def\t#1#2#3{\hbox to 0pt{\hss%
3935   \setbox0=\hbox{\addjfontfeatures{TateFeatures={JFM=#1}}\huge #3}%
3936   \textcolor{#2}{\transparent{0.5}\vrule width 0.4pt height\ht0 depth\dp0}\kern-.2pt\copy0
3937   \textcolor{#2}{\transparent{0.5}\kern-\wd0\vrule width\wd0height .2pt depth .2pt
3938   \kern-\wd0\raise\ht0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3939   \kern-\wd0\lower\dp0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3940   \kern-.2pt\vrule width 0.4pt height\ht0 depth \dp0}\hss}}
3941
3942 \begin{minipage}{.7\textwidth}
3943 \centering
3944 \leavevmode\hbox to 0pt{\r{ujisv}{blue}\hss}\r{tmin}{red}\quad
3945 \leavevmode\hbox to 0pt{\s{ujisv}{blue}\hss}\s{tmin}{red}\quad
3946 \raise4\zw\hbox{\tate\Large\t{ujisv}{black}{漢}\t{tmin}{red}{漢}\qquad
3947            \t{ujisv}{black}{っ}\t{tmin}{red}{っ}}
3948 \end{minipage}%
3949 \begin{minipage}{.3\textwidth}
3950 \textcolor{blue}{Blue: \texttt{jfm-ujisv.lua}}\\
3951 \textcolor{red}{Red: \texttt{jfm-tmin.lua}}
3952 \end{minipage}
3953 \ltjsetparameter{jacharrange={-3}}
3954 \end{table}
3955 \end{comment}
3956
3957 %<*en>
3958 \cs{tfont} loads a font as a Japanese font for vertical direction.
3959 This command admits the same syntax as in \cs{font}~and~\cs{jfont}.
3960 A font defined by~\cs{tfont} differs the following points from that by~\cs{jfont}:
3961 \begin{itemize}
3962  \item OpenType Feature~\texttt{vrt2}%
3963   \footnote{If the font does not define the \texttt{vrt2} feature,
3964         \texttt{vert} is used instead.} is automatically activated,
3965   unless \texttt{vert}~and//or~\texttt{vrt2} features are explicitly activated
3966   or deactivated (as the second line in the example below).
3967 \begin{lstlisting}
3968 \tfont\S=HaranoAjiMincho-Regular:jfm=ujisv % vrt2 is automatically activated
3969 \tfont\T=HaranoAjiMincho-Regular:jfm=ujisv;-vert % vert and vrt2 are not activated
3970 \tfont\U=file:ipaexm.ttf:jfm=ujisv
3971     % vert is automatically activated, since this font does not have vrt2
3972 \end{lstlisting}
3973  \item Sometimes \texttt{vert} and/or \texttt{vrt2} are not activated
3974  while one specified activation of these feature.
3975  This is because the font does not define these features in current combination of
3976  script~tag and language~system~identifier.
3977
3978  In this situation, \LuaTeX-ja performs all replacements which is defined in~\texttt{vert}
3979  feature for \emph{some} scripts for \emph{some} languages.
3980  \item \cs{tfont} uses a vertical JFM instead of a horizontal JFM.
3981 \LuaTeX-ja ships following vertical JFMs:
3982 \begin{description}
3983 \item[\texttt{jfm-ujisv.lua}] A standard vertical JFM in \LuaTeX-ja. This JFM is
3984   based on \verb+upnmlminr-v.tfm+, a metric for UTF/OTF package that
3985   is used in \upTeX.
3986 \item[\texttt{jfm-tmin.lua}] A counterpart for \verb+tmin10.tfm+, which is one
3987   of the default Japanese font metric shipped with \pTeX.
3988 \end{description}
3989 \begin{figure}[!tb]
3990 \begin{LTXexample}[pos=b]
3991 \jfont\X=[HaranoAjiMincho-Regular.otf]:jfm=ujis
3992 \tfont\U=[HaranoAjiMincho-Regular.otf]:jfm=ujisv
3993 \tfont\V=[HaranoAjiMincho-Regular.otf]:jfm=ujisv;jpotf
3994 \def\TEST#1#2{\leavevmode\hbox{#1#2\string#2 “引用,と句読点.”}}
3995 \ttfamily\centering\TEST\yoko\X \quad \TEST\tate\U \quad \TEST\tate\V
3996 \end{LTXexample}
3997 \caption{\texttt{jpotf} ``feature''}
3998 \label{fig:jpotf}
3999 \end{figure}
4000   
4001  \item If \texttt{vert}~and/or~\texttt{vrt2} features are activated,
4002   one can specify \texttt{jpotf} to additional substitutions.
4003   By default, it substitutes ideographic comma/period for fullwidth comma/period,
4004   and double prime quotation marks for double quotation marks
4005   (See~\autoref{fig:jpotf}).
4006   One can customize substitutions by lua~function \verb+luatexja.jfont.register_vert_replace+\ %
4007   (see Japanese version of this manual).
4008 \end{itemize}
4009 %</en>
4010 %<*ja>
4011 \cs{tfont} はフォントを縦組用の和文フォントとして読み込む命令であり,
4012 \cs{tfont}の構文は\cs{jfont}と同様である.
4013 \cs{tfont}で定義された縦組用和文フォントは,
4014 以下の点が\cs{jfont}による横組用和文フォントとは異なる:
4015 \begin{itemize}
4016  \item 明示的にOpenType機能\texttt{vert}, \texttt{vrt2}(のいずれか)の
4017   有効・無効を指定した場合を除き,自動的にOpenType機能\texttt{vrt2}の有効化が
4018   指定されたものとみなされる
4019  \footnote{もしフォントが\texttt{vrt2}を定義していなかった場合,代わりに
4020  \texttt{vert}を用いる.}.
4021 \begin{lstlisting}
4022 \tfont\S=HaranoAjiMincho-Regular:jfm=ujisv % vrt2 is automatically activated
4023 \tfont\T=HaranoAjiMincho-Regular:jfm=ujisv;-vert % vert and vrt2 are not activated
4024 \tfont\U=file:ipaexm.ttf:jfm=ujisv
4025     % vert is automatically activated, since this font does not have vrt2
4026 \end{lstlisting}
4027  \item \texttt{vert}, \texttt{vrt2}の少なくとも一つの有効を指定した場合にも関わらず,
4028   script tagとlanguage system identifierの値の組み合わせによって
4029   実際には有効にならなかった場合,\LuaTeX-jaは
4030  \begin{quote}
4031    どれかのscript,~languageで定義されている\texttt{vert}による
4032    (単一グリフから単一グリフへの)置換を全部適用する
4033  \end{quote}
4034   という挙動を取る\footnote{%
4035   例えば,Windows~7に付属しているSimHeiでは,\texttt{vert}はScriptが\texttt{hani},
4036   Languageが\texttt{CHN}という状況でのみ定義されている.しかし,\Pkg{luaotfload}では
4037   このscript,~languageの組み合わせを指定することはできないので,
4038   \Pkg{luaotfload}そのままでは\texttt{vert}を適用させることはできない.
4039  }.
4040  \item さらに,置換前と置換後のグリフがどちらも「UAX~\#50で``r''もしくは``Tr''と指定されている」ものは90度自動回転させる.
4041  \item \ref{ssec:math}節で述べる,数式中の和文フォントには縦組用和文フォントは指定できない.
4042  \item \meta{JFM name}には縦組用JFMを指定する.
4043 以下の縦組用JFMが\LuaTeX-jaには同梱されている.%おり,違いを\autoref{tab-difjfm-tate}に示した.
4044 \begin{description}
4045 \item[\texttt{jfm-ujisv.lua}] \LuaTeX-jaの標準縦組用JFMである.このJFMは\upTeX で
4046   用いられるUTF/OTFパッケージ用の和文用TFMである \verb+upnmlminr-v.tfm+ を
4047   元にしている.
4048 \item[\texttt{jfm-tmin.lua}] \pTeX に同梱されているデフォルトの和文用縦組TFM
4049   である \verb+tmin10.tfm+ に相当し,\texttt{min10.tfm} と同様に
4050   「っ」など一部の文字幅が狭められている.
4051 \end{description}
4052
4053 \begin{figure}[!tb]
4054 \begin{LTXexample}[pos=r,width=.4\textwidth]
4055 \jfont\X=[HaranoAjiMincho-Regular.otf]:jfm=ujis
4056 \tfont\U=[HaranoAjiMincho-Regular.otf]:jfm=ujisv
4057 \tfont\V=[HaranoAjiMincho-Regular.otf]:jfm=ujisv;jpotf
4058 \def\TEST#1#2{\leavevmode
4059   \hbox{#1#2\string#2 “引用,と句読点.”}}
4060 \ttfamily\centering
4061 \TEST\yoko\X\quad \TEST\tate\U\quad
4062 \TEST\tate\V
4063 \end{LTXexample}
4064 \caption{\texttt{jpotf} ``feature''}
4065 \label{fig:jpotf}
4066 \end{figure}
4067 \begin{table}[t]
4068   \def\D#1#2#3#4{%
4069         {\fboxsep0pt\fcolorbox{cyan}{white}%
4070     {\large\lower-\cdp\hbox{\tate\ltjjachar"#1#2#3#4}}}\ (\texttt{U+#1#2#3#4})%"
4071   }
4072   \caption{\texttt{jpotf}が指定された際に行われる追加の縦組形への置換}
4073   \label{tab:vert_replace_jpotf}\small\centering
4074   \begin{tabular}{*{2}{l@{}>{${}\longmapsto{}$}c@{}l}}
4075         \toprule
4076         \D FF0C&&\D 3001&\D FF0E&&\D 3002\\
4077         \D 201C&&\D 301D&\D 201D&&\D 301F\\
4078         \bottomrule
4079   \end{tabular}
4080 \end{table}
4081
4082  \item \texttt{vert}, \texttt{vrt2}の少なくとも片方が(明示的・自動的を問わず)
4083   有効になっていた場合,さらに\texttt{jpotf}を指定することで
4084   「通常では行わない縦組用字形への置換」を行うことができる.
4085   
4086   標準では,\autoref{tab:vert_replace_jpotf}に示した置換が登録されている
4087   \footnote{%
4088         \texttt{jpotf}という名前にしたのは,
4089         OTFパッケージの縦組用和文TFMでほぼ同じの処理(そちらではさらに一重引用符を
4090         「シングルミニュート」に置換する機能もあった)を行っていたことに由来する.
4091   }.実行例は\autoref{fig:jpotf}を参照.
4092
4093   ユーザ側で「置換」をカスタマイズしたい場合,
4094   \verb+luatexja.jfont.register_vert_replace+関数に変更内容を記したテーブルを渡す.
4095   例えば置換$i_1\longmapsto v_1$, $i_2\longmapsto v_2$,~$\dots$を登録する場合は
4096         \begin{lstlisting}[escapechar=\!]
4097 \directlua{luatexja.jfont.register_vert_replace{[!$i_1$!]=!$v_1$!, [!$i_2$!]=!$v_2$!, ...}}
4098         \end{lstlisting}
4099   を実行する.
4100   \verb+luatexja.jfont.register_vert_replace+による変更はこの関数の\emph{実行後}に定義される
4101   フォントについてのみ有効である.
4102   
4103 \end{itemize}
4104
4105 なお,\pTeX では,\cs{font},~\cs{jfont},~\cs{tfont}のどれでも欧文フォント・横組用和文フォン
4106 ト・縦組用和文フォントの定義が可能であったが,\LuaTeX-jaではそうでないので注意.
4107 %</ja>
4108
4109 %<en>\subsection{Default Japanese fonts and JFMs}
4110 %<ja>\subsection{標準和文フォント・JFMの変更}
4111 \label{ssec:cfg}
4112 %<*en>
4113 If following commands are defined at loading \LuaTeX-ja package, these change
4114 default Japanese fonts and JFMs for them:
4115 %</en>
4116 %<*ja>
4117 \LuaTeX-jaが読み込まれる前に以下の命令が定義されていた場合は,
4118 それらが標準和文フォントやそれらに用いるJFMとして使われる.
4119 %</ja>
4120
4121 \begin{cslist}[style=standard]
4122   \item[\cs{ltj@stdmcfont}] 
4123 %<en>The default Japanese font for the mincho family.
4124 %<ja>明朝体として用いるフォント.
4125   \item[\cs{ltj@stdgtfont}]
4126 %<en>The default Japanese font for the gothic family.
4127 %<ja>ゴシック体として用いるフォント.
4128   \item[\cs{ltj@stdyokojfm}]
4129 %<en>The default JFM for horizontal direction.
4130 %<ja>標準で用いる横組用JFM.
4131   \item[\cs{ltj@stdtatejfm}]
4132 %<en>The default JFM for vertical direction.
4133 %<ja>標準で用いる縦組用JFM.
4134 \end{cslist}
4135
4136 %<*en>
4137 For example,
4138 \begin{lstlisting}
4139 \def\ltj@stdmcfont{IPAMincho}
4140 \def\ltj@stdgtfont{IPAGothic}
4141 \end{lstlisting}
4142 makes that IPA~Mincho and IPA~Gothic will be used as default Japanese fonts, instead of
4143 Harano Aji fonts.
4144 %IPAex~Mincho and IPAex~Gothic.
4145
4146 This feature is intended for classes which use special JFMs%
4147 \footnote{This is because commands has \texttt{@} in their names.}.
4148 It is recommended to use \cs{luatexja-preset}~or~\cs{luatexja-fontspec} package
4149 to select standard fonts in ordinary \LaTeX\ sources.
4150 %</en>
4151 %<*ja>
4152 例えば
4153 \begin{lstlisting}
4154 \def\ltj@stdmcfont{IPAMincho}
4155 \def\ltj@stdgtfont{IPAGothic}
4156 \end{lstlisting}
4157 と記述しておけば,標準和文フォントがIPA明朝・IPAゴシックへと変
4158 更される.
4159
4160 この機能は,特別のJFMを用いるクラス
4161 \footnote{例えば阿部紀行氏によるjlreqがそれにあたる.}%
4162 などでの使用を意図しており,命令名に\texttt{@}が含まれることから
4163 通常の\TeX/\LaTeX 文書での使用は意図していない.
4164 通常の\LaTeX 文書では\Pkg{luatexja-preset}や\Pkg{luatexja-fontspec}などで
4165 使用フォントを選択することを推奨する.
4166 %</ja>
4167
4168 %<*en>
4169 For compatibility with earlier versions,
4170 \LuaTeX-ja reads  \texttt{luatexja.cfg} automatically if it is found by \LuaTeX.
4171 One should not overuse this \texttt{luatexja.cfg}; it will overwrite
4172 the definition of \cs{ltj@stdmcfont} and others.
4173 %</en>
4174 %<*ja>
4175 旧バージョンとの互換性のため,
4176 \LuaTeX から見える位置に\texttt{luatexja.cfg}があれば,\LuaTeX-jaはそれを読み込む.
4177 しかし,\texttt{luatexja.cfg}内で\cs{ltj@stdmcfont}等が定義されていた場合はそちらが
4178 優先されるので,もはや\texttt{luatexja.cfg}は使わないほうが良いだろう.
4179 %</ja>
4180
4181 %<en>\subsection{Prefix \texttt{psft}}
4182 %<ja>\subsection{\texttt{psft}プリフィックス}
4183 \label{ssec:psft}
4184 %<*en>
4185 Besides ``\texttt{file}''\ and ``\texttt{name}''\ prefixes which
4186 are introduced in the \Pkg{luaotfload} package,
4187 \LuaTeX-ja adds ``\texttt{psft}''\ prefix in \cs{jfont} (and~\cs{font}),
4188 to specify a ``name-only'' Japanese font which
4189 will not be embedded to PDF.
4190 Note that these non-embedded fonts under current \LuaTeX\ has Identity-H encoding,
4191 and this violates the standard ISO32000-1:2008~(\cite{pdfstd}).
4192
4193 \emph{OpenType font features, such as ``\texttt{+jp90}'',
4194 have no meaning in name-only fonts using ``\texttt{psft}''\ prefix,
4195 because we can't expect what fonts are actually used by the PDF reader.}
4196 Note that \texttt{extend}~and~\texttt{slant} settings (see~above) are supported
4197 with \texttt{psft} prefix, because they are only simple linear transformations.
4198 %</en>
4199 %<*ja>
4200 \Pkg{luaotfload}で使用可能になった
4201 \texttt{file}\ と \texttt{name}\ のプリフィックスに加えて,
4202 \cs{jfont}(と \cs{font} プリミティブ)では
4203 \texttt{psft}\ プリフィックスを用いることができる.
4204 このプリフィックスを用いることで,PDFには埋め込まれない「名前だけの」
4205 和文フォントを指定することができる.
4206 なお,現行の\LuaTeX で非埋め込みフォントを作成するとPDF内でのエンコーディングが
4207 Identity-Hとなり,PDFの標準規格ISO32000-1:2008~(\cite{pdfstd})に非準拠になってしまう
4208 ので注意してほしい.
4209
4210 \emph{\texttt{psft} プリフィックスの下では
4211 \texttt{+jp90} などのOpenType機能の効力はない.
4212 非埋込フォントをPDFに使用すると,実際にどのようなフォントが
4213 表示に用いられるか予測できないからである.}\
4214 \texttt{extend} と \texttt{slant} 指定は単なる変形のため
4215 \texttt{psft} プリフィックスでも使用可能である.
4216 %</ja>
4217
4218 %<en>\paragraph{\texttt{cid} key}
4219 %<ja>\paragraph{\texttt{cid}キー}
4220 \label{para-cid}
4221
4222 %<*en>
4223 The default font defined by using \texttt{psft} prefix is for Japanese typesetting;
4224 it is Adobe-Japan1-7 CID-keyed font.
4225 One can specify \texttt{cid} key to use other CID-keyed non-embedded fonts
4226 for Chinese or Korean typesetting.
4227 %</en>
4228 %<*ja>
4229 標準で\texttt{psft}\ プリフィックスで定義されるフォントは日本語用のもので
4230 あり,Adobe-Japan1-7のCIDに対応したものとなる.しかし,\LuaTeX-jaは中国語
4231 の組版にも威力を発揮することが分かり,日本語フォントでない非埋込フォント
4232 の対応も必要となった.そのために追加されたのが\texttt{cid}キーである.
4233
4234 \texttt{cid}キーに値を指定すると,そのCIDを持った非埋込フォントを定義することができる:
4235 %</ja>
4236 \begin{lstlisting}[numbers=left]
4237 \jfont\testJ={psft:Ryumin-Light:cid=Adobe-Japan1-7;jfm=jis}    % Japanese
4238 \jfont\testD={psft:Ryumin-Light:jfm=jis}                       % default: Adobe-Japan1-7
4239 \jfont\testC={psft:AdobeMingStd-Light:cid=Adobe-CNS1-7;jfm=jis}% Traditional Chinese
4240 \jfont\testG={psft:SimSun:cid=Adobe-GB1-6;jfm=jis}             % Simplified Chinese
4241 \jfont\testK={psft:Batang:cid=Adobe-Korea1-2;jfm=jis}          % Korean
4242 \jfont\testKR={psft:SourceHanSerifAKR9:cid=Adobe-KR-9;jfm=jis} % Korean
4243 \end{lstlisting}
4244 %<*en>
4245 Note that the code above specifies \texttt{jfm-jis.lua}, which is for Japanese fonts,
4246 as JFM for Chinese and Korean fonts.
4247 %</en>
4248 %<*ja>
4249 上のコードでは中国語・韓国語用フォントに対してもJFMに
4250 日本語用の\texttt{jfm-jis.lua}を指定しているので注意されたい.
4251 %</ja>
4252
4253 %<*en>
4254 At present, \LuaTeX-ja supports only 5 values written in the sample code above.
4255 Specifying other values, e.g.,
4256 %</en>
4257 %<*ja>
4258 今のところ,\LuaTeX-jaは上のサンプルコード中に書いた5つの値しかサポートしていない.
4259 %</ja>
4260 \begin{lstlisting}
4261 \jfont\test={psft:Ryumin-Light:cid=Adobe-Japan2;jfm=jis}
4262 \end{lstlisting}
4263 %<*en>
4264 produces the following error:
4265 %</en>
4266 %<*ja>
4267 のようにそれら以外の値を指定すると,エラーが発生する:
4268 %</ja>
4269 \begin{lstlisting}[numbers=left]
4270 ! Package luatexja Error: bad cid key `Adobe-Japan2'.
4271
4272 See the luatexja package documentation for explanation.
4273 Type  H <return>  for immediate help.
4274 <to be read again>
4275                    \par
4276 l.78
4277
4278 ? h
4279 I couldn't find any non-embedded font information for the CID
4280 `Adobe-Japan2'. For now, I'll use `Adobe-Japan1-6'.
4281 Please contact the LuaTeX-ja project team.
4282 ?
4283 \end{lstlisting}
4284
4285 %<en>\subsection{Structure of a JFM file}
4286 %<ja>\subsection{JFMファイルの構造}
4287 \label{ssec:jfm-str}
4288 %<en>A JFM file is a Lua script which has only one function call:
4289 %<ja>JFMファイルはただ一つの関数呼び出しを含むLuaスクリプトである:
4290 \begin{lstlisting}
4291 luatexja.jfont.define_jfm { ... }
4292 \end{lstlisting}
4293 %<*en>
4294 Real data are stored in the table which indicated above by
4295 \verb+{ ... }+.  So, the rest of this subsection are devoted to describe the
4296 structure of this table.  Note that all lengths in a JFM file are
4297 floating-point numbers in design-size unit.
4298 %</en>
4299 %<*ja>
4300 実際のデータは上で \verb+{ ... }+ で示されたテーブルの中に格納されている.
4301 以下ではこのテーブルの構造について記す.
4302 なお,JFMファイル中の長さは全てdesign sizeを単位とする浮動小数点数であることに
4303 注意する.
4304 %</ja>
4305
4306 \begin{cslist}[style=standard]
4307
4308 \item[version=\meta{version}]
4309 %<en>(optional, default value is~1)
4310 %<ja>(任意,既定値は1)
4311
4312 %<*en>
4313 The version JFM. Currently 1,~2,~and,~3 are supported
4314 %</en>
4315 %<*ja>
4316 JFMのバージョン.1,~2,~3がサポートされる.
4317 %</ja>
4318   
4319 \item[dir=\meta{direction}]
4320 %<en>(required)
4321 %<ja>(必須)
4322
4323 %<*en>
4324 The direction of JFM. \texttt{'yoko'}~(horizontal)
4325 or \texttt{'tate'}~(vertical) are supported.
4326 %</en>
4327 %<*ja>
4328 JFMの書字方向.\texttt{'yoko'}(横組)と \texttt{'tate'}(縦組)がサポートされる.
4329 %</ja>
4330
4331 \item[zw=\meta{length}]
4332 %<en>(required)
4333 %<ja>(必須)
4334
4335 %<en>The amount of the length of the ``full-width''.
4336 %<*ja>
4337 「全角幅」の長さ.この量が \cs{zw} の長さとなる.\pTeX では
4338 「全角幅」\texttt{1zw} は「文字クラス0の文字」の幅と決められていたが,
4339 \LuaTeX-jaではここで指定する.
4340 %</ja>
4341
4342 \item[zh=\meta{length}]
4343 %<en>(required)
4344 %<ja>(必須)
4345
4346 %<en>The amount of the ``full-height'' (height + depth).
4347 %<*ja>
4348 「全角高さ」(height + depth)の長さ.通常は全角幅と同じ長さになるだろう.
4349 \pTeX では 「全角高さ」\texttt{1zh} は「文字クラス0の文字」の高さと深さの和と決められていたが,
4350 \LuaTeX-jaではここで指定する.
4351 %</ja>
4352
4353 \item[kanjiskip=\{\meta{natural}, \meta{stretch}, \meta{shrink}\}]
4354 %<en>(optional)
4355 %<ja>(任意)
4356
4357 %<*en>
4358 This field specifies the ``ideal'' amount of \Param{kanjiskip}. As noted
4359              in Subsection~\ref{subs-kskip}, if the parameter
4360              \Param{kanjiskip} is \cs{maxdimen}, the value specified
4361              in this field is actually used (if this field is not specified in
4362              JFM, it is regarded as 0\,pt). Note that \meta{stretch} and \meta{shrink}
4363              fields are in design-size unit too.
4364 %</en>
4365 %<*ja>
4366 理想的な\Param{kanjiskip}の量を指定する.\ref{subs-kskip}節で述べたように,
4367 もし\Param{kanjiskip}が \cs{maxdimen} の値ならば,このフィールドで指定された
4368 値が実際には用いられる(指定なしは0\,ptとして扱われる).\meta{stretch}と\meta{shrink}のフィールドもdesign size
4369 が単位であることに注意せよ.
4370 %</ja>
4371
4372 \item[xkanjiskip=\{\meta{natural}, \meta{stretch}, \meta{shrink}\}]
4373 %<en>(optional)
4374 %<ja>(任意)
4375
4376 %<*en>
4377 Like the \texttt{kanjiskip} field, this field specifies the ``ideal''
4378              amount of \Param{xkanjiskip}.
4379 %</en>
4380 %<*ja>
4381 \texttt{kanjiskip}フィールドと同様に,\Param{xkanjiskip}の理想的な量を
4382 指定する.
4383 %</ja>
4384 \end{cslist}
4385
4386 %<*en>
4387 \paragraph{Character classes}
4388 Besides from above fields, a JFM file have several sub-tables those
4389 indices are natural numbers.  The table indexed by~$i\in\omega$ stores
4390 information of \emph{character class}~$i$. At least, the character class~0 is
4391 always present, so each JFM file must have a sub-table whose index is
4392 \texttt{[0]}.  Each sub-table (its numerical index is denoted by $i$) has
4393 the following fields:
4394 %</en>
4395 %<*ja>
4396 \paragraph{文字クラス}
4397 上記のフィールドに加えて,JFMファイルはそのインデックスが自然数であるいくつかの
4398 サブテーブルを持つ.インデックスが$i\in\omega$であるテーブルは\emph{文字クラス}$i$の
4399 情報を格納する.少なくとも,文字クラス0は常に存在するので,JFMファイルはインデックス
4400 が\texttt{[0]}のサブテーブルを持たなければならない.それぞれのサブテーブル
4401 (そのインデックスを$i$で表わす)は以下のフィールドを持つ:
4402 %</ja>
4403
4404 \begin{cslist}[style=standard]
4405 \item[chars=\{\meta{character}, ...\}]
4406 %<en>(required except character class~0)
4407 %<ja>(文字クラス0を除いて必須)
4408
4409 %<*en>
4410 This field is a list of characters which are in this character
4411              type~$i$. This field is optional if $i=0$, since all
4412              \textbf{JAchar} which do not belong  any character classes other
4413              than 0 are in the character class 0
4414              (hence, the character class~0 contains most of
4415              \textbf{JAchar}s). In the list, character(s) can be specified in the following form:
4416 \begin{itemize}
4417 \item a Unicode code point
4418 \item the character itself (as a Lua string, like \hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ'+})
4419 \item a string like \hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ*'+} (the character followed by an asterisk)
4420 \item several ``imaginary'' characters (We will describe these later.)
4421 \end{itemize}
4422 %</en>
4423 %<*ja>
4424 このフィールドは文字クラス$i$に属する文字のリストである.このフィールドは$i=0$の
4425 場合には任意である(文字クラス0には,0以外の文字クラスに属するものを
4426 除いた全ての\textbf{JAchar}が属するから).このリスト中で文字を指定するには,以下の方法がある:
4427 \begin{itemize}
4428 \item Unicode におけるコード番号
4429 \item 「\hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ'+}」のような,文字それ自体
4430 \item 「\hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ*'+}」のような,文字それ自体の後にアスタリスクをつけたもの
4431 \item いくつかの「仮想的な文字」(後に説明する)
4432 \end{itemize}
4433 %</ja>
4434
4435 \item[width=\meta{length}, height=\meta{length}, depth=\meta{length}, italic=\meta{length}]
4436 %<en>(required)
4437 %<ja>(必須)
4438
4439 %<*en>
4440 \begin{table}[t]
4441  \centering
4442 \begin{tabular}{llr}
4443 \toprule
4444 Direction of JFM&\textbf{\texttt{'yoko'} (horizontal)}&\multicolumn{1}{l}{\textbf{\texttt{'tate'} (vertical)}}\\
4445 \midrule
4446 \texttt{width} field&\multicolumn{2}{c}{the width of the ``real'' glyph}\\
4447 \texttt{height} field&the height of the ``real'' glyph&0.0\\
4448 \texttt{depth} field&the depth of the ``real'' glyph&0.0\\
4449 \midrule
4450 \texttt{italic} field&\multicolumn{2}{c}{0.0}\\
4451 \bottomrule
4452 \end{tabular}
4453 \caption{Default values of \texttt{width} field and other fields}
4454 \label{tab-wid}
4455 \end{table}
4456 Specify the width of characters in character class~$i$, the height, the depth and
4457 the amount of italic correction. All characters in character class~$i$ are regarded that its width, height, and depth are
4458 as values of these fields. The default values are shown in \autoref{tab-wid}.
4459 %</en>
4460 %<*ja>
4461 \begin{table}[t]
4462  \centering
4463 \begin{tabular}{llr}
4464 \toprule
4465 JFM書字方向&\emph{\texttt{'yoko'}(横組)}&\multicolumn{1}{l}{\emph{\texttt{'tate'}(縦組)}}\\
4466 \midrule
4467 \texttt{width}&\multicolumn{2}{c}{「実際のグリフ」の幅}\\
4468 \texttt{height}&「実際のグリフ」の高さ&0.0\\
4469 \texttt{depth}&「実際のグリフ」の深さ&0.0\\
4470 \midrule
4471 \texttt{italic}&\multicolumn{2}{c}{0.0}\\
4472 \bottomrule
4473 \end{tabular}
4474 \caption{\texttt{width} フィールド等の標準値}
4475 \label{tab-wid}
4476 \end{table}
4477 文字クラス$i$に属する文字の幅,高さ,深さ,イタリック補正の量を指定する.
4478 文字クラス$i$に属する全ての文字は,その幅,高さ,深さがこのフィールドで指定した
4479 値であるものとして扱われる.省略時や,数でない値を指定した時には表\nobreak\ref{tab-wid}に
4480              示されている値を用いる.例えば,横組用JFMで \texttt{width} フィールドには数値以外の値を指
4481              定した場合,文字の幅はその「実際の」グリフの幅となる.OpenTypeの \texttt{prop} featureと併用
4482              すれば,これによってプロポーショナル組を行うことができる.
4483 %</ja>
4484
4485 \item[left=\meta{length}, down=\meta{length}, align=\meta{align}]\
4486
4487 %<*en>
4488 These fields are for adjusting the position of the ``real'' glyph. Legal
4489              values of \texttt{align} field are \texttt{'left'},
4490              \texttt{'middle'}, and \texttt{'right'}. If one of these
4491              3~fields are omitted, \texttt{left} and \texttt{down} are
4492              treated as~0, and \texttt{align} field is treated as
4493              \texttt{'left'}.
4494 The effects of these 3~fields are indicated in
4495 \autoref{fig:pos}~and~\autoref{fig:pos-tate}.
4496 %</en>
4497 %<*ja>
4498 これらのフィールドは実際のグリフの位置を調整するためにある.
4499 \texttt{align} フィールドに指定できる値は \texttt{'left'}, \texttt{'middle'},
4500 \texttt{'right'} のいずれかである.もしこれら3つのフィールドのうちの1つが省かれた
4501 場合,\texttt{left} と \texttt{down} は0,\texttt{align} フィールドは
4502 \ \texttt{'left'} であるものとして扱われる.
4503 これら3つのフィールドの意味については\autoref{fig:pos}(横組用和文フォント),
4504 \autoref{fig:pos-tate}(縦組用和文フォント)で説明する.
4505 %</ja>
4506
4507 %<*en>
4508 In most cases, \texttt{left} and \texttt{down} fields are~0, while
4509 it is not uncommon that the \texttt{align} field is \texttt{'middle'} or \texttt{'right'}.
4510 For example, setting the \texttt{align} field to \texttt{'right'} is practically needed
4511 when the current character class is the class for opening delimiters'.
4512 %</en>
4513 %<*ja>
4514 多くの場合,\texttt{left}と\texttt{down}は0である一方,
4515 \texttt{align}フィールドが\texttt{'middle'}や\texttt{'right'}であることは
4516 珍しいことではない.
4517 例えば,\texttt{align}フィールドを\texttt{'right'}に指定することは,
4518 文字クラスが開き括弧類であるときに実際必要である.
4519 %</ja>
4520
4521 \begin{figure}[!tb]
4522 \begin{minipage}{0.4\textwidth}%
4523 \begin{center}\unitlength=10pt\small
4524 \begin{picture}(15,12)(-1,-4)
4525 \color{b_gray}% jfm
4526 \put(0,0){\vrule width 12\unitlength height 8\unitlength depth 3\unitlength}
4527
4528 \color{b_pink}% step1
4529 \put(-1,-1.5){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
4530
4531 \color{red}% real glyph
4532 \thicklines
4533 \put(-1,-1.5){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
4534 \put(5,-1.5){\line(0,1){7}\line(0,-1){2.5}}
4535 \put(-1,5.5){\line(1,0){6}}
4536 \put(-1,-4){\line(1,0){6}}
4537
4538 \color{b_green}% real glyph
4539 \put(3,0){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
4540
4541 \color{black}% jfm
4542 \thicklines
4543 \put(0,0){\vector(0,1){8}\line(0,-1){3}\vector(1,0){12}}
4544 \put(12,0){\line(0,1){8}\vector(0,-1){3}}
4545 \put(0,8){\line(1,0){12}}
4546 \put(0,-3){\line(1,0){12}}
4547 \put(0.2,4){\makebox(0,0)[l]{\texttt{height}}}
4548 \put(12.2,-1.5){\makebox(0,0)[l]{\texttt{depth}}}
4549 \put(6,0.2){\makebox(0,0)[b]{\texttt{width}}}
4550
4551 \color{green}% step1
4552 \thicklines
4553 \put(3,0){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
4554 \put(9,0){\line(0,1){7}\line(0,-1){2.5}}
4555 \put(3,7){\line(1,0){6}}
4556 \put(3,-2.5){\line(1,0){6}}
4557 \newsavebox{\eqdist}
4558 \savebox{\eqdist}(0,0)[b]{%
4559   \thinlines
4560   \put(-0.08,0.2){\line(0,-1){0.4}}%
4561   \put(0.08,0.2){\line(0,-1){0.4}}}
4562 \put(1.5,0){\usebox{\eqdist}}
4563 \put(10.5,0){\usebox{\eqdist}}
4564
4565 \color{blue}% shifted
4566 \thicklines
4567 \put(3,-1.5){\vector(-1,0){4}}
4568 \put(1,-1.7){\makebox(0,0)[t]{\texttt{left}}}
4569 \put(3,0){\vector(0,-1){1.5}}
4570 \put(3.2,-0.75){\makebox(0,0)[l]{\texttt{down}}}
4571 \end{picture}
4572 \end{center}
4573 \end{minipage}%
4574 \begin{minipage}{0.6\textwidth}%
4575 %<*en>
4576 Consider a  Japanese character node which belongs to
4577 a character class whose the \texttt{align}
4578 field is \texttt{'middle'}.
4579 %</en>
4580 %<*ja>
4581 \texttt{align}フィールドの値が \texttt{'middle'} であるような文字クラスに属する
4582 和文文字ノードを考えよう.
4583 %</ja>
4584 \begin{itemize}
4585 \item
4586 %<*en>
4587 The black rectangle is the imaginary body of the node.
4588 Its width, height, and depth are specified by JFM.
4589 %</en>
4590 %<*ja>
4591 黒色の長方形はノードの枠であり,
4592 その幅,高さ,深さはJFMによって指定されている.
4593 %</ja>
4594 \item
4595 %<*en>
4596 Since the \texttt{align} field is \texttt{'middle'},
4597 the ``real'' glyph is centered horizontally (the green rectangle) first.
4598 %</en>
4599 %<*ja>
4600 \texttt{align}フィールドは \texttt{'middle'} なので,
4601 実際のグリフの位置はまず水平方向に中央揃えしたものとなる(緑色の長方形).
4602 %</ja>
4603 \item
4604 %<*en>
4605 Furthermore, the glyph is shifted according to values of fields
4606       \texttt{left} and \texttt{down}. The ultimate position of the real
4607       glyph is indicated by the red rectangle.
4608 %</en>
4609 %<*ja>
4610 さらに,グリフは \texttt{left} と \texttt{down} の値に従ってシフトされる.
4611 最終的な実際のグリフの位置は赤色の長方形で示された位置になる.
4612 %</ja>
4613 \end{itemize}
4614 \end{minipage}
4615 \medskip
4616
4617 \caption{%
4618 %<en>The position of the real glyph (horizontal Japanese fonts)
4619 %<ja>横組和文フォントにおける「実際の」グリフの位置
4620 }
4621 \label{fig:pos}
4622 \end{figure}
4623 \begin{figure}[!tb]
4624 \begin{minipage}{0.4\textwidth}%
4625 \begin{center}\unitlength=10pt\small
4626 \begin{picture}(15,12)(-6,0)
4627 \color{b_gray}% jfm
4628 \put(-6,0){\vrule width 12\unitlength height 11\unitlength}
4629
4630 \color{b_pink}% real glyph
4631 \put(-6.5,5.5){\vrule width 8\unitlength height 6\unitlength depth 3\unitlength}
4632
4633 \color{red}% real glyph
4634 \thicklines
4635 \put(-6.5,5.5){\vector(0,1){6}\vector(0,-1){3}\vector(1,0){8}}
4636 \put( 1.5,5.5){\line(0,1){6}\line(0,-1){3}}
4637 \put(-6.5,11.5){\line(1,0){8}}
4638 \put(-6.5,2.5){\line(1,0){8}}
4639
4640 \color{b_green}% step1
4641 \put(-4,3){\vrule width 8\unitlength height 6\unitlength depth 3\unitlength}
4642
4643 \color{black}% jfm
4644 \thicklines
4645 \put(0,11){\vector(1,0){6}\vector(-1,0){6}\vector(0,-1){11}}
4646 \put(0,0){\line(1,0){6}\line(-1,0){6}}
4647 \put(-6,0){\line(0,1){11}}
4648 \put( 6,0){\line(0,1){11}}
4649 \put( 3,10.8){\makebox(0,0)[t]{\texttt{height}}}
4650 \put(-3,10.8){\makebox(0,0)[t]{\texttt{depth}}}
4651 \put(0.2,5.5){\makebox(0,0)[l]{\texttt{width}}}
4652
4653 \color{green}% step1
4654 \thicklines
4655 \put(-4,3){\vector(0,1){6}\vector(0,-1){3}\vector(1,0){8}}
4656 \put( 4,3){\line(0,1){6}\line(0,-1){3}}
4657 \put(-4,9){\line(1,0){8}}
4658 \put(-4,0){\line(1,0){8}}
4659 \savebox{\eqdist}(0,0)[b]{%
4660   \thinlines
4661   \put(-0.08,0.2){\line(0,-1){0.4}}%
4662   \put(0.08,0.2){\line(0,-1){0.4}}}
4663 \put(2,9){\usebox{\eqdist}}
4664 \put(-2,9){\usebox{\eqdist}}
4665
4666
4667 \color{blue}% shifted
4668 \thicklines
4669 \put(-4,3){\vector(0,1){2.5}}
4670 \put(-3.8,4.25){\makebox(0,0)[l]{\texttt{left}}}
4671 \put(-4,5.5){\vector(-1,0){2.5}}
4672 \put(-5.,5.7){\makebox(0,0)[b]{\texttt{down}}}
4673 \end{picture}
4674 \end{center}
4675 \end{minipage}%
4676 \begin{minipage}{0.6\textwidth}%
4677 %<*en>
4678 (\dots)
4679 %</en>
4680 %<*ja>
4681 \texttt{align}フィールドの値が \texttt{'right'} であるような文字クラスに属する
4682 和文文字を考えよう.
4683 \begin{itemize}
4684 \item
4685 実際のグリフの「垂直位置」は,まずベースラインが文字の物理的な左右方向の中央を通る
4686 位置となる.
4687 \item
4688 また,この場合 \texttt{align} フィールドは \texttt{'right'} なので,
4689 「水平位置」は字送り方向に「右寄せ」したものとなる(緑色の長方形).
4690 \item
4691 その後さらに \texttt{left} と \texttt{down} の値に従ってシフトされる
4692 のは横組用和文フォントと変わらない.
4693 \end{itemize}
4694 %</ja>
4695 \end{minipage}
4696 \medskip
4697
4698 \caption{%
4699 %<en>The position of the real glyph (vertical Japanese fonts)
4700 %<ja>縦組和文フォントにおける「実際の」グリフの位置
4701 }
4702 \label{fig:pos-tate}
4703 \end{figure}
4704
4705 \item[kern={\{[$j$]=\meta{kern}, [$j'$]=\{\meta{kern}, [ratio=\meta{ratio}]\}, ...\}}]
4706 \nopagebreak
4707 \item[glue={\{[$j$]=\{\meta{width}, \meta{stretch}, \meta{shrink}, [ratio=\meta{ratio}, ...]\}, ...\}}]\leavevmode
4708 %<*ja>
4709
4710 文字クラス$i$の文字と$j$の文字の間に挿入されるカーンやグルーの量を指定する.
4711
4712 \meta{ratio}は,グルーの自然長のうちどれだけの割合が「後の文字」由来かを示す量で,
4713 $0$から$+1$の実数値をとる.省略時の値は$0.5$である.
4714 このフィールドの値は\Param{differentjfm}の値が
4715 \texttt{pleft},~\texttt{pright},~\texttt{paverage}の値のときのみ実際に用いられる.
4716
4717 例えば,\cite{x4051}では,句点と中点の間には,
4718 句点由来の二分空きと中点由来の四分空きが挿入されるが,この場合には
4719 \begin{itemize}
4720 \item \meta{width}には$0.5+0.25=0.75$を指定する.
4721 \item \meta{ratio}には$0.25/(0.5+0.25)=1/3$を指定する.
4722 \end{itemize}
4723 %</ja>
4724 %<*en>
4725 \
4726
4727 Specifies the amount of kern or glue which will be inserted
4728 between characters in character class~$i$ and those in character class~$j$.
4729
4730 \meta{ratio} specifies how much the glue is originated in the ``right'' character.
4731 It is a real number between 0 and 1, and treated as 0.5 if omitted. For example,
4732 The width of a glue between an ideographic full stop ``。''
4733 and a fullwidth middle dot ``・'' is three-fourth of fullwidth,
4734 namely halfwidth from the ideographic full stop, and
4735 quarter-width from the fullwidth middle dot.  In this case,
4736 we specify \meta{ratio} to $0.25/(0.5+0.25)=1/3$.
4737 %</en>
4738
4739 %<*ja>
4740 グルーの指定においては,上記に加えて各 \texttt{[$j$]} の各サブテーブル内に
4741 次のキーを指定できる,
4742 \begin{cslist}[style=standard]
4743 \item[priority=\meta{priority}]
4744              \Pkg{luatexja-adjust}による優先順位付き
4745              行長調整(\ref{ssec:adj}節)において,このグルーの優先度を指定する.許される値は以下の通り:
4746   \begin{description}
4747     \item[バージョン1] $-4$から$+3$の間の整数
4748     \item[バージョン2以降] $-4$から$+3$の間の整数の2つ組\texttt{\{\meta{stretch}, \meta{shrink}\}}か,
4749     または$-4$から$+3$の間の整数.\meta{stretch}, \meta{shrink}はそれぞれこのグルーが伸びるときの優先度,縮むときの
4750     優先度であり,単に整数$i$が指定された場合は\texttt{\{$i$, $i$\}}であると解釈される.
4751   \end{description}
4752   ここで指定する値は,大きい値ほど「先に伸ばされる」「先に縮ませる」ことを意味しており,省略時の値
4753              は0である.範囲外の値が指定されたときの動作は未定義である.
4754 \item[kanjiskip\_natural=\meta{num}\textrm{, }%
4755   kanjiskip\_stretch=\meta{num}\textrm{, }kanjiskip\_shrink=\meta{num}]\leavevmode
4756   \label{pg:ksp_nat}
4757
4758 JFMによって本来挿入されるグルーの他に
4759 \Param{kanjiskip}分の空白を自然長(\texttt{kanjiskip\_natural}),伸び量(\texttt{kanjiskip\_stretch}),
4760 縮み量(\texttt{kanjiskip\_shrink})ごとに挿入する
4761 %  \footnote{本来\Param{xkanjiskip}が挿入される場所においては\Param{xkanjiskip}分の空白を自然長・伸び量・縮み量ごとに}%
4762 ための指定である.いずれも省略された場合のデフォルト値は0(追加しない)である.
4763
4764 例えば,\LuaTeX-jaの横組標準JFMの \texttt{jfm-ujis.lua} では,
4765 \begin{itemize}
4766  \item 通常の文字「あ」と開き括弧類の間に入るグルーは,自然長・縮み量半角,伸び量0のグルー
4767 となっているが,さらに\Param{kanjiskip}の伸び量に \texttt{kanjiskip\_stretch}(ここでは1)を掛け
4768        た分だけ伸びることが許される.
4769  \item 同様に,閉じ括弧類(全角コンマ「,」も含む)と和文文字「う」「え」,
4770   閉じ括弧類と「f」の間も自然長・縮み量半角,伸び量0のグルー
4771 となっているが,さらに\Param{kanjiskip}の伸び量に \texttt{kanjiskip\_stretch}(ここでは1)を掛け
4772        た分だけ伸びることが許される.
4773  \item 一方,開き括弧類と通常の文字の間,また通常の文字と閉じ括弧類の間は
4774   自然長・縮み量・伸び量0のグルーだが,\Param{kanjiskip}の縮み量に
4775   \texttt{kanjiskip\_shrink}(ここでは1)を掛けた分だけ縮むことが許される.
4776 \end{itemize}
4777 となっている.従って,以下のような組版結果を得る.
4778
4779 \medskip
4780 \begin{LTXexample}[width=18\zw]
4781 \leavevmode\let\V=\vrule
4782 \ltjsetparameter{kanjiskip=0pt plus 5\zw}
4783 \ltjsetparameter{xkanjiskip=0pt plus 0.5\zw}
4784 \V\hbox spread 7\zw{aあ「い」う,えお」f}\V
4785
4786 \vrule\hbox{ああ「い」う,えお」f}\V\par
4787 \ltjsetparameter{kanjiskip=0pt minus \zw}
4788 \V\hbox spread -2.5\zw{aあ「い」う,えお」f}\V
4789 \end{LTXexample}
4790 \end{cslist}
4791 %</ja>
4792 %<*en>
4793 In case of glue, one can specify following additional keys in each \texttt{[$j$]}
4794              subtable:
4795 \begin{cslist}[style=standard]
4796 \item[priority=\meta{priority}]
4797 An integer in $[-4,3]$ (treated as 0 if omitted), or
4798 a pair of these integers \texttt{\{\meta{stretch}, \meta{shrink}\}} (version 2~or~later).
4799 This is
4800 used only in line adjustment with priority by \Pkg{luatexja-adjust}
4801 (see Subsection~\ref{ssec:adj}). Higher value means the glue is easy to stretch,
4802 and is also easy to shrink. 
4803 \item[kanjiskip\_natural=\meta{num}\textrm{, }%
4804   kanjiskip\_stretch=\meta{num}\textrm{, }kanjiskip\_shrink=\meta{num}]\leavevmode
4805
4806 These keys specifies the amount of the natural width of \Param{kanjiskip}%
4807 (the stretch/shrink part, respectively) which will be inserted
4808 in addition to the original JFM glue. Default values of them are all 0.
4809
4810 As an example, in \texttt{jfm-ujis.lua}, the standard JFM in horizontal writing, we have
4811 \begin{itemize}
4812  \item Between an ordinal letter ``あ'' and an ideographic opening bracket, we have
4813 a glue whose natural part and shrink part are both half-width, while its stretch part is
4814        zero. However, this glue also can be stretched
4815        as much as the stretch part of \Param{kanjiskip} times the value of
4816        \texttt{kanjiskip\_stretch} key (1 in this case).
4817  \item Between an ideographic closeing brackets (including the ideographic comma ``,'')
4818        and an ordinal letter (including an \textbf{ALchar} ``f\/''), we have the same glue.
4819        Again, this glue also can be stretched
4820        as much as the stretch part of \Param{kanjiskip} times the value of
4821        \texttt{kanjiskip\_stretch} key (1 in this case).
4822  \item Between an ideographic opening bracket and an ordinal letter
4823   and between an ordinal letter and an ideographic closing bracket,
4824   we have a glue whose natural part and stretch part are both zero, while its shrink part as much as
4825   the shrink part of \Param{kanjiskip}.
4826 \end{itemize}
4827 Hence we have the following result:
4828
4829 \medskip
4830 \begin{LTXexample}[width=18\zw]
4831 \leavevmode\let\V=\vrule
4832 \ltjsetparameter{kanjiskip=0pt plus 5\zw}
4833 \ltjsetparameter{xkanjiskip=0pt plus 0.5\zw}
4834 \V\hbox spread 7\zw{aあ「い」う,えお」f}\V
4835
4836 \vrule\hbox{aあ「い」う,えお」f}\V\par
4837 \ltjsetparameter{kanjiskip=0pt minus \zw}
4838 \V\hbox spread -2.5\zw{aあ「い」う,えお」f}\V
4839 \end{LTXexample}
4840
4841 \end{cslist}
4842 %</en>
4843   
4844 \item[end\_stretch=\meta{kern}, end\_shrink=\meta{kern}]
4845 %<*ja>
4846 (任意,バージョン1のみ)
4847
4848 優先順位付き行長調整が有効であり,かつ現在の文字クラスの文字が行
4849              末に来た時に,行長を詰める調整・伸ばす調整のた
4850              めにこの文字と行末の間に挿入可能なカーンの大きさを指定する.
4851 %</ja>
4852 %<*en>
4853 (optional, version~1 only)
4854 %</en>
4855
4856   \item[end\_adjust=\{\meta{kern}, \meta{kern}, ...\}]
4857 %<*ja>
4858 (任意,バージョン2以降)
4859
4860 優先順位付き行長調整が有効であり,かつ現在の文字クラスの文字が
4861   行末に来た時に,この文字と行末の間には指定された値のいずれかの大きさのカーンが
4862   挿入される(\autoref{ssec:adj}参照).
4863
4864 バージョン1における
4865 \begin{lstlisting}[escapechar=\$]
4866     end_stretch = $a$, end_shrink = $b$
4867 \end{lstlisting}
4868 という指定は,バージョン2以降では次の指定と同じになる.
4869 \begin{lstlisting}[escapechar=\$]
4870     end_adjust = {$-b$, 0.0, $a$}
4871 \end{lstlisting}
4872 もし真ん中の \texttt{0.0} がない場合は,$a$か$-b$かいずれかのカーンが常に行末に追加される.
4873 %</ja>
4874 %<*en>
4875 (optional, version~2 or~later)
4876 %</en>
4877
4878   \item[round\_threshold=\meta{float}]
4879 %<*ja>
4880 (任意,バージョン3以降,文字クラス0のみ)
4881
4882 「実際のグリフの幅に合わせて文字幅を整数倍する」際のしきい値を指定する.
4883 より正確に述べると,次のようになる.このフィールドに正の数$r$が指定されていたとし,
4884 JFM中で「文字クラス0の文字幅」と指定されている値が$w$,文字クラス0に属する文字のあるグリフの実際の幅が$w'$であったとする.
4885 $n=\nint(w'/w)$とした
4886 \footnote{ここで,$\nint(a)=\lfloor a+0.5\rfloor$は$a$に「もっとも近い整数」を表す.}
4887 とき,もし$w'>w$かつ$\lvert w'/w-n\rvert \char`<r$であれば,JFMで文字幅$nw$が指定されたものとして扱う.
4888
4889 この機能は,ほとんど源ノ明朝・源ノ角ゴシックにおける2倍角・3倍角ダッシュの合字のために実装されたと
4890 言ってもよい(この場合$w'=2$,~$3$である).これらのグリフは\LuaTeX 内部ではUnicodeの私用領域に割り当てられるので,
4891 JFM側で番号を指定することができない.
4892 %</ja>
4893 %<*en>
4894 (optional, version~3 or~later, only available in character class~0)
4895 %</en>
4896
4897
4898 \end{cslist}
4899
4900 %<*ja>
4901 \paragraph{文字クラスの決定}
4902 文字からその文字の属する文字クラスを算出する過程について,
4903 次の内容を含んだ \texttt{jfm-test.lua} を用いて説明する.
4904 %</ja>
4905 %<*en>
4906 \paragraph{Character to character classes}
4907 We explain how the character class of a character is determined,
4908 using  \texttt{jfm-test.lua} which contains the following:
4909 %</en>
4910 \begin{lstlisting}
4911    [0] = {
4912       chars = { '漢' },
4913       align = 'left', left = 0.0, down = 0.0,
4914       width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
4915    },
4916    [2000] = {
4917       chars = { '。', 'ヒ' },
4918       align = 'left', left = 0.0, down = 0.0,
4919       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
4920    },
4921 \end{lstlisting}
4922 %<ja>ここで,次のような入力とその実行結果を考える:
4923 %<en>Now consider the following input/output:
4924 \begin{LTXexample}[width=0.3\textwidth]
4925 \jfont\a=IPAexMincho:jfm=test;+hwid
4926 \setbox0\hbox{\a ヒ漢}\the\wd0
4927 \end{LTXexample}
4928 %<*en>
4929 Now we look why the above source outputs 15\,pt.
4930 \begin{enumerate}
4931 \item The character ``ヒ'' is converted to its half width  form ``ヒ'' by \verb+hwid+ feature.
4932 \item According to the JFM, the character class of ``ヒ'' is 2000, hence its width is halfwidth.
4933 \item The character class of ``漢'' is zero,  hence its width is fullwidth.
4934 \item Hence the width of \cs{hbox} equals to 15\,pt.
4935 \end{enumerate}
4936 This example shows that the character class of a character is generally determined \emph{after
4937 applying font features by \Pkg{luaotfload}}.
4938 %</en>
4939 %<*ja>
4940 上記の出力結果が,15\,ptとなっているのは理由によるものである:
4941 \begin{enumerate}
4942 \item \verb+hwid+ featureによって「ヒ」が半角幅のグリフ「ヒ」と置き換わる(\Pkg{luaotfload} による処理).
4943 \item JFMによれば,この「ヒ」のグリフの文字クラスは2000である.
4944 \item 以上により文字クラス2000とみなされるため,結果として「ヒ」の幅は半角だと認識される.
4945 \end{enumerate}
4946 この例は,\emph{文字クラスの決定はOpenType機能の適用によるグリフ置換の結果に基づく}ことを
4947 示している.
4948 %</ja>
4949
4950 %<*en>
4951 However, if the class determined by the glyph after application of features is zero,
4952 \LuaTeX-ja adopts the class determined by the glyph \emph{before} application of features.
4953 The following input is an example.
4954 %</en>
4955 %<*ja>
4956 但し,JFMによって決まる置換後のグリフの文字クラスが0である場合は,置換前の文字クラスを採用する.
4957 %</ja>
4958 \begin{LTXexample}[width=0.3\textwidth]
4959 \jfont\a=HaranoAjiMincho-Regular:jfm=test;+vert
4960 \a 漢。\inhibitglue 漢
4961 \end{LTXexample}
4962 %<*en>
4963 Here, the character class of the ideographic full stop ``。''~(\texttt{U+3002}) is determined
4964 as follows:
4965 \begin{enumerate}
4966 \item As the case of ``ヒ'', the ideographic full stop ``。'' is converted to its vertical
4967       form ``\char"FE12''~(\texttt{U+FE12}) by \verb+vert+ feature.%"
4968 \item The character class of ``\char"FE12'', according to the JFM  is \emph{zero}.
4969 \item However, \LuaTeX-ja remembers that this ``\char"FE12'' is obtained from ``。'' by
4970       font features. The character class of ``。'' is \emph{non-zero value}, namely, 2000.
4971 \item Hence the ideographic full stop ``。'' in above belongs the character class~2000.
4972 \end{enumerate}
4973 %</en>
4974 %<*ja>
4975 ここで,句点「。」(\texttt{U+3002})の文字クラスは,以下のようにして決まる.
4976 \begin{enumerate}
4977 \item \Pkg{luaotfload}によって縦組用句点のグリフに置き換わる.
4978 \item 置換後のグリフは \texttt{U+FE12} であり,JFMに従えば文字クラスは\emph{0}と判定される.
4979 \item この場合,置換前の横組用句点のグリフによって文字クラスを判定する.
4980 \item 結果として,上の出力例中の句点の文字クラスは2000となる.
4981 \end{enumerate}
4982 %</ja>
4983
4984
4985 %<ja>\paragraph{仮想的な文字}
4986 %<en>\paragraph{Imaginary characters}
4987 %<*en>
4988 As described before, one can specify several ``imaginary characters'' in
4989 \texttt{chars} field. The most of these characters are regarded as the
4990 characters of class 0 in \pTeX.
4991 As a result, \LuaTeX-ja can control typesetting finer than \pTeX.
4992 The following is the list of imaginary characters:
4993 %</en>
4994 %<*ja>
4995 上で説明した通り,\texttt{chars}フィールド中にはいくつかの「特殊文字」も
4996 指定可能である.これらは,大半が\pTeX のJFMグルーの挿入処理ではみな「文字
4997 クラス0の文字」として扱われていた文字であり,その結果として\pTeX より細か
4998 い組版調整ができるようになっている.以下でその一覧を述べる:
4999 %</ja>
5000
5001 \begin{cslist}
5002 %%\item['diffmet']
5003 %%<en>Used at a boundary between two \textbf{JAchar}s whose JFM or size is different.
5004 %%<ja>JFMやサイズが異なる2つの\textbf{JAchar}の間の境界として用いられる.
5005
5006 \item['boxbdd']
5007 %<*en>
5008 The beginning/ending of a hbox, and the beginning of a noindented (i.e., began by \cs{noindent}) paragraph.
5009 If a hbox~$b$ begins (resp.~ends) a glue or kern between this ``charater'' and a \textbf{JAchar},
5010 \textbf{JAglue} won't be inserted before(resp.~after) the hbox~$b$.
5011 \Param{kanjiskip}~and~\Param{xkanjiskip} around a hbox.
5012 %</en>
5013 %<*ja>
5014 hboxの先頭と末尾,及びインデントされていない(\cs{noindent} で開始された)段落の先頭を表す.
5015 この「文字」との間に設定したグルー・カーンがボックス$b$の先頭(もしくは末尾)に来た場合,
5016   そのボックス$b$の直前(もしくは直後)には和文処理グルーは入らない.
5017 %</ja>
5018
5019 \item['parbdd']
5020 %<en>The beginning of an (indented) paragraph.
5021 %<ja>通常の(\cs{noindent} で開始されていない)段落の先頭.
5022
5023 \item['jcharbdd']
5024 %<en>A boundary between \textbf{JAchar} and anything else.
5025 %<*ja>
5026 \textbf{JAchar}と「その他のもの」との境界.
5027
5028 バージョン2以前では\textbf{ALchar},箱,罫線(rule),glue,~kernなどいろいろなものと\textbf{JAchar}の境界に対して
5029 本特殊文字が用いられていたが,
5030 バージョン3以降では\ \texttt{'jcharbdd'}, \texttt{'alchar'}, \texttt{'nox\_alchar'},
5031 \texttt{'glue'} と細分化され,
5032 \texttt{'jcharbdd'} は主に\textbf{JAchar}とボックスや罫線(rule)との境界に使われるようになった.
5033 %</ja>
5034   
5035 \item['alchar', 'nox\_alchar']
5036 %<*en>
5037 (version 3~or~later) A boundary between \textbf{JAchar} and \textbf{ALchar}.
5038 %</en>
5039 %<*ja>
5040 (バージョン3以降)\textbf{JAchar}と\textbf{ALchar}との境界.
5041 \textbf{JAchar}と\textbf{ALchar}の間に\Param{xkanjiskip}が入ることが可能な場合は
5042 \ \texttt{'alchar'}\ が,そうでない場合は\ \texttt{'nox\_alchar'}\ が用いられる
5043 (この区別は\textbf{ALchar}側の\Param{alxspmode}の値によってのみ行われる).
5044 %</ja>
5045
5046 \item['glue']
5047 %<en>(version 3~or~later) A boundary between \textbf{JAchar}, and, a glue or kern.
5048 %<ja>(バージョン3以降)\textbf{JAchar}とglue,kernとの境界.
5049
5050 \item[$-1$]
5051 %<en>The left/right boundary of an inline math formula.
5052 %<ja>行中数式と地の文との境界.
5053 \end{cslist}
5054
5055 %<en>\paragraph{Porting JFM from \pTeX}
5056 %<ja>\paragraph{\pTeX 用和文用TFMの移植}
5057
5058 % ToDo: English version.
5059
5060 %<*en>
5061 See Japanese version of this manual.
5062 %</en>
5063
5064 %<*ja>
5065 以下に,\pTeX 用に作られた和文用TFMを\LuaTeX-ja用に移植する場合の注意点を挙げておく.
5066 \begin{itemize}
5067 \item 実際に出力される和文フォントのサイズがdesign sizeとなる.
5068 このため,例えば$1\,\textrm{zw}$がdesign sizeの0.962216倍であるJISフォン
5069       トメトリック等を移植する場合は,次のようにするべきである:
5070 \begin{itemize}
5071 \item JFM中の全ての数値を$1/0.962216$倍しておく.
5072 \item \TeX ソース中で使用するところで,サイズ指定を0.962216倍にする.
5073       \LaTeX でのフォント宣言なら,例えば次のように:
5074 \begin{lstlisting}
5075 \DeclareFontShape{JY3}{mc}{m}{n}{<-> s*[0.962216] psft:Ryumin-Light:jfm=jis}{}
5076 \end{lstlisting}
5077 \end{itemize}
5078 \item 上に述べた特殊文字は,\texttt{'boxbdd'}を除き文字クラスを全部0とする
5079       (JFM中に単に書かなければよい).
5080 \item \texttt{'boxbdd'}については,それのみで一つの文字クラスを形成し,その
5081       文字クラスに関してはグルー/カーンの設定はしない.
5082
5083 これは,\pTeX では,
5084       hboxの先頭・末尾とインデントされていない(\cs{noindent} で開始さ
5085       れた)段落の先頭にはJFMグルーは入らないという仕様を実現させるためである.
5086 \item \pTeX の組版を再現させようというのが目的であれば以上の注意を守れば十分である.
5087
5088 ところで,\pTeX では通常の段落の先頭にJFMグルーが残るという仕様があるので,
5089       段落先頭の開き括弧は全角二分下がりになる.全角下がりを実現させるに
5090       は,段落の最初に手動で \cs{inhibitglue} を追加するか,あるいは
5091       \ \cs{everypar} のハックを行い,それを自動化させるしかなかった.
5092
5093 一方,\LuaTeX-jaでは,\texttt{'parbdd'}によって,それがJFM側で調整できるよ
5094 うになった.例えば,\LuaTeX-ja同梱のJFMのように,\texttt{'boxbdd'}と同じ文字クラスに
5095 \texttt{'parbdd'}を入れれば全角下がりとなる.
5096
5097 \begin{LTXexample}[width=0.4\textwidth]
5098 \jfont\g=HaranoAjiMincho-Regular:jfm=test \g
5099 \parindent1\zw\noindent{}◆◆◆◆◆
5100 \par 「◆◆←二分下がり
5101 \par 【◆◆←全角下がり
5102 \par 〔◆◆←全角二分下がり
5103 \end{LTXexample}
5104 \end{itemize}
5105
5106 但し,\cs{everypar} を利用している場合にはこの仕組みは正しく動かない.
5107 そのような例としては箇条書き中の \cs{item} で始まる段落があり,\Pkg{ltjsclasses}では
5108 人工的に「\texttt{'parbdd'}の意味を持つ」whatsitノードを作ることによって対処している%
5109 \footnote{\texttt{ltjsclasses.dtx} を参照されたい.
5110 JFM側で一部の対処ができることにより,\Pkg{jsclasses}のようにif文の判定はしていない.}.
5111 %</ja>
5112
5113
5114 %<en>\subsection{Math font family}
5115 %<ja>\subsection{数式フォントファミリ}
5116 \label{ssec:math}
5117
5118 %<*en>
5119 \TeX\ handles fonts in math formulas by 16~font families\footnote{Omega,
5120 Aleph, \LuaTeX~and $\varepsilon$-\kern-.125em(u)\pTeX\ can handles 256~families, but
5121 an external package is needed to support this in plain \TeX\ and
5122 \LaTeX.}, and each family has three fonts:
5123 \cs{textfont}, \cs{scriptfont} and \cs{scriptscriptfont}.
5124 %</en>
5125 %<*ja>
5126 \TeX\ は数式フォントを16のファミリ\footnote{Omega, Aleph, \LuaTeX,そして
5127   $\varepsilon$-\kern-.125em(u)\pTeX\ では256の数式ファミリを扱うことができるが,
5128   これをサポートするためにplain \TeX と\LaTeX では外部パッケージを読み込む必要が
5129   ある.}で管理し,それぞれのファミリは3つのフォントを持っている:
5130 \cs{textfont}, \cs{scriptfont} そして \cs{scriptscriptfont} である.
5131 %</ja>
5132
5133 %<*en>
5134 \LuaTeX-ja's handling of Japanese fonts in math formulas is similar;
5135 \autoref{tab-math} shows counterparts to \TeX's primitives for math
5136 font families. There is no relation between the value of
5137 \cs{fam} and that of \cs{jfam}; with appropriate settings,
5138 one can set both \cs{fam} and \cs{jfam} to the same value.
5139 Here \meta{jfont\_cs} in the argument of \Param{jatextfont} etc.\ is
5140 a control sequence which is defined by \cs{jfont}, i.e.,
5141 a \emph{horizontal} Japanese font.
5142 %</en>
5143 %<*ja>
5144 \LuaTeX-jaの数式中での和文フォントの扱いも同様である.
5145 \autoref{tab-math}は数式フォントファミリに対する \TeX のプリミティブと対応する
5146 ものを示している.\cs{fam} と \cs{jfam} の値の間には関係はなく,
5147 適切な設定の下では \cs{fam} と \cs{jfam} の両方に同じ値を設定することができる.
5148 \Param{jatextfont} 他の第2引数\meta{jfont\_cs}は,\cs{jfont} で定義された
5149 \emph{横組用}和文フォントである.\cs{tfont} で定義された
5150 \emph{縦組用}和文フォントを指定することは想定していない.
5151 %</ja>
5152
5153 \begin{table}[!tb]
5154 %<en>\caption{Commands for Japanese math fonts}
5155 %<ja>\caption{和文数式フォントに対する命令}
5156 \label{tab-math}
5157 %<en>\medskip
5158 \centering
5159 \def\{{\char`\{}\def\}{\char`\}}\small
5160 \begin{tabular}{ll}
5161 \toprule
5162 %<en>\bf Japanese fonts&\bf alphabetic fonts\\
5163 %<ja>\bf 和文フォント&\bf 欧文フォント\\
5164 \midrule
5165 \cs{jfam}${}\in [0,256)$&\cs{fam}\\
5166 \ttfamily\Param{jatextfont}\,=\{\meta{jfam},\meta{jfont\_cs}\}&\ttfamily\cs{textfont}\meta{fam}=\meta{font\_cs}\\
5167 \ttfamily\Param{jascriptfont}\,=\{\meta{jfam},\meta{jfont\_cs}\}&\ttfamily\cs{scriptfont}\meta{fam}=\meta{font\_cs}\\
5168 \ttfamily\Param{jascriptscriptfont}\,=\{\meta{jfam},\meta{jfont\_cs}\}&\ttfamily\cs{scriptscriptfont}\meta{fam}=\meta{font\_cs}\\
5169 \bottomrule
5170 \end{tabular}
5171 \end{table}
5172
5173 %<en>\subsection{Callbacks}
5174 %<ja>\subsection{コールバック}
5175
5176 %<*en>
5177 \LuaTeX-ja also has several callbacks. These callbacks can
5178 be accessed via \verb+luatexbase.add_to_callback+ function and so on, as other callbacks.
5179 %</en>
5180 %<*ja>
5181 \LuaTeX 自体のものに加えて,\LuaTeX-jaもコールバックを持っている.
5182 これらのコールバックには,他のコールバックと同様に \verb+luatexbase.add_to_callback+
5183 関数などを用いることでアクセスすることができる.
5184 %</ja>
5185 \begin{description}[font=\bfseries, style=nextline]
5186 %<en>\item[\texttt{luatexja.load\_jfm} callback]
5187 %<ja>\item[\texttt{luatexja.load\_jfm}コールバック]
5188 %<*en>
5189 With this callback, one can overwrite JFMs.
5190 This callback is called when a new JFM is loaded.
5191 %</en>
5192 %<*ja>
5193 このコールバックを用いることでJFMを上書きすることができる.
5194 このコールバックは新しいJFMが読み込まれるときに呼び出される.
5195 %</ja>
5196
5197 \begin{lstlisting}[numbers=left]
5198 function (<table> jfm_info, <string> jfm_name)
5199   return <table> new_jfm_info
5200 end
5201 \end{lstlisting}
5202
5203 %<*en>
5204 The argument \verb+jfm_info+ contains a table similar to the table in a JFM file, except
5205 this argument has \texttt{chars} field which contains character codes
5206              whose character class is not~0.
5207 %</en>
5208 %<*ja>
5209 引数 \verb+jfm_info+ はJFMファイルのテーブルと似たものが格納されるが,
5210 クラス0を除いた文字のコードを含んだ\texttt{chars}フィールドを持つ点が異なる.
5211 %</ja>
5212
5213 %<*en>
5214 An example of this callback is the \texttt{ltjarticle} class, with
5215              forcefully assigning character class~0 to \texttt{'parbdd'}
5216              in the JFM \texttt{jfm-min.lua}.
5217 %</en>
5218 %<*ja>
5219 このコールバックの使用例は\texttt{ltjarticle}クラスにあり,
5220 \texttt{jfm-min.lua}中の\texttt{'parbdd'}を強制的にクラス0に割り当てている.
5221 %</ja>
5222
5223 %<en>\item[\texttt{luatexja.define\_jfont} callback]
5224 %<ja>\item[\texttt{luatexja.define\_jfont}コールバック]
5225 %<*en>
5226 This callback and the next callback form a pair, and you can assign characters
5227  which do not have fixed code points in Unicode to non-zero character classes.
5228 This \texttt{luatexja.define\_font} callback is called just when new Japanese font is loaded.
5229 %</en>
5230 %<*ja>
5231 このコールバックと次のコールバックは組をなしており,Unicode中に固定された文字コード
5232 番号を持たない文字を非零の文字クラスに割り当てることができる.
5233 このコールバックは新しい和文フォントが読み込まれたときに呼び出される.
5234 %</ja>
5235
5236 \begin{lstlisting}[numbers=left]
5237 function (<table> jfont_info, <number> font_number)
5238   return <table> new_jfont_info
5239 end
5240 \end{lstlisting}
5241 %<*en>
5242 \verb+jfont_info+ has the following fields,
5243 \emph{which may not overwritten by a user}:
5244 \begin{description}
5245 \item[\texttt{size}]
5246 The font size specified at \cs{jfont} in scaled points ($1\,\mathrm{sp}=2^{-16}\,\mathrm{pt}$).
5247 \item[\texttt{zw}, \texttt{zh}, \texttt{kanjiskip}, \texttt{xkanjiskip}]
5248 These are scaled value of those specified by the JFM, by the font size.
5249 \item[\texttt{jfm}]
5250 The internal number of the JFM.
5251 \item[\texttt{var}]
5252 The value of \texttt{jfmvar}~key, which is specified at \cs{jfont}.
5253 The default value is the empty string.
5254 \item[\texttt{chars}]
5255 The mapping table from character codes to its character classes.\\
5256 The specification \texttt{[i].chars=\{\meta{character}, ...\}} in the JFM will be  stored in this
5257            field as \texttt{chars=\{[\meta{character}]=\,$i$, ...\}}.
5258 \item[\texttt{char\_type}]
5259 For $i\in\omega$, \texttt{char\_type[$i$]} is information of characters whose class is
5260            $i$, and has the following fields:
5261 \begin{itemize}
5262  \item \texttt{width},~\texttt{height}, \texttt{depth},
5263   \texttt{italic}, \texttt{down},~\texttt{left}\ are just
5264        scaled value of those specified by the JFM, by the font size.
5265  \item \texttt{align} is a number which is determined from \texttt{align}~field in the JFM:
5266 \[
5267  \begin{cases*}
5268   1&(\texttt{'right'} in JFM),\\
5269   0.5&(\texttt{'middle'} in JFM),\\
5270   0&(otherwise).
5271  \end{cases*}
5272 \]
5273 \end{itemize}
5274 For $i$,~$j\in \omega$, \texttt{char\_type[$i$][$j$]} stores a kern or a glue which will be inserted
5275 between character class~$i$ and class~$j$.
5276 \end{description}
5277 %</en>
5278 %<*ja>
5279 \verb+jfont_info+ は最低限以下のフィールドを持つが,これらを書き換えてはならない:
5280 \begin{cslist}
5281 \item[size]
5282 実際に使われるフォントサイズ(sp単位).$1\,\mathrm{sp}=2^{-16}\,\mathrm{pt}$.
5283 \item[zw\textrm{, }zh\textrm{, }kanjiskip\textrm{, }xkanjiskip]
5284 JFMファイルで指定されているそれぞれの値をフォントサイズに合わせてスケーリングしたものを
5285 sp単位で格納している.
5286 \item[jfm]
5287 利用されているJFMを識別するための番号.
5288 \item[var]
5289 \cs{jfont},~\cs{tfont} で指定された \texttt{jfmvar} キーの値(未指定のときは空文字列).
5290 \item[chars]
5291 文字コードから文字クラスへの対応が記述されたテーブル.\\
5292 JFM内の \texttt{[i].chars=\{\meta{character}, ...\}} という指定は\
5293 \texttt{chars=\{[\meta{character}]=\,$i$, ...\}} という形式に変換されている.
5294 \item[char\_type]
5295 $i\in\omega$に対して,\texttt{char\_type[$i$]} は文字クラス$i$の文字の寸法を格納しており,
5296 以下のフィールドを持つ.
5297 \begin{itemize}
5298  \item \texttt{width},~\texttt{height}, \texttt{depth},
5299   \texttt{italic}, \texttt{down},~\texttt{left}\ は
5300 JFMで指定されているそれぞれの値をスケーリングしたものである.
5301  \item \texttt{align} はJFMで指定されている値によって,
5302 \[
5303  \begin{cases*}
5304   1&(\texttt{'right'} in JFM),\\
5305   0.5&(\texttt{'middle'} in JFM),\\
5306   0&(otherwise).
5307  \end{cases*}
5308 \]
5309 のいずれかの値をとる.
5310 \end{itemize}
5311 $i$,~$j\in \omega$に対して,\texttt{char\_type[$i$][$j$]} は
5312 文字クラス$i$の文字と$j$の文字の間に挿入されるグルーやカーンの情報を格納している.
5313
5314 間に入るものがカーンであれば,この値は%
5315 \texttt{[$j$]=\{\meta{kern}, ratio=\meta{ratio}\}}であり,
5316 \meta{kern}はカーンの値をsp単位で表したものである.
5317   
5318 一方,間に入るものがグルーであれば,この値は以下のキーを持つテーブルである.
5319 \begin{description}
5320   \item[{[1], [2], [3]}]
5321   グルーのそれぞれ自然長,伸び量,縮み量をsp単位で表したもの.
5322   \item[\texttt{priority}] (バージョン2以降の)JFMでの指定 \texttt{\{\meta{stretch},\meta{shrink}\}} を
5323   \[
5324     (\text{\meta{stretch}}+4)\cdot 8+\text{\meta{shrink}}+4
5325   \]
5326   として0--63の整数にパックしたもの.
5327   \item[\texttt{ratio}, \texttt{kanjiskip\_natural}, \texttt{kanjiskip\_stretch}, \texttt{kanjiskip\_shrink}]
5328   JFM中の同名のフィールドの値がそのまま使われている.
5329 \end{description}
5330 \item[chars\_cbcache]
5331 文字クラス決定の処理で.キャッシュとして使われる.
5332 \end{cslist}
5333 %</ja>
5334
5335 %<*en>
5336 The returned table \verb+new_jfont_info+ also should include these fields, but
5337 you are free to add more fields (to use them in the \texttt{luatexja.find\_char\_class} callback).
5338 The \verb+font_number+ is a font number.
5339 %</en>
5340 %<*ja>
5341 戻り値の \verb+new_jfont_info+ テーブルも上に述べたフィールドをそのまま含まなければならないが,
5342 それ以外にユーザが勝手にフィールドを付け加えることは自由である.
5343 \verb+font_number+ はフォント番号である.
5344 %</ja>
5345
5346 %<*en>
5347 A good example of this and the next callbacks is the \Pkg{luatexja-otf}
5348              package, supporting \verb+"AJ1-xxx"+ form for Adobe-Japan1
5349              CID characters in a JFM. This callback doesn't replace any
5350              code of \LuaTeX-ja.
5351 %</en>
5352 %<*ja>
5353 これと次のコールバックの良い使用例は\Pkg{luatexja-otf}パッケージであり,
5354 JFM中でAdobe-Japan1 CIDの文字を \verb+"AJ1-xxx"+ の形で指定するために
5355 用いられている.
5356 %</ja>
5357
5358 %<en>\item[\texttt{luatexja.find\_char\_class} callback]
5359 %<ja>\item[\texttt{luatexja.find\_char\_class}コールバック]
5360 %<*en>
5361 This callback is called just when \LuaTeX-ja is trying to determine which
5362              character class a character \verb+chr_code+ belongs.
5363 A function used in this callback should be in the following form:
5364 %</en>
5365 %<*ja>
5366 このコールバックは\LuaTeX-jaが \verb+chr_code+ の文字がどの文字クラスに
5367 属するかを決定しようとする際に呼び出される.
5368 このコールバックで呼び出される関数は次の形をしていなければならない:
5369 %</ja>
5370 \begin{lstlisting}[numbers=left]
5371 function (<number> char_class, <table> jfont_info, <number> char_code)
5372   if char_class~=0 then return char_class
5373   else
5374     ....
5375     return (<number> new_char_class or 0)
5376   end
5377 end
5378 \end{lstlisting}
5379
5380 %<*en>
5381 The argument \verb+char_class+ is the result of \LuaTeX-ja's default
5382              routine or previous function calls in this callback, hence
5383              this argument may not be 0. Moreover, the returned
5384              \verb+new_char_class+ should be as same as \verb+char_class+ when \verb+char_class+
5385              is not~0, otherwise you will overwrite the \LuaTeX-ja's
5386              default routine.
5387 %</en>
5388 %<*ja>
5389 引数 \verb+char_class+ は\LuaTeX-jaのデフォルトルーチンか,このコールバックの
5390 直前の関数呼び出しの結果を含んでおり,したがってこの値は0ではないかもしれない.
5391 さらに,戻り値の \verb+new_char_class+ は \verb+char_class+ が非零のときには
5392 \verb+char_class+ の値と同じであるべきで,そうでないときは\LuaTeX-jaの
5393 デフォルトルーチンを書き換えることになる.
5394 %</ja>
5395
5396 %<en>\item[\texttt{luatexja.set\_width} callback]
5397 %<ja>\item[\texttt{luatexja.set\_width}コールバック]
5398 %<*en>
5399 This callback is called when \LuaTeX-ja is trying to encapsule a
5400              \textbf{JAchar} \textit{glyph\_node}, to adjust its
5401              dimension and position.
5402 %</en>
5403 %<*ja>
5404 このコールバックは\LuaTeX-jaが\textbf{JAchar}の寸法と位置を調節するために
5405 その\textit{glyph\_node}をカプセル化しようとする際に呼び出される.
5406 %</ja>
5407 \begin{lstlisting}[numbers=left]
5408 function (<table> shift_info, <table> jfont_info, <table> char_type)
5409   return <table> new_shift_info
5410 end
5411 \end{lstlisting}
5412
5413 %<*en>
5414 The argument \verb+shift_info+ and the returned \verb+new_shift_info+ have
5415 \texttt{down} and \texttt{left} fields, which are the amount of shifting
5416              down/left the character in a scaled point.
5417 %</en>
5418 %<*ja>
5419 引数 \verb+shift_info+ と戻り値の \verb+new_shift_info+ は
5420 \texttt{down}と\texttt{left}のフィールドを持ち,これらの値は
5421 文字の下/左へのシフト量(sp単位)である.
5422 %</ja>
5423
5424 %<*en>
5425 A good example is \Pkg{test/valign.lua}.
5426 After loading this file, the vertical position of glyphs is automatically
5427 adjusted; the ratio $(\hbox{height}:\hbox{depth})$ of glyphs is adjusted
5428 to be that of letters in the character class~0. For example, suppose that
5429 \begin{itemize}
5430 \item The setting of the JFM: $(\hbox{height})=88x$, $(\hbox{depth})=12x$
5431   (the standard values of Japanese OpenType fonts);
5432 \item The value of the real font: $(\hbox{height})=28y$, $(\hbox{depth})=5y$
5433   (the standard values of Japanese TrueType fonts).
5434 \end{itemize}
5435 Then, the position of glyphs is shifted up by
5436 %</en>
5437 %<*ja>
5438 良い例が\Pkg{test/valign.lua}である.このファイルが読み込まれた状態では,
5439              JFM内で規定された文字クラス0の文字における$(\hbox{高
5440              さ}):(\hbox{深さ})$の比になるように,実際のフォントの出力上
5441              下位置が自動調整される.例えば,
5442 \begin{itemize}
5443 \item JFM側の設定:$(\hbox{高さ})=88x$, $(\hbox{深さ})=12x$%
5444 (和文OpenTypeフォントの標準値)
5445 \item 実フォント側の数値:$(\hbox{高さ})=28y$, $(\hbox{深さ})=5y$(和文TrueTypeフォントの標準値)
5446 \end{itemize}
5447 となっていたとする.すると,実際の文字の出力位置は,以下の量だけ上にずらされることとなる:
5448 %</ja>
5449 \[
5450  \frac{88x}{88x+12x} (28y+5y) - 28y = \frac{26}{25}y= 1.04y.
5451 \]
5452 \end{description}
5453
5454 %<en>\section{Parameters}
5455 %<ja>\section{パラメータ}
5456 \subsection{\cs{ltjsetparameter}}
5457 \label{ssec:param}
5458
5459 %<*en>
5460 As described before, \cs{ltjsetparameter} and \cs{ltjgetparameter} are
5461 commands for accessing most parameters of \LuaTeX-ja. One of the main
5462 reason that \LuaTeX-ja didn't adopted the syntax similar to that of \pTeX\
5463 (\textit{e.g.},~\verb+\prebreakpenalty`)=10000+)
5464 is the position of \verb+hpack_filter+ callback in the source
5465 of \LuaTeX, see Section~\ref{sec-para}.
5466 %</en>
5467 %<*ja>
5468 先に述べたように,\LuaTeX-jaの内部パラメータにアクセスするには
5469 \cs{ltjsetparameter}(または \cs{ltjglobalsetparameter})と \cs{ltjgetparameter} を用いる.
5470 \LuaTeX-jaが\pTeX のような文法(例えば,\verb+\prebreakpenalty`)=10000+)を
5471 採用しない理由の一つは,\LuaTeX のソースにおける \verb+hpack_filter+
5472 コールバックの位置にある.\ref{sec-para}章を参照.
5473 %</ja>
5474
5475 %<*en>
5476 \cs{ltjsetparameter} and \cs{ltjglobalsetparameter} are commands
5477 for assigning parameters. These take one argument which is a key-value list.
5478 The difference between these two commands is the
5479 scope of assignment;
5480 \cs{ltjsetparameter} does a local assignment and
5481 \cs{ltjglobalsetparameter} does a global one by default.
5482 They also obey the value of \cs{globaldefs}, like other assignments.
5483 %</en>
5484 %<*ja>
5485 \cs{ltjsetparameter} と \cs{ltjglobalsetparameter} はパラメータを
5486 指定するための命令で,key-valueリストを
5487 引数としてとる.両者の違いはスコープであり,標準では
5488 \cs{ltjsetparameter} はローカルな設定を行うのに対し,
5489 \cs{ltjglobalsetparameter} はグローバルな設定を行う.
5490 また,他のパラメータ指定と同様に \cs{globaldefs} の値にも従う.
5491 %</ja>
5492
5493 %<*en>
5494 The following is the list of parameters which can be specified by the
5495 \cs{ltjsetparameter} command. [\cs{cs}] indicates the counterpart
5496 in \pTeX, and symbols beside each parameter has the following meaning:
5497 %</en>
5498 %<*ja>
5499 以下は \cs{ltjsetparameter} に指定することができるパラメータの一覧である.
5500 [\cs{cs}]は\pTeX における対応物を示す.
5501 また,それぞれのパラメータの右上の記号には次の意味がある:
5502 %</ja>
5503 \begin{itemize}
5504 %<*en>
5505 \item ``$\ast$'' : values at the end of a paragraph or a hbox are
5506 adopted in the whole paragraph or the whole hbox.
5507 %</en>
5508 %<*ja>
5509 \item ``$\ast$'':段落やhboxの終端での値がその段落/hbox全体で用いられる.
5510 %</ja>
5511 %<*en>
5512 \item ``\dagger'': assignments are always global.
5513 %</en>
5514 %<*ja>
5515 \item ``\dagger'':指定は常にグローバルになる.
5516 %</ja>
5517 \end{itemize}
5518
5519 \begin{cslist}[style=standard]
5520 \item[\DParam{jcharwidowpenalty}\,=\meta{penalty}$^\ast$] [\cs{jcharwidowpenalty}]\
5521
5522 %<*en>
5523 Penalty value for suppressing orphans. This penalty is inserted just
5524              after the last \textbf{JAchar} which is not regarded as a
5525              (Japanese) punctuation mark.
5526 %</en>
5527 %<*ja>
5528 パラグラフの最後の字が孤立して改行されるのを防ぐためのペナルティの値.
5529 このペナルティは(日本語の)句読点として扱われない最後の\textbf{JAchar}の直後に
5530 挿入される.
5531 %</ja>
5532
5533 \item[\DParam{kcatcode}\,=\{\meta{char\_code},\meta{natural number}\}$^\ast$]\
5534
5535 %<*en>
5536 An additional attributes which each character whose character code is \meta{char\_code} has.
5537 At version~20120506.0 or later, the lowermost bit of \meta{natural number} indicates
5538              whether the character is considered as a punctuation mark
5539              (see the description of \Param{jcharwidowpenalty} above).
5540 %</en>
5541 %<*ja>
5542 文字コードが\meta{char\_code}の文字が持つ付加的な属性値.
5543 バージョン20120506.0以降では,\meta{natural number}の最下位ビットが,その文字が句読点と
5544 みなされるかどうかを表している(上の\Param{jcharwidowpenalty}の記述を参照).
5545 %</ja>
5546
5547 \item[\DParam{prebreakpenalty}\,=\{\meta{char\_code},\meta{penalty}\}$^\ast$] [\cs{prebreakpenalty}]\
5548
5549 %<*ja>
5550 文字コード\meta{char\_code}の\textbf{JAchar}が行頭にくることを抑止するために,
5551              この文字の前に挿入/追加されるペナルティの量を指定する.
5552
5553 例えば閉じ括弧「〗」は絶対に行頭にきてはならないので,
5554 \begin{lstlisting}
5555 \ltjsetparameter{prebreakpenalty={`〙,10000}}
5556 \end{lstlisting}
5557 と,最大値の10000が標準で指定されている.他にも,小書きのカナなど,絶対禁止とい
5558              うわけではないができれば行頭にはきて欲しくない場合に,0と
5559              10000の間の値を指定するのも有用であろう.
5560
5561 \pTeX では,\cs{prebreakpenalty}, \cs{postbreakpenalty}において,
5562 \begin{itemize}
5563 \item 一つの文字に対して,pre, postどちらか一つしか指定することができない%
5564   \footnote{後から指定した方で上書きされる.}
5565 \item pre, post合わせて256文字分の情報を格納することしかできない
5566 \end{itemize}
5567 という制限があったが,\LuaTeX-jaではこれらの制限は解消されている.
5568 %</ja>
5569 %<*en>
5570 Set a penalty which is inserted automatically before the character \meta{char\_code},
5571 to prevent a line starts from this character. For example, a line cannot started
5572 with one of closing brackets ``〗'', so \LuaTeX-ja sets
5573 \begin{lstlisting}
5574 \ltjsetparameter{prebreakpenalty={`〙,10000}}
5575 \end{lstlisting}
5576 by default.
5577
5578 \pTeX\ has following restrictions on \cs{prebreakpenalty} and \cs{postbreakpenalty},
5579 but they don't exist in \LuaTeX-ja:
5580 \begin{itemize}
5581  \item Both \cs{prebreakpenalty} and \cs{postbreakpenalty} cannot be set
5582 for the same character.
5583  \item We can set \cs{prebreakpenalty} and \cs{postbreakpenalty} up to 256~characters.
5584 \end{itemize}
5585 %</en>
5586
5587 \item[\DParam{postbreakpenalty}\,=\{\meta{char\_code},\meta{penalty}\}$^\ast$]
5588            [\cs{postbreakpenalty}]\
5589
5590 %<*ja>
5591 文字コード\meta{char\_code}の\textbf{JAchar}が行末にくることを抑止するために,
5592              この文字の後に挿入/追加されるペナルティの量を指定する.
5593 %</ja>
5594 %<*en>
5595 Set a penalty which is inserted automatically after the character \meta{char\_code},
5596 to prevent a line ends with this character.
5597 %</en>
5598
5599 \item[\DParam{jatextfont}\,=\{\meta{jfam},\meta{jfont\_cs}\}$^\ast$]
5600 %<en>[\cs{textfont} in \TeX]
5601 %<ja>[\TeX の \cs{textfont}]
5602 \item[\DParam{jascriptfont}\,=\{\meta{jfam},\meta{jfont\_cs}\}$^\ast$]
5603 %<en>[\cs{scriptfont} in \TeX]
5604 %<ja>[\TeX の \cs{scriptfont}]
5605 \item[\DParam{jascriptscriptfont}\,=\{\meta{jfam},\meta{jfont\_cs}\}$^\ast$]
5606 %<en>[\cs{scriptscriptfont} in \TeX]
5607 %<ja>[\TeX の \cs{scriptscriptfont}]
5608 \item[\DParam{yjabaselineshift}\,=\meta{dimen}]\
5609 \item[\DParam{yalbaselineshift}\,=\meta{dimen}] [\cs{ybaselineshift}]
5610 \item[\DParam{tjabaselineshift}\,=\meta{dimen}]\
5611 \item[\DParam{talbaselineshift}\,=\meta{dimen}] [\cs{tbaselineshift}]
5612
5613 \item[\DParam{jaxspmode}\,=\{\meta{char\_code},\meta{mode}\}$^\ast$]\
5614
5615 %<*en>
5616 Set whether inserting \Param{xkanjiskip} is allowed before/after a \textbf{JAchar} whose character code is \meta{char\_code}.
5617 The followings are allowed for \meta{mode}:
5618 %</en>
5619 %<*ja>
5620 文字コードが\meta{char\_code}の\textbf{JAchar}の前/後ろに\Param{xkanjiskip}の
5621 挿入を許すかどうかの設定.
5622 以下の\meta{mode}が許される:
5623 %</ja>
5624 \begin{description}
5625 %<en>\item[0, \texttt{inhibit}] Insertion of \Param{xkanjiskip} is inhibited before the character, nor after the character.
5626 %<ja>\item[0, \texttt{inhibit}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも禁止される.
5627 %<en>\item[1, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed before the character, but not after.
5628 %<ja>\item[1, \texttt{preonly}] \Param{xkanjiskip}の挿入は文字の前では許されるが,後ろでは許されない.
5629 %<en>\item[2, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed after the character, but not before.
5630 %<ja>\item[2, \texttt{postonly}] \Param{xkanjiskip}の挿入は文字の後ろでは許されるが,前では許されない.
5631 %<en>\item[3, \texttt{allow}] Insertion of \Param{xkanjiskip} is allowed both before the character and after the character. This is the default value.
5632 %<ja>\item[3, \texttt{allow}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも許される.これがデフォルトの値である.
5633 \end{description}
5634 %<*en>
5635 This parameter is similar to the \cs{inhibitxspcode} primitive of \pTeX, but not compatible with \cs{inhibitxspcode}.
5636 %</en>
5637 %<*ja>
5638 このパラメータは\pTeX の \cs{inhibitxspcode} プリミティブと似ているが,
5639 互換性はない.
5640 %</ja>
5641 \item[\DParam{alxspmode}\,=\{\meta{char\_code},\meta{mode}\}$^\ast$] [\cs{xspcode}]\
5642
5643 %<*en>
5644 Set whether inserting \Param{xkanjiskip} is allowed before/after a
5645              \textbf{ALchar} whose character code is \meta{char\_code}.
5646              The followings are allowed for \meta{mode}:
5647 %</en>
5648 %<*ja>
5649 文字コードが\meta{char\_code}の\textbf{ALchar}の前/後ろに\Param{xkanjiskip}の
5650 挿入を許すかどうかの設定.
5651 以下の\meta{mode}が許される:
5652 %</ja>
5653 \begin{description}
5654 %<en>\item[0, \texttt{inhibit}] Insertion of \Param{xkanjiskip} is inhibited before the character, nor after the character.
5655 %<ja>\item[0, \texttt{inhibit}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも禁止される.
5656 %<en>\item[1, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed before the character, but not after.
5657 %<ja>\item[1, \texttt{preonly}] \Param{xkanjiskip}の挿入は文字の前では許されるが,後ろでは許されない.
5658 %<en>\item[2, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed after the character, but not before.
5659 %<ja>\item[2, \texttt{postonly}] \Param{xkanjiskip}の挿入は文字の後ろでは許されるが,前では許されない.
5660 %<en>\item[3, \texttt{allow}] Insertion of \Param{xkanjiskip} is allowed before the character and after the character. This is the default value.
5661 %<ja>\item[3, \texttt{allow}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも許される.これがデフォルトの値である.
5662 \end{description}
5663 %<*en>
5664 Note that parameters \Param{jaxspmode} and \Param{alxspmode} share a common table, hence these two parameters are synonyms of each other.
5665 %</en>
5666 %<*ja>
5667 \Param{jaxspmode}と\Param{alxspmode}は共通のテーブルを用いているため,
5668 これら2つのパラメータは互いの別名となっていることに注意する.
5669 %</ja>
5670
5671 \item[\DParam{autospacing}\,=\meta{bool}] [\cs{autospacing}]
5672 \item[\DParam{autoxspacing}\,=\meta{bool}] [\cs{autoxspacing}]
5673 \item[\DParam{kanjiskip}\,=\meta{skip}$^\ast$] [\cs{kanjiskip}]\
5674
5675 %<*ja>
5676 デフォルトで2つの\textbf{JAchar}の間に挿入されるグルーである.
5677 通常では,\pTeX と同じようにフォントサイズに比例して変わることはない.
5678 しかし,自然長が \cs{maxdimen} の場合は,例外的に和文フォントのJFM側で指定されている
5679 値を採用(こちらはフォントサイズに比例)することになっている.
5680 %</ja>
5681 %<*en>
5682 The default glue which inserted between two \textbf{JAchar}s.
5683 Changing current Japanese font does not alter this parameter, as \pTeX.
5684
5685 If the natural width of this parameter is \cs{maxdimen}, \LuaTeX-ja uses
5686 the value which is specified in the JFM for current Japanese font (See Subsection~\ref{ssec:jfm-str}).
5687 %</en>
5688
5689 \item[\DParam{xkanjiskip}\,=\meta{skip}$^\ast$] [\cs{xkanjiskip}]\
5690
5691 %<*ja>
5692 デフォルトで\textbf{JAchar}と\textbf{ALchar}の間に挿入されるグルーである.
5693 \Param{kanjiskip}と同じように,通常ではフォントサイズに比例して変わることはないが,
5694 自然長が \cs{maxdimen} の場合が例外である.
5695 %</ja>
5696 %<*en>
5697 The default glue which inserted between a \textbf{JAchar} and an
5698       \textbf{ALchar}.
5699 Changing current font does not alter this parameter, as \pTeX.
5700
5701 As \Param{kanjiskip}, if the natural width of this parameter is \cs{maxdimen}, \LuaTeX-ja uses
5702 the value which is specified in the JFM for current Japanese font (See Subsection~\ref{ssec:jfm-str}).
5703 %</en>
5704
5705
5706 \item[\DParam{differentjfm}\,=\meta{mode}$^\dagger$]\
5707
5708 %<*en>
5709 Specify how glues/kerns between two \textbf{JAchar}s whose JFM (or size) are different.
5710 The allowed arguments are the followings:
5711 %</en>
5712 %<*ja>
5713 JFM(もしくはサイズ)が異なる2つの\textbf{JAchar}の間にグルー/カーンをどのように
5714 入れるかを指定する.
5715 許される値は以下の通り:
5716 %</ja>
5717 \begin{quote}
5718 \texttt{average},
5719 \texttt{both},
5720 \texttt{large},
5721 \texttt{small},
5722 \texttt{pleft},
5723 \texttt{pright},
5724 \texttt{paverage}
5725 \end{quote}
5726 %<*en>
5727 The default value is \texttt{paverage}. \dots
5728 %</en>
5729 %<*ja>
5730 デフォルト値は \texttt{paverage} である.
5731 各々の値による差異の詳細は\ref{ssec:cluster-wa}節の「『右空白』の算出」を参照してほしい.
5732 %</ja>
5733
5734 \item[\DParam{jacharrange}\,=\meta{ranges}]
5735 \item[\DParam{kansujichar}\,=\{\meta{digit}, \meta{char\_code}\}$^\ast$] [\cs{kansujichar}]
5736
5737 \item[\DParam{direction}\,=\meta{dir}\ \hbox{\normalfont\rmfamily (always local)}]\
5738
5739 %<*en>
5740 Assigning to this parameter has the same effect as
5741 \cs{yoko}~(if $\hbox{\meta{dir}}=4$), \cs{tate}~(if $\hbox{\meta{dir}}=3$),
5742 \cs{dtou}~(if $\hbox{\meta{dir}}=1$) or \cs{utod}~(if $\hbox{\meta{dir}}=11$).
5743 If the argument \meta{dir} is not one of 4,~3, 1~nor~11,
5744 the behavior of this assignment is undefined.
5745 %</en>
5746 %<*ja>
5747 組方向を変更する \cs{yoko}~(if $\hbox{\meta{dir}}=4$), \cs{tate}~(if $\hbox{\meta{dir}}=3$),
5748 \cs{dtou}~(if $\hbox{\meta{dir}}=1$), \cs{utod}~(if $\hbox{\meta{dir}}=11$) と同じ役割を持つ.
5749 利用可能な状況もこれら4命令と同一である.引数\meta{dir}が4,~3, 1,~11のいずれでも無いときの
5750 動作は未定義である.
5751 %</ja>
5752
5753 \end{cslist}
5754
5755
5756 \subsection{\cs{ltjgetparameter}}
5757 \label{ssec:getpar}
5758 %<*en>
5759 \cs{ltjgetparameter} is a control sequence for acquiring parameters. It
5760 always takes a parameter name as first argument.
5761 %</en>
5762 %<*ja>
5763 \cs{ltjgetparameter} はパラメータの値を取得するための命令であり,
5764 常にパラメータの名前を第一引数にとる.
5765 %</ja>
5766 \begin{LTXexample}
5767 \ltjgetparameter{differentjfm},
5768 \ltjgetparameter{autospacing},
5769 \ltjgetparameter{kanjiskip},
5770 \ltjgetparameter{prebreakpenalty}{`)}.
5771 \end{LTXexample}
5772
5773 %<*en>
5774 \emph{The return value of\/ \cs{ltjgetparameter} is
5775 always a string}, which is outputted by \texttt{tex.write()}.
5776 Hence any character other than space~``\texttt{\char32}''~(\texttt{U+0020}) has the category code
5777 12~(other), while the space has 10~(space).
5778 %</en>
5779 %<*ja>
5780 \emph{\cs{ltjgetparameter} の戻り値は常に文字列である.}
5781 これは\texttt{tex.write()}によって出力しているためで,空白「\texttt{\char32}」
5782 (\texttt{U+0020})を除いた文字のカテゴリーコードは全て12~(other)となる.
5783 一方,空白のカテゴリーコードは10~(space)である.
5784 %</ja>
5785
5786 \begin{itemize}
5787 \item
5788 %<*en>
5789 If first argument is one of the
5790 following, no  additional argument is needed.
5791 %</en>
5792 %<*ja>
5793 第1引数が次のいずれかの場合には,追加の引数は必要ない.
5794 %</ja>
5795 \begin{quote}
5796 \sffamily
5797 jcharwidowpenalty, yjabaselineshift, yalbaselineshift, autospacing, autoxspacing,\\
5798 kanjiskip, xkanjiskip, differentjfm, direction
5799 \end{quote}
5800 %<*en>
5801 Note that \verb+\ltjgetparameter{autospacing}+~and~\verb+\ltjgetparameter{autoxspacing}+
5802 returns 1 or 0, not
5803 \texttt{true}~nor~\texttt{false}.
5804 %</en>
5805 %<*ja>
5806 \verb+\ltjgetparameter{autospacing}+ と \verb+\ltjgetparameter{autoxspacing}+ は,
5807 \texttt{true}や\texttt{false}を返すの\emph{ではなく},
5808 1か0のいずれかを返すことに注意,
5809 %</ja>
5810
5811 \item
5812 %<*en>
5813 If first argument is one of the
5814 following, an additional argument---a character code, for example---is needed.
5815 %</en>
5816 %<*ja>
5817 第1引数が次のいずれかの場合には,さらに文字コードを第2引数としてとる.
5818 %</ja>
5819 \begin{quote}
5820 \sffamily
5821 kcatcode, prebreakpenalty, postbreakpenalty, jaxspmode, alxspmode
5822 \end{quote}
5823 %<*en>
5824 \verb+\ltjgetparameter{jaxspmode}{...}+~and~\verb+\ltjgetparameter{alxspmode}{...}+
5825 returns 0,~1, 2,~or~3, instead of \texttt{preonly} etc.
5826 %</en>
5827 %<*ja>
5828 \verb+\ltjgetparameter{jaxspmode}{...}+ や \verb+\ltjgetparameter{alxspmode}{...}+\
5829 は,\texttt{preonly} などといった文字列ではなく,0から3までの値を返す.
5830 %</ja>
5831
5832 \item
5833 %<*en>
5834 \verb+\ltjgetparameter{jacharrange}{+\meta{range}\verb+}+ returns \texttt{0}
5835 if ``characters which belong to the character range~\meta{range} are \textbf{JAchar}'',
5836 \texttt{1} if ``\dots~are \textbf{ALchar}''.
5837 Although there is no character range~$-1$, specifying $-1$ to \meta{range} does not cause an
5838       error (returns 1).
5839 %</en>
5840 %<*ja>
5841 \verb+\ltjgetparameter{jacharrange}{+\meta{range}\verb+}+ は,\meta{range}が\textbf{JAchar}達の
5842 範囲ならば0を,そうでなければ1を返す.「$-1$番の文字範囲」は存在しないが,\meta{range}に$-1$を
5843 指定してもエラーは発生しない(1を返す).
5844 %</ja>
5845
5846 \item
5847 %<*en>
5848 For an integer~\meta{digit} between 0~and~9,
5849      \verb+\ltjgetparameter{kansujichar}{+\meta{digit}\verb+}+ returns the character code
5850 of the result of \cs{kansuji}\meta{digit}.
5851 %</en>
5852 %<*ja>
5853 0--9の数\meta{digit}に対して,
5854 \verb+\ltjgetparameter{kansujichar}{+\meta{digit}\verb+}+ は,\cs{kansuji}\meta{digit}で出力され
5855      る文字の文字コードを返す.
5856 %</ja>
5857
5858 \item
5859 %<*en>
5860 \verb+\ltjgetparameter{adjustdir}+ returns a integer which represents
5861 the direction of the surrounding vertical list.
5862 As \Param{direction}, the return value 1 means \emph{dtou} direction,
5863 3 means \emph{tate} direction (vertical typesetting),
5864 and 4 means \emph{yoko} direction (horizontal typesetting).
5865 %</en>
5866 %<*ja>
5867 \verb+\ltjgetparameter{adjustdir}+ は,周囲のvboxの組方向(言い換えれば,
5868 \cs{vadjust} で用いられる組方向)を表す数値を返す.
5869 \Param{direction}と同様に,1は \cs{dtou} 方向を,
5870 3は縦組みを,4は横組みを表す.
5871 %</ja>
5872
5873 \item
5874 %<*en>
5875 For an integer~\meta{register} between 0~and~65535,
5876 \verb+\ltjgetparameter{boxdir}{+\meta{register}\verb+}+ returns the direction of
5877 \cs{box}\meta{register}. If this box register is void, the returned value is zero.
5878 %</en>
5879 %<*ja>
5880 0--65535の数\meta{register}に対して,
5881 \verb+\ltjgetparameter{boxdir}{+\meta{register}\verb+}+ は,\cs{box}\meta{register}に
5882 格納されているボックスの組方向を表す.もしこのレジスタが空の場合は,0が返される.
5883 %</ja>
5884
5885 \item
5886 %<*en>
5887 The following parameter names \emph{cannot be specified} in \cs{ltjgetparameter}.
5888 %</en>
5889 %<*ja>
5890 次のパラメータ名を \cs{ltjgetparameter} に指定することはできない.
5891 %</ja>
5892 \begin{quote}
5893 \sffamily
5894 jatextfont, jascriptfont, jascriptscriptfont, jacharrange
5895 \end{quote}
5896
5897 \item
5898 %<*en>
5899 \verb+\ltjgetparameter{chartorange}{+\meta{char\_code}\verb+}+ returns
5900 the range number which \meta{char\_code} belongs to
5901 (although there is no parameter named ``chartorange'').
5902
5903 If \meta{char\_code} is between 0 and 127, this \meta{char\_code} does not belong to
5904 any character range. In this case,
5905       \verb+\ltjgetparameter{chartorange}{+\meta{char\_code}\verb+}+
5906 returns $-1$.
5907
5908 Hence, one can know whether \meta{char\_code} is \textbf{JAchar} or not
5909 by the following:
5910 %</en>
5911 %<*ja>
5912 \verb+\ltjgetparameter{chartorange}{+\meta{char\_code}\verb+}+ によって
5913 \meta{char\_code}の属する文字範囲の番号を知ることができる.
5914
5915 \meta{char\_code}に0--127の値を指定した場合(このとき,\meta{char\_code}が属する
5916 文字範囲は存在しない)は$-1$が返る.
5917
5918 そのため,\meta{char\_code}が\textbf{JAchar}か\textbf{ALchar}かは
5919 次で知ることができる:
5920 %</ja>
5921 \begin{quote}
5922 \ttfamily \verb+\ltjgetparameter{jacharrange}{\ltjgetparameter{chartorange}{+%
5923   \meta{char\_code}\verb+}}+\\\null\hfill\verb+% 0 if JAchar, 1 if ALchar+
5924 \end{quote}
5925
5926 %<*en>
5927 \item Because the returned value is string, the following conditionals do not work
5928 if \Param{kanjiskip} (or~\Param{xkanjiskip}) has the stretch part or the shrink part.
5929 \begin{lstlisting}
5930 \ifdim\ltjgetparameter{kanjiskip}>\z@ ... \fi
5931 \ifdim\ltjgetparameter{xkanjiskip}>\z@ ... \fi
5932 \end{lstlisting}
5933 The correct way is using a temporary register.
5934 \begin{lstlisting}
5935 \@tempskipa=\ltjgetparameter{kanjiskip} \ifdim\@tempskipa>\z@ ... \fi
5936 \@tempskipa=\ltjgetparameter{xkanjiskip}\ifdim\@tempskipa>\z@ ... \fi
5937 \end{lstlisting}
5938 %</en>
5939 %<*ja>
5940 \item 返り値が文字列であることから,\Param{kanjiskip}や\Param{xkanjiskip}を直接
5941 \ \cs{ifdim} を使って比較することは望ましくない.伸び量や縮み量を持っている時には,
5942 次はエラーを発生させる:
5943 \begin{lstlisting}
5944 \ifdim\ltjgetparameter{kanjiskip}>\z@ ... \fi
5945 \ifdim\ltjgetparameter{xkanjiskip}>\z@ ... \fi
5946 \end{lstlisting}
5947 レジスタに一旦代入するのが良い:
5948 \begin{lstlisting}
5949 \@tempskipa=\ltjgetparameter{kanjiskip} \ifdim\@tempskipa>\z@ ... \fi
5950 \@tempskipa=\ltjgetparameter{xkanjiskip}\ifdim\@tempskipa>\z@ ... \fi
5951 \end{lstlisting}
5952 %</ja>
5953
5954 \end{itemize}
5955
5956
5957 %<*en>
5958 \subsection{Alternative Commands to \cs{ltjsetparameter}}
5959 The basic method to set parameters of \LuaTeX-ja is to use
5960 \cs{ltjsetparameter}~or~\cs{ltjglobalsetparameter}.
5961 However, these commands are slow, because they parse a key-value list,
5962 so several alternative commands are used in \LuaTeX-ja.
5963 \emph{This subsection is not for general \LuaTeX-ja users.}
5964
5965 \paragraph{Setting \Param{kanjiskip}~or~\Param{xkanjiskip}}
5966 In \Pkg{ltjsclasses}, every size-changing command such as \cs{Large}
5967 changes \cs{kanjiskip}~and~\cs{xkanjiskip}.
5968 But a simple implementation, as the code below, is slow since
5969 two key-value lists are parsed by \cs{ltjsetparameter}:
5970 \begin{lstlisting}
5971   \ltjsetparameter{kanjiskip=0\zw plus .1\zw minus .01\zw}
5972   \@tempskipa=\ltjgetparameter{xkanjiskip}
5973   \ifdim\@tempskipa>\z@
5974     \if@slide
5975       \ltjsetparameter{xkanjiskip=0.1em}
5976     \else
5977       \ltjsetparameter{xkanjiskip=0.25em plus 0.15em minus 0.06em}
5978     \fi
5979   \fi
5980 \end{lstlisting}
5981
5982 Hence, \LuaTeX-ja defines more primitive commands, namely \cs{ltj@setpar@global},
5983 \cs{ltjsetkanjiskip}, and~\cs{ltjsetxkanjiskip}. Here
5984 \begin{quote}
5985   \lstinline+\ltj@setpar@global\ltjsetkanjiskip 10pt+
5986 \end{quote}
5987 and \lstinline+\ltjsetparameter{kanjiskip=10pt}+ has the same effect.
5988 The actual code of \Pkg{ltjsclasses} is shown below:
5989 \begin{lstlisting}
5990   \ltj@setpar@global
5991   \ltjsetkanjiskip{\z@ plus .1\zw minus .01\zw}
5992   \@tempskipa=\ltjgetparameter{xkanjiskip}
5993   \ifdim\@tempskipa>\z@
5994     \if@slide
5995       \ltjsetxkanjiskip.1em
5996     \else
5997       \ltjsetxkanjiskip.25em plus .15em minus .06em
5998     \fi
5999   \fi
6000 \end{lstlisting}
6001
6002 Note that using \cs{ltjsetkanjiskip}~or~\cs{ltjsetxkanjiskip} alone,
6003 that is, without executing \cs{ltj@setpar@global} in advance, is \emph{not} supported.
6004 %</en>
6005
6006 %<*ja>
6007 \subsection{\cs{ltjsetparameter} の代替}
6008 原則として各種内部パラメータの設定には \cs{ltjsetparameter} もしくは
6009 \ \cs{ltjglobalsetparameter}\ を用いることになるが,
6010 \cs{ltjsetparameter} の実行には時間がかかるという難点があり,
6011 \LuaTeX-ja の内部ではより高速に実行できる別の形式を用いている.
6012 \emph{本節は一般利用者むけの内容ではない.}
6013
6014 \paragraph{\Param{kanjiskip}, \Param{xkanjiskip}の設定}
6015 \pLaTeXe 新ドキュメントクラスでは,
6016 \begin{lstlisting}
6017 \def\@setfontsize#1#2#3{%
6018   ...
6019   \kanjiskip=0zw plus .1zw minus .01zw
6020   \ifdim\xkanjiskip>\z@
6021     \if@slide \xkanjiskip=0.1em \else
6022       \xkanjiskip=0.25em plus 0.15em minus 0.06em
6023     \fi
6024   \fi}
6025 \end{lstlisting}
6026 と,フォントサイズを変更するごとに \cs{kanjiskip}, \cs{xkanjiskip} を変更している.
6027 この \cs{@setfontsize} は文書の中で多数回実行されるので.
6028 \LuaTeX-ja 用に素直に書き換えた
6029 \begin{lstlisting}
6030   \ltjsetparameter{kanjiskip=0\zw plus .1\zw minus .01\zw}
6031   \@tempskipa=\ltjgetparameter{xkanjiskip}
6032   \ifdim\@tempskipa>\z@
6033     \if@slide
6034       \ltjsetparameter{xkanjiskip=0.1em}
6035     \else
6036       \ltjsetparameter{xkanjiskip=0.25em plus 0.15em minus 0.06em}
6037     \fi
6038   \fi
6039 \end{lstlisting}
6040 としたのではタイプセットが遅くなってしまう.
6041 そこで,\cs{ltjsetparameter} の中で
6042 \begin{itemize}
6043 \item \cs{globaldefs} の値を読み取る \cs{ltj@setpar@global}
6044 \item \Param{kanjiskip} の設定を行う \cs{ltjsetkanjiskip}
6045 \item \Param{xkanjiskip} の設定を行う \cs{ltjsetxkanjiskip}
6046 \end{itemize}
6047 を独立させ,\Pkg{ltjsclasses}では,
6048 \begin{lstlisting}
6049   \ltj@setpar@global
6050   \ltjsetkanjiskip{\z@ plus .1\zw minus .01\zw}
6051   \@tempskipa=\ltjgetparameter{xkanjiskip}
6052   \ifdim\@tempskipa>\z@
6053     \if@slide
6054       \ltjsetxkanjiskip.1em
6055     \else
6056       \ltjsetxkanjiskip.25em plus .15em minus .06em
6057     \fi
6058   \fi
6059 \end{lstlisting}
6060 としている.
6061 \cs{ltj@setpar@global}を直前に実行せず,単独で
6062 \cs{ltjsetkanjiskip}, \cs{ltjsetxkanjiskip}を実行することは想定されていないので注意.
6063
6064 %</ja>
6065
6066
6067 %<en>\section{Other Commands for plain \TeX\ and \LaTeXe}
6068 %<ja>\section{plainでも\LaTeX でも利用可能なその他の命令}
6069 %<en>\subsection{Commands for compatibility with \pTeX}
6070 %<ja>\subsection{\pTeX 互換用命令}
6071
6072 %<*en>
6073 The following commands are implemented for compatibility with \pTeX.
6074 Note that the former five commands don't support JIS~X~0213, but only JIS~X~0208.
6075 The last \cs{kansuji} converts an integer into its Chinese numerals.
6076 %</en>
6077 %<*ja>
6078 以下の命令は\pTeX との互換性のために実装されている.そのため,JIS~X~0213には対応せず,
6079 \pTeX と同じようにJIS~X~0208の範囲しかサポートしていない.
6080 %</ja>
6081 \begin{center}
6082 \cs{kuten}, \cs{jis}, \cs{euc}, \cs{sjis}, \cs{ucs}, \cs{kansuji}
6083 \end{center}
6084 %<*en>
6085 These six commands takes an internal integer, and returns a \emph{string}.
6086 %</en>
6087 %<*ja>
6088 これら6命令は内部整数を引数とするが,実行結果は\textbf{文字列}であることに注意.
6089 %</ja>
6090 \begin{LTXexample}
6091 \newcount\hoge
6092 \hoge="2423 %"
6093 \the\hoge, \kansuji\hoge\\
6094 \jis\hoge, \char\jis\hoge\\
6095 \kansuji1701
6096 \end{LTXexample}
6097
6098 %<*en>
6099 To change characters of Chinese numerals for each digit, set \Param{kansujichar} parameter:
6100 \begin{LTXexample}
6101 \ltjsetparameter{kansujichar={1,`壹}}
6102 \ltjsetparameter{kansujichar={7,`漆}}
6103 \ltjsetparameter{kansujichar={0,`零}}
6104 \kansuji1701
6105 \end{LTXexample}
6106 %</en>
6107
6108
6109 \subsection{\cs{inhibitglue}, \cs{disinhibitglue}}
6110 %<*en>
6111 \cs{inhibitglue} suppresses the insertion of a glue/kern soecified in JFM at the place.
6112 The following is an example, using a special JFM that there will be a glue between
6113 the beginning of a box and ``あ'', and also between ``あ''~and~``ウ''.
6114 %</en>
6115 %<*ja>
6116 \cs{inhibitglue} は発行箇所でのJFM由来グルー/カーンの挿入を抑制する.
6117 以下は,ボックスの始めと「あ」の間,「あ」「ウ」の間にグルーが入る特別なJFMを用いた例で
6118 ある.
6119 %</ja>
6120
6121 \begin{LTXexample}[width=0.4\textwidth]
6122 \jfont\g=HaranoAjiMincho-Regular:jfm=test \g
6123 \fbox{\hbox{あウあ\inhibitglue ウ}}
6124 \inhibitglue\par\noindent あ1
6125 \par\inhibitglue\noindent あ2
6126 \par\noindent\inhibitglue あ3
6127 \par )4)\inhibitglue 5
6128 \par\hrule\noindent あoff\inhibitglue ice
6129 \end{LTXexample}
6130
6131 %<*en>
6132 With the help of this example, we remark the specification of \cs{inhibitglue}:
6133 %</en>
6134 %<*ja>
6135 この例を援用して,\cs{inhibitglue} の仕様について述べる.
6136 %</ja>
6137 \begin{itemize}
6138 %<*en>
6139 \item The call of \cs{inhibitglue} in the (internal) vertical mode is
6140       simply ignored.
6141 %</en>
6142 %<*ja>
6143 \item \emph{\cs{inhibitglue} の垂直モード中での呼び出しは意味を持たない}\footnote{%
6144   この点は\TeX~Live~2014での\pTeX における \cs{inhibitglue} の仕様変更と同じである.
6145 }.
6146 4行目の入力で有効にならないのは,\cs{inhibitglue} の時点では垂直モードであり,
6147 \cs{noindent} の時点で水平モードになるからである.
6148 %</ja>
6149
6150 %<*en>
6151 \item \cs{inhibitglue} does \emph{not} suppress \Param{kanjiskip} or \cs{xkanjiskip}.
6152 %</en>
6153 %<*ja>
6154 \item \cs{inhibitglue}は\Param{kanjiskip}, \Param{xkanjiskip}の挿入は抑制しない.
6155   例えば上の例の6行目では,「)」と「5」の間には本来はJFM由来の半角空きが挿入されるはずだが,
6156   それが\cs{inhibitglue}で無効になったため,\Param{xkanjiskip}が代わりに挿入されている.
6157 %</ja>
6158
6159 %<*en>
6160 \item The call of \cs{inhibitglue} in the (restricted) horizontal
6161       mode is only effective on the spot; does not get over boundary of
6162       paragraphs. Moreover, \cs{inhibitglue} cancels ligatures and
6163       kernings, as shown in the last line of above example.
6164 %</en>i
6165 %<*ja>
6166 \item \cs{inhibitglue} の(制限された)水平モード中での呼び出しはその場でのみ
6167   有効であり,段落の境界を乗り越えない.
6168   さらに,\cs{inhibitglue} は上の例の最終行のように(欧文における)リガチャとカーニングを
6169   打ち消す.これは,\cs{inhibitglue} が内部的には「現在のリスト中にwhatsitノードを
6170   追加する」ことを行なっているからである.
6171 %</ja>
6172
6173 %<*en>
6174 \item The call of \cs{inhibitglue} in math mode is just ignored.
6175 %</en>
6176 %<*ja>
6177 \item \cs{inhibitglue} を数式モード中で呼び出した場合はただ無視される.
6178 %</ja>
6179
6180 %<*ja>
6181 \item \LaTeX で\LuaTeX-ja を使用する場合は,
6182 \cs{inhibitglue} の代わりとして \verb+\<+ を使うことができる.
6183 既に \verb+\<+ が定義されていた場合は,\LuaTeX-ja の読み込みで強制的に上書きされるので
6184 注意すること.
6185 %</ja>
6186 \end{itemize}
6187
6188 %<*en>
6189 \cs{disinhibitglue} suppresses the effect of \cs{inhbitglue}.
6190 In other words, \cs{disinhibitglue} allows the insertion of a glue/kern specified by JFM.
6191 If \cs{inhibitglue}~and~\cs{disinhibitglue} both specified at the same time,
6192 the latest one is effective.
6193 This commans is added in the version 20201224.0.
6194
6195 Note that \cs{disinhibitglue} also cancels ligatures and kernings.
6196 %</en>
6197 %<*ja>
6198 \cs{disinhibitglue}は\cs{inhibitglue}の効果を無効化する.
6199 言い換えれば,(\cs{inhibitglue}で抑制されたはずの))JFM由来グルー/カーンの挿入を許可する.
6200 同じ箇所に\cs{inhibitglue}と\cs{disinhibitglue}が両方ある場合は,後ろの指定が有効になる.
6201 この命令はバージョン20201224.0で追加された.
6202
6203 なお,\cs{disinhibitglue}もリガチャやカーニングを打ち消すことに注意されたい.これは
6204 (\cs{inhibitglue}と同様に)whatsitノードを使って実装されていることによる.
6205 %</ja>
6206
6207 \subsection{\cs{ltjfakeboxbdd}, \cs{ltjfakeparbegin}}
6208 %<*en>
6209 Sometimes \texttt{'parbdd'}~and~\texttt{'boxbdd'} specifications~look like ``fail'',
6210 especially in paragraphs inside list environments.
6211 This is because \cs{everypar} inserts some nodes such as boxes and kerns, so
6212 the ``first letter'' in a paragraph is in fact not the first letter.
6213 %</en>
6214 %<*ja>
6215 リスト環境内での\cs{item}で始まる各項目などでは,
6216 「段落最初の鍵括弧が余計に半角字下げされる」など,
6217 JFMにある\texttt{'parbdd'}, \texttt{'boxbdd'}の指定が見かけ上破綻していることがある.
6218
6219 これは\TeX が\cs{everypar}を用いて段落開始時に記号類や空白などを挿入してしまっているため,
6220 段落最初の鍵括弧が実際には段落最初のノードではないことに起因する.以下に例を示した.
6221 %</ja>
6222 \begin{LTXexample}[width=0.3\textwidth]
6223 \parindent1\zw
6224 \noindent ああああああああ\par % for comparison
6225 「ああああああ \par            % normal paragraph
6226
6227 \everypar{\null}
6228 「ああああああ \par            % ???
6229 \end{LTXexample}
6230 %<*en>
6231 \cs{ltjfakeboxbdd}~and~\cs{ltjfakeparbegin} primitives resolve this situation.
6232 \begin{itemize}
6233   \item \cs{ltjfakeparbegin} creates a node which indicates
6234   ``beginning of an indented paragraph'' to the insertion process of \textbf{JAglue}.
6235  \item \cs{ltjfakeboxbdd} creates a node which indicates
6236   ``beginning/ending of a box'' to the insertion process of \textbf{JAglue}.
6237 \end{itemize}
6238 As an example, the example above can be improved as follows:
6239 %</en>
6240 %<*ja>
6241 \cs{ltjfakeboxbdd}, \cs{ltjfakeparbegin}はこの状況を改善する命令である.
6242 実際には\cs{everypar}の末尾にこれらを追加するという使い方がほとんどになるだろう.
6243 \begin{itemize}
6244   \item \cs{ltjfakeparbegin}は,実行された箇所が「インデントあり段落の開始」であると\LuaTeX-jaの
6245   和文処理グルー挿入処理に認識させる.この命令の直前に\textbf{JAchar}があった場合,
6246   この文字の後ろに入るグルー等の処理については未定義である
6247   \footnote{%
6248     この命令と同等の内容は,\cs{dirrctlua}の形で\Pkg{ltjsclasses}内で以前から使われていた.
6249     一般ユーザでも利用しやすくするため,バージョン20170505.0で新たに命令として定義した.
6250   }.
6251   \item \cs{ltjfakeboxbdd}は,実行された箇所が「ボックスの先頭と末尾」であると\LuaTeX-jaの
6252   和文処理グルー挿入処理に認識させる.
6253 \end{itemize}
6254 例えば,先ほどの例に対して適用すると,次のようになる.
6255 %</ja>
6256 \begin{LTXexample}[width=0.3\textwidth]
6257 \parindent1\zw
6258 \noindent ああああああああ\par % for comparison
6259 「ああああああ \par            % normal paragraph
6260
6261 \everypar{\null\ltjfakeparbegin}
6262 「ああああああ \par
6263 \end{LTXexample}
6264
6265
6266 \subsection{\cs{insertxkanjiskip}, \cs{insertkanjiskip}}
6267 %<*en>
6268 There are some situations which one wants to insert \Param{xkanjiskip} manually.
6269 A simple approach is to use \cs{hskip}\cs{ltjgetparameter\{xkanjiskip\}}, but this approach has
6270 several weak points. To cope with these weak points, \LuaTeX-ja defines a command \cs{insertxkanjiskip} which
6271 inserts \Param{xkanjiskip} glue manually, from the version 20201224.0.
6272 \begin{itemize}
6273   \item ``\cs{insertxkanjiskip}'' (without any keyword) uses the value of \Param{xkanjiskip} at the place.
6274   \item ``\cs{insertxkanjiskip late}'' (with ``\texttt{late}''~keyword) uses the value of \Param{xkanjiskip}
6275   at the end of a paragraph/hbox.
6276 \end{itemize}
6277 See the example below.
6278 %</en>
6279 %<*ja>
6280 \TeX で日本語の文章を作成していると,
6281 しばしば「手動で和欧文間空白\Param{xkanjiskip}を挿入したい」という状況に遭遇する.
6282 このような場合,\cs{hskip}\cs{ltjgetparameter\{xkanjiskip\}}\+とするのがよくある対応であったが,これらには
6283 次のような難点がある:
6284 \begin{itemize}
6285   \item \cs{xkanjiskip}は「段落やhboxでの終端での値がその段落/hbox全体で用いられる」となっているため,
6286   \cs{hskip}\cs{ltjgetparameter\{xkanjiskip\}}\+以降に\Param{xkanjiskip}の値が変わる場合に対応できない.
6287   \item \LuaTeX-jaでは,\cs{xkanjiskip}の自然長が$\cs{maxdimen}=(2^{30}-1)\,\mbox{sp}$であった場合,
6288   JFMで指定された値を実際に利用することになっているが,それに対応できていない.
6289   \item \Pkg{luatexja-adjust}(\ref{ssec:adj}節)による優先度行長調整では,
6290   \cs{hskip}\cs{ltjgetparameter\{xkanjiskip\}}\+は手動で挿入したグルーであるから,
6291   自動で挿入された\Param{xkanjiskip}とは
6292   伸縮の優先順序が異なってしまう.
6293 \end{itemize}
6294
6295 これらの難点に対処した,\Param{xkanjiskip}をグルーとして手動挿入する命令が\cs{insertxkanjiskip}である.
6296 これはバージョン20201224.0で追加された.
6297 以下の実行例に示すように,
6298 \begin{itemize}
6299   \item 単独で\cs{insertxkanjiskip}とした場合は,その時点での\Param{xkanjiskip}の値を使用する
6300   \item 「\cs{insertxkanjiskip~late}」と\texttt{late}キーワードを後置した場合は,
6301   段落/hbox終了時にそのときの\Param{xkanjiskip}の値に自動設定される
6302   (段落/hbox途中での値は未定義)
6303   \item どちらであっても,実行箇所に本来なら自動挿入されるはずのJFM由来グルー/カーンは挿入されない
6304 \end{itemize}
6305 となっている.
6306 %</ja>
6307 \begin{LTXexample}[width=0.3333\textwidth]
6308 \ltjsetparameter{xkanjiskip=0.25\zw}
6309 あ(%                        0.5\zw  (from JFM)
6310 あ\insertxkanjiskip (%      0.25\zw (xkanjiskip at here)
6311 あ\insertxkanjiskip late (% 0.25\zw (xkanjiskip at EOP)
6312 あa%                         1.25\zw (xkanjiskip at EOP)
6313 \\%
6314 \ltjsetparameter{xkanjiskip=1.25\zw}
6315 あ\insertxkanjiskip (%      1.25\zw (xkanjiskip at here)
6316 あa%                         1.25\zw (xkanjiskip at EOP)
6317 %% At the end of the paragraph (EOP), xkanjiskip is 1.25\zw.
6318 \end{LTXexample}
6319
6320 %<*en>
6321 There is a similar command \cs{insertkanjiskip} (\Param{kanjiskip} instead~of \Param{xkanjiskip}) is also defined.
6322 Note that any shorthand form of \cs{insert}[\texttt{x}]\texttt{kanjiskip} are not defined by \LuaTeX-ja.
6323 %</en>
6324 %<*ja>
6325 \cs{insertxkanjiskip}(または\texttt{late}つき)の短縮形
6326 \footnote{ちょうど\cs{inhibitglue}の短縮形\cs{\ltjalchar`\<}\+に対応するもの.}は
6327 \LuaTeX-jaでは定義していない.短縮形を使いたい人は,面倒でも各自で
6328 \begin{lstlisting}
6329  \protected\def\+{\insertxkanjiskip late}
6330 \end{lstlisting}
6331 などと定義してほしい.
6332
6333 最後になるが,以上の説明の\Param{xkanjiskip}をすべて標準の和文間空白\Param{kanjiskip}に置き換えた
6334 \cs{insertkanjiskip}命令も準備されている.
6335 %</ja>
6336
6337 \subsection{\cs{ltjdeclarealtfont}}
6338 \label{ssec:altfont}
6339 %<*en>
6340 Using \cs{ltjdeclarealtfont}, one can ``compose'' more than one Japanese fonts.
6341 This \cs{ltjdeclarealtfont} uses in the following form:
6342 \begin{quote}
6343 \ttfamily \textbackslash ltjdeclarealtfont\meta{base\_font\_cs}\meta{alt\_font\_cs}\{\meta{range}\}
6344 \end{quote}
6345 where  \meta{base\_font\_cs}~and~\meta{alt\_font\_cs} are defined by \cs{jfont}.
6346 Its meaning is
6347 \begin{quote}
6348 If the current Japanese font is \meta{base\_font\_cs}, characters which belong to \meta{range}
6349 is typeset by another Japanese font \meta{alt\_font\_cs}, instead of \meta{base\_font\_cs}.
6350 \end{quote}
6351 Here \meta{range} is a comma-separated list of character codes, but also accepts negative integers:
6352 $-n$~($n≥1$) means that all characters of character classes~$n$, with respect to JFM used
6353 by \meta{base\_font\_cs}. Note that characters which do not exist in \meta{alt\_font\_cs} are
6354 ignored.
6355
6356 For example, if \cs{hoge} uses \texttt{jfm-ujis.lua}, the standard JFM of \LuaTeX-ja,
6357 then
6358 \begin{lstlisting}
6359 \ltjdeclarealtfont\hoge\piyo{"3000-"30FF, {-1}-{-1}}
6360 \end{lstlisting}
6361 does
6362 \begin{quote}
6363 If the current Japanese font is \cs{hoge}, \texttt{U+3000}--\texttt{U+30FF}
6364 and characters in class~1 (ideographic opening brackets)
6365 are typeset by \cs{piyo}.
6366 \end{quote}
6367
6368 Note that specifying negative numbers needs specification like \verb+{-1}-{-1}+,
6369 because simple ``\texttt{-1}'' is treated as the range between 0~and~1.
6370 %</en>
6371 %<*ja>
6372 \cs{jfont} の書式を見ればわかるように,基本的には\LuaTeX-jaにおける1つの和文フォントに
6373 使用出来る「実際のフォント」は1つである.
6374 しかし,\cs{ltjdeclarealtfont} を用いると,この原則から外れることができる.
6375
6376 \cs{ltjdeclarealtfont} は以下の書式で使用する:
6377 \begin{quote}
6378 \ttfamily \textbackslash ltjdeclarealtfont\meta{base\_font\_cs}\meta{alt\_font\_cs}\{\meta{range}\}
6379 \end{quote}
6380 これは「現在の和文フォント」が\meta{base\_font\_cs}であるとき,
6381 \meta{range}に属する文字は\meta{alt\_font\_cs}を用いて組版される,という意味である.
6382 \begin{itemize}
6383  \item \meta{base\_font\_cs}, \meta{alt\_font\_cs}は
6384 \cs{jfont} によって定義された和文フォントである.
6385  \item \meta{range}は文字コードの範囲を表すコンマ区切りのリストであるが,
6386    例外として負数$-n$は「\meta{base\_font\_cs}のJFMの文字クラス$n$に属する全ての文字」
6387    を意味する.
6388
6389 \meta{range}中に\meta{alt\_font\_cs}中に実際には存在しない文字が指定された場合は,
6390 その文字に対する設定は無視される.
6391 \end{itemize}
6392
6393 例えば,\cs{hoge} のJFMが\LuaTeX-ja標準の
6394 \ \texttt{jfm-ujis.lua} であった場合,
6395 \begin{lstlisting}
6396 \ltjdeclarealtfont\hoge\piyo{"3000-"30FF, {-1}-{-1}}
6397 \end{lstlisting}
6398 は「\cs{hoge} を利用しているとき,
6399 \texttt{U+3000}--\texttt{U+30FF}と
6400 文字クラス1(開き括弧類)中の文字だけは \cs{piyo} を用いる」
6401 ことを設定する.\verb+{-1}-{-1}+ という変わった指定の仕方をしているのは,
6402 普通に \texttt{-1} と指定したのでは正しく$-1$と読み取られないという
6403 マクロの都合による.
6404 %</ja>
6405
6406 %<*ja>
6407 \subsection{\cs{ltjalchar} と \cs{ltjjachar}}
6408 文字コードが$\text{\meta{char\_code}}~(\geq 128=\mathtt{0x80})$の文字を
6409 \ \cs{char} プリミティブを使い \cs{char}\meta{char\_code} として出力させると,
6410 その文字の属する文字範囲(\ref{ssec:setrange}節参照)によって
6411 \textbf{ALchar}か\textbf{JAchar}か,つまり欧文フォントで出力されるか和文フォントで出力され
6412 るかが決まる.
6413
6414 文字範囲の設定を無視し,文字コードが\meta{char\_code}の文字を強制的に
6415 \textbf{ALchar}, \textbf{JAchar}で出力する命令がそれぞれ
6416 \ \cs{ltjalchar},~\cs{ltjjachar} である.使用方法は \cs{char} と同じく
6417 \ \cs{ltjalchar}\meta{char\_code}, \cs{ltjjachar}\meta{char\_code}とすればよい.
6418 \LuaTeX-ja~20190926.0から,\meta{char\_code}が127以下の場合でも\cs{ltjjachar}\meta{char\_code}が
6419 \textbf{JAchar}として出力されるようになっている.
6420
6421 以下は\ref{ssec:setrange}節に載せた例に,\cs{char} の動作などを追加したものである.
6422 %</ja>
6423 \begin{LTXexample}[width=0.25\textwidth]
6424 \gtfamily\large
6425 ¶,\char`¶,\ltjalchar`¶,\ltjjachar`¶\\     % default: ALchar
6426 α,\char`α,\ltjalchar`α,\ltjjachar`α\\ % default: JAchar
6427 g,\char`g,\ltjalchar`g,\ltjjachar`g       % ALchar unless \ltjjachar
6428 \end{LTXexample}
6429
6430 %<en>\section{Commands for \LaTeXe}
6431 %<ja>\section{\LaTeXe 用の命令}
6432
6433 %<*en>
6434 \subsection{Loading Japanese fonts in \LaTeXe}
6435 \label{ssec:ltx-jfm}
6436 From version~20190107, 
6437 \emph{\LuaTeX-ja does not load Japanese fonts for horizontal direction and
6438   that for vertical direction at same time},
6439 to reduce the number of loaded fonts.
6440 This will save time for typesetting and memory consumption of Lua side (\cite{tc18ltja}).
6441
6442 \begin{itemize}
6443   \item \cs{selectfont} loads (and chooses) only the Japanese font for the current direction,
6444   and does not load the Japanese font for other direction
6445   (\LuaTeX-ja only detects its size and JFM, to calculate the amount of shifting the baseline).
6446
6447   \item Direction changing commands (\cs{yoko},~\cs{tate}, \cs{dtou},~\cs{utod}) are patched to
6448   include the following process:
6449   \begin{quote}
6450         If the Japanese font for new direction is not loaded,
6451         \LuaTeX-ja loads it automatically.
6452   \end{quote}
6453   Original commands are saved as \cs{ltj@@orig@yoko} etc.
6454   
6455   \item Specifying Japanese font command which is
6456   defined by \cs{jfont},~\cs{tfont}, or~\cs{DeclareFixedFont} directly
6457   actually loads (and selects) the Japanese font.
6458   For example, \textbf{JAchar}s in \cs{box0} will be typeset in \cs{HOGE},
6459   in the following code:
6460 \begin{lstlisting}
6461   % in horizontal direction (\yoko)
6462   \DeclareFixedFont\HOGE{JT3}{gt}{m}{n}{12} % JT3: for vertical direction
6463   \HOGE
6464   \setbox0=\hbox{\tate あいう}
6465 \end{lstlisting}
6466   \end{itemize}
6467 %</en>
6468
6469 %<*ja>
6470 \subsection{\LaTeXe 下での和文フォントの読み込み}
6471 \label{ssec:ltx-jfm}
6472 バージョン20190107以降では,\LaTeXe の下で\LuaTeX-jaを使用した際に,
6473 \emph{横組用和文フォントと縦組み用和文フォントを両方一度に読み込み・選択せずに,
6474   実際にそれぞれを使う組方向になったときに行う}という方針にした.
6475 これは実際に読み込むフォント数を削減することで,
6476 タイプセットにかかる時間と(主にLuaの)メモリ消費を削減するためである(\cite{tc18ltja}).
6477
6478 \begin{itemize}
6479   \item \cs{selectfont}は横組用・縦組用和文フォントのうち,現在の組方向で使う方を
6480   実際に読み込み(・選択し),そうでない方は「フォントサイズとJFMのみ\LuaTeX-jaが把握している状態」
6481   (以下,\emph{JFM把握状態})とする.
6482
6483   \item 組方向変更命令\cs{yoko},~\cs{tate}, \cs{dtou},~\cs{utod}には
6484   \begin{quote}
6485         新たな組方向での和文フォントが読み込まれていない(JFM把握状態)ならば,
6486         現在のエンコーディング・ファミリ・シリーズ・シェイプから改めて読み込む(または選択する)
6487   \end{quote}
6488   処理が付け加えられている.
6489   もとの「組方向を変更するだけ」の命令は\cs{ltj@@orig@yoko}のように\texttt{ltj@@orig@}が前についた
6490   命令に保存されている.
6491   
6492   \item \cs{jfont},~\cs{tfont},~\cs{DeclareFixedFont}で定義された和文フォントは
6493   その時点で実際にフォントが読み込まれる.すなわち,以下のコードにおいて,
6494   \cs{box0}中の\textbf{JAchar}は\cs{HOGE}でタイプセットされる.
6495 \begin{lstlisting}
6496   % in horizontal direction (\yoko)
6497   \DeclareFixedFont\HOGE{JT3}{gt}{m}{n}{12} % JT3: for vertical direction
6498   \HOGE
6499   \setbox0=\hbox{\tate あいう}
6500 \end{lstlisting}
6501   \end{itemize}
6502 %</ja>
6503
6504 %<en>\subsection{Patch for NFSS2}
6505 %<ja>\subsection{NFSS2へのパッチ}
6506 \label{ssec:nfsspat}
6507
6508 %<*en>
6509 Japanese patch for NFSS2 in \LuaTeX-ja
6510 is based on \texttt{plfonts.dtx} which plays the same role in \pLaTeXe.
6511 We will describe
6512 commands which are not described in Subsection~\ref{ssec:chgfnt}.
6513 %</en>
6514 %<*ja>
6515 \LuaTeX-jaのNFSS2への日本語パッチは
6516 \pLaTeXe で同様の役割を果たす \texttt{plfonts.dtx} をベースに,
6517 和文エンコーディングの管理等をLuaで書きなおしたものである.
6518 ここでは\ref{ssec:chgfnt}節で述べていなかった命令について
6519 記述しておく.
6520 %</ja>
6521
6522 \begin{cslist}%
6523 \item[\normalfont\bfseries %
6524 %<ja>追加の長さ変数達
6525 %<en>additonal dimensions
6526 ]
6527 %<*en>
6528 Like \pLaTeXe, \LuaTeX-ja defines the following dimensions
6529 for information of current Japanese font:
6530 %</en>
6531 %<*ja>
6532 \pLaTeXe と同様に,\LuaTeX-jaは「現在の和文フォントの情報」を格納する長さ変数
6533 %</ja>
6534 \begin{quote}
6535  \cs{cht}~(height), \cs{cdp}~(depth), \cs{cHT}~(sum of former two),\\
6536  \cs{cwd}~(width), \cs{cvs}~(lineskip), \cs{chs}~(equals to \cs{cwd})
6537 \end{quote}
6538 %<en>and its \cs{normalsize} version:
6539 %<ja>と,その \cs{normalsize} 版である
6540 \begin{quote}
6541  \cs{Cht}~(height), \cs{Cdp}~(depth),
6542  \cs{Cwd}~(width), \\\cs{Cvs}~(equals to \cs{baselineskip}),
6543  \cs{Chs}~(equals to \cs{cwd})%
6544 %<en>.
6545 \end{quote}
6546 %<*ja>
6547 を定義している.なお,\cs{cwd} と \cs{zw},また
6548 \cs{cHT} と \cs{zh} は一致しない可能性がある.なぜなら,
6549 \cs{cwd},~\cs{cHT} は文字クラス0の和文文字の寸法から決定されるのに対し,
6550 \cs{zw} と \cs{zh} はJFMに指定された値に過ぎないからである.
6551 %</ja>
6552 %<*en>
6553 Note that \cs{cwd}~and~\cs{cHT} may  differ from \cs{zw}~and~\cs{zh}
6554 respectively.
6555 On the one hand the former dimensions are determined from
6556 a character whose character class is zero,
6557 but on the other hand \cs{zw}~and~\cs{zh} are specified by JFM.
6558 %</en>
6559
6560
6561 \item[\cs{DeclareYokoKanjiEncoding}\{\meta{encoding}\}\{\meta{text-settings}\}\{\meta{math-settings}\}]
6562 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
6563 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
6564 \item[\cs{DeclareTateKanjiEncoding}\{\meta{encoding}\}\{\meta{text-settings}\}\{\meta{math-settings}\}]
6565
6566 %<*en>
6567 In NFSS2 under \LuaTeX-ja, distinction between alphabetic fonts
6568              and Japanese fonts are only made by their
6569              encodings. For example, encodings OT1 and T1 are encodings for
6570              alphabetic fonts, and Japanese fonts cannot
6571              have these encodings. These command define a new encoding
6572              scheme for Japanese font families.
6573 %</en>
6574 %<*ja>
6575 \LuaTeX-jaのNFSS2においては,欧文フォントと和文フォントは
6576 そのエンコーディングによってのみ区別される.
6577 例えば,OT1とT1のエンコーディングは欧文フォントのエンコーディングであり,
6578 和文フォントはこれらのエンコーディングを持つことはできない.
6579 これらコマンドは横組用・縦組用和文フォントのための新しいエンコーディングを
6580 それぞれ定義する.
6581 %</ja>
6582
6583 \item[\cs{DeclareKanjiEncodingDefaults}\{\meta{text-settings}\}\{\meta{math-settings}\}]
6584 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
6585 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
6586 \item[\cs{DeclareKanjiSubstitution}\{\meta{encoding}\}\{\meta{family}\}\{\meta{series}\}\{\meta{shape}\}]
6587 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
6588 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
6589 \item[\cs{DeclareErrorKanjiFont}\{\meta{encoding}\}\{\meta{family}\}\{\meta{series}\}\{\meta{shape}\}\{\meta{size}\}]
6590
6591 %<*en>
6592 The above 3~commands are just the counterparts for \cs{DeclareFontEncodingDefaults} and~others.
6593 %</en>
6594 %<*ja>
6595 上記3つのコマンドはちょうどNFSS2 の \cs{DeclareFontEncodingDefaults} などに対応するものである.
6596 %</ja>
6597
6598 \item[\cs{reDeclareMathAlphabet}\{\meta{unified-cmd}\}\{\meta{al-cmd}\}\{\meta{ja-cmd}\}]
6599
6600 % ToDo: en
6601 %<*ja>
6602 和文・欧文の数式用フォントファミリを一度に変更する命令を作成する.
6603 具体的には,欧文数式用フォントファミリ変更の命令\meta{al-cmd}(\cs{mathrm} 等)と,和文数式用フォ
6604              ントファミリ変更の命令\meta{ja-cmd}(\cs{mathmc} 等)の2つを同時に行う命令として
6605              \meta{unified-cmd}を(再)定義する.実際の使用では\meta{unified-cmd}と
6606              \meta{al-cmd}に同じものを指定する,すなわち,\meta{al-cmd}で和文側も変
6607              更させるようにするのが一般的と思われる.
6608
6609 本命令は
6610 \begin{center}
6611 \meta{unified-cmd}\texttt{\{}\meta{arg}\texttt{\}}\quad$\longrightarrow$\quad
6612 (\meta{al-cmd}の1段展開結果)\texttt{\{}\meta{ja-cmd}の1段展開結果)\texttt{\{\meta{arg}\}\}}
6613 \end{center}
6614 と定義を行うので,使用には注意が必要である:
6615 %<en>\vspace{-\medskipamount}
6616 \begin{itemize}
6617 \item \meta{al-cmd},~\meta{ja-cmd}は既に定義されていなければならない.
6618       \cs{reDeclareMathAlphabet}\\の後に
6619 両命令の内容を再定義しても,\meta{unified-cmd}の内容にそれは反映されない.
6620 \item \meta{al-cmd},~\meta{ja-cmd}に\verb+\@mathrm+などと \texttt{@} をつけた命令を指定した時の動作は保証できない.
6621 \end{itemize}
6622 %</ja>
6623
6624 \item[\cs{DeclareRelationFont}\{\meta{ja-encoding}\}\{\meta{ja-family}\}\{\meta{ja-series}\}\{\meta{ja-shape}\}\\*
6625   \null\hfill\{\meta{al-encoding}\}\{\meta{al-family}\}\{\meta{al-series}\}\{\meta{al-shape}\}]
6626 %<*en>
6627 This command sets the ``accompanied'' alphabetic font (given by the latter 4~arguments)
6628 with respect to a Japanese font given by the former 4~arguments.
6629 %</en>
6630 %<*ja>
6631 いわゆる「従属欧文」を設定するための命令である.前半の4引数で表される和文フォントに対して,
6632 そのフォントに対応する「従属欧文」のフォントを後半の4引数により与える.
6633 %</ja>
6634 \item[\cs{SetRelationFont}]
6635 %<*en>
6636 This command is almost same as \cs{DeclareRelationFont}, except that this command does a local
6637 assignment, where \cs{DeclareRelationFont} does a global assignment.
6638 %</en>
6639 %<*ja>
6640 このコマンドは \cs{DeclareRelationFont} とローカルな指定であることを除いて
6641 ほとんど同じである(\cs{DeclareRelationFont} はグローバル).
6642 %</ja>
6643
6644 \item[\cs{userelfont}]
6645 %<*en>
6646 (Only)~at the next call of \cs{selectfont},
6647   change current alphabetic font encoding/family/\dots\ to the `accompanied' alphabetic
6648   font family with respect to current Japanese font family,
6649   which was set by
6650   \cs{DeclareRelationFont} or \cs{SetRelationFont}.
6651
6652   The following is an example of \cs{SetRelationFont} and \cs{userelfont}:
6653 %</en>
6654 %<*ja>
6655 次回(のみ)の\cs{selectfont}の実行時に,現在の欧文フォントのエンコーディング/ファミリ/…… を,
6656 \cs{DeclareRelationFont} か \cs{SetRelationFont} で指定された
6657 現在の和文フォントに対応する「従属欧文」フォントに変更する.
6658
6659   以下に \cs{SetRelationFont} と \cs{userelfont} の例を
6660 紹介しておこう.\cs{userelfont} の使用によって,「abc」の部分のフォントが
6661 Latin Modern Sans Serif (TU/lmss/m/n) に変わっていることがわかる.
6662 %</ja>
6663 \begin{LTXexample}[width=0.3\textwidth]
6664 \makeatletter
6665 \SetRelationFont{JY3}{\k@family}{m}{n}{TU}{lmss}{m}{n}
6666   % \k@family: current Japanese font family
6667 \userelfont\selectfont あいうabc
6668 \end{LTXexample}
6669
6670 \item[\cs{adjustbaseline}]
6671 %<*en>
6672 In \pLaTeXe, \cs{adjustbaseline} sets \cs{tbaselineshift}
6673 to match the vertical center of ``M'' and that of ``漢''  in vertical typesetting:
6674 \[
6675 \text{\cs{tbaselineshift}} \leftarrow
6676 \frac{(h_{\text{M}}+d_{\text{M}}) - (h_{\text{漢}}+d_{\text{漢}})}2
6677   + d_{\text{漢}} - d_{\text{M}},
6678 \]
6679 where $h_{a}$~and~$d_{a}$ denote the height of ``$a$'' and the depth, respectively.
6680 In \LuaTeX-ja, this \cs{adjustbaseline} does similar task, namely setting the
6681              \Param{talbaselineshift} parameter
6682 (a Japanese character whose character class is zero is used, instead of `漢' ).
6683 %</en>
6684 %<*ja>
6685 \pLaTeXe では,\cs{adjustbaseline} は縦組時に「M」と「漢」の中心線を一致させるために,
6686 \cs{tbaselineshift} を設定する役割を持っている:
6687 \[
6688 \text{\cs{tbaselineshift}} \leftarrow
6689 \frac{(h_{\text{M}}+d_{\text{M}}) - (h_{\text{漢}}+d_{\text{漢}})}2
6690   + d_{\text{漢}} - d_{\text{M}},
6691 \]
6692 ここで,$h_{a}$,~$d_{a}$はそれぞれ「$a$」の高さ・深さを表す.
6693 \LuaTeX-jaにおいても,同じように\cs{adjustbaseline}は\Param{talbaselineshift}パラメータの調整処
6694              理を行っている(但し「漢」でなく「文字クラス0の和文文字」を用いる).
6695
6696 \pLaTeXe では,\cs{adjustbaseline}で(本節の最初に述べた,小文字で始まる)\cs{cht}, \cs{cwd}%の
6697   設定処理も行っていたが,\LuaTeX-jaでも全く同様である.
6698 %</ja>
6699
6700 \item[\cs{fontfamily}\{\meta{family}\}]
6701 %<*en>
6702 As in \LaTeXe, this command changes current font family (alphabetic, Japanese,~\emph{or both})
6703 to \meta{family}. See Subsection~\ref{ssec:fontfamilycmd} for detail.
6704 %</en>
6705 %<*ja>
6706 元々の\LaTeXe におけるものと同様に,このコマンドは現在のフォントファミリ(欧文,
6707 和文,\emph{もしくは両方})を\meta{family}に変更する.詳細は\ref{ssec:fontfamilycmd}節を参照すること.
6708 %</ja>
6709
6710 \item[\cs{fontshape}\{\meta{shape}\}\textrm{, }\cs{fontshapeforce}\{\meta{shape}\}]
6711 %<*en>
6712 As in \LaTeXe, this command changes current alphabetic font shape
6713 according to shape change rules.
6714
6715 Traditionally, \cs{fontshape} changes also current Japanese font shape always.
6716 However, this leads a lot of \LaTeX\ font warning like
6717 \begin{verbatim}
6718     Font shape `JY3/mc/m/it' undefined
6719     using `JY3/mc/m/n' instead on ....
6720 \end{verbatim}
6721 when \cs{itshape} is called,
6722 because almost all Japanese fonts only have shape ``\texttt{n}'', and \cs{itshape} calls \cs{fontshape}.
6723
6724 \LuaTeX-ja~20200323.0 change the behavior. Namely,
6725 \cs{fontshape\{\meta{shape}\}}~and~\cs{fontshapeforce\{\meta{shape}\}} change current Japanese font shape, only if
6726 the required shape (according to shape changing rules) or \meta{shape} is avaliable in current Japanese font family/series.
6727 When this is not the case, an info such as
6728 \begin{verbatim}
6729     Kanji font shape JY3/mc/m/it' undefined
6730     No change on ...
6731 \end{verbatim}
6732 is issued instead of a warning.
6733 %</en>
6734 %<*ja>
6735 元々の\LaTeXe におけるものと同様に,このコマンドは現在の欧文フォントシェイプを
6736 \cs{DeclareFontShapeChangeRule}によるシェイプ更新規則によって変更する.
6737
6738 伝統的には,\cs{fontshape}は無条件に和文フォントシェイプも変更した.しかし,例えば多くの和文フォントは
6739 シェイプが``\texttt{n}''しか持たないことと\cs{itshape}が\cs{fontshape}を呼び出すことから,
6740 \begin{verbatim}
6741     Font shape `JY3/mc/m/it' undefined
6742     using `JY3/mc/m/n' instead on ....
6743 \end{verbatim}
6744 といった警告をもたらしてしまっていた.
6745
6746 一方,\LuaTeX-ja 20200323.0以降では,
6747 \cs{fontshape\{\meta{shape}\}}, \cs{fontshapeforce\{\meta{shape}\}}が和文フォントシェイプを更新するのは,
6748 シェイプ更新規則に基づいた値や\meta{shape}の少なくとも一つが現在の和文フォントファミリ・シリーズで利用可能なときに限られる.
6749 どちらでもなく,和文フォントシェイプが変更されなかった場合には
6750 \begin{verbatim}
6751     Kanji font shape JY3/mc/m/it' undefined
6752     No change on ...
6753 \end{verbatim}
6754 というinfo(警告でなく)を出力する.
6755 %</ja>
6756
6757 \item[\cs{kanjishape}\{\meta{shape}\}\textrm{, }\cs{kanjishapeforce}\{\meta{shape}\}]
6758 %<*en>
6759 \cs{kanjishape\{\meta{shape}\}} changes current Japanese font shape according to shape change rules, and
6760 \cs{kanjishapeforce\{\meta{shape}\}} changes current Japanese font shape to \meta{shape}, regardless of the rules.
6761 Hence \cs{kanjishape\{it\}} produces a warning
6762 \begin{verbatim}
6763     Font shape `JY3/mc/m/it' undefined
6764     using `JY3/mc/m/n' instead on ....
6765 \end{verbatim}
6766 which is not produced by \cs{fontshape\{it\}}.
6767 %</en>
6768 %<*ja>
6769   ...
6770 %</ja>
6771
6772
6773 \begin{figure}[!tb]
6774 \begin{LTXexample}[pos=b]
6775 \DeclareKanjiFamily{JY3}{edm}{}
6776 \DeclareFontShape{JY3}{edm}{m}{n}   {<-> s*HaranoAjiMincho-Regular:jfm=ujis}{}
6777 \DeclareFontShape{JY3}{edm}{m}{fb}  {<-> s*HaranoAjiGothic-Regular:jfm=ujis;color=003FFF}{}
6778 \DeclareFontShape{JY3}{edm}{m}{fb2} {<-> s*HaranoAjiGothic-Regular:jfm=ujis;color=FF1900}{}
6779 \DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{fb}{ "4E00-"67FF,{-2}-{-2}}
6780 \DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{fb2}{"6800-"9FFF}
6781 {\kanjifamily{edm}\selectfont
6782 日本国民は、正当に選挙された国会における代表者を通じて行動し、……}
6783 \end{LTXexample}
6784 %<ja>\caption{\cs{DeclareAlternateKanjiFont} の使用例}
6785 %<en>\caption{An example of \cs{DeclareAlternateKanjiFont}}
6786 \label{fig:altkanji}
6787 \end{figure}
6788
6789 \item[\cs{DeclareAlternateKanjiFont}\\
6790   \{\meta{base-encoding}\}\{\meta{base-family}\}\{\meta{base-series}\}\{\meta{base-shape}\}\\
6791   \{\meta{alt-encoding}\}\{\meta{alt-family}\}\{\meta{alt-series}\}\{\meta{alt-shape}\}\{\meta{range}\}]
6792 %<*ja>
6793 \ref{ssec:altfont}節の\
6794 \cs{ltjdeclarealtfont} と同様に,前半の4引数の
6795 和文フォント(基底フォント)のうち\meta{range}中の文字を
6796 第5から第8引数の和文フォントを使って組むように指示する.
6797 使用例を図\nobreak\ref{fig:altkanji}に載せた.
6798
6799 \begin{itemize}
6800  \item
6801 \cs{ltjdeclarealtfont} では基底フォント・置き換え先和文フォントはあらかじめ定義されてい
6802              ないといけない(その代わり即時発効)たが,
6803 \cs{DeclareAlternateKanjiFont} の設定が
6804 実際に効力が発揮するのは,書体変更やサイズ変更を行った時,
6805 あるいは(これらを含むが)\cs{selectfont} が実行された時である.
6806  \item
6807 段落やhboxの最後での設定値が段落/hbox全体にわたって通用する点や,
6808 \meta{range}に負数$-n$を指定した場合,それが「基底フォントの文字クラス$n$に属する文字全体」
6809 と解釈されるのは \cs{ltjdeclarealtfont} と同じである.
6810 \end{itemize}%
6811 %</ja>
6812 %<*en>
6813 As \cs{ltjdeclarealtfont}~(Subsection~\ref{ssec:altfont}),
6814 characters in \meta{range} of the Japanese font (we say the \emph{base font})
6815 which specified by first 4 arguments are typeset
6816 by the Japanese font which specified by fifth to eighth arguments
6817 (we say the \emph{alternate font}).
6818 An example is shown in \autoref{fig:altkanji}.
6819
6820 \begin{itemize}
6821  \item
6822 In \cs{ltjdeclarealtfont}, the base font and the alternate font must be already defined.
6823 But this \cs{DeclareAlternateKanjiFont} is not so.
6824 In other words, \cs{DeclareAlternateKanjiFont} is effective only after
6825 current Japanese font is changed, or only after \cs{selectfont} is executed.
6826  \item \dots
6827 \end{itemize}%
6828 \vspace{-\medskipamount}
6829 %</en>
6830 \end{cslist}
6831
6832
6833 %<*en>
6834 Furthermore, \LuaTeX-ja applies patches which enables NFSS2 commands,
6835 such~as \cs{DeclareSymbolFont}~and~\cs{SetSymbolFont}, to specify
6836 Japanee fonts as math fonts.
6837
6838 Specifying \texttt{disablejfam} option in \cs{usepackage} prevents
6839 applying these patches.
6840 Hence one cannot write Japanese Characters in math mode directly
6841 if \texttt{disablejfam} option is specified.
6842 The code below does not work either:
6843 \begin{lstlisting}
6844 \DeclareSymbolFont{mincho}{JY3}{mc}{m}{n}
6845 \DeclareSymbolFontAlphabet{\mathmc}{mincho}
6846 \end{lstlisting}
6847 %</en>
6848 %<*ja>
6849 この他にも,標準では
6850 \cs{DeclareSymbolFont}, \cs{SetSymbolFont} などの命令で
6851 (NFSS2の枠組みで)数式フォントとして日本語フォントを使えるようにするためのパッチを当てている.
6852
6853 一方,\texttt{disablejfam}オプション指定時には,これらのパッチを当てないので
6854 \begin{lstlisting}
6855 \DeclareSymbolFont{mincho}{JY3}{mc}{m}{n}
6856 \DeclareSymbolFontAlphabet{\mathmc}{mincho}
6857 \end{lstlisting}
6858 のように設定しても,数式モード中に直に日本語を記述することはできない.
6859 \verb|$\mathmc{あ}$| のように \cs{mathmc} で囲んでもできない.
6860 %</ja>
6861
6862 %<en>\subsection{Detail of \cs{fontfamily} command}
6863 %<ja>\subsection{\cs{fontfamily}コマンドの詳細}
6864 \label{ssec:fontfamilycmd}
6865 %<*en>
6866 In this subsection, we describe when \cs{fontfamily}\meta{family} changes current
6867 Japanese/alphabetic font family. Basically, current Japanese fotn family is changed to
6868 \meta{family} if it is recognized as a Japanese font family, and similar with alphabetic font
6869 family. There is a case that current Japanese/alphabetic font family are both changed to
6870 \meta{family}, and another case that \meta{family} isn't recognized as a Japanese/alphabetic font
6871 family either.
6872
6873 \paragraph{Recognition as Japanese font family}
6874 First, Whether Japanese font family will be changed is determined in following order.
6875 This order is very similar to \cs{fontfamily} in \pLaTeXe, but we re-implemented in Lua.
6876 We use an auxiliary list~$N_{\mathrm{J}}$.
6877 %</en>
6878 %<*ja>
6879 本節では,\cs{fontfamily}\meta{family} がいつ和文/欧文フォントファミリを変更するかについて解説
6880 する.基本的には,\meta{family}が和文フォントファミリだと認識されれば和文側が,欧文フォントファ
6881 ミリだと認識されれば欧文側が変更される.どちらとも認識されれば和文・欧文の両方が変わるこ
6882 とになるし,当然どちらとも認識されないこともある.
6883
6884 \paragraph{和文フォントファミリとしての認識}
6885 まず,\meta{family}が和文フォントファミリとして認識されるかは以下の順序で決定される.
6886 これは\pLaTeXe の \cs{fontfamily} にとても似ているが,ここではLuaによって実装している.
6887 補助的に「和文フォントファミリではないと認識された」ファミリを格納したリスト$N_{\mathrm{J}}$を用いる.
6888 %</ja>
6889 \begin{enumerate}
6890 %<*en>
6891 \item If the family~\meta{family} has been defined already by \cs{DeclareKanjiFamily},
6892       \meta{family} is recognized as a  Japanese font family.
6893       Note that \meta{family} need not be defined under \emph{current} Japanese font encoding.
6894 %</en>
6895 %<*ja>
6896 \item ファミリ\meta{family}が既に \cs{DeclareKanjiFamily} によって定義されている場合,
6897       \meta{family}は和文フォントファミリであると認識される.
6898       ここで,\meta{family}は現在の和文フォントエンコーディングで定義されていなくてもよい.
6899 %</ja>
6900 %<*en>
6901 \item If the family~\meta{family} has been listed in a list~$N_{\mathrm{J}}$, this means
6902       that \meta{family} is not a Japanese font family.
6903 %</en>
6904 %<*ja>
6905 \item ファミリ\meta{family}がリスト$N_{\mathrm{J}}$に既に含まれていれば,それは
6906       \meta{family}が和文フォントファミリではないことを意味する.
6907 %</ja>
6908 %<*en>
6909 \item If the \Pkg{luatexja-fontspec} package is loaded, we stop here, and \meta{family} is not
6910       recognized as a Japanese font family.
6911
6912       If the \Pkg{luatexja-fontspec} package is \emph{not} loaded,
6913 now \LuaTeX-ja looks whether there exists a Japanese font encoding~\meta{enc} such that
6914       a font definition named \texttt{\meta{enc}\meta{family}.fd} (the file name is
6915       all lowercase) exists. If so, \meta{family} is recognized as a  Japanese font family (the font definition file won't be loaded here).
6916       If not, \meta{family} is not a Japanese font family, and
6917       \meta{family} is appended to the list~$N_{\mathrm{J}}$.
6918 %</en>
6919 %<*ja>
6920 \item もし\Pkg{luatexja-fontspec}パッケージが読み込まれていれば,ここで終了であり,
6921 \meta{family}は和文フォントファミリとして認識されないことになる.
6922
6923 もし\Pkg{luatexja-fontspec}パッケージが読み込まれていなければ,和文エンコーディング\meta{enc}で
6924 フォント定義ファイル\texttt{\meta{enc}\meta{family}.fd}(ファイル名は全て小文字)が存在するようなも
6925       のがあるかどうかを調べる.
6926 存在すれば,\meta{family}は和文フォントファミリと認識される(フォント定義ファイルは読み込まれな
6927       い).
6928 存在しなければ,\meta{family}は和文フォントファミリでないと認識され,リスト$N_{\mathrm{J}}$に\meta{family}を追加することでそれを記憶する.
6929
6930 %</ja>
6931 \end{enumerate}
6932
6933 %<*en>
6934 \paragraph{Recognition as alphabetic font family}
6935 Next, whether alphabetic font family will be changed is determined in following order.
6936 We use auxiliary lists $F_{\mathrm{A}}$~and~$N_{\mathrm{A}}$,
6937 %</en>
6938 %<*ja>
6939 \paragraph{欧文フォントファミリとしての認識}
6940 同様に,\meta{family}が和文フォントファミリとして認識されるかは以下の順序で決定される.
6941 補助的に「欧文フォントファミリと既に認識された」ファミリのリスト$F_{\textrm{A}}$と,
6942 「欧文フォントファミリではないと認識された」ファミリを格納したリスト$N_{\mathrm{A}}$を用いる.
6943 %</ja>
6944
6945 \begin{enumerate}
6946 %<*en>
6947 \item If the family~\meta{family} has been listed in a list~$F_{\mathrm{A}}$,
6948       \meta{family} is recognized as an alphabetic font family.
6949 %</en>
6950 %<*ja>
6951 \item ファミリ\meta{family}がリスト$F_{\mathrm{A}}$に既に含まれていれば,
6952       \meta{family}は欧文フォントファミリと認識される.
6953 %</ja>
6954 %<*en>
6955 \item If the family~\meta{family} has been listed in a list~$N_{\mathrm{A}}$, this means
6956       that \meta{family} is not  an alphabetic font family.
6957 %</en>
6958 %<*ja>
6959 \item ファミリ\meta{family}がリスト$N_{\mathrm{A}}$に既に含まれていれば,それは
6960       \meta{family}が欧文フォントファミリではないことを意味する.
6961 %</ja>
6962 %<*en>
6963 \item If there exists an alphabetic font encoding such that the family~\meta{family} has been
6964       defined under it, \meta{family} is recognized as an alphabetic font family, and
6965       to memorize this, \meta{family} is appended to the list~$F_{\mathrm{A}}$.
6966 %</en>
6967 %<*ja>
6968 \item ある欧文フォントエンコーディング下でファミリ\meta{family}が定義されていれば,
6969       \meta{family}は欧文フォントファミリと認識され,リスト$F_{\mathrm{A}}$に\meta{family}を追加することでこのことを記憶する.
6970 %</ja>
6971 %<*en>
6972 \item Now \LuaTeX-ja looks whether there exists an alphabetic font encoding~\meta{enc} such that
6973       a font definition named \texttt{\meta{enc}\meta{family}.fd} (the file name is
6974       all lowercase) exists. If so, current alphabetic font family will be changed to
6975       \meta{family}~(the font definition file won't be loaded here).
6976       If not, current alphabetic font family won't be changed, and
6977       \meta{family} is appended to the list~$N_{\mathrm{A}}$.
6978 %</en>
6979 %<*ja>
6980 \item 最終段階では,欧文エンコーディング\meta{enc}で
6981 フォント定義ファイル\texttt{\meta{enc}\meta{family}.fd}(ファイル名は全て小文字)が存在するようなも
6982       のがあるかどうかを調べる.
6983 存在すれば,\meta{family}は欧文フォントファミリと認識される(フォント定義ファイルは読み込まれない).
6984 存在しなければ,\meta{family}は欧文フォントファミリと認識されないので,リスト$N_{\mathrm{A}}$に
6985       \meta{family}を追加してそのことを記憶する.
6986 %</ja>
6987 \end{enumerate}
6988
6989 %<*en>
6990 Also, each call of \cs{DeclareFontFamily} \emph{after} loading of \LuaTeX-ja makes
6991 the second argument (family) is appended to the list~$F_{\mathrm{A}}$.
6992 %</en>
6993 %<*ja>
6994 また,\cs{DeclareFontFamily}が\LuaTeX-jaの読み込み後に実行された場合は,
6995 第2引数(ファミリ名)が自動的に$F_{\mathrm{A}}$に追加される.
6996 %</ja>
6997
6998 %<*en>
6999 The above order is very similar to \cs{fontfamily} in \pLaTeXe, but more complicated (clause~3.).
7000 This is because  \pLaTeXe\ is a \emph{format} however \LuaTeX-ja is not,
7001 hence \LuaTeX-ja does not know calls of \cs{DeclareFontFamily} \emph{before} itself is
7002 loaded.
7003 %</en>
7004 %<*ja>
7005 以上の方針は\pLaTeXe における \cs{fontfamily} にやはり類似しているが,3.が加わり若干複雑になっている.
7006 それは\pLaTeXe がフォーマットであるのに対し\LuaTeX-jaはそうでないため,
7007 \LuaTeX-jaは自身が読み込まれる前にどういう\cs{DeclareFontFamily}の呼び出しがあったか
7008 把握できないからである.
7009 %</ja>
7010
7011 %<en>\paragraph{Remarks}
7012 %<ja>\paragraph{注意}
7013 %<*en>
7014 Of course, there is a case that \meta{family} is not recognized as a Japanese font family,  nor
7015 an alphabetic font family.
7016 In this case, \LuaTeX-ja treats ``the argument \meta{family} is wrong'', so
7017 set both current alphabetic and Japanese font family to \meta{family},
7018 to use the default family for font substitution.
7019 %</en>
7020 %<*ja>
7021 さて,引数によっては,「和文フォントファミリとも欧文フォントファミリも認識されなかった」
7022 という事態もあり得る.
7023   この場合,引数\meta{family}は不正だった,ということになるので,
7024 和文・欧文の両方のフォントファミリを\meta{family}に設定し,代用フォントが使われるに任せることにする.
7025 %</ja>
7026
7027 %<*en>
7028 \subsection{Notes on \cs{DeclareTextSymbol}}
7029 From \LaTeX~2017/01/01, the standard encoding of \LuaLaTeX\ is changed to the \texttt{TU}
7030 encoding. This menas that symbols defined by \texttt{T1}~and~\texttt{TS1} encodings can be used
7031 without loading any package. To produces these symbols in alphabetic fonts in \LuaTeX-ja,
7032 \LuaTeX-ja patches \cs{DeclareTextSymbol}, and reloads \texttt{tuenc.def}.
7033
7034 Under original definition of \cs{DeclareTextSymbol},
7035 internal commands which is defined by \cs{DeclareTextSymbol} (such as \cs{T1\cs{textquotedblleft}})
7036 are \textit{chardef} tokens. However, this no longer holds in \LuaTeX-ja;
7037 for example, the meaning of \cs{TU\cs{textquotedblleft}} is \cs{ltjalchar8220\ltjalchar"2423 }.
7038 %</en>
7039 %<*ja>
7040 \subsection{\cs{DeclareTextSymbol}使用時の注意}
7041 \LaTeX~(2017/01/01)以降では,\texttt{TU}エンコーディングが標準となり,特に何もしなくても
7042 \texttt{T1},~\texttt{TS1}エンコーディングで定義されていた記号類が
7043 使えるようになった.\LuaTeX-jaではこれらの命令によって記号が欧文フォントで出力されるようにするため,
7044 \cs{DeclareTextSymbol}命令を改変し,そして\texttt{TU}エンコーディングの定義である
7045 \texttt{tuenc.def}を再読込している.
7046
7047 従来は \cs{DeclareTextSymbol} で内部的に定義された\cs{T1\cs{textquotedblleft}}といった命令は
7048 \textit{chardef}トークンであった.しかし前段落で述べた改変によりもはやそうではなくなっており,例えば
7049 \cs{TU\cs{textquotedblleft}}は \cs{ltjalchar8220\ltjalchar"2423 } という定義になっている.%"
7050 %</ja>
7051
7052 \begin{table}[t]
7053   \centering\small
7054   \caption{strut}\label{tab:strutbox}\medskip
7055   \begin{tabular}{llcccl}
7056     \toprule
7057     \textbf{box}&\textbf{direction}&\textbf{width}&\textbf{height}&\textbf{depth}
7058     &\textbf{user command}\\
7059     \midrule
7060   \cs{ystrutbox}&yoko&0&0.7\cs{baselineskip}&0.3\cs{baselineskip}&\cs{ystrut}\\\midrule
7061   \cs{tstrutbox}&tate, utod&0&0.5\cs{baselineskip}&0.5\cs{baselineskip}&\cs{tstrut}\\\midrule
7062   \cs{dstrutbox}&dtou&0&0.7\cs{baselineskip}&0.3\cs{baselineskip}&\cs{dstrut}\\\midrule
7063   \cs{zstrutbox}&---&0&0.7\cs{baselineskip}&0.3\cs{baselineskip}&\cs{zstrut}\\\bottomrule
7064   \end{tabular}
7065 \end{table}
7066 %<*en>
7067 \subsection{\cs{strutbox}}
7068 As \pLaTeX~(2017/04/08 or later), \cs{strutbox} is \emph{a macro} which is expanded to one of
7069 \cs{ystrutbox},~\cs{tstrutbox},~and~\cs{dstrutbox}
7070 (all of them are shown in \autoref{tab:strutbox}), according to the current direction.
7071 Similarly, \cs{strut} now uses one of these boxes.
7072 %</en>
7073 %<*ja>
7074 \subsection{\cs{strutbox}}
7075 \pLaTeX~2017/04/08以降と同じように,
7076 \cs{strutbox}は現在の組方向によって\cs{ystrutbox}, \cs{tstrutbox}, \cs{dstrutbox}の
7077 いずれかに展開される\emph{マクロ}となっている(これらについては\autoref{tab:strutbox}参照).
7078 同様に\cs{strut}もこの3\nobreak ボックスのいずれかを組方向によって使い分けるようになっている.
7079
7080 \cs{zstrutbox}はutod方向(\pTeX でいう縦数式ディレクション)で使われる支柱ボックスであるが,
7081 実際に使われるのは\cs{zstrut}が明示的に発行された時,そして
7082 \Pkg{lltjext}パッケージで追加される組方向指定で \texttt{<u>} を指定した時,および
7083 周囲が縦組の状況で \texttt{<z>} を指定した時に限られている.
7084 %</ja>
7085
7086 %<*en>
7087 \section{expl3 interface}
7088 This section describes expl3 interfaces provided by \LuaTeX-ja.
7089 All of them belong to te \texttt{platex} module, since they are provided for compatibility with Japanese \pLaTeX.
7090 Note that commands which are marked with dagger (``\dagger'') are additions by \LuaTeX-ja.
7091 %</en>
7092 %<*ja>
7093 \section{expl3形式の命令}
7094 expl3の文法に沿った組方向変更命令や組方向による条件判断文である.
7095 これらは\pLaTeX との互換性の為に用意されているので,\texttt{platex}モジュールとして定義されている.
7096 なお,``\dagger''がついている命令は\LuaTeX-ja独自のものである.
7097 %</ja>
7098 \begin{cslist}
7099   \item[\cs{platex\_direction\_yoko:}\textrm{, }\cs{platex\_direction\_tate:}\textrm{, }\cs{platex\_direction\_dtou:}]
7100 %<ja>  それぞれ\cs{yoko},~\cs{tate},~\cs{dtou}と同義.
7101 %<en>  Synonyms for \cs{yoko},~\cs{tate}~and~\cs{dtou}, respectively.
7102   \item[\cs{platex\_if\_direction\_yoko\_p:}]
7103 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
7104 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
7105   \item[\cs{platex\_if\_direction\_yoko:\underline{\textsl{TF}}} \{\meta{true code}\} \{\meta{false code}\}]
7106 %<ja>  現在の組方向が横組であるか否かをテストする.
7107 %<en>  Tests if the current direction is \emph{yoko} (horizontal writing).
7108   \item[\cs{platex\_if\_direction\_tate\_nomath\_p:}$^\dagger$]
7109 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
7110 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
7111   \item[\cs{platex\_if\_direction\_tate\_nomath:\underline{\textsl{TF}}}$^\dagger$ \{\meta{true code}\} \{\meta{false code}\}]
7112 %<ja>  現在の組方向が縦組であるか否かをテストする.
7113 %<en>  Tests if the current direction is \emph{tate} (vertical writing).
7114   \item[\cs{platex\_if\_direction\_tate\_math\_p:}$^\dagger$]
7115 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
7116 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
7117   \item[\cs{platex\_if\_direction\_tate\_math:\underline{\textsl{TF}}}$^\dagger$ \{\meta{true code}\} \{\meta{false code}\}]
7118 %<ja>  現在の組方向がutod方向(\pTeX でいう「縦数式ディレクション」)であるか否かをテストする.
7119 %<en>  Tests if the current direction is \emph{utod}.
7120   \item[\cs{platex\_if\_direction\_tate\_p:}]
7121 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
7122 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
7123   \item[\cs{platex\_if\_direction\_tate:\underline{\textsl{TF}}} \{\meta{true code}\} \{\meta{false code}\}]
7124 %<ja>  現在の組方向が縦組またはutod方向であるか否かをテストする.
7125 %<en>  Tests if the current direction is \emph{tate}~or~\emph{utod}.
7126   \item[\cs{platex\_if\_direction\_dtou\_p:}]
7127 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
7128 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
7129   \item[\cs{platex\_if\_direction\_dtou:\underline{\textsl{TF}}} \{\meta{true code}\} \{\meta{false code}\}]
7130 %<ja>  現在の組方向がdtou方向であるか否かをテストする.
7131 %<en>  Tests if the current direction is \emph{dtou}.
7132   \item[\cs{platex\_if\_box\_yoko\_p:N} \meta{box}]
7133 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
7134 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
7135   \item[\cs{platex\_if\_box\_yoko:N\underline{\textsl{TF}}} \meta{box} \{\meta{true code}\} \{\meta{false code}\}]
7136 %<ja>  ボックス\meta{box}の組方向が横組であるか否かをテストする.
7137 %<en>  Tests if the direction of \meta{box} is \emph{yoko}.
7138   \item[\cs{platex\_if\_box\_tate\_nomath\_p:N}$^\dagger$ \meta{box}]
7139 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
7140 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
7141   \item[\cs{platex\_if\_box\_tate\_nomath:N\underline{\textsl{TF}}}$^\dagger$ \meta{box} \{\meta{true code}\} \{\meta{false code}\}]
7142 %<ja>  ボックス\meta{box}の組方向が縦組であるか否かをテストする.
7143 %<en>  Tests if the direction of \meta{box} is \emph{tate}.
7144   \item[\cs{platex\_if\_box\_tate\_math\_p:N}$^\dagger$ \meta{box}]
7145 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
7146 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
7147   \item[\cs{platex\_if\_box\_tate\_math:N\underline{\textsl{TF}}}$^\dagger$ \meta{box} \{\meta{true code}\} \{\meta{false code}\}]
7148 %<ja>  ボックス\meta{box}の組方向がutod方向であるか否かをテストする.
7149 %<en>  Tests if the direction of \meta{box} is \emph{utod}.
7150   \item[\cs{platex\_if\_box\_tate\_p:N} \meta{box}]
7151 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
7152 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
7153   \item[\cs{platex\_if\_box\_tate:N\underline{\textsl{TF}}} \meta{box} \{\meta{true code}\} \{\meta{false code}\}]
7154 %<ja>  ボックス\meta{box}の組方向が縦組またはutod方向であるか否かをテストする.
7155 %<en>  Tests if the direction of \meta{box} is \emph{tate}~or~\emph{utod}.
7156   \item[\cs{platex\_if\_box\_dtou\_p:N} \meta{box}]
7157 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
7158 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
7159 \item[\cs{platex\_if\_box\_dtou:N\underline{\textsl{TF}}} \meta{box} \{\meta{true code}\} \{\meta{false code}\}]
7160 %<ja>    ボックス\meta{box}の組方向がdtou方向であるか否かをテストする.
7161 %<en>  Tests if the direction of \meta{box} is \emph{dtou}.
7162 \end{cslist}
7163
7164
7165 %<*en>
7166 \section{Addon packages}
7167 \LuaTeX-ja has several addon packages.
7168 These addons are written as \LaTeX\ packages, but
7169 \Pkg{luatexja-otf} and~\Pkg{luatexja-adjust} can be loaded in plain \LuaTeX\
7170 by \cs{input}.
7171 %</en>
7172 %<*ja>
7173 \section{拡張パッケージ}
7174 \LuaTeX-jaには(動作には必須ではないが)自由に読み込める拡張が付属している.
7175 これらは\LaTeX のパッケージとして制作しているが,
7176 \Pkg{luatexja-otf}と\Pkg{luatexja-adjust}についてはplain \LuaTeX でも\
7177 \cs{input} で読み込み可能である.
7178 %</ja>
7179 \subsection{\Pkg{luatexja-fontspec}}
7180 \label{ssec:fontspec2}
7181 %<*en>
7182 As described in Subsection~\ref{ssec:fontspec}, this optional package
7183 provides the counterparts for several commands defined in the
7184 \Pkg{fontspec} package (requires \Pkg{fontspec}~v2.4).
7185 In addition to OpenType font features in the original \Pkg{fontspec},
7186 the following ``font features'' specifications are allowed for
7187 the commands of Japanese version:
7188 %</en>
7189 %<*ja>
7190 \ref{ssec:fontspec}節で述べたように,この追加パッケージは\Pkg{fontspec}%
7191 パッケージで定義されているコマンドに対応する和文フォント用のコマンドを提供する.
7192
7193 \Pkg{fontspec}パッケージで指定可能な各種OpenType機能に加えて,和文版のコマンドには
7194 以下の「フォント機能」を指定することができる:
7195 %</ja>
7196
7197
7198 \begin{cslist}
7199 \item[CID=\meta{name}\textrm{, }JFM=\meta{name}\textrm{, }JFM-var=\meta{name}]
7200
7201 %<*en>
7202 These 3 keys correspond to \texttt{cid}, \texttt{jfm} and
7203 \texttt{jfmvar} keys for \cs{jfont}~and~\cs{tfont} respectively.
7204 See Subsections~\ref{ssec:jfont} and \ref{ssec:psft} for details
7205  of \texttt{cid}, \texttt{jfm} and
7206 \texttt{jfmvar} keys.
7207
7208 The \texttt{CID} key is effective only when with \texttt{NoEmbed}
7209 described below. The same JFM cannot be used in both horizontal Japanese fonts and
7210              vertical Japanese fonts, hence the \texttt{JFM} key
7211 will be actually used in \texttt{YokoFeatures}~and~\texttt{TateFeatures} keys.
7212 %</en>
7213 %<*ja>
7214 これら3つのキーはそれぞれ \cs{jfont},~\cs{tfont}に対する
7215 \texttt{cid}, \texttt{jfm}, \texttt{jfmvar}キーとそれぞれ対応する.
7216 \texttt{cid}, \texttt{jfm}, \texttt{jfmvar}キーの詳細は\ref{ssec:jfont}節
7217              と\ref{ssec:psft}節を参照.
7218
7219 \texttt{CID} キーは下の \texttt{NoEmbed} と合わせて用いられたときのみ有効である.
7220 また,横組用JFMと縦組用JFMは共用できないため,実際に \texttt{JFM} キーを用いる際は
7221 後に述べる\ \texttt{YokoFeatures} キーや \texttt{TateFeatures}\ の中で用いる
7222 ことになる.
7223 %</ja>
7224
7225 \item[NoEmbed]
7226 %<*en>
7227 By specifying this key, one can use ``name-only'' Japanese font which
7228 will not be embedded in the output PDF file. See Subsection~\ref{ssec:psft}.
7229 %</en>
7230 %<*ja>
7231 これを指定することで,PDFに埋め込まれない「名前だけ」のフォントを指定することが
7232 できる.\ref{ssec:psft}節を参照.
7233 %</ja>
7234
7235 \begin{figure}[!tb]
7236 \begin{LTXexample}[width=0.25\textwidth]
7237 \jfontspec[
7238   YokoFeatures={Color=FF1900}, TateFeatures={Color=003FFF},
7239   TateFont=HaranoAjiGothic-Regular
7240 ]{HaranoAjiMincho-Regular}
7241 \hbox{\yoko 横組のテスト}\hbox{\tate 縦組のテスト}
7242 \addjfontfeatures{Color=00AF00}
7243 \hbox{\yoko 横組}\hbox{\tate 縦組}
7244 \end{LTXexample}
7245 %<ja>\caption{\texttt{TateFeatures} 等の使用例}
7246 %<en>\caption{An example of \texttt{TateFeatures} etc.}
7247 \label{fig:yokotate-fontspec}
7248 \end{figure}
7249
7250 \item[Kanjiskip=\meta{bool}]
7251 %<*ja>
7252 \pageref{pg:ltjksp}ページで説明した \verb+\jfont+ 中での \texttt{ltjksp} 指定と
7253 同一の効力を持ち,
7254 JFM中における \texttt{kanjiskip\_natural}, \texttt{kanjiskip\_stretch},\
7255 \texttt{kanjiskip\_shrink}キー(\pageref{pg:ksp_nat}ページ)の有効/無効を切り替える.
7256 標準値は \texttt{true} である.
7257 %</ja>
7258
7259 \item[TateFeatures=\{\meta{features}\}\textrm{, }TateFont=\meta{font}]
7260 %<*en>
7261 The \texttt{TateFeatures} key specifies font features which are only turned~on in
7262 vertical writing, such as \texttt{Style=VerticalKana}~(\texttt{vkna} feature).
7263 Similarly, the \texttt{TateFont} key specifies the Japanese font which will be used only
7264              in vertical writing.
7265 A demonstrarion is shown in \autoref{fig:yokotate-fontspec}.
7266 %</en>
7267 %<*ja>
7268 縦組において使用されるフォントや,縦組においてのみ適用されるフォント機能達を
7269 指定する.使用例は\autoref{fig:yokotate-fontspec}参照.
7270 %</ja>
7271
7272 \item[YokoFeatures=\{\meta{features}\}]
7273 %<*en>
7274 The \texttt{YokoFeatures} key specifies font features which are only turned~on in
7275 horizontal writing,.
7276 A demonstrarion is shown in \autoref{fig:yokotate-fontspec}.
7277 %</en>
7278 %<*ja>
7279 同様に,横組においてのみ適用されるフォント機能達を
7280 指定する.使用例は\autoref{fig:yokotate-fontspec}参照.
7281 %</ja>
7282
7283
7284 \begin{figure}[!tb]
7285 \begin{LTXexample}[pos=b]
7286 \jfontspec[
7287   AltFont={
7288     {Range="4E00-"67FF, Font=HaranoAjiGothic-Regular, Color=003FFF},
7289     {Range="6800-"9EFF, Color=FF1900},
7290     {Range="3040-"306F, Font=HaranoAjiGothic-Regular, Color=35A16B},
7291   }
7292 ]{HaranoAjiMincho-Regular}
7293 日本国民は、正当に選挙された国会における代表者を通じて行動し、われらとわれらの子孫のために、
7294 諸国民との協和による成果と、わが国全土にわたつて自由のもたらす恵沢を確保し、……
7295 \end{LTXexample}
7296 %<ja>\caption{\texttt{AltFont} の使用例}
7297 %<en>\caption{An example of \texttt{AltFont}}
7298 \label{fig:altkanji-fontspec}
7299 \end{figure}
7300
7301 \item[AltFont]
7302
7303 %<*en>
7304 As \cs{ltjdeclarealtfont}~(Subsection~\ref{ssec:altfont}) and
7305 \cs{DeclareAlternateKanjiFont}~(Subsection~\ref{ssec:nfsspat}),
7306 with this key, one can typeset some Japanese characters
7307 by a different font and/or using different features.
7308 The \texttt{AltFont} feature takes a comma-separated list of comma-separated lists,
7309 as the following:
7310 %</en>
7311 %<*ja>
7312 \ref{ssec:altfont}節の \cs{ltjdeclarealtfont} や,
7313 \ref{ssec:nfsspat}節の \cs{DeclareAlternateKanjiFont} と同様に,
7314 このキーを用いると一部の文字を異なったフォントや機能たちを使って組むことができる.
7315 \texttt{AltFont} キーに指定する値は,次のように二重のコンマ区切りリストである:
7316 %</ja>
7317 \begin{lstlisting}[escapechar=\#]
7318 AltFont = {
7319   ...
7320   { Range=#\meta{range}#, #\meta{features}#},
7321   { Range=#\meta{range}#, Font=#\meta{font~name}#, #\meta{features}# },
7322   { Range=#\meta{range}#, Font=#\meta{font~name}># },
7323   ...
7324 }
7325 \end{lstlisting}
7326 %<*en>
7327 Each sublist should have the \texttt{Range} key
7328 (sublist which does not contain \texttt{Range} key is simply ignored).
7329 A demonstrarion is shown in \autoref{fig:altkanji-fontspec}.
7330 %</en>
7331 %<*ja>
7332 各部分リストには \texttt{Range} キーが必須である(含まれない部分リストは
7333 単純に無視される).指定例は\autoref{fig:altkanji-fontspec}に示した.
7334 %</ja>
7335 \end{cslist}
7336
7337 %<*ja>
7338 なお,\Pkg{luatexja-fontspec} 読み込み時には和文フォント定義ファイル%
7339 \texttt{\meta{ja-enc}\meta{family}.fd}は全く参照されなくなる.
7340 %</ja>
7341
7342
7343 %<*en>
7344 \paragraph{Remark on \texttt{AltFont}, \texttt{YokoFeatures}, \texttt{TateFeatures} keys}
7345 \leavevmode\par
7346 In \texttt{AltFont},~\texttt{YokoFeatures},~\texttt{TateFeatures} keys,
7347 one cannot specify per-shape settings such as \texttt{BoldFeatures}.
7348 For example,
7349 \begin{lstlisting}
7350 AltFont = {
7351   { Font=HogeraMin-Light, BoldFont=HogeraMin-Bold,
7352     Range="3000-"30FF, BoldFeatures={Color=FF1900} }
7353 }
7354 \end{lstlisting}
7355 does \emph{not} work. Instead, one have to write
7356 \begin{lstlisting}
7357 UprightFeatures = {
7358   AltFont = { { Font=HogeraMin-Light, Range="3000-"30FF, } },
7359 },
7360 BoldFeatures = {
7361   AltFont =  { { Font=HogeraMin-Bold, Range="3000-"30FF, Color=FF1900 } },
7362 }
7363 \end{lstlisting}
7364
7365 On the other hand, \texttt{YokoFeatures}, \texttt{TateFeatures} and  \texttt{TateFont}
7366 keys can be specified in each list in the \texttt{AltFont} key. Also,
7367 one can specify \texttt{AltFont} inside \texttt{YokoFeatures},~\texttt{TateFeatures}.
7368
7369 Note that features which are specified in \texttt{YokoFeatures}~and~\texttt{TateFeatures}
7370 are always interpreted \emph{after} other ``direction-independent'' features.
7371 This explains why \cs{addjfontfeatures} at~line~6 in~\autoref{fig:yokotate-fontspec}
7372 has no effect, because a color specification is already done in
7373 \texttt{YokoFeatures}~and~\texttt{TateFeatures} keys.
7374 %</en>
7375 %<*ja>
7376 \paragraph{\texttt{AltFont}, \texttt{YokoFeatures}, \texttt{TateFeatures} 等の制限}
7377 \texttt{AltFont},~\texttt{YokoFeatures},~\texttt{TateFeatures}の各キーは
7378 シェイプ別に指定されるべきものであり,
7379 内部では \texttt{BoldFeatures} などのシェイプ別の指定は行うことが出来ない.
7380 例えば.
7381 \begin{lstlisting}
7382 AltFont = {
7383   { Font=HogeraMin-Light, BoldFont=HogeraMin-Bold,
7384     Range="3000-"30FF, BoldFeatures={Color=FF1900} }
7385 }
7386 \end{lstlisting}
7387 のように指定することは出来ず,
7388 \begin{lstlisting}
7389 UprightFeatures = {
7390   AltFont = { { Font=HogeraMin-Light, Range="3000-"30FF, } },
7391 },
7392 BoldFeatures = {
7393   AltFont =  { { Font=HogeraMin-Bold, Range="3000-"30FF, Color=FF1900 } },
7394 }
7395 \end{lstlisting}
7396 のように指定しなければならない.
7397
7398 一方,\texttt{AltFont} キー内の各リストでは
7399 \ \texttt{YokoFeatures},~\texttt{TateFeatures} 及び \texttt{TateFont} キーを
7400 指定することは可能であり.また\ \texttt{YokoFeatures},~\texttt{TateFeatures} キーの
7401 中身に \texttt{AltFont} を指定することができる.
7402
7403 また,\autoref{fig:yokotate-fontspec}後半部では6行目の疑似太字無効化の指定が効かず,
7404 2行目で指定した\ \texttt{YokoFeatures},~\texttt{TateFeatures}\ による疑似太字の指定が有効になっ
7405 たままである.これは\emph{\ \texttt{YokoFeatures},~\texttt{TateFeatures}\ による
7406 OpenType機能指定は
7407 組方向に依存しないOpenType機能の指定より後に解釈される}からである.
7408
7409 %</ja>
7410
7411
7412 \subsection{\Pkg{luatexja-otf}}
7413 \label{ssec:ltjotf}
7414 %<*en>
7415 This optional package supports typesetting glyphs
7416 by specifying a CID number.
7417 The package \Pkg{luatexja-otf} offers the following 2~low-level
7418 commands:
7419 %</en>
7420 %<*ja>
7421 この追加パッケージはCID番号による文字の出力をサポートする.
7422 \Pkg{luatexja-otf}は以下の2つの低レベルコマンドを提供する:
7423 %</ja>
7424 \begin{cslist}
7425 \item[\cs{CID}\{\meta{number}\}]
7426 %<*en>
7427 Typeset a glyph whose CID number is \meta{number}.
7428 If the Japanese font is neither Adobe-Japan1,~Adobe-GB1, Adobe-CNS1,
7429 Adobe-Korea1,~nor~Adobe-KR CID-keyed font,
7430 \LuaTeX-ja treats that \meta{number} is a CID number of Adobe-Japan1 character collection,
7431 and tries to typeset a ``most suitable glyph''.
7432
7433 Note that if the Japanese font is loaded using the HarfBuzz library, this \cs{CID}
7434 command does not work.
7435 %</en>
7436 %<*ja>
7437 CID番号が\meta{number}の文字を出力する.
7438 もし現在の和文フォントがAdobe-Japan1,~Adobe-GB1, Adobe-CNS1, Adobe-Korea1,~Adobe-KRの
7439   いずれのCID-keyed fontでもない場合,\meta{number}はAdobe-Japan1のCID番号であると解釈し
7440   「適切なグリフ」\footnote{%
7441   特に縦組用グリフのCID番号を指定した場合は(LuaTeX-ja 20190504.0以降では若干改良されているが)
7442   意図しない結果になる可能性が高い.
7443   なお,バージョン20190708.0以降では,CIDからグリフへの選択にグリフ名の情報を使用していない.
7444   また,フォントにAdobe-Japan1のIVSが含まれていれば,その情報を用いて
7445   グリフを選択する.
7446 }を出力する.
7447
7448 なお,現在の和文フォントがHarfBuzzを用いて読み込まれた場合には,\cs{CID}は正しく動作しない.
7449 %</ja>
7450
7451 \item[\cs{UTF}\{\meta{hex\_number}\}]
7452 %<*en>
7453 Typeset a character whose character code is \meta{hex\_number} (in hexadecimal).
7454 This command is similar to \verb+\char"+\meta{hex\_number},\ %"
7455 but please remind remarks below.
7456 %</en>
7457 %<*ja>
7458 文字コードが(16進で)\meta{hex\_number}の文字を出力する.
7459 このコマンドは \verb+\char"+\meta{hex\_number}と似ているが,下の注意を参照すること.%"
7460 %</ja>
7461 \end{cslist}
7462
7463 %<*ja>
7464 このパッケージは,マクロ集 \texttt{luatexja-ajmacros.sty}\footnote{\Pkg{otf}パッケージ付属の井上浩一氏によるマクロ集
7465 \texttt{ajmacros.sty} に対して
7466 漢字コードをUTF-8にしたり,plain \LuaTeX でも利用可能にするという
7467 修正を加えたものである.}\ も自動的に読み込む.
7468 \texttt{luatexja-ajmacros.sty} は,
7469 そのため,\Pkg{luatexja-otf} を読みこめば \texttt{ajmacros.sty} マクロ集にある \cs{aj半角} などのマクロもそのまま使うことができる.
7470 %</ja>
7471 %<*en>
7472 This package automatically loads \texttt{luatexja-ajmacros.sty}, which is slightly
7473 modified version of \texttt{ajmacros.sty}\footnote{Useful macros by iNOUE Koich!, for the
7474 \Pkg{japanese-otf} package.}.
7475 Hence one can use macros which sre defined in \texttt{ajmacros.sty}, such as~\cs{aj半角}.
7476 %</en>
7477
7478 %<en>\paragraph{Remarks}
7479 %<ja>\paragraph{注意}
7480 %<*en>
7481 Characters by \cs{CID} and \cs{UTF} commands are different from
7482 ordinary characters in the following points:
7483 %</en>
7484 %<*ja>
7485 \cs{CID} と \cs{UTF} コマンドによって出力される文字は
7486 以下の点で通常の文字と異なる:
7487 %</ja>
7488 \begin{itemize}
7489 %<*en>
7490 \item Always treated as \textbf{JAchar}s.
7491 %</en>
7492 %<*ja>
7493 \item 常に\textbf{JAchar}として扱われる.
7494 %</ja>
7495 %<*en>
7496 \item In vertical direction, \texttt{vert}/\texttt{vrt2} feature are automatically applied to
7497       characters by \cs{UTF}, regardless these feature are not activated in current Japanese font.
7498 %</en>
7499 %<*ja>
7500 \item 縦組時には,現在の縦組用和文フォントで \texttt{vert}/\texttt{vrt2} 機能が
7501   有効か無効かを問わず,\cs{UTF} で出力される文字にはこれらのOpenType機能が働いた字形になる.
7502 %</ja>
7503 %<*en>
7504 \item Processes for supporting other OpenType features (for example,
7505       glyph replacement and kerning) by the \Pkg{luaotfload} package
7506       is not performed to these characters.
7507 %</en>
7508 %<*ja>
7509 \item その他のOpenType機能(例えばグリフ置換やカーニング)をサポートするための
7510   \Pkg{luaotfload}パッケージによる処理はこれらの文字には働かない.
7511 %</ja>
7512 \end{itemize}
7513
7514 %<en>\paragraph{Additional syntax of JFM}
7515 %<ja>\paragraph{JFMへの記法の追加}
7516
7517 %<*en>
7518 The package \Pkg{luatexja-otf} extends the syntax of JFM; the entries of \texttt{
7519 chars} table in JFM now allows a string in the form
7520 \verb+'AJ1-xxx'+, which stands for the character
7521 whose CID number in Adobe-Japan1 is \verb+xxx+.
7522
7523 This extended notation is used in the standard JFM \texttt{jfm-ujis.lua}
7524 to typeset halfwidth Hiragana glyphs (CID~516--598) in halfwidth.
7525 %</en>
7526 %<*ja>
7527 \Pkg{luatexja-otf}パッケージを読み込むと,
7528 JFMの\texttt{chars}テーブルのエントリとして \verb+'AJ1-xxx'+ の形の文字列が
7529 使えるようになる.これはAdobe-Japan1におけるCID番号が \verb+xxx+ の文字を表す.
7530
7531 この拡張記法は,標準JFM~\texttt{jfm-ujis.lua}で,半角ひらがなのグリフ(CID~516--598)を
7532 正しく半角幅で組むために利用されている.
7533 %</ja>
7534
7535 \subsection{\Pkg{luatexja-adjust}}
7536 \label{ssec:adj}
7537 \begin{figure}[t]
7538 \def\sq{%
7539   \hbox to 1\zw{\hss\fboxsep=-.5\fboxrule\fbox{%
7540    \hskip\dimexpr-.5\zw-.2pt\vrule width.4pt height.08\zw depth.12\zw%
7541   \hskip\dimexpr.5\zw-.2pt\relax}\hss}}
7542 \def\sb{\hbox to 1\zw{\hss\fboxsep=-.5\fboxrule\fbox{%
7543   ■\hskip\dimexpr-.5\zw-.2pt\vrule width.4pt height.08\zw depth.12\zw%
7544   \hskip\dimexpr.5\zw-.2pt\relax}\hss}}
7545 \newbox\gridbox
7546 \def\outbox#1{{\Large%
7547   \ltjsetparameter{kanjiskip=0pt plus .2\zw minus .2\zw}%
7548   \setbox\gridbox=\hbox to 20\zw{\sq\sq\sq\sq\sb\sq\sq\sq\sq\sb\sq\sq\sq\sq\sb\sq\sq\sq\sq\sb}%
7549   \hbox{\textcolor{cyan}{\copy\gridbox}\hskip-20\zw%
7550   \vbox{\hsize=20\zw\noindent\leftskip0pt\rightskip0pt\parfillskip0pt#1}\vrule}%
7551 }}
7552
7553 {\centering
7554 \begin{tabular}{lc}
7555 \toprule
7556 no adjustment&\outbox{以上の原理は,「包除原理」とよく呼ばれるが\hskip-.5\zw\null}\\
7557 without priority&%
7558 \ltjdisableadjust
7559 \outbox{以上の原理は,「包除原理」とよく呼ばれるが}%
7560 \ltjenableadjust\\
7561 with priority&%
7562 \outbox{以上の原理は,「包除原理」とよく呼ばれるが}
7563 %<en>\ltjdisableadjust
7564 \\
7565 \bottomrule
7566 \end{tabular}\par}
7567 \medskip
7568
7569 \fakefn{}{The value of
7570 \Param{kanjiskip} is 0\,pt${}^{+1/5\,\mathrm{em}}_{-1/5\,\mathrm{em}}$ in this figure,
7571 for making the difference obvious.}
7572 %<ja>\caption{行長調整}\label{fig:adj}
7573 %<en>\caption{Line adjustment}\label{fig:adj}
7574 \end{figure}
7575
7576
7577 %<*en>
7578 (see Japanese version of this manual)
7579 %</en>
7580 %<*ja>
7581 この追加パッケージは以下の機能を提供する.詳細な仕様については\ref{sec-adjspec}章を参照してほしい.
7582 \begin{description}
7583  \item[行末文字の位置調整]
7584   \pTeX では,(是非はともかく)「行末の読点はぶら下げか二分取りか全角取りのいずれかに」のように
7585   行末文字と実際の行末の位置関係を2通り以上にすることは面倒であった.
7586   和文フォントメトリックだけでは「常に行末の読点はぶら下げ」といったことしかできず,
7587   前の文に書いたことを実現するには
7588   \begin{lstlisting}
7589 \def\。{%
7590   \penalty10000 % 禁則ペナルティ
7591   \hbox to0pt{。\hss}\penalty0 % ぶら下げの場合
7592   \kern.5\zw\penalty0 % 二分取りの場合
7593   \kern.5\zw\penalty0 % 全角取りの場合
7594 }
7595 \end{lstlisting}
7596   のような命令を定義し,文中の全ての句点を \lstinline+\。+ で書くことが必要だった.
7597
7598   \Pkg{luatexja-adjust}パッケージは,上で述べた行末文字と実際の行末との位置関係を
7599   2通り以上から自動的に選択する機能を提供する.
7600   \pdfTeX と同じように,「\TeX による行分割の後で行末文字の位置を補正する」方法と
7601   「行分割の過程で行末文字の位置を考慮に入れる」方法を選べるようにした
7602   (\Pkg{luatexja-adjust}パッケージの既定では前者).
7603   
7604  \item[優先順位付きの行長調整]
7605   \pTeX では,行長調整において優先度の概念が存在しなかったため,図
7606   \ref{fig:adj}上段における半角分の半端は,\autoref{fig:adj}中段のように,鍵
7607   括弧周辺の空白と和文間空白(\Param{kanjiskip})の両方によって負担される.し
7608   かし,「日本語組版処理の要件」\cite{jlreq}やJIS~X~4051~\cite{x4051}におい
7609   ては,このような状況では半端は鍵括弧周辺の空白のみで負担し,その他の和文
7610   文字はベタ組で組まれる(\autoref{fig:adj}下段)ことになっている.
7611   \Pkg{luatexja-adjust}パッケージの提供する第2の機能は,
7612   \cite{jlreq}や\cite{x4051}における規定のような,優先順位付き
7613   の行長調整である.
7614   \begin{itemize}
7615    \item 優先度付き行長調整は,段落を行分割した後に個々の行について行われるものである.
7616         そのため,行分割の位置は変化することはない.
7617         
7618         \verb+\hbox{...}+ といった「途中で改行できない水平ボックス」では(たとえ幅が指定されていても)無効である.
7619    \item 優先度付き行長調整を行うと,和文処理グルーの自然長は変化しないが,伸び量や縮み量は
7620         一般に変化する.そのため,既に組まれた段落を \cs{unhbox} などを利用して組み直す処理を
7621         行う場合には注意が必要である.
7622   \end{itemize}
7623   
7624  \item[「中身までみた」行送り計算]
7625   複数行に渡る文章を組版するときには行間に空きが入ることが普通である.
7626   \TeX では各行が一つずつの水平ボックスをなしていることを思い出すと,隣り合った
7627   2つの行(つまり水平ボックス)の間の空きは次のようにして決まるのだった:
7628   \begin{itemize}
7629    \item 「通常に組んだときの行間」$d$を,\cs{baselineskip}から
7630         「前の行」の深さと「次の行」の高さを加えたものを引いた値とする.
7631    \item $d\ge\cs{lineskiplimit}$の場合,
7632         標準の行送り\cs{baselineskip}で組んでも十分な間隔があると判断され,
7633         2行の間には長さ$d$の空白が挿入される.つまり行送りは\cs{baselineskip}.
7634    \item $d<\cs{lineskiplimit}$の場合,
7635         2行の間には長さ\cs{lineskip}の空白が挿入される.
7636         そのため(設定値によるが,多くの場合)行送りは\cs{baselineskip}より広がる.
7637   \end{itemize}
7638
7639   \begin{figure}[t]
7640         \noindent\centering
7641         \begin{minipage}[b]{18\zw}
7642           \ltjenableadjust[profile=false, linestep=false]
7643           ……だから,①より$\dfrac{a^2}{b} = \dfrac{1+\sqrt{5}}2$.\\
7644           よって$b=\dfrac{1-\sqrt{5}}2$である.\\
7645           これを②式に代入すると……
7646           \par\vskip\abovecaptionskip
7647           \ltjenableadjust[profile=false, linestep=false]
7648           \par\centering\leavevmode{\small (a)}
7649         \end{minipage}%
7650         \kern2\zw
7651         \begin{minipage}[b]{18\zw}
7652           \ltjenableadjust[profile]
7653           ……だから,①より$\dfrac{a^2}{b} = \dfrac{1+\sqrt{5}}2$.\\
7654           よって$b=\dfrac{1-\sqrt{5}}2$である.\\
7655           これを②式に代入すると……
7656           \par\vskip\abovecaptionskip
7657           \ltjenableadjust[profile=false, linestep=false]
7658           \par\centering\leavevmode{\small (b)}
7659         \end{minipage}\par
7660           \caption{高い行が連続したときの状況}\label{fig:linegap1}
7661   \end{figure}
7662
7663   ここで,\TeX は行送りの決定で「高さ・深さを取っているものが
7664   行のどの水平位置にあるか」は一切考慮しないことに注意してほしい.そのため,
7665   \autoref{fig:linegap1}~(a)のように「必要以上に行間が空いて見える」状況が起こることがある.
7666
7667   \Pkg{luatexja-adjust}パッケージでは,「通常に組んだときの行間」$d$を
7668   各行の中身の文字・グルー・ボックスの寸法を勘案して計算するという方法を
7669   利用できるようにした.この機能を使うと,\autoref{fig:linegap1}~(b)のように
7670   行間の空きが必要以上に大きくなることを避けることができる.
7671   \begin{itemize}
7672         \item 段落中の隣り合った二行だけでなく,行間の空きは
7673         新たに水平ボックス$h$を(内部・外部問わず)垂直モードで追加した時にも自動で挿入される.
7674         その場合には,前段落で述べた「中身までみる」処理は
7675         \begin{itemize}
7676          \item 現在のリストにおける最後のノード
7677           \footnote{最後のノードが\cs{parskip}によるグルーであった場合のみ
7678                 さらに一つ前のノードを参照する}が水平ボックス$h'$であり,かつ
7679           \item \cs{prevdepth}の値とその$h'$の深さの値が一致している
7680         \end{itemize}
7681         場合にのみ発動するようにしている.
7682         \item 行の中身に水平ボックス$h''$が入ってくることもあるが,その場合は$h''$の中身の高さ・深さまでは
7683         参照せず,あくまでも$h''$自身の高さ・深さのみを参照する.
7684         参照するようにしてしまうと,\cs{smash}など手動で行った高さ・深さ調整の意味がなくなってしまうからである.
7685   \end{itemize}
7686   
7687   \begin{figure}[t]
7688         \noindent\centering
7689         \begin{minipage}[b]{16\zw}
7690           \ltjenableadjust[profile]
7691           ……だから,①より$\dfrac{a^2}{b}= \dfrac{1+\sqrt{5}}2$.\\
7692           よって$b=\dfrac{1-\sqrt{5}}2$である.\\
7693           これを②式に代入すると……
7694           \par\vskip\abovecaptionskip
7695           \ltjenableadjust[profile=false, linestep=false]
7696           \par\centering\leavevmode{\small (a): 無効}
7697         \end{minipage}%
7698         \kern2\zw
7699         \begin{minipage}[b]{16\zw}
7700           \ltjsetparameter{linestep_factor=0.25}
7701           \ltjenableadjust[profile, linestep]
7702           ……だから,①より$\dfrac{a^2}{b} = \dfrac{1+\sqrt{5}}2$.\\
7703           よって$b=\dfrac{1-\sqrt{5}}2$である.\\
7704           これを②式に代入すると……
7705           \par\vskip\abovecaptionskip
7706           \ltjenableadjust[profile=false, linestep=false]
7707           \par\centering\leavevmode{\small (b): $0.25$\cs{baselineskip}刻み}
7708         \end{minipage}\par\medskip
7709         \begin{minipage}[b]{16\zw}
7710           \ltjsetparameter{linestep_factor=0.5}
7711           \ltjenableadjust[profile, linestep]
7712           ……だから,①より$\dfrac{a^2}{b} = \dfrac{1+\sqrt{5}}2$.\\
7713           よって$b=\dfrac{1-\sqrt{5}}2$である.\\
7714           これを②式に代入すると……
7715           \par\vskip\abovecaptionskip
7716           \ltjenableadjust[profile=false, linestep=false]
7717           \par\centering\leavevmode{\small (c): 0.5\cs{baselineskip}刻み}
7718         \end{minipage}%
7719         \kern2\zw
7720         \begin{minipage}[b]{16\zw}
7721           \ltjsetparameter{linestep_factor=1}
7722           \ltjenableadjust[profile, linestep]
7723           ……だから,①より$\dfrac{a^2}{b} = \dfrac{1+\sqrt{5}}2$.\\
7724           よって$b=\dfrac{1-\sqrt{5}}2$である.\\
7725           これを②式に代入すると……
7726           \par\vskip\abovecaptionskip
7727           \ltjenableadjust[profile=false, linestep=false]
7728           \par\centering\leavevmode{\small (d): \cs{baselineskip}刻み}
7729         \end{minipage}\par
7730           \caption{段階的な行送り増加}\label{fig:linegap2}
7731   \end{figure}
7732
7733  \item[段階的な行送り調整]
7734   既に述べたように,
7735   「通常に組んだときの行間」$d$が\cs{lineskiplimit}より小さい場合,\TeX 標準では
7736   行間は\cs{lineskip}となるのだった.
7737   このとき行送りは「前の行の深さ」,「次の行の高さ」,\cs{lineskip}の3つの和になるわけだが,
7738   場合によっては行送りを「\cs{baselineskip}の整数倍」などと切りのいい値に揃えたいという状況が
7739   考えられなくもない.
7740   
7741   \Pkg{luatexja-adjust}パッケージでは,$d<\cs{lineskiplimit}$のときに
7742   行送りを\cs{baselineskip}の\Param{linestep\_factor}倍ずつ増減させて
7743   \begin{quote}
7744         行間が\cs{lineskip}以上となるような,
7745         最小の$(1+k\cdot \Param{linestep\_factor})\cs{baselineskip}$($k$は整数)の値
7746   \end{quote}
7747   とする機能を利用できるようにした.
7748   \autoref{fig:linegap2}の(a)がこの機能を無効にした状況で,(b),~(c),~(d)が
7749   それぞれ\Param{linestep\_factor}を0.25,~0.5,~1とした状況である.
7750
7751   なお,この機能は表組時(\cs{halign},~\cs{valign})には無効である.
7752   \LaTeX における表組環境(tabular, arrayなど)では,\cs{baselineskip},~\cs{lineskip}はどちらも0に設定されているので
7753   (代わりに各行に\cs{@arstrut}という支柱が入る)ために意味がないことと,
7754   数式を内部で表組を使って組むalign環境などではかえって行間が不揃いになってしまうからである.
7755 \end{description}
7756
7757 \Pkg{luatexja-adjust}パッケージは,上記で述べた4機能を有効化/無効化するための
7758 以下の命令を提供する.これらはすべてグローバルに効力を発揮する.
7759
7760 \begin{cslist}
7761 \item[\cs{ltjenableadjust[...]}]
7762 \verb+...+ に指定したkey-valueリストに従い,「行末文字の位置調整」「優先順位付きの行長調整」
7763   「『中身までみた』行送り計算」「段階的な行送り調整」%「濁点・半濁点付き仮名文字の正規化」
7764   を有効化/無効化する.
7765 指定できるキーは以下の通り.
7766 \begin{description}
7767   \item[\texttt{lineend=[false,true,extended]}]
7768   行末文字の位置調整の機能を無効化(\texttt{false}),「行分割後に調整」の形で有効化(\texttt{true}),
7769   「行分割の過程で考慮」の形で有効化(\texttt{extended})する.
7770   \item[\texttt{priority=[false,true]}]
7771   優先順位付きの行長調整を無効化(\texttt{false}),または有効化(\texttt{true}).
7772   \item[\texttt{profile=[false,true]}]
7773   「中身までみた」行送り計算を無効化(\texttt{false}),または有効化(\texttt{true}).
7774   \item[\texttt{linestep=[false,true]}]
7775   段階的な行送り調整を無効化(\texttt{false}),または有効化(\texttt{true}).
7776 %  \item[\texttt{composekana=[false,true]}]
7777 %  濁点・半濁点付き仮名文字の正規化を無効化(\texttt{false}),または有効化(\texttt{true}).
7778 \end{description}
7779 どのキーともキー名のみを指定した場合は値として\texttt{true}が指定されたものと扱われる.
7780
7781 互換性の為,オプション無しでただ\cs{ltjenableadjust}が呼び出された場合は,
7782 \begin{lstlisting}
7783 \ltjenableadjust[lineend=true,priority=true]
7784 \end{lstlisting}
7785 と扱われる.
7786   
7787 \item[\cs{ltjdisableadjust}]
7788 \Pkg{luatexja-adjust}パッケージの機能を無効化する.
7789 \begin{lstlisting}
7790 \ltjenableadjust[lineend=false,priority=false,profile=false,linestep=false]
7791 \end{lstlisting}
7792 と同義.
7793 \end{cslist}
7794
7795 また,次のパラメータが\cs{ltjsetparameter}内で
7796 追加される.いずれもグローバルに効力を発揮する.
7797 \begin{cslist}[style=standard]
7798 \item[\DParam{stretch\_priority}\,=\{\meta{list}\}]
7799 \Param{kanjiskip}, \Param{xkanjiskip},および「\textbf{JAglue}以外のグルー」を,
7800 「行を自然長より伸ばす」場合の調整に用いる優先度を指定する.
7801
7802 指定方法は,\meta{list}の中にkey-value listの形で
7803 \begin{lstlisting}
7804 stretch_priority={kanjiskip=-35,xkanjiskip=-25,others=50}
7805 \end{lstlisting}
7806 のようにして行う.キー名\texttt{kanjiskip},~\texttt{xkanjiskip}については
7807 そのままの意味であり,
7808 \texttt{others}キーが「\textbf{JAglue}以外のグルー」を表す.
7809 各キーの値は,JFMグルーにおける「優先度$i$」を$10i$に対応させた整数値であり,
7810   大きい方が先に伸ばされることを意味している.
7811   初期値は
7812 \begin{lstlisting}
7813 {kanjiskip=-35,xkanjiskip=-25,others=50}
7814 \end{lstlisting}
7815 であり,「優先度$-4$」と指定されているJFMグルーが最も伸びにくいようになっている.
7816
7817 \item[\DParam{shrink\_priority}\,=\{\meta{list}\}]
7818 同様に,「行を自然長より縮める」場合の調整に用いる優先度を指定する.
7819 それ以外は\Param{stretch\_priority}と指定の形式は変わらない(初期値も変わらない).
7820
7821  \item[\DParam{linestep\_factor}\,=\meta{float}]
7822   段階的な行送り調整の際,\cs{baselineskip}の自然長の何倍単位で行送りを変えるかを指定する.
7823   0を指定すると無効になるのと変わらない.また負数を指定すると,
7824   その絶対値が指定されたかのように扱われる.
7825   初期値は0.5(つまり半行単位)である.
7826
7827   \item[\DParam{profile\_hgap\_factor}\,=\meta{float}]
7828   「中身まで見た」行送り計算の際,
7829   前の行にある深さが大きいものと次の行にある高さが大きいものが
7830   水平方向にどれだけ離れていないといけないかを
7831   「\cs{lineskip}の自然長の何倍か」で指定する.
7832   負数を指定すると,その絶対値が指定されたかのように扱われる.
7833   初期値は1(つまり\cs{lineskip}(の自然長))である.
7834 \end{cslist}
7835
7836 さらに,バージョン20220211.0以降では次の命令が提供される.
7837 \begin{cslist}
7838   \item[\cs{ltjghostbeginjachar}]
7839   \LuaTeX-ja本体が提供している\cs{ltjfakeparbegin}, \cs{ltjfakeboxbdd}と類似の命令である.
7840   実行された箇所が(限定・非限定を問わず)水平モードであった場合に,実行された箇所は
7841   「文字クラス0の\textbf{JAchar}」の直前であると,
7842   \LuaTeX-jaの和文処理グルー挿入処理に認識させる.以下の実行例を参照.
7843
7844 \medskip
7845 \begin{LTXexample}[width=18\zw]
7846 \ltjsetparameter{kanjiskip=14pt,xkanjiskip=50pt}
7847 \let\LG=\ltjghostbeforejachar
7848 A\LG  B   \par% ==> ALchar--(xkanjiskip)--\LG
7849 A\LG  字  \par% ==> ALchar--(xkanjiskip)--\LG
7850 漢\LG B   \par% ==> JAchar--(kanjiskip)--\LG
7851 漢\LG 字  \par% ==> JAchar--(kanjiskip)--\LG
7852 \end{LTXexample}
7853
7854   \item[\cs{ltjghostafterjachar}]
7855   \cs{ltjghostbeginjachar}と対を成す命令で,実行された箇所は
7856   「文字クラス0の\textbf{JAchar}」の直後であると,
7857   \LuaTeX-jaの和文処理グルー挿入処理に認識させる.以下の実行例を参照.
7858
7859 \medskip
7860 \begin{LTXexample}[width=18\zw]
7861 \ltjsetparameter{kanjiskip=14pt,xkanjiskip=50pt}
7862 \let\LG=\ltjghostafterjachar
7863 A\LG  B   \par% ==> \LG--(xkanjiskip)--ALchar
7864 漢\LG B   \par% ==> \LG--(xkanjiskip)--ALchar
7865 A\LG  字  \par% ==> \LG--(kanjiskip)--JAchar
7866 漢\LG 字  \par% ==> \LG--(kanjiskip)--JAchar
7867 \end{LTXexample}
7868 \end{cslist}
7869 なお,バージョン20220207.0で追加された\cs{ltjghostjachar}は実装にバグがあったのと「両側」
7870 という点が扱いづらかったので,将来は削除する予定である.
7871
7872 両命令の主な仕様用途は和文ゴーストでの使用である.\Pkg{BXghost}パッケージ(\cite{bxghost})などでは
7873 伝統的に全角空白(\texttt{U+3000})と\verb+\kern-1\zw+を組み合わせた方法が使われてきたが,
7874 \LuaTeX-jaでは全角空白を使っただけではうまくいかない可能性があるため,新たに命令が用意された.
7875
7876 %</ja>
7877
7878 \subsection{\Pkg{luatexja-ruby}}
7879 %<*en>
7880 This addon package provides functionality of ``ruby'' (\emph{furigana}) annotations
7881 using callbacks of \LuaTeX-ja.
7882 There is no detailed manual of \Pkg{luatexja-ruby.sty} in English.
7883 (Japanese manual is another PDF file, \url{luatexja-ruby.pdf}.)
7884 %</en>
7885 %<*ja>
7886 この追加パッケージは,\LuaTeX-jaの機能を利用したルビ(振り仮名)の組版機能を提供する.
7887 前後の文字種に応じた前後への自動進入や,
7888 行頭形・行中形・行末形の自動的な使い分けが特徴である.
7889
7890 ルビ組版に設定可能な項目や注意事項が多いため,本追加パッケージの詳細な説明は
7891 使用例と共に \url{luatexja-ruby.pdf}\ という別ファイルに載せている.
7892 この節では簡単な使用方法のみ述べる.
7893 %</ja>
7894
7895 \begin{description}
7896 %<*en>
7897  \item[Group-ruby]
7898 By default, ruby characters (the second argument of \cs{ruby})
7899 are attached to base characters (the first argument), as one object.
7900 This type of ruby is called \emph{group-ruby}.
7901 %</en>
7902 %<*ja>
7903  \item[グループルビ] 標準ではグループルビの形で組まれる.第1引数に親文字,
7904 第2引数にルビを記述する.
7905 %</ja>
7906 \begin{LTXexample}[width=0.3\textwidth]
7907 東西線\ruby{妙典}{みようでん}駅は……\\
7908 東西線の\ruby{妙典}{みようでん}駅は……\\
7909 東西線の\ruby{妙典}{みようでん}という駅……\\
7910 東西線\ruby{葛西}{かさい}駅は……
7911 \end{LTXexample}
7912 %<*en>
7913 As the above example, ruby hangover is allowed on the Hiragana before/after
7914 its base characters.
7915 %</en>
7916 %<ja> この例のように,標準では前後の平仮名にルビ全角までかかるようになっている.
7917
7918 %<*en>
7919 \item[Mono-ruby]
7920 To attach ruby characters to each base characters (\emph{mono-ruby}),
7921 one should use \cs{ruby} multiple times:
7922 %</en>
7923 %<*ja>
7924  \item[モノルビ] 親文字を1文字にするとモノルビとなる.
7925 2文字以上の熟語をモノルビの形で組みたい場合は,面倒でも
7926 その数だけ \cs{ruby} を書く必要がある.
7927 %</ja>
7928 \begin{LTXexample}[width=0.3\textwidth]
7929 東西線の\ruby{妙}{みよう}\ruby{典}{でん}駅は……
7930 \end{LTXexample}
7931
7932 %<*en>
7933  \item[Jukugo-ruby]
7934 Vertical bar~\verb+|+ denotes a boundary of \emph{groups}.
7935 %</en>
7936 %<*ja>
7937  \item[熟語ルビ] 引数内の縦棒 \verb+|+ はグループの区切りを表し,
7938 複数グループのルビは熟語ルビとして組まれる.
7939 \cite{x4051}にあるように,
7940 どのグループでも「親文字」が対応するルビ以上の長さの場合は
7941 各グループごとに,そうでないときは全体をまとめて1つのグループルビとして組まれる.
7942 \cite{jlreq}で規定されている組み方とは異なるので注意.
7943 %</ja>
7944 \begin{LTXexample}
7945 \ruby{妙|典}{みよう|でん}\
7946 \ruby{葛|西}{か|さい}\
7947 \ruby{神楽|坂}{かぐら|ざか}
7948 \end{LTXexample}
7949 %<*en>
7950 If there are multiple groups in one \cs{ruby} call,
7951 A linebreak between two groups is allowed.
7952 %</en>
7953 %<ja> 複数ルビではグループとグループの間で改行が可能である.
7954 \begin{LTXexample}[width=0.3\textwidth]
7955 \vbox{\hsize=6\zw\noindent
7956   \hbox to 2.5\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
7957   \hbox to 2.5\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
7958   \hbox to   3\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
7959 }
7960 \end{LTXexample}
7961 \end{description}
7962
7963 %<*en>
7964 If the width of ruby characters are longer than that of base characters,
7965 \cs{ruby} automatically selects the appropriate form
7966 among the line-head form, the line-middle form, and the line-end form.
7967 %</en>
7968 %<*ja>
7969 また,ルビ文字のほうが親文字よりも長い場合は,自動的に
7970 行頭形・行中形・行末形のいずれか適切なものを選択する.
7971 %</ja>
7972 \begin{LTXexample}[width=0.3\textwidth]
7973 \vbox{\hsize=8\zw\noindent
7974 \null\kern3\zw ……を\ruby{承}{うけたまわ}る
7975      \kern1\zw ……を\ruby{承}{うけたまわ}る\\
7976 \null\kern5\zw ……を\ruby{承}{うけたまわ}る
7977 }
7978 \end{LTXexample}
7979
7980
7981 %<*ja>
7982 \subsection{\Pkg{lltjext}}
7983 \pLaTeX では縦組用の拡張として \Pkg{plext} パッケージが用意されていたが,
7984 それを\LuaTeX-ja用に書きなおしたものが本追加パッケージ \Pkg{lltjext} である.
7985
7986 従来の \Pkg{plext} パッケージとの違いは,
7987 \begin{itemize}
7988  \item 組方向オプション \texttt{<y>}(横組),\texttt{<t>}(縦組),
7989 \texttt{<z>}\ の他に\ \texttt{<d>}(dtou方向),\texttt{<u>}(utod方向)を追加した.
7990 \texttt{<z>} と \texttt{<u>} の違いは,\texttt{<z>} が(\Pkg{plext} パッケージと同様に)
7991 周囲の組方向が縦組のときにしか意味を持たない
7992   \footnote{%
7993     周囲の組方向が縦組以外のときは,\texttt{<z>} を指定しても中身の組方向は周囲の組方向と変わらない.
7994   }%
7995 のに対し,\texttt{<u>} にはそのような制限がないことである.
7996  \item 連数字用命令 \cs{rensuji} における位置合わせオプション \texttt{[l]}, \texttt{[c]},
7997        \texttt{[r]} の挙動を若干変更した.
7998 \end{itemize}
7999
8000 %</ja>
8001 %<*en>
8002 \subsection{\texttt{lltjext.sty}}
8003 \pLaTeX\ supplies additional macros for vertical writing in the \Pkg{plext} package.
8004 The \Pkg{lltjext} package which we want to describe here is the \LuaTeX-ja
8005 counterpart of the \Pkg{plext} package.
8006 %</en>
8007
8008 %<*ja>
8009 念の為,本 \Pkg{lltjext} パッケージで追加・変更している命令の一覧を載せておく.
8010 \begin{cslist}
8011 \item[tabular\textrm{, }array\textrm{, }minipage環境]
8012 これらの環境は,
8013 \begin{lstlisting}
8014 \begin{tabular}<dir>[pos]{table spec} ... \end{tabular}
8015 \begin{array}<dir>[pos]{table spec}   ... \end{array}
8016 \begin{minipage}<dir>[pos]{width}     ... \end{minipage}
8017 \end{lstlisting}
8018 のように,組方向オプション \texttt{\<dir\>} が拡張されている.
8019 既に述べたように,組方向オプションに指定できる値は以下の5つであり,
8020 それ以外を指定した時や無指定時は周囲の組方向と同じ組方向になる.
8021 \begin{description}
8022  \item[y] 横組(\cs{yoko})
8023  \item[t] 縦組(\cs{tate})
8024  \item[z] 周囲が縦組の時はutod方向,それ以外はそのまま
8025  \item[d] dtou方向
8026  \item[u] utod方向
8027 \end{description}
8028 \item[\cs{parbox}<\meta{dir}>{[\meta{pos}]}\{\meta{width}\}\{\meta{contents}\}]
8029 \cs{parbox} 命令も同様に,組方向の指定ができるように拡張されている.
8030
8031 \item[\cs{pbox}<\meta{dir}>{[\meta{width}][\meta{pos}]}\{\meta{contents}\}]
8032 組方向\meta{dir}で\meta{contents}の中身をLRモードで組む命令である.
8033 \meta{width}が正の値であるときは,ボックス全体の幅がその値となる.
8034 その際,中身は\meta{pos}の値に従い,左寄せ(\texttt{l}),右揃え(\texttt{r}),
8035 中央揃え(それ以外)される.
8036 \item[picture環境]
8037 図表作成に用いる\texttt{picture}環境も,
8038 \begin{lstlisting}
8039 \begin{picture}<dir>(x_size, y_size)(x_offset,y_offset)
8040   ...
8041 \end{picture}
8042 \end{lstlisting}
8043 と組方向が指定できるように拡張されている.
8044 $x$成分の増加方向は字送り方向,$y$成分の増加方向は行送り方向の\emph{反対方向}となる.
8045 \Pkg{plext} パッケージと同様に
8046 内部ではベースライン補正(\Param{yalbaselineshift}パラメータなど)の影響を受けないように,
8047 \cs{put},~\cs{line}, \cs{vector}, \cs{dashbox}, \cs{oval},~\cs{circle}も
8048 ベースライン補正を受けないように再定義されている.
8049
8050 \item[\cs{rensuji}{[\meta{pos}]}\{\meta{contents}\}\textrm{, }\cs{rensujiskip}]
8051
8052 \item[\cs{Kanji}\{\meta{counter\_name}\}]
8053
8054 \item[\cs{kasen}\{\meta{contents}\}\textrm{, }\cs{bou}\{\meta{contents}\}\textrm{,
8055                      }\cs{boutenchar}]
8056
8057 \item[参照番号]
8058 \end{cslist}
8059 %</ja>
8060 %<*en>
8061 \begin{cslist}
8062 \item[tabular\textrm{, }array\textrm{, }minipage\textrm{ environments}]
8063 These environments are extended by \texttt{\<dir\>}, which specifies the direction,
8064 as follows:
8065 \begin{lstlisting}
8066 \begin{tabular}<dir>[pos]{table spec} ... \end{tabular}
8067 \begin{array}<dir>[pos]{table spec}   ... \end{array}
8068 \begin{minipage}<dir>[pos]{width}     ... \end{minipage}
8069 \end{lstlisting}
8070 This option permits one of the following five values. If none of them is specified,
8071 the direction inside the environment is same as that outside the enviromnent.
8072 \begin{description}
8073  \item[y] \emph{yoko} direction (horizontal writing)
8074  \item[t] \emph{tate} direction (vertical writing)
8075  \item[z] \emph{utod} direction if direction outside the env.\ is \emph{tate}.
8076  \item[d] \emph{dtou} direction
8077  \item[u] \emph{utod} direction
8078 \end{description}
8079 \item[\cs{parbox}<\meta{dir}>{[\meta{pos}]}\{\meta{width}\}\{\meta{contents}\}]
8080 \cs{parbox} command is also extended by \texttt{<\meta{dir}>}.
8081
8082 \item[\cs{pbox}<\meta{dir}>{[\meta{width}][\meta{pos}]}\{\meta{contents}\}]
8083 This commands typeset \meta{contents} in LR-mode, in \meta{dir} direction.
8084 If \meta{width} is positive, the width of the box becomes this \meta{width}.
8085 In this case, \meta{contents} will be aligned to left (when \meta{pos} is \texttt{l}),
8086 center (\texttt{c}), or~right (\texttt{r}).
8087   
8088 \item[picture\textrm{\ environment}]
8089 \texttt{picture} environment also extended by \texttt{<\meta{dir}>}, as follows:
8090 \begin{lstlisting}
8091 \begin{picture}<dir>(x_size, y_size)(x_offset,y_offset)
8092   ...
8093 \end{picture}
8094 \end{lstlisting}
8095
8096 \item[\cs{rensuji}{[\meta{pos}]}\{\meta{contents}\}\textrm{, }\cs{rensujiskip}]
8097
8098 \item[\cs{Kanji}\{\meta{counter\_name}\}]
8099
8100 \item[\cs{kasen}\{\meta{contents}\}\textrm{, }\cs{bou}\{\meta{contents}\}\textrm{,
8101                      }\cs{boutenchar}]
8102
8103 \item[参照番号]
8104 \end{cslist}
8105 %</en>
8106
8107 %<*ja>
8108 \paragraph{表組他の揃え位置}
8109 表組(\texttt{array}, \texttt{tabular}環境),\cs{parbox}命令,\cs{minipage}環境の
8110 揃え位置については\autoref{tab:lltjext_dir}を参照.\pLaTeX~2017-07-29と
8111 できるだけ同じ挙動になるようにしている.\autoref{tab:lltjext_dir}中のA--Dの意味は次の通り.
8112
8113 \begin{table}
8114   \caption{\Pkg{lltjext}パッケージにおける表組・\cs{parbox}命令他の揃え位置}
8115   \label{tab:lltjext_dir}
8116   {\centering
8117     \begin{tabular}{lcccc}
8118       \toprule
8119       ↓中身\周囲→&\cs{yoko}&\cs{tate}&\cs{utod}&\cs{dtou}\\
8120       \midrule
8121       \cs{yoko}&A&B&B&B\\
8122       \cs{tate}&B&A&D&C\\
8123       \cs{utod}&B&D&A&C\\
8124       \cs{dtou}&B&C&C&A\\
8125       \bottomrule
8126     \end{tabular}\par}
8127 \end{table}
8128
8129 \begin{description}
8130  \item[A] 周囲の組方向と中身の組方向が同じ場合.
8131   \begin{itemize}
8132    \item \texttt{[t]}指定のとき:
8133     中身の先頭行のベースラインが周囲のベースラインと一致する.
8134     表組で先頭行の上に罫線があった場合は,それがベースラインの位置
8135     \footnote{\LuaTeX-jaでは和文側のベースラインの位置も上下移動できることに注意.
8136       そのため「和文ベースライン」の位置に来るとは限らない.}となる.
8137    \item \texttt{[c]}指定のとき:
8138     中身の上下の中心が周囲の数式の軸を通る.
8139    \item \texttt{[b]}指定のとき:
8140     中身の最終行のベースラインが周囲のベースラインと一致する.
8141     表組で最終行の下に罫線があった場合は,それがベースラインの位置となる.
8142   \end{itemize}
8143  \item[B] 周囲の組方向と中身の組方向が90度ずれている場合.
8144   \begin{itemize}
8145    \item \texttt{[t]}指定のとき:
8146     表組においては,上端が周囲のベースラインと一致する.
8147     \cs{parbox}や\cs{minipage}環境においては,上端が周囲の和文文字の上端と一致する.
8148    \item \texttt{[c]}指定のとき:
8149     中身の上下の中心が周囲の数式の軸を通る.
8150    \item \texttt{[b]}指定のとき:
8151     表組においては,下端が周囲のベースラインと一致する.
8152     \cs{parbox}や\cs{minipage}環境においては,下端が周囲の和文文字の下端と一致する.
8153   \end{itemize}
8154  \item[C] 周囲の組方向と中身の組方向が180度ずれている場合.
8155   \cs{parbox}や\cs{minipage}環境においては,上のBの場合と同じ挙動である.表組においては,
8156   Aで\texttt{[t]}と\texttt{[b]}を入れ替えた
8157   \begin{itemize}
8158    \item \texttt{[t]}指定のとき:
8159     中身の最終行のベースラインが周囲のベースラインと一致する.
8160     最終行の下に罫線があった場合は,それがベースラインの位置となる.
8161    \item \texttt{[c]}指定のとき:
8162     中身の上下の中心が周囲の数式の軸を通る.
8163    \item \texttt{[b]}指定のとき:
8164     中身の先頭行のベースラインが周囲のベースラインと一致する.
8165     表組で先頭行の上に罫線があった場合は,それがベースラインの位置となる.
8166   \end{itemize}
8167  \item[D] 通常の縦組(\cs{tate})と「縦数式ディレクション」に相当する\cs{utod}方向が絡んだ場合.
8168   \cs{parbox}や\cs{minipage}環境においては,上のBの場合と同じ挙動である.表組においては,
8169   \begin{itemize}
8170    \item \texttt{[t]}指定のとき:
8171     中身の先頭行の欧文ベースラインが周囲の欧文ベースラインと一致する.
8172    \item \texttt{[c]}指定のとき:
8173     中身の上下の中心が周囲の数式の軸を通る.
8174    \item \texttt{[b]}指定のとき:
8175     中身の最終行の欧文ベースラインが周囲の欧文ベースラインと一致する.
8176   \end{itemize}
8177 \end{description}
8178 %</ja>
8179
8180 \subsection{\Pkg{luatexja-preset}}
8181 \label{ssec:preset}
8182
8183 %<*en>
8184 As described in Subsection~\ref{ssec:preset-abst},
8185 One can load the \Pkg{luatexja-preset}
8186 package to use several ``presets'' of Japanese fonts.
8187 This package provides functions in a part of \Pkg{japanese-otf} package (changing fonts)
8188 and a part of \Pkg{PXchfon} package (presets) by Takayuki Yato.
8189
8190 Options which are given in \cs{usepackage} but not described in this~subsection
8191 are simply passed to the \Pkg{luatexja-fontspec}\footnote{if \texttt{nfssonly} option is
8192 \emph{not} specified; in this case these options are simply ignored.}.
8193 For example, the line~5 in below example is equivalent to lines 1--3.
8194 %</en>
8195 %<*ja>
8196 \ref{ssec:preset-abst}節で述べたように,よく使われている和文フォント設定を一行で指定できるようにしたのが
8197 \Pkg{luatexja-preset}パッケージである.このパッケージは,
8198 \Pkg{otf}パッケージの一部(多書体化)と八登崇之氏による\Pkg{PXchfon}パッケージの一部(プリセット指定)
8199 とを合わせたような格好をしている.
8200
8201 パッケージ読み込み時に渡されたオプションのうち,
8202 本節にないものを指定した場合,それらはそのまま
8203 \Pkg{luatexja-fontspec}パッケージに渡される\footnote{\texttt{nfssonly} オプションが
8204 指定されていた場合は,\Pkg{luatexja-fontspec}パッケージは読み込まれないので単純に無視され
8205 る.}.例えば,下の1--3行目は5行目のように一行にまとめることができる.
8206 %</ja>
8207 \begin{lstlisting}
8208 \usepackage[no-math]{fontspec}
8209 \usepackage[match]{luatexja-fontspec}
8210 \usepackage[kozuka-pr6n]{luatexja-preset}
8211 %%--------
8212 \usepackage[no-math,match,kozuka-pr6n]{luatexja-preset}
8213 \end{lstlisting}
8214
8215 %<en>\subsubsection{General Options}
8216 %<ja>\subsubsection{一般的なオプション}
8217 \label{sssec:ltjpreset-general}
8218
8219 \begin{cslist}[before*=]
8220 \item[fontspec%
8221 %<en>\textrm{~(enabled by default)}
8222 %<ja>\emph{\gtfamily (既定)}
8223 ]
8224 %<*en>
8225 With this option, Japanese fonts are selected using functionality of
8226 the \Pkg{luatexja-fontspec} package. This means that the \Pkg{fontspec} package is
8227              automatically loaded by this package.
8228
8229 If you need to pass some options to \Pkg{fontspec}, you can load \Pkg{fontspec} manually
8230 before \Pkg{luatexja-preset}:
8231 %</en>
8232 %<*ja>
8233 \Pkg{luatexja-fontspec}パッケージの機能を用いて和文フォントを選択する.
8234 これは,\Pkg{fontspec}パッケージが自動で読み込まれることを意味する.
8235
8236 もし\Pkg{fontspec}パッケージに何らかのオプションを渡す必要がある
8237 \footnote{例えば,数式フォントまで置換されてしまい,\cs{mathit}によってギリシャ文字の
8238 斜体大文字が出なくなる,など.}場合は,
8239 次のように\Pkg{luatexja-preset}の前に\Pkg{fontspec}を手動で読みこめば良い:
8240 %</ja>
8241 \begin{lstlisting}
8242 \usepackage[no-math]{fontspec}
8243 \usepackage[...]{luatexja-preset}
8244 \end{lstlisting}
8245
8246 \item[nfssonly]
8247 %<*en>
8248 With this option, selecting Japanese fonts won't be performed using the functionality of
8249              the \Pkg{fontspec} package, but only standard NFSS2 (hence without
8250              \cs{addjfontfeatures} etc.).
8251 This option is ignored when \Pkg{luatexja-fontspec} package is loaded.
8252
8253 When this option is specified, \Pkg{fontspec}~and~\Pkg{luatexja-fontspec} are
8254 \emph{not} loaded by default. Nevertheless,
8255 the package\Pkg{fontspec} can coexist with the option, as the following:
8256 \begin{lstlisting}
8257 \usepackage{fontspec}
8258 \usepackage[hiragino-pron,nfssonly]{luatexja-preset}
8259 \end{lstlisting}
8260 In this case, one can use \cs{setmainfont} etc.\ to select \emph{alphabetic} fonts.
8261 %</en>
8262 %<*ja>
8263 \LaTeX 標準のフォント選択機構(NFSS2)を用いて
8264 \texttt{ltjpm}$n$(明朝),\texttt{ltjpg}$n$(ゴシック),
8265 それに後に述べる\texttt{deluxe}オプションが指定された場合には
8266 \texttt{ltjpmg}$n$(丸ゴシック)という
8267 和文フォントファミリを定義%
8268 \footnote{%
8269   $n$は自然数であり,\cs{ltjapplypreset}の実行(この命令は\Pkg{luatexja-preset}パッケージ
8270   読み込み時に自動的に実行される)ごとに増加していく.
8271 }し,これらを用いる.
8272
8273 本オプション指定時には\Pkg{fontspec}・\Pkg{luatexja-fontspec}パッケージは
8274 自動では読み込まれない,しかし,
8275 \begin{lstlisting}
8276 \usepackage{fontspec}
8277 \usepackage[hiragino-pron,nfssonly]{luatexja-preset}
8278 \end{lstlisting}
8279 のようにすれば,このオプションを指定すれば
8280 欧文フォントを\Pkg{fontspec}パッケージの機能を使って指定することができる.
8281
8282 一方,\Pkg{luatexja-preset}パッケージ読み込み時に
8283 既に\Pkg{luatexja-fontspec}パッケージが読み込まれている場合は
8284 \texttt{nfssonly}オプションは無視される.
8285 %</ja>
8286
8287 \item[match]
8288 %<*en>
8289 If this option is specified, usual family-changing commands such as
8290 \cs{rmfamily},~\cs{textrm}, \cs{sffamily},~\dots\ also change Japanese font family.
8291 This option is passed to \Pkg{luatexja-fontspec}, if \texttt{fontspec}
8292 option is specifed.
8293 %</en>
8294
8295 %<*ja>
8296 このオプションが指定されると,「\pLaTeXe 新ドキュメントクラス」のように\
8297 \cs{rmfamily}, \verb+\textrm{...}+, \cs{sffamily} 等が
8298 欧文フォントだけでなく和文フォントも変更するようになる.
8299 \ \texttt{fontspec}\
8300 オプションが有効になっている場合は,このオプションは \Pkg{luatexja-fontspec} パッケージへと渡される.
8301 %</ja>
8302
8303
8304 \item[nodeluxe%
8305 %<en>\textrm{~(enabled by default)}
8306 %<ja>\emph{\gtfamily (既定)}
8307 ]
8308 %<*en>
8309 The nagation of \texttt{deluxe} option.
8310 Use one-weighted \textit{mincho} and \textit{gothic} font families.
8311 This means that \verb+\mcfamily\bfseries+, \verb+\gtfamily\bfseries+ and
8312 \verb+\gtfamily\mdseries+ use the same font.
8313 %</en>
8314 %<*ja>
8315 \texttt{deluxe}オプションの否定.
8316 \LaTeXe 環境下の標準設定のように,明朝体・ゴシック体を各1ウェイトで使用する.
8317 より具体的に言うと,この設定の下では
8318 \ \verb+\mcfamily\bfseries+, \verb+\gtfamily\bfseries+,
8319 \verb+\gtfamily\mdseries+はみな同じフォントとなる.
8320 %</ja>
8321 \item[deluxe]
8322 %<*en>
8323 Use the mincho family with three weights (light, medium, and~bold),
8324 the gothic family with three weights (medium, bold, and extra~bold), and \textit{rounded gothic}%
8325 \footnote{Provided by \cs{mgfamily} and \cs{textmg},
8326 because ``rounded gothic'' is called \textit{maru gothic} (丸ゴシック) in Japanese.}.
8327 Mincho light and gothic extra~bold can be by
8328 \cs{mcfamily}\cs{ltseries}~and~\cs{gtfamily}\cs{ebseries}, respectively.
8329
8330 \begin{itemize}
8331  \item Some presets do not have the light weight of mincho.
8332   In this case, we substitute the medium weight for the light weight.
8333  \item \Pkg{luatexja-preset} does not produce an error (only produces a warning), even if
8334   (one of) fonts for \cs{mcfamily}\cs{ltseries}, \cs{gtfamily}\cs{ebseries}, \cs{mgfamily}
8335   do not exist.
8336 \end{itemize}
8337 %</en>
8338 %<*ja>
8339 明朝体・ゴシック体各3ウェイトと,
8340 丸ゴシック体 (\cs{mgfamily}, \verb+\textmg{...}+) を利用可能にする.
8341 明朝体は細字・中字・太字の3ウェイトがあり,
8342 明朝体の細字は \cs{mcfamily}\cs{ltseries} で利用できる.
8343 また,ゴシック体は中字・太字・極太の3ウェイトがあり,
8344 ゴシック体の極太は \cs{gtfamily}\cs{ebseries} で利用できる%
8345 \footnote{過去との互換性のため,\cs{gtebfamily}, \cs{textgteb\{...\}} も
8346  依然として利用可能である.}.
8347
8348 \begin{itemize}
8349   \item プリセット設定によっては明朝体細字が用意されていないものもある.その場合は
8350   明朝体中字が代用される.
8351   \item 明朝体細字,ゴシック体極太,丸ゴシック体の3フォントについては
8352   実際にフォントをロードする前に存在するかチェックを行う.
8353   存在しなかったものについては警告を発し,
8354   それぞれ明朝体中字.ゴシック体太字,ゴシック体太字で代用する.
8355 \end{itemize}
8356 %</ja>
8357 \item[expert]
8358 %<*en>
8359 Use horizontal/vertical kana alternates, and define a command \cs{rubyfamily} to use kana
8360 characters designed for ruby.
8361 %</en>
8362 %<*ja>
8363 横組・縦組専用仮名を用いる.また,\cs{rubyfamily} でルビ用仮名が使用可能となる\footnote{%
8364   \cs{rubyfamily}とはいいつつ,実際にはフォントファミリを切り替えるのではない(通常では
8365   OpenType機能の有効化であり,\texttt{nfssonly} 指定時にはシェイプを \texttt{rb} に切り替える).
8366 }.
8367 %</ja>
8368 \item[bold]
8369 %<*en>
8370 Substitute bold series of gothic for medium series of gothic and bold series of mincho.
8371 If \texttt{nodeluxe} option is enabled, medium series of gothic is also changed,
8372 since we use same font for both series of gothic.
8373 %</en>
8374 %<*ja>
8375 \texttt{nodeluxe}オプション指定時には,「明朝の太字」をゴシック体と同じフォントにする.
8376 \texttt{deluxe}オプション指定時には,「明朝の太字」「ゴシック体の中字」をゴシック体の太字と同じフォントにする.
8377 %</ja>
8378 \item[jis90\textrm{,~}90jis]
8379 %<en>Use JIS~X~0208:1990 glyph variants if possible.
8380 %<ja>出来る限りJIS~X~0208:1990の字形を使う.
8381 \item[jis2004\textrm{,~}2004jis]
8382 %<en>Use JIS~X~0213:2004 glyph variants if possible.
8383 %<ja>出来る限りJIS~X~0213:2004の字形を使う.
8384 \item[jfm\_yoko=\meta{jfm}]
8385 %<*en>
8386 Use the JFM \texttt{jfm-\meta{jfm}.lua} for horizontal direction, instead of \texttt{jfm-ujis.lua}~(default JFM).
8387 %</en>
8388 %<*ja>
8389 横組用和文フォントで用いるJFMを\texttt{jfm-\meta{jfm}.lua}にする.このオプションがない時は
8390 \LuaTeX\nobreakdash -ja標準の\texttt{jfm-ujis.lua}が用いられる.
8391 %</ja>
8392 \item[jfm\_tate=\meta{jfm}]
8393 %<*en>
8394 Use the JFM \texttt{jfm-\meta{jfm}.lua} for vertical direction, instead of \texttt{jfm-ujisv.lua}~(default JFM).
8395 %</en>
8396 %<*ja>
8397 縦用和文フォントで用いるJFMを\texttt{jfm-\meta{jfm}.lua}にする.このオプションがない時は
8398 \LuaTeX-ja標準の\texttt{jfm-ujisv.lua}が用いられる.
8399 %</ja>
8400
8401 \item[jis]
8402 %<en>Same as \texttt{jfm\_yoko=jis}.
8403 %<ja>\texttt{jfm\_yoko=jis}と同じ.ここで用いるJFM~\texttt{jfm-jis.lua}はJISフォントメトリックを元にしたものである.
8404
8405 \end{cslist}
8406 %<*en>
8407 Note that \texttt{jis90},~\texttt{90jis}, \texttt{jis2004}~and~\texttt{2004jis} only affect with mincho,
8408 gothic (and, possibly rounded gothic) families defined by this package.
8409 We didn't taken account of when more than one options among them are specified.
8410 %</en>
8411 %<*ja>
8412 \texttt{jis90},~\texttt{90jis}, \texttt{jis2004},~\texttt{2004jis}については本パッケージで定義された
8413 明朝体・ゴシック体(・丸ゴシック体)にのみ有効である.
8414 これら4オプションのうち複数が同時に指定された場合の動作については全く考慮していない.
8415 %</ja>
8416
8417 %<en>\subsubsection{Presets which support multi weights}
8418 %<ja>\subsubsection{多ウェイト用プリセットの一覧}
8419 \label{sssec:ltjpreset-multi}
8420
8421 %<*en>
8422 Besides \texttt{bizud}, \texttt{haranoaji}, \texttt{morisawa-pro},~and~\texttt{morisawa-pr6n} presets,
8423 fonts are specified by font name, not by file name.
8424 In following tables, starred fonts (e.g.~KozGo\dots-Regular) are used for medium series of \textit{gothic},
8425 \emph{if and only if \texttt{deluxe} option is specified}.
8426 %</en>
8427 %<*ja>
8428 \texttt{bizud}, \texttt{haranoaji}, \texttt{morisawa-pro}, \texttt{morisawa-pr6n}以外はフォントの指定は
8429 (ファイル名でなく)フォント名で行われる.
8430 以下の表において,*\,つきのフォント(e.g.,~KozGo\dots-Regular)は,\emph{\texttt{deluxe}オプション指定時に}
8431 ゴシック体中字として用いられるものを示している.
8432 %</ja>
8433 \begin{cslist}[style=standard]
8434  \item[kozuka-pro] Kozuka Pro (Adobe-Japan1-4) fonts.
8435 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
8436  \item[kozuka-pr6] Kozuka Pr6 (Adobe-Japan1-6)  fonts.
8437 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
8438  \item[kozuka-pr6n] Kozuka Pr6N (Adobe-Japan1-6, JIS04-savvy) fonts.
8439
8440 %<*en>
8441 Kozuka Pro/Pr6N fonts are bundled with Adobe's software, such as Adobe~InDesign.
8442 There is not rounded gothic family in Kozuka fonts.
8443 %</en>
8444 %<*ja>
8445 小塚Pro書体・Pr6N書体はAdobe InDesign等のAdobe製品にバンドルされている.
8446 「小塚丸ゴシック」は存在しないので,便宜的に小塚ゴシックHによって代用している.
8447 %</ja>
8448 \begin{center}\small
8449 \begin{tabular}{lllll}
8450 \toprule
8451 \bfseries family&\bfseries series&\ttfamily kozuka-pro&\ttfamily kozuka-pr6&\ttfamily kozuka-pr6n\\
8452 \midrule
8453  &light&KozMinPro-Light&KozMinProVI-Light&KozMinPr6N-Light\\
8454 %<en>\textit{mincho}%
8455 %<ja>\textgt{明朝}%
8456  &medium&KozMinPro-Regular&KozMinProVI-Regular&KozMinPr6N-Regular\\
8457  &bold&KozMinPro-Bold&KozMinProVI-Bold&KozMinPr6N-Bold\\
8458 \midrule
8459  &&KozGoPro-Regular*&KozGoProVI-Regular*&KozGoPr6N-Regular*\\
8460  &\smash{\raisebox{1.5ex}{medium}}
8461  &KozGoPro-Medium&KozGoProVI-Medium&KozGoPr6N-Medium\\
8462 \cmidrule(l){2-5}
8463 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
8464 %<ja>\smash{\raisebox{2ex}{\textgt{ゴシック}}}%
8465  &bold&KozGoPro-Bold&KozGoProVI-Bold&KozGoPr6N-Bold\\
8466  &extra bold&KozGoPro-Heavy&KozGoProVI-Heavy&KozGoPr6N-Heavy\\
8467 \midrule
8468 %<en>\textit{rounded gothic}
8469 %<ja>\textgt{丸ゴシック}
8470 &&KozGoPro-Heavy&KozGoProVI-Heavy&KozGoPr6N-Heavy\\
8471 \bottomrule
8472 \end{tabular}
8473 \end{center}
8474
8475  \item[hiragino-pro]  Hiragino Pro (Adobe-Japan1-5) fonts.
8476 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
8477  \item[hiragino-pron] Hiragino ProN (Adobe-Japan1-5, JIS04-savvy) fonts.
8478
8479 %<*en>
8480 Hiragino fonts (except Hiragino~Mincho~W2) are bundled with Mac OS~X 10.5 or later.
8481 Note that fonts for gothic extra~bold (HiraKakuStd[N]-W8) only contains characters in
8482 Adobe-Japan1-3 character collection, while others contains those in
8483 Adobe-Japan1-5 character collection.
8484 %</en>
8485 %<*ja>
8486 極太ゴシック体として用いるヒラギノ角ゴW8は,Adobe-Japan1-3の範囲しかカバーしていない
8487 Std/StdNフォントであり,その他はAdobe-Japan1-5対応である.
8488
8489 なお,明朝体細字として用いるヒラギノ明朝体W2はOS~Xにはバンドルされておらず,
8490 別途購入する必要がある.
8491 %</ja>
8492 \begin{center}\small
8493 \begin{tabular}{llll}
8494 \toprule
8495 \bf family&\bf series&\tt hiragino-pro&\tt hiragino-pron\\
8496 \midrule
8497  &light&Hiragino~Mincho~Pro~W2&Hiragino~Mincho~ProN~W2\\
8498 %<en>\textit{mincho}%
8499 %<ja>\textgt{明朝}%
8500  &medium&Hiragino~Mincho~Pro~W3&Hiragino~Mincho~ProN~W3\\
8501  &bold&Hiragino~Mincho~Pro~W6&Hiragino~Mincho~ProN~W6\\
8502 \midrule
8503  &&Hiragino~Kaku~Gothic~Pro~W3*&Hiragino~Kaku~Gothic~ProN~W3*\\
8504  &\smash{\raisebox{1.5ex}{medium}}
8505  &Hiragino~Kaku~Gothic~Pro~W6&Hiragino~Kaku~Gothic~ProN~W6\\
8506 \cmidrule(l){2-4}
8507 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
8508 %<ja>\smash{\raisebox{2ex}{\textgt{ゴシック}}}%
8509  &bold&Hiragino~Kaku~Gothic~Pro~W6&Hiragino~Kaku~Gothic~ProN~W6\\
8510  &extra bold&Hiragino~Kaku~Gothic~Std~W8&Hiragino~Kaku~Gothic~StdN~W8\\
8511 \midrule
8512 %<en>\textit{rounded gothic}
8513 %<ja>\textgt{丸ゴシック}
8514 &&Hiragino~Maru~Gothic~Pro~W4&Hiragino~Maru~Gothic~ProN~W4\\
8515 \bottomrule
8516 \end{tabular}
8517 \end{center}
8518
8519 \item[bizud] BIZ UD fonts (by Morisawa Inc.) bundled with
8520   Windows~10 October 2018 Update.
8521 \begin{center}\small
8522 \begin{tabular}{ll>{\ttfamily}l}
8523 \toprule
8524 \textbf{family}&\textbf{series}\\
8525 \midrule
8526 %<en>\textit{mincho}
8527 %<ja>\textgt{明朝}%
8528  &&BIZ-UDMinchoM.ttc\\
8529 \midrule
8530  &medium&BIZ-UDGothicR.ttc\\
8531 \cmidrule(l){2-3}
8532 %<en>\textit{gothic}%
8533 %<ja>\textgt{ゴシック}
8534  &bold&BIZ-UDGothicB.ttc\\
8535  &extra bold&BIZ-UDGothicB.ttc\\
8536 \midrule
8537 %<en>\textit{rounded gothic}
8538 %<ja>\textgt{丸ゴシック}
8539 &&BIZ-UDGothicB.ttc\\
8540 \bottomrule
8541 \end{tabular}
8542 \end{center}
8543
8544 %<en>\newpage
8545
8546  \item[morisawa-pro]  Morisawa Pro (Adobe-Japan1-4) fonts.
8547 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
8548  \item[morisawa-pr6n]  Morisawa Pr6N (Adobe-Japan1-6, JIS04-savvy) fonts.
8549 \begin{center}\footnotesize
8550 \begin{tabular}{ll>{\tt}l>{\tt}l}
8551 \toprule
8552 \bf family&\bf series&morisawa-pro&morisawa-pr6n\\
8553 \midrule
8554  &medium&A-OTF-RyuminPro-Light.otf&A-OTF-RyuminPr6N-Light.otf\\
8555 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
8556 %<ja>\smash{\raisebox{1.5ex}{\textgt{明朝}}}%
8557  &bold&A-OTF-FutoMinA101Pro-Bold.otf&A-OTF-FutoMinA101Pr6N-Bold.otf\\
8558 \midrule
8559  &medium
8560  &A-OTF-GothicBBBPro-Medium.otf&A-OTF-GothicBBBPr6N-Medium.otf\\
8561 %<en>\textit{gothic}%
8562 %<ja>\textgt{ゴシック}
8563  &bold&A-OTF-FutoGoB101Pro-Bold.otf&A-OTF-FutoGoB101Pr6N-Bold.otf\\
8564  &extra bold&A-OTF-MidashiGoPro-MB31.otf&A-OTF-MidashiGoPr6N-MB31.otf\\
8565 \midrule
8566 %<en>\textit{rounded gothic}
8567 %<ja>\textgt{丸ゴシック}
8568 &&A-OTF-Jun101Pro-Light.otf&A-OTF-ShinMGoPr6N-Light.otf\\
8569 \bottomrule
8570 \end{tabular}
8571 \end{center}
8572
8573
8574  \item[yu-win]  Yu fonts bundled with Windows~8.1.
8575 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
8576  \item[yu-win10]  Yu fonts bundled with Windows~10.
8577 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
8578  \item[yu-osx]  Yu fonts bundled with OSX~Mavericks.
8579 \begin{center}\small
8580 \begin{tabular}{lllll}
8581 \toprule
8582 \bf family&\bf series&\texttt{yu-win}&\texttt{yu-win10}&\texttt{yu-osx}\\
8583 \midrule
8584  &light&YuMincho-Light&YuMincho-Light&(YuMincho~Medium)\\
8585 %<en>\textit{mincho}%
8586 %<ja>\textgt{明朝}%
8587  &medium&YuMincho-Regular&YuMincho-Regular&YuMincho~Medium\\
8588  &bold&YuMincho-Demibold&YuMincho-Demibold&YuMincho~Demibold\\
8589 \midrule
8590  &&YuGothic-Regular*&YuGothic-Regular*&YuGothic~Medium*\\
8591  &\smash{\raisebox{1.5ex}{medium}}%
8592         &YuGothic-Regular&YuGothic-Medium&YuGothic~Medium\\
8593 \cmidrule(l){2-5}
8594 %<en>\textit{gothic}%
8595 %<ja>\textgt{ゴシック}
8596  &bold&YuGothic-Bold&YuGothic-Bold&YuGothic~Bold\\
8597  &extra bold&YuGothic-Bold&YuGothic-Bold&YuGothic~Bold\\
8598 \midrule
8599 %<en>\textit{rounded gothic}
8600 %<ja>\textgt{丸ゴシック}
8601 &&YuGothic-Bold&YuGothic-Bold&YuGothic~Bold\\
8602 \bottomrule
8603 \end{tabular}
8604 \end{center}
8605
8606 \item[moga-mobo]  MogaMincho, MogaGothic, and MoboGothic.
8607 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
8608 \item[moga-mobo-ex]  MogaExMincho, MogaExGothic, and MoboExGothic.
8609 %<en>\par These fonts can be downloaded from \url{http://yozvox.web.fc2.com/}.
8610 %<ja>これらのフォントは \url{http://yozvox.web.fc2.com/} からダウンロードできる.
8611 \begin{center}\small
8612 \begin{tabular}{llll}
8613 \toprule
8614 \bf family&\bf series&\bf default, \texttt{90jis}~option&\bf \texttt{jis2004} option\\
8615 \midrule
8616  &medium&Moga90Mincho&MogaMincho\\
8617 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
8618 %<ja>\smash{\raisebox{1.5ex}{\textgt{明朝}}}%
8619  &bold&Moga90Mincho Bold&MogaMincho Bold\\
8620 \midrule
8621  &medium&Moga90Gothic&MogaGothic\\
8622 %<en>\textit{gothic}%
8623 %<ja>\textgt{ゴシック}
8624  &bold&Moga90Gothic Bold&MogaGothic Bold\\
8625  &extra bold&Moga90Gothic Bold&MogaGothic Bold\\
8626 \midrule
8627 %<en>\textit{rounded gothic}
8628 %<ja>\textgt{丸ゴシック}
8629 &&Mobo90Gothic&MoboGothic\\
8630 \bottomrule
8631 \end{tabular}
8632 \end{center}
8633 %<en>When \texttt{moga-mobo-ex} is specified, the font ``MogaEx90Mincho'' etc.\ are used.
8634 %<ja>\texttt{moga-mobo-ex}オプション指定時にはMogaEx90MinchoなどのExが名前についたフォントが使われる.
8635
8636 \item[ume]  Ume Mincho and Ume Gothic.
8637 %<en>\par These fonts can be downloaded from\\\hfill \url{https://ja.osdn.net/projects/ume-font/wiki/FrontPage}.
8638 %<ja>これらのフォントは \url{https://ja.osdn.net/projects/ume-font/wiki/FrontPage} からダウンロードできる.
8639 \begin{center}\small
8640 \begin{tabular}{lll}
8641 \toprule
8642 \bf family&\bf series&\bf default\\
8643 \midrule
8644  &medium&Ume Mincho\\
8645 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
8646 %<ja>\smash{\raisebox{1.5ex}{\textgt{明朝}}}%
8647  &bold&Ume Mincho\\
8648 \midrule
8649  &&Ume Gothic*\\
8650  &\smash{\raisebox{1.5ex}{medium}}&Ume Gothic O5\\
8651 \cmidrule(l){2-3}
8652 %<en>\textit{gothic}%
8653 %<ja>\textgt{ゴシック}
8654  &bold&Ume Gothic O5\\
8655  &extra bold&Ume Gothic O5\\
8656 \midrule
8657 %<en>\textit{rounded gothic}
8658 %<ja>\textgt{丸ゴシック}
8659 &&Ume Gothic O5\\
8660 \bottomrule
8661 \end{tabular}
8662 \end{center}
8663
8664 %<en>\newpage
8665  \item[sourcehan]  Source Han Serif and Source Han Sans fonts (Language-specific OTF \textit{or} OTC)
8666 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
8667  \item[sourcehan-jp]  Source Han Serif JP and Source Han Sans JP fonts (Region-specific Subset OTF)
8668 \begin{center}\small
8669 \def\AD#1#2{Source Han #1 #2&Source Han #1 JP #2}%
8670 \begin{tabular}{lllll}
8671 \toprule
8672 \bf family&\bf series&\texttt{sourcehan}&\texttt{sourcehan-jp}\\
8673 \midrule
8674  &light&\AD{Serif}{Light}\\
8675 %<en>\textit{mincho}%
8676 %<ja>\textgt{明朝}%
8677  &medium&\AD{Serif}{Regular}\\
8678  &bold&\AD{Serif}{Bold}\\
8679 \midrule
8680  &&\AD{Sans}{Regular*}\\
8681  &\smash{\raisebox{1.5ex}{medium}}
8682  &\AD{Sans}{Medium}\\
8683 \cmidrule(l){2-4}
8684 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
8685 %<ja>\smash{\raisebox{2ex}{\textgt{ゴシック}}}%
8686  &bold&\AD{Sans}{Bold}\\
8687  &extra bold&\AD{Sans}{Heavy}\\
8688 \midrule
8689 %<en>\textit{rounded gothic}
8690 %<ja>\textgt{丸ゴシック}
8691 &&\AD{Sans}{Medium}\\
8692 \bottomrule
8693 \end{tabular}
8694 \end{center}
8695
8696
8697  \item[noto-otc]  Noto Serif CJK and Noto Sans CJK fonts (OTC)
8698 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
8699  \item[noto-otf\textrm{, }noto]  Noto Serif CJK and Noto Sans CJK fonts (Language-specific OTF)
8700 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
8701  \item[noto-jp]  Noto Serif CJK and Noto Sans CJK fonts (Region-specific subset OTF)
8702 \begin{center}\small
8703 \def\AD#1#2{Noto #1 CJK #2&Noto #1 CJK JP #2&Noto #1 JP #2}%
8704 \begin{tabular}{lllll}
8705 \toprule
8706 \bf family&\bf series&\texttt{noto-otc}&\texttt{noto-otf}, \texttt{noto}&\texttt{noto-jp}\\
8707 \midrule
8708  &light&\AD{Serif}{Light}\\
8709 %<en>\textit{mincho}%
8710 %<ja>\textgt{明朝}%
8711  &medium&\AD{Serif}{Regular}\\
8712  &bold&\AD{Serif}{Bold}\\
8713 \midrule
8714  &&\AD{Sans}{Regular*}\\
8715  &\smash{\raisebox{1.5ex}{medium}}
8716  &\AD{Sans}{Medium}\\
8717 \cmidrule(l){2-5}
8718 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
8719 %<ja>\smash{\raisebox{2ex}{\textgt{ゴシック}}}%
8720  &bold&\AD{Sans}{Bold}\\
8721  &extra bold&\AD{Sans}{Black}\\
8722 \midrule
8723 %<en>\textit{rounded gothic}
8724 %<ja>\textgt{丸ゴシック}
8725 &&\AD{Sans}{Medium}\\
8726 \bottomrule
8727 \end{tabular}
8728 \end{center}
8729
8730 \item[haranoaji]  Harano Aji Fonts.
8731 %<en>\par These fonts can be downloaded from\\\hfill \url{https://github.com/trueroad/HaranoAjiFonts}.
8732 %<ja>これらのフォントは \url{https://github.com/trueroad/HaranoAjiFonts} からダウンロードできる.
8733 %<*en>
8734 There is not rounded gothic family in Harano Aji Fonts.
8735 %</en>
8736 %<*ja>
8737 「原ノ味丸ゴシック」は存在しないので,便宜的に原ノ味角ゴシックHeavyによって代用している.
8738 %</ja>
8739 \begin{center}\small
8740 \begin{tabular}{lll}
8741 \toprule
8742 \bf family&\bf series&\texttt{haranoaji}\\
8743 \midrule
8744  &light&HaranoAjiMincho-Light.otf\\
8745 %<en>\textit{mincho}%
8746 %<ja>\textgt{明朝}%
8747  &medium&HaranoAjiMincho-Regular.otf\\
8748  &bold&HaranoAjiMincho-Bold.otf\\
8749 \midrule
8750  &&HaranoAjiGothic-Regular.otf*\\
8751  &\smash{\raisebox{1.5ex}{medium}}
8752  &HaranoAjiGothic-Medium.otf\\
8753 \cmidrule(l){2-3}
8754 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
8755 %<ja>\smash{\raisebox{2ex}{\textgt{ゴシック}}}%
8756  &bold&HaranoAjiGothic-Bold.otf\\
8757  &extra bold&HaranoAjiGothic-Heavy.otf\\
8758 \midrule
8759 %<en>\textit{rounded gothic}
8760 %<ja>\textgt{丸ゴシック}
8761 &&HaranoAjiGothic-Medium.otf\\
8762 \bottomrule
8763 \end{tabular}
8764 \end{center}
8765 \end{cslist}
8766
8767 %<en>\subsubsection{Presets which do not support multi weights}
8768 %<ja>\subsubsection{単ウェイト用プリセット一覧}
8769 \label{sssec:ltjpreset-single}
8770
8771 %<*en>
8772 Next, we describe settings for using only single weight.
8773 %</en>
8774 %<*ja>
8775 次に,単ウェイト用の設定を述べる.この4設定では
8776 明朝体太字・丸ゴシック体はゴシック体と同じフォントが用いられる.
8777 %</ja>
8778 \par\nobreak\medskip
8779 {\centering\small
8780 \begin{tabular}{lllll}
8781 \toprule
8782 &\tt noembed&\tt ipa&\tt ipaex&\tt ms\\
8783 \midrule
8784 %<*en>
8785 \it mincho&Ryumin-Light (non-embedded)
8786 &IPA Mincho&IPAex Mincho&MS Mincho\\
8787 \it gothic&GothicBBB-Medium (non-embedded)
8788 &IPA Gothic&IPAex Gothic&MS Gothic\\
8789 %</en>
8790 %<*ja>
8791 \gtfamily 明朝&Ryumin-Light(非埋込)
8792 &IPA明朝&IPAex明朝&MS明朝\\
8793 \gtfamily ゴシック&GothicBBB-Medium(非埋込)
8794 &IPAゴシック&IPAexゴシック&MSゴシック\\
8795 %</ja>
8796 \bottomrule
8797 \end{tabular}\par\medskip}
8798
8799 %<en>\subsubsection{Presets which use HG fonts}
8800 %<ja>\subsubsection{HGフォントを使うプリセット}
8801 \label{sssec:ltjpreset-hg}
8802 %<*en>
8803 We can use HG~fonts bundled with Microsoft~Office for realizing multiple weights.
8804 In the table below, starred fonts (e.g., IPA~Gothic*) are used
8805 only if \texttt{jis2004} or \texttt{nodeluxe} option is spefified.
8806 %</en>
8807 %<*ja>
8808 すぐ前に書いた単ウェイト用設定を,Microsoft Office等に付属するHGフォントを使って
8809 多ウェイト化した設定もある.以下の表では,*~付きのフォント(例:IPAゴシック*)は
8810 \texttt{jis2004}と\texttt{nodeluxe}のいずれかのオプションが有効になっているときに使われる.
8811 %</ja>
8812 \par\nobreak\medskip
8813 {\centering\small
8814 \begin{tabular}{lllll}
8815 \toprule
8816 \textbf{family}&\textbf{series}&\tt ipa-hg&\tt ipaex-hg&\tt ms-hg\\
8817 \midrule
8818 %<*en>
8819 &medium&IPA Mincho&IPAex Mincho&MS Mincho\\
8820 \smash{\raisebox{1.5ex}{\textit{mincho}}}%
8821 &bold&HG Mincho E&HG Mincho E&HG Mincho E\\\midrule
8822 &&IPA Gothic*&IPAex Gothic*&MS Gothic*\\
8823 &\smash{\raisebox{1.5ex}{medium}}%
8824 &HG Gothic M&HG Gothic M&HG Gothic M\\\cmidrule{2-5}
8825 \textit{gothic}&bold&HG Gothic E&HG Gothic E&HG Gothic E\\\cmidrule{2-5}
8826 &extra bold&HG Soei Kaku Gothic UB&HG Soei Kaku Gothic UB&HG Soei Kaku Gothic UB\\\midrule
8827 \textit{rounded gothic}&&
8828 HG MaruGothic M PRO&HG MaruGothic M PRO&HG MaruGothic M PRO\\
8829 %</en>
8830 %<*ja>
8831 &medium&IPA明朝&IPAex明朝&MS明朝\\
8832 \smash{\raisebox{1.5ex}{\textgt{明朝}}}%
8833 &bold&HG明朝E&HG明朝E&HG明朝E\\\midrule
8834 &&IPAゴシック*&IPAexゴシック*&MSゴシック*\\
8835 &\smash{\raisebox{1.5ex}{medium}}%
8836 &HGゴシックM&HGゴシックM&HGゴシックM\\\cmidrule{2-5}
8837 \textgt{ゴシック}&bold&HGゴシックE&HGゴシックE&HGゴシックE\\\cmidrule{2-5}
8838 &extra bold&HG創英角ゴシックUB&HG創英角ゴシックUB&HG創英角ゴシックUB\\\midrule
8839 \textgt{丸ゴシック}&&
8840 HG丸ゴシックM-PRO&HG丸ゴシックM-PRO&HG丸ゴシックM-PRO\\
8841 %</ja>
8842 \bottomrule
8843 \end{tabular}\par\medskip}
8844
8845 %<*en>
8846 Note that HG~Mincho~E, HG~Gothic~E, HG Soei Kaku Gothic UB, and HG Maru Gothic PRO
8847 are internally specified by:
8848 \begin{description}
8849 \item[default] by font name (\texttt{HGMinchoE}, etc.).
8850 \item[\texttt{jis90}, \texttt{90jis}] by file name (\texttt{hgrme.ttc}, \texttt{hgrge.ttc}, \texttt{hgrsgu.ttc}, \texttt{hgrsmp.ttf}).
8851 \item[\texttt{jis2004}, \texttt{2004jis}] by file name (\texttt{hgrme04.ttc}, \texttt{hgrge04.ttc}, \texttt{hgrsgu04.ttc}, \texttt{hgrsmp04.ttf}).
8852 \end{description}
8853 %</en>
8854 %<*ja>
8855 なお,HG明朝E・HGゴシックE・HG創英角ゴシックUB・HG丸ゴシック体PROの4つについては,内部で
8856 \begin{description}
8857 \item[標準] フォント名(\texttt{HGMinchoE} など)
8858 \item[\texttt{jis90}, \texttt{90jis}指定時] ファイル名 (%
8859 \texttt{hgrme.ttc}, \texttt{hgrge.ttc}, \texttt{hgrsgu.ttc}, \texttt{hgrsmp.ttf})
8860 \item[\texttt{jis2004}, \texttt{2004jis}指定時] ファイル名 (%
8861 \texttt{hgrme04.ttc}, \texttt{hgrge04.ttc}, \texttt{hgrsgu04.ttc}, \texttt{hgrsmp04.ttf})
8862 \end{description}
8863 として指定を行っているので注意すること.
8864 %</ja>
8865
8866 %<en>\subsubsection{Define/Use Custom Presets}
8867 %<ja>\subsubsection{新たなプリセットの定義}
8868
8869 %<*ja>
8870 バージョン20170904.0以降では,自分で新たなプリセットを定義することが出来るようになった.
8871 以下に説明する2命令はプリアンブルでしか実行できない.
8872 %</ja>
8873 %<*en>
8874 From version~20170904.0, one can define new presets using \cs{ltjnewpreset},
8875 and use them by \cs{ltjapplypreset}. These two commands can only be used in the preamble.
8876 %</en>
8877 \begin{cslist}
8878  \item[\cs{ltjnewpreset}\{\meta{name}\}\{\meta{specification}\}]
8879 %<*ja>
8880   新たに\meta{name}という名称のプリセットを定義する.この名称は,
8881   すでに定義されているプリセット名や,
8882   \ref{sssec:ltjpreset-general}で定義されているオプション,さらに
8883   次の13個と重複してはならない.
8884   \begin{quote}
8885         \ttfamily
8886         mc mc-l mc-m mc-b mc-bx gt gt-u gt-d gt-m gt-b gt-bx gt-eb mg-m
8887   \end{quote}
8888
8889   \meta{specification}は,プリセット名や以下のキー達のコンマ区切りリストを指定する:
8890   \begin{description}
8891    \item[\ttfamily mc-l=\meta{font}] 明朝体細字(\cs{mcfamily}\cs{ltseries})
8892    \item[\ttfamily mc-m=\meta{font}] 明朝体中字(\cs{mcfamily}\cs{mdseries})
8893    \item[\ttfamily mc-b=\meta{font}] 明朝体太字(\cs{mcfamily}\cs{bfseries})
8894    \item[\ttfamily mc-bx=\meta{font}] \texttt{mc-b=\meta{font}}と同義.
8895    \item[\ttfamily gt-u=\meta{font}] \texttt{deluxe}オプション未指定時のゴシック体(\cs{gtfamily})・明朝体太字
8896    \item[\ttfamily gt-d=\meta{font}] \texttt{deluxe}オプション指定時のゴシック体中字(\cs{gtfamily}\cs{mdseries})
8897    \item[\ttfamily gt-m=\meta{font}] \texttt{deluxe}オプションの指定の有無に関係なく
8898     ゴシック体中字(\cs{gtfamily}\cs{mdseries})を指定する.「\texttt{gt-u=\meta{font}, gt-d\meta{font}}」と同義.
8899    \item[\ttfamily gt-b=\meta{font}] ゴシック体太字(\cs{gtfamily}\cs{bfseries})\\
8900     なお,パッケージ読み込み時に\texttt{bold}オプションが指定された場合は,\texttt{mc-b=\meta{font}}を指定したことにもなる.
8901    \item[\ttfamily gt-bx=\meta{font}] \texttt{gt-b=\meta{font}}と同義.
8902    \item[\ttfamily gt-eb=\meta{font}] ゴシック体太字(\cs{gtfamily}\cs{ebseries})
8903    \item[\ttfamily mg-m=\meta{font}] 丸ゴシック体(\cs{mgfamily})
8904    \item[\ttfamily mc=\meta{font}] 明朝体の細字・中字・太字全部を設定.
8905         以下を指定したことと同じである:
8906         \begin{quote}
8907           \ttfamily mc-l=\meta{font}, mc-m=\meta{font}, mc-b=\meta{font}
8908         \end{quote}
8909    \item[\ttfamily gt=\meta{font}] ゴシック体の中字・太字・極太全部を設定.
8910         以下を指定したことと同じである:
8911         \begin{quote}
8912           \ttfamily gt-u=\meta{font}, gt-d=\meta{font}, gt-b=\meta{font}, gt-eb=\meta{font}
8913         \end{quote}
8914   \end{description}
8915 %</ja>
8916 %<*en>
8917   Define new preset~\meta{name}. This <name> cannot be same as other presets,
8918   options described in Subsubsection~\ref{sssec:ltjpreset-general}, nor
8919   following 13~strings:
8920   \begin{quote}
8921         \ttfamily
8922         mc mc-l mc-m mc-b mc-bx gt gt-u gt-d gt-m gt-b gt-bx gt-eb mg-m
8923   \end{quote}
8924
8925   \meta{specification} is a comma-separated list which consists of
8926   other presets and/or the following keys:
8927   \begin{description}
8928    \item[\ttfamily mc-l=\meta{font}] mincho light
8929    \item[\ttfamily mc-m=\meta{font}] mincho medium
8930    \item[\ttfamily mc-b=\meta{font}] mincho bold
8931    \item[\ttfamily mc-bx=\meta{font}] synonym for \texttt{mc-b=\meta{font}}
8932    \item[\ttfamily gt-u=\meta{font}] gothic, when \texttt{deluxe}~option is not specified.
8933    \item[\ttfamily gt-d=\meta{font}] gothic medium, when \texttt{deluxe}~option is specified.
8934    \item[\ttfamily gt-m=\meta{font}] gothic medium. This key is equivalent to ``\texttt{gt-u=\meta{font}, gt-d\meta{font}}''.
8935    \item[\ttfamily gt-b=\meta{font}] gothic bold\\
8936     Note that this key also specifies mincho bold if \texttt{bold} option is specified.
8937    \item[\ttfamily gt-bx=\meta{font}] synonym for \texttt{gt-b=\meta{font}}
8938    \item[\ttfamily gt-eb=\meta{font}] gothic extra~bold
8939    \item[\ttfamily mg-m=\meta{font}] rounded gothic
8940    \item[\ttfamily mc=\meta{font}] Equivalent to
8941         \begin{quote}
8942           \ttfamily mc-l=\meta{font}, mc-m=\meta{font}, mc-b=\meta{font}
8943         \end{quote}
8944    \item[\ttfamily gt=\meta{font}] Equivalent to
8945         \begin{quote}
8946           \ttfamily gt-u=\meta{font}, gt-d=\meta{font}, gt-b=\meta{font}, gt-eb=\meta{font}
8947         \end{quote}
8948   \end{description}
8949 %</en>
8950  \item[\cs{ltjnewpreset}*\{\meta{name}\}\{\meta{specification}\}]
8951 %<*ja>
8952   \cs{ltjnewpreset}とほぼ同じであるが,こちらはすでに定義されているプリセット名
8953   を\meta{name}に指定した場合にはエラーを出さずに定義を置き換える.
8954 %</ja>
8955 %<*en>
8956   Almost same as \cs{ltjnewpreset}. However, if \meta{name} matches a preset which already defined,
8957   this command simply overwrite it.
8958 %</en>
8959  \item[\cs{ltjapplypreset}\{\meta{name}\}]
8960 %<ja> \meta{name}で指定されたプリセットを使って和文フォントを設定する.
8961 %<en> Set Japanese font families using preset~\meta{name}.
8962 \end{cslist}
8963
8964 %<*ja>
8965 なお,\cs{ltjnewpreset}の第二引数\meta{specification}に含まれる
8966 プリセット名は\cs{ltjnewpreset}の時点で定義されている必要はなく,
8967 \cs{ltjapplypreset}で実際に使うときに定義されていれば良い.
8968 そのため,次のような記述も可能である:
8969 \begin{lstlisting}
8970   \ltjnewpreset{hoge}{piyo,mc-b=HiraMinProN-W6}
8971   \ltjnewpreset{piyo}{mg-m=HiraMaruProN-W4}
8972   \ltjapplypreset{hoge}
8973 \end{lstlisting}
8974
8975 \paragraph{注意}
8976 \cs{ltjnewpreset}で定義したプリセットには以下の制限がある.
8977 \begin{itemize}
8978   \item 非埋め込みのフォントを指定することはできない.
8979   \item \texttt{ipa-hg}などのいくつかのプリセットでは
8980   「\texttt{90jis}, \texttt{jis2004}が指定されているか否かでフォントの指定を変える」処理が
8981   行われていたが,\cs{ltjnewpreset}で定義したプリセットではこの処理は働かない.
8982   HGフォントやモガ明朝などを使うプリセットを定義する場合には注意すること.
8983 \end{itemize}
8984 %</ja>
8985 %<*en>
8986 Note that \cs{ltjnewpreset} does not ``expand'' the definition to define a preset.
8987 This means that one can write as the following:
8988 \begin{lstlisting}
8989   \ltjnewpreset{hoge}{piyo,mc-b=HiraMinProN-W6}
8990   \ltjnewpreset{piyo}{mg-m=HiraMaruProN-W4}
8991   \ltjapplypreset{hoge}
8992 \end{lstlisting}
8993
8994 \paragraph{Restrictions}
8995 Presets which are defined by \cs{ltjnewpreset} have following restrictions:
8996 \begin{itemize}
8997   \item One cannot specify non-embedded fonts (such as Ryumin-Light).
8998   \item Some presets, such as \texttt{ipa-hg}, have a feature that
8999   fonts are changed according to whether \texttt{90jis}~or~\texttt{jis2004} is speified.
9000   This feature is not usable in presets which are defined by \cs{ltjnewpreset}.
9001 \end{itemize}
9002 %</en>
9003
9004
9005 \clearpage
9006 %<en>\part{Implementations}
9007 %<ja>\part{実装}
9008 \label{part-imp}
9009 %<en>\section{Storing Parameters}
9010 %<ja>\section{パラメータの保持}
9011 \label{sec-para}
9012 %<en>\subsection{Used dimensions, attributes and whatsit nodes}
9013 %<ja>\subsection{\LuaTeX-jaで用いられるレジスタとwhatsitノード}
9014
9015 %<*en>
9016 Here the following is the list of dimensions and attributes which are used in \LuaTeX-ja.
9017 %</en>
9018 %<*ja>
9019 以下は\LuaTeX-jaで用いられる寸法レジスタ(dimension),属性レジスタ(attribute)の
9020 リストである.
9021 %</ja>
9022 \begin{list}{}{%
9023 \def\makelabel{\ttfamily}\advance\leftmargin1\zw
9024 \def\dim#1{\item[\textbackslash #1\ \textrm{(dimension)}]}
9025 \def\cnt#1{\item[\textbackslash #1\ \textrm{(counter)}]}
9026 \def\attr#1{\item[\textbackslash #1\ \textrm{(attribute)}]}
9027 }
9028
9029 \dim{jQ}
9030 %<*en>
9031 \cs{jQ} is equal to
9032                         $1\,\textrm{Q}=0.25\,\textrm{mm}$, where ``Q''~(also called ``級'') is
9033                         a unit used in Japanese phototypesetting.
9034 So one should not change the value of this dimension.
9035 %</en>
9036 %<*ja>
9037 \cs{jQ} は写植で用いられた$1\,\textrm{Q}=0.25\,\textrm{mm}$%
9038 (「級」とも書かれる)に等しい.したがって,
9039 この寸法レジスタの値を変更してはならない.
9040 %</ja>
9041
9042 \dim{jH}
9043 %<*en>
9044 There is also a unit called ``歯'' which equals to $0.25\,\textrm{mm}$ and
9045                          used in Japanese phototypesetting.
9046 This \cs{jH} is the same \cs{dimen} register as \cs{jQ}.
9047 %</en>
9048 %<*ja>
9049 同じく写植で用いられていた単位として「歯」があり,これも$0.25\,\textrm{mm}$と
9050 等しい.この \cs{jH} は \cs{jQ} と同じ寸法レジスタを指す.
9051 %</ja>
9052
9053 \dim{ltj@dimen@zw}
9054 %<*en>
9055 A temporal register for the ``full-width'' of current Japanese font.
9056 The command \cs{zw} sets this register to the correct value, and
9057 ``return'' this register itself.
9058 %</en>
9059 %<*ja>
9060 現在の和文フォントの「全角幅」を保持する一時レジスタ.
9061 \cs{zw} 命令は,このレジスタを適切な値に設定した後,
9062 「このレジスタ自体を返す」.
9063 %</ja>
9064
9065 \dim{ltj@dimen@zh}
9066 %<*en>
9067 A temporal register for the ``full-height'' (usually the sum of height of imaginary body and its depth) of current Japanese font.
9068 The command \cs{zh} sets this register to the correct value, and
9069 ``return'' this register itself.
9070 %</en>
9071 %<*ja>
9072 現在の和文フォントの「全角高さ」(通常,高さと深さの和)を保持する一時レジスタ.
9073 \cs{zh} 命令は,このレジスタを適切な値に設定した後,
9074 「このレジスタ自体を返す」.
9075 %</ja>
9076
9077 \attr{jfam}
9078 %<*en>
9079 Current number of Japanese font family for math formulas.
9080 %</en>
9081 %<*ja>
9082 数式用の和文フォントファミリの現在の番号.
9083 %</ja>
9084
9085 \attr{ltj@curjfnt}
9086 %<*en>
9087 If this attribute is a positive number, it stores the font number of current Japanese font for horizontal direction.
9088 If this attribute is negative, it means that the Japanese font for horizontal direction is
9089 not loaded---\LuaTeX-ja only knows its size and JFM.
9090 %</en>
9091 %<*ja>
9092 基本的には現在の横組用和文フォントのフォント番号を格納しているが,
9093 \LaTeX 下で使用する場合は($-2$以下の)負数となることがある.
9094   負数の場合は「横組用和文フォントは実際には読み込まれておらず,そのフォントサイズとJFMだけが
9095   \LuaTeX-jaが把握している」状態を表す.
9096 %</ja>
9097
9098 \attr{ltj@curtfnt}
9099 %<*en>
9100 Similar to \cs{ltj@curjfnt}, but with current Japanese font for vertical direction.
9101 %</en>
9102 %<*ja>
9103 縦組用和文フォントに関する\cs{ltj@curjfnt}と同様の値.
9104 %</ja>
9105
9106 \attr{ltj@charclass}
9107 %<*en>
9108 The character class of a \textbf{JAchar}. This attribute is only set on a
9109                          \textit{glyph\_node} which contains a \textbf{JAchar}.
9110 %</en>
9111 %<*ja>
9112 \textbf{JAchar}の文字クラス.\textbf{JAchar}が格納された\textit{glyph\_node}でのみ使われる.
9113 %</ja>
9114
9115 \attr{ltj@yablshift}
9116 %<*en>
9117 The amount of shifting the baseline of alphabetic fonts in scaled point ($2^{-16}\,\textrm{pt}$).
9118 ``unset'' means zero.
9119 %</en>
9120 %<*ja>
9121 スケールド・ポイント($2^{-16}\,\textrm{pt}$)を単位とした欧文フォントのベースラインの移動量.
9122 この属性が「未設定」(\texttt{-"7FFFFFFF})のときは0であるとみなされる.\cs{ltj@ykblshift}他も同様.
9123 %</ja>
9124
9125 \attr{ltj@ykblshift}
9126 %<*en>
9127 The amount of shifting the baseline of Japanese fonts in scaled point ($2^{-16}\,\textrm{pt}$).
9128 %</en>
9129 %<*ja>
9130 スケールド・ポイント($2^{-16}\,\textrm{pt}$)を単位とした和文フォントのベースラインの移動量.
9131 %</ja>
9132
9133 \attr{ltj@tablshift}
9134 \attr{ltj@tkblshift}
9135
9136 \attr{ltj@autospc}
9137 %<*en>
9138 Whether the auto insertion of \Param{kanjiskip} is allowed at the node.
9139 0 means ``not allowed'', and the other value (including ``unset'') means ``allowed''.
9140 %</en>
9141 %<*ja>
9142 そのノードで\Param{kanjiskip}の自動挿入が許されるかどうか.
9143 0は「許可しない」,0以外の値(「未設定」も含む)は「許可する」.
9144 %</ja>
9145
9146 \attr{ltj@autoxspc}
9147 %<*en>
9148 Whether the auto insertion of \Param{xkanjiskip} is allowed at the node.
9149 0 means ``not allowed'', and the other value (including ``unset'') means ``allowed''.
9150 %</en>
9151 %<*ja>
9152 そのノードで\Param{xkanjiskip}の自動挿入が許されるかどうか.
9153 0は「許可しない」,0以外の値(「未設定」も含む)は「許可する」.
9154 %</ja>
9155
9156 \attr{ltj@icflag}
9157 %<*en>
9158 An attribute for distinguishing ``kinds'' of a node. One of the following value is
9159 assigned to this attribute:
9160 %</en>
9161 %<*ja>
9162 ノードの「種類」を区別するための属性.以下のうちのひとつが値として割り当てられる:
9163 %</ja>
9164 \begin{description}
9165 \item[\textit{italic} (1)]
9166 %<*en>
9167 Kerns from italic correction (\verb+\/+), or from kerning information of a Japanese font.
9168 These kerns are ``ignored'' in the insertion process of \textbf{JAglue},
9169 unlike explicit \cs{kern}.
9170 %</en>
9171 %<*ja>
9172 イタリック補正(\verb+\/+)によるカーン,
9173 または \Pkg{luaotfload} によって挿入されたフォントのカーニング情報由来のカーン.
9174 これらのカーンは通常の \cs{kern} とは異なり,
9175 \textbf{JAglue}の挿入処理においては透過する.
9176 %</ja>
9177
9178 \item[\textit{packed} (2)]
9179
9180 \item[\textit{kinsoku} (3)]
9181 %<*en>
9182 Penalties inserted for the word-wrapping process (\emph{kinsoku shori}) of Japanese characters.
9183 %</en>
9184 %<ja>禁則処理のために挿入されたペナルティ.
9185 \item[\mathversion{bold}$\textit{from\_jfm}$--$(\textit{from\_jfm}+63)$~(4--67)]
9186 %<en>Glues/kerns from JFM.
9187 %<ja>JFM由来のグルー/カーン.
9188 \item[\textit{kanji\_skip}~(68), \textit{kanji\_skip\_jfm}~(69)]
9189 %<en>Glues from \Param{kanjiskip}.
9190 %<ja>和文間空白\Param{kanjiskip}を表すグルー.
9191 \item[\textit{xkanji\_skip}~(70), \textit{xkanji\_skip\_jfm}~(71)]
9192 %<en>Glues from \Param{xkanjiskip}.
9193 %<ja>和欧文間空白\Param{xkanjiskip}を表すグルー.
9194 \item[\textit{processed} (73)]
9195 %<en>Nodes which is already processed by \ldots.
9196 %<ja>\LuaTeX-ja の内部処理によって既に処理されたノード.
9197 \item[\textit{ic\_processed} (74)]
9198 %<*en>
9199 Glues from an italic correction, but already processed in the insertion process of \textbf{JAglue}s.
9200 %</en>
9201 %<ja>イタリック補正に由来するグルーであって,既に \textbf{JAglue} 挿入処理にかかったもの.
9202 \item[\textit{boxbdd} (75)]
9203 %<en>Glues/kerns that inserted just the beginning or the ending of an hbox or a paragraph.
9204 %<ja>hboxか段落の最初か最後に挿入されたグルー/カーン.
9205 \item[\textit{special\_jaglue} (76)]
9206 %<en>Glues from \cs{insert}[\texttt{x}]\texttt{kanjiskip}.
9207 %<ja>\cs{insert}[\texttt{x}]\texttt{kanjiskip}由来のグルー.
9208 \end{description}
9209
9210 %<*ja>
9211 また,挿入処理の結果であるリストの最初のノードでは,\verb+\ltj@icflag+ の値に
9212 \textit{processed\_begin\_flag}~(4096)が追加される.これによって,\cs{unhbox} が
9213 連続した場合でも「ボックスの境界」が識別できるようになっている.
9214 %</ja>
9215
9216 \attr{ltj@kcat\,$i$}
9217 %<*en>
9218 Where $i$~is a natural number which is less than~7.
9219 These 7~attributes store bit~vectors indicating which character block is regarded as a block of \textbf{JAchar}s.
9220 %</en>
9221 %<*ja>
9222 $i$は7より小さい自然数.
9223 これら7つの属性レジスタは,どの文字ブロックが\textbf{JAchar}のブロックとして
9224 扱われるかを示すビットベクトルを格納する.
9225 %</ja>
9226
9227 \attr{ltj@dir}
9228 %<*ja>
9229 \textit{direction}~whatsit(後述)において組方向を示すために,あるいは\textit{dir\_box}の
9230                          組方向を用いる.\textit{direction}~whatsitにおいては値は
9231 \begin{quote}
9232  \textit{dir\_dtou} (1), \textit{dir\_tate} (3),
9233  \textit{dir\_yoko} (4), \textit{dir\_utod} (11)
9234 \end{quote}
9235 のいずれかであり,\textit{dir\_box}ではこれらに次を加えた値をとる(\ref{sec-dir-imp}章参照).
9236 %</ja>
9237 \begin{description}
9238 \item[\textit{dir\_node\_auto} (128)]
9239 %<ja> 異なる組方向に配置するために自動的に作られたボックス.
9240 \item[\textit{dir\_node\_manual} (256)]
9241 %<ja> \cs{ltjsetwd} によって「ボックスの本来の組方向とは異なる組方向での寸法」を
9242 %<ja> 設定したときに,それを記録するためのボックス.
9243 \end{description}
9244 %<ja> \TeX 側から見える値,つまり \verb+\the\ltj@dir+ の値は常に0である.
9245
9246 \cnt{ltjlineendcomment}
9247 %<*ja>
9248   \LuaTeX-jaは\textbf{JAchar}で入力行が終了した場合,その直後にコメント文字を
9249   おくことで余計な空白が挿入されることを防いでいる.
9250   \cs{ltjlineendcomment}はその際のコメント文字のUnicodeにおける符号位置を指定する
9251   (詳細は\ref{ssec:lineend}節を参照).
9252
9253   \LuaTeX-jaにおける既定値は$\texttt{"FFFFF}=1048575$であり,
9254   ユーザは内部動作を熟知していない限りこのカウンタの値を変更してはならない.
9255   \cs{ltjlineendcomment}の値がUnicodeの範囲外(負や,$\texttt{"10FFFF}=1114111$を超えた場合)
9256   にくることは想定されていない.
9257 %</ja>
9258 \end{list}
9259
9260 %<*en>
9261 Furthermore, \LuaTeX-ja uses several user-defined whatsit nodes for
9262 internal processing. All those nodes except \emph{direction} whatsits
9263 store a natural number (hence its \texttt{type} is 100).
9264 \emph{direction} whatsits store a node list, hence its \texttt{type} is 110.
9265 Their \texttt{user\_id} (used for distinguish user-defined whatsits)
9266 are allocated by \texttt{luatexbase.newuserwhatsitid}.
9267 %</en>
9268 %<*ja>
9269 さらに,\LuaTeX-jaはいくつかのuser-defined whatsit nodeを内部処理に用いる.
9270 \textit{direction} whatsitはノードリストを格納するが,
9271 それ以外のwhatsitノードの \texttt{type} は100であり,ノードは自然数を格納している.
9272 user-defined whatsitを識別するための \texttt{user\_id} は\
9273 \texttt{luatexbase.newuserwhatsitid} により確保されており,
9274 下の見出しは単なる識別用でしかない.
9275 %</ja>
9276 \begin{description}
9277 \item[\textit{inhibitglue}]
9278 %<*en>
9279 Nodes for indicating that \cs{inhibitglue} is
9280            specified. The \texttt{value} field of these nodes doesn't matter.
9281 %</en>
9282 %<*ja>
9283 \cs{inhibitglue} が指定されたことを示すノード.これらのノードの\
9284 \texttt{value} フィールドは意味を持たない.
9285 %</ja>
9286
9287 \item[\textit{stack\_marker}]
9288 %<*en>
9289 Nodes for \LuaTeX-ja's stack system (see the next
9290            subsection). The \texttt{value} field of these nodes is
9291            current group level.
9292 %</en>
9293 %<*ja>
9294 \LuaTeX-jaのスタックシステム(次の節を参照)のためのノード.
9295 これらのノードの \texttt{value} フィールドは現在のグループネストレベルを表す.
9296 %</ja>
9297
9298 \item[\textit{char\_by\_cid}]
9299 %<*en>
9300 Nodes for \textbf{JAchar} which processes by \Pkg{luaotfload} won't be applied,
9301        and the character code is
9302            stored in the \texttt{value} field. Each node of this type are
9303            converted to a \textit{glyph\_node} \emph{after}
9304            processes by luaotfload.
9305 Nodes of this type is used in \cs{CID}~and~\cs{UTF}.
9306 %</en>
9307 %<*ja>
9308 \Pkg{luaotfload}による処理が適用されない\textbf{JAchar}のためのノードで,
9309 \texttt{value} フィールドに文字コードが格納されている.
9310 この種類のノードはそれぞれが\Pkg{luaotfload}のコールバックの処理の
9311 \emph{後で}\textit{glyph\_node}に変換される.
9312 \cs{CID}, \cs{UTF}でこの種類のノードが利用されている.
9313 %</ja>
9314
9315 \item[\textit{replace\_vs}]
9316 %<*en>
9317 Similar to \textit{char\_by\_cid} whatsits above.
9318 These nodes are for \textbf{ALchar} which the callback process of
9319            \Pkg{luaotfload} won't be applied.
9320 %</en>
9321 %<*ja>
9322 上の\textit{char\_by\_cid}と同様に,
9323 これらのノードは\Pkg{luaotfload}のコールバックによる処理が適用されない\textbf{ALchar}のた
9324            めものである.
9325 %</ja>
9326
9327 \item[\textit{begin\_par}]
9328 %<*en>
9329 Nodes for indicating beginning of a paragraph.
9330 A paragraph which is started by \cs{item} in list-like environments has a horizontal box
9331 for its label before the actual contents. So \dots
9332 %</en>
9333 %<*ja>
9334 「段落の開始」を意味するノード.
9335 \texttt{list}環境,\texttt{itemize}環境などにおいて,\cs{item} で始まる各項目は……
9336 %</ja>
9337
9338 \item[\textit{direction}]
9339
9340 \end{description}
9341
9342 %<*en>
9343 These whatsits will be removed during the process of inserting \textbf{JAglue}s.
9344 %</en>
9345 %<*ja>
9346 これらのwhatsitノードは\textbf{JAglue}の挿入処理の間に取り除かれる.
9347 %</ja>
9348
9349 %<en>\subsection{Stack system of \LuaTeX-ja}
9350 %<ja>\subsection{\LuaTeX-jaのスタックシステム}
9351 \label{ssec:stack}
9352
9353 %<en>\paragraph{Background}
9354 %<ja>\paragraph{背景}
9355 %<*en>
9356 \LuaTeX-ja has its own stack system, and most parameters of \LuaTeX-ja
9357 are stored in it. To clarify the reason, imagine the parameter
9358 \Param{kanjiskip} is stored by a skip, and consider the following
9359 source:
9360 %</en>
9361 %<*ja>
9362 \LuaTeX-jaは独自のスタックシステムを持ち,\LuaTeX-jaのほとんどのパラメータは
9363 これを用いて保持されている.その理由を明らかにするために,
9364 \Param{kanjiskip}パラメータがスキップレジスタで保持されているとし,
9365 以下のコードを考えてみよう:
9366 %</ja>
9367 \begin{LTXexample}
9368 \ltjsetparameter{kanjiskip=0pt}ふがふが.%
9369 \setbox0=\hbox{%
9370   \ltjsetparameter{kanjiskip=5pt}ほげほげ}
9371 \box0.ぴよぴよ\par
9372 \end{LTXexample}
9373
9374 %<*en>
9375 As described in Subsection~\ref{ssec:param}, the only effective value of
9376 \Param{kanjiskip} in an hbox is the latest value, so the value of
9377 \Param{kanjiskip} which applied in the entire hbox should be 5\,pt.
9378 However, by the implementation method of \LuaTeX, this ``5\,pt'' cannot be
9379 known from any callbacks.  In the \texttt{tex/packaging.w}, which is a
9380 file in the source of \LuaTeX, there are the following codes:
9381 %</en>
9382 %<*ja>
9383 \ref{ssec:param}節で述べたように,あるhboxの中で効力を持つ
9384 \Param{kanjiskip}の値は最後に現れた値のみであり,したがってボックス全体に適用される
9385 \Param{kanjiskip}は5\,ptであるべきである.しかし,\LuaTeX の実
9386 装を観察すると,この5\,ptという長さはどのコールバックからも知ることはできないことがわかる.
9387 \LuaTeX のソースファイルの1つ \texttt{tex/packaging.w} の中に,
9388 以下のコードがある:
9389 %</ja>
9390 \begin{lstlisting}[numbers=left,firstnumber=1226]
9391 void package(int c)
9392 {
9393     scaled h;                   /* height of box */
9394     halfword p;                 /* first node in a box */
9395     scaled d;                   /* max depth */
9396     int grp;
9397     grp = cur_group;
9398     d = box_max_depth;
9399     unsave();
9400     save_ptr -= 4;
9401     if (cur_list.mode_field == -hmode) {
9402         cur_box = filtered_hpack(cur_list.head_field,
9403                                  cur_list.tail_field, saved_value(1),
9404                                  saved_level(1), grp, saved_level(2));
9405         subtype(cur_box) = HLIST_SUBTYPE_HBOX;
9406 \end{lstlisting}
9407 %<*en>
9408 Notice that \texttt{unsave()} is executed \emph{before}
9409 \texttt{filtered\_hpack()}, where \texttt{hpack\_filter} callback is
9410 executed) here. So ``5\,pt'' in the above source is orphaned at
9411 \texttt{unsave()}, and hence it can't be accessed from \texttt{hpack\_filter}
9412 callback.
9413 %</en>
9414 %<*ja>
9415 \texttt{unsave()} が \texttt{filtered\_hpack()}(これは \texttt{hpack\_filter} コールバックが
9416 実行されるところである)の\emph{前に}実行されていることに注意する.
9417 したがって,上記ソース中で5\,ptは \texttt{unsave()} のところで捨てられ,
9418 \texttt{hpack\_filter} コールバックからはアクセスすることができない.
9419 %</ja>
9420
9421 %<en>\paragraph{Implementation}
9422 %<ja>\paragraph{解決法}
9423
9424 %<*en>
9425 The code of stack system is based on that in a post of Dev-luatex mailing list\footnote{%
9426 \texttt{[Dev-luatex] tex.currentgrouplevel}, a post at 2008/8/19 by Jonathan Sauer.}.
9427 %</en>
9428 %<*ja>
9429 スタックシステムのコードはDev-luatexメーリングリストのある投稿\footnote{%
9430 \texttt{[Dev-luatex] tex.currentgrouplevel}: Jonathan Sauerによる2008/8/19の投稿.}を
9431 ベースにしている.
9432 %</ja>
9433
9434 %<*en>
9435 These are two \TeX\ count registers for maintaining information:
9436 \verb+\ltj@@stack+ for the stack level, and \verb+\ltj@@group@level+ for
9437 the \TeX's group level when the last assignment was done.  Parameters
9438 are stored in one big table named \texttt{charprop\_stack\_table}, where
9439 \texttt{charprop\_stack\_table[$i$]} stores data of stack level~$i$. If
9440 a new stack level is created by \cs{ltjsetparameter}, all data of the
9441 previous level is copied.
9442 %</en>
9443 %<*ja>
9444 情報を保持するために,2つの\TeX の整数レジスタを用いている:
9445 \verb+\ltj@@stack+ にスタックレベル,\verb+\ltj@@group@level+ に最後の代入が
9446 なされた時点での\TeX のグループレベルを保持している.
9447 パラメータは\texttt{charprop\_stack\_table}という名前のひとつの大きなテーブルに
9448 格納される.ここで,\texttt{charprop\_stack\_table[$i$]}はスタックレベル$i$の
9449 データを格納している.もし新しいスタックレベルが \cs{ltjsetparameter} によって
9450 生成されたら,前のレベルの全てのデータがコピーされる.
9451 %</ja>
9452
9453 %<*en>
9454 To resolve the problem mentioned in above paragraph ``Background'', \LuaTeX-ja uses
9455 another trick. When the stack level is about to be increased, a whatsit
9456 node whose type, subtype and value are 44~(\textit{user\_defined}),
9457 \textit{stack\_marker} and the current group level respectively is appended to the current
9458 list (we refer this node by \textit{stack\_flag}). This enables us to
9459 know whether assignment is done just inside a hbox. Suppose that the
9460 stack level is~$s$ and the \TeX's group level is~$t$ just after the hbox
9461 group, then:
9462 %</en>
9463 %<*ja>
9464 上の「背景」で述べた問題を解決するために,\LuaTeX-jaでは次の手法を用いる:
9465 スタックレベルが増加するするとき,type, subtype, valueがそれぞれ
9466 44~(\textit{user\_defined}), \textit{stack\_marker},そして現在のグループレベルであるwhatsitノード
9467 を現在のリストに付け加える(このノードを\textit{stack\_flag}とする).
9468 これにより,あるhboxの中で代入がなされたかどうかを知ることが可能
9469 となる.スタックレベルを$s$,そのhbox groupの直後の\TeX のグループレベルを
9470 $t$とすると:
9471 %</ja>
9472 \begin{itemize}
9473 %<*en>
9474 \item If there is no \textit{stack\_flag} node in the list of the contents of the hbox, then
9475       no assignment was occurred inside the hbox. Hence values of
9476       parameters at the end of the hbox are stored in the stack
9477       level~$s$.
9478 %</en>
9479 %<*ja>
9480 \item もしそのhboxの中身を表すリストの中に\textit{stack\_flag}ノードがなければ,
9481   hboxの中では代入は起こらなかったということになる.
9482   したがって,そのhboxの終わりにおけるパラメータの値はスタックレベル$s$に
9483   格納されている.
9484 %</ja>
9485
9486 %<*en>
9487 \item If there is a \textit{stack\_flag} node whose value is~$t+1$, then
9488       an assignment was occurred just inside the hbox group. Hence
9489       values of parameters at the end of the hbox are stored in the
9490       stack level~$s+1$.
9491 %</en>
9492 %<*ja>
9493 \item もし値が$t+1$の\textit{stack\_flag}ノードがあれば,その
9494   hboxの中で代入が起こったことになる.
9495   したがって,hboxの終わりにおけるパラメータの値はスタックレベル$s+1$に
9496   格納されている.
9497 %</ja>
9498
9499 %<*en>
9500 \item If there are \textit{stack\_flag} nodes but all of their values
9501       are more than~$t+1$, then an assignment was occurred in the box,
9502       but it is done in more internal group. Hence values of
9503       parameters at the end of the hbox are stored in the stack
9504       level~$s$.
9505 %</en>
9506 %<*ja>
9507 \item もし\textit{stack\_flag}ノードがあるがそれらの値が全て$t+1$より大きい
9508   場合,そのボックスの中で代入が起こったが,それは「より内部の」グループで
9509   起こったということになる.したがって,hboxの終わりでのパラメータの
9510   値はスタックレベル$s$に格納されている.
9511 %</ja>
9512 \end{itemize}
9513
9514 %<*en>
9515 Note that to work this trick correctly, assignments to
9516 \verb+\ltj@@stack+ and \verb+\ltj@@group@level+ have to be local always,
9517 regardless the value of \cs{globaldefs}.
9518 To solve this problem, we use another trick: the assignment
9519 \hbox{\verb+\directlua{tex.globaldefs=0}+} is always local.
9520 %</en>
9521 %<*ja>
9522 このトリックを正しく働かせるためには,\verb+\ltj@@stack+ と \verb+\ltj@@group@level+ への
9523 代入は \cs{globaldefs} の値によらず常にローカルでなければならないことに注意する.
9524 この問題は \hbox{\verb+\directlua{tex.globaldefs=0}+}(この代入は常にローカル)を
9525 用いることで解決している.
9526 %</ja>
9527
9528 %<*en>
9529 \subsection{Lua functions of the stack system}
9530 In this subsection, we will see how a user use \LuaTeX-ja's stack system to
9531 store some data which obeys the grouping of \TeX.
9532 %</en>
9533 %<*ja>
9534 \subsection{スタックシステムで使用される関数}
9535 本節では,ユーザが\LuaTeX-jaのスタックシステムを使用して,
9536 \TeX のグルーピングに従うような
9537 独自のデータを取り扱う方法を述べる.
9538 %</ja>
9539
9540 %<*en>
9541 The following function can be used to store data into a stack:
9542 \begin{lstlisting}
9543 luatexja.stack.set_stack_table(index, <any> data)
9544 \end{lstlisting}
9545 Any values which except \texttt{nil}~and~NaN are usable as \textit{index}.
9546 However, a user should use only negative integers or strings as \textit{index},
9547 since natural numbers are used by \LuaTeX-ja itself.
9548 Also, whether \textit{data} is stored locally or globally
9549 is determined by \texttt{luatexja.isglobal}
9550 (stored globally if and only if \texttt{luatexja.isglobal == 'global'}).
9551 %</en>
9552 %<*ja>
9553 スタックに値を設定するには,以下のLua関数を呼び出せば良い:
9554 \begin{lstlisting}
9555 luatexja.stack.set_stack_table(<any> index, <any> data)
9556 \end{lstlisting}
9557 直感的には,スタックテーブル中のインデックス\textit{index}の値を\textit{data}にする,という意味である.
9558 \textit{index}の値としては \texttt{nil} とNaN以外の任意の値を使えるが,
9559 自然数は\LuaTeX-jaが使用する(将来の拡張用も含む)ので,
9560 ユーザが使用する場合は負の整数値か文字列の値にすることが望ましい.
9561 また,ローカルに設定されるかグローバルに設定されるかは,\texttt{luatexja.isglobal} の値に依存する
9562 (グローバルに設定されるのは,\texttt{luatexja.isglobal == 'global'} であるちょうどその時).
9563 %</ja>
9564
9565 %<*en>
9566 Stored data can be obtained as the return value of
9567 \begin{lstlisting}
9568 luatexja.stack.get_stack_table(index, <any> default, <number> level)
9569 \end{lstlisting}
9570 where \textit{level} is the stack level, which is usually the value of \verb+\ltj@@stack+,
9571 and \textit{default} is the default value which will be returned if no values are stored
9572 in the stack table whose level is \textit{level}.
9573 %</en>
9574 %<*ja>
9575 スタックの値は,
9576 \begin{lstlisting}
9577 luatexja.stack.get_stack_table(<any> index, <any> default, <number> level)
9578 \end{lstlisting}
9579 の戻り値で取得できる.\textit{level}はスタックレベルであり,
9580 通常は \verb+\ltj@@stack+ の値を指定することになるだろう.
9581 \textit{default}はレベル\textit{level}のスタックに値が設定されていなかった場合に
9582 返すデフォルト値である.
9583 %</ja>
9584
9585 \begin{figure}[tb]
9586 \begin{lstlisting}[numbers=left, firstnumber=380]
9587 \protected\def\ltj@setpar@global{%
9588   \relax\ifnum\globaldefs>0\directlua{luatexja.isglobal='global'}%
9589     \else\directlua{luatexja.isglobal=''}\fi
9590 }
9591 \protected\def\ltjsetparameter#1{%
9592   \ltj@setpar@global\setkeys[ltj]{japaram}{#1}\ignorespaces}
9593 \protected\def\ltjglobalsetparameter#1{%
9594   \relax\ifnum\globaldefs<0\directlua{luatexja.isglobal=''}%
9595     \else\directlua{luatexja.isglobal='global'}\fi%
9596   \setkeys[ltj]{japaram}{#1}\ignorespaces}
9597 \end{lstlisting}
9598 %<ja>\caption{パラメータ設定命令の定義}
9599 %<en>\caption{Definiton of parameter setting commands}
9600 \label{fig:setpar-def}
9601 \end{figure}
9602
9603 %<*en>
9604 \subsection{Extending Parameters}
9605 Keys for \cs{ltjsetparameter}~and~\cs{ltjgetparameter} can be extended,
9606 as in \Pkg{luatexja-adjust}.
9607 %</en>
9608 %<*ja>
9609 \subsection{パラメータの拡張}
9610 ここでは,\Pkg{luatexja-adjust}で行なっているように,
9611 \cs{ltjsetparameter},~\cs{ltjgetparameter}に指定可能なキーを追加する方法
9612 を述べる.
9613 %</ja>
9614
9615 %<*en>
9616 \paragraph{Setting parameters}
9617 \autoref{fig:setpar-def} shows the \emph{most outer} definition of
9618 two commands,
9619 \cs{ltjsetparameter} and \cs{ltjglobalsetparameter}.
9620 Most important part is the last \cs{setkeys},
9621 which is offered by the \Pkg{xkeyval} package.
9622
9623 Hence, to add a key in \cs{ltjsetparameter}, one only have to add a key
9624 whose prefix is \texttt{ltj} and whose family is \texttt{japaram}, as the following.
9625 \begin{lstlisting}
9626 \define@key[ltj]{japaram}{...}{...}
9627 \end{lstlisting}
9628
9629 \cs{ltjsetparameter}~and~\cs{ltjglobalsetparameter} automatically sets
9630 \texttt{luatexja.isglobal}. Its meaning is the following.
9631 \begin{align}
9632  \texttt{luatexja.isglobal} =
9633 \begin{cases*}
9634  \texttt{'global'}&(global assignment),\\
9635  \texttt{''}&(local assignment).
9636 \end{cases*}
9637 \end{align}
9638 This is determined not only by command name
9639 (\cs{ltjsetparameter}~or~\cs{ltjglobalsetparameter}),
9640 but also by the value of \cs{globaldefs}.
9641 %</en>
9642 %<*ja>
9643 \paragraph{パラメータの設定}
9644 \cs{ltjsetparameter}と,\cs{ltjglobalsetparameter}の定義は\autoref{fig:setpar-def}の
9645 のようになっている.
9646 本質的なのは最後の\cs{setkeys}で,これは\Pkg{xkeyval}パッケージの提供する命令である.
9647
9648 このため,\cs{ltjsetparameter}に指定可能なパラメータを追加するには,
9649 \meta{prefix}を\texttt{ltj},\meta{family}を\texttt{japaram}としたキーを
9650 \begin{lstlisting}
9651 \define@key[ltj]{japaram}{...}{...}
9652 \end{lstlisting}
9653 のように定義すれば良いだけである.
9654 なお,パラメータ指定がグローバルかローカルかどうかを示す\texttt{luatexja.isglobal}が,
9655 \begin{align}
9656  \texttt{luatexja.isglobal} =
9657 \begin{cases*}
9658  \texttt{'global'}&(パラメータ設定はグローバル),\\
9659  \texttt{''}&(パラメータ設定はローカル).
9660 \end{cases*}
9661 \end{align}
9662 として自動的にセットされる\footnote{命令が\cs{ltjglobalsetparameter}かどうかだけでは
9663 なく,実行時の\cs{globaldefs}の値にも依存して定まる.}.
9664 %</ja>
9665
9666 %<*en>
9667 \paragraph{Getting parameters}
9668 \cs{ltjgetparameter} is implemented by a Lua script.
9669
9670 For parameters that do not need additional arguments, one only have to
9671 define a function in the table \verb+luatexja.unary_pars+.
9672 For example, with the following function,
9673 \verb+\ltjgetparameter{hoge}+ returns a \emph{string} \texttt{42}.
9674 \begin{lstlisting}[numbers=left]
9675 function luatexja.unary_pars.hoge (t)
9676   return 42
9677 end
9678 \end{lstlisting}
9679 Here the argument of \verb+luatexja.unary_pars.hoge+ is
9680 the stack level of \LuaTeX-ja's stack system (see Subsection~\ref{ssec:stack}).
9681
9682 On the other hand, for parameters that need an additional argument
9683 (this must be an integer), one have to define a function in
9684 \verb+luatexja.binary_pars+ first. For example,
9685 \begin{lstlisting}[numbers=left]
9686 function luatexja.binary_pars.fuga (c, t)
9687   return tostring(c) .. ', ' .. tostring(42)
9688 end
9689 \end{lstlisting}
9690 Here the first argument $t$ is the stack level, as before.
9691 The second argument $c$ is just the second argument of \cs{ltjgetparameter}.
9692
9693 For parameters that need an additional argument, one also have to
9694 execute the \TeX\ code like
9695 \begin{lstlisting}
9696 \ltj@@decl@array@param{fuga}
9697 \end{lstlisting}
9698 to indicate that ``the parameter \texttt{fuga} needs an additional argument''.
9699 %</en>
9700 %<*ja>
9701 \paragraph{パラメータの取得}
9702 一方,\cs{ltjgetparameter} はLuaスクリプトによって実装されている.
9703 値を取得するのに追加引数の要らないパラメータについては,\verb+luatexja.unary_pars+\
9704 内に処理内容を記述した関数を定義すれば良い.例えば,Luaスクリプトで
9705 \begin{lstlisting}[numbers=left]
9706 function luatexja.unary_pars.hoge (t)
9707   return 42
9708 end
9709 \end{lstlisting}
9710 を実行すると,\verb+\ltjgetparameter{hoge}+ は \texttt{42} という\emph{文字列}を返す.
9711 関数 \verb+luatexja.unary_pars.hoge+ の引数$t$は,\ref{ssec:stack}節で述べた
9712 \LuaTeX-jaのスタックシステムにおけるスタックレベルである.
9713 戻り値はいかなる値であっても,最終的には文字列として出力されることに注意.
9714
9715 一方,追加引数(\emph{数値しか許容しない})が必要なパラメータについては,
9716 まずLuaスクリプトで処理内容の本体を記述しておく:
9717 \begin{lstlisting}[numbers=left]
9718 function luatexja.binary_pars.fuga (c, t)
9719   return tostring(c) .. ', ' .. tostring(42)
9720 end
9721 \end{lstlisting}
9722 引数$t$は,先に述べた通りのスタックレベルである.一方,引数$c$は\
9723 \cs{ltjgetparameter} の第2引数を表す数値である.
9724 しかしこれだけでは駄目で,
9725 \begin{lstlisting}
9726 \ltj@@decl@array@param{fuga}
9727 \end{lstlisting}
9728 を実行し,\TeX インターフェース側に
9729 「\verb+\ltjgetparameter{fuga}+ は追加引数が必要」ということを通知する必要がある.
9730 %</ja>
9731
9732 %<en>\section{Linebreak after a Japanese Character}
9733 %<ja>\section{和文文字直後の改行}
9734 \label{sec-lbreak}
9735 %<en>\subsection{Reference: behavior in \pTeX}
9736 %<ja>\subsection{参考:\pTeX の動作}
9737 %<*en>
9738 In~\pTeX, a line break after a Japanese character doesn't emit a space,
9739 since words are not separated by spaces in Japanese writings. However,
9740 this feature isn't fully implemented in \LuaTeX-ja due to the
9741 specification of callbacks in~\LuaTeX. To clarify the difference between
9742 \pTeX~and~\LuaTeX, We briefly describe the handling of a line break in~\pTeX, in
9743 this subsection.
9744
9745 \pTeX's input processor can be described in terms of a finite state
9746 automaton, as that of~\TeX\ in~Section~2.5 of~\cite{texbytopic}. The
9747 internal states are as follows:
9748 \begin{itemize}
9749 \item State~$N$: new line
9750 \item State~$S$: skipping spaces
9751 \item State~$M$: middle of line
9752 \item State~$K$: after a Japanese character
9753 \end{itemize}
9754 The first three states---$N$,~$S$, and~$M$---are as same as \TeX's input
9755 processor.  State~$K$ is similar to state~$M$, and is entered after
9756 Japanese characters.  The diagram of state transitions are indicated in
9757 \autoref{fig:ptexipro}.  Note that \pTeX\ doesn't leave state~$K$
9758 after ``beginning/ending of a group'' characters.
9759 %</en>
9760
9761 %<*ja>
9762 欧文では文章の改行は単語間でしか行わない.そのため,\TeX では,(文字の直後の)改行は
9763 空白文字と同じ扱いとして扱われる.一方,和文ではほとんどどこでも改行が可能なため,
9764 \pTeX では和文文字の直後の改行は単純に無視されるようになっている.
9765
9766 このような動作は,\pTeX が\TeX からエンジンとして拡張されたことによって可能になったことである.
9767 \pTeX の入力処理部は,\TeX におけるそれと同じように,有限オートマトンとして記述することができ,
9768 以下に述べるような4状態を持っている.
9769
9770 \begin{itemize}
9771 \item State~$N$: 行の開始.
9772 \item State~$S$: 空白読み飛ばし.
9773 \item State~$M$: 行中.
9774 \item State~$K$: 行中(和文文字の後).
9775 \end{itemize}
9776 また,状態遷移は,\autoref{fig:ptexipro}のようになっており,図中の数字は
9777 カテゴリーコードを表している.最初の3状態は\TeX の入力処理部と同じであり,
9778 図中から状態$K$と「$j$」と書かれた矢印を取り除けば,\TeX の入力処理部と同
9779 じものになる.
9780
9781 この図から分かることは,
9782 \begin{quote}
9783 行が和文文字(とグループ境界文字)で終わっていれば,改行は無視される
9784 \end{quote}
9785 ということである.
9786 %</ja>
9787
9788 \begin{figure}[!tb]
9789 \let\sp\textvisiblespace\small
9790 \begin{minipage}{.6\textwidth}%
9791 \begin{center}
9792 \unitlength=6.5mm\sf\mathversion{bold}
9793 \begin{tikzpicture}[
9794   ->, auto, shorten >=1pt
9795 ]
9796 \node [shape=rectangle, font=\scriptsize] (init) at (2,7) {start};
9797 \node [shape=circle,draw, fill=b_cyan] (newline) at (4,7) {$N$};
9798 \node [shape=circle,draw, fill=b_cyan] (midline) at (4,4) {$M$};
9799 \node [shape=circle,draw, fill=b_cyan] (skipspc) at (8,7) {$S$};
9800 \node [shape=circle,draw, fill=b_pink]  (kanji) at (8,4) {$K$};
9801 \node [shape=rectangle,draw, fill=b_green] (scanacs) at (6,8) {scan a c.s.};
9802 \node (endk) at (8,2.5) {} ;
9803 \node (endm) at (4,2.5) {} ;
9804 \node (ends) at (8,8.5) {} ;
9805 \node (endn) at (4,8.5) {} ;
9806 \begin{scope}[font=\scriptsize]
9807 \path (newline) edge [bend right]    node [left]{G, O} (midline)
9808       (init)    edge                 node {} (newline)
9809       (midline) edge [bend right=10] node {10} (skipspc)
9810       (skipspc) edge [bend right]    node [left,right=10,above=7]{G, O} (midline)
9811       (skipspc) edge [loop right]    node {10} (skipspc)
9812       (newline) edge [loop right]    node {10} (newline)
9813       (scanacs) edge [bend left]     node [left=3,below]{$(*)$} (skipspc)
9814       (scanacs) edge [bend right]    node [right=30,above=20]{$(*)$} (midline)
9815       (midline) edge                 node {5\ [\sp]} (endm)
9816       (midline) edge [loop left]     node {G, O} (midline)
9817       (skipspc) edge                 node [right] {5} (ends)
9818       (newline) edge                 node {5 [\cs{par}]} (endn);
9819 \begin{scope}[red]
9820 \path (newline) edge [bend right]    node [right=25,below=3]{J} (kanji)
9821       (midline) edge                 node [below]{J} (kanji)
9822       (kanji)   edge [bend left]     node {O} (midline)
9823       (kanji)   edge                 node {10} (skipspc)
9824       (kanji)   edge [loop right]    node {G, J} (kanji)
9825       (skipspc) edge [bend left]     node {J} (kanji)
9826       (kanji)   edge                 node {5} (endk)
9827 ;
9828 \end{scope}
9829 \end{scope}
9830 \end{tikzpicture}
9831 \end{center}
9832 \end{minipage}%
9833 \begin{minipage}{.4\textwidth}
9834 \begin{description}
9835 \item[\textsf{G}] Beginning of group (usually \verb+{+)\\
9836  and ending of group (usually \verb+}+).
9837 \item[\textsf{J}] Japanese characters.
9838 \item[\textsf{5}] \textit{end-of-line} (usually \verb+^+\verb+^J+).
9839 \item[\textsf{10}] space (usually \sp).
9840 \item[\textsf{O}] other characters, whose category code is in $\{3,4,6,7,8,11,12,13\}$.
9841 \item[\textsf{[\sp]}, \textsf{[\cs{par}]}]
9842 emits a space, or~\cs{par}.
9843 \end{description}
9844 \end{minipage}
9845 \begin{itemize}
9846 \item We omitted about category codes
9847 9~(\textit{ignored}), 14~(\textit{comment}), and~15~(\textit{invalid})
9848 from the above diagram. We also ignored the input like ``\verb+^+\verb+^A+'' or ``\verb+^+\verb+^df+''.
9849 \item When a character whose category code is 0 (\textit{escape character}) is seen by \TeX,
9850 the input processor scans a control sequence (\textsf{scan a c.s.}).
9851 These paths are not shown in the above diagram.
9852
9853 After that, the state is changed to State~$S$ (skipping blanks) in most cases, but
9854 to State~$M$ (middle of line) sometimes.
9855 \end{itemize}
9856 %<en>\caption{State transitions of \pTeX's input processor}
9857 %<ja>\caption{\pTeX の入力処理部の状態遷移}
9858 \label{fig:ptexipro}
9859 \end{figure}
9860
9861
9862 %<en>\subsection{Behavior in \LuaTeX-ja}
9863 %<ja>\subsection{\LuaTeX-jaの動作}
9864   \label{ssec:lineend}
9865 %<*en>
9866 States in the input processor of \LuaTeX\ is the same as that of \TeX,
9867 and they can't be customized by any callbacks. Hence, we can only use
9868 \verb+process_input_buffer+ and \verb+token_filter+ callbacks for to
9869 suppress a space by a line break which is after Japanese characters.
9870
9871 However, \verb+token_filter+ callback cannot be used either, since a
9872 character in category code 5~(\textit{end-of-line}) is converted into an space
9873 token \emph{in the input processor}.  So we can use only the
9874 \verb+process_input_buffer+ callback.  This means that suppressing a
9875 space must be done \emph{just before} an input line is read.
9876
9877 Considering these situations, handling of an end-of-line in \LuaTeX-ja are as follows:
9878 \begin{quote}
9879 A character whose character code is \cs{ltjlineendcomment}%
9880 \footnote{Its default value is \texttt{"FFFFF}, so  \texttt{U+FFFFF} is used.
9881 The category code of \texttt{U+FFFFF} is set to 14~(\textit{comment}) by
9882 \LuaTeX-ja.} is appended to an input line, \emph{before \LuaTeX\ actually
9883 process it}, if and only if the following three conditions are satisfied:
9884 \begin{enumerate}
9885 \item The category code of \cs{endlinechar}%
9886 \footnote{Usually, it is $\langle$\textit{return}$\rangle$
9887       (whose character code is 13).} is 5~(\textit{end-of-line}).
9888 \item The category code of \cs{ltjlineendcomment} itself is 14~(\textit{comment}).
9889 \item The input line matches the following ``regular expression'':
9890 \[
9891   (\text{any char})^*(\textbf{JAchar})
9892   \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
9893 \]
9894 \end{enumerate}
9895 \end{quote}
9896
9897 \paragraph{Remark}
9898 The following example shows the major difference from the behavior of \pTeX.
9899 \begin{LTXexample}
9900 \fontspec[Ligatures=TeX]{Linux Libertine O}
9901 \ltjsetparameter{autoxspacing=false}
9902 \ltjsetparameter{jacharrange={-6}}xあ
9903 y\ltjsetparameter{jacharrange={+6}}zい
9904 u
9905 \end{LTXexample}
9906 It is not strange that ``あ'' does not printed in the above output.
9907 This is because \TeX\ Gyre\ Termes does not contain ``あ'', and because
9908 ``あ'' in line~3 is considered as an \textbf{ALchar}.
9909
9910 Note that there is no space before ``y'' in the output, but
9911 there is a space before ``u''. This follows from following reasons:
9912 \begin{itemize}
9913 \item When line~3 is processed by \texttt{process\_input\_buffer} callback,
9914 ``あ'' is considered as an \textbf{JAchar}.
9915 Since  line~3 ends with an \textbf{JAchar},
9916 the comment character (whose character code is \cs{ltjlineendcomment}) is appended to this line,
9917 and hence the linebreak immediately after this line is ignored.
9918 \item When line~4 is processed by \texttt{process\_input\_buffer} callback,
9919 ``い'' is considered as an \textbf{ALchar}.
9920 Since  line~4 ends with an \textbf{ALchar}, the linebreak immediately after this line
9921 emits a space.
9922 \end{itemize}
9923 %</en>
9924
9925 %<*ja>
9926 \LuaTeX の入力処理部は\TeX のそれと全く同じであり,コールバックによりユーザが
9927 カスタマイズすることはできない.このため,改行抑制の目的でユーザが利用で
9928 きそうなコールバックとしては,\verb+process_input_buffer+や
9929 \verb+token_filter+に限られてしまう.しかし,\TeX の入力処理部をよく見る
9930 と,後者も役には経たないことが分かる:改行文字は,入力処理部によってトー
9931 クン化される時に,カテゴリーコード10の32番文字へと置き換えられてしまうた
9932 め,\verb+token_filter+で非標準なトークン読み出しを行おうとしても,空白文
9933 字由来のトークンと,改行文字由来のトークンは区別できないのだ.
9934
9935 すると,我々のとれる道は,\verb+process_input_buffer+を用いて
9936 \LuaTeX の入力処理部に引き渡される前に入力文字列を編集するというものしかない.
9937 以上を踏まえ,\LuaTeX-jaにおける「和文文字直後の改行抑制」の処理は,次のようになっている:
9938
9939 \begin{quote}
9940 各入力行に対し,\emph{その入力行が読まれる前の内部状態で}
9941 以下の3条件が満たされている場合,\LuaTeX-jaは\cs{ltjlineendcomment}番の文字
9942 \footnote{\cs{ltjlineendcomment}の既定値は\texttt{"FFFFF}であるので,
9943   既定では\texttt{U+FFFFF}が使われることになる.この文字はコメント文字として扱われるように
9944   \LuaTeX-ja内部で設定をしている.}%
9945 を末尾に追加する.よって,その場合に改行は空白とは見做されないこととなる.
9946 \begin{enumerate}
9947 \item \cs{endlinechar}の文字\footnote{普通は,改行文字(文字コード13番)である.}
9948 のカテゴリーコードが5~(\textit{end-of-line})である.
9949 \item \cs{ltjlineendcomment}のカテゴリーコードが14~(\textit{comment})である.
9950 \item 入力行は次の「正規表現」にマッチしている:
9951 \[
9952   (\text{any char})^*(\textbf{JAchar})
9953   \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
9954 \]
9955 \end{enumerate}
9956 \end{quote}
9957
9958 この仕様は,前節で述べた\pTeX の仕様にできるだけ近づけたものとなっている.条件1.は,
9959 \texttt{lstlisting}系環境などの日本語対応マクロを書かなくてすませるためのものである.
9960
9961 しかしながら,\pTeX と完全に同じ挙動が実現できたわけではない.
9962 次のように,\textbf{JAchar}の範囲を変更したちょうどその行においては挙動が異なる:
9963 \begin{LTXexample}
9964 \fontspec[Ligatures=TeX]{TeX Gyre Termes}
9965 \ltjsetparameter{autoxspacing=false}
9966 \ltjsetparameter{jacharrange={-6}}xあ
9967 y\ltjsetparameter{jacharrange={+6}}zい
9968 u
9969 \end{LTXexample}
9970 上ソース中の「あ」は\textbf{ALchar}(欧文扱い)であり.
9971 ここで使用している欧文フォント\TeX\ Gyre Termesは「あ」を含まない.
9972 よって,出力に「あ」は現れないことは不思議ではない.
9973 それでも,\pTeX とまったく同じ挙動を示すならば,出力は
9974 「\hbox{\ltjsetparameter{autoxspacing=false}x yzいu}」となるはずである.しかし,実際には
9975 上のように異なる挙動となっているが,それは以下の理由による:
9976 \begin{itemize}
9977 \item 3行目を \texttt{process\_input\_buffer} で処理する時点では,
9978       「あ」は\textbf{JAchar}(和文扱い)である.よって3行目は\textbf{JAchar}で終わることになり,
9979       \cs{ltjlineendcomment}番のコメント文字が追加される.
9980       よって,直後の改行文字は無視されることになり,空白は入らない.
9981 \item 4行目を \texttt{process\_input\_buffer} で処理する時点では,
9982       「い」は\textbf{ALchar}である.よって4行目は\textbf{ALchar}で終わることになり,
9983       直後の改行文字は空白に置き換わる.
9984 \end{itemize}
9985 このため,トラブルを避けるために,\textbf{JAchar}の範囲を\cs{ltjsetparameter}で編集した場合,
9986 その行はそこで改行するようにした方がいいだろう.
9987 %</ja>
9988
9989 %<*ja>
9990 \subsection{濁点・半濁点付き仮名の正規化→\Pkg{luaotfload}~v3.19以降ではそちらで}
9991 \TeX~Live~2016以降の(u)\pTeX では,合成用濁点(\texttt{U+3099})・合成用半濁点(\texttt{U+309A})を用いて
9992 表現された平仮名・片仮名を合成済み文字に変換するという処理を行っている.
9993 この処理を行っている要因としては,
9994 \begin{itemize}
9995   \item 無用なトラブルを避けるため.
9996   濁点・半濁点付きの仮名文字が「合成用濁点・半濁点を使って入力されているか」「最初から合成済み文字で入力されているか」を
9997   見た目から判別することは難しい.
9998   \item \pTeX との互換性のため.\pTeX は内部コードがJIS~X~0208の範囲に限られるため,
9999   合成用濁点・半濁点は利用できない.そのため上記の変換処理はさらに前から行われていた.
10000 \end{itemize}
10001
10002 \LuaTeX(-ja)では入力の変換は基本的に行わず,
10003 文字の合成は使用しているフォントのOpenType機能に委ねるという立場であったが,
10004 \Pkg{luaotfload}~v3.19以降では,標準でNFCへのUnicode正規化を行っている.
10005 そのため,バージョン2023****.0以降では,\LuaTeX-jaによる自前の変換\footnote{バージョン20220103.0で実装した.}は
10006 行わないようにしている.
10007 %</ja>
10008
10009 %<*ja>
10010 %<en>\section{Insertion of JFM glues, \Param{kanjiskip} and \Param{xkanjiskip}}
10011 %<ja>\section{JFMグルーの挿入,\Param{kanjiskip}と\Param{xkanjiskip}}
10012 \label{sec-jfmglue}
10013 %<en>\subsection{Overview}
10014 %<ja>\subsection{概要}
10015
10016 \LuaTeX-jaにおける \textbf{JAglue} の挿入方法は,\pTeX のそれとは全く異なる.
10017 \pTeX では次のような仕様であった:
10018 \begin{itemize}
10019 \item JFMグルーの挿入は,和文文字を表すトークンを元に水平リストに(文字を表す)\meta{char\_node}を
10020 追加する過程で行われる.
10021 \item \Param{xkanjiskip}の挿入は,hboxへのパッケージングや行分割前に行われる.
10022 \item \Param{kanjiskip}はノードとしては挿入されない.パッケージングや行分割の計算時に
10023 「和文文字を表す2つの\meta{char\_node}の間には\Param{kanjiskip}がある」ものとみなされる.
10024 \end{itemize}
10025 しかし,\LuaTeX-jaでは,hboxへのパッケージングや行分割前に全ての
10026 \textbf{JAglue},即ちJFMグルー・\Param{xkanjiskip}・\Param{kanjiskip}の
10027 3種類を一度に挿入することになっている.これは,\LuaTeX において欧文の合字・
10028 カーニング処理がノードベースになったことに対応する変更である.
10029
10030 \LuaTeX-jaにおける\textbf{JAglue}挿入処理では,次節で定義する
10031 「クラスタ」を単位にして行われる.大雑把にいうと,「クラスタ」は文字とそれに付随す
10032 るノード達(アクセント位置補正用のカーンや,イタリック補正)をまとめたもの
10033 であり,2つのクラスタの間には,ペナルティ,\cs{vadjust},whatsitなど,行組版
10034 には関係しないものがある.
10035
10036
10037 %<en>\subsection{Definition of a Cluster}
10038 %<ja>\subsection{「クラスタ」の定義}
10039
10040 \def\OA{$\text{\sf O}_{\text{\sf A}}$}
10041 \def\OB{$\text{\sf O}_{\text{\sf B}}$}
10042 \def\NA{$\text{\sf N}_{\text{\sf A}}$}
10043 \def\NB{$\text{\sf N}_{\text{\sf B}}$}
10044 \begin{defn}
10045 %<*en>
10046 A \emph{cluster} is consecutive nodes in one of the following forms,
10047 with the \textit{id} of it:
10048 %</en>
10049 %<*ja>
10050 \emph{クラスタ}は以下の形のうちのどれかひとつをとるノードのリストである:
10051 %</ja>
10052 \begin{enumerate}
10053 %<*en>
10054 \item Nodes whose value of\ \verb+\ltj@icflag+ is in $[3,15)$.  These
10055       nodes come from a hbox which is already packaged, by unpackaging
10056       (\cs{unhbox}).
10057       The \textit{id} of the cluster is \textit{id\_pbox}.
10058 %</en>
10059 %<*ja>
10060 \item その \verb+\ltj@icflag+ の値が$[3,15)$に入るノードのリスト.
10061   これらのノードはある既にパッケージングされたhboxから \cs{unhbox} で
10062   アンパックされたものである.
10063   この場合,クラスタの\textit{id}は\textit{id\_pbox}である.
10064 %</ja>
10065
10066 %<*en>
10067 \item A inline math formula, including two \textit{math\_node}s at the boundary of it.
10068       The \textit{id} of the cluster is \textit{id\_math}.
10069 %</en>
10070 %<*ja>
10071 \item インライン数式でその境界に2つの\textit{math\_node}を含むもの.
10072   この場合,クラスタの\textit{id}は\textit{id\_math}である.
10073 %</ja>
10074
10075 %<*en>
10076 \item A \textit{glyph\_node}~$p$, which represents a \textbf{JAchar}, with nodes which relate with it:
10077 %</en>
10078 %<*ja>
10079 \item \textbf{JAchar}を表す\textit{glyph\_node}~$p$とそれに関係するノード:
10080 %</ja>
10081 \begin{enumerate}
10082 %<*en>
10083 \item[(a)] A kern for the italic correction of~$p$.
10084 %</en>
10085 %<*ja>
10086 \item[(a)] $p$のイタリック補正のためのカーン.
10087 %</ja>
10088
10089 %<*en>
10090 \item[(b)] An accent attached to $p$ by \cs{accent}.
10091 %</en>
10092 %<*ja>
10093 \item[(b)] \cs{accent} による$p$に付随したアクセント.
10094 %</ja>
10095 \end{enumerate}
10096 \[
10097 \overbrace{%
10098  \Node{kern}{$\mathit{subtype}=2$}\longrightarrow
10099 \left\{\begin{array}{c}
10100 \Node{glyph}{accent}\\\noalign{\medskip}
10101 \Node{hbox}{accent (shifted vert.)}
10102 \end{array}\right\}\longrightarrow
10103 \Node{kern}{$\mathit{subtype}=2$}}^{\text{(b)}}
10104 \longrightarrow
10105 \Node{glyph}{$p$}\longrightarrow
10106 \overbrace{%
10107 \Node{kern}{italic corr.}}^{\text{(a)}}
10108 \]
10109
10110 %<*en>
10111 In this case, the \textit{id} is \textit{id\_jglyph}.
10112 %</en>
10113 %<*ja>
10114 この場合の\textit{id}は\textit{id\_jglyph}である.
10115 %</ja>
10116
10117 %<*en>
10118 \item A list which begins from a \textit{glyph\_node} which represents a \textbf{ALchar},
10119       and consists of \textbf{ALchar} \textit{glyph\_node}s,
10120       kerns for adjusting accents~(its subtype is 2), kerns for italic corrections and
10121       kerns which are automatically inserted by \LuaTeX~or~luaotfload.
10122       In this case, the \textit{id} is \textit{id\_glyph}.
10123 %</en>
10124 %<*ja>
10125 \item \textbf{ALchar}を表す\textit{glyph\_node},\cs{accent} によるアクセント位置補正用の
10126       カーン(subtypeが2),そしてイタリック補正・カーニングによって挿入されたカーン達が連続
10127       したもの.この場合の\textit{id}は\textit{id\_glyph}である.
10128 %</ja>
10129
10130 %<*en>
10131 \item An box-like node, that is, an hbox, a vbox, a rule (\cs{vrule}) and an \textit{unset\_node}.
10132 The \textit{id} of the cluster is \textit{id\_hlist} if the node is an
10133       hbox which is not shifted vertically, or \textit{id\_box\_like}
10134       otherwise.
10135 %</en>
10136 %<*ja>
10137 \item 水平ボックス(hbox),垂直ボックス,罫線 (\cs{vrule}),
10138   そして\textit{unset\_node}.
10139   クラスタの\textit{id}は垂直に移動していないhboxならば\textit{id\_hlist},
10140   そうでなければ\textit{id\_box\_like}となる.
10141 %</ja>
10142
10143 %<*en>
10144 \item A glue, a kern whose subtype is not 2~(\textit{accent}), and a discretionary break.
10145 The \textit{id} of the cluster is \textit{id\_glue}, \textit{id\_kern}
10146       and \textit{id\_disc}, respectively.
10147 %</en>
10148 %<*ja>
10149 \item グルー,subtypeが 2~(\textit{accent})ではないカーン,そしてdiscretionary break.
10150   その\textit{id} of the clusterはそれぞれ\textit{id\_glue}, \textit{id\_kern},そして
10151   \textit{id\_disc}である.
10152 %</ja>
10153 \end{enumerate}
10154 %<*en>
10155 We use \textit{Np}, \textit{Nq} and \textit{Nr} to denote a cluster.
10156 %</en>
10157 %<*ja>
10158 以下では\textit{Np}, \textit{Nq}, \textit{Nr}でクラスタを表す.
10159 %</ja>
10160 \end{defn}
10161
10162 \paragraph{\textit{id}の意味}
10163 $\mathit{Np}.\mathit{id}$の意味を述べるとともに,
10164 「先頭の文字」を表す\textit{glyph\_node}~$\mathit{Np}.\mathit{head}$と,
10165 「最後の文字」を表す\textit{glyph\_node}~$\mathit{Np}.\mathit{tail}$を次のように定義する.
10166 直感的に言うと,\textit{Np}は$\mathit{Np}.\mathit{head}$で始まり$\mathit{Np}.\mathit{tail}$で終わるような単語,
10167 と見做すことができる.これら$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は
10168 説明用に準備した概念であって,実際のLuaコード中にそのように書かれているわけではないことに注意.
10169
10170 \begin{description}
10171 \item[\textit{id\_jglyph}] \textbf{JAchar}(和文文字).\\
10172 $\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は,その\textbf{JAchar}を表している
10173 \textit{glyph\_node}そのものである.
10174 \item[\textit{id\_glyph}] \textbf{JAchar}(和文文字)以外のものを表す\textit{glyph\_node}~$p$.\\
10175 多くの場合,$p$は\textbf{ALchar}(欧文文字)を格納しているが,「ffi」などの合字によって作られた
10176 \textit{glyph\_node}である可能性もある.
10177 前者の場合,$\mathit{Np}.\mathit{head}$,~$\mathit{Np}.\mathit{tail} = p$である.
10178 一方,後者の場合,
10179 \begin{itemize}
10180 \item $\mathit{Np}.\mathit{head}$は,
10181 合字の構成要素の先頭→(その\textit{glyph\_node}における)合字の構成要素の先頭→……
10182 と再帰的に検索していってたどり着いた\textit{glyph\_node}である.
10183 \item $\mathit{Np}.\mathit{last}$は,同様に末尾→末尾→と検索してたどり着いた\textit{glyph\_node}である.
10184 \end{itemize}
10185 \item[\textit{id\_math}] インライン数式.\\
10186 便宜的に,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$ともに
10187 「文字コード$-1$の欧文文字」とおく.
10188 \item[\textit{id\_hlist}] 縦方向にシフトされていないhbox.\\
10189 この場合,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$はそれぞれ$p$の内容を表すリストの,
10190 先頭・末尾のノードである.
10191 \medskip
10192 \begin{itemize}
10193 \item 状況によっては,\TeX ソースで言うと
10194 \begin{lstlisting}
10195 \hbox{\hbox{abc}...\hbox{\lower1pt\hbox{xyz}}}
10196 \end{lstlisting}
10197 のように,$p$の内容が別のhboxで開始・終了している可能性も十分あり得る.そのような場合,
10198 $\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$の算出は,
10199 \emph{垂直方向にシフトされていない}hboxの
10200 場合だけ内部を再帰的に探索する.例えば上の例では,$\mathit{Np}.\mathit{head}$は文字「a」を表すノードであり,
10201 一方$\mathit{Np}.\mathit{tail}$は垂直方向にシフトされたhbox,
10202 \verb+\lower1pt\hbox{xyz}+ に対応するノードである.
10203 \item また,先頭にアクセント付きの文字がきたり,末尾にイタリック補正用のカーンが
10204 来ることもあり得る.この場合は,クラスタの定義のところにもあったように,それらは無視して算出を行う.
10205 \item 最初・最後のノードが合字によって作られた\textit{glyph\_node}のときは,それぞれに対して\textit{id\_glyph}%
10206 と同様に再帰的に構成要素をたどっていく.
10207 \end{itemize}
10208 \item[\textit{id\_pbox}] 「既に処理された」ノードのリストであり,これらのノードが二度処理を受けないために
10209 まとめて1つのクラスタとして取り扱うだけである.
10210 \textit{id\_hlist}と同じ方法で$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$を算出する,
10211 \item[\textit{id\_disc}] discretionary break (\verb+\discretionary{pre}{post}{nobreak}+).\\
10212 \textit{id\_hlist}と同じ方法で$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$を算出するが,
10213 第3引数の \texttt{nobreak}(行分割が行われない時の内容)を使う.言い換えれば,ここで行分割が発生した時の状況は
10214 全く考慮に入れない.
10215 \item[\textit{id\_box\_like}] \textit{id\_hlist}とならないboxや,rule.\\
10216 この場合は,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$のデータは利用されないので,2つの算出は無意味である.
10217 敢えて明示するならば,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は共にnil値である.
10218 \item[他] 以上にない\textit{id}に対しても,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$の算出は無意味.
10219 \end{description}
10220
10221 \paragraph{クラスタの別の分類}
10222 さらに,JFMグルー挿入処理の実際の説明により便利なように,\textit{id}とは別のクラスタの分類を行っておく.
10223 挿入処理では2つの隣り合ったクラスタの間に
10224 空白等の実際の挿入を行うことは前に書いたが,ここでの説明では,問題にしているクラスタ\textit{Np}は「後ろ側」のクラスタである
10225 とする.「前側」のクラスタについては,以下の説明で\textit{head}が\textit{last}に置き換わることに注意すること.
10226 \begin{description}
10227 \item[和文A] リスト中に直接出現している\textbf{JAchar}.
10228 \textit{id}が\textit{id\_jglyph}であるか,\\
10229 \textit{id}が\textit{id\_pbox}であって$\mathit{Np}.\mathit{head}$が\textbf{JAchar}であるとき.
10230
10231 \item[和文B] リスト中のhboxの中身の先頭として出現した\textbf{JAchar}.和文Aとの違いは,これの前に
10232 JFMグルーの挿入が行われない(\Param{xkanjiskip},~\Param{kanjiskip}は入り得る)ことである.\\
10233 \textit{id}が\textit{id\_hlist}か\textit{id\_disc}であって$\mathit{Np}.\mathit{head}$が\textbf{JAchar}であるとき.
10234
10235 \item[欧文] リスト中に直接/hboxの中身として出現している「\textbf{JAchar}以外の文字」.次の3つの場合が該当:
10236 \begin{itemize}
10237 \item \textit{id}が\textit{id\_glyph}である.
10238 \item \textit{id}が\textit{id\_math}である(つまりこのクラスタは1つの文中数式をなす).
10239 \item \textit{id}が\textit{id\_pbox}か\textit{id\_hlist}か\textit{id\_disc}であって,$\mathit{Np}.\mathit{head}$が\textbf{ALchar}.
10240 \end{itemize}
10241 \item[箱] box,またはそれに類似するもの.次の2つが該当:
10242 \begin{itemize}
10243 \item \textit{id}が\textit{id\_pbox}か\textit{id\_hlist}か\textit{id\_disc}であって,$\mathit{Np}.\mathit{head}$が\textit{glyph\_node}でない.
10244 \item \textit{id}が\textit{id\_box\_like}である.
10245 \end{itemize}
10246
10247 \end{description}
10248
10249 \subsection{段落/hboxの先頭や末尾}
10250 \paragraph{先頭部の処理}
10251 まず,段落/hboxの一番最初にあるクラスタ\textit{Np}を探索する.
10252 hboxの場合は何の問題もないが,段落の場合では以下のノード達を事前に読み飛ばしておく:
10253 \begin{itemize}
10254 \item \cs{parindent} 由来のhbox($\mathit{subtype}=3$)
10255 \item \textit{subtype}が44~(\textit{user\_defined})でないようなwhatsit
10256 \end{itemize}
10257 これは,\cs{parindent}由来のhboxがクラスタを構成しないようにするためである.
10258
10259 次に,\textit{Np}の直前に空白$g$を必要なら挿入する:
10260 \begin{enumerate}
10261 \item この処理が働くような\textit{Np}は\textsf{和文A}である.
10262 \item 問題のリストが字下げありの段落(\cs{parindent} 由来のhboxあり)の場合は,
10263 この空白$g$は「文字コード \texttt{'parbdd'} の文字」と\textit{Np}の間に入るグルー/カーンである.
10264 \item そうでないとき(\verb+noindent+ で開始された段落やhbox)は,
10265 $g$は「文字コード \texttt{'boxbdd'} の文字」と\textit{Np}の間に入るグルー/カーンである.
10266 \end{enumerate}
10267 ただし,もし$g$がglueであった場合,この挿入によって\textit{Np}による行分割が新たに可能になるべきではない.
10268 そこで,以下の場合には,$g$の直前に \cs{penalty10000} を挿入する:
10269 \begin{itemize}
10270 \item 問題にしているリストが段落であり,かつ
10271 \item \textit{Np}の前には予めペナルティがなく,$g$はglue.
10272 \end{itemize}
10273
10274 \paragraph{末尾の処理}
10275 末尾の処理は,問題のリストが段落のものかhboxのものかによって異なる.
10276 後者の場合は容易い:最後のクラスタを\textit{Nq}とおくと,\textit{Nq}と「文字コード\
10277 \texttt{'boxbdd'} の文字」の間に入るグルー/カーンを,
10278 \textit{Nq}の直後に挿入するのみである.
10279
10280 一方.前者(段落)の場合は,リストの末尾は常に \cs{penalty10000} と,
10281 \cs{parfillskip} 由来のグルーが存在する.%よって,最後のクラスタ\textit{Np}は
10282 %この \cs{parfillskip} 由来のグルーとなり,実質的な中身の最後はその1つ前のクラスタ\textit{Nq}となる.
10283 段落の最後の「通常の\textbf{JAchar}${}+{}$句点」が独立した行となるのを防ぐために,
10284 \Param{jcharwidowpenalty}の値の分だけ適切な場所のペナルティを増やす.
10285
10286 ペナルティ量を増やす場所は,\textit{head}が\textbf{JAchar}であり,
10287 かつその文字の\Param{kcatcode}が偶数であるような
10288 最後のクラスタの直前にあるものたちである%
10289 \footnote{大雑把に言えば,\Param{kcatcode}が奇数であるような\textbf{JAchar}%
10290 を約物として考えていることになる.
10291 \Param{kcatcode}の最下位ビットはこの\Param{jcharwidowpenalty}用にのみ利用される.}.
10292
10293 \subsection{概観と典型例:2つの「和文A」の場合}
10294 \label{ssec:cluster-wa}
10295 先に述べたように,2つの隣り合ったクラスタ,\textit{Nq}と\textit{Np}の間には,
10296 ペナルティ,\cs{vadjust},whatsitなど,行組版には関係しないものがある.模式的に表すと,
10297 \[
10298  \Node{cluster}{\textit{Nq}}\longrightarrow
10299 \overbrace{
10300 \Node{penalty}{$p$}\longrightarrow \cdots\longrightarrow \Node{whatsit}{}}^{\textrm{(a)}}
10301 \longrightarrow \Node{cluster}{\textit{Np}}
10302 \]
10303 のようになっている.間の(a)に相当する部分には,何のノードもない場合ももちろんあり得る.
10304 そうして,JFMグルー挿入後には,この2クラスタ間は次のようになる:
10305 \[
10306  \Node{cluster}{\textit{Nq}}\longrightarrow%\Node{kern}{左空白}\longrightarrow
10307 \overbrace{
10308 \Node{penalty}{$p+x$}\longrightarrow \cdots\longrightarrow
10309 \Node{whatsit}{}}^{\textrm{(a)}}\longrightarrow
10310 \Node{glue or kern}{\raisebox{-.2\zw}{右空白}}\longrightarrow
10311 \Node{cluster}{\textit{Np}}
10312 \]
10313
10314 以後,\emph{典型的な例として,クラスタ\textit{Nq}と\textit{Np}が共に\textsf{\textmd{和文A}}である場合を見ていこう,}
10315 この場合が全ての場合の基本となる.
10316
10317 \paragraph{「右空白」の算出}
10318 まず,「右空白」にあたる量を算出する.通常はこれが,隣り合った2つの\textbf{JAchar}間に入る空白量となる.
10319 \begin{description}
10320 \item[JFM由来{[M]}] JFMの文字クラス指定によって入る空白を以下によって求める.この段階で空白量が未定義(未指定)だった場合,
10321       デフォルト値\Param{kanjiskip}を採用することとなるので,次へ.
10322 \begin{enumerate}
10323 \item もし両クラスタの間で \cs{inhibitglue} が実行されていた場合(証としてwhatsitノードが自動挿入される),
10324       代わりに\Param{kanjiskip}が挿入されることとなる.次へ.
10325 \item \textit{Nq}と\textit{Np}が同じJFM・同じ\texttt{jfmvar}キー・同じサイズの和文フォントであったならば,
10326       共通に使っているJFM内で挿入される空白(グルーかカーン)が決まっているか調べ,決まっていればそれを採用.
10327 \item 1.でも2.でもない場合は,JFM・\texttt{jfmvar}・サイズの3つ組は\textit{Nq}と\textit{Np}で異なる.
10328 この場合,まず
10329 \[
10330 \vcenter{\halign{\hfil$#:={}$&\inhibitglue#\inhibitglue\cr
10331 gb&(\textit{Nq}と「使用フォントが\textit{Nq}のそれと同じで,\hfil\cr
10332 \omit&\quad 文字コードが\textit{Np}のそれの文字」との間に入るグルー/カーン)\hfil\cr
10333 ga&(\inhibitglue 「使用フォントが\textit{Np}のそれと同じで,\hfil\cr
10334 \omit&\quad 文字コードが\textit{Nq}のそれの文字」と\textit{Np}との間に入るグルー/カーン)\hfil\cr
10335 }}
10336 \]
10337 として,前側の文字のJFMを使った時の空白(グルー/カーン)と,後側の文字のJFMを使った時のそれを求める.
10338
10339 $\mathit{gb}$,~$\mathit{ga}$それぞれに対する\meta{ratio}の値を$d_b$,~$d_a$とする.
10340 \begin{itemize}
10341 \item
10342 $\mathit{ga}$と$\mathit{gb}$の両方が未定義であるならば,JFM由来のグルーは挿入されず,
10343 \Param{kanjiskip}を採用することとなる.
10344 どちらか片方のみが未定義であるならば,次のステップでその未定義の方は長さ0のkernで,\meta{ratio}の値は0であるかのように扱われる.
10345 \item
10346 \Param{diffrentjfm}の値が \texttt{pleft}, \texttt{pright},
10347       \texttt{paverage} のとき,
10348 \meta{ratio}の指定に従って比例配分を行う.
10349 JFM由来のグルー/カーンは以下の値となる:
10350 \[
10351  f\left(\frac{1-d_b}2\textit{gb} + \frac{1+d_b}2\textit{ga},
10352 \frac{1-d_a}2\textit{gb} + \frac{1+d_a}2\textit{ga}\right)
10353 \]
10354 ここで.$f(x,y)$は
10355 \[
10356  f(x,y)=\begin{dcases*}
10357 x&($\Param{diffrentjfm}=\texttt{pleft}$),\\
10358 y&($\Param{diffrentjfm}=\texttt{pright}$),\\
10359 \frac{x+y}2&($\Param{diffrentjfm}=\texttt{paverage}$).
10360 \end{dcases*}
10361 \]
10362 \item
10363 \Param{differentjfm}がそれ以外の値の時は,\meta{ratio}の値は無視され,JFM由来のグルー/カーンは以下の値となる:
10364 \[
10365  f(\textit{gb},\textit{ga})
10366 \]
10367 ここで.$f(x,y)$は
10368 \[
10369  f(x,y)=\begin{dcases*}
10370 \min(x,y)&($\Param{diffrentjfm}=\texttt{small}$),\\
10371 \max(x,y)&($\Param{diffrentjfm}=\texttt{large}$),\\
10372 \frac{x+y}2&($\Param{diffrentjfm}=\texttt{average}$),\\
10373 x+y&($\Param{diffrentjfm}=\texttt{both}$).
10374 \end{dcases*}
10375 \]
10376 \end{itemize}
10377 \end{enumerate}
10378
10379 例えば,
10380 \begin{lstlisting}
10381 \jfont\foo=psft:Ryumin-Light:jfm=ujis;-kern
10382 \jfont\bar=psft:GothicBBB-Medium:jfm=ujis;-kern
10383 \jfont\baz=psft:GothicBBB-Medium:jfm=ujis;jfmvar=piyo;-kern
10384 \end{lstlisting}
10385 という3フォントを考え,
10386 \[
10387  \overbrace{\Node{glyph}{\cs{ foo}, `あ'}}^{p}
10388 \longrightarrow \overbrace{\Node{glyph}{\cs{bar}, `い'}}^{q}
10389 \longrightarrow \overbrace{\Node{glyph}{\cs{baz}, `う'}}^{r}
10390 \]
10391 という3ノードを考える(それぞれ単独でクラスタをなす).
10392 この場合,$p$と$q$の間は,実フォントが異なるにもかかわらず2.の状況となる一方で,
10393 $q$と$r$の間は(実フォントが同じなのに)\texttt{jfmvar} キーの内容が異なるので3.の状況となる.
10394
10395   なお,JFMで\texttt{kanjiskip\_natural}, \texttt{kanjiskip\_stretch},\
10396 \texttt{kanjiskip\_shrink}キーが指定されていた場合は,……
10397   
10398 \item[\Param{kanjiskip}~{[K]}] 上の[M]において空白が定まらなかった場合,
10399 以下で定めた量「右空白」として採用する.
10400 この段階においては,\cs{inhibitglue} は効力を持たないため,
10401 結果として,2つの\textbf{JAchar}間には常に何らかのグルー/カーンが挿入されることとなる.
10402 \begin{enumerate}
10403 \item 両クラスタ(厳密には$\mathit{Nq}.\mathit{tail}$,$\mathit{Np}.\mathit{head}$)の中身の文字コードに対する
10404 \Param{autospacing}パラメータが両方ともfalseだった場合は,長さ0のglueとする.
10405 \item ユーザ側から見た\Param{kanjiskip}パラメータの自然長が$\cs{maxdimen}=(2^{30}-1)\,\mbox{sp}$で
10406 なければ,\Param{kanjiskip}パラメータの値を持つglueを採用する.
10407 \item 2.でない場合は,\textit{Nq}, \textit{Np}で使われているJFMに指定されている\Param{kanjiskip}の値を用いる.
10408 どちらか片方のクラスタだけが\textbf{JAchar}(\textsf{和文A}・\textsf{和文B})のときは,そちらのクラスタで使われている
10409 JFM由来の値だけを用いる.もし両者で使われているJFMが異なった場合は,上の[M]~3.と同様の方法を用いて調整する.
10410 \end{enumerate}
10411 \end{description}
10412 %\paragraph{「左空白」の算出とそれに伴う補正}
10413 %「左空白」は過去のバージョンでは定義していたが,このバージョンでは
10414 %挿入は一切行われない(機能自体削除している).
10415 %しかし,仕様は流動的であり,将来復活する可能性もあるため,マニュアル中の記述は今のところ極力変更しない.
10416 \paragraph{禁則用ペナルティの挿入}
10417 まず,
10418 \[
10419  a:=(\text{\textit{Nq}{\footnotemark}の文字に対する\Param{postbreakpenalty}の値})
10420 +(\text{\textit{Np}{\footnotemark}の文字に対する\Param{prebreakpenalty}の値})
10421 \]
10422 とおく\footnotetext{厳密にはそれぞれ$\mathit{Nq}.\mathit{tail}$,$\mathit{Np}.\mathit{head}$.}.
10423 ペナルティは通常$[-10000,10000]$の整数値をとり,また$\pm 10000$は正負の無限大を意味することになっているが,この$a$の
10424 算出では単純な整数の加減算を行う.
10425
10426 $a$は禁則処理用に\textit{Nq}と\textit{Np}の間に加えられるべきペナルティ量である.
10427 \begin{description}
10428 \item[P-normal~{[PN]}]
10429 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティ(\textit{penalty\_node})があれば処理は簡単である:
10430 それらの各ノードにおいて,ペナルティ値を($\pm 10000$を無限大として扱いつつ)$a$だけ増加させればよい.
10431 また,$10000 + (-10000) = 0$としている.
10432
10433 少々困るのは,(a)部分にペナルティが存在していない場合である.
10434 直感的に,補正すべき量$a$が0でないとき,その値をもつ\textit{penalty\_node}を作って
10435 「右空白」の(もし未定義なら\textit{Np}の)直前に挿入……
10436 ということになるが,実際には僅かにこれより複雑である.
10437 \begin{itemize}
10438 \item 「右空白」がカーンであるとき,
10439 それは「\textit{Nq}と\textit{Np}の間で改行は許されない」ことを意図している.そのため,
10440 この場合は$a\neq 0$であってもペナルティの挿入はしない.
10441 \item そうでないないときは,$a\neq 0$ならば\textit{penalty\_node}を作って挿入する.
10442 %\item 「左空白」がカーンとしてきっちり定義されている時(このとき,「右空白」はカーンでない),
10443 %この「左空白」の直後での行分割を許容しないといけないので,$a=0$であっても
10444 %\textit{penalty\_node}を作って挿入する.
10445 %\item 以上のどれでもないときは,$a\neq 0$ならば\textit{penalty\_node}を作って挿入する.
10446 \end{itemize}
10447 \end{description}
10448
10449 \def\gkf#1#2#3{\sf$\displaystyle\vphantom{\Bigg(}%
10450   \frac{\hbox to 4\zw{\hss#2\hss}}{\hbox{#3}}$}
10451 \begin{table}[t]
10452 %<en>\caption{Summary of JFM glues}
10453 %<ja>\caption{JFM グルーの概要}
10454 \label{tab-jfmglue}
10455 %<en>\medskip
10456 \begin{center}
10457 \small
10458 \begin{tabular}{c|cccccc}
10459 \toprule
10460 {\bf\textit{Np}}↓&\sf 和文A&\sf 和文B&\sf 欧文&\sf 箱&\sf glue&\sf kern\\\midrule
10461 \sf 和文A&
10462 \gkf{E}{M→K}{PN}&
10463 \gkf{---}{\OA →K}{PN}&
10464 \gkf{---}{\NA →X}{PN}&
10465 \gkf{---}{\OA}{PA}&
10466 \gkf{---}{\OA}{PN}&
10467 \gkf{---}{\OA}{PS}\\
10468 \sf 和文B&
10469 \gkf{E}{\OB→K}{PA}&
10470 \gkf{---}{K}{PS}&
10471 \gkf{---}{X}{PS}\\
10472 \sf 欧文&
10473 \gkf{E}{\NB →X}{PA}&
10474 \gkf{---}{X}{PS}\cr
10475 \sf 箱&\gkf{E}{\OB}{PA}\\
10476 \sf glue&\gkf{E}{\OB}{PN}\\
10477 \sf kern&\gkf{E}{\OB}{PS}\\
10478 \bottomrule
10479 \end{tabular}
10480 \end{center}
10481 \begin{quote}
10482 %<*en>
10483 In the table above, {\small\gkf{E}{M→K}{PN}} means that
10484 %</en>
10485 %<*ja>
10486 上の表において,{\small\gkf{E}{M→K}{PN}}は次の意味である:
10487 %</ja>
10488 \begin{enumerate}
10489 %<*en>
10490 \item To determine the ``right-space'', \LuaTeX-ja first attempts by the method ``\textsf{JFM-origin~[M]}''.
10491 If this attempt fails, \LuaTeX-ja use the method ``\textsf{\Param{kanjiskip}~[K]}''.
10492 %</en>
10493 %<*ja>
10494 \item 「右空白」を決めるために,\LuaTeX-ja はまず「JFM由来{[M]}」の方法を試みる.
10495   これが失敗したら,\LuaTeX-ja は「\Param{kanjiskip}~{[K]}」の方法を試みる.
10496 %</ja>
10497
10498 % %<*en>
10499 % \item The ``left space'' between \textit{Nq}~and~\textit{Np} is
10500 %   determined by the method ``\textsf{line-end~[E]}''.
10501 % %</en>
10502 % %<*ja>
10503 % \item \textit{Nq} と \textit{Np} の間の「左空白」は「\textsf{line-end~[E]}」の
10504 %   方法で決定される.
10505 % %</ja>
10506
10507 %<*en>
10508 \item \LuaTeX-ja adopts the method ``\textsf{P-normal~[PN]}'' to adjust the penalty
10509   between two clusters for \emph{kinsoku shori}.
10510 %</en>
10511 %<*ja>
10512 \item \LuaTeX-jaは2つのクラスタの間の禁則処理用のペナルティを設定するために「\textsf{P-normal~[PN]}」の方法を採用する.
10513 %</ja>
10514 \end{enumerate}
10515 \end{quote}
10516 \end{table}
10517
10518 \subsection{その他の場合}
10519 本節の内容は\autoref{tab-jfmglue}にまとめてある.
10520
10521 \paragraph{和文Aと欧文の間}
10522 \textit{Nq}が\textsf{和文A}で,\textit{Np}が\textsf{欧文}の場合,JFMグルー挿入処理は次のようにして行われる.
10523 \begin{itemize}
10524 \item 「右空白」については,まず以下に述べる\textsf{欧文境界B~[\NB]}により空白を決定しようと試みる.
10525 それが失敗した場合は,\textsf{\Param{xkanjiskip}~[X]}によって定める.
10526 %\item 「左空白」については,既に述べた\textsf{line-end~[E]}をそのまま採用する.それに伴う「右空白」の補正も%同じ.
10527 \item 禁則用ペナルティも,以前述べた\textsf{P-normal~[PN]}と同じである.
10528 \end{itemize}
10529 \begin{description}
10530 \item[欧文境界B~{[\NB]}] 以下で求めた量を「右空白」として採用する.
10531 この処理は\textsf{JFM-origin~[M]}の変種と考えて良く,
10532 典型例は「和文の閉じ括弧と欧文文字の間に入る半角アキ」である.
10533 \begin{enumerate}
10534 \item もし両クラスタの間で \cs{inhibitglue} が実行されていた場合%
10535 (証としてwhatsitノードが自動挿入される),未定義.
10536 \item そうでなければ,
10537 \textit{Nq}と「文字コードが$x$の文字」との間に入るグルー/カーンとする.
10538 この$x$は次の場合分けによる:
10539   \begin{itemize}
10540     \item $\mathit{Np}.\mathit{id}$が\textit{id\_math}のとき(つまりクラスタ\textit{Np}が文中数式を表す)
10541     ときは,$x=-1$.
10542     \item \textit{Np}の中身の中身の文字コードについて,「直前への\Param{xkanjiskip}の挿入」が禁止されている
10543 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメータが偶数)ときは,
10544     $x=\text{\texttt{'nox\_alchar'}}$.
10545     \item 以上のいずれでもないときは,$x=\text{\texttt{'alchar'}}$.
10546   \end{itemize}
10547 \end{enumerate}
10548 \item[\Param{xkanjiskip}~{[X]}]
10549 この段階では,\textsf{\Param{kanjiskip}~[K]}のときと同じように,
10550 以下で定めた量を「右空白」として採用する.
10551 \cs{inhibitglue} は効力を持たない.
10552 \begin{enumerate}
10553 \item 以下のいずれかの場合は,\Param{xkanjiskip}の挿入は抑止される.しかし,実際には行分割を許容するために,長さ0のglueを採用する:
10554 \begin{itemize}
10555 \item 両クラスタにおいて,それらの中身の文字コードに対する\Param{autoxspacing}パラメータが共にfalseである.
10556 \item \textit{Nq}の中身の文字コードについて,「直後への\Param{xkanjiskip}の挿入」が禁止されている
10557 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメータが2以上).
10558 \item \textit{Np}の中身の文字コードについて,「直前への\Param{xkanjiskip}の挿入」が禁止されている
10559 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメータが偶数).
10560 \end{itemize}
10561 \item ユーザ側から見た\Param{xkanjiskip}パラメータの自然長が$\cs{maxdimen}=(2^{30}-1)\,\textrm{sp}$で
10562 なければ,\Param{xkanjiskip}パラメータの値を持つglueを採用する.
10563 \item 2.でない場合は,\textit{Nq}, \textit{Np}(\textsf{和文A}/\textsf{和文B}なのは片方だけ)
10564 で使われているJFMに指定されている\Param{xkanjiskip}の値を用いる.
10565 \end{enumerate}
10566 \end{description}
10567
10568 \paragraph{欧文と和文Aの間}
10569 \textit{Nq}が\textsf{欧文}で,\textit{Np}が\textsf{和文A}の場合,JFMグルー挿入処理は上の場合とほぼ同じである.
10570 \textsf{和文A}のクラスタが逆になるので,\textsf{欧文境界B~[\NB]}の部分が変わるだけである.
10571 \begin{itemize}
10572 \item 「右空白」については,まず以下に述べる\textsf{欧文境界A~[\OA]}により空白を決定しようと試みる.
10573 それが失敗した場合は,\textsf{\Param{xkanjiskip}~[X]}によって定める.
10574 %\item \textit{Nq}が和文でないので,「左空白」は算出されない.
10575 \item 禁則用ペナルティは,以前述べた\textsf{P-normal~[PN]}と同じである.
10576 \end{itemize}
10577 \begin{description}
10578 \item[欧文境界A~{[\NA]}] これは\textsf{欧文境界B~[\NB]}で\textit{Np}と\textit{Nq}の役割が
10579   交換されたものと思えば良い.
10580   この処理で定まる空白の典型例は,欧文文字と和文の開き括弧との間に入る半角アキである.
10581 \begin{enumerate}
10582 \item もし両クラスタの間で \cs{inhibitglue} が実行されていた場合(証としてwhatsitノードが自動挿入される),
10583   未定義.
10584 \item そうでなければ,
10585 「文字コードが$x$の文字」と\textit{Np}との間に入るグルー/カーンと定める.
10586 $x$は\textit{Nq}から\textsf{欧文境界B~[\NB]}におけるそれと同じ方法で定めるが,
10587 \texttt{'nox\_alchar'}か\texttt{'alchar'}は
10588 \begin{quote}
10589   \textit{Nq}の中身の文字コードについて,「直後への\Param{xkanjiskip}の挿入」が禁止されている
10590 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメータが2以上).
10591 \end{quote}
10592   か否かで判断する.
10593 \end{enumerate}
10594 \end{description}
10595
10596 \paragraph{和文Aと箱・グルー・カーンの間}
10597 \textit{Nq}が\textsf{和文A}で,\textit{Np}が\textsf{箱}・グルー・カーンのいずれかであった場合,
10598 両者の間に挿入されるJFMグルーについては同じ処理である.しかし,そこでの行分割に対する仕様が異なるので,
10599 ペナルティの挿入処理は若干異なったものとなっている.
10600 \begin{itemize}
10601 \item 「右空白」については,以下に述べる\textsf{Boundary-B~[\OB]}により空白を決定しようと試みる.
10602 それが失敗した場合は,「右空白」は挿入されない.
10603 %\item 「左空白」については,既に述べた\textsf{line-end~[E]}の算出方法をそのまま採用する.それに伴う「右空白」の補正も同じ.
10604 \item 禁則用ペナルティの処理は,後ろのクラスタ\textit{Np}の種類によって異なる.
10605 なお,$\mathit{Np}.\mathit{head}$は無意味であるから,
10606 「$\mathit{Np}.\mathit{head}$に対する\Param{prebreakpenalty}の値」は0とみなされる.言い換えれば,
10607 \[
10608  a:=(\text{\textit{Nq}の文字に対する\Param{postbreakpenalty}の値}).
10609 \]
10610 \begin{description}
10611 \item[箱] \textit{Np}が\textsf{箱}であった場合は,両クラスタの間での行分割は
10612 (明示的に両クラスタの間に \cs{penalty10000} があった場合を除き)いつも許容される.そのため,
10613 ペナルティ処理は,後に述べる\textsf{P-allow~[PA]}が\textsf{P-normal~[PN]}の代わりに用いられる.
10614 \item[グルー] \textit{Np}がグルーの場合,ペナルティ処理は\textsf{P-normal~[PN]}を用いる.
10615 \item[カーン] \textit{Np}がカーンであった場合は,両クラスタの間での行分割は
10616 (明示的に両クラスタの間にペナルティがあった場合を除き)許容されない.
10617 ペナルティ処理は,後に述べる\textsf{P-suppress~[PS]}を使う.
10618 \end{description}
10619 これらの\textsf{P-normal~[PN]},\textsf{P-allow~[PA]},\textsf{P-suppress~[PS]}の違いは,
10620 \textit{Nq}と\textit{Np}の間(以前の図だと(a)の部分)にペナルティが存在しない場合にのみ存在する.
10621 \end{itemize}
10622
10623 \begin{description}
10624 \item[Boundary-B~{[\OB]}] この処理は\textsf{欧文境界B~[\NB]}と同様であり,
10625   $x$が次によって決まることのみが異なる:
10626   \begin{itemize}
10627     \item \textit{Np}がグルーやカーンのときは,$x=\text{\texttt{'glue'}}$.
10628     \item そうでない(\textit{Np}が\textsf{箱})ときは,$x=\text{\texttt{'jcharbdd'}}$.
10629   \end{itemize}
10630 \item[P-allow~{[PA]}]
10631 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティがあれば,\textsf{P-normal~[PN]}と同様に,
10632 それらの各ノードにおいてペナルティ値を$a$だけ増加させる.
10633
10634 (a)部分にペナルティが存在していない場合,
10635 \LuaTeX-ja は\textit{Nq}と\textit{Np}の間の行分割を可能にしようとする.
10636 そのために,以下のいずれかの場合に$a$をもつ\textit{penalty\_node}を作って
10637 「右空白」の(もし未定義なら\textit{Np}の)直前に挿入する:
10638 \begin{itemize}
10639 \item 「右空白」がグルーでない(カーンか未定義)であるとき.
10640 \item $a\neq 0$のときは,「右空白」がグルーであっても\textit{penalty\_node}を作る.
10641 \end{itemize}
10642
10643 \item[P-suppress~{[PS]}]
10644 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティがあれば,\textsf{P-normal~[PN]}と同様に,
10645 それらの各ノードにおいてペナルティ値を$a$だけ増加させる.
10646
10647 (a)部分にペナルティが存在していない場合,
10648 \textit{Nq}と\textit{Np}の間の行分割は元々不可能のはずだったのであるが,
10649 \LuaTeX-ja はそれをわざわざ行分割可能にはしない.
10650 そのため,「右空白」がglueであれば,その直前に \cs{penalty10000} を挿入する.
10651 \end{description}
10652
10653 \paragraph{箱・グルー・カーンと和文Aの間}
10654 \textit{Np}が\textsf{箱}・グルー・カーンのいずれかで,\textit{Np}が\textsf{和文A}であった場合は,
10655 すぐ上の(\textit{Nq}と\textit{Np}の順序が逆になっている)場合と同じである.
10656 %が,「左空白」がなくなることにのみ注意.
10657 \begin{itemize}
10658 \item 「右空白」については,以下に述べる\textsf{Boundary-A~[\OA]}により空白を決定しようと試みる.
10659 それが失敗した場合は,「右空白」は挿入されない.
10660 %\item \textit{Nq}が和文でないので,「左空白」は算出されない.
10661 \item 禁則用ペナルティの処理は,\textit{Nq}の種類によって異なる.
10662 $\mathit{Nq}.\mathit{tail}$は無意味なので,
10663 \[
10664  a:=(\text{\textit{Np}の文字に対する\Param{prebreakpenalty}の値}).
10665 \]
10666 \begin{description}
10667 \item[箱] \textit{Nq}が\textsf{箱}の場合は,\textsf{P-allow~[PA]}を用いる.
10668 \item[グルー] \textit{Nq}がグルーの場合は,\textsf{P-normal~[PN]}を用いる.
10669 \item[カーン] \textit{Nq}がカーンの場合は,\textsf{P-suppress~[PS]}を用いる.
10670 \end{description}
10671 \end{itemize}
10672
10673 \begin{description}
10674 \item[Boundary-A~{[\OA]}] この処理は\textsf{欧文境界A~[\NA]}と同様であり,
10675   $x$が次によって決まることのみが異なる:
10676   \begin{itemize}
10677     \item \textit{Nq}がグルーやカーンのときは,$x=\text{\texttt{'glue'}}$.
10678     \item そうでない(\textit{Nq}が\textsf{箱})ときは,$x=\text{\texttt{'jcharbdd'}}$.
10679   \end{itemize}
10680 \end{description}
10681
10682 \paragraph{和文Aと和文Bの違い}
10683 先に述べたように,\textsf{和文B}はhboxの中身の先頭(or 末尾)として出現している
10684 \textbf{JAchar}である.リスト内に直接ノードとして現れている\textbf{JAchar}(\textsf{和文A})との違いは,
10685 \begin{itemize}
10686 \item \textsf{和文B}に対しては,JFMの文字クラス指定から定まる空白
10687 (\textsf{JFM由来[M]},\textsf{Boundary-A~[\OA]}など)の挿入は行われない.
10688 %「左空白」の算出も行われない.
10689 例えば,
10690 \begin{itemize}
10691 \item 片方が\textsf{和文A},もう片方が\textsf{和文B}のクラスタの場合,
10692 \textsf{Boundary-A~[\OA]}または\textsf{Boundary-B~[\OB]}の挿入を試み,それがダメなら
10693 \Param{kanjiskip}~\textsf{[K]}の挿入を行う.
10694 \item \textsf{和文B}の2つのクラスタの間には,\Param{kanjiskip}~\textsf{[K]}が自動的に入る.
10695 \end{itemize}
10696 \item \textsf{和文B}と箱・グルー・カーンが隣接したとき(どちらが前かは関係ない),間にJFMグルー・ペナルティの挿入は一切しない.
10697 \item \textsf{和文B}と\textsf{和文B},また\textsf{和文B}と\textsf{欧文}とが隣接した時は,禁則用ペナルティ挿入処理は
10698 \textsf{P-suppress~[PS]}が用いられる.
10699 \item \textsf{和文B}の文字に対する\Param{prebreakpenalty},~\Param{postbreakpenalty}の値は使われず,0として計算される.
10700 \end{itemize}
10701
10702
10703 次が具体例である:
10704 \begin{LTXexample}
10705 あ.\inhibitglue A\\
10706 \hbox{あ.}A\\
10707 あ.A
10708 \end{LTXexample}
10709 \begin{itemize}
10710 \item 1行目の\cs{inhibitglue}は\textsf{欧文境界B~[\NB]}の処理のみを抑止するので,ピリオドと「A」の間には
10711 \Param{xkanjiskip}(四分アキ)が入ることに注意.
10712 \item 2行目のピリオドと「A」の間においては,前者が\textsf{和文B}となる(hboxの中身の末尾として登場しているから)ので,
10713 そもそも\textsf{欧文境界B~[\NB]}の処理は行われない.よって,\Param{xkanjiskip}が入ることとなる.
10714 \item 3行目では,ピリオドの属するクラスタは\textsf{和文A}である.これによって,
10715 ピリオドと「A」の間には\textsf{欧文境界B~[\NB]}由来の半角アキが入ることになる.
10716 \end{itemize}
10717 %</ja>
10718
10719 %<*ja>
10720 \section{ベースライン補正の方法}
10721 \subsection{\texttt{yoffset} フィールド}
10722 \Param{yalbaselineshift}等のベースライン補正は,基本的には対象となっている
10723 \textit{glyph\_node}の \texttt{yoffset} フィールドの値を増減することによって
10724 実装されている.なお,\texttt{yoffset} の値は上方向への移動量であるのに対し,
10725 \Param{yalbaselineshift}などは下方向への移動量である.
10726
10727 さて,\texttt{yoffset} の増減によって見かけのグリフ位置は上下に移動するが,
10728 仮想ボディの高さ$h$,深さ$d$については
10729 \begin{description}
10730  \item[$\texttt{yoffset}\geq 0$のとき]
10731 $h = \max(\texttt{height} + \texttt{yoffset}, 0)$,
10732 $d = \max(\texttt{depth} - \texttt{yoffset}, 0)$,
10733  \item[$\texttt{yoffset}<0$のとき]
10734 $h = \max(\texttt{height} + \texttt{yoffset}, 0)$, $d=\texttt{depth}$.
10735 \end{description}
10736 という仕様になっている.つまり,\texttt{yoffset} が負(グリフを下ける)の場合に深さは増加しな
10737 い(\autoref{tab:yoffset_and_im}参照).
10738
10739 \begin{table}[t]
10740 \caption{\texttt{yoffset} and imaginary body}
10741 \label{tab:yoffset_and_im}
10742 \centering\small
10743 \fboxsep0pt
10744 \def\T#1#2{\fcolorbox{blue}{white}{%
10745   \setbox0=\hbox{\LARGE #1%
10746     \directlua{
10747       local p = tex.nest[tex.nest.ptr].tail
10748       p.yoffset = #2 * 65536
10749     }%
10750   }%
10751   \copy0\kern-\wd0\smash{\color{red}\vrule width \wd0 height 0.2pt depth 0.2pt}%
10752 }}
10753 \begin{tabular}{>{\bfseries}lccccc}
10754 \toprule
10755 \texttt{yoffset}&10\,pt&5\,pt&0&$-5$\,pt&$-10$\,pt\\
10756 \midrule
10757 仮想ボディ&\T{y}{10}, \T{H}{10}&\T{y}{5}, \T{H}{5}&\T{y}{0}, \T{H}{0}%
10758 &\T{y}{-5}, \T{H}{-5}&\T{y}{-10}, \T{H}{-10}\\[10pt]
10759 \bottomrule
10760 \end{tabular}
10761 \end{table}
10762
10763 \subsection{\textbf{ALchar}の補正}
10764 上記の問題について,\textbf{ALchar}のベースライン補正では
10765 「正しい深さ」を持った罫線(rule)を補うという対応策をとった.
10766 この罫線による補正は,\textit{id}が\textit{id\_glyph}であるクラスタ単位,
10767 大雑把に言えば音節単位で行われる.
10768 文字列``Typeset''を
10769 \begin{itemize}
10770  \item フォントはLatin Modern Roman (\texttt{lmroman10-regular.otf}) 10\,pt
10771  \item \Param{yalbaselineshift}は5\,pt
10772 \end{itemize}
10773 という状況で組んだ場合を例にとって説明しよう.
10774
10775 \LuaTeX・\Pkg{luaotfload}によるカーニング・ハイフネーションが終わった段階では,……
10776
10777
10778
10779 %</ja>
10780
10781 %<en>\section{Patch for the \Pkg{listings} Package}
10782 %<ja>\section{\Pkg{listings} パッケージへの対応}
10783
10784 %<*en>
10785 It is well-known that the \Pkg{listings} package outputs weird results
10786 for Japanese input.
10787 The \Pkg{listings} package makes most of letters active and assigns
10788 output command for each letter~(\cite{listings}).
10789 But Japanese characters are not included in these activated letters.
10790 For \pTeX{} series, there is no method to make Japanese characters active;
10791 a patch \Pkg{jlisting.sty}~(\cite{jlisting}) resolves the problem forcibly.
10792 %</en>
10793 %<*ja>
10794 \Pkg{listings} パッケージが,そのままでは日本語をまともに出力できないこと
10795 はよく知られている.きちんと整形して出力するために,\Pkg{listings}パッケー
10796 ジは内部で「ほとんどの文字」をアクティブにし,各文字に対してその文字の出
10797 力命令を割り当てている(\cite{listings}).
10798 しかし,そこでアクティブにする文字の中に,和文文
10799 字がないためである.\pTeX 系列では,和文文字をアクティブにする手法がなく,
10800 \Pkg{jlisting.sty} というパッチ(\cite{jlisting})を用いることで無理やり解決していた.
10801 %</ja>
10802
10803 %<*en>
10804 In \LuaTeX-ja, the problem is resolved by using the \verb+process_input_buffer+ callback.
10805 The callback function inserts the output command (active character \cs{ltjlineendcomment})
10806 before each letter above \texttt{U+0080}.
10807 This method can omits the process to make all Japanese characters active
10808 (most of the activated characters are not used in many cases).
10809 %</en>
10810 %<*ja>
10811 \LuaTeX-jaでは,\verb+process_input_buffer+ コールバックを利用することで,
10812 「各行に出現する\texttt{U+0080}以降の文字に対して,それらの出力命令を前置する」
10813 という方法をとっている.出力命令としては,アクティブ文字化した\cs{ltjlineendcomment}を用いている.
10814 これにより,(入力には使用されていないかもしれない)和文文字をもすべてアクティブ化する手間もなく,
10815 見通しが良い実装になっている.
10816 %</ja>
10817
10818
10819 %<*en>
10820 If the \Pkg{listings} package  and \LuaTeX-ja were loaded,
10821 then the patch \Pkg{lltjp-listings} is loaded automatically at \verb+\begin{document}+.
10822 %</en>
10823 %<*ja>
10824 \LuaTeX-ja で利用される \Pkg{listings} パッケージへのパッチ \Pkg{lltjp-listings} は,
10825 \Pkg{listings} と\LuaTeX-jaを読み込んでおけば,
10826 \verb+\begin{document}+ の箇所において自動的に読み込まれるので,通常はあまり
10827 意識する必要はない.
10828 %</ja>
10829
10830 %<en>\subsection{Notes and additional keys}
10831 %<ja>\subsection{注意}
10832 % %<*en>
10833 % \paragraph{Escaping to \LaTeX}
10834 % We used the \verb+process_input_buffer+ callback to output \textbf{JAchar}s.
10835 % But it has a drawback; any commands whose name contains a \textbf{JAchar}
10836 % cannot be used in any ``escape to \LaTeX''.
10837
10838 % Consider the following input:
10839 % %</en>
10840 % %<*ja>
10841 % \paragraph{\LaTeX へのエスケープ}
10842 % 日本語対応を行うために \verb+process_input_buffer+ を使用したことで,
10843 % \texttt{texcl},~\texttt{escapeinside}といった\emph{「\LaTeX へのエスケープ」中では,
10844 % \textbf{JAchar}を名称の一部に含む制御綴は使用不可能}である.
10845 % 例えば次のような入力を考えよう:
10846 % %</ja>
10847 % \begin{lstlisting}[showspaces][escapechar=\!]
10848 % !\cs{begin}!{lstlisting}[escapechar=\#]
10849 % #\ほげ xぴよ#
10850 % !\cs{end}!{lstlisting}
10851 % \end{lstlisting}
10852 % %<en>The line~2 is transformed by the callback to
10853 % %<ja>ここで,2行目は \verb+process_input_buffer+ の作用により,
10854 % \begin{lstlisting}[showspaces, escapechar=\!]
10855 % #\!\IVSA FFFFF!ほ!\IVSA FFFFF!げ x!\IVSA FFFFF!ぴ!\IVSA FFFFF!よ#
10856 % \end{lstlisting}
10857 % %<*en>
10858 % before the line is actually processed.
10859 % In the escape (between the character ``\verb+#+''),
10860 % the category code of \texttt{U+FFFFF} is set to 9~(\emph{ignored}).
10861 % Hence the control symbol ``\cs{}\IVSA FFFFF'' will be executed,
10862 % instead of ``\verb+\ほげ+''.
10863 % %</en>
10864 % %<*ja>
10865 % と変換されてから,実際の処理に回される.
10866 % 「\verb+#+」で挟まれた「\LaTeX へのエスケープ」中では\
10867 % \texttt{U+FFFFF} のカテゴリーコードは9~(\textit{ignored})となるので,
10868 % 結局「\verb+\ほげ+」の代わりに
10869 % 「\cs{}\IVSA FFFFF」というcontrol symbolが実行されることになる.
10870 % %</ja>
10871
10872 %<*en>
10873 \paragraph{Variation selectors}
10874 \Pkg{lltjp-listings} add two keys, namely \texttt{vsraw}~and~\texttt{vscmd},
10875 which specify how variation selectors are treated in
10876 \texttt{lstlisting} or other enviroments.
10877 Note that these additional keys are not usable in the preamble,
10878 since \Pkg{lltjp-listings} is loaded at \verb+\begin{document}+.
10879
10880 \texttt{vsraw} is a key which takes a boolean value, and its default value is
10881 false.
10882 \begin{itemize}
10883  \item If the \texttt{vsraw} key is true, then
10884 variation selectors are ``combined'' with the previous character.
10885 %</en>
10886 %<*ja>
10887 \paragraph{異体字セレクタの扱い}
10888 \texttt{lstlisting} 環境などの内部にある異体字セレクタを扱うため,
10889 \Pkg{lltjp-listings} では \texttt{vsraw} と \texttt{vscmd} という2つのキーを追加した.
10890 しかし,\Pkg{lltjp-listings} が実際に読み込まれるのは \verb+\begin{document}+\
10891 のところであるので,プリアンブル内ではこれらの追加キーは使用できない.
10892
10893 \texttt{vsraw}は,ブール値の値をとるキーであり,標準ではfalseである.
10894 \begin{itemize}
10895  \item trueの場合は,異体字セレクタは「直前の文字に続けて」出力されるため,
10896 例えば以下の例(左側は入力,右側はその出力)のようになる.
10897 %</ja>
10898 %%%% [preset=...]: workaround for lstlisting inside LTXexample
10899 \begin{LTXexample}[preset=\expandafter\def\csname @captype\endcsname{lstlisting}]
10900 \begin{lstlisting}[vsraw=true]
10901 葛󠄀城市,葛󠄁飾区,葛西
10902 \end{lstlisting}
10903 \end{LTXexample}
10904 %<*en>
10905 \item If the \texttt{vsraw} key is false, then
10906 variation selectors are typeset by an appropriate command, which is specified by
10907       the \texttt{vscmd} key.
10908 The default setting of the \texttt{vscmd} key produces the following.
10909 %</en>
10910 %<*ja>
10911 \item falseの場合は,異体字セレクタは適当な命令によって「見える形で」出力される.
10912 どのような形で出力されるかを規定するのが \texttt{vscmd} キーであり,
10913 \Pkg{lltjp-listings} の標準設定では以下の例の右側のように出力される.
10914 %</ja>
10915 \begin{LTXexample}[preset=\expandafter\def\csname @captype\endcsname{lstlisting}]
10916 \begin{lstlisting}[vsraw=false,
10917    vscmd=\ltjlistingsvsstdcmd]
10918 葛󠄀城市,葛󠄁飾区,葛西
10919 \end{lstlisting}
10920 \end{LTXexample}
10921 %<ja> ちなみに,本ドキュメントでは次のようにしている:
10922 %<en> For example, the following code is the setting of the \texttt{vscmd} key in this document.
10923 \begin{lstlisting}[numbers=left]
10924 \def\IVSA#1#2#3#4#5{%
10925   \hbox to1em{\hss\textcolor{blue}{\raisebox{3.5pt}{\normalfont\ttfamily%
10926     \fboxsep=0.5pt\fbox{\hbox to0.75em{\hss\tiny \oalign{0#1#2\crcr#3#4#5\crcr}\hss}}}}\hss}%
10927 }
10928 {\catcode`\%=11
10929   \gdef\IVSB#1{\expandafter\IVSA\directlua{
10930     local cat_str = luatexbase.catcodetables['string']
10931     tex.sprint(cat_str, string.format('%X', 0xE00EF+#1))
10932 }}}
10933 \lstset{vscmd=\IVSB}
10934 \end{lstlisting}
10935 \end{itemize}
10936 %<*en>
10937 The default output command of variation selectors is stored in \verb+\ltjlistingsvsstdcmd+.
10938 %</en>
10939 %<*ja>
10940 既定の出力命令を復活させたい場合は\ \verb+vscmd=\ltjlistingsvsstdcmd+\
10941 とすれば良い.
10942 %</ja>
10943
10944 %<*en>
10945 \paragraph{The \texttt{doubleletterspace} key}
10946 Even the column format is \texttt{[c]fixed}, sometimes characters are not vertically aligned.
10947 The following example  is typeset with \texttt{basewidth=2em}, and
10948 you'll see the leftmost ``\texttt{H}'' are not vertically aligned.
10949 \begin{lstlisting}[basewidth=2em, basicstyle=\tt,numbers=left]
10950 :H:
10951 :HHHH:
10952 \end{lstlisting}
10953
10954 \Pkg{lltjp-listing} adds the \texttt{doubleletterspace} key (not activated by default, for
10955 compatibility) to
10956 improve the situation, namely doubles inter-character space in each output unit.
10957 With this key, the above input now produces better output.
10958 \begin{lstlisting}[basewidth=2em, basicstyle=\tt,numbers=left, doubleletterspace]
10959 :H:
10960 :HHHH:
10961 \end{lstlisting}
10962 %</en>
10963 %<*ja>
10964 \paragraph{\texttt{doubleletterspace}キー}
10965 \Pkg{listings}パッケージで列揃えが \texttt{[c]fixed} となっている場合でも,
10966 場合によっては文字が縦に揃わない場合もある.
10967 例を以下に示そう.これは強調するために \texttt{basewidth=2em} を設定している.
10968 \begin{lstlisting}[basewidth=2em, basicstyle=\tt,numbers=left]
10969 :H:
10970 :HHHH:
10971 \end{lstlisting}
10972 1行目と2行目の「\texttt{H}」の位置が揃っていないが,
10973 これは出力単位ごとに,先頭・末尾・各文字間に同じ量の空白を挿入することによる.
10974
10975 \Pkg{lltjp-listing}では,このような症状を改善させるために \texttt{doubleletterspace} キー
10976 を追加した(標準では互換性のために無効になっている).このキーを有効にすると,
10977 出力単位中の各文字間の空白を2倍にすることで文字を揃いやすくしている.
10978 上と同じものを \texttt{doubleletterspace} キーを有効にして組んだものが以下であり,
10979 きちんと「\texttt{H}」の位置が揃っていることが分かる.
10980 \begin{lstlisting}[basewidth=2em, basicstyle=\tt,numbers=left, doubleletterspace]
10981 :H:
10982 :HHHH:
10983 \end{lstlisting}
10984 %</ja>
10985
10986 %<en>\subsection{Class of characters}
10987 %<ja>\subsection{文字種}
10988
10989 %<en>Roughly speaking, the \Pkg{listings} package processes input as follows:
10990 %<ja>\Pkg{listings} パッケージの内部では,大雑把に言うと
10991 \begin{enumerate}
10992 %<en>\item Collects \textit{letters} and \textit{digits}, which can be used for the name of identifiers.
10993 %<ja>\item 識別子として使える文字 (``letter'',~``digit'') たちを集める.
10994 %<en>\item When reading an \textit{other}, outputs the collected character string (with modification, if needed).
10995 %<ja>\item letterでもdigitでもない文字が現れた時に,収集した文字列を(必要なら修飾して)出力する.
10996 %<en>\item Collects \textit{others}.
10997 %<ja>\item 今度は逆に,letterでない文字たちをletterが現れるまで集める.
10998 %<en>\item When reading a \textit{letter} or a \textit{digit}, outputs the collected character string.
10999 %<ja>\item letterが出現したら集めた文字列を出力する.
11000 %<en>\item Turns back to 1.
11001 %<ja>\item 1.に戻る.
11002 \end{enumerate}
11003 %<*en>
11004 By the above process, line breaks inside of an identifier are blocked.
11005 A flag \verb+\lst@ifletter+ indicates whether the previous character can be used
11006 for the name of identifiers or not.
11007 %</en>
11008 %<*ja>
11009 という処理が行われている.これにより,識別子の途中では行分割が行われないようになっている.
11010 直前の文字が識別子として使えるか否かは \verb+\lst@ifletter+ というフラグに格納されている.
11011 %</ja>
11012
11013 %<*en>
11014 For Japanese characters, line breaks are permitted on both sides
11015 except for brackets, dashes, etc.
11016 Hence the patch \Pkg{lltjp-listings} introduces
11017 a new flag \verb+\lst@ifkanji+, which indicates
11018 whether the previous character is a Japanese character or not.
11019 For illustration, we introduce following classes of characters:
11020 %</en>
11021 %<*ja>
11022 さて,日本語の処理である.殆どの和文文字の前後では行分割が可能であるが,その一方で
11023 括弧類や音引きなどでは禁則処理が必要なことから,\Pkg{lltjp-listings} では,
11024 直前が和文文字であるかを示すフラグ \verb+\lst@ifkanji+ を新たに導入した.
11025 以降,説明のために以下のように文字を分類する:
11026 %</ja>
11027 %<*ja>
11028 \begin{center}
11029 \small
11030 \begin{tabular}{llllll}
11031 \toprule
11032 &\emph{Letter}&\emph{Other}&\emph{Kanji}&\emph{Open}&\emph{Close}\\\midrule
11033 \verb+\lst@ifletter+&T&F&T&F&T\\
11034 \verb+\lst@ifkanji+&F&F&T&T&F\\
11035 \emph{意図}&識別子中の文字&その他欧文文字&殆どの和文文字&開き括弧類&閉じ括弧類\\
11036 \bottomrule
11037 \end{tabular}
11038 \end{center}
11039 %</ja>
11040 %<*en>
11041 \begin{center}
11042 \small
11043 \begin{tabular}{llll}
11044 \toprule
11045 &\textbf{Letter}&\textbf{Other}&\\\midrule
11046 \verb+\lst@ifletter+&T&F&\\
11047 \verb+\lst@ifkanji+&F&F&\\
11048 \textbf{Meaning}&char in an identifier&other alphabet&\\
11049   \midrule
11050 &\textbf{Kanji}&\textbf{Open}&\textbf{Close}\\\midrule
11051 \verb+\lst@ifletter+&T&F&T\\
11052 \verb+\lst@ifkanji+&T&T&F\\
11053 \textbf{Meaning}&most of Japanese char&opening brackets&closing brackets\\
11054 \bottomrule
11055 \end{tabular}
11056 \end{center}
11057 %</en>
11058 %<*en>
11059 Note that \textit{digits} in the \Pkg{listings} package can be Letter or
11060 Other according to circumstances.
11061 %</en>
11062 %<*ja>
11063 なお,本来の\Pkg{listings} パッケージでの分類``digit''は,
11064 出現状況によって,上の表のLetterとOtherのどちらにもなりうる.
11065 また,KanjiとCloseは \verb+\lst@ifletter+ と \verb+\lst@ifkanji+ の値が一致しているが,
11066 これは間違いではない.
11067 %</ja>
11068
11069 %<*en>
11070 For example, let us consider the case an Open comes after a Letter.
11071 Since an Open represents Japanese open brackets,
11072 it is preferred to be permitted to insert line break after the Letter.
11073 Therefore, the collected character string is output in this case.
11074 %</en>
11075 %<*ja>
11076 例えば,Letterの直後にOpenが来た場合を考える.
11077 文字種Openは和文開き括弧類を想定しているので,Letterの直後では行分割が可能であることが望ましい.
11078 そのため,この場合では,すでに収集されている文字列を出力することで行分割を許容するようにした.
11079 %</ja>
11080
11081 %<*en>
11082 The following table summarizes $5\times 5=25$ cases:
11083 %</en>
11084 %<*ja>
11085 同じように,$5\times 5=25$通り全てについて書くと,次のようになる:
11086 %</ja>
11087 \begin{center}
11088 \small
11089 \begin{tabular}{lllllll}
11090 \toprule
11091 %<*en>
11092 &&\multicolumn{4}{c}{\textbf{Next}}\\\cmidrule(lr){3-7}
11093 &&\hbox to 4em{Letter\hss}&\hbox to 4em{Other\hss}
11094 &\hbox to 4em{Kanji\hss}&\hbox to 4em{Open\hss}&Close\\\midrule
11095 &Letter&collects&\multicolumn{3}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
11096 &Other&outputs&collects&\multicolumn{2}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
11097 \textbf{Prev}&Kanji&\multicolumn{4}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
11098 &Open&\multicolumn{5}{c}{\hrulefill \ collects\ \hrulefill}\\
11099 &Close&\multicolumn{4}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
11100 %</en>
11101 %<*ja>
11102 &&\multicolumn{4}{c}{\textbf{後側文字種}}\\\cmidrule(lr){3-7}
11103 &&\hbox to 4em{Letter\hss}&\hbox to 4em{Other\hss}
11104 &\hbox to 4em{Kanji\hss}&\hbox to 4em{Open\hss}&Close\\\midrule
11105 \emph{直}&Letter&収集&\multicolumn{3}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
11106 \emph{前}&Other&出力&収集&\multicolumn{2}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
11107 \emph{文}&Kanji&\multicolumn{4}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
11108 \emph{字}&Open&\multicolumn{5}{c}{\hrulefill \ 収集\ \hrulefill}\\
11109 \emph{種}&Close&\multicolumn{4}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
11110 %</ja>
11111 \bottomrule
11112 \end{tabular}
11113 \end{center}
11114 %<en>In the above table,
11115 %<ja>上の表において,
11116 \begin{itemize}
11117 %<en>\item ``outputs'' means to output the collected character string (i.e., line breaking is permitted there).
11118 %<ja>\item 「出力」は,それまでに集めた文字列を出力(≒ここで行分割可能)を意味する.
11119
11120 %<en>\item ``collects'' means to append the next character to the collected character string (i.e., line breaking is prohibited there).
11121 %<ja>\item 「収集」は,後側の文字を,現在収集された文字列に追加(行分割不可)を意味する.
11122 \end{itemize}
11123
11124 %<*en>
11125 Characters above or equal to~\texttt{U+0080} \emph{except Variation Selectors}
11126 are classified into above 5~classes by the following rules:
11127 %</en>
11128 %<*ja>
11129 \texttt{U+0080}以降の\emph{異体字セレクタ以外の}各文字が
11130 Letter, Other, Kanji, Open, Closeのどれに属するかは次によって決まる:
11131 %</ja>
11132 \begin{itemize}
11133 %<en>\item \textbf{ALchar}s above or equal to~\texttt{U+0080} are classified as Letter.
11134 %<ja>\item \<(\texttt{U+0080}以降の)\textbf{ALchar}は,すべてLetter扱いである.
11135
11136 %<en>\item \textbf{JAchar}s are classified in the order as follows:
11137 %<ja>\item \textbf{JAchar}については,以下の順序に従って文字種を決める:
11138 \begin{enumerate}
11139 %<en>\item Characters whose \Param{prebreakpenalty} is greater than or equal to 0 are classified as Open.
11140 %<ja>\item \Param{prebreakpenalty}が0以上の文字はOpen扱いである.
11141
11142 %<en>\item Characters whose \Param{postbreakpenalty} is greater than or equal to 0 are classified as Close.
11143 %<ja>\item \Param{postbreakpenalty}が0以上の文字はClose扱いである.
11144
11145 %<en>\item Characters that don't satisfy the above two conditions are classified as Kanji.
11146 %<ja>\item 上の3条件のどちらにも当てはまらなかった文字は,Kanji扱いである.
11147 \end{enumerate}
11148 \end{itemize}
11149
11150 %<*en>
11151 The width of halfwidth kana (\texttt{U+FF61}--\texttt{U+FF9F})
11152 is same as the width of \textbf{ALchar};
11153 the width of the other \textbf{JAchar}s is double the width of \textbf{ALchar}.
11154 %</en>
11155 %<*ja>
11156 なお,半角カナ(U+FF61--U+FF9F)以外の\textbf{JAchar}は欧文文字2文字分の幅をとるものとみなされる.
11157 半角カナは欧文文字1文字分の幅となる.
11158 %</ja>
11159
11160 %<*en>
11161 This classification process is executed every time a character appears in
11162 the \texttt{lstlisting} environment or other environments/commands.
11163 %</en>
11164 %<*ja>
11165 これらの文字種決定は,実際に \texttt{lstlisting} 環境などの内部で文字が出てくるたびに行われる.
11166 %</ja>
11167
11168 %<*ja>
11169 \section{和文の行長補正方法}
11170 \label{sec-adjspec}
11171 \Pkg{luatexja-adjust}で提供される優先順位付きの行長調整の詳細を大まかに述べると,次のようになる.
11172 \begin{itemize}
11173 \item (\texttt{lineend=extended}の場合)\textbf{JAglue}の挿入処理のところで,
11174   ……
11175 \item 通常の\TeX の行分割方法に従って,段落を行分割する.この段階では,行
11176       長に半端が出た場合,その半端分は\textbf{JAglue}(\Param{xkanjiskip},
11177       \Param{kanjiskip},JFMグルー)と
11178       それ以外のグルーの全てで(優先順位なく)負担される.
11179 \item その後,\texttt{post\_linebreak\_filter} callbackを使い,\emph{段
11180       落中の各行ごとに},行末文字の位置を調整(\texttt{lineend=true}の場合)したり,優先度付きの行長調整
11181       を実現するためにグルーの伸縮度を調整する.
11182       その処理においては,グルーの自然長と\textbf{JAglue}以外の
11183       グルーの伸び量・縮み量は変更せず,必要に応じて\textbf{JAglue}の伸び量・縮み量のみを
11184       変更する設計とした.
11185 \end{itemize}
11186 この章の残りでは各処理について解説する.
11187
11188 \paragraph{準備:合計伸縮量の計算}
11189 グルーの伸縮度(\texttt{plus} や \texttt{minus} で指定されている値)には,
11190 有限値の他に,\texttt{fi},\texttt{fil},\texttt{fill},\texttt{filll}と
11191 いう4つの無限大レベル(後ろの方ほど大きい)がある.行の調整に
11192 \texttt{fi} などの\emph{無限大レベルの伸縮度が用いられている行では,
11193 「行末文字の位置調整」のみ行い,「グルーの調整」は行わない.}
11194
11195 まず,段落中の行中のグルーを
11196 \begin{itemize}
11197 \item \textbf{JAglue}ではないグルー
11198 \item JFMグルー(優先度\footnote{%
11199   \ref{ssec:jfm-str}節にあるように,
11200   各JFMグルーには$-4$から3までの優先度がついている.場合によっては
11201   伸びと縮みで異なる優先度が付いているかもしれない.}%
11202 別にまとめられる)
11203 \item 和欧文間空白(\Param{xkanjiskip})
11204 \item 和文間空白(\Param{kanjiskip})
11205 \end{itemize}
11206 の$1+1+8+1=10$つに類別する.
11207 そして許容されている伸び量(\texttt{stretch}の値)の合計を
11208 無限のレベルごとに
11209 \begin{align*}
11210  T^{+}_{l}&:= \sum_{\text{$\texttt{stretch\_order}(p) = l$}} \texttt{stretch}(p),&
11211  l\in \{\text{(finite)}, \texttt{fi}, \texttt{fil}, \texttt{fill}, \texttt{filll}\}
11212 \end{align*}
11213 と計算する.さらに,
11214 \begin{align*}
11215 T^{+}&:=T^{+}_{L^+},&L^{+} = \max \{l\in
11216  \{\text{(finite)}, \texttt{fi}, \texttt{fil}, \texttt{fill}, \texttt{filll}\}:
11217  T^{+}_l\neq 0\}
11218 \end{align*}
11219 とおく.有限の伸び量については,上記の8種類の類別ごとにも合計を計算する.
11220 さらに縮み量(\texttt{shrink}の値)についても同様の処理を行い,$T^{-}$を計算する.
11221
11222 また,行長から自然長を引いた値を\textit{total}とおく.
11223
11224 \subsection{行末文字の位置調整(行分割後の場合)}
11225 行末が\textbf{JAchar}であり,この文字の属する文字クラスでは
11226 \begin{quote}
11227   \texttt{end\_adjust = \{$a_{1}$, $a_{2}$, ..., $a_{n}$\}}
11228 \end{quote}
11229 であったとする.
11230 このとき,以下の条件を満たした場合,
11231 この文字クラスに対する\texttt{end\_adjust}の値のいずれかだけこの文字の位置を移動させる.
11232 \begin{description}
11233   \item[最終行以外] 行長調整に無限大の伸縮度が用いられていない.
11234   すなわち,$\textit{total}>0$ならば$L^{+}=(\text{finite})$であり,
11235   $\textit{total}>0$ならば$L^{-}=(\text{finite})$である.
11236   \item[最終行] 行長調整に無限大に伸び縮みするグルーが用いられたなら,それは\cs{parfillskip}のみであり,
11237     かつ,次の不等式が成立する:
11238   \[
11239    \min\{0,a_{1}\}\text{\cs{zw}}\leq (\text{\cs{parfillskip}の実際の長さ}) \leq \max\{0,a_{n}\}\text{\cs{zw}}
11240   \]
11241 \end{description}
11242
11243 各$1\leq i\leq n$に対して,
11244 「行末に$a_{i}$全角だけのカーンを追加した時の,\textit{glue\_set}の値」を
11245 $b_{i}$とおく.式で書くと,
11246 \[
11247 b_{i} = \begin{dcases*}
11248   \frac{\lvert\textit{total}-a_{i}\text{\cs{zw}}\rvert}{T^{+}}
11249           &($\textit{total}-a_{i}\text{\cs{zw}}\geq 0$),\\
11250   \frac{\lvert\textit{total}-a_{i}\text{\cs{zw}}\rvert}{T^{-}}
11251           &($\textit{total}-a_{i}\text{\cs{zw}}<0$).
11252 \end{dcases*}
11253 \]
11254 $b_{i}$達の最小値を与えるような$i$を$j$としたとき\footnote{%
11255   そのような$i$が2つ以上あるときは,$|\textit{total}-a_{i}\cdot \text{\cs{zw}}|$,
11256   $|a_{i}|$, $a_i$の順で比較して一番小さくなるものが選ばれる.
11257 },
11258 行末に大きさ$a_{j}$のカーンを追加する.
11259 \textit{total}から$a_{j}$全角の大きさだけ引いておく.
11260
11261 \subsection{行末文字の位置調整(行分割での考慮)}
11262 \texttt{lineend=extended}が指定されている場合,\TeX による行分割が行われる前に
11263 各\textbf{JAchar}の直後に,その文字が行末に来たときの位置補正用のノードを挿入していく.
11264
11265 \ref{sec-jfmglue}章の用語を使って述べる.
11266 前側のクラスタ\textit{Nq}が「和文A」「和文B」であり,
11267 JFMによって\texttt{end\_adjust}の値が
11268 \begin{quote}
11269   \texttt{end\_adjust = \{$a_{1}$, $a_{2}$, ..., $a_{n}$\}}
11270 \end{quote}
11271 であったとする.このとき,次のクラスタ\textit{Np}の直前に以下のノード列を挿入する.
11272 \textbf{JAglue}の挿入過程で禁則処理のために「\textit{Nq}と\textit{Np}の間のペナルティ値を増やす」ことが
11273 行われることがあるが,以下で述べられている$(n+1)$個のペナルティはみなその処理対象になっている.
11274 \begin{align*}
11275   \Node{kern}{$a_{1}\text{\cs{zw}}$}
11276   &\longrightarrow \Node{penalty}{$0$} \longrightarrow\Node{kern}{$(a_{2}-a_{1})\text{\cs{zw}}$}
11277   \longrightarrow \Node{penalty}{$0$} \longrightarrow\Node{kern}{$(a_{3}-a_{2})\text{\cs{zw}}$}\\
11278   &\longrightarrow
11279   \cdots \longrightarrow\Node{penalty}{$0$} \longrightarrow
11280   \Node{kern}{$(a_{n}-a_{n-1})\text{\cs{zw}}$}
11281   \longrightarrow \Node{penalty}{$0$} \longrightarrow
11282   \Node{kern}{$-a_{n}\text{\cs{zw}}$} \longrightarrow \Node{penalty}{$10000$}
11283 \end{align*}
11284 $n$個あるペナルティの箇所が改行可能箇所である.いずれかで改行された場合は,
11285 その前にあるカーン($n$箇所のうちどこで改行しても,合計の長さは$a_{i}$の形)は行末に残るが,
11286 後ろのペナルティ・カーンは除去される.なお,$a_1=0$のときは最初の幅が$a_{1}\text{\cs{zw}}$のカーンは不要なので挿入されず,
11287 さらにかつ$n=1$であった場合は後ろのペナルティも挿入されない.
11288
11289 なお,段落の末尾には\cs{penalty10000}と\cs{parfillskip}由来のグルーが自動的に入るが,
11290 これらとの兼ね合いのため\emph{最後のクラスタについては上記のノード挿入処理は行われない}.
11291 段落最終行の行末文字の位置調整は,すでに述べた「行分割後の場合」における最終行の処理をそのまま用いている.
11292
11293 \subsection{グルーの調整}
11294 $|\textit{total}|$の分だけが,行中のグルーの伸び量,あるいは縮み量に応じて負担されることになる.
11295 以下,$\textit{total}\geq 0$であると仮定して話を進めるが,負のときも同様である.
11296 \Pkg{luatexja-adjust}の初期値では以下の順に伸び量を負担するようになっており,
11297 (優先度$-4$のJFMグルーは例外として)できるだけ\Param{kanjiskip}を自然長のままにすることを
11298 試みている.この順番は\Param{stretch\_priority}(縮み量については\Param{shrink\_priority})
11299 パラメータで変更可能である.
11300 \begin{enumerate}\def\labelenumi{(\Alph{enumi})}
11301  \item \textbf{JAglue}以外のグルー
11302  \item 優先度3のJFMグルー
11303  \item 優先度2のJFMグルー
11304  \item 優先度1のJFMグルー
11305  \item 優先度0のJFMグルー
11306  \item 優先度$-1$のJFMグルー
11307  \item 優先度$-2$のJFMグルー
11308  \item \Param{xkanjiskip}
11309  \item 優先度$-3$のJFMグルー
11310  \item \Param{kanjiskip}
11311  \item 優先度$-4$のJFMグルー
11312 \end{enumerate}
11313 \begin{enumerate}
11314  \item 行末の\textbf{JAchar}を移動したことで$\textit{total}=0$となれば,
11315 調整の必要はなく,行が格納されているhboxの
11316 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算すればよい.
11317 以降,$\textit{total}\neq 0$と仮定する.
11318  \item \textit{total}が「\textbf{JAglue}以外のグルーの伸び量の合計」(以下,(A)の伸び量の
11319        合計,と称す)よりも小さければ,
11320 それらのグルーに\textit{total}を負担させ,\textbf{JAglue}達自身は自然長で組むことができる.
11321 よって,以下の処理を行う:
11322 \begin{enumerate}
11323 \item 各\textbf{JAglue}の伸び量を0とする.
11324 \item 行が格納されているhboxの
11325 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算する.
11326 これによって,\textit{total}は\textbf{JAglue}以外のグルーによって負担される.
11327 \end{enumerate}
11328 \item \textit{total}が「(A)の伸び量の合計」以上ならば,(A)--(K)のどこまで負担すれば
11329 \textit{total}以上になるかを計算する.
11330 例えば,
11331 \[
11332  \textit{total} = (\text{(A)--(B)の伸び量の合計}) + p\cdot (\text{(C)の伸び量の合計}),
11333  \qquad 0\le p<1
11334 \]
11335 であった場合,各グルーは次のように組まれる:
11336 \begin{itemize}
11337  \item (A),~(B)に属するグルーは各グルーで許された伸び量まで伸ばす.
11338  \item (C)に属するグルーはそれぞれ$p\times (\text{伸び量})$だけ伸びる.
11339  \item (D)--(K)に属するグルーは自然長のまま.
11340 \end{itemize}
11341 実際には,前に述べた「設計」に従い,次のように処理している:
11342 \begin{enumerate}
11343 \item (C)に属するグルーの伸び量を$p$倍する.
11344 \item (D)--(K)に属するグルーの伸び量を0とする.
11345 \item 行が格納されているhboxの
11346 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算する.
11347 これによって,\textit{total}は\textbf{JAglue}以外のグルーによって負担される.
11348 \end{enumerate}
11349 \item \textit{total}が(A)--(K)の伸び量の合計よりも大きい場合,どうしようもないので
11350       \verb+^^;+何もしない.
11351 \end{enumerate}
11352
11353 %</ja>
11354
11355 %<*ja>
11356 \section{複数フォントの「合成」(未完)}
11357 \section{\LuaTeX-jaにおけるキャッシュ}
11358 \Pkg{luaotfload}パッケージが,各TrueType・OpenTypeフォントの情報を
11359 キャッシュとして保存しているのと同様の方法で,
11360 \LuaTeX-jaもいくつかのキャッシュファイルを作成するようになった.
11361 \begin{itemize}
11362  \item 通常,キャッシュは \texttt{\$TEXMFVAR/luatexja/} 以下に保存され,
11363 そこから読み込みが行われる.
11364  \item 「通常の」テキスト形式のキャッシュ(拡張子は \texttt{.lua.gz},gzip圧縮されているため)以外にも,
11365 それをバイナリ形式(バイトコード)に変換したものもサポートしている.
11366 \begin{itemize}
11367  \item キャッシュを読み込む時,同名のバイナリキャッシュがあれば,
11368 テキスト形式のものよりそちらを優先して読み込む.
11369  \item テキスト形式のキャッシュが更新/作成される際は,そのバイナリ版も
11370 同時に更新される.
11371 また,(バイナリ版が見つからず)テキスト形式のキャッシュ側が読み込まれたときは,
11372 \LuaTeX-jaはバイナリキャッシュを作成する.
11373 未圧縮のテキスト形式のキャッシュ(\texttt{hoge.lua})は20200802.0以降では利用しない.
11374 \end{itemize}
11375 \end{itemize}
11376 %</ja>
11377 %<*en>
11378 \section{Cache Management of \LuaTeX-ja}
11379 \LuaTeX-ja creates some cache files to reduce the loading time.
11380 in a similar way to the \Pkg{luaotfload} package:
11381 \begin{itemize}
11382  \item Cache files are usually stored in (and loaded from)
11383 \texttt{\$TEXMFVAR/luatexja/}.
11384  \item In addition to caches of the text form (the extension is ``\texttt{.lua.gz}'',
11385 because they are compressed by gzip),
11386 caches of the \emph{binary}~(bytecode) form are supported.
11387 \begin{itemize}
11388  \item In loading a cache, the binary cache precedes
11389 the text form.
11390  \item When \LuaTeX-ja updates a compressed text cache \texttt{hoge.lua.gz},
11391 its binary version is also updated.
11392 \end{itemize}
11393 \end{itemize}
11394 %</en>
11395
11396 %<*ja>
11397 \subsection{キャッシュの使用箇所}
11398
11399 \LuaTeX-ja では以下のキャッシュを使用している:
11400 \begin{cslist}
11401 \item[ltj-cid-auto-adobe-japan1.\{lua.gz,luc\}]
11402 Ryumin-Lightのような非埋め込みフォントの情報を格納しており,
11403 (それらが\LuaTeX-jaの標準和文フォントなので)\LuaTeX-jaの読み込み時に自動で読まれる.
11404 生成には\texttt{UniJIS2004-UTF32-\{H,V\}}, \texttt{Adobe-Japan1-UCS2}という3つの
11405 CMapが必要である.
11406
11407 \pageref{para-cid}ページで述べたように,\texttt{cid}キーを使って
11408 非埋め込みの中国語・韓国語フォントを定義する場合,同様のキャッシュが生成される.
11409 キャッシュの名称,必要となるCMapについては\autoref{tab:cid-cache}を参照して欲しい.
11410 %</ja>
11411 %<*en>
11412 \subsection{Use of cache}
11413
11414 \LuaTeX-ja uses the following cache:
11415 \begin{cslist}
11416 \item[ltj-cid-auto-adobe-japan1.\{lua.gz,luc\}]
11417 The font table of a CID-keyed non-embedded Japanese font.
11418 This is loaded in every run.
11419 It is created from three CMaps, \texttt{UniJIS2004-UTF32-\{H,V\}} and
11420              \texttt{Adobe-Japan1-UCS2},
11421 and this is why these two CMaps are needed in the first run of \LuaTeX-ja.
11422
11423 Similar caches are created as \autoref{tab:cid-cache},
11424 if you specified \texttt{cid} key in \cs{jfont}
11425 to use other CID-keyed non-embedded fonts for Chinese or Korean,
11426 as in Page~\pageref{para-cid}.
11427 %</en>
11428
11429 \begin{table}[!tb]
11430  \centering\small
11431 \caption{\texttt{cid} key and corresponding files}
11432 \label{tab:cid-cache}
11433 \vspace*{\medskipamount}
11434 \begin{tabular}{>{\tt}l>{\tt}l>{\tt}l>{\tt}l}
11435 \toprule
11436 \bf \texttt{cid} key&\bf name of the cache &
11437 \multicolumn{2}{c}{\bf used CMaps}\\
11438 \midrule
11439 Adobe-Japan1-*&ltj-cid-auto-adobe-japan1.\{lua.gz,luc\}&UniJIS2004-UTF32-*&Adobe-Japan1-UCS2\\
11440 Adobe-Korea1-*&ltj-cid-auto-adobe-korea1.\{lua.gz,luc\}&UniKS-UTF32-*&Adobe-Korea1-UCS2\\
11441 Adobe-KR-*&ltj-cid-auto-adobe-kr.\{lua.gz,luc\}&UniAKR-UTF32-*&Adobe-KR-UCS2\\
11442 Adobe-GB1-*&ltj-cid-auto-adobe-gb1.\{lua.gz,luc\}&UniGB-UTF32-*&Adobe-GB1-UCS2\\
11443 Adobe-CNS1-*&ltj-cid-auto-adobe-cns1.\{lua.gz,luc\}&UniCNS-UTF32-*&Adobe-CNS1-UCS2\\
11444 \bottomrule
11445 \end{tabular}
11446 \end{table}
11447
11448 %<*ja>
11449 \item[ltj-kinsoku\_default.\{lua.gz,luc\}]
11450 禁則処理,\Param{kansujichar}などの標準設定が格納されたファイルである.
11451 %</ja>
11452 %<*en>
11453 \item[ltj-kinsoku.luc]
11454 The bytecode cache which default \textit{kinsoku} parameters are stored.
11455 %</en>
11456
11457 %<*ja>
11458 \item[ltj-jisx0208.luc]
11459 \LuaTeX-ja配布中の\texttt{ltj-jisx0208.lua}をバイトコード化したものである.
11460 これはJIS~X~0208とUnicodeとの変換テーブルであり,
11461 \pTeX との互換目的の文字コード変換命令で用いられる.
11462 %</ja>
11463 %<*en>
11464 \item[ltj-jisx0208.luc]
11465 The bytecode version of \texttt{ltj-jisx0208.lua}.
11466 This is the conversion table between JIS~X~0208 and Unicode
11467 which is used in Kanji-code conversion commands for compatibility with \pTeX.
11468 %</en>
11469
11470 %<*ja>
11471 \item[ltj-ivd\_aj1.luc]
11472 \LuaTeX-ja配布中の\texttt{ltj-ivd\_aj1.lua}をバイトコード化したものである.
11473 これはUnicodeの漢字異体字データベースのAdobe-Japan1コレクションの内容を
11474   格納したテーブルであり,\Pkg{luatexja-otf}パッケージの\cs{CID}命令で使われることがある.
11475 %</ja>
11476 %<*en>
11477 \item[ltj-ivd\_aj1.luc]
11478 The bytecode version of \texttt{ltj-ivd\_aj1.lua}.
11479 %</en>
11480
11481 %<*ja>
11482 \item[extra\_***.\{lua.gz,luc\}]
11483 フォント``\texttt{***}''における,グリフ番号からUnicode値への変換テーブル,縦組時のグリフ回転の有無を格納したテーブル,
11484 及び縦組時におけるグリフの原点位置・高さのテーブルを格納している.
11485 %</ja>
11486 %<*en>
11487 \item[extra\_***.\{lua.gz,luc\}]
11488 This file conains some information (especially for vertical typesetting) about the font `\texttt{***}''.
11489 %</en>
11490 \end{cslist}
11491
11492 %<*en>
11493 \subsection{Internal}
11494 Cache management system of \LuaTeX-ja is stored in \texttt{luatexja.base}
11495 (\texttt{ltj-base.lua}).
11496 There are four public functions for cache management in \texttt{luatexja.base},
11497 where \meta{filename} stands for the file name \emph{without suffix}:
11498 \begin{cslist}
11499 \item[save\_cache(\meta{filename}, \meta{data})]
11500 Save a non-nil table \meta{data} into a cache \meta{filename}.
11501 Both the compressed text form \meta{filename}\texttt{.lua.gz} and its binary version
11502 are created or updated.
11503
11504 \item[save\_cache\_luc(\meta{filename}, \meta{data}{[, \meta{serialized\_data}]})]
11505
11506 Same as \texttt{save\_cache}, except that only the binary cache is updated.
11507 The third argument \meta{serialized\_data} is not usually given.
11508 But if this is given, it is treated as a string representation of \meta{data}.
11509
11510 \item[load\_cache(\meta{filename}, \meta{outdate})]
11511 Load the cache \meta{filename}.
11512 \meta{outdate} is a function which takes one argument (the contents of the cache),
11513 and its return value is whether the cache is outdated.
11514
11515 \texttt{load\_cache} first tries to
11516 read the binary cache \meta{filename}\texttt{.luc}.
11517 If its contents is up-to-date, \texttt{load\_cache} returns the contents.
11518 If the binary cache is not found or
11519 its contents is outdated, \texttt{load\_cache} tries to
11520 read the compressed text form \meta{filename}\texttt{.lua.gz}.
11521 Hence, the return value of \texttt{load\_cache} is non-nil,
11522 if and only if the updated cache is found.
11523
11524 \item[remove\_cache(\meta{filename})]
11525 Remove the cahce \meta{filename}.
11526 \end{cslist}
11527 %</en>
11528 %<*ja>
11529 \subsection{内部命令}
11530 \LuaTeX-jaにおけるキャッシュ管理は,\texttt{luatexja.base}~(\texttt{ltj-base.lua})に
11531 実装しており,以下の関数が公開されている.
11532 ここで,\meta{filename}は保存するキャッシュのファイル名を\emph{拡張子なしで}指定する.
11533 \begin{cslist}
11534 \item[save\_cache(\meta{filename}, \meta{data})]
11535 nilでない\meta{data}をキャッシュ\meta{filename}に保存する.
11536 テキスト形式の\meta{filename}\texttt{.lua.gz}\footnote{拡張子からわかる通り,実際にはgzip圧縮される.}のみならず,
11537 そのバイナリ形式も作成・更新される.
11538
11539 \item[save\_cache\_luc(\meta{filename}, \meta{data}{[, \meta{serialized\_data}]})]
11540
11541 \texttt{save\_cache}と同様だが,バイナリキャッシュのみが更新される.
11542 第3引数\meta{serialized\_data}が与えられた場合,それを
11543 \meta{data}の文字列化表現として使用する.
11544 そのため,\meta{serialized\_data}は普通は指定しないことになるだろう.
11545
11546 \item[load\_cache(\meta{filename}, \meta{outdate})]
11547 キャッシュ\meta{filename}を読み込む.
11548 \meta{outdate}は1引数(キャッシュの中身)をとる関数であり,
11549 その戻り値は「キャッシュの更新が必要」かどうかを示すブール値でないといけない.
11550
11551 \texttt{load\_cache}は,まずバイナリキャッシュ\meta{filename}\texttt{.luc}を
11552 読みこむ.もしその内容が「新しい」,つまり\meta{outdate}の評価結果が \texttt{false} なら
11553 \texttt{load\_cache}はこのバイナリキャッシュの中身を返す.
11554 もしバイナリキャッシュが見つからなかったか,「古すぎる」ならば(gzip圧縮された)テキスト形式の
11555              \meta{filename}\texttt{.lua.gz}を読み込み,\meta{outdate}で再度評価する.
11556
11557 以上より,\texttt{load\_cache}自体がnilでない値を返すのは,ちょうど「新しい」キャッシュが
11558 見つかった場合である.
11559
11560 \item[remove\_cache(\meta{filename})]
11561 キャッシュ\meta{filename}を削除する.テキスト形式(gzip圧縮されているか否かを問わず)も
11562 バイナリ形式もまとめて削除する.
11563 \end{cslist}
11564 %</ja>
11565
11566
11567 %<*ja>
11568 \section{縦組の実装}
11569 \label{sec-dir-imp}
11570 \ref{sec-direction}章の最初でも述べたように,
11571 \LuaTeX-jaは横組(\texttt{TLT})で組んだボックスを回転させる方式で
11572 縦組を実装している.
11573
11574 \LuaTeX-jaにおける縦組の実装は
11575 \pTeX における実装(\cite{ptexdoc,ptextug})をベースにしている.
11576
11577 \subsection{direction~whatsit}
11578 \textit{direction}~whatsitとは,\textit{direction}という特定の \verb+user_id+ を持つ
11579 whatsitのことであり,以下のタイミングで作られる.
11580 \begin{itemize}
11581  \item 組方向を \cs{tate} 等で変更したとき.
11582  \item \cs{hbox}, \cs{vbox}, \cs{vtop} による明示的なボックスの開始時.\\
11583 \verb+\hbox{}+, \verb+\vbox{}+ といった,
11584 \begin{itemize}
11585  \item \cs{tate} 等によりボックス内部の組方向を変更していない
11586  \item ボックスの中身のリストが空である
11587 \end{itemize}
11588 場合は,\LuaTeX の \verb+hpack_filter+, \verb+vpack_filter+ といった
11589 callbackに処理が回らない.そこで,\LuaTeX-ja では,\cs{everyhbox}, \cs{everyvbox} を利用す
11590        ることで各ボックスの先頭に確実に追加するようにしている\footnote{%
11591   問題は \cs{hbox to 25pt\{\}} という状況である.実際のこのボックスの中身は空でない(少な
11592        くともdirection whatsitがある)ため,何も対策をしなければhpack時にUnderfill警告が発
11593        生してしまうことになる.\LuaTeX-jaではそうならないように「\cs{hbadness},
11594        \cs{vbadness} を一時的に10000に変更し,hpack, vpack後に元の値に戻す」処理を行ってい
11595        る.
11596 }.
11597  \item \cs{vsplit}によってvboxを分割した時の「残り」の先頭.
11598  \item \LuaTeX-ja読み込み前に作成したボックスの寸法を \cs{ltjsetwd} 等によって変更した時.
11599  \item \cs{insert} によるinsertionでは,中身の先頭に\textit{direction}~whatsitは作られず,
11600 その代わりに中身の各ボックス・罫線の直前に作られる\footnote{%
11601  これは,ページ分割の過程でinsertionが分割される時,「現在のページで出力される部分」が空と
11602        なることがあることによる.先頭にwhatsitを置くと,最悪でも「現在のページにwhatsitが
11603        残る」ことになってしまう.}.
11604 \end{itemize}
11605 なお,\verb+\vtop{...}+ の場合は,先頭にdirection whatsitを置くと
11606 ボックスの高さが常に0\,ptになるという問題が発生する.そのため,この場合に限っては
11607 vpack時にdirection whatsitをリストの2番目に移動させている.
11608
11609 direction whatsitはあくまでも組方向処理のための補助的なノードであるので,
11610 \cs{unhbox}, \cs{unhcopy} によってボックスの中身が展開される時には展開直前に削除される.
11611 これは
11612 \begin{lstlisting}
11613  % yoko direction
11614 \setbox0=\hbox{\tate B}
11615 \noindent % 水平モードに入る.この時点でのリストの中身は空
11616 \unhbox0 A
11617 \end{lstlisting}
11618 といった場合に,段落が縦組で組まれたり,あるいは
11619 \begin{lstlisting}
11620 \setbox0=\hbox{}
11621 \leavevmode \hbox{A}\unhbox0
11622 \setbox1=\lastbox % \box1 はどうなる?
11623 \end{lstlisting}
11624 で \cs{box1} が \cs{hbox\{A\}} でなく空になってしまうことを防ぐためである.
11625
11626
11627 \subsection{\textit{dir\_box}}
11628 縦中横など異方向のボックスを配置する場合に,周囲の組方向と大きさを整合させるため,
11629 \LuaTeX-jaでは \verb+\ltj@dir+ が128以降の\textit{hlist\_node}, \textit{vlist\_node}を
11630 用いる.これらは\pTeX における\textit{dir\_node}の役割と同じ果たしており,
11631 この文章中では\textit{dir\_box}と呼称する.
11632
11633 \subsubsection{異方向のボックスの整合}
11634 \textit{dir\_box}の第一の使用目的は,異方向のボックスの大きさを整合させることである.
11635 例えば,
11636 \begin{lstlisting}
11637  % yoko direction
11638 平成\hbox{\tate 26}年
11639 \end{lstlisting}
11640 は段落中で
11641 \[
11642  \xymatrix{
11643    {}\Node{glyph}{`平'}\ar[r]&{}\Node{glyph}{`成'}\ar[r]&
11644    {}\HNode{hbox}{10.00003}{3.02779}{0.0}\ar[r]\ar[d]^{\text{中身}}&{}\Node{glyph}{`年'}\\
11645    &&{}\Node{whatsit}{\cs{tate}}\ar[r]&{}\Node{glyph}{`2'}\ar[r]&{}\Node{glyph}{`6'}
11646  }
11647 \]
11648 というリストを作る.その後,この段落が終了したときに,
11649 \LuaTeX-jaの\textbf{JAglue}挿入処理が行われ
11650 \[
11651  \xymatrix{
11652    {}\Node{glyph}{`平'}\ar[r]
11653   &{}\textcolor{blue}{\Node{glue}{\Param{xkanjiskip}}}\ar[r]
11654   &{}\Node{glyph}{`成'}\ar[r]
11655   &{}\textcolor{blue}{\Node{penalty}{0}}
11656     \ar`r[d] `[l] `[ddll] `[dl] [dl]
11657   \\
11658   &&{}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{yoko})}{3.02779}{10.00003}{0.0}}\ar[r]\ar[d]^{\text{中身}}
11659   &{}\textcolor{blue}{\Node{penalty}{0}}\ar[r]
11660   &{}\Node{glyph}{`年'}\\
11661   &&{}\HNode{hbox}{10.00003}{3.02779}{0.0}\ar[d]^{\text{中身}}\\
11662   &&{}\Node{whatsit}{\cs{tate}}\ar[r]&{}\Node{glyph}{`2'}\ar[r]&{}\Node{glyph}{`6'}
11663  }
11664 \]
11665 のようになる(青字は\textbf{JAglue},赤字が整合処理のための\textit{dir\_box}である).
11666 \TeX の \cs{showbox} 形式で書けば
11667
11668 \medskip{\narrowbaselines\ttfamily\obeylines\parindent0pt
11669 \catcode`\@=0 @catcode`@\=12
11670 .\tenmin 平
11671 @textcolor{blue}{.\glue 0.0 plus 0.4 minus 0.4}
11672 .\tenmin 成
11673 @textcolor{blue}{.\penalty 0}
11674 @textcolor{red}{.\hbox(10.00003+0.0)x3.02779, direction TLT}
11675 ..\hbox(3.02779+0.0)x10.00003, direction TLT
11676 ...\whatsit4=[]
11677 ...\tenrm 2
11678 ...\tenrm 6
11679 @textcolor{blue}{.\penalty 0}
11680 .\tenmin 年
11681 }\medskip
11682
11683 \noindent である.
11684
11685 なお,\cs{raise},~\cs{lower}, \cs{moveleft},~\cs{moveright} といったボックス移動命令では.
11686 移動を正しく表現するために段落やボックスの途中でも異方向のボックスは\textit{dir\_box}にカ
11687 プセル化している.
11688 例えば
11689 \begin{lstlisting}
11690  % yoko direction
11691 平成\raise1pt\hbox{\tate 26}年\showlists
11692 \end{lstlisting}
11693 は以下のような結果を得る.
11694
11695 \medskip{\narrowbaselines\ttfamily\obeylines\parindent0pt
11696 \catcode`\@=0 @catcode`@\=12
11697 (前略)
11698 \tenrm 平
11699 \tenrm 成
11700 @textcolor{red}{\hbox(10.00003+0.0)x3.02779, shifted -1.0, direction TLT}
11701 .\hbox(3.02779+0.0)x10.00003, direction TLT
11702 ..\whatsit4=[]
11703 ..\tenrm 2
11704 ..\tenrm 6
11705 \tenrm 年
11706 }\medskip
11707
11708 また,メインの垂直リストに異方向のボックスが追加される場合にも同様に即座に
11709 \textit{dir\_box}にカプセル化している.ページ分割のタイミングを正
11710 しく\TeX が判断するためである.
11711 \cs{lastbox} によるボックスの取得では,\textit{dir\_box}は削除される.
11712
11713 \subsubsection{異方向のボックス寸法の格納}
11714 第二の使用目的は,現在の組方向がボックス本来の組方向とは異なる状況で,
11715 \cs{ltjsetwd} によってボックス寸法を設定されたことを記録することである.
11716
11717 例えば
11718 \begin{lstlisting}[numbers=left]
11719 \setbox0=\hbox{\vrule width 10pt height 5pt depth 2pt}
11720 \setbox1=\hbox{\tate\ltjsetwd0=20pt}
11721 \wd0=9pt
11722 \setbox1=\hbox{\dtou\ltjsetwd0=20pt}
11723 \setbox0=\hbox{\dtou a\box0}
11724 \end{lstlisting}
11725 というコードを考える.1行目で \cs{box0} には横組の
11726 幅10\,pt,高さ5\,pt,深さ2\,ptのボックスが代入される.
11727 よって,
11728 \begin{itemize}
11729  \item 縦組下では \cs{box0} は幅7\,pt,高さ・深さ5\,ptのボックスとして扱われる.
11730  \item \cs{dtou} 下では \cs{box0} は幅7\,pt,高さ10\,pt,深さ0\,ptのボックスとして扱われる.
11731 \end{itemize}
11732 このとき,\cs{box0} の\emph{中身}は
11733 \[
11734  \xymatrix{
11735    {}\Node{whatsit}{\cs{yoko}}\ar[r]&{}\Node{rule}{}
11736  }
11737 \]
11738 である.
11739
11740 さて,2行目で縦組時の \cs{box0} の幅が20\,ptに設定される.この情報が
11741 direction~whatsit内部のノードリストに,\textit{dir\_box}として格納される:
11742 \[
11743  \xymatrix{
11744    {}\Node{whatsit}{\cs{yoko}}\ar[r]\ar[d]_{\text{中身}}&{}\Node{rule}{}\\
11745    {}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{tate})}{20.0}{5.0}{5.0}}
11746  }
11747 \]
11748
11749 次に,3行目では横組時の,つまり \cs{box0} 本来の組方向での深さが9\,ptに変更される.
11750 このとき,\cs{box0} は
11751 \begin{itemize}
11752  \item 縦組下では寸法代入が既に行われているので,2行目で作成された\textit{dir\_box}の通り
11753        に幅20\,pt,高さ・深さ5\,ptのボックスとして扱われる.
11754  \item \cs{dtou} 下ではまだ寸法代入が行われていないので,
11755 \cs{box0} の寸法変更に追従し,幅7\,pt,高さ9\,pt,深さ0\,ptのボックスとして扱われる.
11756 \end{itemize}
11757
11758 4行目では \cs{dtou} 下での\cs{box0} の幅が20\,ptに設定されるので,2行目と同じように
11759 \[
11760  \xymatrix{
11761    {}\Node{whatsit}{\cs{yoko}}\ar[r]\ar[d]_{\text{中身}}&{}\Node{rule}{}\\
11762    {}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{dtou})}{20.0}{9.0}{0.0}}\ar[r]&
11763    {}\HNode{\textit{dir\_box} (\cs{tate})}{20.0}{5.0}{5.0}
11764  }
11765 \]
11766 と\textit{dir\_box}が作成される.
11767
11768 このように寸法代入によってつくられた\textit{dir\_box}は,前節の整合過程のときに再利用され
11769 る.上記の例でいえば,5行目を実行した後の \cs{box0} の内容は
11770 \[
11771  \xymatrix{
11772    {}\Node{whatsit}{\cs{dtou}}\ar[r]&
11773    {}\Node{glyph}{`a'}\ar[r]&
11774    {}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{dtou})}{20.0}{9.0}{0.0}}\ar[d]_{\text{中身}}\\
11775    &&{}\HNode{hbox}{9.0}{5.0}{2.0}\ar[d]_{\text{中身}}\\
11776    &&{}\Node{whatsit}{\cs{yoko}}\ar[r]&{}\Node{rule}{}
11777  }
11778 \]
11779 のようになる.
11780
11781 \subsection{縦組用字形の取得}
11782 縦組時には,「\hbox to \zw{、}」(\texttt{U+3001})から「\ltjjachar"FE11」(\texttt{U+FE11})%"
11783 のように縦組用字形への置き換えに関係する処理は,以下のようになっている.
11784
11785
11786 \begin{table}[t]
11787   \def\D#1#2#3#4{%
11788         {\fboxsep0pt\fcolorbox{cyan}{white}%
11789     {\large\KOZM\ltjjachar"#1#2#3#4}}\ (\texttt{U+#1#2#3#4})%"
11790   }
11791   \def\DH#1#2#3#4{%
11792         {\fboxsep0pt\fcolorbox{cyan}{white}%
11793     {\large\ltjjachar"#1#2#3#4}}\ (\texttt{U+#1#2#3#4})%"
11794   }
11795   \caption{\LuaTeX-ja標準で行われる縦組形への置換}
11796   \label{tab:vert_replace}\small\centering
11797   \begin{tabular}{*{3}{l@{}>{${}\longmapsto{}$}c@{}l}}
11798         \toprule
11799         \D 3001&&\D FE11&\D 3002&&\D FE12&\D 3016&&\DH FE17\\
11800         \D 3017&&\DH FE18&\D 2026&&\D FE19&\D 2025&&\D FE30\\
11801         \D 2014&&\D FE31&\D 2013&&\D FE32&\D FF3F&&\D FE33\\
11802         \D FF08&&\D FE35&\D FF09&&\D FE36&\D FF5B&&\D FE37\\
11803         \D FF5D&&\D FE38&\D 3014&&\D FE39&\D 3015&&\D FE3A\\
11804         \D 3010&&\D FE3B&\D 3011&&\D FE3C&\D 300A&&\D FE3D\\
11805         \D 300B&&\D FE3E&\D 3008&&\D FE3F&\D 3009&&\D FE40\\
11806         \D 300C&&\D FE41&\D 300D&&\D FE42&\D 300E&&\D FE43\\
11807         \D 300F&&\D FE44&\D FF3B&&\D FE47&\D FF3D&&\D FE48\\
11808         \bottomrule
11809   \end{tabular}
11810 \end{table}
11811 \begin{itemize}
11812         \item 各縦組用和文フォントは読み込み時に以下の属性が設定される:
11813         \begin{description}
11814           \item[\textit{vert\_activated}] 真となるのは,
11815           明示的に \texttt{-vert} も \texttt{-vrt2} のいずれも指定されていないちょうどその時.
11816           \item[\textit{auto\_enable\_vrt2}] 真となるのは,
11817           \texttt{vert}, \texttt{vrt2}のいずれについても有効・無効が指定されていないちょうどその時.
11818         \end{description}
11819         \textit{vert\_activated}については\texttt{luatexja.define\_jfont}コールバックで渡される引数
11820         \texttt{jfont\_info}から取得可能である.
11821
11822         \item \textit{auto\_enable\_vrt2}が真の場合は,現在のscript tagとlanguage system identifierの値で
11823         \texttt{vrt2}機能が利用可能か調べる.利用可能ならば\texttt{vrt2}を,そうでなければ
11824         \texttt{vert}を有効化する.
11825         \item また,各和文フォント読み込み時には,
11826         「OpenType機能による置換以前に行う縦組形への置換」を格納したテーブル\textit{vform}も作成する.
11827         \begin{enumerate}
11828           \item \autoref{tab:vert_replace}に示した各置換$i\longmapsto v$に対し,
11829           置換先$v$がフォント内に存在する文字コードであるならば,$i\longmapsto v$を\textit{vform}に登録する.
11830           \item \ref{ssec:tfont}節にある\texttt{jpotf}が指定された場合,
11831           \LuaTeX-ja内部の別のテーブル\textit{vert\_jpotf\_table}に登録されている各置換$i\longmapsto v$に対して
11832           置換先$v$がフォント内に存在する文字コードであるならば,$i\longmapsto v$を\textit{vform}に登録する.
11833           \item もし\texttt{vert}も\texttt{vrt2}も現在のscript, languageでは有効にできない場合,
11834           どこかのscript, languageにおける\texttt{vert}で定義されている
11835           置換$i\longmapsto v$をすべて\textit{vform}に登録する.
11836         \end{enumerate}
11837
11838         あとで説明するように,\textit{vform}は\textit{vert\_activated}が真であるような縦組用和文フォントでしか
11839         利用されない.
11840         
11841         \item 「現在の水平リスト」内の\textbf{JAchar}を(欧文フォントから)和文フォントへ置き換える処理において,
11842     その時点での組方向が縦組であり,かつ処理対象の各ノードの縦組用フォントで
11843         \textit{vert\_activated}が真である場合,\textit{vform}に従いグリフが置き換えられる.
11844
11845         \Pkg{luaotfload}が行う,OpenType機能に沿ったグリフ置換はこの後の処理となる.
11846   \end{itemize}
11847 %</ja>
11848
11849 \newpage
11850 \begin{thebibliography}{99}
11851   \addcontentsline{toc}{section}{\refname}
11852 \bibitem{texbytopic}
11853 Victor Eijkhout. \newblock \textit{\TeX\ by Topic, A \TeX nician's Reference}, Addison-Wesley, 1992.
11854 \bibitem{listings} C.\ Heinz, B.\ Moses. \newblock The \textsf{Listings} Package.
11855 \bibitem{uptex} Takuji Tanaka. \newblock
11856 upTeX---Unicode version of pTeX with CJK extensions,
11857 TUG 2013, October 2013.\newblock
11858 \url{http://tug.org/tug2013/slides/TUG2013_upTeX.pdf}
11859 \bibitem{jlisting} Thor Watanabe. \newblock Listings\ -\ MyTeXpert.\newblock
11860 \url{http://mytexpert.osdn.jp/index.php?Listings}
11861 \bibitem{jlreq}  W3C Japanese Layout Task Force~(ed). \newblock
11862 Requirements for Japanese Text Layout (W3C Working Group Note), 2011, 2012. \newblock
11863 \url{http://www.w3.org/TR/jlreq/}%
11864 %<ja> \\日本語訳の書籍版:W3C日本語組版タスクフォース(編),『W3C技術ノート 日本語組版処理の要件』,東京電機大学出版局,2012.
11865 \bibitem{min10} 乙部厳己.「min10フォントについて」\newblock
11866 \url{http://argent.shinshu-u.ac.jp/~otobe/tex/files/min10.pdf}
11867 \bibitem{x4051} 日本工業規格(Japanese Industrial Standard). 「JIS~X~4051,
11868 日本語文書の組版方法(Formatting rules for Japanese documents)」, 1993, 1995, 2004.
11869 \bibitem{ptexdoc} 濱野尚人,田村明史,倉沢良一.「\TeX の出版への応用—縦組み機能の組み込み—」.
11870 \newblock\texttt{.../texmf-dist/doc/ptex/base/ptexdoc.pdf}
11871 \bibitem{ptextug} Hisato Hamano. \newblock
11872 \textit{Vertical Typesetting with \TeX}, TUGBoat~\textbf{11}(3), 346--352, 1990.
11873 \bibitem{pdfstd} International Organization for Standardization. \newblock
11874 ISO 32000-1:2008, \textit{Document management -- Portable document format -- Part 1: PDF
11875       1.7}, 2008. \newblock
11876 \url{http://www.iso.org/iso/iso\_catalogue/catalogue_tc/catalogue\_detail.htm?csnumber=51502}
11877 \bibitem{tc18ltja} 北川弘典.「\LuaTeX-jaの近況」,\TeX Conf~2018.
11878   \url{https://raw.githubusercontent.com/h-kitagawa/presentations/main/tc18ltja.pdf}
11879 \bibitem{bxghost} Takuto ASAKURA. \newblock The \textsf{BXghost} Package. \url{https://github.com/wtsnjp/BXghost}
11880 \end{thebibliography}
11881
11882 \makeatletter
11883 \let\ltj@@end=\@@end
11884 {\catcode`\%=12\relax\catcode`\~=12\relax
11885 \protected\gdef\@@end{%
11886 \typeout{attributes:}
11887 \directlua{
11888   for i=0,65535 do
11889     local a = tex.getattribute(i)
11890     if a~=-0x7FFFFFFF then
11891       texio.write_nl('term and log',
11892         string.format('attr %6d, %d', i, a))
11893     end
11894     tex.setbox('global', i, nil)
11895   end
11896   print('IC', luatexja.inherit_na_count )
11897 }\ltj@@end}}
11898 \end{document}
11899 %</!showexpl>
11900 %<*showexpl>
11901 %%
11902 %% config file for showexpl.sty
11903 %%
11904 %% Copyright The LuaTeX-ja project team, 2012
11905 %%
11906 \ProvidesFile{showexpl.cfg}
11907   [2012/05/20 v0.01 Definitions for the showexpl package (luatexja)]
11908 \lstset{}
11909 \def\SX@Info{}
11910 \endinput
11911 %</*showexpl>