OSDN Git Service

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