OSDN Git Service

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