OSDN Git Service

Move files which are not required in the regular use into src/no_runtime/.
[luatex-ja/luatexja.git] / doc / manual.dtx
1 %#! lualatex -shell-escape manual.ins
2
3 %<*en>
4 \documentclass[a4paper,titlepage]{article}
5 \usepackage[margin=25mm,footskip=5mm]{geometry}
6 %</en>
7 %<*ja>
8 \documentclass[a4paper,titlepage]{ltjsarticle}
9 \usepackage[margin=25mm, footskip=5mm]{geometry}
10 \advance\leftmargini-1\zw\advance\leftmarginii-1\zw
11 %</ja>
12
13 \usepackage{amsmath,amssymb,xcolor,pict2e,multienum,amsthm,float,makecell}
14 \usepackage{booktabs,listings,showexpl,multicol}
15 \usepackage{luatexja-otf}
16 \usepackage{luatexja-fontspec}
17 \usepackage[unicode=true]{hyperref}
18 \usepackage[all]{xy}
19 \SelectTips{cm}{}
20 \def\labelenumii{(\arabic{enumii})}
21
22 \DeclareRobustCommand\eTeX{\ensuremath{\varepsilon}-\kern-.125em\TeX}
23 \DeclareRobustCommand\LuaTeX{Lua\TeX}
24 \DeclareRobustCommand\pdfTeX{pdf\TeX}
25 \DeclareRobustCommand\pTeX{p\kern-.05em\TeX}
26 \DeclareRobustCommand\upTeX{up\kern-.05em\TeX}
27 \DeclareRobustCommand\pLaTeX{p\kern-.05em\LaTeX}
28 \DeclareRobustCommand\pLaTeXe{p\kern-.05em\LaTeXe}
29 \DeclareRobustCommand\epTeX{\ensuremath{\varepsilon}-\kern-.125em\pTeX}
30
31 \theoremstyle{definition}
32 %<en>\newtheorem{defn}{Definition}
33 %<ja>\newtheorem{defn}{定義}
34
35 \newenvironment{cslist}{%
36   \leftskip2em\parindent=0pt\def\makelabel##1{{\tt\char92##1}}
37   \def\{{\char`\{}\def\}{\char`\}}
38   \let\origitem=\item
39   \def\item[##1]{\par\smallskip\par\hskip-\leftskip\makelabel{##1}\par}
40 }{}
41
42 \makeatletter
43 \long\def\@makecaption#1#2{%
44   \vskip\abovecaptionskip
45   \sbox\@tempboxa{{\small #1. #2}}%
46   \ifdim \wd\@tempboxa >\hsize
47     {\small #1. #2}\par
48   \else
49     \global \@minipagefalse
50     \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
51   \fi
52   \vskip\belowcaptionskip}
53 % Suppress output from showexpl to stdout.
54 \let\SX@Info\relax
55 \makeatother
56
57 \def\Node#1#2{\,\vcenter{\hbox{\fboxsep=1pt\fbox{\vbox{\small\halign{\hfil##\hfil\cr
58   #1\mathstrut\cr\noalign{\hrule height.4pt}\strut#2\cr}}}}\,}}
59
60 %<*en>
61 \title{The \LuaTeX-ja package}
62 \author{The \LuaTeX-ja project team}
63 %</en>
64 %<*ja>
65 \title{\LuaTeX-jaパッケージ}
66 \author{\LuaTeX-jaプロジェクトチーム}
67 %</ja>
68
69 \lstset{
70   basicstyle=\ttfamily\small, pos=o, breaklines=true,
71   numbers=none, rframe={}, basewidth=0.5em
72 }
73
74 \parskip=\smallskipamount
75 \protected\def\Param#1{\textsf{#1}} % parameter name
76 \protected\def\Pkg#1{\underline{\smash{\texttt{#1}}}} % packages/classes
77
78 \begin{document}
79 \catcode`\<=13
80 \def<#1>{{\normalfont\rm\itshape$\langle$#1$\rangle$}}
81 \maketitle
82
83 \tableofcontents
84 \bigskip
85
86 %<*en>
87 \textbf{This documentation is far from complete. It may have many
88 grammatical (and contextual) errors.} Also, several parts
89 (especially, Section~\ref{sec-jfmglue}) are written in Japanese only.
90 %</en>
91 %<*ja>
92 \textbf{\large 本ドキュメントはまだまだ未完成です.}
93 %</ja>
94
95 \clearpage
96 %<en>\part{User's manual}
97 %<ja>\part{ユーザーズマニュアル}
98
99 %<en>\section{Introduction}
100 %<ja>\section{はじめに}
101
102 %<*en>
103 The \LuaTeX-ja package is a macro package for typesetting high-quality
104 Japanese documents when using \LuaTeX.
105 %</en>
106 %<*ja>
107 \LuaTeX-jaパッケージは,次世代標準\TeX である\LuaTeX の上で,\pTeX と同等
108 /それ以上の品質の日本語組版を実現させようとするマクロパッケージである.
109 %</ja>
110
111 %<en>\subsection{Backgrounds}
112 %<ja>\subsection{背景}
113
114 %<*en>
115 Traditionally, ASCII \pTeX, an extension of \TeX, and its derivatives
116 are used to typeset Japanese documents in \TeX. \pTeX\ is an engine
117 extension of \TeX: so it can produce high-quality Japanese documents
118 without using very complicated macros. But this point is a mixed
119 blessing: \pTeX\ is left behind from other extensions of \TeX,
120 especially \eTeX\ and \pdfTeX, and from changes about
121 Japanese processing in computers (\textit{e.g.}, the UTF-8 encoding).
122 %</en>
123 %<*ja>
124 従来,「\TeX を用いて日本語組版を行う」といったとき,エンジンとしては
125 ASCII \pTeX やそれの拡張物が用いられることが一般的であった.\pTeX は\TeX
126 のエンジン拡張であり,(少々仕様上不便な点はあるものの)商業印刷の分野に
127 も用いられるほどの高品質な日本語組版を可能としている.だが,それは弱点に
128 もなってしまった:\pTeX という(組版的に)満足なものがあったため,海外で
129 行われている数々の\TeX の拡張──例えば\eTeX や\pdfTeX ──や,TrueType,
130 OpenType, Unicodeといった計算機で日本語を扱う際の状況の変化に追従すること
131 を怠ってしまったのだ.
132 %</ja>
133
134 %<*en>
135 Recently extensions of \pTeX, namely \upTeX\ (Unicode-implementation
136 of \pTeX) and \epTeX\ (merging of \pTeX\ and
137 \eTeX\ extension), have developed to fill those gaps to some
138 extent, but gaps still exist.
139 %</en>
140 %<*ja>
141 ここ数年,若干状況は改善されてきた.現在手に入る大半の\pTeX バイナリでは
142 外部UTF-8入力が利用可能となり,さらにUnicode化を推進し,\pTeX の内部処理
143 までUnicode化した\upTeX も開発されている.また,\pTeX に\eTeX 拡張をマー
144 ジした\epTeX も登場し,\TeX\ Live\ 2011では\pLaTeX が\epTeX の上で動作す
145 るようになった.だが,\pdfTeX 拡張(PDF 直接出力やmicro-typesetting)を
146 \pTeX に対応させようという動きはなく,海外とのgapは未だにあるのが現状であ
147 る.
148 %</ja>
149
150 %<*en>
151 However, the appearance of \LuaTeX\ changed the whole situation. With
152 using Lua `callbacks', users can customize the internal processing of
153 \LuaTeX. So there is no need to modify sources of engines to
154 support Japanese typesetting: to do this, we only have to write Lua
155 scripts for appropriate callbacks.
156 %</en>
157 %<*ja>
158 しかし,\LuaTeX の登場で,状況は大きく変わることになった.Luaコードで
159 `callback'を書くことにより,\LuaTeX の内部処理に割り込みをかけることが可
160 能となった.これは,エンジン拡張という真似をしなくても,Luaコードとそれに
161 関する\TeX マクロを書けば,エンジン拡張とほぼ同程度のことができるようになっ
162 たということを意味する.\LuaTeX-jaは,このアプローチによってLuaコード・
163 \TeX マクロによって日本語組版を\LuaTeX の上で実現させようという目的で開発
164 が始まったパッケージである.
165 %</ja>
166
167 %<en>\subsection{Major Changes from \pTeX}
168 %<ja>\subsection{\pTeX からの主な変更点}
169
170 %<*en>
171 The \LuaTeX-ja package is under much influence of \pTeX\ engine. The initial
172 target of development was to implement features of \pTeX. However,
173 \emph{\LuaTeX-ja is not a just porting of \pTeX; unnatural
174 specifications/behaviors of \pTeX\ were not adopted}.
175 %</en>
176 %<*ja>
177 \LuaTeX-jaは,\pTeX に多大な影響を受けている.初期の開発目標は,\pTeX の機
178 能をLuaコードにより実装することであった.しかし,開発が進むにつれ,\pTeX
179 の完全な移植は不可能であり,また\pTeX における実装がいささか不可解になっ
180 ているような状況も発見された.そのため,\textbf{\LuaTeX-ja は,もはや
181 \pTeX の完全な移植は目標とはしない.\pTeX における不自然な仕様・挙動があ
182 れば,そこは積極的に改める.}
183 %</ja>
184
185 %<*en>
186 The followings are major changes from \pTeX:
187 %</en>
188 %<*ja>
189 以下は \pTeX からの主な変更点である.
190 %</ja>
191
192 \begin{itemize}
193 %<*en>
194 \item A Japanese font is a tuple of a `real' font, a Japanese font
195       metric (\textbf{JFM}, for short), and an optional string called
196       `variation'.
197 %</en>
198 %<*ja>
199 \item 和文フォントは(小塚明朝,IPA明朝などの)実際のフォント,和文フォントメトリック(JFM と呼ぶ),そ
200       して `variation' と呼ばれる文字列の組である.
201 %</ja>
202
203 %<*en>
204 \item In \pTeX, a line break after Japanese character is ignored (and
205       doesn't yield a space), since line breaks (in source files) are
206       permitted almost everywhere in Japanese texts. However, \LuaTeX-ja
207       doesn't have this function completely, because of a specification
208       of \LuaTeX.
209 %</en>
210 %<*ja>
211 \item 日本語の文書中では改行はほとんどどこでも許されるので,\pTeX では和文文字
212       直後の改行は無視される(スペースが入らない)ようになっていた.しかし,
213       \LuaTeX-ja では \LuaTeX の仕様のためにこの機能は完全には実装されていない.
214 %</ja>
215
216 %<*en>
217 \item The insertion process of glues/kerns between two Japanese
218       characters and between a Japanese character and other characters
219       (we refer these glues/kerns as \textbf{JAglue}) is rewritten from
220       scratch.
221 %</en>
222 %<*ja>
223 \item 2つの和文文字の間,和文文字と欧文文字の間に入るグルー/カーン
224       (\textbf{JAglue} と呼ぶ)の挿入処理が0から書き直されている.
225 %</ja>
226
227 \begin{itemize}
228 %<*en>
229 \item As \LuaTeX's internal character handling is `node-based'
230       (\textit{e.g.}, \verb+of{}fice+ doesn't prevent ligatures), the
231       insertion process of \textbf{JAglue} is now `node-based'.
232 %</en>
233 %<*ja>
234 \item \LuaTeX の内部での文字の扱いが「ノードベース」になっているように(例えば,
235       \verb+of{}fice+ で合字は抑制されない),\textbf{JAglue} の挿入処理も
236       「ノードベース」である.
237 %</ja>
238
239 %<*en>
240 \item Furthermore, nodes between two characters which have no effects in
241       line break (\textit{e.g.}, \verb+\special+ node) and kerns from
242       italic correction are ignored in the insertion process.
243 %</en>
244 %<*ja>
245 \item さらに,2つの文字の間にある行末では効果を持たないノード(例えば \verb+\special+ ノード)や,
246   イタリック補正に伴い挿入されるカーンは挿入処理中では無視される.
247 %</ja>
248
249 %<*en>
250 \item \emph{Caution: due to above two points, many methods which did for the
251       dividing the process of the insertion of \textbf{JAglue} in \pTeX\ are not
252       effective anymore.} In concrete terms, the following two methods are not effective anymore:
253 %</en>
254 %<*ja>
255 \item \textbf{注意:上の2つの変更により,従来 \textbf{JAglue} の挿入処理を分断するのに
256       使われていたいくつかの方法は用いることができない.具体的には,次の方法はもはや無効である:}
257 %</ja>
258 \begin{verbatim}
259   ちょ{}っと  ちょ\/っと
260 \end{verbatim}
261 %<*en>
262       If you want to do so, please put an empty hbox between it instead:
263 %</en>
264 %<*ja>
265       もし同じことをやりたければ,空の水平ボックスを間に挟めばよい:
266 %</ja>
267 \begin{verbatim}
268   ちょ\hbox{}っと
269 \end{verbatim}
270
271
272 %<*en>
273 \item In the process, two Japanese fonts which only differ in their `real'
274       fonts are identified.
275 %</en>
276 %<*ja>
277 \item 処理中では,2つの和文フォントは,「実際の」フォントのみが異なる場合に同一視
278       される.
279 %</ja>
280 \end{itemize}
281
282 %<*en>
283 \item At the present, vertical typesetting (\emph{tategaki}), is not
284       supported in \LuaTeX-ja.
285 %</en>
286 %<*ja>
287 \item 現時点では,縦書きは \LuaTeX-ja ではサポートされていない.
288 %</ja>
289
290 \end{itemize}
291
292 %<*en>
293 For detailed information, see Part~\ref{part-imp}.
294 %</en>
295 %<*ja>
296 詳細については第 \ref{part-imp} 部を参照.
297 %</ja>
298
299 %<en>\subsection{Notations}
300 %<ja>\subsection{用語と記法}
301
302 %<*en>
303 In this document, the following terms and notations are used:
304 %</en>
305 %<*ja>
306 本ドキュメントでは,以下の用語と記法を用いる:
307 %</ja>
308
309 \begin{itemize}
310 %<*en>
311 \item Characters are divided into two types:
312 %</en>
313 %<*ja>
314 \item 文字は2種類に分けられる:
315 %</ja>
316 \begin{itemize}
317 %<*en>
318 \item \textbf{JAchar}: standing for Japanese characters such as
319       Hiragana, Katakana, Kanji and other punctuation marks for
320       Japanese.
321 %</en>
322 %<*ja>
323 \item \textbf{JAchar}: ひらがな,カタカナ,漢字,和文用の約物といった和文文字の
324       ことを指す.
325 %</ja>
326
327 %<*en>
328 \item \textbf{ALchar}: standing for all other characters like alphabets.
329 %</en>
330 %<*ja>
331 \item \textbf{ALchar}: アルファベットを始めとする,その他全ての文字を指す.
332 %</ja>
333 \end{itemize}
334
335 %<*en>
336 We say `alphabetic fonts' for fonts used in \textbf{ALchar}, and `Japanese fonts' for fonts used in \textbf{JAchar}.
337 %</en>
338 %<*ja>
339 そして,\textbf{ALchar} の出力に用いられるフォントを「欧文フォント」と呼び,
340 \textbf{JAchar} の出力に用いられるフォントを「和文フォント」と呼ぶ.
341 %</ja>
342
343 %<*en>
344 \item A word in a sans-serif font (like \Param{prebreakpenalty})
345       means an internal parameter for Japanese typesetting, and it
346       is used as a key in \verb+\ltjsetparameter+ command.
347 %</en>
348 %<*ja>
349 \item サンセリフ体で書かれた語(例:\Param{prebreakpenalty})は日本語組版用の
350       パラメータを表し,これらは \verb+\ltjsetparameter+ コマンドのキーとして
351       用いられる.
352 %</ja>
353
354 %<*en>
355 \item A word in typewriter font with underline (like \Pkg{fontspec})
356       means a package or a class of \LaTeX.
357 %</en>
358 %<*ja>
359 \item 下線付きのタイプライタ体で書かれた語(例:\Pkg{fontspec})は \LaTeX の
360       パッケージやクラスを表す.
361 %</ja>
362
363 %<*en>
364 \item The word `primitive' is used not only for primitives in \LuaTeX,
365       but also for control sequences that defined in the core module of
366       \LuaTeX-ja.
367 %</en>
368 %<*ja>
369 \item 「プリミティブ」という語を,\LuaTeX のプリミティブだけではなく \LuaTeX-ja
370       のコアモジュールで定義されたコントロールシーケンスに対しても用いる.
371 %</ja>
372
373 %<*en>
374 \item In this document, natural numbers start from~0.
375 %</en>
376 %<*ja>
377 \item 本ドキュメントでは,自然数は0から始まる.
378 %</ja>
379 \end{itemize}
380
381 %<en>\subsection{About the project}
382 %<ja>\subsection{プロジェクトについて}
383
384 %<*en>
385 \paragraph{Project Wiki} Project Wiki is under construction.
386 %</en>
387 %<*ja>
388 \paragraph{プロジェクト Wiki} プロジェクト Wiki は構築中である.
389 %</ja>
390
391 %<*en>
392 \begin{itemize}
393 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28en%29} (English)
394 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage} (Japanese)
395 \end{itemize}
396 %</en>
397 %<*ja>
398 \begin{itemize}
399 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage}(日本語)
400 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28en%29}(英語)
401 \end{itemize}
402 %</ja>
403
404 %<*en>
405 This project is hosted by SourceForge.JP.
406 %</en>
407 %<*ja>
408 本プロジェクトは SourceForge.JP のサービスを用いて運営されている.
409 %</ja>
410
411 %<en>\paragraph{Members}\
412 %<ja>\paragraph{開発メンバー}\
413 %<*en>
414 \begin{multienumerate}
415 \def\labelenumi{$\bullet$}
416 \mitemxxx{Hironori KITAGAWA}{Kazuki MAEDA}{Takayuki YATO}
417 \mitemxxx{Yusuke KUROKI}{Noriyuki ABE}{Munehiro YAMAMOTO}
418 \mitemxxx{Tomoaki HONDA}{Shuzaburo SAITO}{MA Qiyuan}
419 \end{multienumerate}
420 %</en>
421 %<*ja>
422 \begin{multienumerate}
423 \def\labelenumi{$\bullet$}
424 \mitemxxx{北川 弘典}{前田 一貴}{八登 崇之}
425 \mitemxxx{黒木 裕介}{阿部 紀行}{山本 宗宏}
426 \mitemxxx{本田 知亮}{齋藤 修三郎}{馬 起園}
427 \end{multienumerate}
428 %</ja>
429
430
431 % \paragraph{Acknowledgments} -- 挿入するならここ
432
433 \clearpage
434 %<en>\section{Getting Started}
435 %<ja>\section{使い方}
436 %<en>\subsection{Installation}
437 %<ja>\subsection{インストール}
438
439 %<*en>
440 To install the \LuaTeX-ja\ package, you will need:
441 %</en>
442 %<*ja>
443 \LuaTeX-ja パッケージのインストールには,次のものが必要である.
444 %</ja>
445 \begin{itemize}
446 %<*en>
447 \item \LuaTeX\ (version 0.65.0-beta or later) and its supporting packages.\\
448 If you are using \TeX~Live~2011 or current W32\TeX, you don't have to worry.
449 %</en>
450 %<*ja>
451 \item \LuaTeX(バージョン 0.65.0-beta 以降)とその支援パッケージ.
452       \TeX~Live~2011 や W32\TeX の最新版ならば問題ない.
453 %</ja>
454 %<*en>
455 \item The source archive of \LuaTeX-ja, of course\texttt{:)}
456 %</en>
457 %<*ja>
458 \item \LuaTeX-ja のソースアーカイブ(もちろん \texttt{:)}).
459 %</ja>
460 %<*en>
461 \item The \Pkg{filehook} package.
462 %</en>
463 %<*ja>
464 \item \Pkg{filehook} パッケージ.
465 %</ja>
466 %<*en>
467 \item The \Pkg{xunicode} package, which version is \emph{just v0.981 (2011/09/09)}.\\
468 If you have the \Pkg{fontspec} package, this \Pkg{xunicode} package must be exist.
469 But be careful about the version; other versions may not work correctly with \LuaTeX-ja.
470 %</en>
471 %<*ja>
472 \item \Pkg{xunicode} パッケージ (\textbf{2011/09/09,~v0.981}).\\
473 \Pkg{fontspec} パッケージが導入されていればこのパッケージも導入されているはずであるが,
474 この v0.981 以外のバージョンでは\LuaTeX-ja 上で正しく動作しない危険性がある.
475 %</ja>
476 \end{itemize}
477
478 %<*en>
479 The installation methods are as follows:
480 %</en>
481 %<*ja>
482 インストール方法は以下のようになる:
483 %</ja>
484 \begin{enumerate}
485 %<*en>
486 \item Download the source archive.
487
488       At the present, \LuaTeX-ja has no official release, so you have to retrieve
489       the archive from the repository.
490       You can retrieve the Git repository via
491 %</en>
492 %<*ja>
493 \item ソースアーカイブをダウンロードする.
494
495       現時点では,\LuaTeX-ja の公式リリースはまだない.そのため,Git リポジトリを
496       次のようにすることで取得する必要がある:
497 %</ja>
498 \begin{verbatim}
499 $ git clone git://git.sourceforge.jp/gitroot/luatex-ja/luatexja.git
500 \end{verbatim}
501 %<*en>
502       or download the archive of HEAD in the \texttt{master} branch from
503 %</en>
504 %<*ja>
505       もしくは,\texttt{master} ブランチの HEAD のアーカイブを以下からダウンロードしてもよい:
506 %</ja>
507 \begin{flushleft}
508 \url{http://git.sourceforge.jp/view?p=luatex-ja/luatexja.git;a=snapshot;h=HEAD;sf=tgz}.
509 \end{flushleft}
510
511 %<*en>
512 Note that the forefront of development may not be the \texttt{master} branch.
513 %</en>
514 %<*ja>
515 \texttt{master} ブランチはたまにしか更新されない.
516 最新の開発中のコードは \texttt{master} ブランチには含まれていない場合がかなり多いので注意.
517 %</ja>
518
519 %<*en>
520 \item Extract the archive. You will see \texttt{src/} and several other sub-directories.
521 %</en>
522 %<*ja>
523 \item 後者の方法でアーカイブを取得したならば,それを展開する.
524       \texttt{src/} をはじめとしたいくつかのディレクトリができるが,
525       動作には \texttt{src/} 以下の内容だけで十分.
526 %</ja>
527
528 %<*en>
529 \item Copy all the contents of \texttt{src/} (except \texttt{src/no\_runtime/}) into one of your \texttt{TEXMF} tree.\\
530       \texttt{TEXMF/tex/luatex/luatexja/} is an example location. 
531       Files in \texttt{src/no\_runtime/} are not required for the regular use, 
532       so you may simply remove \texttt{src/no\_runtime/}.
533 %</en>
534 %<*ja>
535 \item \texttt{src/} の中身で,(\texttt{src/no\_runtime/}以外の)全てを自分の \texttt{TEXMF} ツリーにコピーする.\\
536       場所の例としては,例えば \texttt{TEXMF/tex/luatex/luatexja/} がある.
537       \texttt{src/no\_runtime/} 中のファイルは通常の使用には必要ないので,単に削除して構わない.
538       シンボリックリンクが利用できる環境で,かつレポジトリを直接取得したのであれば,コピーではなく
539       リンクを貼るのが適切だろう.
540 %</ja>
541
542 %<*en>
543 \item If \texttt{mktexlsr} is needed to update the file name database, make it so.
544 %</en>
545 %<*ja>
546 \item 必要があれば,\texttt{mktexlsr} を実行する.
547 %</ja>
548 \end{enumerate}
549
550 %<en>\subsection{Cautions}
551 %<ja>\subsection{注意点}
552
553 \begin{itemize}
554 %<*en>
555 \item The encoding of your source file must be UTF-8. No other
556       encodings, such as EUC-JP or Shift-JIS, are not supported.
557 %</en>
558 %<*ja>
559 \item 原稿のソースファイルの文字コードは UTF-8 固定である.
560       従来日本語の文字コードとして用いられてきた EUC-JP や Shift-JIS は使用できない.
561 %</ja>
562 \end{itemize}
563
564 %<en>\subsection{Using in plain \TeX}
565 %<ja>\subsection{plain \TeX で使う}
566 \label{ssec-plain}
567
568 %<*en>
569 To use \LuaTeX-ja in plain \TeX, simply put the following at the beginning of the document:
570 %</en>
571 %<*ja>
572 \LuaTeX-ja を plain \TeX で使うためには,単に次の行をソースファイルの冒頭に追加すればよい:
573 %</ja>
574 \begin{verbatim}
575 \input luatexja.sty
576 \end{verbatim}
577 %<*en>
578 This does minimal settings (like \texttt{ptex.tex}) for typesetting Japanese documents:
579 %</en>
580 %<*ja>
581 これで(\texttt{ptex.tex} のように)日本語組版のための最低限の設定がなされる:
582 %</ja>
583
584 \begin{itemize}
585 %<*en>
586 \item The following 6~Japanese fonts are preloaded:
587 \begin{center}
588 \begin{tabular}{ccccc}
589 \toprule
590 \textbf{classification}&\textbf{font name}&\bf `10\,pt'&\bf`7\,pt'&\bf`5\,pt'\\\midrule
591 \emph{mincho}&Ryumin-Light    &\verb+\tenmin+&\verb+\sevenmin+&\verb+\fivemin+\\
592 \emph{gothic}&GothicBBB-Medium&\verb+\tengt+ &\verb+\sevengt+ &\verb+\fivegt+\\
593 \bottomrule
594 \end{tabular}
595 \end{center}
596 %</en>
597 %<*ja>
598 \item 以下の6つの和文フォントが定義される:
599 \begin{center}
600 \begin{tabular}{ccccc}
601 \toprule
602 \textbf{字体}&\textbf{フォント名}&\bf `10\,pt'&\bf`7\,pt'&\bf`5\,pt'\\\midrule
603 明朝体&Ryumin-Light    &\verb+\tenmin+&\verb+\sevenmin+&\verb+\fivemin+\\
604 ゴシック体&GothicBBB-Medium&\verb+\tengt+ &\verb+\sevengt+ &\verb+\fivegt+\\
605 \bottomrule
606 \end{tabular}
607 \end{center}
608 %</ja>
609 \begin{itemize}
610 %<*en>
611 \item The `Q(級)' is a unit used in Japanese phototypesetting, and
612       $1\,\textrm{Q}=0.25\,\textrm{mm}$. This length is stored in a
613       dimension \verb+\jQ+.
614 %</en>
615 %<*ja>
616 \item `Q(級)' は日本の写植で用いられる単位で,$1\,\textrm{Q}=0.25\,\textrm{mm}$
617       である.この長さは \verb+\jQ+ に保持されている.
618 %</ja>
619
620 %<*en>
621 \item It is widely accepted that the font `Ryumin-Light' and
622       `GothicBBB-Medium' aren't embedded into PDF files, and PDF reader
623       substitute them by some external Japanese fonts (\textit{e.g.},
624       Kozuka Mincho is used for Ryumin-Light in Adobe Reader). We adopt this custom to
625       the default setting.
626 %</en>
627 %<*ja>
628 \item `Ryumin-Light' と `GothicBBB-Medium' は PDF ファイルに埋め込まずに
629       名前参照のみで用いることが広く受け入れられており,この場合 PDF リーダーが
630       適切な外部フォントで代用する(例えば,Adobe Reader では Ryumin-Light は
631       小塚明朝で代替される).そこで,これらを引き続きデフォルトのフォントと
632       して採用する.
633 %</ja>
634
635 %<*en>
636 \item A character in an alphabetic font is generally smaller than a
637       Japanese font in the same size. So actual size specification of
638       these Japanese fonts is in fact smaller than that of alphabetic
639       fonts, namely scaled by 0.962216.
640 %</en>
641 %<*ja>
642 \item 欧文フォントの文字は和文フォントの文字よりも,同じ文字サイズでも
643       一般に小さくデザインされている.そこで,標準ではこれらの和文フォントの実際のサイズは指定された値よりも
644       小さくなるように設定されており,具体的には指定の 0.962216 倍にスケールされる.
645       この 0.962216 という数値も,p\TeX におけるスケーリングを踏襲した値である.
646 %</ja>
647 \end{itemize}
648
649 %<*en>
650 \item The amount of glue that are inserted between a \textbf{JAchar} and
651       an \textbf{ALchar} (the parameter \Param{xkanjiskip}) is set to
652 %</en>
653 %<*ja>
654 \item \textbf{JAchar} と \textbf{ALchar} の間に入るグルー (\Param{xkanjiskip}) の
655       量は次のように設定されている:
656 %</ja>
657 \[
658  (0.25\cdot 0.962216\cdot 10\,\mathrm{pt})^{+1\,\text{pt}}_{-1\,\text{pt}}
659  = 2.40554\,\mathrm{pt}^{+1\,\text{pt}}_{-1\,\text{pt}}.
660 \]
661 \end{itemize}
662
663 %<en>\subsection{Using in \LaTeX}
664 %<ja>\subsection{\LaTeX で使う}
665 \label{ssec-ltx}
666
667 \paragraph{\LaTeXe}
668
669 %<*en>
670 Using in \LaTeXe\ is basically same. To set up the minimal environment
671 for Japanese, you only have to load \texttt{luatexja.sty}:
672 %</en>
673 %<*ja>
674 \LaTeXe を用いる場合も基本的には同じである.日本語組版のための最低限の環境を
675 設定するためには,\texttt{luatexja.sty} を読み込むだけでよい:
676 %</ja>
677 \begin{verbatim}
678 \usepackage{luatexja}
679 \end{verbatim}
680 %<*en>
681 It also does minimal settings (counterparts in \pLaTeX\ are \texttt{
682 plfonts.dtx} and \texttt{pldefs.ltx}):
683 %</en>
684 %<*ja>
685 これで \pLaTeX の \texttt{plfonts.dtx} と \texttt{pldefs.ltx} に相当する最低限の設定が
686 なされる:
687 %</ja>
688
689 \begin{itemize}
690 %<*en>
691 \item \texttt{JY3} is the font encoding for Japanese fonts (in horizontal direction).\\
692 When vertical typesetting is supported by \LuaTeX-ja in the future, \texttt{JT3} will be used for vertical fonts.
693 %</en>
694 %<*ja>
695 \item \texttt{JY3} は和文フォント用のフォントエンコーディングである(横書き用).\\
696 将来的に,\LuaTeX-ja で縦書きがサポートされる際には,\texttt{JT3} を縦書き用として
697 用いる予定である.
698 %</ja>
699
700 %<*en>
701 \item Two font families \texttt{mc} and \texttt{gt} are defined:
702 \begin{center}
703 \begin{tabular}{ccccc}
704 \toprule
705 \textbf{classification}&\textbf{family}&\verb+\mdseries+&\verb+\bfseries+&\textbf{scale}\\\midrule
706 \emph{mincho}&\tt mc&Ryumin-Light    &GothicBBB-Medium&0.962216\\
707 \emph{gothic}&\tt gt&GothicBBB-Medium&GothicBBB-Medium&0.962216\\
708 \bottomrule
709 \end{tabular}
710 \end{center}
711 Remark that the bold series in both family are same as the medium series of \emph{gothic} family.
712 This is a convention in \pLaTeX. This is a trace that there were only 2~fonts (these are Ryumin-Light
713 and GothicBBB-Medium) in early years of DTP.
714 %</en>
715 %<*ja>
716 \item 2つのフォントファミリ \texttt{mc} と \texttt{gt} が定義されている:
717 \begin{center}
718 \begin{tabular}{ccccc}
719 \toprule
720 \textbf{字体}&\textbf{ファミリ}&\verb+\mdseries+&\verb+\bfseries+&\textbf{スケール}\\\midrule
721 明朝体&\tt mc&Ryumin-Light    &GothicBBB-Medium&0.962216\\
722 ゴシック体&\tt gt&GothicBBB-Medium&GothicBBB-Medium&0.962216\\
723 \bottomrule
724 \end{tabular}
725 \end{center}
726 どちらのファミリにおいても,その bold シリーズはゴシック体の medium シリーズで
727 あることに注意.これは初期の DTP において和文フォントが2つ(それがちょうど\
728 Ryumin-Light, GothicBBB-Medium だった)しか利用できなかった時の名残であり,\pLaTeX{}
729 での標準設定とも同じである.
730 %</ja>
731
732 %<*en>
733 \item Japanese characters in math mode are typeset by the font family \texttt{mc}.
734 %</en>
735 %<*ja>
736 \item 数式モード中の和文文字は \texttt{mc} ファミリで出力される.
737 %</ja>
738 \end{itemize}
739
740 %<*en>
741 However, above settings are not sufficient for Japanese-based
742 documents. To typeset Japanese-based documents, you are better to use
743 class files other than \texttt{article.cls}, \texttt{book.cls}, and so on.  At
744 the present, we have the counterparts of \Pkg{jclasses} (standard
745 classes in \pLaTeX) and \Pkg{jsclasses} (classes by Haruhiko
746 Okumura), namely, \Pkg{ltjclasses} and \Pkg{ltjsclasses}.
747 %</en>
748 %<*ja>
749 しかしながら,上記の設定は日本語の文書にとって十分とは言えない.
750 日本語文書を組版するためには,\texttt{article.cls}, \texttt{book.cls} といった
751 欧文用のクラスファイルではなく,和文用のクラスファイルを用いた方がよい.
752 現時点では,\Pkg{jclasses} (\pLaTeX の標準クラス)と \Pkg{jsclasses}
753 (奥村晴彦氏によるクラスファイル)に対応するものとして,\Pkg{ltjclasses},
754 \Pkg{ltjsclasses} がそれぞれ用意されている.
755 %</ja>
756
757 %<*en>
758 \paragraph{\texttt{\char92 CID, \texttt{\char92 UTF}} and macros in OTF package}
759 Under \pLaTeX, \Pkg{otf} package (developed by Shuzaburo Saito) is
760 used for typesetting characters which is in Adobe-Japan1-6 CID but not
761 in JIS~X~0208. Since this package is widely used, \LuaTeX-ja
762 supports some of functions in \Pkg{otf} package.
763 If you want to use these functions, load \Pkg{luatexja-otf} package.
764 %</en>
765 %<*ja>
766 \paragraph{\texttt{\char92 CID, \texttt{\char92 UTF}} と OTF パッケージのマクロ}
767 \pLaTeX では,JIS~X~0208 にない Adobe-Japan1-6 の文字を出力するために,
768 齋藤修三郎氏による \Pkg{otf} パッケージが用いられていた.このパッケージは
769 広く用いられているため,\LuaTeX-ja においても \Pkg{otf} パッケージの機能の
770 一部をサポートしている.これらの機能を用いるためには \Pkg{luatexja-otf} パッケージ
771 を読み込めばよい.
772 %</ja>
773
774 \begin{LTXexample}
775 森\UTF{9DD7}外と内田百\UTF{9592}とが\UTF{9AD9}島屋に行く。
776
777 \CID{7652}飾区の\CID{13706}野家,
778 葛飾区の吉野家
779 \end{LTXexample}
780 %lltjp-listings.sty要修正?:↑「森」の直後で改行.
781
782
783 %<en>\subsection{Changing Fonts}
784 %<ja>\subsection{フォントの変更}
785 \label{ssub-chgfnt}
786
787 %<*en>
788 \paragraph{Remark: Japanese Characters in Math Mode}
789 Since \pTeX\ supports Japanese characters in math mode, there are
790 sources like the following:
791 %</en>
792 %<*ja>
793 \paragraph{意見:数式モード中の和文文字}
794 \pTeX では,特に何もしないでも数式中に和文文字を記述することができた.そのため,
795 以下のようなソースが見られた:
796 %</ja>
797 \begin{LTXexample}
798 $f_{高温}$~($f_{\text{high temperature}}$).
799 \[ y=(x-1)^2+2\quad よって\quad y>0 \]
800 $5\in 素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
801 \end{LTXexample}
802 %<*en>
803 We (the project members of \LuaTeX-ja) think that using
804 Japanese characters in math mode are allowed if and only if these are used as identifiers.
805 In this point of view,
806 %</en>
807 %<*ja>
808 \LuaTeX-ja プロジェクトでは,数式モード中での和文文字はそれらが識別子として用いられる
809 ときのみ許されると考えている.
810 この観点から,
811 %</ja>
812 \begin{itemize}
813 %<*en>
814 \item The lines 1~and~2 above are not correct, since `高温' in above is used as a textual label, and
815 `よって' is used as a conjunction.
816 %</en>
817 %<*ja>
818 \item 上記数式のうち 1, 2 行目は正しくない.なぜならば `高温' が意味のあるラベルと
819       して,`よって' が接続詞として用いられているからである.
820 %</ja>
821 %<*en>
822 \item However, the line~3 is correct, since `素' is used as an identifier.
823 %</en>
824 %<*ja>
825 \item しかしながら,3行目は `素' が識別子として用いられているので正しい.
826 %</ja>
827 \end{itemize}
828 %<*en>
829 Hence, in our opinion, the above input should be corrected as:
830 %</en>
831 %<*ja>
832 したがって,\LuaTeX-ja プロジェクトの意見としては,上記の入力は次のように直されるべき
833 である:
834 %</ja>
835 \begin{LTXexample}
836 $f_{\text{高温}}$~%
837 ($f_{\text{high temperature}}$).
838 \[ y=(x-1)^2+2\quad
839   \mathrel{\text{よって}}\quad y>0 \]
840 $5\in 素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
841 \end{LTXexample}
842 %BUG?: \{\}がなければ「素」がでない.上の段落の「よって」もでてない.
843 %<*en>
844 We also believe that using Japanese characters as identifiers is rare,
845 hence we don't describe how to change Japanese fonts in math mode in
846 this chapter. For the method, please see Subsection~\ref{ssec-math}.
847 %</en>
848 %<*ja>
849 また \LuaTeX-ja プロジェクトでは,和文文字が識別子として用いられることはほとんどない
850 と考えており,したがってこの節では数式モード中の和文フォントを変更する方法については
851 記述しない.この方法については \ref{ssec-math} 節を参照のこと.
852 %</ja>
853
854 %<*en>
855 \paragraph{plain \TeX}
856 To change Japanese fonts in plain \TeX, you must use the primitive
857 \verb+\jfont+. So please see Subsection~\ref{ssec-jfont}.
858 %</en>
859 %<*ja>
860 \paragraph{plain \TeX}
861 plain \TeX で和文フォントを変更するためには,\verb+\jfont+ プリミティブを用いなけれ
862 ばならない.\ref{ssec-jfont} 節を参照.
863 %</ja>
864
865 %<*en>
866 \paragraph{NFSS2}
867 For \LaTeXe, \LuaTeX-ja adopted most of the font selection system of \pLaTeXe\ (in \texttt{plfonts.dtx}).
868 %</en>
869 %<*ja>
870 \paragraph{NFSS2}
871 \LaTeXe については,\LuaTeX-ja ではフォント選択システムを \pLaTeXe\ (\texttt{plfonts.dtx})
872 の大部分をそのまま採用している.
873 %</ja>
874 \begin{itemize}
875 %<*en>
876 \item Two control sequences \verb+\mcdefault+ and \verb+\gtdefault+ are
877       used to specify the default font families for \emph{mincho} and
878       \emph{gothic}, respectively. Default values: \texttt{mc} for
879       \verb+\mcdefault+ and \texttt{gt} for \verb+\gtdefault+.
880 %</en>
881 %<*ja>
882 \item 2つのコントロールシーケンス \verb+\mcdefault+ と \verb+\gtdefault+ がそれぞ
883       れ明朝体とゴシック体のデフォルトのフォントファミリを指定するために用いられる.
884       初期値:\verb+\mcdefault+ は \texttt{mc},\verb+\gtdefault+ は \texttt{gt}.
885 %</ja>
886 %<*en>
887 \item Commands \verb+\fontfamily+, \verb+\fontseries+,
888       \verb+\fontshape+ and \verb+\selectfont+ can be used to change
889       attributes of Japanese fonts.
890 %</en>
891 %<*ja>
892 \item \verb+\fontfamily+, \verb+\fontseries+, \verb+\fontshape+, そして
893       \verb+\selectfont+ が和文フォントの属性を変更するために使用できる.
894 %</ja>
895
896 %<*en>
897 \begin{center}
898 \begin{tabular}{cccccc}
899 \toprule
900 &\textbf{encoding}&\textbf{family}&\textbf{series}&\textbf{shape}&\textbf{selection}\\\midrule
901 alphabetic fonts
902 &\verb+\romanencoding+&\verb+\romanfamily+&\verb+\romanseries+&\verb+\romanshape+
903 &\verb+\useroman+\\
904 Japanese fonts
905 &\verb+\kanjiencoding+&\verb+\kanjifamily+&\verb+\kanjiseries+&\verb+\kanjishape+
906 &\verb+\usekanji+\\
907 both&---&--&\verb+\fontseries+&\verb+\fontshape+&---\\
908 auto select&\verb+\fontencoding+&\verb+\fontfamily+&---&---&\verb+\usefont+\\
909 \bottomrule
910 \end{tabular}
911 \end{center}
912 %</en>
913 %<*ja>
914 \begin{center}
915 \begin{tabular}{cccccc}
916 \toprule
917 &\textbf{エンコーディング}&\textbf{ファミリ}&\textbf{シリーズ}&\textbf{シェープ}&\textbf{選択}\\\midrule
918 欧文フォント
919 &\verb+\romanencoding+&\verb+\romanfamily+&\verb+\romanseries+&\verb+\romanshape+
920 &\verb+\useroman+\\
921 和文フォント
922 &\verb+\kanjiencoding+&\verb+\kanjifamily+&\verb+\kanjiseries+&\verb+\kanjishape+
923 &\verb+\usekanji+\\
924 両方&---&--&\verb+\fontseries+&\verb+\fontshape+&---\\
925 自動選択&\verb+\fontencoding+&\verb+\fontfamily+&---&---&\verb+\usefont+\\
926 \bottomrule
927 \end{tabular}
928 \end{center}
929 %</ja>
930
931 %<*en>
932       \verb+\fontencoding{<encoding>}+ changes the encoding of alphabetic fonts
933       or Japanese fonts depending on the argument. For example,
934       \verb+\fontencoding{JY3}+ changes the encoding of Japanese fonts to
935       \texttt{JY3} and \verb+\fontencoding{T1}+ changes the encoding of
936       alphabetic fonts to \texttt{T1}.
937       \verb+\fontfamily+ also changes the family of Japanese fonts, alphabetic
938       fonts, \emph{or both}. For detail, see Subsection~\ref{ssub-nfsspat}.
939 %</en>
940 %<*ja>
941       ここで,\verb+\fontencoding{<encoding>}+ は,引数により和文側か欧文
942       側かのどちらかのエンコーディングを変更する.例えば,
943       \verb+\fontencoding{JY3}+ は和文フォントのエンコーディングを
944       \texttt{JY3}に変更し,\verb+\fontencoding{T1}+ は欧文フォント側を
945       \texttt{T1}へと変更する.\verb+\fontfamily+ も引数により和文側,欧文
946       側,\textbf{あるいは両方}のフォントファミリを変更する.詳細は
947       \ref{ssub-nfsspat}節を参照すること.
948 %</ja>
949
950 %<*en>
951 \item For defining a Japanese font family, use
952       \verb+\DeclareKanjiFamily+ instead of
953       \verb+\DeclareFontFamily+. However, in the present implementation,
954       using \verb+\DeclareFontFamily+ doesn't cause any problem.
955 %</en>
956 %<*ja>
957 \item 和文フォントファミリの定義には \verb+\DeclareFontFamily+ の
958       代わりに \verb+\DeclareKanjiFamily+ を用いる.しかし,現在の
959       実装では \verb+\DeclareFontFamily+ を用いても問題は生じない.
960 %</ja>
961 \end{itemize}
962
963 \subsection{fontspec}
964 \label{ssec-fontspec}
965 %<*en>
966 To coexist with the \Pkg{fontspec} package, it is needed to load
967 \Pkg{luatexja-fontspec} package in the preamble. This additional
968 package automatically loads \Pkg{luatexja} and \Pkg{fontspec}
969 package, if needed.
970 %</en>
971 %<*ja>
972 \Pkg{fontspec} パッケージと同様の機能を和文フォントに対しても用いるためには,
973 \Pkg{luatexja-fontspec} パッケージをプリアンブルで読み込む必要がある.このパッケージ
974 は必要ならば自動で \Pkg{luatexja} パッケージと \Pkg{fontspec} パッケージを読み込む.
975 %</ja>
976
977 %<*en>
978 In \Pkg{luatexja-fontspec} package, the following 7~commands are defined as
979 counterparts of original commands in the \Pkg{fontspec} package:
980 %</en>
981 %<*ja>
982 \Pkg{luatexja-fontspec} パッケージでは,以下の7つのコマンドを \Pkg{fontspec}
983 パッケージの元のコマンドに対応するものとして定義している:
984 %</ja>
985 %<*en>
986 \begin{center}
987 \begin{tabular}{ccccc}
988 \toprule
989 Japanese fonts
990 &\verb+\jfontspec+&\verb+\setmainjfont+&\verb+\setsansjfont+&\verb+\newjfontfamily+\\
991 alphabetic fonts
992 &\verb+\fontspec+&\verb+\setmainfont+&\verb+\setsansfont+&\verb+\newfontfamily+\\
993 \midrule
994 Japanese fonts
995 &\verb+\newjfontface+&\verb+\defaultjfontfeatures+&\verb+\addjfontfeatures+\\
996 alphabetic fonts
997 &\verb+\newfontface+&\verb+\defaultfontfeatures+&\verb+\addfontfeatures+\\
998 \bottomrule
999 \end{tabular}
1000 \end{center}
1001 %</en>
1002 %<*ja>
1003 \begin{center}
1004 \begin{tabular}{ccccc}
1005 \toprule
1006 和文フォント
1007 &\verb+\jfontspec+&\verb+\setmainjfont+&\verb+\setsansjfont+&\verb+\newjfontfamily+\\
1008 欧文フォント
1009 &\verb+\fontspec+&\verb+\setmainfont+&\verb+\setsansfont+&\verb+\newfontfamily+\\
1010 \midrule
1011 和文フォント
1012 &\verb+\newjfontface+&\verb+\defaultjfontfeatures+&\verb+\addjfontfeatures+\\
1013 欧文フォント
1014 &\verb+\newfontface+&\verb+\defaultfontfeatures+&\verb+\addfontfeatures+\\
1015 \bottomrule
1016 \end{tabular}
1017 \end{center}
1018 %</ja>
1019
1020 \begin{LTXexample}
1021 \fontspec[Numbers=OldStyle]{TeX Gyre Termes}
1022 \jfontspec{IPAexMincho}
1023 JIS~X~0213:2004→辻
1024
1025 \addjfontfeatures{CJKShape=JIS1990}
1026 JIS~X~0208:1990→辻
1027 \end{LTXexample}
1028
1029 %<*en>
1030 Note that there is no command named \verb+\setmonojfont+, since it is
1031 popular for Japanese fonts that nearly all Japanese glyphs have same
1032 widths.  Also note that the kerning feature is set off by default in
1033 these 7~commands, since this feature and \textbf{JAglue} will clash (see
1034 \ref{para-kern}).
1035 %</en>
1036 %<*ja>
1037 和文フォントについては全ての和文文字のグリフがほぼ等幅であるのが普通であるため,
1038 \verb+\setmonojfont+ コマンドは存在しないことに注意.また,これらの和文用の7つのコマ
1039 ンドでは Kerning feature はデフォルトでは off となっている.これはこの
1040 feature が \textbf{JAglue} と衝突するためである(\ref{para-kern} 節を参照).
1041 %</ja>
1042
1043 %<en>\section{Changing Parameters}
1044 %<ja>\section{パラメータの変更}
1045
1046 %<*en>
1047 There are many parameters in \LuaTeX-ja. And due to the behavior of \LuaTeX,
1048 most of them are not stored as internal register of \TeX, but as an
1049 original storage system in \LuaTeX-ja. Hence, to assign or acquire those
1050 parameters, you have to use commands \verb+\ltjsetparameter+ and
1051 \verb+\ltjgetparameter+.
1052 %</en>
1053 %<*ja>
1054 \LuaTeX-ja には多くのパラメータが存在する.そして \LuaTeX の仕様のために,
1055 その多くは \TeX のレジスタにではなく,\LuaTeX-ja 独自の方法で保持されている.
1056 そのため,これらのパラメータを設定・取得するためには \verb+\ltjsetparameter+ と \verb+\ltjgetparameter+ を
1057 用いる必要がある.
1058 %</ja>
1059
1060 %<en>\subsection{Editing the range of \textbf{JAchar}s}
1061 %<ja>\subsection{\textbf{JAchar} の範囲の設定}
1062
1063 %<*en>
1064 To edit the range of \textbf{JAchar}s, you have to assign a non-zero
1065 natural number which is less than 217 to the character range first. This
1066 can be done by using \verb+\ltjdefcharrange+ primitive. For example, the
1067 next line assigns whole characters in Supplementary Ideographic Plane
1068 and the character `漢' to the range number~100.
1069 %</en>
1070 %<*ja>
1071 \textbf{JAchar} の範囲を設定するためには,まず各文字に0より大きく217より小さい index を
1072 割り当てる必要がある.これには \verb+\ltjdefcharrange+ プリミティブを用いる.
1073 例えば,次のように書くことで追加漢字面 (SIP) にある全ての文字と `漢' が
1074 「100番の文字範囲」に属するように設定される.
1075 %</ja>
1076 \begin{lstlisting}
1077 \ltjdefcharrange{100}{"10000-"1FFFF,`漢}
1078 \end{lstlisting}
1079 %<*en>
1080 This assignment of numbers to ranges are always global, so you should
1081 not do this in the middle of a document.
1082 %</en>
1083 %<*ja>
1084 この文字範囲の割り当ては常にグローバルであり,したがって文書の途中で
1085 この操作をするべきではない.
1086 %</ja>
1087
1088 %<*en>
1089 If some character has been belonged to some non-zero numbered range,
1090 this will be overwritten by the new setting. For example, whole SIP
1091 belong to the range~4 in the default setting of \LuaTeX-ja, and if you
1092 specify the above line, then SIP will belong to the range~100 and be
1093 removed from the range~4.
1094 %</en>
1095 %<*ja>
1096 もし指定されたある文字がある非零番号の範囲に属していたならば,これは新しい設定で
1097 上書きされる.例えば,SIP は全て \LuaTeX-ja のデフォルトでは4番の文字範囲に
1098 属しているが,上記の指定を行えば SIP は100番に属すようになり,4番からは除かれる.
1099 %</ja>
1100
1101 %<*en>
1102 After assigning numbers to ranges, the \textsf{jacharrange} parameter can
1103 be used to customize which character range will be treated as ranges of
1104 \textbf{JAchar}s, as the following line (this is just the default
1105 setting of \LuaTeX-ja):
1106 %</en>
1107 %<*ja>
1108 文字範囲に番号を割り当てた後は,\textsf{jacharrange} パラメータが \textbf{JAchar} と
1109 して扱われる文字の範囲を設定するために用いられる.例えば,以下は \LuaTeX-ja の
1110 初期設定である:
1111 %</ja>
1112 \begin{verbatim}
1113 \ltjsetparameter{jacharrange={-1, +2, +3, -4, -5, +6, +7, +8}}
1114 \end{verbatim}
1115 %<*en>
1116 The argument to \textsf{jacharrange} parameter is a list of integer.
1117 Negative integer $-n$ in the list means that `the characters that belong to
1118 range~$n$ are treated as \textbf{ALchar}', and positive integer $+n$ means
1119 that `the characters that belong to range~$n$ are treated as \textbf{JAchar}'.
1120 %</en>
1121 %<*ja>
1122 \textsf{jacharrange} パラメータには整数のリストを与える.
1123 リスト中の負の整数 $-n$ は「文字範囲 $n$ に属する文字は \textbf{ALchar} として
1124 扱われる」ことを意味し,正の整数 $+n$ は \textbf{JAchar} として扱うことを意味する.
1125 %</ja>
1126
1127 %<*en>
1128 \paragraph{Default Setting}
1129 \LuaTeX-ja predefines eight character ranges for convenience. They are
1130 determined from the following data:
1131 %</en>
1132 %<*ja>
1133 \paragraph{初期設定}
1134 \LuaTeX-ja では8つの文字範囲を設定している.これらは以下のデータに基づいて決定して
1135 いる.
1136 %</ja>
1137 \begin{itemize}
1138 %<*en>
1139 \item Blocks in Unicode~6.0.
1140 %</en>
1141 %<*ja>
1142 \item Unicode~6.0 のブロック.
1143 %</ja>
1144 %<*en>
1145 \item The \texttt{Adobe-Japan1-UCS2} mapping between a CID Adobe-Japan1-6 and Unicode.
1146 %</en>
1147 %<*ja>
1148 \item \texttt{Adobe-Japan1-UCS2} による Adobe-Japan1-6 の CID と Unicode の間の
1149       マッピング.
1150 %</ja>
1151 %<*en>
1152 \item The \texttt{PXbase} bundle for \upTeX\ by Takayuki Yato.
1153 %</en>
1154 %<*ja>
1155 \item 八登崇之氏による \upTeX 用の \texttt{PXbase} バンドル.
1156 %</ja>
1157 \end{itemize}
1158
1159 %<*en>
1160 Now we describe these eight ranges. The alphabet `J' or `A' after the
1161 number shows whether characters in the range is treated as
1162 \textbf{JAchar}s or not by default. These settings are similar to the
1163 \texttt{prefercjk} settings defined in \texttt{PXbase} bundle.
1164 %</en>
1165 %<*ja>
1166 以下ではこれら8つの文字範囲について記述する.番号のあとのアルファベット `J' と `A'
1167 はデフォルトで \textbf{JAchar} か \textbf{ALchar} かを表している.これらの設定は
1168 \texttt{PXbase} バンドルで定義されている \texttt{prefercjk} と類似のものである.
1169 %</ja>
1170 \begin{description}
1171 %<*en>
1172 \item[Range~8${}^{\text{J}}$] Symbols in the intersection of the upper half of ISO~8859-1
1173          (Latin-1 Supplement) and JIS~X~0208 (a basic character set for Japanese). This character range
1174          consists of the following characters:
1175 %</en>
1176 %<*ja>
1177 \item[範囲 8${}^{\text{J}}$] ISO~8859-1 の上位領域(ラテン1補助)と
1178                              JIS~X~0208 の共通部分にある記号.この文字範囲は
1179                              以下の文字で構成される:
1180 %</ja>
1181 \begin{multicols}{2}
1182 \begin{itemize}
1183 \def\ch#1#2{\item \char"#1\ (\texttt{U+00#1}, #2)}%"
1184 %<*en>
1185 \ch{A7}{Section Sign}
1186 \ch{A8}{Diaeresis}
1187 \ch{B0}{Degree sign}
1188 \ch{B1}{Plus-minus sign}
1189 \ch{B4}{Spacing acute}
1190 \ch{B6}{Paragraph sign}
1191 \ch{D7}{Multiplication sign}
1192 \ch{F7}{Division Sign}
1193 %</en>
1194 %<*ja>
1195 \ch{A7}{節記号}
1196 \ch{A8}{トレマ}
1197 \ch{B0}{度}
1198 \ch{B1}{正又は負符号}
1199 \ch{B4}{アキュート・アクセント}
1200 \ch{B6}{段落記号}
1201 \ch{D7}{乗算記号}
1202 \ch{F7}{除算記号}
1203 %</ja>
1204 \end{itemize}
1205 \end{multicols}
1206
1207 %<*en>
1208 \item[Range~1${}^{\text{A}}$] Latin characters that some of them are included in Adobe-Japan1-6.
1209 This range consist of the following Unicode ranges, \emph{except characters in the range~8 above}:
1210 %</en>
1211 %<*ja>
1212 \item[範囲 1${}^{\text{A}}$] ラテン文字.一部はAdobe-Japan1-6 にも含まれている.
1213                              この範囲は以下の Unicode のブロックから構成されている.
1214                              \textbf{ただし,範囲 8 は除く.}
1215 %</ja>
1216 \begin{multicols}{2}
1217 \begin{itemize}
1218 %<*en>
1219 \item \texttt{U+0080}--\texttt{U+00FF}: Latin-1 Supplement
1220 \item \texttt{U+0100}--\texttt{U+017F}: Latin Extended-A
1221 \item \texttt{U+0180}--\texttt{U+024F}: Latin Extended-B
1222 \item \texttt{U+0250}--\texttt{U+02AF}: IPA Extensions
1223 \item \texttt{U+02B0}--\texttt{U+02FF}: Spacing Modifier Letters
1224 \item \texttt{U+0300}--\texttt{U+036F}: Combining Diacritical Marks
1225 \item \texttt{U+1E00}--\texttt{U+1EFF}: Latin Extended Additional
1226 %</en>
1227 %<*ja>
1228 \item \texttt{U+0080}--\texttt{U+00FF}: ラテン1補助
1229 \item \texttt{U+0100}--\texttt{U+017F}: ラテン文字拡張A
1230 \item \texttt{U+0180}--\texttt{U+024F}: ラテン文字拡張B
1231 \item \texttt{U+0250}--\texttt{U+02AF}: IPA拡張(国際音声記号)
1232 \item \texttt{U+02B0}--\texttt{U+02FF}: 前進を伴う修飾文字
1233 \item \texttt{U+0300}--\texttt{U+036F}: ダイアクリティカルマーク(合成可能)
1234 \item \texttt{U+1E00}--\texttt{U+1EFF}: ラテン文字拡張追加
1235 %</ja>
1236 \par\
1237 \end{itemize}
1238 \end{multicols}
1239 %<*en>
1240 \item[Range~2${}^{\text{J}}$] Greek and Cyrillic letters. JIS~X~0208 (hence most of Japanese
1241            fonts) has some of these characters.
1242 %</en>
1243 %<*ja>
1244 \item[範囲 2${}^{\text{J}}$] ギリシャ文字とキリル文字.JIS~X~0208(したがって多くの
1245                              和文フォント)はこれらの文字を持つ.
1246 %</ja>
1247 \begin{multicols}{2}
1248 \begin{itemize}
1249 %<*en>
1250 \item \texttt{U+0370}--\texttt{U+03FF}: Greek and Coptic
1251 \item \texttt{U+0400}--\texttt{U+04FF}: Cyrillic
1252 \item \texttt{U+1F00}--\texttt{U+1FFF}: Greek Extended
1253 %</en>
1254 %<*ja>
1255 \item \texttt{U+0370}--\texttt{U+03FF}: ギリシア文字及びコプト文字
1256 \item \texttt{U+0400}--\texttt{U+04FF}: キリル文字
1257 \item \texttt{U+1F00}--\texttt{U+1FFF}: キリル文字補助
1258 %</ja>
1259 \\\
1260 \end{itemize}
1261 \end{multicols}
1262 %<*en>
1263 \item[Range~3${}^{\text{J}}$] Punctuations and Miscellaneous symbols. The block list is
1264            indicated in Table~\ref{table-rng3}.
1265 %</en>
1266 %<*ja>
1267 \item[範囲 3${}^{\text{J}}$] 句読点と記号類.ブロックのリストは表~\ref{table-rng3}
1268                              に示してある.
1269 %</ja>
1270 \begin{table}[!tb]
1271 %<*en>
1272 \caption{Unicode blocks in predefined character range~3.}
1273 %</en>
1274 %<*ja>
1275 \caption{文字範囲 3 に指定されている Unicode ブロック.}
1276 %</ja>
1277 \label{table-rng3}
1278 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
1279 \begin{center}\small
1280 \begin{tabular}{llll}
1281 %<*en>
1282 "2000--"206F&General Punctuation&
1283 "2070--"209F&Superscripts and Subscripts\\
1284 "20A0--"20CF&Currency Symbols&
1285 "20D0--"20FF&Comb.\ Diacritical Marks for Symbols\\
1286 "2100--"214F&Letterlike Symbols&
1287 "2150--"218F&Number Forms\\
1288 "2190--"21FF&Arrows&
1289 "2200--"22FF&Mathematical Operators\\
1290 "2300--"23FF&Miscellaneous Technical&
1291 "2400--"243F&Control Pictures\\
1292 "2500--"257F&Box Drawing&
1293 "2580--"259F&Block Elements\\
1294 "25A0--"25FF&Geometric Shapes&
1295 "2600--"26FF&Miscellaneous Symbols\\
1296 "2700--"27BF&Dingbats&
1297 "2900--"297F&Supplemental Arrows-B\\
1298 "2980--"29FF&Misc.\ Mathematical Symbols-B&
1299 "2B00--"2BFF&Miscellaneous Symbols and Arrows\\
1300 "E000--"F8FF&Private Use Area&
1301 %</en>
1302 %<*ja>
1303 "2000--"206F&一般句読点&
1304 "2070--"209F&上付き・下付き\\
1305 "20A0--"20CF&通貨記号&
1306 "20D0--"20FF&記号用ダイアクリティカルマーク(合成可能)\\
1307 "2100--"214F&文字様記号&
1308 "2150--"218F&数字に準じるもの\\
1309 "2190--"21FF&矢印&
1310 "2200--"22FF&数学記号(演算子)\\
1311 "2300--"23FF&その他の技術用記号&
1312 "2400--"243F&制御機能用記号\\
1313 "2500--"257F&罫線素片&
1314 "2580--"259F&ブロック要素\\
1315 "25A0--"25FF&幾何学模様&
1316 "2600--"26FF&その他の記号\\
1317 "2700--"27BF&装飾記号&
1318 "2900--"297F&補助矢印B\\
1319 "2980--"29FF&その他の数学記号B&
1320 "2B00--"2BFF&その他の記号及び矢印\\
1321 "E000--"F8FF&私用領域(外字領域)&
1322 %</ja>
1323 \end{tabular}
1324 \end{center}
1325 \end{table}
1326 %<*en>
1327 \item[Range~4${}^{\text{A}}$] Characters usually not in Japanese fonts. This range consists
1328            of almost all Unicode blocks which are not in other
1329            predefined ranges. Hence, instead of showing the block list,
1330            we put the definition of this range itself:
1331 %</en>
1332 %<*ja>
1333 \item[範囲 4${}^{\text{A}}$] 通常和文フォントには含まれていない文字.
1334                              この範囲は他の範囲にないほとんど全ての Unicode ブロック
1335                              で構成されている.したがって,ブロックのリストを示す
1336                              代わりに,範囲の定義そのものを示す:
1337 %</ja>
1338 \begin{lstlisting}
1339 \ltjdefcharrange{4}{%
1340    "500-"10FF, "1200-"1DFF, "2440-"245F, "27C0-"28FF, "2A00-"2AFF,
1341   "2C00-"2E7F, "4DC0-"4DFF, "A4D0-"A82F, "A840-"ABFF, "FB50-"FE0F,
1342   "FE20-"FE2F, "FE70-"FEFF, "FB00-"FB4F, "10000-"1FFFF} % non-Japanese
1343 \end{lstlisting}
1344 %<*en>
1345 \item[Range~5${}^{\text{A}}$] Surrogates and Supplementary Private Use Areas.
1346 %</en>
1347 %<*ja>
1348 \item[範囲 5${}^{\text{A}}$] 代用符号と補助私用領域.
1349 %</ja>
1350 %<*en>
1351 \item[Range~6${}^{\text{J}}$] Characters used in Japanese. The block list is indicated in Table~\ref{table-rng6}.
1352 %</en>
1353 %<*ja>
1354 \item[範囲 6${}^{\text{J}}$] 日本語で用いられる文字.ブロックのリストは
1355                              表~\ref{table-rng6} に示す.
1356 %</ja>
1357 \begin{table}[!tb]
1358 %<*en>
1359 \caption{Unicode blocks in predefined character range~6.}
1360 %</en>
1361 %<*ja>
1362 \caption{文字範囲 6 に指定されている Unicode ブロック.}
1363 %</ja>
1364 \label{table-rng6}
1365 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
1366 \begin{center}\small
1367 \begin{tabular}{llll}
1368 %<*en>
1369 "2460--"24FF&Enclosed Alphanumerics&
1370 "2E80--"2EFF&CJK Radicals Supplement\\
1371 "3000--"303F&CJK Symbols and Punctuation&
1372 "3040--"309F&Hiragana\\
1373 "30A0--"30FF&Katakana&
1374 "3190--"319F&Kanbun\\
1375 "31F0--"31FF&Katakana Phonetic Extensions&
1376 "3200--"32FF&Enclosed CJK Letters and Months\\
1377 "3300--"33FF&CJK Compatibility&
1378 "3400--"4DBF&CJK Unified Ideographs Extension A\\
1379 "4E00--"9FFF&CJK Unified Ideographs&
1380 "F900--"FAFF&CJK Compatibility Ideographs\\
1381 "FE10--"FE1F&Vertical Forms&
1382 "FE30--"FE4F&CJK Compatibility Forms\\
1383 "FE50--"FE6F&Small Form Variants&
1384 "{20}000--"{2F}FFF&(Supplementary Ideographic Plane)
1385 %</en>
1386 %<*ja>
1387 "2460--"24FF&囲み英数字&
1388 "2E80--"2EFF&CJK部首補助\\
1389 "3000--"303F&CJKの記号及び句読点&
1390 "3040--"309F&平仮名\\
1391 "30A0--"30FF&片仮名&
1392 "3190--"319F&漢文用記号(返り点)\\
1393 "31F0--"31FF&片仮名拡張&
1394 "3200--"32FF&囲みCJK文字・月\\
1395 "3300--"33FF&CJK互換用文字&
1396 "3400--"4DBF&CJK統合漢字拡張A\\
1397 "4E00--"9FFF&CJK統合漢字&
1398 "F900--"FAFF&CJK互換漢字\\
1399 "FE10--"FE1F&縦書き形&
1400 "FE30--"FE4F&CJK互換形\\
1401 "FE50--"FE6F&小字形&
1402 "{20}000--"{2F}FFF&(追加漢字面)
1403 %</ja>
1404 \end{tabular}
1405 \end{center}
1406 \end{table}
1407 %<*en>
1408 \item[Range~7${}^{\text{J}}$] Characters used in CJK languages, but not included in  Adobe-Japan1-6.
1409 The block list is indicated in Table~\ref{table-rng7}.
1410 %</en>
1411 %<*ja>
1412 \item[範囲 7${}^{\text{J}}$] CJK 言語で用いられる文字のうち,Adobe-Japan1-6 に
1413                             含まれていないもの.
1414                             ブロックのリストは表~\ref{table-rng7} に示す.
1415 %</ja>
1416 \begin{table}[!tb]
1417 %<*en>
1418 \caption{Unicode blocks in predefined character range~7.}
1419 %</en>
1420 %<*ja>
1421 \caption{文字範囲 7 に指定されている Unicode ブロック.}
1422 %</ja>
1423 \label{table-rng7}
1424 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
1425 \begin{center}\small
1426 \begin{tabular}{llll}
1427 %<*en>
1428 "1100--"11FF&Hangul Jamo&
1429 "2F00--"2FDF&Kangxi Radicals\\
1430 "2FF0--"2FFF&Ideographic Description Characters&
1431 "3100--"312F&Bopomofo\\
1432 "3130--"318F&Hangul Compatibility Jamo&
1433 "31A0--"31BF&Bopomofo Extended\\
1434 "31C0--"31EF&CJK Strokes&
1435 "A000--"A48F&Yi Syllables\\
1436 "A490--"A4CF&Yi Radicals&
1437 "A830--"A83F&Common Indic Number Forms\\
1438 "AC00--"D7AF&Hangul Syllables&
1439 "D7B0--"D7FF&Hangul Jamo Extended-B
1440 %</en>
1441 %<*ja>
1442 "1100--"11FF&ハングル字母&
1443 "2F00--"2FDF&康熙部首\\
1444 "2FF0--"2FFF&漢字構成記述文字&
1445 "3100--"312F&注音字母 (注音符号)\\
1446 "3130--"318F&ハングル互換字母&
1447 "31A0--"31BF&注音字母拡張\\
1448 "31C0--"31EF&CJKの筆画&
1449 "A000--"A48F&イ文字\\
1450 "A490--"A4CF&イ文字部首&
1451 "A830--"A83F&共通インド数字に準じるもの\\
1452 "AC00--"D7AF&ハングル音節文字&
1453 "D7B0--"D7FF&ハングル字母拡張B
1454 %</ja>
1455 \end{tabular}
1456 \end{center}
1457 \end{table}
1458 \end{description}
1459
1460
1461 %<en>\subsection{\Param{kanjiskip} and \Param{xkanjiskip}}
1462 %<ja>\subsection{\Param{kanjiskip} と \Param{xkanjiskip}}
1463 \label{subs-kskip}
1464
1465 %<*en>
1466 \textbf{JAglue} is divided into the following three categories:
1467 %</en>
1468 %<*ja>
1469 \textbf{JAglue} は以下の3つのカテゴリに分類される:
1470 %</ja>
1471 \begin{itemize}
1472 %<*en>
1473 \item Glues/kerns specified in JFM. If \verb+\inhibitglue+ is issued
1474       around a Japanese character, this glue will not be inserted at the
1475       place.
1476 %</en>
1477 %<*ja>
1478 \item JFM で指定されたグルー/カーン.もし \verb+\inhibitglue+ が和文文字の周りで
1479       発行されていれば,このグルーは挿入されない.
1480 %</ja>
1481 %<*en>
1482 \item The default glue which inserted between two \textbf{JAchar}s (\Param{%
1483       kanjiskip}).
1484 %</en>
1485 %<*ja>
1486 \item デフォルトで2つの \textbf{JAchar} の間に挿入されるグルー(\Param{kanjiskip}).
1487 %</ja>
1488 %<*en>
1489 \item The default glue which inserted between a \textbf{JAchar} and an
1490       \textbf{ALchar} (\Param{xkanjiskip}).
1491 %</en>
1492 %<*ja>
1493 \item デフォルトで \textbf{JAchar} と \textbf{ALchar} の間に挿入されるグルー(\Param{xkanjiskip}).
1494 %</ja>
1495 \end{itemize}
1496 %<*en>
1497 The value (a skip) of \Param{kanjiskip} or \Param{xkanjiskip} can be
1498 changed as the following.
1499 %</en>
1500 %<*ja>
1501 \Param{kanjiskip} や \Param{xkanjiskip} の値は以下のようにして変更可能である.
1502 %</ja>
1503 \begin{lstlisting}
1504 \ltjsetparameter{kanjiskip={0pt plus 0.4pt minus 0.4pt},
1505                  xkanjiskip={0.25\zw plus 1pt minus 1pt}}
1506 \end{lstlisting}
1507
1508 %<*en>
1509 It may occur that JFM contains the data of `ideal width of \Param{kanjiskip}'
1510 and/or `ideal width of \Param{xkanjiskip}'.
1511 To use these data from JFM, set the value of \Param{kanjiskip} or
1512 \Param{xkanjiskip} to \verb+\maxdimen+.
1513 %</en>
1514 %<*ja>
1515 JFM は「望ましい \Param{kanjiskip} の値」や「望ましい \Param{xkanjiskip} の値」を
1516 持っていることがある.
1517 これらのデータを使うためには,\Param{kanjiskip} や \Param{xkanjiskip} の
1518 値を \verb+\maxdimen+ の値に設定すればよい.
1519 %</ja>
1520
1521 %<en>\subsection{Insertion Setting of \Param{xkanjiskip}}
1522 %<ja>\subsection{\Param{xkanjiskip} の設定の挿入}
1523
1524 %<*en>
1525 It is not desirable that \Param{xkanjiskip} is inserted into every
1526 boundary between \textbf{JAchar}s and \textbf{ALchar}s. For example,
1527 \Param{xkanjiskip} should not be inserted after opening parenthesis
1528 (\textit{e.g.}, compare `(あ' and `(\hskip\ltjgetparameter{xkanjiskip}あ').
1529 \LuaTeX-ja can control whether \Param{xkanjiskip} can be inserted
1530 before/after a character, by changing \Param{jaxspmode} for \textbf{JAchar}s and
1531 \Param{alxspmode} parameters \textbf{ALchar}s respectively.
1532 %</en>
1533 %<*ja>
1534 \Param{xkanjiskip} がすべての \textbf{JAchar} と \textbf{ALchar} の境界に
1535 挿入されるのは望ましいことではない.例えば,\Param{xkanjiskip} は開き括弧の
1536 後には挿入されるべきではない(`(あ' と `(\hskip\ltjgetparameter{xkanjiskip}あ' を
1537 比べてみよ).
1538 \LuaTeX-ja では \Param{xkanjiskip} をある文字の前/後に挿入するかどうかを,
1539 \textbf{JAchar} に対しては \Param{jaxspmode} を,\textbf{ALchar} に対しては
1540 \Param{alxspmode} をそれぞれ変えることで制御することができる.
1541 %</ja>
1542 \begin{LTXexample}
1543 \ltjsetparameter{jaxspmode={`あ,preonly}, alxspmode={`\!,postonly}}
1544 pあq い!う
1545 \end{LTXexample}
1546
1547 %<*en>
1548 The second argument \texttt{preonly} means `the insertion of
1549 \Param{xkanjiskip} is allowed before this character, but not after'.
1550 the other possible values are \texttt{postonly}, \texttt{allow} and \texttt{
1551 inhibit}. ...
1552 %</en>
1553 %<*ja>
1554 2つ目の引数の \texttt{preonly} は「\Param{xkanjiskip} の挿入はこの文字の
1555 前でのみ許され,後では許さない」ことを意味する.他に指定可能な値は
1556 \texttt{postonly}, \texttt{allow}, \texttt{inhibit} である.
1557
1558 なお,現行の
1559 仕様では,\Param{jaxspmode}, \Param{alxspmode} はテーブルを共有しており,
1560 上のソースの1行目を次のように変えても同じことになる:
1561 \begin{verbatim}
1562 \ltjsetparameter{alxspmode={`あ,preonly}, jaxspmode={`\!,postonly}}
1563 \end{verbatim}
1564 また,これら2パラメータには数値で値を指定することもできる(第\ref{part-ref}部を参照).
1565 %</ja>
1566
1567 %<*en>
1568 If you want to enable/disable all insertions of \Param{kanjiskip} and
1569 \Param{xkanjiskip}, set \Param{autospacing} and \Param{autoxspacing}
1570 parameters to \texttt{true}/\texttt{false}, respectively.
1571 %</en>
1572 %<*ja>
1573 もし全ての \Param{kanjiskip} と \Param{xkanjiskip} の挿入を有効化/無効化
1574 したければ,それぞれ \Param{autospacing} と \Param{autoxspacing} を
1575 \texttt{true}/\texttt{false} に設定すればよい.
1576 %</ja>
1577
1578 %<en>\subsection{Shifting Baseline}
1579 %<ja>\subsection{ベースラインの移動}
1580
1581 %<*en>
1582 To make a match between a Japanese font and an alphabetic font, sometimes
1583 shifting of the baseline of one of the pair is needed. In \pTeX, this is achieved
1584 by setting \verb+\ybaselineshift+ to a non-zero length (the
1585 baseline of alphabetic fonts is shifted below). However, for documents
1586 whose main language is not Japanese, it is good to shift the baseline of
1587 Japanese fonts, but not that of alphabetic fonts.
1588 Because of this, \LuaTeX-ja can independently set the shifting amount
1589 of the baseline of alphabetic fonts (\Param{yalbaselineshift}
1590 parameter) and that of Japanese fonts (\Param{yjabaselineshift}
1591 parameter).
1592 %</en>
1593 %<*ja>
1594 和文フォントと欧文フォントを合わせるためには,時々どちらかのベースラインの移動が
1595 必要になる.\pTeX ではこれは \verb+\ybaselineshift+ を非零の長さに設定することで
1596 なされていた(欧文フォントのベースラインが下がる).しかし,日本語が主ではない
1597 文書に対しては,欧文フォントではなく和文フォントのベースラインを移動した方がよい.
1598 このため,\LuaTeX-ja では欧文フォントのベースラインのシフト量
1599 (\Param{yalbaselineshift} パラメータ)と和文フォントのベースラインのシフト量
1600 (\Param{yjabaselineshift}パラメータ)を独立に設定できるようになっている.
1601 %</ja>
1602
1603 \begin{LTXexample}
1604 \vrule width 150pt height 0.4pt depth 0pt\hskip-120pt
1605 \ltjsetparameter{yjabaselineshift=0pt, yalbaselineshift=0pt}abcあいう
1606 \ltjsetparameter{yjabaselineshift=5pt, yalbaselineshift=2pt}abcあいう
1607 \end{LTXexample}
1608 %<*en>
1609 Here the horizontal line in above is the baseline of a line.
1610 %</en>
1611 %<*ja>
1612 上の例において引かれている水平線がベースラインである.
1613 %</ja>
1614
1615 %<*en>
1616 There is an interesting side-effect: characters in different size can be
1617 vertically aligned center in a line, by setting two parameters appropriately.
1618 The following is an example (beware the value is not well tuned):
1619 %</en>
1620 %<*ja>
1621 この機能には面白い使い方がある:2つのパラメータを適切に設定することで,サイズの
1622 異なる文字を中心線に揃えることができるのだ.
1623 以下は一つの例である(値はあまり調整されていないことに注意):
1624 %</ja>
1625 \begin{LTXexample}
1626 xyz漢字
1627 {\scriptsize
1628   \ltjsetparameter{yjabaselineshift=-1pt,
1629     yalbaselineshift=-1pt}
1630   XYZひらがな
1631 }abcかな
1632 \end{LTXexample}
1633
1634
1635 %<en>\subsection{Cropmark}
1636 %<ja>\subsection{トンボ}
1637
1638 %<*en>
1639 Cropmark is a mark for indicating 4~corners and horizontal/vertical
1640 center of the paper. In Japanese, we call cropmark as tombo(w).
1641 \pLaTeX\ and this \LuaTeX-ja support `tombow' by their kernel.
1642 The following steps are needed to typeset cropmark:
1643 %</en>
1644 %<*ja>
1645 トンボは用紙の四つ角と水平/垂直方向の中心を表す印である.
1646 \pLaTeX と \LuaTeX-ja ではトンボの出力をサポートしている.
1647 トンボを出力するためには以下の手順が必要である:
1648 %</ja>
1649
1650 \begin{enumerate}
1651 %<*en>
1652 \item First, define the banner which will be printed at the upper left
1653       of the paper. This is done by assigning a token list to
1654       \verb+\@bannertoken+.
1655
1656 For example, the following sets banner as `\texttt{filename (YYYY-MM-DD hh:mm)}':
1657 %</en>
1658 %<*ja>
1659 \item まず,用紙の左上に印刷されるバナーを定義する.これは \verb+\@bannertoken+
1660       にトークンリストを与えることでなされる.
1661
1662 例えば,以下はバナーとして `\texttt{filename (YYYY-MM-DD hh:mm)}' を設定する:
1663 %</ja>
1664
1665 \begin{verbatim}
1666 \makeatletter
1667
1668 \hour\time \divide\hour by 60 \@tempcnta\hour \multiply\@tempcnta 60\relax
1669 \minute\time \advance\minute-\@tempcnta
1670 \@bannertoken{%
1671    \jobname\space(\number\year-\two@digits\month-\two@digits\day
1672    \space\two@digits\hour:\two@digits\minute)}%
1673 \end{verbatim}
1674
1675 \item ...
1676 \end{enumerate}
1677
1678
1679 %<en>\part{Reference}
1680 %<ja>\part{リファレンス}
1681 \label{part-ref}
1682 %<en>\section{Font Metric and Japanese Font}
1683 %<ja>\section{フォントメトリックと和文フォント}
1684 %<en>\subsection{\texttt{\char92jfont} primitive}
1685 %<ja>\subsection{\texttt{\char92jfont} プリミティブ}
1686 \label{ssec-jfont}
1687
1688 %<*en>
1689 To load a font as a Japanese font, you must use the
1690 \verb+\jfont+ primitive instead of~\verb+\font+, while
1691 \verb+\jfont+ admits the same syntax used in~\verb+\font+.
1692 \LuaTeX-ja automatically loads \Pkg{luaotfload} package,
1693 so TrueType/OpenType fonts with features can be used for Japanese fonts:
1694 %</en>
1695 %<*ja>
1696 フォントを和文フォントとして読み込むためには,\verb+\jfont+ プリミティブを
1697 \verb+\font+ プリミティブの代わりに用いる.
1698 \verb+\jfont+ プリミティブの文法は \verb+\font+ と同じである.
1699 \LuaTeX-ja は \Pkg{luaotfload} パッケージを自動的に読み込むので,
1700 TrueType/OpenType フォントに feature を指定したものを和文フォントとして用いる
1701 ことができる:
1702 %</ja>
1703 \begin{LTXexample}
1704 \jfont\tradgt={file:ipaexg.ttf:script=latn;%
1705   +trad;-kern;jfm=ujis} at 14pt
1706 \tradgt{}当/体/医/区
1707 \end{LTXexample}
1708
1709 %<*en>
1710 Note that the defined control sequence
1711 (\verb+\tradgt+ in the example above) using \verb+\jfont+ is not a
1712 \textit{font\_def} token, hence the input like \verb+\fontname\tradgt+
1713 causes a error.  We denote control sequences which are defined in
1714 \verb+\jfont+ by <jfont\_cs>.
1715 %</en>
1716 %<*ja>
1717 なお,\verb+\jfont+ で定義されたコントロールシーケンス(上の例だと \verb+\tradgt+)
1718 は \textit{font\_def} トークンではないので,\verb+\fontname\tradgt+ のような
1719 入力はエラーとなることに注意する.以下では \verb+\jfont+ で定義された
1720 コントロールシーケンスを <jfont\_cs> で表す.
1721 %</ja>
1722
1723 \paragraph{JFM}
1724 %<*en>
1725 As noted in Introduction, a JFM has measurements of characters and
1726 glues/kerns that are automatically inserted for Japanese
1727 typesetting. The structure of JFM will be described in the next
1728 subsection. At the calling of \verb+\jfont+ primitive, you must specify
1729 which JFM will be used for this font by the following keys:
1730 %</en>
1731 %<*ja>
1732 「はじめに」の節で述べたように,JFM は文字と和文組版で自動的に挿入される
1733 グルー/カーンの寸法情報を持っている.JFM の構造は次の小節で述べる.
1734 \verb+\jfont+ プリミティブの呼び出しの際には,どの JFM を用いるのかを以下のキーで
1735 指定する必要がある:
1736 %</ja>
1737
1738 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}\advance\leftmargin1\zw}
1739 \item[jfm=<name>]
1740 %<*en>
1741 Specify the name of JFM. If specified JFM has not been loaded, \LuaTeX-ja search and load
1742 a file named \texttt{jfm-<name>.lua}.
1743
1744 The following JFMs are shipped with \LuaTeX-ja:
1745 %</en>
1746 %<*ja>
1747 JFM の名前を指定する.もし以前に指定されたJFMが読み込まれていなければ,
1748 \texttt{jfm-<name>.lua} を読み込む.
1749
1750 以下の JFM が \LuaTeX-ja には同梱されている:
1751 %</ja>
1752 \begin{description}
1753 %<*en>
1754 \item[\tt jfm-ujis.lua] A standard JFM in \LuaTeX-ja. This JFM is
1755   based on \verb+upnmlminr-h.tfm+, a metric for UTF/OTF package that
1756   is used in \upTeX. When you use the \Pkg{luatexja-otf} package, you should use this JFM.
1757 %</en>
1758 %<*ja>
1759 \item[\tt jfm-ujis.lua] \LuaTeX-ja の標準 JFM である.この JFM は \upTeX で
1760   用いられる UTF/OTF パッケージ用のメトリックである \verb+upnmlminr-h.tfm+ を
1761   元にしている.\Pkg{luatexja-otf} パッケージを使うときはこの JFM を指定するべきである.
1762 %</ja>
1763 %<*en>
1764 \item[\tt jfm-jis.lua] A counterpart for \verb+jis.tfm+, `JIS font
1765   metric' which is widely used in \pTeX. A major difference of
1766   \texttt{jfm-ujis.lua} and this \texttt{jfm-jis.lua} is that
1767   most characters under \texttt{jfm-ujis.lua} are square-shaped,
1768   while that under \texttt{jfm-jis.lua} are horizontal
1769   rectangles.
1770 %</en>
1771 %<*ja>
1772 \item[\tt jfm-jis.lua] \pTeX で広く用いられている「JIS フォントメトリック」
1773   \verb+jis.tfm+ に相当する JFM である.\texttt{jfm-ujis.lua} とこの
1774   \texttt{jfm-jis.lua} の主な違いは,\texttt{jfm-ujis.lua} ではほとんどの文字が
1775   正方形状であるのに対し,\texttt{jfm-jis.lua} では横長の長方形状である.
1776 %</ja>
1777 %<*en>
1778 \item[\tt jfm-min.lua] A counterpart for \verb+min10.tfm+, which is one
1779   of the default Japanese font metric shipped with \pTeX. There
1780   are notable difference between this JFM and other 2~JFMs, as
1781   shown in Table~\ref{tab-difjfm}.
1782 %</en>
1783 %<*ja>
1784 \item[\tt jfm-min.lua] \pTeX に同梱されているデフォルトの和文フォントメトリック
1785   である \verb+min10.tfm+ に相当する JFM である.この JFM と他の2つの JFM の間には
1786   表 \ref{tab-difjfm} に示すような特筆すべき違いがある.
1787 %</ja>
1788 \end{description}
1789
1790 \item[jfmvar=<string>] Sometimes there is a need that ...
1791 \end{list}
1792
1793 \begin{table}[t]
1794 %<en>\caption{Differences between JFMs shipped with \LuaTeX-ja}
1795 %<ja>\caption{\LuaTeX-ja に同梱されている JFM の違い}
1796 \label{tab-difjfm}
1797 \ltjsetparameter{jacharrange={+3}}
1798 \begin{center}
1799 \def\r#1{{\jfont\g=psft:Ryumin-Light:jfm=#1 at 14.43324pt \g
1800 \setbox0=\vtop{\hsize=7\zw\noindent ◆◆◆◆◆◆◆
1801 ある日モモちゃんがお使いで迷子になって泣きました.}\copy0
1802 \vrule height 0pt depth \dp0}}
1803 \def\s#1{{\jfont\g=psft:Ryumin-Light:jfm=#1 at 14.43324pt \g
1804 \setbox0=\vtop{\hsize=7\zw\noindent ちょっと!何}\copy0}}
1805 \def\t#1{{\jfont\g=psft:Ryumin-Light:jfm=#1 at 19.24432pt \g
1806 \setbox0=\hbox{漢}%
1807 \vrule width 0.4pt height\ht0 depth\dp0\kern-.2pt\copy0
1808 \kern-\wd0\vrule width\wd0height .2pt depth .2pt
1809 \kern-\wd0\raise\ht0\hbox{\vrule width\wd0height .2pt depth .2pt}%
1810 \kern-\wd0\lower\dp0\hbox{\vrule width\wd0height .2pt depth .2pt}%
1811 \kern-.2pt\vrule width 0.4pt height\ht0 depth \dp0}}
1812 \begin{tabular}{rccc}
1813 \toprule
1814 &\tt jfm-ujis.lua&\tt jfm-jis.lua&\tt jfm-min.lua\\
1815 \midrule
1816 %<en>Example~1\footnotemark
1817 %<ja>例1\footnotemark
1818 &\r{ujis}&\r{jis}&\r{min}\\
1819 %<en>Example~2
1820 %<ja>例2
1821 &\s{ujis}&\s{jis}&\s{min}\\
1822 Bounding Box&\t{ujis}&\t{jis}&\t{min}\\
1823 \bottomrule
1824 \end{tabular}
1825 \end{center}
1826 \ltjsetparameter{jacharrange={-3}}
1827 \end{table}
1828 \footnotetext{from: 乙部厳己, min10フォントについて.
1829 \texttt{http://argent.shinshu-u.ac.jp/\~{\ }otobe/tex/files/min10.pdf}.}
1830
1831 %<en>\paragraph{Note: kern feature}
1832 %<ja>\paragraph{注意:kern feature}
1833 \label{para-kern}
1834 %<*en>
1835 Some fonts have information for inter-glyph spacing. However, this
1836 information is not well-compatible with \LuaTeX-ja.  More concretely,
1837 this kerning space from this information are inserted \emph{before} the
1838 insertion process of \textbf{JAglue}, and this causes incorrect spacing
1839 between two characters when both a glue/kern from the data in the font
1840 and it from JFM are present.
1841 %</en>
1842 %<*ja>
1843 いくつかのフォントはグリフ間のスペースについての情報を持っている.しかし,
1844 この情報は \LuaTeX-ja とはあまり相性がよくない.具体的には,この情報に基づいて挿入
1845 されるカーニングスペースは \textbf{JAglue} の挿入過程の\textbf{前に}挿入され,
1846 JFM に基づくグルー/カーンも挿入される場合には2文字間の意図しないスペースの原因と
1847 なる.
1848 %</ja>
1849
1850 \begin{itemize}
1851 %<*en>
1852 \item You should specify \texttt{-kern} in
1853   \verb+jfont+ primitive, when you want to use other font features,
1854   such as \texttt{script=...}\,.
1855 %</en>
1856 %<*ja>
1857 \item  \texttt{script=...} といった feature を使いたい場合には,\verb+\jfont+
1858   プリミティブに \texttt{-kern} を指定するべきである.
1859 %</ja>
1860 %<*en>
1861 \item If you want to use Japanese fonts in proportional width, and use
1862       information from this font, use \texttt{jfm-prop.lua} for its JFM, and ...
1863 %</en>
1864 %<*ja>
1865 \item もしプロポーショナル幅の和文フォントをそのフォントの情報に基づいて使いたい
1866   ならば,\texttt{jfm-prop.lua} を JFM として指定し,……
1867 %</ja>
1868
1869 TODO: kanjiskip?
1870 \end{itemize}
1871
1872
1873 %<en>\subsection{Prefix \texttt{psft}}
1874 %<ja>\subsection{\texttt{psft} プレフィックス}
1875 \label{ssec-psft}
1876 %<*en>
1877 Besides \texttt{file:}\ and \texttt{name:}\ prefixes, one can use \texttt{psft:}\
1878 prefix in \verb+\jfont+ (and~\verb+\font+) primitive,
1879 to specify a `name-only' Japanese font which
1880 will not be embedded to PDF. Typical use of this prefix is to specify
1881 the `standard' Japanese fonts, namely, `Ryumin-Light' and
1882 `GothicBBB-Medium'. For kerning or other information, that of Kozuka
1883 Mincho Pr6N Regular (this is a font by Adobe Inc., and included in
1884 Japanese Font Packs for Adobe Reader) will be used.
1885 %</en>
1886 %<*ja>
1887 \texttt{file:} と \texttt{name:} のプレフィックスに加えて,
1888 \verb+\jfont+ プリミティブ(と \verb+\font+ プリミティブ)では
1889 \texttt{psft:} プレフィックスを用いることができる.
1890 このプレフィックスを用いることで,PDF には埋め込まれない「名前だけの」
1891 和文フォントを指定することができる.典型的な使い方は「標準的な」和文フォント,
1892 つまり `Ryumin-Light' と `GothicBBB-Medium' を指定することである.
1893 この場合,カーニング他の情報は小塚明朝 Pr6N Regular
1894 (Adobe 社によるフォントで,Adobe Reader の日本語フォントパックに含まれている)
1895 が用いられる.
1896 %</ja>
1897
1898 \paragraph{\texttt{cid} key}
1899 \label{para-cid}
1900
1901  \texttt{cid} key, ...
1902
1903
1904 %<en>\subsection{Structure of JFM file}
1905 %<ja>\subsection{JFM ファイルの構造}
1906
1907 %<*en>
1908 A JFM file is a Lua script which has only one function call:
1909 %</en>
1910 %<*ja>
1911 JFM ファイルはただ一つの関数呼び出しを含む Lua スクリプトである:
1912 %</ja>
1913 \begin{verbatim}
1914 luatexja.jfont.define_jfm { ... }
1915 \end{verbatim}
1916 %<*en>
1917 Real data are stored in the table which indicated above by
1918 \verb+{ ... }+.  So, the rest of this subsection are devoted to describe the
1919 structure of this table.  Note that all lengths in a JFM file are
1920 floating-point numbers in design-size unit.
1921 %</en>
1922 %<*ja>
1923 実際のデータは上で \verb+{ ... }+ で示されたテーブルの中に格納されている.
1924 以下ではこのテーブルの構造について記す.
1925 なお,JFM ファイル中の長さは全て design-size を単位とする浮動小数点数であることに
1926 注意する.
1927 %</ja>
1928
1929 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}\advance\leftmargin1\zw}
1930
1931 \item[dir=<direction>]
1932 %<en>(required)
1933 %<ja>(必須)
1934
1935 %<en>The direction of JFM. At the present, only \texttt{'yoko'} is supported.
1936 %<ja>JFM の書字方向.現時点では \texttt{'yoko'} のみがサポートされる.
1937
1938 \item[zw=<length>]
1939 %<en>(required)
1940 %<ja>(必須)
1941
1942 %<en>The amount of the length of the `full-width'.
1943 %<ja>「全角幅」の長さ.
1944
1945 \item[zh=<length>]
1946 %<en>(required)
1947 %<ja>(必須)
1948
1949 %<en>The amount of the length of the `full-height' (height + depth).
1950 %<ja>「全角高さ」(height + depth)の長さ.
1951
1952 \item[kanjiskip=\{<natural>, <stretch>, <shrink>\}]
1953 %<en>(optional)
1954 %<ja>(任意)
1955
1956 %<*en>
1957 This field specifies the `ideal' amount of \Param{kanjiskip}. As noted
1958              in Subsection~\ref{subs-kskip}, if the parameter
1959              \Param{kanjiskip} is \verb+\maxdimen+, the value specified
1960              in this field is actually used (if this field is not specified in
1961              JFM, it is regarded as 0\,pt). Note that <stretch> and <shrink>
1962              fields are in design-size unit too.
1963 %</en>
1964 %<*ja>
1965 「理想的な」 \Param{kanjiskip} の量を指定する.\ref{subs-kskip} 節で述べたように,
1966 もし \Param{kanjiskip} が \verb+\maxdimen+ の値ならば,このフィールドで指定された
1967 値が実際には用いられる(もしこのフィールドが JFM で指定されていなければ,
1968 0\,pt であるものとして扱われる).<stretch> と <shrink> のフィールドも design-size
1969 が単位であることに注意せよ.
1970 %</ja>
1971
1972 \item[xkanjiskip=\{<natural>, <stretch>, <shrink>\}]
1973 %<en>(optional)
1974 %<ja>(任意)
1975
1976 %<*en>
1977 Like the \Param{kanjiskip} field, this field specifies the `ideal'
1978              amount of \Param{xkanjiskip}.
1979 %</en>
1980 %<*ja>
1981 \Param{kanjiskip} フィールドと同様に,\Param{xkanjiskip} の「理想的な」量を
1982 指定する.
1983 %</ja>
1984 \end{list}
1985
1986 %<*en>
1987 Besides from above fields, a JFM file have several sub-tables those
1988 indices are natural numbers.  The table indexed by~$i\in\omega$ stores
1989 information of `character class'~$i$. At least, the character class~0 is
1990 always present, so each JFM file must have a sub-table whose index is
1991 \texttt{[0]}.  Each sub-table (its numerical index is denoted by $i$) has
1992 the following fields:
1993 %</en>
1994 %<*ja>
1995 上記のフィールドに加えて,JFM ファイルはそのインデックスが自然数であるいくつかの
1996 サブテーブルを持つ.インデックスが $i\in\omega$ であるテーブルは「文字クラス」$i$ の
1997 情報を格納する.少なくとも,文字クラス0は常に存在するので,JFM ファイルはインデックス
1998 が \texttt{[0]} のサブテーブルを持たなければならない.それぞれのサブテーブル
1999 (そのインデックスを $i$ で表わす)は以下のフィールドを持つ:
2000 %</ja>
2001
2002 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}\advance\leftmargin1\zw}
2003 \item[chars=\{<character>, ...\}]
2004 %<en>(required except character class~0)
2005 %<ja>(文字クラス0を除いて必須)
2006
2007 %<*en>
2008 This field is a list of characters which are in this character
2009              type~$i$. This field is not required if $i=0$, since all
2010              \textbf{JAchar} which are not in any character class other
2011              than 0 are in the character class 0
2012              (hence, the character class~0 contains most of
2013              \textbf{JAchar}s). In the list, a character can be
2014              specified by its code number, or by the character itself
2015              (as a string of length~1). Moreover, there are `imaginary
2016              characters' which specified in the list. We will describe these later.
2017 %</en>
2018 %<*ja>
2019 このフィールドは文字クラス~$i$ に属する文字のリストである.このフィールドは $i=0$ の
2020 場合には必須ではない.なぜならば,文字クラス 0 には,0 以外の文字クラスに属するものを
2021 除いた全ての \textbf{JAchar} が属するからである(よって,文字クラス 0 はほとんどの
2022 \textbf{JAchar} を含む).このリストでは,文字はその文字コードを用いて,もしくは
2023 文字それ自体(長さ1の文字列)によって指定される.さらに,このリストで指定される
2024 「仮想的な文字」も存在する.これらについては後に記す.
2025 %</ja>
2026
2027 \item[width=<length>, height=<length>, depth=<length>, italic=<length>]
2028 %<en>(required)
2029 %<ja>(必須)
2030
2031 %<*en>
2032 Specify width of characters in character class~$i$, height, depth and
2033 the amount of italic correction. All characters in character class~$i$ are regarded that its width, height and depth are
2034 as values of these fields.
2035 But there is one exception: if \texttt{'prop'} is specified in \texttt{width} field, width of a character becomes that of its `real' glyph
2036 %</en>
2037 %<*ja>
2038 文字クラス~$i$ に属する文字の幅,高さ,深さ,イタリック補正の量を指定する.
2039 文字クラス~$i$ に属する全ての文字は,その幅,高さ,深さがこのフィールドで指定した
2040 値であるものとして扱われる.
2041 しかし,例外が一つある:もし \texttt{'prop'} が \texttt{width} フィールドに
2042 指定された場合,文字の幅はその「実際の」グリフの幅となる.
2043 %</ja>
2044
2045 \item[left=<length>, down=<length>, align=<align>]\
2046
2047 %<*en>
2048 These fields are for adjusting the position of the `real' glyph. Legal
2049              values of \texttt{align} field are \texttt{'left'},
2050              \texttt{'middle'} and \texttt{'right'}. If one of these
2051              3~fields are omitted, \texttt{left} and \texttt{down} are
2052              treated as~0, and \texttt{align} field is treated as
2053              \texttt{'left'}.
2054 The effects of these 3~fields are indicated in Figure~\ref{fig-pos}.
2055 %</en>
2056 %<*ja>
2057 これらのフィールドは「実際の」グリフの位置を調整するためにある.
2058 \texttt{align} フィールドに指定できる値は \texttt{'left'}, \texttt{'middle'},
2059 \texttt{'right'} のいずれかである.もしこれら3つのフィールドのうちの1つが省かれた
2060 場合,\texttt{left} と \texttt{down} は 0,\texttt{align} フィールドは
2061 \texttt{'left'} であるものとして扱われる.
2062 これら3つのフィールドの意味については図\ref{fig-pos} で説明する.
2063 %</ja>
2064
2065 %<*en>
2066 In most cases, \texttt{left} and \texttt{down} fields are~0, while
2067 it is not uncommon that the \texttt{align} field is \texttt{'middle'} or \texttt{'right'}.
2068 For example, setting the \texttt{align} field to \texttt{'right'} is practically needed
2069 when the current character class is the class for opening delimiters'.
2070 %</en>
2071 %<*ja>
2072 多くの場合,\texttt{left} と \texttt{down} は 0 である一方,
2073 \texttt{align} フィールドが \texttt{'middle'} や \texttt{'right'} であることは
2074 珍しいことではない.
2075 例えば,\texttt{align} フィールドを \texttt{'right'} に指定することは,
2076 文字クラスが開き括弧類であるときに実際必要である.
2077 %</ja>
2078 \begin{figure}[!tb]
2079 \begin{minipage}{0.4\textwidth}%
2080 \begin{center}\unitlength=10pt\small
2081 \begin{picture}(15,12)(-1,-4)
2082 \color{black!10!white}% real glyph :step1
2083 \put(0,0){\vrule width 12\unitlength height 8\unitlength depth 3\unitlength}
2084
2085 \color{red!20!white}% real glyph :step1
2086 \put(-1,-1.5){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
2087
2088 \color{red}% real glyph
2089 \thicklines
2090 \put(-1,-1.5){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
2091 \put(5,-1.5){\line(0,1){7}\line(0,-1){2.5}}
2092 \put(-1,5.5){\line(1,0){6}}
2093 \put(-1,-4){\line(1,0){6}}
2094
2095 \color{green!20!white}% real glyph :step1
2096 \put(3,0){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
2097
2098 \color{black}% real glyph :step1
2099 \thicklines
2100 \put(0,0){\vector(0,1){8}\line(0,-1){3}\vector(1,0){12}}
2101 \put(12,0){\line(0,1){8}\vector(0,-1){3}}
2102 \put(0,8){\line(1,0){12}}
2103 \put(0,-3){\line(1,0){12}}
2104 \put(0.2,4){\makebox(0,0)[l]{\texttt{height}}}
2105 \put(12.2,-1.5){\makebox(0,0)[l]{\texttt{depth}}}
2106 \put(6,0.2){\makebox(0,0)[b]{\texttt{width}}}
2107
2108 \color{green!50!black}% real glyph :step1
2109 \thicklines
2110 \put(3,0){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
2111 \put(9,0){\line(0,1){7}\line(0,-1){2.5}}
2112 \put(3,7){\line(1,0){6}}
2113 \put(3,-2.5){\line(1,0){6}}
2114 \newsavebox{\eqdist}
2115 \savebox{\eqdist}(0,0)[b]{%
2116   \thinlines
2117   \put(-0.08,0.2){\line(0,-1){0.4}}%
2118   \put(0.08,0.2){\line(0,-1){0.4}}}
2119 \put(1.5,0){\usebox{\eqdist}}
2120 \put(10.5,0){\usebox{\eqdist}}
2121
2122 \color{blue}% shifted
2123 \thicklines
2124 \put(3,-1.5){\vector(-1,0){4}}
2125 \put(1,-1.7){\makebox(0,0)[t]{\texttt{left}}}
2126 \put(3,0){\vector(0,-1){1.5}}
2127 \put(3.2,-0.75){\makebox(0,0)[l]{\texttt{down}}}
2128 \end{picture}
2129 \end{center}
2130 \end{minipage}%
2131 \begin{minipage}{0.6\textwidth}%
2132 %<*en>
2133 Consider a node containing Japanese character whose value of the \texttt{align}
2134 field is \texttt{'middle'}.
2135 %</en>
2136 %<*ja>
2137 \texttt{align} フィールドの値が \texttt{'middle'} である和文文字を含むノードを
2138 考えよう.
2139 %</ja>
2140 \begin{itemize}
2141 \item
2142 %<*en>
2143 The black rectangle is a frame of the node.
2144 Its width, height and depth are specified by JFM.
2145 %</en>
2146 %<*ja>
2147 黒色の長方形はノードの枠である.
2148 その幅,高さ,深さは JFM によって指定される.
2149 %</ja>
2150 \item
2151 %<*en>
2152 Since the \texttt{align} field is \texttt{'middle'},
2153 the `real' glyph is centered horizontally (the green rectangle).
2154 %</en>
2155 %<*ja>
2156 \texttt{align} フィールドは \texttt{middle} なので,「実際の」グリフは
2157 水平方向の中心に配置される(緑色の長方形).
2158 %</ja>
2159 \item
2160 %<*en>
2161 Furthermore, the glyph is shifted according to values of fields
2162       \texttt{left} and \texttt{down}. The ultimate position of the real
2163       glyph is indicated by the red rectangle.
2164 %</en>
2165 %<*ja>
2166 さらに,グリフは \texttt{left} と \texttt{down} の値に従ってシフトされる.
2167 最終的な実際のグリフの位置は赤色の長方形で示された位置になる.
2168 %</ja>
2169 \end{itemize}
2170 \end{minipage}
2171 \caption{
2172 %<en>The position of the `real' glyph.
2173 %<ja>「実際の」グリフの位置.
2174 }
2175 \label{fig-pos}
2176 \end{figure}
2177
2178
2179 \item[kern={\{[$j$]=<kern>, ...\}}]
2180
2181 \item[glue={\{[$j$]=\{<width>, <stretch>, <shrink>\}, ...\}}]
2182 \end{list}
2183
2184 %<*en>
2185 As described before, you can specify several `imaginary characters' in
2186 \texttt{chars} field. The most of these characters are regarded as the
2187 characters of class 0 in \pTeX.
2188 As a result, \LuaTeX-ja can control typesetting finer than \pTeX.
2189 The following is the list of `imaginary characters':
2190 %</en>
2191 %<*ja>
2192 上で説明した通り,\texttt{chars}フィールド中にはいくつかの「特殊文字」も
2193 指定可能である.これらは,大半が\pTeX のJFMグルーの挿入処理ではみな「文字
2194 クラス0の文字」として扱われていた文字であり,その結果として\pTeX より細か
2195 い組版調整ができるようになっている.以下でその一覧を述べる:
2196 %</ja>
2197 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}\advance\leftmargin1\zw}
2198 \item['lineend']
2199 %<en>An ending of a line.
2200 %<ja>行の終端を表す.
2201
2202 \item['diffmet']
2203 %<en>Used at a boundary between two \textbf{JAchar}s whose JFM or size is different.
2204 %<ja>JFM やサイズが異なる2つの \textbf{JAchar} の間の境界として用いられる.
2205
2206 \item['boxbdd']
2207 %<en>The beginning/ending of a horizontal box, and the beginning of a noindented paragraph.
2208 %<ja>hboxの先頭と末尾,及びインデントされていない(\verb+\noindent+で開始された)段落の先頭を表す.
2209
2210 \item['parbdd']
2211 %<en>The beginning of an (indented) paragraph.
2212 %<ja>通常の(\verb+\noindent+で開始されていない)段落の先頭.
2213
2214 \item['jcharbdd']
2215 %<en>A boundary between \textbf{JAchar} and anything else (such as \textbf{ALchar}, kern, glue, ...).
2216 %<ja>和文文字と「その他のもの」(欧文文字,glue,kern等)との境界.
2217
2218 \item[$-1$]
2219 %<en>The left/right boundary of an inline math formula.
2220 %<ja>行中数式と地の文との境界.
2221 \end{list}
2222
2223 %<en>\paragraph{Porting JFM from \pTeX}
2224 %<ja>\paragraph{\pTeX 用和文フォントメトリックの移植}
2225
2226 % ToDo: English version.
2227
2228 %<*en>
2229 ...
2230 %</en>
2231
2232 %<*ja>
2233 以下に,\pTeX 用和文フォントメトリックを\LuaTeX-ja用に移植する場合の注意点を挙げておく.
2234 \begin{itemize}
2235 \item 実際に出力される和文フォントのサイズがdesign sizeとなる.
2236 このため,例えば$1\,\textrm{zw}$がdesign sizeの0.962216倍であるJISフォン
2237       トメトリック等を移植する場合は,
2238 \begin{itemize}
2239 \item JFM中の全ての数値を$1/0.962216$倍しておく.
2240 \item \TeX ソース中で使用するところで,サイズ指定を0.962216倍にする.
2241       \LaTeX でのフォント宣言なら,例えば次のように:
2242 \begin{verbatim}
2243 \DeclareFontShape{JY3}{mc}{m}{n}{<-> s*[0.962216] psft:Ryumin-Light:jfm=jis}{}
2244 \end{verbatim}
2245 \end{itemize}
2246 \item 上に述べた特殊文字は,\texttt{'boxbdd'}を除き文字クラスを全部0とする
2247       (JFM中に単に書かなければよい).
2248 \item \texttt{'boxbdd'}については,それのみで一つの文字クラスを形成し,その
2249       文字クラスに関してはglue/kernの設定はしない.
2250
2251 これは,\pTeX では,
2252       水平ボックスの先頭・末尾とインデントされていない(\verb+\noindent+で開始さ
2253       れた)段落の先頭にはJFMグルーは入らないという仕様を実現させるためである.
2254 \item \pTeX の組版を再現させようというのが目的であれば以上の注意を守れば十分である.
2255
2256 ところで,\pTeX では通常の段落の先頭にJFMグルーが残るという仕様があるので,
2257       段落先頭の開き括弧は全角二分下がりになる.全角下がりを実現させるに
2258       は,段落の最初に手動で\verb+\inhibitglue+を追加するか,あるいは
2259       \verb+\everypar+のhackを行い,それを自動化させるしかなかった.
2260
2261 一方,\LuaTeX-jaでは,\texttt{'parbdd'}によって,それがJFM側で調整できるよ
2262 うになった.例えば,\LuaTeX-ja同梱のJFMのように,\texttt{'boxbdd'}と同じ文字クラスに
2263 \texttt{'parbdd'}を入れれば全角下がりとなる.
2264
2265 \ltjsetparameter{jacharrange={+3}}
2266 \begin{LTXexample}
2267 \jfont\g=psft:Ryumin-Light:jfm=test \g
2268 \parindent1\zw\noindent{}◆◆◆◆◆
2269 \par 「◆◆←二分下がり
2270 \par 【◆◆←全角下がり
2271 \par 〔◆◆←全角二分下がり
2272 \end{LTXexample}
2273 \end{itemize}
2274 \ltjsetparameter{jacharrange={-3}}
2275 %</ja>
2276
2277 %<en>\subsection{Math Font Family}
2278 %<ja>\subsection{数式フォントファミリ}
2279 \label{ssec-math}
2280
2281 %<*en>
2282 \TeX\ handles fonts in math formulas by 16~font families\footnote{Omega,
2283 Aleph, \LuaTeX~and $\varepsilon$-\kern-.125em(u)\pTeX\ can handles 256~families, but
2284 an external package is needed to support this in plain \TeX\ and
2285 \LaTeX.}, and each family has three fonts:
2286 \verb+\textfont+, \verb+\scriptfont+ and \verb+\scriptscriptfont+.
2287 %</en>
2288 %<*ja>
2289 \TeX\ は数式フォントを16のファミリ\footnote{Omega, Aleph, \LuaTeX,そして
2290   $\varepsilon$-\kern-.125em(u)\pTeX\ では256 の数式ファミリを扱うことができるが,
2291   これをサポートするために plain \TeX と \LaTeX では外部パッケージを読み込む必要が
2292   ある.}で管理し,それぞれのファミリは3つのフォントを持っている:\verb+\textfont+, \verb+\scriptfont+ そして \verb+\scriptscriptfont+ である.
2293 %</ja>
2294
2295 %<*en>
2296 \LuaTeX-ja's handling of Japanese fonts in math formulas is similar;
2297 Table~\ref{tab-math} shows counterparts to \TeX's primitives for math
2298 font families. There is no relation between the value of
2299 \verb+\fam+ and that of \verb+\jfam+; with appropriate settings,
2300 you can set both \verb+\fam+ and \verb+\jfam+ to the same value.
2301 %</en>
2302 %<*ja>
2303 \LuaTeX-ja の数式中での和文フォントの扱いも同様である.
2304 表 \ref{tab-math} は数式フォントファミリに対する \TeX\ のプリミティブと対応する
2305 ものを示している.\verb+\fam+ と \verb+\jfam+ の値の間には関係はなく,
2306 適切な設定の下では \verb+\fam+ と \verb+\jfam+ の両方に同じ値を設定することができる.
2307 %</ja>
2308
2309 \begin{table}[!tb]
2310 %<en>\caption{Primitives for Japanese math fonts.}
2311 %<ja>\caption{和文数式フォントに対するプリミティブ.}
2312 \label{tab-math}
2313 \begin{center}\def\{{\char`\{}\def\}{\char`\}}
2314 \begin{tabular}{lll}
2315 \toprule
2316 %<en>&Japanese fonts&alphabetic fonts\\
2317 %<ja>&和文フォント&欧文フォント\\
2318 \midrule
2319 font family&\verb+\jfam+${}\in [0,256)$&\verb+\fam+\\
2320 text size&\tt\Param{jatextfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\verb+\textfont+<fam>=<font\_cs>\\
2321 script size&\tt\Param{jascriptfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\verb+\scriptfont+<fam>=<font\_cs>\\
2322 scriptscript size&\tt\Param{jascriptscriptfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\verb+\scriptscriptfont+<fam>=<font\_cs>\\
2323 \bottomrule
2324 \end{tabular}
2325 \end{center}
2326 \end{table}
2327
2328 %<en>\subsection{Callbacks}
2329 %<ja>\subsection{コールバック}
2330
2331 %<*en>
2332 Like \LuaTeX\ itself, \LuaTeX-ja also has callbacks. These callbacks can
2333 be accessed via \verb+luatexbase.add_to_callback+ function and so on, as other callbacks.
2334 %</en>
2335 %<*ja>
2336 \LuaTeX 自体のものに加えて,\LuaTeX-ja もコールバックを持っている.
2337 これらのコールバックには,他のコールバックと同様に \verb+luatexbase.add_to_callback+
2338 関数などを用いることでアクセスすることができる.
2339 %</ja>
2340 \begin{list}{}%
2341 {\def\makelabel#1{\bfseries#1}}
2342 %<en>\item[\texttt{luatexja.load\_jfm} callback]
2343 %<ja>\item[\texttt{luatexja.load\_jfm} コールバック]
2344 %<*en>
2345 With this callback you can overwrite JFMs.
2346 This callback is called when a new JFM is loaded.
2347 %</en>
2348 %<*ja>
2349 このコールバックを用いることで JFM を上書きすることができる.
2350 このコールバックは新しい JFM が読み込まれるときに呼び出される.
2351 %</ja>
2352
2353 \begin{lstlisting}[numbers=left]
2354 function (<table> jfm_info, <string> jfm_name)
2355   return <table> new_jfm_info
2356 end
2357 \end{lstlisting}
2358
2359 %<*en>
2360 The argument \verb+jfm_info+ contains a table similar to the table in a JFM file, except
2361 this argument has \texttt{chars} field which contains character codes
2362              whose character class is not~0.
2363 %</en>
2364 %<*ja>
2365 引数 \verb+jfm_info+ は JFM ファイルのテーブルと似たものが格納されるが,
2366 クラス0を除いた文字のコードを含んだ \texttt{chars} フィールドを持つ点が異なる.
2367 %</ja>
2368
2369 %<*en>
2370 An example of this callback is the \texttt{ltjarticle} class, with
2371              forcefully assigning character class~0 to \texttt{'parbdd'}
2372              in the JFM \texttt{jfm-min.lua}. This callback doesn't
2373              replace any code of \LuaTeX-ja.
2374 %</en>
2375 %<*ja>
2376 このコールバックの使用例は \texttt{ltjarticle} クラスにあり,
2377 \texttt{jfm-min.lua} 中の \texttt{'parbdd'} を強制的にクラス0に割り当てている.
2378 このコールバックは \LuaTeX-ja のコードを書き換えない.
2379 %</ja>
2380
2381 %<en>\item[\texttt{luatexja.define\_font} callback]
2382 %<ja>\item[\texttt{luatexja.define\_font} コールバック]
2383 %<*en>
2384 This callback and the next callback form a pair, and you can assign letters which don't have
2385              fixed code points in Unicode to non-zero character classes.
2386 This \texttt{luatexja.define\_font} callback is called just when new Japanese font is loaded.
2387 %</en>
2388 %<*ja>
2389 このコールバックと次のコールバックは組をなしており,Unicode 中に固定された文字コード
2390 番号を持たない文字を非零の文字クラスに割り当てることができる.
2391 このコールバックは新しい和文フォントが読み込まれたときに呼び出される.
2392 %</ja>
2393
2394 \begin{lstlisting}[numbers=left]
2395 function (<table> jfont_info, <number> font_number)
2396   return <table> new_jfont_info
2397 end
2398 \end{lstlisting}
2399
2400 %<*en>
2401 You may assume that \verb+jfont_info+ has the following fields:
2402 %</en>
2403 %<*ja>
2404 \verb+jfont_info+ は以下のフィールドを持つ:
2405 %</ja>
2406 \begin{description}
2407 \item[\tt jfm]
2408 %<en>The index number of JFM.
2409 %<ja>JFM のインデックス番号.
2410
2411 \item[\tt size]
2412 %<en>Font size in a scaled point (${}=2^{-16}\,\textrm{pt}$).
2413 %<ja>スケールド・ポイント (${}=2^{-16}\,\textrm{pt}$) を単位としたフォントのサイズ.
2414
2415 \item[\tt var]
2416 %<en>The value specified in \texttt{jfmvar=...} at a call of \verb+\jfont+.
2417 %<ja>\verb+\jfont+ の呼び出しの際に \texttt{jfmvar=...} で指定された値.
2418 \end{description}
2419
2420 %<*en>
2421 The returned table \verb+new_jfont_info+ also should include these three fields.
2422 The \verb+font_number+ is a font number.
2423 %</en>
2424 %<*ja>
2425 戻り値の \verb+new_jfont_info+ テーブルもこれら3つのフィールドを含まなければならない.
2426 \verb+font_number+ はフォント番号である.
2427 %</ja>
2428
2429 %<*en>
2430 A good example of this and the next callbacks is the \Pkg{luatexja-otf}
2431              package, supporting \verb+"AJ1-xxx"+ form for Adobe-Japan1
2432              CID characters in a JFM. This callback doesn't replace any
2433              code of \LuaTeX-ja.
2434 %</en>
2435 %<*ja>
2436 これと次のコールバックの良い使用例は \Pkg{luatexja-otf} パッケージであり,
2437 JFM 中で Adobe-Japan1 CID の文字を \verb+"AJ1-xxx"+ の形で指定するために
2438 用いられている.
2439 このコールバックは \LuaTeX-ja のコードを書き換えない.
2440 %</ja>
2441
2442 %<en>\item[\texttt{luatexja.find\_char\_class} callback]
2443 %<ja>\item[\texttt{luatexja.find\_char\_class} コールバック]
2444 %<*en>
2445 This callback is called just when \LuaTeX-ja is trying to determine which
2446              character class a character \verb+chr_code+ belongs.
2447 A function used in this callback should be in the following form:
2448 %</en>
2449 %<*ja>
2450 このコールバックは \LuaTeX-ja が \verb+chr_code+ の文字がどの文字クラスに
2451 属するかを決定しようとする際に呼び出される.
2452 このコールバックで呼び出される関数は次の形をしていなければならない:
2453 %</ja>
2454 \begin{lstlisting}[numbers=left]
2455 function (<number> char_class, <table> jfont_info, <number> chr_code)
2456   if char_class~=0 then return char_class
2457   else
2458     ....
2459     return (<number> new_char_class or 0)
2460   end
2461 end
2462 \end{lstlisting}
2463
2464 %<*en>
2465 The argument \verb+char_class+ is the result of \LuaTeX-ja's default
2466              routine or previous function calls in this callback, hence
2467              this argument may not be 0. Moreover, the returned
2468              \verb+new_char_class+ should be as same as \verb+char_class+ when \verb+char_class+
2469              is not~0, otherwise you will overwrite the \LuaTeX-ja's
2470              default routine.
2471 %</en>
2472 %<*ja>
2473 引数 \verb+char_class+ は \LuaTeX-ja のデフォルトルーチンか,このコールバックの
2474 直前の関数呼び出しの結果を含んでおり,したがってこの値は0ではないかもしれない.
2475 さらに,戻り値の \verb+new_char_class+ は \verb+char_class+ が非零のときには
2476 \verb+char_class+ の値と同じであるべきで,そうでないときは \LuaTeX-ja の
2477 デフォルトルーチンを書き換えることになる.
2478 %</ja>
2479
2480 %<*en>
2481 This callback doesn't replace any code of \LuaTeX-ja.
2482 %</en>
2483 %<*ja>
2484 このコールバックは \LuaTeX-ja のコードを書き換えない.
2485 %</ja>
2486
2487 %<en>\item[\texttt{luatexja.set\_width} callback]
2488 %<ja>\item[\texttt{luatexja.set\_width} コールバック]
2489 %<*en>
2490 This callback is called when \LuaTeX-ja is trying to encapsule a
2491              \textbf{JAchar} \textit{glyph\_node}, to adjust its
2492              dimension and position.
2493 %</en>
2494 %<*ja>
2495 このコールバックは \LuaTeX-ja が \textbf{JAchar} の寸法と位置を調節するために
2496 その \textit{glyph\_node} をカプセル化しようとする際に呼び出される.
2497 %</ja>
2498 \begin{lstlisting}[numbers=left]
2499 function (<table> shift_info, <table> jfont_info, <number> char_class)
2500   return <table> new_shift_info
2501 end
2502 \end{lstlisting}
2503
2504 %<*en>
2505 The argument \verb+shift_info+ and the returned \verb+new_shift_info+ have
2506 \texttt{down} and \texttt{left} fields, which are the amount of shifting
2507              down/left the character in a scaled-point.
2508 %</en>
2509 %<*ja>
2510 引数 \verb+shift_info+ と戻り値の \verb+new_shift_info+ は
2511 \texttt{down} と \texttt{left} のフィールドを持ち,これらの値は
2512 文字の下/左へのシフト量(スケールド・ポイント単位)である.
2513 %</ja>
2514
2515 %<*en>
2516 A good example is \Pkg{test/valign.lua}.
2517 After loading this file, the vertical position of glyphs is automatically
2518 adjusted; the ratio $(\hbox{height}:\hbox{depth})$ of glyphs is adjusted
2519 to be that of letters in the character class~0. For example, suppose that
2520 \begin{itemize}
2521 \item The setting of the JFM: $(\hbox{height})=88x$, $(\hbox{depth})=12x$
2522   (the standard values of Japanese OpenType fonts);
2523 \item The value of the real font: $(\hbox{height})=28y$, $(\hbox{depth})=5y$
2524   (the standard values of Japanese TrueType fonts).
2525 \end{itemize}
2526 Then, the position of glyphs is shifted up by
2527 \[
2528  \frac{88x}{88x+12x} (28y+5y) - 28y = \frac{26}{825}y= 0.03\dot1\dot5y.
2529 \]
2530 %</en>
2531 %<*ja>
2532 良い例が\Pkg{test/valign.lua}である.このファイルが読み込まれた状態では,
2533              JFM内で規定された文字クラス0の文字における$(\hbox{高
2534              さ}):(\hbox{深さ})$の比になるように,実際のフォントの出力上
2535              下位置が自動調整される.例えば,
2536 \begin{itemize}
2537 \item JFM側の設定:$(\hbox{高さ})=88x$, $(\hbox{深さ})=12x$%
2538 (和文OpenTypeフォントの標準値)
2539 \item 実フォント側の数値:$(\hbox{高さ})=28y$, $(\hbox{深さ})=5y$(和文TrueTypeフォントの標準値)
2540 \end{itemize}
2541 となっていたとする.すると,実際の文字の出力位置は,
2542 \[
2543  \frac{88x}{88x+12x} (28y+5y) - 28y = \frac{26}{825}y= 0.03\dot1\dot5y
2544 \]
2545 だけ上にずらされることになる.
2546 %</ja>
2547 \end{list}
2548
2549
2550
2551 %<en>\section{Parameters}
2552 %<ja>\section{パラメータ}
2553 %<en>\subsection{\texttt{\char92 ltjsetparameter} primitive}
2554 %<ja>\subsection{\texttt{\char92 ltjsetparameter} プリミティブ}
2555
2556 %<*en>
2557 As noted before, \verb+\ltjsetparameter+ and \verb+\ltjgetparameter+ are
2558 primitives for accessing most parameters of \LuaTeX-ja. One of the main
2559 reason that \LuaTeX-ja didn't adopted the syntax similar to that of \pTeX\
2560 (\textit{e.g.},~\verb+\prebreakpenalty`)=10000+)
2561 is the position of \verb+hpack_filter+ callback in the source
2562 of \LuaTeX, see Section~\ref{sec-para}.
2563 %</en>
2564 %<*ja>
2565 先に述べたように,\verb+\ltjsetparameter+ と \verb+\ltjgetparameter+ は
2566 \LuaTeX-ja のほとんどのパラメータにアクセスするためのプリミティブである.
2567 \LuaTeX-ja が \pTeX のような文法(例えば,\verb+\prebreakpenalty`)=10000+)を
2568 採用しない理由の一つは,\LuaTeX のソースにおける \verb+\hpack_filter+
2569 コールバックの位置にある.\ref{sec-para} 節を参照.
2570 %</ja>
2571
2572 %<*en>
2573 \verb+\ltjsetparameter+ and \verb+\ltjglobalsetparameter+ are primitives
2574 for assigning parameters. These take one argument which is a
2575 \texttt{<key>=<value>} list. Allowed keys are described in the next
2576 subsection.
2577 The difference between
2578 \verb+\ltjsetparameter+ and \verb+\ltjglobalsetparameter+ is only the
2579 scope of assignment;
2580 \verb+\ltjsetparameter+ does a local assignment and
2581 \verb+\ltjglobalsetparameter+ does a global one.
2582 They also obey the value of \verb+\globaldefs+,
2583 like other assignment.
2584 %</en>
2585 %<*ja>
2586 \verb+\ltjsetparameter+ と \verb+\ltjglobalsetparameter+ はパラメータを
2587 指定するためのプリミティブである.これらは \texttt{<key>=<value>} のリストを
2588 引数としてとる.許されるキーは次の節に記述する.
2589 \verb+\ltjsetparameter+ と \verb+\ltjglobalsetparameter+ の違いはスコープの
2590 違いのみである.
2591 \verb+\ltjsetparameter+ はローカルな指定,\verb+\ltjglobalsetparameter+ は
2592 グローバルな指定を行う.
2593 これらは他のパラメータ指定と同様に \verb+\globaldefs+ の値に従う.
2594 %</ja>
2595
2596 %<*en>
2597 \verb+\ltjgetparameter+ is the primitive for acquiring parameters. It
2598 always takes a parameter name as first argument, and also takes the
2599 additional argument---a character code, for example---in some cases.
2600 %</en>
2601 %<*ja>
2602 \verb+\ltjgetparameter+ はパラメータの値を取得するためのプリミティブであり,
2603 常にパラメータの名前を第一引数にとる.
2604 そして,いくつかの場合には加えてさらに引数(例えば文字コード)をとる.
2605 %</ja>
2606 \begin{LTXexample}
2607 \ltjgetparameter{differentjfm},
2608 \ltjgetparameter{autospacing},
2609 \ltjgetparameter{prebreakpenalty}{`)}.
2610 \end{LTXexample}
2611 %<*en>
2612 \emph{The return value of\/ {\normalfont\tt\char92ltjgetparameter} is
2613 always a string}. This is outputted by \texttt{tex.write()}, so any
2614 character other than space~`\texttt{\char32}'~(U+0020) has the category code
2615 12~(other), while the space has 10~(space).
2616 %</en>
2617 %<*ja>
2618 \textbf{{\normalfont\tt\char92ltjgetparameter} の戻り値は常に文字列である.}
2619 これは \texttt{tex.write()} によって出力しているためで,スペース `\texttt{\char32}'~(U+0020) を除いた文字のカテゴリーコードは全て 12~(other) となる.
2620 一方,スペースのカテゴリーコードは 10~(space) である.
2621 %</ja>
2622
2623 %<en>\subsection{List of Parameters}
2624 %<ja>\subsection{パラメータ一覧}
2625
2626 %<*en>
2627 The following is the list of parameters which can be specified by the
2628 \verb+\ltjsetparameter+ command. [\verb+\cs+] indicates the counterpart
2629 in \pTeX, and symbols beside each parameter has the following meaning:
2630 %</en>
2631 %<*ja>
2632 以下は \verb+\ltjsetparameter+ に指定することができるパラメータの一覧である.
2633 [\verb+\cs+] は \pTeX における対応物を示す.
2634 また,それぞれのパラメータの右上にある記号には次の意味がある:
2635 %</ja>
2636 \begin{itemize}
2637 %<*en>
2638 \item No mark: values at the end of the paragraph or the hbox are
2639       adopted in the whole paragraph/hbox.
2640 %</en>
2641 %<*ja>
2642 \item 記号なし:段落や水平ボックスの終端での値がその段落/水平ボックス全体で用いられる.
2643 %</ja>
2644 %<*en>
2645 \item `\ast' : local parameters, which can change everywhere inside a paragraph/hbox.
2646 %</en>
2647 %<*ja>
2648 \item `\ast':ローカルなパラメータであり,段落/水平ボックス内のどこででも値を変えることができる.
2649 %</ja>
2650 %<*en>
2651 \item `\dagger': assignments are always global.
2652 %</en>
2653 %<*ja>
2654 \item `\dagger':指定は常にグローバルになる.
2655 %</ja>
2656 \end{itemize}
2657
2658 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}\advance\leftmargin1\zw}
2659 \item[\Param{jcharwidowpenalty}\,=<penalty>] [\verb+\jcharwidowpenalty+]
2660 %<*en>
2661 Penalty value for suppressing orphans. This penalty is inserted just
2662              after the last \textbf{JAchar} which is not regarded as a
2663              (Japanese) punctuation mark.
2664 %</en>
2665 %<*ja>
2666 パラグラフの最後の字が孤立して改行されるのを防ぐためのペナルティの値.
2667 このペナルティは(日本語の)句読点として扱われない最後の \textbf{JAchar} の直後に
2668 挿入される.
2669 %</ja>
2670
2671 \item[\Param{kcatcode}\,=\{<chr\_code>,<natural number>\}]\
2672 %<*en>
2673 An additional attributes which each character whose character code is <chr\_code> has.
2674 At the present version, the lowermost bit of <natural number> indicates
2675              whether the character is considered as a punctuation mark
2676              (see the description of \Param{jcharwidowpenalty} above).
2677 %</en>
2678 %<*ja>
2679 文字コードが <chr\_code> の文字が持つ付加的な属性値 (attribute).
2680 現在のバージョンでは,<natural number> の最下位ビットが,その文字が句読点と
2681 みなされるかどうかを表している(上の \Param{jcharwidowpenalty} の記述を参照).
2682 %</ja>
2683
2684 \item[\Param{prebreakpenalty}\,=\{<chr\_code>,<penalty>\}] [\verb+\prebreakpenalty+]\
2685 %<*ja>
2686 文字コード<chr\_code>の\textbf{JAchar}が行頭にくることを抑止するために,
2687              この文字の前に挿入/追加されるペナルティの量を指定する.
2688
2689 例えば閉じ括弧「〗」は絶対に行頭にきてはならないので,標準で読み込まれる
2690              \texttt{luatexja-kinsoku.tex}において
2691 \begin{verbatim}
2692 \ltjsetparameter{prebreakpenalty={`〙,10000}}
2693 \end{verbatim}
2694 と,最大値の10000が指定されている.他にも,小書きのカナなど,絶対禁止とい
2695              うわけではないができれば行頭にはきて欲しくない場合に,0と
2696              10000の間の値を指定するのも有用であろう.
2697 \begin{verbatim}
2698 \ltjsetparameter{prebreakpenalty={`ゕ,150}}
2699 \end{verbatim}
2700 %</ja>
2701
2702 \item[\Param{postbreakpenalty}\,=\{<chr\_code>,<penalty>\}] [\verb+\postbreakpenalty+]
2703 %<*ja>
2704 文字コード<chr\_code>の\textbf{JAchar}が行末にくることを抑止するために,
2705              この文字の後に挿入/追加されるペナルティの量を指定する.
2706
2707 \pTeX では,\verb+\prebreakpenalty+, \verb+\postbreakpenalty+において,
2708 \begin{itemize}
2709 \item 一つの文字に対して,pre, postどちらか一つしか指定することができなかっ
2710       た(後から指定した方で上書きされる).
2711 \item pre, post合わせて256文字分の情報を格納することしかできなかった.
2712 \end{itemize}
2713 という制限があったが,\LuaTeX-ja ではこれらの制限は解消されている.
2714 %</ja>
2715
2716 \item[\Param{jatextfont}\,=\{<jfam>,<jfont\_cs>\}]
2717 %<en>[\verb+\textfont+ in \TeX]
2718 %<ja>[\TeX の \verb+\textfont+]
2719 \item[\Param{jascriptfont}\,=\{<jfam>,<jfont\_cs>\}]
2720 %<en>[\verb+\scriptfont+ in \TeX]
2721 %<ja>[\TeX の \verb+\scriptfont+]
2722 \item[\Param{jascriptscriptfont}\,=\{<jfam>,<jfont\_cs>\}]
2723 %<en>[\verb+\scriptscriptfont+ in \TeX]
2724 %<ja>[\TeX の \verb+\scriptscriptfont+]
2725 \item[\Param{yjabaselineshift}\,=<dimen>$^\ast$]\
2726 \item[\Param{yalbaselineshift}\,=<dimen>$^\ast$] [\verb+\ybaselineshift+]
2727
2728 \item[\Param{jaxspmode}\,=\{<chr\_code>,<mode>\}]
2729
2730 %<*en>
2731 Setting whether inserting \Param{xkanjiskip} is allowed before/after a \textbf{JAchar} whose character code is <chr\_code>.
2732 The followings are allowed for <mode>:
2733 %</en>
2734 %<*ja>
2735 文字コードが <chr\_code> の \textbf{JAchar} の前/後ろに \Param{xkanjiskip} の
2736 挿入を許すかどうかの設定.
2737 以下の <mode> が許される:
2738 %</ja>
2739 \begin{description}
2740 %<en>\item[0, \texttt{inhibit}] Insertion of \Param{xkanjiskip} is inhibited before the character, nor after the character.
2741 %<ja>\item[0, \texttt{inhibit}] \Param{xkanjiskip} の挿入は文字の前/後ろのいずれでも禁止される.
2742 %<en>\item[1, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed before the character, but not after.
2743 %<ja>\item[1, \texttt{preonly}] \Param{xkanjiskip} の挿入は文字の前では許されるが,後ろでは許されない.
2744 %<en>\item[2, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed after the character, but not before.
2745 %<ja>\item[2, \texttt{postonly}] \Param{xkanjiskip} の挿入は文字の後ろでは許されるが,前では許されない.
2746 %<en>\item[3, \texttt{allow}] Insertion of \Param{xkanjiskip} is allowed both before the character and after the character. This is the default value.
2747 %<ja>\item[3, \texttt{allow}] \Param{xkanjiskip} の挿入は文字の前/後ろのいずれでも許される.これがデフォルトの値である.
2748 \end{description}
2749 %<*en>
2750 This parameter is similar to the \verb+\inhibitxspcode+ primitive of \pTeX, but not compatible with \verb+\inhibitxspcode+.
2751 %</en>
2752 %<*ja>
2753 このパラメータは \pTeX の \verb+\inhibitxspcode+ プリミティブと似ているが,
2754 互換性はない.
2755 %</ja>
2756
2757 \item[\Param{alxspmode}\,=\{<chr\_code>,<mode>\}] [\verb+\xspcode+]
2758
2759 %<*en>
2760 Setting whether inserting \Param{xkanjiskip} is allowed before/after a
2761              \textbf{ALchar} whose character code is <chr\_code>.
2762              The followings are allowed for <mode>:
2763 %</en>
2764 %<*ja>
2765 文字コードが <chr\_code> の \textbf{ALchar} の前/後ろに \Param{xkanjiskip} の
2766 挿入を許すかどうかの設定.
2767 以下の <mode> が許される:
2768 %</ja>
2769 \begin{description}
2770 %<en>\item[0, \texttt{inhibit}] Insertion of \Param{xkanjiskip} is inhibited before the character, nor after the character.
2771 %<ja>\item[0, \texttt{inhibit}] \Param{xkanjiskip} の挿入は文字の前/後ろのいずれでも禁止される.
2772 %<en>\item[1, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed before the character, but not after.
2773 %<ja>\item[1, \texttt{preonly}] \Param{xkanjiskip} の挿入は文字の前では許されるが,後ろでは許されない.
2774 %<en>\item[2, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed after the character, but not before.
2775 %<ja>\item[2, \texttt{postonly}] \Param{xkanjiskip} の挿入は文字の後ろでは許されるが,前では許されない.
2776 %<en>\item[3, \texttt{allow}] Insertion of \Param{xkanjiskip} is allowed before the character and after the character. This is the default value.
2777 %<ja>\item[3, \texttt{allow}] \Param{xkanjiskip} の挿入は文字の前/後ろのいずれでも許される.これがデフォルトの値である.
2778 \end{description}
2779 %<*en>
2780 Note that parameters \Param{jaxspmode} and \Param{alxspmode} use a common table, hence these two parameters are synonyms of each other.
2781 %</en>
2782 %<*ja>
2783 \Param{jaxspmode} と \Param{alxspmode} は共通のテーブルを用いているため,
2784 これら2つのパラメータは互いの異名となっていることに注意する.
2785 %</ja>
2786
2787 \item[\Param{autospacing}\,=<bool>$^\ast$] [\verb+\autospacing+]
2788 \item[\Param{autoxspacing}\,=<bool>$^\ast$] [\verb+\autoxspacing+]
2789 \item[\Param{kanjiskip}\,=<skip>] [\verb+\kanjiskip+]
2790 \item[\Param{xkanjiskip}\,=<skip>] [\verb+\xkanjiskip+]
2791
2792 \item[\Param{differentjfm}\,=<mode>$^\dagger$]
2793
2794 %<*en>
2795 Specify how glues/kerns between two \textbf{JAchar}s whose JFM (or size) are different.
2796 The allowed arguments are the followings:
2797 %</en>
2798 %<*ja>
2799 JFM(もしくはサイズ)が異なる2つの \textbf{JAchar} の間にグルー/カーンをどのように
2800 入れるかを指定うる.
2801 許される値は以下の通り:
2802 %</ja>
2803 \begin{description}
2804 \item[\texttt{average}]
2805 \item[\texttt{both}]
2806 \item[\texttt{large}]
2807 \item[\texttt{small}]
2808 \end{description}
2809
2810 \item[\Param{jacharrange}\,=<ranges>$^\ast$]
2811 \item[\Param{kansujichar}\,=\{<digit>, <chr\_code>\}] [\verb+\kansujichar+]
2812 \end{list}
2813
2814
2815 %<en>\section{Other Primitives}
2816 %<ja>\section{その他のプリミティブ}
2817 %<en>\subsection{Primitives for Compatibility}
2818 %<ja>\subsection{互換プリミティブ}
2819
2820 %<*en>
2821 The following primitives are implemented for compatibility with \pTeX:
2822 %</en>
2823 %<*ja>
2824 以下のプリミティブは \pTeX との互換性のために実装されている:
2825 %</ja>
2826 \begin{list}{}{\def\makelabel{\ttfamily\char92 }\advance\leftmargin1\zw}
2827 \item[kuten]
2828 \item[jis]
2829 \item[euc]
2830 \item[sjis]
2831 \item[ucs]
2832 \item[kansuji]
2833 \end{list}
2834
2835 %<en>\subsection{\texttt{\char92 inhibitglue} primitive}
2836 %<ja>\subsection{\texttt{\char92 inhibitglue} プリミティブ}
2837
2838 %<*en>
2839 The primitive \verb+\inhibitglue+ suppresses the insertion of \textbf{JAglue}.
2840 The following is an example, using a special JFM that there will be a glue between
2841 the beginning of a box and `あ', and also between `あ' and `ウ'.
2842 %</en>
2843 %<*ja>
2844 \verb+\inhibitglue+ プリミティブは \textbf{JAglue} の挿入を抑制する.
2845 以下は,ボックスの始めと`あ'の間,`あ'と`ウ'の間にグルーが入る特別な JFM を用いた例で
2846 ある.
2847 %</ja>
2848
2849 \begin{LTXexample}
2850 \jfont\g=psft:Ryumin-Light:jfm=test \g
2851 \fbox{\hbox{あウあ\inhibitglue ウ}}
2852 \inhibitglue\par\noindent あ1
2853 \par\inhibitglue\noindent あ2
2854 \par\noindent\inhibitglue あ3
2855 \par\inhibitglue\hrule あoff\inhibitglue ice
2856 \end{LTXexample}
2857
2858 %<*en>
2859 With the help of this example, we remark the specification of \verb+\inhibitglue+:
2860 %</en>
2861 %<*ja>
2862 この例を援用して,\verb+\inhibitglue+ の仕様について述べる.
2863 %</ja>
2864 \begin{itemize}
2865 %<*en>
2866 \item The call of \verb+\inhibitglue+ in the (internal) vertical mode is
2867       effective at the beginning of the next paragraph. This is realized
2868       by hacking \verb+\everypar+.
2869 %</en>
2870 %<*ja>
2871 \item \verb+\inhibitglue+ の垂直モード中での呼び出しは次の段落の始めで効力を持つ.
2872   これは \verb+\everypar+ のハックによって実現されている.
2873 %</ja>
2874
2875 %<*en>
2876 \item The call of \verb+\inhibitglue+ in the (restricted) horizontal
2877       mode is only effective on the spot; does not get over boundary of
2878       paragraphs. Moreover, \verb+\inhibitglue+ cancels ligatures and
2879       kernings, as shown in line~4 of above example.
2880 %</en>
2881 %<*ja>
2882 \item \verb+\inhibitglue+ の(制限された)水平モード中での呼び出しはその場でのみ
2883   有効であり,段落の境界を乗り越えない.
2884   さらに,\verb+\inhibitglue+ は上の例の4行目のようにリガチャとカーニングを
2885   打ち消す.
2886 %</ja>
2887
2888 %<*en>
2889 \item The call of \verb+\inhibitglue+ in math mode is just ignored.
2890 %</en>
2891 %<*ja>
2892 \item \verb+\inhibitglue+ を数式モード中で呼び出した場合はただ無視される.
2893 %</ja>
2894 \end{itemize}
2895
2896 %<en>\section{Control Sequences for \LaTeXe}
2897 %<ja>\section{\LaTeXe 用のコントロールシーケンス}
2898
2899 %<en>\subsection{Patch for NFSS2}
2900 %<ja>\subsection{NFSS2 へのパッチ}
2901 \label{ssub-nfsspat}
2902
2903 %<*en>
2904 As described in Subsection~\ref{ssec-ltx}, \LuaTeX-ja simply adopted
2905 \texttt{plfonts.dtx} in \pLaTeXe\ for the Japanese patch for NFSS2.
2906 For an convenience, we will describe
2907 commands which are not described in Subsection~\ref{ssub-chgfnt}.
2908 %</en>
2909 %<*ja>
2910 \ref{ssec-ltx} 節で述べたように,\LuaTeX-ja は NFSS2 への日本語パッチである
2911 \pLaTeXe の \texttt{plfonts.dtx} を単純に取り入れている.
2912 便宜のため,ここでは \ref{ssub-chgfnt} 節で述べていなかったコマンドについて
2913 記述しておく.
2914 %</ja>
2915
2916 \begin{cslist}%
2917 \item[DeclareYokoKanjiEncoding\{<encoding>\}\{<text-settings>\}\{<math-settings>\}]
2918
2919 %<*en>
2920 In NFSS2 under \LuaTeX-ja, distinction between alphabetic font families
2921              and Japanese font families are only made by their
2922              encodings. For example, encodings OT1 and T1 are for
2923              alphabetic font families, and a Japanese font family cannot
2924              have these encodings. This command defines a new encoding
2925              scheme for Japanese font family (in horizontal direction).
2926 %</en>
2927 %<*ja>
2928 \LuaTeX-ja の NFSS2 においては,欧文フォントファミリと和文フォントファミリは
2929 そのエンコーディングからのみ作られる.
2930 例えば,OT1 と T1 のエンコーディングは欧文フォントファミリに対するものであり,
2931 和文フォントファミリはこれらのエンコーディングを持つことはできない.
2932 このコマンドは和文フォントファミリ(横書き用)のための新しいエンコーディングを
2933 定義する.
2934 %</ja>
2935
2936 \item[DeclareKanjiEncodingDefaults\{<text-settings>\}\{<math-settings>\}]
2937 \item[DeclareKanjiSubstitution\{<encoding>\}\{<family>\}\{<series>\}\{<shape>\}]
2938 \item[DeclareErrorKanjiFont\{<encoding>\}\{<family>\}\{<series>\}\{<shape>\}\{<size>\}]
2939
2940 %<*en>
2941 The above 3~commands are just the counterparts for \verb+DeclareFontEncodingDefaults+ and~others.
2942 %</en>
2943 %<*ja>
2944 上記3つのコマンドはちょうど \verb+DeclareFontEncodingDefaults+ などに対応するものである.
2945 %</ja>
2946
2947 \item[reDeclareMathAlphabet\{<unified-cmd>\}\{<al-cmd>\}\{<ja-cmd>\}]
2948
2949 % ToDo: en
2950 %<*ja>
2951 和文・欧文の数式用フォントファミリを一度に変更する命令を作成する.
2952 具体的には,欧文数式用フォントファミリ変更の命令<al-cmd> (\verb+\mathrm+等)と,和文数式用フォ
2953              ントファミリ変更の命令<ja-cmd>(\verb+\mathmc+等)の2つを同時に行う命令として
2954              <unified-cmd>を(再)定義する.実際の使用では<unified-cmd>と
2955              <al-cmd>に同じものを指定する,すなわち,<al-cmd>で和文側も変
2956              更させるようにするのが一般的と思われる.
2957
2958 {\let\item=\origitem
2959 本命令は
2960 \begin{center}\tt
2961 <unified-cmd>\{<arg>\}\quad$\longrightarrow$\quad
2962 (<al-cmd>を1段展開したもの)\{<ja-cmd>を1段展開したもの)\{<arg>\}\}
2963 \end{center}
2964 と定義を行うので,使用には注意が必要である:
2965 \begin{itemize}
2966 \item <al-cmd>,~<ja-cmd>は既に定義されていなければならない.\verb+\reDeclareMathAlphabet+後に
2967 両命令の内容を再定義しても,<unified-cmd>の内容にそれは反映されない.
2968 \item <al-cmd>,~<ja-cmd>に\verb+\@mathrm+などと \texttt{@} をつけた命令を指定した時の動作は保証できない.
2969 \end{itemize}}
2970 %</ja>
2971
2972 \item[DeclareRelationFont\{<ja-encoding>\}\{<ja-family>\}\{<ja-series>\}\{<ja-shape>\}\\
2973   \hfill\{<al-encoding>\}\{<al-family>\}\{<al-series>\}\{<al-shape>\}]
2974 %<*en>
2975 This command sets the `accompanied' alphabetic font family (given by the latter 4~arguments)
2976 with respect to a Japanese font family given by the former 4~arguments.
2977 %</en>
2978 %<*ja>
2979 いわゆる「従属欧文」を設定するための命令である.前半の4引数で表される和文フォントファミリに対して,
2980 そのフォントに対応する「従属欧文」フォントファミリを後半の4引数により与える.
2981 %</ja>
2982 \item[SetRelationFont]
2983 %<*en>
2984 This command is almost same as \verb+\DeclareRelationFont+, except that this command does a local
2985 assignment, where \verb+\DeclareRelationFont+ does a global assignment.
2986 %</en>
2987 %<*ja>
2988 このコマンドは \verb+\DeclareRelationFont+ とローカルな指定であることを除いて
2989 ほとんど同じである(\verb+\DeclareRelationFont+ はグローバル).
2990 %</ja>
2991
2992 \item[userelfont]
2993 %<*en>
2994 Change current alphabetic font encoding/family/\dots\ to the `accompanied' alphabetic
2995              font family with respect to current Japanese font family,
2996              which was set by
2997              \verb+\DeclareRelationFont+ or \verb+\SetRelationFont+.
2998 Like \verb+\fontfamily+, \verb+\selectfont+ is required to take an effect.
2999 %</en>
3000 %<*ja>
3001 現在の欧文フォントエンコーディング/ファミリ/…… を,
3002 \verb+\DeclareRelationFont+ か \verb+\SetRelationFont+ で指定された
3003 現在の和文フォントファミリに対応する「従属欧文」フォントファミリに変更する.
3004 \verb+\fontfamily+ のように,有効にするためには \verb+\selectfont+ が必要である.
3005 %</ja>
3006
3007 \item[adjustbaseline]
3008 ...
3009
3010 \item[fontfamily\{<family>\}]
3011 {\let\item\origitem
3012 %<*en>
3013 As in \LaTeXe, this command changes current font family (alphabetic, Japanese,~\emph{or both})
3014 to <family>. Which family will be changed is determined as follows:
3015 %</en>
3016 %<*ja>
3017 元々の \LaTeXe におけるものと同様に,このコマンドは現在のフォントファミリ(欧文,
3018 和文,\textbf{もしくは両方})を <family> に変更する.
3019 どのファミリが変更されるかは以下のようにして決定される:
3020 %</ja>
3021 \begin{itemize}
3022 %<*en>
3023 \item Let current encoding scheme for Japanese fonts be
3024       <ja-enc>. Current Japanese font family will be changed to
3025       <family>, if one of the following two conditions is met:
3026 %</en>
3027 %<*ja>
3028 \item 現在の和文フォントに対するエンコーディングが <ja-enc> であるとしよう.
3029   現在の和文フォントファミリは,以下の2つの条件のうちの1つが満たされているときに
3030   <family> に変更される:
3031 %</ja>
3032 \begin{itemize}
3033 %<*en>
3034 \item The family <fam> under the encoding <ja-enc> has been already defined by
3035       \verb+\DeclareKanijFamily+.
3036 %</en>
3037 %<*ja>
3038 \item エンコーディング <ja-enc> におけるファミリ <fam> が既に \verb+\DeclareKanjiFamily+ によって定義されている.
3039 %</ja>
3040 %<*en>
3041 \item A font definition named \texttt{<enc><ja-enc>.fd} (the file name is
3042       all lowercase) exists.
3043 %</en>
3044 %<*ja>
3045 \item フォント定義ファイル \texttt{<enc><ja-enc>.fd}(ファイル名は全て小文字)が存在する.
3046 %</ja>
3047 \end{itemize}
3048 %<*en>
3049 \item Let current encoding scheme for alphabetic fonts be
3050       <al-enc>. For alphabetic font family, the criterion as above is used.
3051 %</en>
3052 %<*ja>
3053 \item 現在の欧文フォントに対するエンコーディングを <al-enc> とする.
3054   欧文フォントファミリに対しても,上記の基準が用いられる.
3055 %</ja>
3056 %<*en>
3057 \item There is a case which none of the above applies, that is, the font
3058       family named <family> doesn't seem to be defined neither under the
3059       encoding <ja-enc>, nor under <al-enc>.
3060 In this case, the default family for font substitution is used for
3061       alphabetic and Japanese fonts. Note that current encoding will not
3062       be set to <family>, unlike the original implementation in \LaTeX.
3063 %</en>
3064 %<*ja>
3065 \item 上記のいずれもが適用されない,つまり <family> が <ja-enc> と <al-enc> の
3066   どちらでも定義されないような場合がある.
3067   この場合,代替フォントに用いられるデフォルトのフォントファミリが欧文フォントと
3068   和文フォントに用いられる.\LaTeX のオリジナルの実装とは異なり,
3069   現在のエンコーディングは <family> には設定されないことに注意する.
3070 %</ja>
3071 \end{itemize}
3072 }
3073 \end{cslist}
3074
3075 %<*en>
3076 As closing this subsection, we shall introduce an example of
3077 \verb+\SetRelationFont+ and \verb+\userelfont+:
3078 %</en>
3079 %<*ja>
3080 この節の終わりに,\verb+\SetRelationFont+ と \verb+\userelfont+ の例を
3081 紹介しておこう.
3082 %</ja>
3083 \begin{LTXexample}
3084 \gtfamily{}あいうabc
3085 \SetRelationFont{JY3}{gt}{m}{n}{OT1}{pag}{m}{n}
3086 \userelfont\selectfont{}あいうabc
3087 \end{LTXexample}
3088
3089
3090 %<en>\subsection{Cropmark/`tombow'}
3091 %<ja>\subsection{トンボ}
3092 % ToDo
3093
3094 %<en>\section{Extensions}
3095 %<ja>\section{拡張}
3096 \subsection{\texttt{luatexja-fontspec.sty}}
3097
3098 %<*en>
3099 As described in Subsection~\ref{ssec-fontspec}, this optional package
3100 provides the counterparts for several commands defined in the
3101 \Pkg{fontspec} package.
3102 In addition to `font features' in the original \Pkg{fontspec},
3103 the following `font features' specifications are allowed for
3104 the commands of Japanese version:
3105 %</en>
3106 %<*ja>
3107 \ref{ssec-fontspec} 節で述べたように,この追加パッケージは \Pkg{fontspec}
3108 パッケージで定義されているコマンドに対応する和文フォント用のコマンドを提供する.
3109 オリジナルの \Pkg{fontspec} での `font feature' に加えて,和文版のコマンドには
3110 以下の `font feature' を指定することができる:
3111 %</ja>
3112
3113
3114 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}\advance\leftmargin1\zw}
3115 \item[JFM=<name>]
3116 \item[JFM-var=<name>]
3117
3118 %<*en>
3119 These 2 font features correspond to \texttt{jfm} and \texttt{jfmvar} keys for
3120 \verb+\jfont+ primitive, respectively. See Subsection~\ref{ssec-jfont}.
3121 %</en>
3122 %<*ja>
3123 これらの2つはそれぞれ \verb+\jfont+ プリミティブに対する
3124 \texttt{jfm}, \texttt{jfmvar} キーとそれぞれ対応する.
3125 \ref{ssec-jfont} 節を参照.
3126 %</ja>
3127
3128 \item[NoEmbed]
3129 %<*en>
3130 By specifying this font feature, you can use `name-only' Japanese font which
3131 will not be embedded in the output PDF file. See Subsection~\ref{ssec-psft}.
3132 %</en>
3133 %<*ja>
3134 これを指定することで,PDF に埋め込まれない「名前だけ」のフォントを指定することが
3135 できる.\ref{ssec-psft} 節を参照.
3136 %</ja>
3137 \end{list}
3138
3139 \subsection{\texttt{luatexja-otf.sty}}
3140
3141 %<*en>
3142 This optional package supports typesetting characters in
3143 Adobe-Japan1. \texttt{luatexja-otf.sty} offers the following 2~low-level
3144 commands:
3145 %</en>
3146 %<*ja>
3147 この追加パッケージは Adobe-Japan1 の文字の出力をサポートする.
3148 \texttt{luatexja-otf.sty} は以下の2つの低レベルコマンドを提供する:
3149 %</ja>
3150 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}\advance\leftmargin1\zw}
3151 \item[\char92CID\{<number>\}]
3152 %<*en>
3153 Typeset a character whose CID number is <number>.
3154 %</en>
3155 %<*ja>
3156 CID 番号が <number> の文字を出力する.
3157 %</ja>
3158
3159 \item[\char92UTF\{<hex\_number>\}]
3160 %<*en>
3161 Typeset a character whose character code is <hex\_number> (in hexadecimal).
3162 This command is similar to \verb+\char"+<hex\_number>,\ %"
3163 but please remind remarks below.
3164 %</en>
3165 %<*ja>
3166 文字コードが(16進で)<hex\_number> の文字を出力する.
3167 このコマンドは \verb+\char"+<hex\_number> と似ているが,下の記述に注意すること.%"
3168 %</ja>
3169 \end{list}
3170
3171 %<en>\paragraph{Remarks}
3172 %<ja>\paragraph{注意}
3173 %<*en>
3174 Characters by \verb+\CID+ and \verb+\UTF+ commands are different from
3175 ordinary characters in the following points:
3176 %</en>
3177 %<*ja>
3178 \verb+\CID+ と \verb+\UTF+ コマンドによって出力される文字は
3179 以下の点で通常の文字と異なる:
3180 %</ja>
3181 \begin{itemize}
3182 %<*en>
3183 \item Always treated as \textbf{JAchar}s.
3184 %</en>
3185 %<*ja>
3186 \item 常に \textbf{JAchar} として扱われる.
3187 %</ja>
3188 %<*en>
3189 \item Processing codes for supporting OpenType features (\textit{e.g.},
3190       glyph replacement and kerning) by the \Pkg{luaotfload} package
3191       is not performed to these characters.
3192 %</en>
3193 %<*ja>
3194 \item OpenType feature(例えばグリフ置換やカーニング)をサポートするための
3195   \Pkg{luaotfload} パッケージのコードはこれらの文字には働かない.
3196 %</ja>
3197 \end{itemize}
3198
3199
3200 %<en>\paragraph{Additional Syntax of JFM}
3201 %<ja>\paragraph{JFM への記法の追加}
3202
3203 %<*en>
3204 \texttt{luatexja-otf.sty} extends the syntax of JFM; the entries of \texttt{
3205 chars} table in JFM now allows a string in the form
3206 \verb+'AJ1-xxx'+, which stands for the character
3207 whose CID number in Adobe-Japan1 is \verb+xxx+.
3208 %</en>
3209 %<*ja>
3210 \texttt{luatexja-otf.sty} は JFM の記法を拡張する.
3211 JFM の \texttt{chars} テーブルのエントリとして \verb+'AJ1-xxx'+ の形の文字列が
3212 使えるようになる.これは Adobe-Japan1 における CID 番号が \verb+xxx+ の文字を表す.
3213 %</ja>
3214
3215 %<en>\part{Implementations}
3216 %<ja>\part{実装}
3217 \label{part-imp}
3218 %<en>\section{Storing Parameters}
3219 %<ja>\section{パラメータの保持}
3220 \label{sec-para}
3221 %<en>\subsection{Used Dimensions, Attributes and whatsit nodes}
3222 %<ja>\subsection{\LuaTeX-ja で用いられる寸法レジスタ,属性レジスタ,whatsit ノード}
3223
3224 %<*en>
3225 Here the following is the list of dimensions and attributes which are used in \LuaTeX-ja.
3226 %</en>
3227 %<*ja>
3228 以下は \LuaTeX-ja で用いられる寸法レジスタ (dimension),属性レジスタ (attribute) の
3229 リストである.
3230 %</ja>
3231 \begin{list}{}{%
3232 \def\makelabel{\ttfamily}\advance\leftmargin1\zw
3233 \def\dim#1{\item[\char92 #1\ \textrm{(dimension)}]}
3234 \def\attr#1{\item[\char92 #1\ \textrm{(attribute)}]}
3235 }
3236
3237 \dim{jQ}
3238 %<*en>
3239 As explained in Subsection~\ref{ssec-plain}, \verb+\jQ+ is equal to
3240                         $1\,\textrm{Q}=0.25\,\textrm{mm}$, where `Q'~(also called `級') is
3241                         a unit used in Japanese phototypesetting. So one should not change the value of this dimension.
3242 %</en>
3243 %<*ja>
3244 \ref{ssec-plain} 節で述べたように,\verb+\jQ+ は $1\,\textrm{Q}=0.25\,\textrm{mm}$
3245 と等しい.ここで,`Q'(もしくは「級」)は日本の写植で用いられる単位である.したがって,
3246 この寸法レジスタの値を変更してはならない.
3247 %</ja>
3248
3249 \dim{jH}
3250 %<*en>
3251 There is also a unit called `歯' which equals to $0.25\,\textrm{mm}$ and
3252                         used in Japanese phototypesetting. This
3253                         \verb+\jH+ is a synonym of \verb+\jQ+.
3254 %</en>
3255 %<*ja>
3256 同じく写植で用いられていた単位として「歯」があり,これは $0.25\,\textrm{mm}$ と
3257 等しい.\verb+\jH+ は \verb+\jQ+ の別名である.
3258 %</ja>
3259
3260 \dim{ltj@zw}
3261 %<*en>
3262 A temporal register for the `full-width' of current Japanese font.
3263 %</en>
3264 %<*ja>
3265 現在の和文フォントの「全角幅」を保持する一時レジスタ.
3266 %</ja>
3267
3268 \dim{ltj@zh}
3269 %<*en>
3270 A temporal register for the `full-height' (usually the sum of height of imaginary body and its depth) of current Japanese font.
3271 %</en>
3272 %<*ja>
3273 現在の和文フォントの「全角高さ」(通常,高さと深さの和)を保持する一時レジスタ.
3274 %</ja>
3275
3276 \attr{jfam}
3277 %<*en>
3278 Current number of Japanese font family for math formulas.
3279 %</en>
3280 %<*ja>
3281 数式用の和文フォントファミリの現在の番号.
3282 %</ja>
3283
3284 \attr{ltj@curjfnt}
3285 %<*en>
3286 The font index of current Japanese font.
3287 %</en>
3288 %<*ja>
3289 現在の和文フォントのフォント番号.
3290 %</ja>
3291
3292 \attr{ltj@charclass}
3293 %<*en>
3294 The character class of Japanese \textit{glyph\_node}.
3295 %</en>
3296 %<*ja>
3297 和文文字の \textit{glyph\_node} の文字クラス.
3298 %</ja>
3299
3300 \attr{ltj@yablshift}
3301 %<*en>
3302 The amount of shifting the baseline of alphabetic fonts in scaled point ($2^{-16}\,\textrm{pt}$).
3303 %</en>
3304 %<*ja>
3305 スケールド・ポイント ($2^{-16}\,\textrm{pt}$) を単位とした欧文フォントのベースラインの移動量.
3306 %</ja>
3307
3308 \attr{ltj@ykblshift}
3309 %<*en>
3310 The amount of shifting the baseline of Japanese fonts in scaled point ($2^{-16}\,\textrm{pt}$).
3311 %</en>
3312 %<*ja>
3313 スケールド・ポイント ($2^{-16}\,\textrm{pt}$) を単位とした和文フォントのベースラインの移動量.
3314 %</ja>
3315
3316 \attr{ltj@autospc}
3317 %<*en>
3318 Whether the auto insertion of \Param{kanjiskip} is allowed at the node.
3319 %</en>
3320 %<*ja>
3321 そのノードで \Param{kanjiskip} の自動挿入が許されるかどうか.
3322 %</ja>
3323
3324 \attr{ltj@autoxspc}
3325 %<*en>
3326 Whether the auto insertion of \Param{xkanjiskip} is allowed at the node.
3327 %</en>
3328 %<*ja>
3329 そのノードで \Param{xkanjiskip} の自動挿入が許されるかどうか.
3330 %</ja>
3331
3332 \attr{ltj@icflag}
3333 %<*en>
3334 An attribute for distinguishing `kinds' of a node. One of the following value is
3335 assigned to this attribute:
3336 %</en>
3337 %<*ja>
3338 ノードの「種類」を区別するための属性.以下のうちのひとつが値として割り当てられる:
3339 %</ja>
3340 \begin{description}
3341 \item[\textit{italic} (1)]
3342 %<*en>
3343 Glues from an italic correction
3344            (\verb+\/+). This distinction of origins of glues
3345            (from explicit \verb+\kern+, or from \verb+\/+)
3346            is needed in the insertion process of \Param{xkanjiskip}.
3347 %</en>
3348 %<*ja>
3349 イタリック補正 (\verb+\/+) によるグルー.このグルーの由来の区別(\verb+\kern+ か
3350 \verb+\/+ か)は \Param{xkanjiskip} の挿入過程において必要になる.
3351 %</ja>
3352
3353 \item[\textit{packed} (2)]
3354
3355 \item[\textit{kinsoku} (3)]
3356 %<*en>
3357 Penalties inserted for the word-wrapping process of Japanese characters (\emph{kinsoku}).
3358 %</en>
3359 %<*ja>
3360 和文文字のワードラップ過程において挿入されたペナルティ (\emph{kinsoku}).
3361 %</ja>
3362
3363 \item[\textit{from\_jfm} (4)]
3364 %<*en>
3365 Glues/kerns from JFM.
3366 %</en>
3367 %<*ja>
3368 JFM 由来のグルー/カーン.
3369 %</ja>
3370
3371 \item[\textit{line\_end} (5)]
3372 %<*en>
3373 Kerns for ...
3374 %</en>
3375 %<*ja>
3376 カーン ...
3377 %</ja>
3378
3379 \item[\textit{kanji\_skip} (6)]
3380 %<*en>
3381 Glues for \Param{kanjiskip}.
3382 %</en>
3383 %<*ja>
3384 \Param{kanjiskip} のグルー.
3385 %</ja>
3386
3387 \item[\textit{xkanji\_skip} (7)]
3388 %<*en>
3389 Glues for \Param{xkanjiskip}.
3390 %</en>
3391 %<*ja>
3392 \Param{xkanjiskip} のグルー.
3393 %</ja>
3394
3395 \item[\textit{processed} (8)]
3396 %<*en>
3397 Nodes which is already processed by ...
3398 %</en>
3399 %<*ja>
3400 ... によって既に処理されたノード.
3401 %</ja>
3402
3403 \item[\textit{ic\_processed} (9)]
3404 %<*en>
3405 Glues from an italic correction, but also already processed.
3406 %</en>
3407 %<*ja>
3408 イタリック補正に由来するグルーであるが,まだ処理されていないもの.
3409 %</ja>
3410
3411 \item[\textit{boxbdd} (15)]
3412 %<*en>
3413 Glues/kerns that inserted just the beginning or the ending of an hbox or a paragraph.
3414 %</en>
3415 %<*ja>
3416 ある水平ボックスか段落の最初か最後に挿入されたグルー/カーン.
3417 %</ja>
3418 \end{description}
3419
3420 \attr{ltj@kcat$i$}
3421 %<*en>
3422 Where $i$~is a natural number which is less than~7.
3423 These 7~attributes store bit~vectors indicating which character block is regarded as a block of \textbf{JAchar}s.
3424 %</en>
3425 %<*ja>
3426 $i$ は7より小さい自然数.
3427 これら7つの属性レジスタは,どの文字ブロックが \textbf{JAchar} のブロックとして
3428 扱われるかを示すビットベクトルを格納する.
3429 %</ja>
3430 \end{list}
3431
3432 %<*en>
3433 Furthermore, \LuaTeX-ja uses several `user-defined' whatsit nodes for
3434 typesetting. All those nodes store a natural number (hence the node's
3435 \texttt{type} is 100).
3436 %</en>
3437 %<*ja>
3438 さらに,\LuaTeX-ja はいくつかの「ユーザ定義の」whatsit ノードを組版に用いる.
3439 これらの全てのノードは自然数を格納している(したがってノードの \texttt{type} は
3440 100 である).
3441 %</ja>
3442 \begin{description}
3443 \item[30111]
3444 %<*en>
3445 Nodes for indicating that \verb+\inhibitglue+ is
3446            specified. The \texttt{value} field of these nodes doesn't matter.
3447 %</en>
3448 %<*ja>
3449 \verb+\inhibitglue+ が指定されたことを示すノード.これらのノードの
3450 \texttt{value} フィールド は意味を持たない.
3451 %</ja>
3452
3453 \item[30112]
3454 %<*en>
3455 Nodes for \LuaTeX-ja's stack system (see the next
3456            subsection). The \texttt{value} field of these nodes is
3457            current group.
3458 %</en>
3459 %<*ja>
3460 \LuaTeX-ja のスタックシステム(次の節を参照)のためのノード.
3461 これらのノードの \texttt{value} フィールドは現在のグループを表す.
3462 %</ja>
3463
3464 \item[30113]
3465 %<*en>
3466 Nodes for Japanese Characters which the callback process of
3467            luaotfload won't be applied, and the character code is
3468            stored in the \texttt{value} field. Each node having this
3469            \verb+user_id+ is converted to a `glyph\_node' \emph{after}
3470            the callback process of luaotfload.
3471 %</en>
3472 %<*ja>
3473 luaotfload のコールバックによる処理が適用されない和文文字のためのノードで,
3474 \texttt{value} フィールドにその文字のコードが格納されている.
3475 この \verb+user_id+ を持つノードはそれぞれが luaotfload のコールバックの処理の
3476 \textbf{後で} `glyph\_node' に変換される.
3477 %</ja>
3478 \end{description}
3479 %<*en>
3480 These whatsits will be removed during the process of inserting \textbf{JAglue}s.
3481 %</en>
3482 %<*ja>
3483 これらの whatsit ノードは \textbf{JAglue} の挿入処理の間に取り除かれる.
3484 %</ja>
3485
3486 %<en>\subsection{Stack System of \LuaTeX-ja}
3487 %<ja>\subsection{\LuaTeX-ja のスタックシステム}
3488 \label{ssec-stack}
3489
3490 %<en>\paragraph{Background}
3491 %<ja>\paragraph{背景}
3492 %<*en>
3493 \LuaTeX-ja has its own stack system, and most parameters of \LuaTeX-ja
3494 are stored in it. To clarify the reason, imagine the parameter
3495 \Param{kanjiskip} is stored by a skip, and consider the following
3496 source:
3497 %</en>
3498 %<*ja>
3499 \LuaTeX-ja は独自のスタックシステムを持ち,\LuaTeX-ja のほとんどのパラメータは
3500 これを用いて保持されている.その理由を明らかにするために,
3501 \Param{kanjiskip} パラメータがスキップレジスタで保持されているとし,
3502 以下のコードを考えてみよう:
3503 %</ja>
3504 \begin{LTXexample}
3505 \ltjsetparameter{kanjiskip=0pt}ふがふが.%
3506 \setbox0=\hbox{\ltjsetparameter{kanjiskip=5pt}ほげほげ}
3507 \box0.ぴよぴよ\par
3508 \end{LTXexample}
3509
3510 %<*en>
3511 As described in Part~\ref{part-ref}, the only effective value of
3512 \Param{kanjiskip} in an hbox is the latest value, so the value of
3513 \Param{kanjiskip} which applied in the entire hbox should be 5\,pt.
3514 However, by the implementation method of \LuaTeX, this `5\,pt' cannot be
3515 known from any callbacks.  In the \texttt{tex/packaging.w} (which is a
3516 file in the source of \LuaTeX), there are the following codes:
3517 %</en>
3518 %<*ja>
3519 第 \ref{part-ref} 部で述べたように,ある水平ボックスの中で効力を持つ
3520 \Param{kanjiskip} の値は最後に現れた値のみであり,したがってボックス全体に適用される
3521 \Param{kanjiskip} は 5\,pt であるべきである.しかし,\LuaTeX の実装のために,
3522 この `5\,pt' はどのコールバックからも知ることはできない.
3523 \texttt{tex/packaging.w}(これは \LuaTeX のソースファイルである)の中に,
3524 以下のコードがある:
3525 %</ja>
3526 \begin{lstlisting}
3527 void package(int c)
3528 {
3529     scaled h;                   /* height of box */
3530     halfword p;                 /* first node in a box */
3531     scaled d;                   /* max depth */
3532     int grp;
3533     grp = cur_group;
3534     d = box_max_depth;
3535     unsave();
3536     save_ptr -= 4;
3537     if (cur_list.mode_field == -hmode) {
3538         cur_box = filtered_hpack(cur_list.head_field,
3539                                  cur_list.tail_field, saved_value(1),
3540                                  saved_level(1), grp, saved_level(2));
3541         subtype(cur_box) = HLIST_SUBTYPE_HBOX;
3542 \end{lstlisting}
3543 %<*en>
3544 Notice that \verb+unsave+ is executed \emph{before}
3545 \verb+filtered_hpack+ (this is where \verb+hpack_filter+ callback is
3546 executed): so `5\,pt' in the above source is orphaned at
3547 \verb+unsave+, and hence it can't be accessed from \verb+hpack_filter+
3548 callback.
3549 %</en>
3550 %<*ja>
3551 \verb+unsave+ が \verb+filtered_hpack+(これは \verb+hpack_filter+ コールバックが
3552 実行されるところである)の\textbf{前に}実行されていることに注意する.
3553 したがって,上記ソース中で `5\,pt' は \verb+unsave+ のところで捨てられ,
3554 \verb+hpack_filter+ からはアクセスすることができない.
3555 %</ja>
3556
3557 %<en>\paragraph{The method}
3558 %<ja>\paragraph{解決法}
3559
3560 %<*en>
3561 The code of stack system is based on that in a post of Dev-luatex mailing list\footnote{%
3562 \texttt{[Dev-luatex] tex.currentgrouplevel}, a post at 2008/8/19 by Jonathan Sauer.}.
3563 %</en>
3564 %<*ja>
3565 スタックシステムのコードは Dev-luatex メーリングリスト\footnote{\texttt{[Dev-luatex] tex.currentgrouplevel} の Jonathan Sauer による 2008/8/19 の投稿.}のある投稿を
3566 ベースにしている.
3567 %</ja>
3568
3569 %<*en>
3570 These are two \TeX\ count registers for maintaining information:
3571 \verb+\ltj@@stack+ for the stack level, and \verb+\ltj@@group@level+ for
3572 the \TeX's group level when the last assignment was done.  Parameters
3573 are stored in one big table named \texttt{charprop\_stack\_table}, where
3574 \texttt{charprop\_stack\_table[$i$]} stores data of stack level~$i$. If
3575 a new stack level is created by \verb+\ltjsetparameter+, all data of the
3576 previous level is copied.
3577 %</en>
3578 %<*ja>
3579 情報を保持するために,2つの \TeX の整数レジスタを用いている:
3580 \verb+\ltj@@stack+ でスタックレベル,\verb+\ltj@@group@level+ で最後の代入が
3581 なされた時点での \TeX のグループレベルを保持している.
3582 パラメータは \texttt{charprop\_stack\_table} という名前のひとつの大きなテーブルに
3583 格納される.ここで,\texttt{charprop\_stack\_table[$i$]} はスタックレベル $i$ の
3584 データを格納している.もし新しいスタックレベルが \verb+\ltjsetparameter+ によって
3585 生成されたら,前のレベルの全てのデータがコピーされる.
3586 %</ja>
3587
3588 %<*en>
3589 To resolve the problem mentioned in `Background' above, \LuaTeX-ja uses
3590 another thing: When a new stack level is about to be created, a whatsit
3591 node whose type, subtype and value are 44~(\textit{user\_defined}),
3592 30112, and current group level respectively is appended to the current
3593 list (we refer this node by \textit{stack\_flag}). This enables us to
3594 know whether assignment is done just inside a hbox. Suppose that the
3595 stack level is~$s$ and the \TeX's group level is~$t$ just after the hbox
3596 group, then:
3597 %</en>
3598 %<*ja>
3599 上の「背景」で述べた問題を解決するために,\LuaTeX-ja ではもう一つの手法を導入する:
3600 新しいスタックレベルが生成されようとするとき,type, subtype, value がそれぞれ
3601 44~(\textit{user\_defined}), 30112,そして現在のグループレベルである whatsit ノード
3602 を現在のリストに付け加える(このノードを \textit{stack\_flag} とする).
3603 これにより,ある水平ボックスの中で代入がなされたかどうかを知ることが可能
3604 となる.スタックレベルを $s$,その水平ボックスグループの直後の \TeX のグループレベルを
3605 $t$ とすると:
3606 %</ja>
3607 \begin{itemize}
3608 %<*en>
3609 \item If there is no \textit{stack\_flag} node in the list of the hbox, then
3610       no assignment was occurred inside the hbox. Hence values of
3611       parameters at the end of the hbox are stored in the stack
3612       level~$s$.
3613 %</en>
3614 %<*ja>
3615 \item もしその水平ボックスのリストの中に \textit{stack\_flag} ノードがなければ,
3616   水平ボックスの中では代入は起こらなかったということになる.
3617   したがって,その水平ボックスの終わりにおけるパラメータの値はスタックレベル $s$ に
3618   格納されている.
3619 %</ja>
3620
3621 %<*en>
3622 \item If there is a \textit{stack\_flag} node whose value is~$t+1$, then
3623       an assignment was occurred just inside the hbox group. Hence
3624       values of parameters at the end of the hbox are stored in the
3625       stack level~$s+1$.
3626 %</en>
3627 %<*ja>
3628 \item もし値が $t+1$ の \textit{stack\_flag} ノードがあれば,その
3629   水平ボックスグループの中で代入が起こったことになる.
3630   したがって,水平ボックスの終わりにおけるパラメータの値はスタックレベル $s+1$ に
3631   格納されている.
3632 %</ja>
3633
3634 %<*en>
3635 \item If there are \textit{stack\_flag} nodes but all of their values
3636       are more than~$t+1$, then an assignment was occurred in the box,
3637       but it is done is `more internal' group. Hence values of
3638       parameters at the end of the hbox are stored in the stack
3639       level~$s$.
3640 %</en>
3641 %<*ja>
3642 \item もし \textit{stack\_flag} ノードがあるがそれらの値が全て $t+1$ より大きい
3643   場合,そのボックスの中で代入が起こったが,それは「より内部の」グループで
3644   起こったということになる.したがって,水平ボックスの終わりでのパラメータの
3645   値はスタックレベル $s$ に格納されている.
3646 %</ja>
3647 \end{itemize}
3648
3649 %<*en>
3650 Note that to work this trick correctly, assignments to
3651 \verb+\ltj@@stack+ and \verb+\ltj@@group@level+ have to be local always,
3652 regardless the value of \verb+\globaldefs+.
3653 This problem is resolved by using
3654 \hbox{\verb+\directlua{tex.globaldefs=0}+} (this assignment is local).
3655 %</en>
3656 %<*ja>
3657 このトリックを正しく働かせるためには,\verb+\ltj@@stack+ と \verb+\ltj@@group@level+ への
3658 代入は \verb+\globaldefs+ の値によらず常にローカルでなければならないことに注意する.
3659 この問題は \hbox{\verb+\directlua{tex.globaldefs=0}+}(この代入は常にローカル)を
3660 用いることで解決している.
3661 %</ja>
3662
3663 %<en>\section{Linebreak after Japanese Character}
3664 %<ja>\section{和文文字直後の改行}
3665 \label{sec-lbreak}
3666 %<en>\subsection{Reference: Behavior in \pTeX}
3667 %<ja>\subsection{参考: \pTeX の動作}
3668 %<*en>
3669 In~\pTeX, a line break after a Japanese character doesn't emit a space,
3670 since words are not separated by spaces in Japanese writings. However,
3671 this feature isn't fully implemented in \LuaTeX-ja due to the
3672 specification of callbacks in~\LuaTeX. To clarify the difference between
3673 \pTeX~and~\LuaTeX, We briefly describe the handling of a line break in~\pTeX, in
3674 this subsection.
3675
3676 \pTeX's input processor can be described in terms of a finite state
3677 automaton, as that of~\TeX\ in~Section~2.5 of~\cite{texbytopic}. The
3678 internal states are as follows:
3679 \begin{itemize}
3680 \item State~$N$: new line
3681 \item State~$S$: skipping spaces
3682 \item State~$M$: middle of line
3683 \item State~$K$: after a Japanese character
3684 \end{itemize}
3685 The first three states---$N$, $S$~and~$M$---are as same as \TeX's input
3686 processor.  State~$K$ is similar to state~$M$, and is entered after
3687 Japanese characters.  The diagram of state transitions are indicated in
3688 Figure~\ref{fig-ptexipro}.  Note that \pTeX\ doesn't leave state~$K$
3689 after `beginning/ending of a group' characters.
3690 %</en>
3691
3692 %<*ja>
3693 欧文では文章の改行は単語間でしか行わない.そのため,\TeX では,(文字の直後の)改行は
3694 空白文字と同じ扱いとして扱われる.一方,和文ではほとんどどこでも改行が可能なため,
3695 \pTeX では和文文字の直後の改行は単純に無視されるようになっている.
3696
3697 このような動作は,\pTeX が\TeX からエンジンとして拡張されたことによって可能になったことである.
3698 \pTeX の入力処理部は,\TeX におけるそれと同じように,有限オートマトンとして記述することができ,
3699 以下に述べるような4状態を持っている.
3700
3701 \begin{itemize}
3702 \item State~$N$: 行の開始.
3703 \item State~$S$: 空白読み飛ばし.
3704 \item State~$M$: 行中.
3705 \item State~$K$: 行中(和文文字の後).
3706 \end{itemize}
3707 また,状態遷移は,図\ref{fig-ptexipro} のようになっており,図中の数字は
3708 カテゴリーコードを表している.最初の3状態は\TeX の入力処理部と同じであり,
3709 図中から状態$K$と「$j$」と書かれた矢印を取り除けば,\TeX の入力処理部と同
3710 じものになる.
3711
3712 この図から分かることは,
3713 \begin{quote}
3714 行が和文文字(とグループ境界文字)で終わっていれば,改行は無視される
3715 \end{quote}
3716 ということである.
3717 %</ja>
3718
3719 \begin{figure}[!tb]
3720 \begin{gather*}
3721  \def\sp{\texttt{\char32}}
3722  \xymatrix{&&
3723    {\text{scan a cs}}\ar@(r,ul)[dr]&\\
3724 \ar[r]&
3725    *++[o][F-]{N}\ar[ur]^0\ar[dd]_{d,\ g}\ar[u]^{5\ (\texttt{\char92par})}
3726      \ar@{->}@(d,l)[ddrr]_(0.45){j}&&
3727    *++[o][F-]{S}\ar@(l,dr)[ul]^0\ar@(l,ur)[ddll]_{d,\ g}\ar[u]_{5}
3728      \ar@{->}@(r,r)[dd]^{j}\\&\\&
3729    *++[o][F-]{M}\ar[uuur]^0\ar@(r,dl)[uurr]_(0.55){10\ (\sp)}
3730      \ar[d]_{5\ ({\sp})}\ar@{->}@(dr,dl)[rr]_{j}&&
3731    *++[o][F-]{K}\ar@{->}@(ul,d)[uuul]^0\ar@{->}[ll]^{d}
3732      \ar@{->}@(ur,dr)[uu]^{10\ (\sp)}\ar@{->}[d]_5\\
3733    &&&
3734  }\\
3735  d:=\{3,4,6,7,8,11,12,13\},\quad g:=\{1,2\},\quad j:=(\text{Japanese characters})
3736 \end{gather*}
3737 \begin{itemize}
3738 \item Numbers represent category codes.
3739 \item Category codes 9~(ignored), 14~(comment)~and~15~(invalid) are omitted in above diagram.
3740 \end{itemize}
3741 \caption{State transitions of \pTeX's input processor.}
3742 \label{fig-ptexipro}
3743 \end{figure}
3744
3745
3746 %<en>\subsection{Behavior in \LuaTeX-ja}
3747 %<ja>\subsection{\LuaTeX-ja の動作}
3748 %<*en>
3749 States in the input processor of \LuaTeX\ is the same as that of \TeX,
3750 and they can't be customized by any callbacks. Hence, we can only use
3751 \verb+process_input_buffer+ and \verb+token_filter+ callbacks for to
3752 suppress a space by a line break which is after Japanese characters.
3753
3754 However, \verb+token_filter+ callback cannot be used either, since a
3755 character in category code 5~(end-of-line) is converted into an space
3756 token \emph{in the input processor}.  So we can use only the
3757 \verb+process_input_buffer+ callback.  This means that suppressing a
3758 space must be done \emph{just before} an input line is read.
3759
3760 Considering these situations, handling of an end-of-line in \LuaTeX-ja are as follows:
3761 \begin{quote}
3762 A character U+FFFFF (its category code is set to 14~(comment) by
3763 \LuaTeX-ja) is appended to an input line, \emph{before \LuaTeX\ actually
3764 process it}, if and only if the following two conditions are satisfied:
3765 \begin{enumerate}
3766 \item The category code of the character $\langle${return}$\rangle$
3767       (whose character code is 13) is 5~(end-of-line).
3768 \item The input line matches the following `regular expression':
3769 \[
3770   (\text{any char})^*(\textbf{JAchar})
3771   \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
3772 \]
3773 \end{enumerate}
3774 \end{quote}
3775
3776 \paragraph{Remark}
3777 The following example shows the major difference from the behavior of \pTeX:
3778 \begin{LTXexample}
3779 \ltjsetparameter{autoxspacing=false}
3780 \ltjsetparameter{jacharrange={-6}}xあ
3781 y\ltjsetparameter{jacharrange={+6}}zあ
3782 u
3783 \end{LTXexample}
3784 \begin{itemize}
3785 \item There is no space between `x' and `y', since the line~2 ends with a \textbf{JAchar} `あ'
3786 (this `あ' considered as an \textbf{JAchar} at the ending of line~1).
3787 \item There is no space between `あ' (in the line~3) and `u', since the
3788       line~3 ends with an \textbf{ALchar}
3789 (the letter `あ' considered as an \textbf{ALchar} at the ending of line~2).
3790 \end{itemize}
3791 %</en>
3792
3793 %<*ja>
3794 \LuaTeX の入力処理部は\TeX のそれと全く同じであり,callbackによりユーザが
3795 カスタマイズすることはできない.このため,改行抑制の目的でユーザが利用で
3796 きそうなcallbackとしては,\verb+process_input_buffer+や
3797 \verb+token_filter+に限られてしまう.しかし,\TeX の入力処理部をよく見る
3798 と,後者も役には経たないことが分かる:改行文字は,入力処理部によってトー
3799 クン化される時に,カテゴリーコード10の32番文字へと置き換えられてしまうた
3800 め,\verb+token_filter+で非標準なトークン読み出しを行おうとしても,空白文
3801 字由来のトークンと,改行文字由来のトークンは区別できないのだ.
3802
3803 すると,我々のとれる道は,\verb+process_input_buffer+を用いて
3804 \LuaTeX の入力処理部に引き渡される前に入力文字列を編集するというものしかない.
3805 以上を踏まえ,\LuaTeX-jaにおける「和文文字直後の改行抑制」の処理は,次のようになっている:
3806
3807 \begin{quote}
3808 各入力行に対し,\textbf{その入力行が読まれる前の内部状態で}
3809 以下の2条件が満たされている場合,\LuaTeX-jaはU+FFFFF番の文字
3810 \footnote{この文字はコメント文字として扱われるように\LuaTeX-ja内部で設定をしている.}
3811 を末尾に追加する.よって,その場合に改行は空白とは見做されないこととなる.
3812 \begin{enumerate}
3813 \item 改行文字(文字コード13番)のカテゴリーコードが5~(end-of-line)である.
3814 \item 入力行は次の「正規表現」にマッチしている:
3815 \[
3816   (\text{any char})^*(\textbf{JAchar})
3817   \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
3818 \]
3819 \end{enumerate}
3820 \end{quote}
3821
3822 この仕様は,前節で述べた\pTeX の仕様にできるだけ近づけたものとなっている.最初の条件は,
3823 \texttt{verbatim}系環境などの日本語対応マクロを書かなくてすませるためのものである.
3824 しかしながら,完全に同じ挙動が実現できたわけではない.
3825 差異は,次の例が示すように,和文文字の範囲を変更した行の改行において見られる:
3826 \begin{LTXexample}
3827 \ltjsetparameter{autoxspacing=false}
3828 \ltjsetparameter{jacharrange={-6}}xあ
3829 y\ltjsetparameter{jacharrange={+6}}zあ
3830 u
3831 \end{LTXexample}
3832 もし\pTeX とまったく同じ挙動を示すならば,出力は
3833 「\hbox{\ltjsetparameter{autoxspacing=false}x yzあu}」となるべきである.しかし,実際には
3834 上のように異なる挙動となっている.
3835 \begin{itemize}
3836 \item 2行目は「あ」という和文文字で終わる(2行目を処理する前の時点では,
3837       「あ」は和文文字扱いである)ため,直後の改行文字は無視される.
3838 \item 3行目は「あ」という欧文文字で終わる(2行目を処理する前の時点では,
3839       「あ」は欧文文字扱いである)ため,直後の改行文字は空白に置き換わる.
3840 \end{itemize}
3841 このため,トラブルを避けるために,和文文字の範囲を\verb+\ltjsetparameter+で編集した場合,
3842 その行はそこで改行するようにした方がいいだろう.
3843 %</ja>
3844
3845
3846 %<en>\section{Insertion of JFM glues, \Param{kanjiskip} and \Param{xkanjiskip}}
3847 %<ja>\section{JFM グルーの挿入,\Param{kanjiskip} と \Param{xkanjiskip}}
3848 \label{sec-jfmglue}
3849 %<en>\subsection{Overview}
3850 %<ja>\subsection{概要}
3851
3852 \LuaTeX-ja における和文処理グルーの挿入方法は,\pTeX のそれとは全く異なる.
3853 \pTeX では次のような仕様であった:
3854 \begin{itemize}
3855 \item JFMグルーの挿入は,和文文字を表すトークンを元に水平リストに(文字を表す)<char\_node>を
3856 追加する過程で行われる.
3857 \item \Param{xkanjiskip}の挿入は,水平ボックスへのパッケージングや行分割前に行われる.
3858 \item \Param{kanjiskip}はノードとしては挿入されない.パッケージングや行分割の計算時に
3859 「和文文字を表す2つの<char\_node>の間には\Param{kanjiskip}がある」ものとみなされる.
3860 \end{itemize}
3861 しかし,\LuaTeX-jaでは,水平ボックスへのパッケージングや行分割前に全ての
3862 \textbf{JAglue},即ちJFMグルー・\Param{xkanjiskip}・\Param{kanjiskip}の
3863 3種類を一度に挿入することになっている.これは,\LuaTeX において欧文の合字・
3864 カーニング処理がノードベースになったことに対応する変更である.
3865
3866 \LuaTeX-jaにおける\textbf{JAglue}挿入処理では,次節で定義する
3867 「クラスタ」を単位にして行われる.大雑把にいうと,「クラスタ」は文字とそれに付随す
3868 るノード達(アクセント位置補正用のkernや,イタリック補正)をまとめたもの
3869 であり,2つのクラスタの間には,ペナルティ,\verb+\vadjust+,whatsitなど,行組版
3870 には関係しないものがある.
3871
3872
3873 %<en>\subsection{definition of a `cluster'}
3874 %<ja>\subsection{「クラスタ」の定義}
3875
3876 \def\OA{$\text{\sf O}_{\text{\sf A}}$}
3877 \def\OB{$\text{\sf O}_{\text{\sf B}}$}
3878 \begin{defn}
3879 A \emph{cluster} is a list of consecutive nodes in one of the following forms,
3880 with the \textit{id} of it:
3881 \begin{enumerate}
3882 \item Nodes whose value of\ \verb+\ltj@icflag+ is in $[3,15)$.  These
3883       nodes come from a hbox which is already packaged, by unpackaging
3884       (\verb+\unhbox+).
3885       The \textit{id} is \textit{id\_pbox}.
3886 \item A inline math formula, including two \textit{math\_node}s at the boundary of it.
3887       The \textit{id} is \textit{id\_math}.
3888 \item A \textit{glyph\_node}~$p$ with nodes which relate with it:
3889 \begin{enumerate}
3890 \item A kern for the italic correction of~$p$.
3891 \item An accent attached to $p$ by \verb+\accent+.
3892 \end{enumerate}
3893 \[
3894 \overbrace{%
3895  \Node{kern}{$\mathit{subtype}=2$}\longrightarrow
3896 \left\{\begin{array}{c}
3897 \Node{glyph}{accent}\\\noalign{\medskip}
3898 \Node{hbox}{accent (shifted vert.)}
3899 \end{array}\right\}\longrightarrow
3900 \Node{kern}{$\mathit{subtype}=2$}}^{\text{(a)}}
3901 \longrightarrow
3902 \Node{glyph}{$p$}\longrightarrow
3903 \overbrace{%
3904 \Node{kern}{italic corr.}}^{\text{(b)}}
3905 \]
3906
3907 The \textit{id} is \textit{id\_jglyph} or
3908 \textit{id\_glyph}, according to whether the \textit{glyph\_node}
3909 represents a Japanese character or not.
3910 \item An box-like node, that is, an hbox, a vbox, a rule (\verb+\vrule+) and an \textit{unset\_node}.
3911 The \textit{id} is \textit{id\_hlist} if the node is an
3912       hbox which is not shifted vertically, or \textit{id\_box\_like}
3913       otherwise.
3914 \item A glue, a kern whose subtype is not 2~(\textit{accent}), and a discretionary break.
3915 The \textit{id} is \textit{id\_glue}, \textit{id\_kern}
3916       and \textit{id\_disc}, respectively.
3917 \end{enumerate}
3918 We denote a cluster by \textit{Np}, \textit{Nq} and \textit{Nr}.
3919 \end{defn}
3920
3921 以降は日本語.
3922
3923 \paragraph{\textit{id}の意味}
3924 $\mathit{Np}.\mathit{id}$の意味を述べるとともに,
3925 「先頭の文字」を表す\textit{glyph\_node}~$\mathit{Np}.\mathit{head}$と,
3926 「最後の文字」を表す\textit{glyph\_node}~$\mathit{Np}.\mathit{tail}$を次のように定義する.
3927 直感的に言うと,\textit{Np}は$\mathit{Np}.\mathit{head}$で始まり$\mathit{Np}.\mathit{tail}$で終わるような単語,
3928 と見做すことができる.これら$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は
3929 説明用に準備した概念であって,実際の Lua コード中にそのように書かれているわけではないことに注意.
3930
3931 \begin{description}
3932 \item[\textit{id\_jglyph}] 和文文字.\\
3933 $\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は,その和文文字を表している
3934 \textit{glyph\_node}そのものである.
3935 \item[\textit{id\_glyph}] 和文文字を表していない\textit{glyph\_node}~$p$.\\
3936 多くの場合,$p$は欧文文字を格納しているが,`ffi'などの合字によって作られた
3937 \textit{glyph\_node}である可能性もある.
3938 前者の場合,$\mathit{Np}.\mathit{head}$,~$\mathit{Np}.\mathit{tail} = p$である.
3939 一方,後者の場合,
3940 \begin{itemize}
3941 \item $\mathit{Np}.\mathit{head}$は,
3942 合字の構成要素の先頭→(その\textit{glyph\_node}における)合字の構成要素の先頭→……
3943 と再帰的に検索していってたどり着いた\textit{glyph\_node}である.
3944 \item $\mathit{Np}.\mathit{last}$は,同様に末尾→末尾→と検索してたどり着いた\textit{glyph\_node}である.
3945 \end{itemize}
3946 \item[\textit{id\_math}] インライン数式.\\
3947 便宜的に,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$ともに
3948 「文字コード$-1$の欧文文字」とおく.
3949 \item[\textit{id\_hlist}] 縦方向にシフトされていない水平ボックス.\\
3950 この場合,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$はそれぞれ$p$の内容を表すリストの,
3951 先頭・末尾のノードである.
3952 \begin{itemize}
3953 \item 状況によっては,\TeX ソースで言うと
3954 \begin{verbatim}
3955 \hbox{\hbox{abc}...\hbox{\lower1pt\hbox{xyz}}}
3956 \end{verbatim}
3957 のように,$p$の内容が別の hbox で開始・終了している可能性も十分あり得る.そのような場合,
3958 $\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$の算出は,\textbf{垂直方向にシフトされていない}水平ボックスの
3959 場合だけ内部を再帰的に探索する.例えば上の例では,$\mathit{Np}.\mathit{head}$は文字「a」を表すノードであり,
3960 一方$\mathit{Np}.\mathit{tail}$は垂直方向にシフトされた水平ボックス,\verb+\lower1pt\hbox{xyz}+に対応するノードである.
3961 \item また,先頭にアクセント付きの文字がきたり,末尾にイタリック補正用の kern が
3962 来ることもあり得る.この場合は,クラスタの定義のところにもあったように,それらは無視して算出を行う.
3963 \item 最初・最後のノードが合字によって作られた\textit{glyph\_node}のときは,それぞれに対して\textit{id\_glyph}%
3964 と同様に再帰的に構成要素をたどっていく.
3965 \end{itemize}
3966 \item[\textit{id\_pbox}] 「既に処理された」ノードのリストであり,これらのノードが二度処理を受けないために
3967 まとめて1つのクラスタとして取り扱うだけである.
3968 \textit{id\_hlist}と同じ方法で$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$を算出する,
3969 \item[\textit{id\_disc}] discretionary break (\verb+\discretionary{pre}{post}{nobreak}+).\\
3970 \textit{id\_hlist}と同じ方法で$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$を算出するが,
3971 第3引数の \texttt{nobreak}(行分割が行われない時の内容)を使う.言い換えれば,ここで行分割が発生した時の状況は
3972 全く考慮に入れない.
3973 \item[\textit{id\_box\_like}] \textit{id\_hlist}とならないboxや,rule.\\
3974 この場合は,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$のデータは利用されないので,2つの算出は無意味である.
3975 敢えて明示するならば,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は共にnil値である.
3976 \item[他] 以上にない\textit{id}に対しても,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$の算出は無意味.
3977 \end{description}
3978
3979 \paragraph{クラスタの別の分類}
3980 さらに,JFMグルー挿入処理の実際の説明により便利なように,\textit{id}とは別のクラスタの分類を行っておく.
3981 挿入処理では2つの隣り合ったクラスタの間に
3982 空白等の実際の挿入を行うことは前に書いたが,ここでの説明では,問題にしているクラスタ\textit{Np}は「後ろ側」のクラスタである
3983 とする.「前側」のクラスタについては,以下の説明で\textit{head}が\textit{last}に置き換わることに注意すること.
3984 \begin{description}
3985 \item[和文A] リスト中に直接出現している和文文字.
3986 \textit{id}が\textit{id\_jglyph}であるか,\\
3987 \textit{id}が\textit{id\_pbox}であって$\mathit{Np}.\mathit{head}$が\textbf{JAchar}であるとき.
3988
3989 \item[和文B] リスト中の水平ボックスの中身の先頭として出現した和文文字.和文Aとの違いは,これの前に
3990 JFMグルーの挿入が行われない(\Param{xkanjiskip},~\Param{kanjiskip}は入り得る)ことである.\\
3991 \textit{id}が\textit{id\_hlist}か\textit{id\_disc}であって$\mathit{Np}.\mathit{head}$が\textbf{JAchar}であるとき.
3992
3993 \item[欧文] リスト中に直接/水平ボックスの中身として出現している欧文文字.次の3つの場合が該当:
3994 \begin{itemize}
3995 \item \textit{id}が\textit{id\_glyph}である.
3996 \item \textit{id}が\textit{id\_math}である.
3997 \item \textit{id}が\textit{id\_pbox}か\textit{id\_hlist}か\textit{id\_disc}であって,$\mathit{Np}.\mathit{head}$が\textbf{ALchar}.
3998 \end{itemize}
3999 \item[箱] box,またはそれに類似するもの.次の2つが該当:
4000 \begin{itemize}
4001 \item \textit{id}が\textit{id\_pbox}か\textit{id\_hlist}か\textit{id\_disc}であって,$\mathit{Np}.\mathit{head}$が\textit{glyph\_node}でない.
4002 \item \textit{id}が\textit{id\_box\_like}である.
4003 \end{itemize}
4004
4005 \end{description}
4006
4007 \subsection{段落/水平ボックスの先頭や末尾}
4008 \paragraph{先頭部の処理}
4009 まず,段落/水平ボックスの一番最初にあるクラスタ\textit{Np}を探索する.
4010 水平ボックスの場合は何の問題もないが,段落の場合では以下のノード達を事前に読み飛ばしておく:
4011 \begin{center}
4012 \verb+\parindent+由来の水平ボックス ($\mathit{subtype}=3$),及び\textit{subtype}が44~(\textit{user\_defined})でない
4013 ようなwhatsit.
4014 \end{center}
4015 これは,\verb+\parindent+由来の水平ボックスがクラスタを構成しないようにするためである.
4016
4017 次に,\textit{Np}の直前に空白$g$を必要なら挿入する:
4018 \begin{enumerate}
4019 \item この処理が働くような\textit{Np}は\textsf{和文A}である.
4020 \item 問題のリストが字下げありの段落(\verb+\parindent+由来の水平ボックスあり)の場合は,
4021 この空白$g$は「文字コード\texttt{'parbdd'}の文字」と\textit{Np}の間に入るglue/kernである.
4022 \item そうでないとき(\verb+noindent+で開始された段落や水平ボックス)は,
4023 $g$は「文字コード\texttt{'boxbdd'}の文字」と\textit{Np}の間に入るglue/kernである.
4024 \end{enumerate}
4025 ただし,もし$g$がglueであった場合,この挿入によって\textit{Np}による行分割が新たに可能になるべきではない.
4026 そこで,以下の場合には,$g$の直前に\verb+\penalty10000+を挿入する:
4027 \begin{itemize}
4028 \item 問題にしているリストが段落であり,かつ
4029 \item \textit{Np}の前には予めペナルティがなく,$g$はglue.
4030 \end{itemize}
4031
4032 \paragraph{末尾の処理}
4033 末尾の処理は,問題のリストが段落のものか水平ボックスのものかによって異なる.
4034 後者の場合は容易い:最後のクラスタを\textit{Nq}とおくと,\textit{Nq}と「文字コード\texttt{'boxbdd'}の文字」の間に入るglue/kernを,
4035 \textit{Nq}の直後に挿入するのみである.
4036
4037 一方.前者(段落)の場合は,リストの末尾は常に\verb+\penalty10000+と,
4038 \verb+\parfillskip+由来のグルーが存在する.よって,最後のクラスタ\textit{Np}は
4039 この\verb+\parfillskip+由来のグルーとなり,実質的な中身の最後はその1つ前のクラスタ\textit{Nq}となる.
4040 \begin{enumerate}
4041 \item まず\textit{Nq}の直後に(後に述べる)\textsf{line-end~[E]}によって定まる空白を挿入する.
4042 \item 次に,段落の最後の「通常の和文文字${}+{}$句点」が独立した行となるのを防ぐために,
4043 \Param{jcharwidowpenalty}の値の分だけ適切な場所のペナルティを増やす.
4044
4045 ペナルティ量を増やす場所は,\textit{head}が\textbf{JAchar}であり,かつその文字の\Param{kcatcode}が偶数であるような
4046 最後のクラスタの直前にあるものたちである\footnote{大雑把に言えば,\Param{kcatcode}が奇数であるような\textbf{JAchar}
4047 を約物として考えていることになる.\Param{kcatcode}の最下位ビットはこの\Param{jcharwidowpenalty}用にのみ利用される.}.
4048 \end{enumerate}
4049
4050 \subsection{概観と典型例:2つの「和文A」の場合}
4051 先に述べたように,2つの隣り合ったクラスタ,\textit{Nq}と\textit{Np}の間には,
4052 ペナルティ,\verb+\vadjust+,whatsitなど,行組版には関係しないものがある.模式的に表すと,
4053 \[
4054  \Node{cluster}{\textit{Nq}}\longrightarrow
4055 \overbrace{
4056 \Node{penalty}{$p$}\longrightarrow \cdots\longrightarrow \Node{whatsit}{}}^{(a)}
4057 \longrightarrow \Node{cluster}{\textit{Np}}
4058 \]
4059 のようになっている.間の(a)に相当する部分には,何のノードもない場合ももちろんあり得る.
4060 そうして,JFMグルー挿入後には,この2クラスタ間は次のようになる:
4061 \[
4062  \Node{cluster}{\textit{Nq}}\longrightarrow\Node{kern}{左空白}\longrightarrow
4063 \overbrace{
4064 \Node{penalty}{$p+x$}\longrightarrow \cdots\longrightarrow \Node{whatsit}{}}^{(a)}
4065 \longrightarrow \Node{glue or kern}{右空白}\longrightarrow \Node{cluster}{\textit{Np}}
4066 \]
4067
4068 以後,\textbf{典型的な例として,クラスタ\textit{Nq}と\textit{Np}が共に\textsf{\textmd{和文A}}である場合を見ていこう,}
4069 この場合が全ての場合の基本となる.
4070
4071 \paragraph{「右空白」の算出}
4072 まず,「右空白」にあたる量を算出する.通常はこれが,隣り合った2つの和文文字間に入る空白量となる.
4073 \begin{description}
4074 \item[JFM由来{[M]}] JFMの文字クラス指定によって入る空白を以下によって求める.この段階で空白量が未定義(未指定)だった場合,
4075       デフォルト値\Param{kanjiskip}を採用することとなるので,次へ.
4076 \begin{enumerate}
4077 \item もし両クラスタの間で\verb+\inhibitglue+が実行されていた場合(証としてwhatsitノードが自動挿入される),
4078       代わりに\Param{kanjiskip}が挿入されることとなる.次へ.
4079 \item \textit{Nq}と\textit{Np}が同じJFM・同じ\texttt{jfmvar}キー・同じサイズの和文フォントであったならば,
4080       共通に使っているJFM内で挿入される空白 (glue or kern) が決まっているか調べる.
4081 \item 1.でも2.でもない場合は,\textit{Nq}と\textit{Np}が違うJFM/\texttt{jfmvar}/サイズである.
4082 この場合,まず
4083 \[
4084 \vcenter{\halign{\hfil$#:={}$&(\inhibitglue#\inhibitglue)\cr
4085 gb&\textit{Nq}と「文字コードが{\tt'diffmet'}の文字」との間に入るglue/kern\cr
4086 ga&「文字コードが{\tt'diffmet'}の文字」と\textit{Np}との間に入るglue/kern\cr
4087 }}
4088 \]
4089 として,左側由来・右側由来の空白 (glue/kern) を(それぞれのJFMから)求める.
4090 $\mathit{ga}$と$\mathit{gb}$のどちらか片方が未定義であるならば,定義されている側の値をそのまま採用する.
4091 もし$\mathit{ga}$と$\mathit{gb}$が両方決まっているならば,両者の値を平均\footnote{\Param{differentjfm}パラメタの
4092 値によって,「大きい方」「小さい方」「合計」に変えることができる.}した値を採用する.
4093 \end{enumerate}
4094
4095 例えば,
4096 \begin{verbatim}
4097 \jfont\foo=psft:Ryumin-Light:jfm=ujis
4098 \jfont\bar=psft:GothicBBB-Medium:jfm=ujis
4099 \jfont\baz=psft:GothicBBB-Medium:jfm=ujis;jfmvar=piyo
4100 \end{verbatim}
4101 という3フォントを考え,
4102 \[
4103  \overbrace{\Node{glyph}{{\tt\char92 foo}, `あ'}}^{p}
4104 \longrightarrow \overbrace{\Node{glyph}{{\tt\char92 bar}, `い'}}^{q}
4105 \longrightarrow \overbrace{\Node{glyph}{{\tt\char92 baz}, `う'}}^{r}
4106 \]
4107 という3ノードを考える(それぞれ単独でクラスタをなす).
4108 この場合,$p$と$q$の間は,実フォントが異なるにもかかわらず(2)の状況となる一方で,
4109 $q$と$r$の間は(実フォントが同じなのに)\texttt{jfmvar}キーの内容が異なるので(3)の状況となる.
4110 \item[\Param{kanjiskip}~{[K]}] 上の[M]において空白が定まらなかった場合,
4111 \Param{kanjiskip}の値を以下で定め,それを「右空白」として採用する.
4112 この段階においては,\verb+\inhibitglue+は効力を持たないため,
4113 結果として,2つの和文文字間には常に何らかのglue/kernが挿入されることとなる.
4114 \begin{enumerate}
4115 \item 両クラスタ(厳密には$\mathit{Nq}.\mathit{tail}$,$\mathit{Np}.\mathit{head}$)の中身の文字コードに対する
4116 \Param{autospacing}パラメタが両方ともfalseだった場合は,長さ0のglueとする.
4117 \item ユーザ側から見た\Param{kanjiskip}パラメタの自然長が${\tt \char92 maxdimen}=(2^{30}-1)\,{\rm sp}$で
4118 なければ,\Param{kanjiskip}パラメタの値を持つglueを採用する.
4119 \item 2.でない場合は,\textit{Nq}, \textit{Np}で使われているJFMに指定されている\Param{kanjiskip}の値を用いる.
4120 どちらか片方のクラスタだけが和文文字(\textsf{和文A}・\textsf{和文B})のときは,そちらのクラスタで使われている
4121 JFM由来の値だけを用いる.もし両者で使われているJFMが異なった場合は,上の[M]~3.と同様の方法を用いて調整する.
4122 \end{enumerate}
4123 \end{description}
4124 \paragraph{「左空白」の算出とそれに伴う補正}
4125 次に,「左空白」にあたる量を算出する:
4126 \begin{description}
4127 \item[line-end~{[E]}]
4128 \textit{Nq}と\textit{Np}の間で行分割が起きたときに,
4129 \textit{Nq}と行末の間に入る空白である.ぶら下げ組の組版などに用いられることを期待している.
4130 \begin{enumerate}
4131 \item 既に算出した「右空白」がkernである場合は,「左空白」は挿入されない.
4132 \item 「右空白」がglueか未定義(長さ0のglueとみなす)の場合は,「左空白」は
4133 \textit{Nq}と「文字コード\texttt{'lineend'}の文字」との間に入るkernとして,JFMから決定される.
4134 \item 2.で決まった「左空白」の長さが0でなければ,その分だけ先ほど算出した「右空白」の自然長を引く.
4135 \end{enumerate}
4136 \end{description}
4137 \paragraph{禁則用ペナルティの挿入}
4138 まず,
4139 \[
4140  a:=(\text{\textit{Nq}{\footnotemark}の文字に対する\Param{postbreakpenalty}の値})
4141 +(\text{\textit{Np}{\footnotemark}の文字に対する\Param{prebreakpenalty}の値})
4142 \]
4143 とおく\footnotetext{厳密にはそれぞれ$\mathit{Nq}.\mathit{tail}$,$\mathit{Np}.\mathit{head}$.}.
4144 ペナルティは通常$[-10000,10000]$の整数値をとり,また$\pm 10000$は正負の無限大を意味することになっているが,この$a$の
4145 算出では単純な整数の加減算を行う.
4146
4147 $a$は禁則処理用に\textit{Nq}と\textit{Np}の間に加えられるべきペナルティ量である.
4148 \begin{description}
4149 \item[P-normal~{[PN]}]
4150 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティ(\textit{penalty\_node})があれば処理は簡単である:
4151 それらの各ノードにおいて,ペナルティ値を($\pm 10000$を無限大として扱いつつ)$a$だけ増加させればよい.
4152 また,$10000 + (-10000) = 0$としている.
4153
4154 少々困るのは,(a)部分にペナルティが存在していない場合である.
4155 直感的に,補正すべき量$a$が0でないとき,その値をもつ\textit{penalty\_node}を作って
4156 「右空白」の(もし未定義なら\textit{Np}の)直前に挿入……
4157 ということになるが,実際には僅かにこれより複雑である.
4158 \begin{itemize}
4159 \item 「右空白」がkernであるとき,
4160 それは「\textit{Nq}と\textit{Np}の間で改行は許されない」ことを意図している.そのため,
4161 この場合は$a\neq 0$であってもペナルティの挿入はしない.
4162 \item 「左空白」がkernとしてきっちり定義されている時(このとき,「右空白」はkernでない),
4163 この「左空白」の直後での行分割を許容しないといけないので,$a=0$であっても
4164 \textit{penalty\_node}を作って挿入する.
4165 \item 以上のどれでもないときは,$a\neq 0$ならば\textit{penalty\_node}を作って挿入する.
4166 \end{itemize}
4167 \end{description}
4168
4169 \def\gkf#1#2#3{\sf$\displaystyle\vphantom{\Bigg(}%
4170   \frac{\hbox to 1\zw{#1}\hbox to 4.5\zw{\hss #2}}{\hbox{#3}}$}
4171 \begin{table}[t]
4172 \caption{Summary of JFM glues}
4173 \label{tab-jfmglue}
4174 \begin{center}
4175 \small
4176 \begin{tabular}{>{\sf}c|cccccc}
4177 \toprule
4178 {\bf\textit{Np}}↓&\sf 和文A&\sf 和文B&\sf 欧文&\sf 箱&\sf glue&\sf kern\\\midrule
4179 和文A&
4180 \gkf{E}{M→K}{PN}&
4181 \gkf{---}{\OA →K}{PN}&
4182 \gkf{---}{\OA →X}{PN}&
4183 \gkf{---}{\OA}{PA}&
4184 \gkf{---}{\OA}{PN}&
4185 \gkf{---}{\OA}{PS}\\
4186 和文B&
4187 \gkf{E}{\OB→K}{PA}&
4188 \gkf{---}{K}{PS}&
4189 \gkf{---}{X}{PS}\\
4190 欧文&
4191 \gkf{E}{\OB →X}{PA}&
4192 \gkf{---}{X}{PS}\cr
4193 箱&\gkf{E}{\OB}{PA}\\
4194 glue&\gkf{E}{\OB}{PN}\\
4195 kern&\gkf{E}{\OB}{PS}\\
4196 \bottomrule
4197 \end{tabular}
4198 \end{center}
4199 \begin{quote}
4200 Here {\small\gkf{E}{M→K}{PN}} means that
4201 \begin{enumerate}
4202 \item To determine the `right-space', \LuaTeX-ja first attempts by the method `\textsf{JFM-origin~[M]}'.
4203 If this attempt fails, \LuaTeX-ja use the method `\textsf{\Param{kanjiskip}~[K]}'.
4204 \item The `left space' between \textit{Nq}~and~\textit{Np} is determined by the method `\textsf{line-end~[E]}'.
4205 \item \LuaTeX-ja adopts the method `\textsf{P-normal~[PN]}' to adjust the penalty between two clusters for \emph{kinsoku shori}.
4206 \end{enumerate}
4207 \end{quote}
4208 \end{table}
4209
4210 \subsection{その他の場合}
4211 本節の内容は表\ref{tab-jfmglue}にまとめてある.
4212
4213 \paragraph{和文Aと欧文の間}
4214 \textit{Nq}が\textsf{和文A}で,\textit{Np}が\textsf{欧文}の場合,JFMグルー挿入処理は次のようにして行われる.
4215 \begin{itemize}
4216 \item 「右空白」については,まず以下に述べる\textsf{Boundary-B~[\OB]}により空白を決定しようと試みる.
4217 それが失敗した場合は,\textsf{\Param{xkanjiskip}~[X]}によって定める.
4218 \item 「左空白」については,既に述べた\textsf{line-end~[E]}をそのまま採用する.それに伴う「右空白」の補正も同じ.
4219 \item 禁則用ペナルティも,以前述べた\textsf{P-normal~[PN]}と同じである.
4220 \end{itemize}
4221 \begin{description}
4222 \item[Boundary-B~{[\OB]}] 和文文字と「和文でないもの」との間に入る空白を以下によって求め,
4223 未定義でなければそれを「右空白」として採用する.
4224 \textsf{JFM-origin~[M]}の変種と考えて良い.
4225 これによって定まる空白の典型例は,和文の閉じ括弧と欧文文字の間に入る半角アキである.
4226 \begin{enumerate}
4227 \item もし両クラスタの間で\verb+\inhibitglue+が実行されていた場合(証としてwhatsitノードが自動挿入される),次へ.
4228 \item そうでなければ,
4229 \textit{Nq}と「文字コードが{\tt'jcharbdd'}の文字」との間に入るglue/kernとして定まる.
4230 \end{enumerate}
4231 \item[\Param{xkanjiskip}~{[X]}]
4232 この段階では,\textsf{\Param{kanjiskip}~[K]}のときと同じように,
4233 \Param{xkanjiskip}の値を以下で定め,それを「右空白」として採用する.
4234 この段階で\verb+\inhibitglue+は効力を持たないのも同じである.
4235 \begin{enumerate}
4236 \item 以下のいずれかの場合は,\Param{xkanjiskip}の挿入は抑止される.しかし,実際には行分割を許容するために,長さ0のglueを採用する:
4237 \begin{itemize}
4238 \item 両クラスタにおいて,それらの中身の文字コードに対する\Param{autoxspacing}パラメタが共にfalseである.
4239 \item \textit{Nq}の中身の文字コードについて,「直後への\Param{xkanjiskip}の挿入」が禁止されている
4240 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメタが2以上).
4241 \item \textit{Np}の中身の文字コードについて,「直前への\Param{xkanjiskip}の挿入」が禁止されている
4242 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメタが偶数).
4243 \end{itemize}
4244 \item ユーザ側から見た\Param{xkanjiskip}パラメタの自然長が${\tt \char92 maxdimen}=(2^{30}-1)\,{\rm sp}$で
4245 なければ,\Param{xkanjiskip}パラメタの値を持つglueを採用する.
4246 \item 2.でない場合は,\textit{Nq}, \textit{Np}(\textsf{和文A}/\textsf{和文B}なのは片方だけ)
4247 で使われているJFMに指定されている\Param{xkanjiskip}の値を用いる.
4248 \end{enumerate}
4249 \end{description}
4250
4251 \paragraph{欧文と和文Aの間}
4252 \textit{Nq}が\textsf{欧文}で,\textit{Np}が\textsf{和文A}の場合,JFMグルー挿入処理は上の場合とほぼ同じである.
4253 \textsf{和文A}のクラスタが逆になるので,\textsf{Boundary-A~[\OA]}の部分が変わるだけ.
4254 \begin{itemize}
4255 \item 「右空白」については,まず以下に述べる\textsf{Boundary-A~[\OA]}により空白を決定しようと試みる.
4256 それが失敗した場合は,\textsf{\Param{xkanjiskip}~[X]}によって定める.
4257 \item \textit{Nq}が和文でないので,「左空白」は算出されない.
4258 \item 禁則用ペナルティは,以前述べた\textsf{P-normal~[PN]}と同じである.
4259 \end{itemize}
4260 \begin{description}
4261 \item[Boundary-A~{[\OA]}] 「和文でないもの」と和文文字との間に入る空白を以下によって求め,
4262 未定義でなければそれを「右空白」として採用する.
4263 \textsf{JFM-origin~[M]}の変種と考えて良い.
4264 これによって定まる空白の典型例は,欧文文字と和文の開き括弧との間に入る半角アキである.
4265 \begin{enumerate}
4266 \item もし両クラスタの間で\verb+\inhibitglue+が実行されていた場合(証としてwhatsitノードが自動挿入される),次へ.
4267 \item そうでなければ,
4268 「文字コードが{\tt'jcharbdd'}の文字」と\textit{Np}との間に入るglue/kernとして定まる.
4269 \end{enumerate}
4270 \end{description}
4271
4272 \paragraph{和文Aと箱・glue・kernの間}
4273 \textit{Nq}が\textsf{和文A}で,\textit{Np}が\textsf{箱}・glue・kernのいずれかであった場合,
4274 両者の間に挿入されるJFMグルーについては同じ処理である.しかし,そこでの行分割に対する仕様が異なるので,
4275 ペナルティの挿入処理は若干異なったものとなっている.
4276
4277 \begin{itemize}
4278 \item 「右空白」については,既に述べた\textsf{Boundary-B~[\OB]}により空白を決定しようと試みる.
4279 それが失敗した場合は,「右空白」は挿入されない.
4280 \item 「左空白」については,既に述べた\textsf{line-end~[E]}の算出方法をそのまま採用する.それに伴う「右空白」の補正も同じ.
4281 \item 禁則用ペナルティの処理は,後ろのクラスタ\textit{Np}の種類によって異なる.
4282 なお,$\mathit{Np}.\mathit{head}$は無意味であるから,
4283 「$\mathit{Np}.\mathit{head}$に対する\Param{prebreakpenalty}の値」は0とみなされる.言い換えれば,
4284 \[
4285  a:=(\text{\textit{Nq}{\footnotemark}の文字に対する\Param{postbreakpenalty}の値}).
4286 \]
4287 \begin{description}
4288 \item[箱] \textit{Np}が\textsf{箱}であった場合は,両クラスタの間での行分割は
4289 (明示的に両クラスタの間に\verb+\penalty10000+があった場合を除き)いつも許容される.そのため,
4290 ペナルティ処理は,後に述べる\textsf{P-allow~[PA]}が\textsf{P-normal~[PN]}の代わりに用いられる.
4291 \item[glue] \textit{Np}がglueの場合,ペナルティ処理は\textsf{P-normal~[PN]}を用いる.
4292 \item[kern] \textit{Np}がkernであった場合は,両クラスタの間での行分割は
4293 (明示的に両クラスタの間にペナルティがあった場合を除き)許容されない.
4294 ペナルティ処理は,後に述べる\textsf{P-suppress~[PS]}を使う.
4295 \end{description}
4296 これらの\textsf{P-normal~[PN]},\textsf{P-allow~[PA]},\textsf{P-suppress~[PS]}の違いは,
4297 \textit{Nq}と\textit{Np}の間(以前の図だと(a)の部分)にペナルティが存在しない場合にのみ存在する.
4298 \end{itemize}
4299
4300 \begin{description}
4301 \item[P-allow~{[PA]}]
4302 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティがあれば,\textsf{P-normal~[PN]}と同様に,
4303 それらの各ノードにおいてペナルティ値を$a$だけ増加させる.
4304
4305 (a)部分にペナルティが存在していない場合,
4306 \LuaTeX-ja は\textit{Nq}と\textit{Np}の間の行分割を可能にしようとする.
4307 そのために,以下の場合に$a$をもつ\textit{penalty\_node}を作って
4308 「右空白」の(もし未定義なら\textit{Np}の)直前に挿入する:
4309 \begin{itemize}
4310 \item 「右空白」がglueでない(kernか未定義)であるとき.
4311 \item 「左空白」がkernとしてきっちり定義されている時.
4312 \end{itemize}
4313
4314 \item[P-suppress~{[PS]}]
4315 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティがあれば,\textsf{P-normal~[PN]}と同様に,
4316 それらの各ノードにおいてペナルティ値を$a$だけ増加させる.
4317
4318 (a)部分にペナルティが存在していない場合,
4319 \textit{Nq}と\textit{Np}の間の行分割は元々不可能のはずだったのであるが,
4320 \LuaTeX-ja はそれをわざわざ行分割可能にはしない.
4321 そのため,「右空白」がglueであれば,その直前に\verb+\penalty10000+を挿入する.
4322 \end{description}
4323
4324 なお,「右空白」はkern,「左空白」は未定義の
4325 \[
4326  \overbrace{\Node{glyph}{`あ'}}^{\mathit{Nq}}\longrightarrow \overbrace{\Node{glue}{1\,pt}}^{\mathit{Np}}
4327 \]
4328 のような状況を考える.
4329 このとき,$a$,即ち「あ」の\Param{postbreakpenalty}がいかなる値であっても,
4330 この2クラスタ間は最終的に
4331 \begin{equation}
4332  \overbrace{\Node{glyph}{`あ'}}^{\mathit{Nq}}\longrightarrow
4333 \Node{kern}{右空白}\longrightarrow \overbrace{\Node{glue}{1\,pt}}^{\mathit{Np}}
4334 \label{eq-gref}
4335 \end{equation}
4336 となり,$a$分のペナルティは挿入されないことに注意して欲しい.
4337 \Param{postbreakpenalty}は($a$は)殆どの場合が非負の値と考えられ,そのような場合では
4338 \eqref{eq-gref}と
4339 \[
4340  \overbrace{\Node{glyph}{`あ'}}^{\mathit{Nq}}\longrightarrow
4341 \Node{penalty}{$a$}\longrightarrow
4342 \Node{kern}{右空白}\longrightarrow \overbrace{\Node{glue}{1\,pt}}^{\mathit{Np}}
4343 \]
4344 との間に差異は生じない%
4345 \footnote{kern$\rightarrow$glueが1つの行分割可能点(行分割に伴うペナルティは0)
4346 であるため,たとえ$a=10000$であっても,\textit{Nq}と\textit{Np}の間で行分割を禁止することはできない.}.
4347
4348 \paragraph{箱・glue・kernと和文Aの間}
4349 \textit{Np}が\textsf{箱}・glue・kernのいずれかで,\textit{Np}が\textsf{和文A}であった場合は,
4350 すぐ上の(\textit{Nq}と\textit{Np}の順序が逆になっている)場合とほぼ同じであるが,「左空白」がなくなることにのみ注意.
4351 \begin{itemize}
4352 \item 「右空白」については,既に述べた\textsf{Boundary-A~[\OA]}により空白を決定しようと試みる.
4353 それが失敗した場合は,「右空白」は挿入されない.
4354 \item \textit{Nq}が和文でないので,「左空白」は算出されない.
4355 \item 禁則用ペナルティの処理は,\textit{Nq}の種類によって異なる.
4356 $\mathit{Nq}.\mathit{tail}$は無意味なので,
4357 \[
4358  a:=(\text{\textit{Np}{\footnotemark}の文字に対する\Param{prebreakpenalty}の値}).
4359 \]
4360 \begin{description}
4361 \item[箱] \textit{Nq}が\textsf{箱}の場合は,\textsf{P-allow~[PA]}を用いる.
4362 \item[glue] \textit{Nq}がglueの場合は,\textsf{P-normal~[PN]}を用いる.
4363 \item[kern] \textit{Nq}がkernの場合は,\textsf{P-suppress~[PS]}を用いる.
4364 \end{description}
4365 \end{itemize}
4366
4367 \paragraph{和文Aと和文Bの違い}
4368 先に述べたように,\textsf{和文B}は水平ボックスの中身の先頭(or 末尾)として出現している
4369 和文文字である.リスト内に直接ノードとして現れている和文文字(\textsf{和文A})との違いは,
4370 \begin{itemize}
4371 \item \textsf{和文B}に対しては,JFMの文字クラス指定から定まる空白
4372 \textsf{JFM-origin~[M]},\textsf{Boundary-A~[\OA]},\textsf{Boundary-B~[\OB]})の挿入は行われない.
4373 「左空白」の算出も行われない.例えば,
4374 \begin{itemize}
4375 \item 片方が\textsf{和文A},もう片方が\textsf{和文B}のクラスタの場合,
4376 \textsf{Boundary-A~[\OA]}または\textsf{Boundary-B~[\OB]}の挿入を試み,それがダメなら
4377 \Param{kanjiskip}~\textsf{[K]}の挿入を行う.
4378 \item \textsf{和文B}の2つのクラスタの間には,\Param{kanjiskip}~\textsf{[K]}が自動的に入る.
4379 \end{itemize}
4380 \item \textsf{和文B}と箱・glue・kernが隣接したとき(どちらが前かは関係ない),間にJFMグルー・ペナルティの挿入は一切しない.
4381 \item \textsf{和文B}と\textsf{和文B},また\textsf{和文B}と\textsf{欧文}とが隣接した時は,禁則用ペナルティ挿入処理は
4382 \textsf{P-suppress~[PS]}が用いられる.
4383 \item \textsf{和文B}の文字に対する\Param{prebreakpenalty},~\Param{postbreakpenalty}の値は使われず,0として計算される.
4384 \end{itemize}
4385
4386
4387 次が具体例である:
4388 \begin{LTXexample}
4389 あ.\inhibitglue A\\
4390 \hbox{あ.}A\\
4391 あ.A
4392 \end{LTXexample}
4393 \begin{itemize}
4394 \item 1行目の\verb+\inhibitglue+は\textsf{Boundary-B~[\OB]}の処理のみを抑止するので,ピリオドと「A」の間には
4395 \Param{xkanjiskip}(四分アキ)が入ることに注意.
4396 \item 2行目のピリオドと「A」の間においては,前者が\textsf{和文B}となる(水平ボックスの中身の末尾として登場しているから)ので,
4397 そもそも\textsf{Boundary-B~[\OB]}の処理は行われない.よって,\Param{xkanjiskip}が入ることとなる.
4398 \item 3行目では,ピリオドの属するクラスタは\textsf{和文A}である.これによって,
4399 ピリオドと「A」の間には\textsf{Boundary-B~[\OB]}由来の半角アキが入ることになる.
4400 \end{itemize}
4401
4402 \section{psft}
4403
4404 \begin{thebibliography}{99}
4405   \addcontentsline{toc}{section}{\refname}
4406 \bibitem{texbytopic}
4407 Victor Eijkhout,  \emph{\TeX\ by Topic, A \TeX nician's Reference}, Addison-Wesley, 1992.
4408 \end{thebibliography}
4409 \end{document}