OSDN Git Service

lltjp-listings.sty: support IVS (ugly hack)
[luatex-ja/luatexja.git] / doc / luatexja.dtx
1 %<*!showexpl>
2 %#! lualatex -shell-escape
3
4 % To typeset this manual, you need following two fonts:
5 %  - KozMinPr6N-Regular.otf
6 %  - KozGoPr6N-Medium.otf
7 %  - KozGoPr6N-Regular.otf
8
9 %<en>\documentclass[a4paper,titlepage]{article}
10 %<ja>\documentclass[a4paper,titlepage]{ltjsarticle}
11
12 %%%%%%%%
13 \makeatletter
14 %%%%%%%%
15
16 %%%%%%%% record loaded packages
17 \let\ltjpkglist\empty
18 \newif\if@real@append@list
19 \def\@append@newentry#1#2{{%
20   \@real@append@listtrue \def\@tempa{#2}%
21   \let\@pkglist\@append@newentry@pkglist#1%
22   \if@real@append@list
23     \let\@pkglist=\relax\xdef#1{#1\@pkglist{#2}}%
24   \fi}}
25 \def\@append@newentry@pkglist#1{%
26   \def\@tempb{#1}%
27   \ifx\@tempa\@tempb\@real@append@listfalse\fi}
28 \def\@addtofilelist#1{\@append@newentry\ltjpkglist{#1}}
29 \let\@listfiles\empty
30
31 %<*en>
32 \usepackage[margin=25mm,footskip=6mm]{geometry}
33 \usepackage{luatexja-adjust}\ltjdisableadjust
34 \parskip=\smallskipamount
35 \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
36                                     {3.25ex \@plus1ex \@minus.2ex}%
37                                     {-1em}%
38                                     {\normalfont\normalsize\bfseries\raisebox{.2ex}{$\mdlgblksquare\mkern1mu$}}}
39 %</en>
40 %<*ja>
41 \usepackage[textwidth=45\zw, lines=45, footskip=6mm]{geometry}
42 \usepackage{luatexja-adjust}%\ltjdisableadjust
43 \advance\leftmargini-1\zw\advance\leftmarginii-1\zw
44 %</ja>
45
46 \usepackage{amsmath,array,tikz,pict2e,multienum,float}
47 \usepackage{booktabs,multicol}
48
49 %%%%%%%% listings
50 \usepackage{listings,showexpl}
51 \lstset{
52   basicstyle=\ttfamily\small, pos=r, breaklines=true,
53   numbers=none, rframe={}, basewidth=0.5em, numberstyle=\tiny, numbersep=0.5em,
54   explpreset={numberstyle=\tiny, numbers=left, numbersep=1em}
55 }
56 % Suppress output from showexpl to stdout.
57 \let\SX@Info\relax
58
59 %%%%%%%% hyperref
60 \usepackage{hyperref}
61 %<*en>
62 \title{The \LuaTeX-ja package}
63 \author{The \LuaTeX-ja project team}
64 %</en>
65 %<*ja>
66 \title{\LuaTeX-jaパッケージ}
67 \author{\LuaTeX-jaプロジェクトチーム}
68 %</ja>
69 \hypersetup{%
70         unicode,
71         colorlinks,
72         allbordercolors=1 1 1,
73         allcolors=blue,
74 %<*en>
75         pdfauthor={The LuaTeX-ja project team},
76         pdftitle={The LuaTeX-ja package}
77 %</en>
78 %<*ja>
79         pdfauthor={LuaTeX-jaプロジェクトチーム},
80         pdftitle={LuaTeX-jaパッケージ}
81 %</ja>
82 }
83
84 %%%%%%%% definition env.
85 \usepackage{amsthm}
86 \theoremstyle{definition}
87 %<en>\newtheorem{defn}{Definition}
88 %<ja>\newtheorem{defn}{定義}
89
90 %%%%%%%% fonts
91 \usepackage{luatexja-otf}
92 %<ja>\usepackage{lmodern}
93 \directlua{luatexja.otf.enable_ivs()}
94 \usepackage[kozuka-pr6n]{luatexja-preset}
95 %<*ja>
96 \def\emph#1{\textbf{\textgt{#1}}}
97 \def\headfont{\normalfont\bfseries\gtfamily}
98 \usepackage{amssymb}
99 %</ja>
100 %<*en>
101 \usepackage{unicode-math}
102 \setmainfont[Ligatures=TeX]{TeX Gyre Termes}
103 \setsansfont[Scale=0.95,Ligatures=TeX]{TeX Gyre Heros}
104 \setmathfont{xits-math.otf}
105 \frenchspacing
106 %</en>
107 \DeclareRobustCommand\ttfamily
108         {\not@math@alphabet\ttfamily\mathtt
109          \romanfamily\ttdefault\ttjfam\selectfont}
110 \newjfontfamily\ttjfam{KozGoPr6N-Regular.otf}
111
112
113 %%%%%%%% logo
114 \usepackage{metalogo}
115 \DeclareRobustCommand\eTeX{\ensuremath{\varepsilon}-\kern-.125em\TeX}
116 \DeclareRobustCommand\LuaTeX{Lua\TeX}
117 \DeclareRobustCommand\pdfTeX{pdf\TeX}
118 \DeclareRobustCommand\pTeX{p\kern-.15em\TeX}
119 \DeclareRobustCommand\upTeX{up\kern-.15em\TeX}
120 \DeclareRobustCommand\pLaTeX{p\kern-.05em\LaTeX}
121 \DeclareRobustCommand\pLaTeXe{p\kern-.05em\LaTeXe}
122 \DeclareRobustCommand\epTeX{\ensuremath{\varepsilon}-\kern-.125em\pTeX}
123
124 %%%%%%%% other macros
125 \newenvironment{cslist}{%
126 %<ja>  \leftskip2\zw
127 %<en>  \leftskip2em
128   \parindent=0pt\def\makelabel##1{{\tt\char92##1}}
129   \def\{{\char`\{}\def\}{\char`\}}
130   \let\origitem=\item
131   \def\item[##1]{\par\smallskip\par\hskip-\leftskip\makelabel{##1}\par}
132   \@totalleftmargin\leftskip
133 }{\par%
134 %<en>\medskip
135 }
136
137 \def\labelenumii{(\arabic{enumii})}
138 \long\def\@makecaption#1#2{%
139   \vskip\abovecaptionskip
140   \sbox\@tempboxa{{\small #1. #2}}%
141   \ifdim \wd\@tempboxa >\hsize
142     {\small #1. #2}\par
143   \else
144     \global \@minipagefalse
145     \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
146   \fi
147   \vskip\belowcaptionskip}
148
149 \def\_{\leavevmode \kern .06em\vbox {\hrule \@width .333em}}
150
151 %%%%%%%%
152 \makeatother
153 %%%%%%%%
154
155 \def\Node#1#2{\,\vcenter{\hbox{\fboxsep=1pt\fbox{\vbox{\small\halign{\hfil##\hfil\cr
156   #1\mathstrut\cr\noalign{\hrule height.4pt}\strut#2\cr}}}}\,}}
157
158 \protected\def\Param#1{\textsf{#1}} % parameter name
159 \protected\def\Pkg#1{\underline{\smash{\texttt{#1}}}} % packages/classes
160
161
162 \begin{document}
163 \catcode`\<=13
164 \def<#1>{{\normalfont\rm\itshape$\langle$#1$\rangle$}}
165 \maketitle
166
167 \tableofcontents
168 \bigskip
169
170 %<*en>
171 \textbf{This documentation is far from complete. It may have many
172 grammatical (and contextual) errors.} Also, several parts
173 are written in Japanese only.
174 %</en>
175 %<*ja>
176 \emph{\large 本ドキュメントはまだまだ未完成です.}
177 %</ja>
178
179 \clearpage
180 %<en>\part{User's manual}
181 %<ja>\part{ユーザーズマニュアル}
182
183 %<en>\section{Introduction}
184 %<ja>\section{はじめに}
185
186
187 %<*en>
188 The \LuaTeX-ja package is a macro package for typesetting high-quality
189 Japanese documents when using \LuaTeX.
190 %</en>
191 %<*ja>
192 \LuaTeX-jaパッケージは,次世代標準\TeX である\LuaTeX の上で,\pTeX と同等
193 /それ以上の品質の日本語組版を実現させようとするマクロパッケージである.
194 %</ja>
195 %<en>\subsection{Backgrounds}
196 %<ja>\subsection{背景}
197
198 %<*en>
199 Traditionally, ASCII \pTeX, an extension of \TeX, and its derivatives
200 are used to typeset Japanese documents in \TeX. \pTeX\ is an engine
201 extension of \TeX: so it can produce high-quality Japanese documents
202 without using very complicated macros. But this point is a mixed
203 blessing: \pTeX\ is left behind from other extensions of \TeX,
204 especially \eTeX\ and \pdfTeX, and from changes about
205 Japanese processing in computers (\textit{e.g.}, the UTF-8 encoding).
206 %</en>
207 %<*ja>
208 従来,「\TeX を用いて日本語組版を行う」といったとき,エンジンとしては
209 ASCII \pTeX やそれの拡張物が用いられることが一般的であった.\pTeX は\TeX
210 のエンジン拡張であり,(少々仕様上不便な点はあるものの)商業印刷の分野に
211 も用いられるほどの高品質な日本語組版を可能としている.だが,それは弱点に
212 もなってしまった:\pTeX という(組版的に)満足なものがあったため,海外で
213 行われている数々の\TeX の拡張――例えば\eTeX や\pdfTeX ――や,TrueType,
214 OpenType, Unicodeといった計算機で日本語を扱う際の状況の変化に追従すること
215 を怠ってしまったのだ.
216 %</ja>
217
218 %<*en>
219 Recently extensions of \pTeX, namely \upTeX\ (Unicode-implementation
220 of \pTeX) and \epTeX\ (merging of \pTeX\ and
221 \eTeX\ extension), have developed to fill those gaps to some
222 extent, but gaps still exist.
223 %</en>
224 %<*ja>
225 ここ数年,若干状況は改善されてきた.現在手に入る大半の\pTeX バイナリでは
226 外部UTF-8入力が利用可能となり,さらにUnicode化を推進し,\pTeX の内部処理
227 までUnicode化した\upTeX も開発されている.また,\pTeX に\eTeX 拡張をマー
228 ジした\epTeX も登場し,\TeX\ Live\ 2011では\pLaTeX が\epTeX の上で動作す
229 るようになった.だが,\pdfTeX 拡張(PDF直接出力やmicro-typesetting)を
230 \pTeX に対応させようという動きはなく,海外とのgapは未だにあるのが現状であ
231 る.
232 %</ja>
233
234 %<*en>
235 However, the appearance of \LuaTeX\ changed the whole situation. With
236 using Lua ``callbacks'', users can customize the internal processing of
237 \LuaTeX. So there is no need to modify sources of engines to
238 support Japanese typesetting: to do this, we only have to write Lua
239 scripts for appropriate callbacks.
240 %</en>
241 %<*ja>
242 しかし,\LuaTeX の登場で,状況は大きく変わることになった.Luaコードで
243 ``callback''を書くことにより,\LuaTeX の内部処理に割り込みをかけることが可
244 能となった.これは,エンジン拡張という真似をしなくても,Luaコードとそれに
245 関する\TeX マクロを書けば,エンジン拡張とほぼ同程度のことができるようになっ
246 たということを意味する.\LuaTeX-jaは,このアプローチによってLuaコード・
247 \TeX マクロによって日本語組版を\LuaTeX の上で実現させようという目的で開発
248 が始まったパッケージである.
249 %</ja>
250
251 %<en>\subsection{Major Changes from \pTeX}
252 %<ja>\subsection{\pTeX からの主な変更点}
253 \label{ssec:chgptex}
254
255 %<*en>
256 The \LuaTeX-ja package is under much influence of \pTeX\ engine. The initial
257 target of development was to implement features of \pTeX. However,
258 \emph{\LuaTeX-ja is not a just porting of \pTeX; unnatural
259 specifications/behaviors of \pTeX\ were not adopted}.
260 %</en>
261 %<*ja>
262 \LuaTeX-jaは,\pTeX に多大な影響を受けている.初期の開発目標は,\pTeX の機
263 能をLuaコードにより実装することであった.しかし,開発が進むにつれ,\pTeX
264 の完全な移植は不可能であり,また\pTeX における実装がいささか不可解になっ
265 ているような状況も発見された.そのため,\emph{\LuaTeX-jaは,もはや
266 \pTeX の完全な移植は目標とはしない.\pTeX における不自然な仕様・挙動があ
267 れば,そこは積極的に改める.}
268 %</ja>
269
270 %<*en>
271 The followings are major changes from \pTeX:
272 %</en>
273 %<*ja>
274 以下は \pTeX からの主な変更点である.
275 %</ja>
276
277 \begin{itemize}
278 %<*en>
279 \item A Japanese font is a tuple of a ``real'' font, a Japanese font
280       metric (\emph{JFM}, for short).
281 %</en>
282 %<*ja>
283 \item 和文フォントは(小塚明朝,IPA明朝などの)実際のフォント,和文フォン
284       トメトリック(JFMと呼ぶ\footnote{混乱を防ぐため,p\TeX の意味での
285       JFM (\texttt{min10.tfm}) などは本ドキュメントでは\emph{和文用
286       TFM}とよぶことにする.})の組である.
287 %</ja>
288
289 %<*en>
290 \item In \pTeX, a line break after Japanese character is ignored (and
291       doesn't yield a space), since line breaks (in source files) are
292       permitted almost everywhere in Japanese texts. However, \LuaTeX-ja
293       doesn't have this function completely, because of a specification
294       of \LuaTeX.
295 %</en>
296 %<*ja>
297 \item 日本語の文書中では改行はほとんどどこでも許されるので,\pTeX では和文文字
298       直後の改行は無視される(スペースが入らない)ようになっていた.しかし,
299       \LuaTeX-ja では \LuaTeX の仕様のためにこの機能は完全には実装されていない.
300 %</ja>
301
302 %<*en>
303 \item The insertion process of glues/kerns between two Japanese
304       characters and between a Japanese character and other characters
305       (we refer glues/kerns of both kinds as \textbf{JAglue}) is rewritten from
306       scratch.
307 %</en>
308 %<*ja>
309 \item 2つの和文文字の間や,和文文字と欧文文字の間に入るグルー/カーン
310       (両者をあわせて\textbf{JAglue}と呼ぶ)の挿入処理が0から書き直されている.
311 %</ja>
312
313 \begin{itemize}
314 %<*en>
315 \item As \LuaTeX's internal ligature handling is ``node-based''
316       (\textit{e.g.}, \verb+of{}fice+ doesn't prevent ligatures), the
317       insertion process of \textbf{JAglue} is now ``node-based''.
318 %</en>
319 %<*ja>
320 \item \LuaTeX の内部での合字の扱いは「ノード」を単位として行われるようになっている(例えば,
321       \verb+of{}fice+ で合字は抑制されない).それに合わせ,\textbf{JAglue}の挿入処理も
322       ノード単位で実行される.
323 %</ja>
324
325 %<*en>
326 \item Furthermore, nodes between two characters which have no effects in
327       line break (\textit{e.g.}, \verb+\special+ node) and kerns from
328       italic correction are ignored in the insertion process.
329 %</en>
330 %<*ja>
331 \item さらに,2つの文字の間にある行末では効果を持たないノード(例えば \verb+\special+ ノード)や,
332   イタリック補正に伴い挿入されるカーンは挿入処理中では無視される.
333 %</ja>
334
335 %<*en>
336 \item \emph{Caution: due to above two points, many methods which did for the
337       dividing the process of the insertion of \textbf{JAglue} in \pTeX\ are not
338       effective anymore.} In concrete terms, the following two methods are not effective anymore:
339 %</en>
340 %<*ja>
341 \item \emph{注意:上の2つの変更により,従来\textbf{JAglue}の挿入処理を分断するのに
342       使われていたいくつかの方法は用いることができない.具体的には,次の方法はもはや無効である:}
343 %</ja>
344 \begin{verbatim}
345 ちょ{}っと    ちょ\/っと
346 \end{verbatim}
347 %<*en>
348       If you want to do so, please put an empty hbox between it instead:
349 %</en>
350 %<*ja>
351       もし同じことをやりたければ,空の水平ボックスを間に挟めばよい:
352 %</ja>
353 \begin{verbatim}
354 ちょ\hbox{}っと
355 \end{verbatim}
356
357
358 %<*en>
359 \item In the process, two Japanese fonts which only differ in their ``real''
360       fonts are identified. 
361 %</en>
362 %<*ja>
363 \item 処理中では,2つの和文フォントは,実フォントが異なるだけの場合には同一視
364       される.
365 %</ja>
366 \end{itemize}
367
368 %<*ja>
369 \item \LuaTeX-jaでは,\pTeX と同様に漢字・仮名を制御綴内に用いることができ,
370 \verb+\西暦+ などが正しく動作するようにしている.
371 但し,制御綴中に使える和文文字が\pTeX・\upTeX と全く同じではないことに注意すること.
372 %</ja>
373
374 %<*en>
375 \item At the present, vertical typesetting (\emph{tategaki}), is not
376       supported in \LuaTeX-ja.
377 %</en>
378 %<*ja>
379 \item 現時点では,縦書きは\LuaTeX-jaではサポートされていない.
380 %</ja>
381 \end{itemize}
382
383 %<*en>
384 For detailed information, see Part~\ref{part-imp}.
385 %</en>
386 %<*ja>
387 詳細については第\ref{part-imp}部を参照.
388 %</ja>
389
390 %<en>\subsection{Notations}
391 %<ja>\subsection{用語と記法}
392
393 %<*en>
394 In this document, the following terms and notations are used:
395 %</en>
396 %<*ja>
397 本ドキュメントでは,以下の用語と記法を用いる:
398 %</ja>
399 \begin{itemize}
400 %<*en>
401 \item Characters are classified into following two types.
402       Note that the classification can be customized by a user
403       (see Subsection~\ref{ssec-setrange}).
404 %</en>
405 %<*ja>
406 \item 文字は次の2種類に分けられる.この類別はユーザが後から変更可能である
407       (\ref{ssec-setrange}節を参照).
408 %</ja>
409 \begin{itemize}
410 %<*en>
411 \item \textbf{JAchar}: standing for characters which used in Japanese typesetting,
412       such as Hiragana,~Katakana, Kanji, and~other Japanese punctuation marks.
413 %</en>
414 %<*ja>
415 \item \textbf{JAchar}: ひらがな,カタカナ,漢字,和文用の約物といった
416       日本語組版に使われる文字のことを指す.
417 %</ja>
418
419 %<en>\item \textbf{ALchar}: standing for all other characters like latin alphabets.
420 %<ja>\item \textbf{ALchar}: ラテンアルファベットを始めとする,その他全ての文字を指す.
421 \end{itemize}
422
423 %<*en>
424 We say \emph{alphabetic fonts} for fonts used in \textbf{ALchar}, 
425 and \emph{Japanese fonts} for fonts used in \textbf{JAchar}.
426 %</en>
427 %<*ja>
428 そして,\textbf{ALchar}の出力に用いられるフォントを\emph{欧文フォント}と呼び,
429 \textbf{JAchar}の出力に用いられるフォントを\emph{和文フォント}と呼ぶ.
430 %</ja>
431 %<*en>
432 \item A word in a sans-serif font (like \Param{\hyperlink{fld:prebp}{prebreakpenalty}})
433       means an internal parameter for Japanese typesetting, and it
434       is used as a key in \verb+\ltjsetparameter+ command.
435 %</en>
436 %<*ja>
437 \item サンセリフ体で書かれた語(例:\Param{\hyperlink{fld:prebp}{prebreakpenalty}})は日本語組版用の
438       パラメータを表し,これらは \verb+\ltjsetparameter+ コマンドのキーとして
439       用いられる.
440 %</ja>
441 %<*en>
442 \item A word in typewriter font with underline (like \Pkg{fontspec})
443       means a package or a class of \LaTeX.
444 %</en>
445 %<*ja>
446 \item 下線付きタイプライタ体の語(例:\Pkg{fontspec})は\LaTeX の
447       パッケージやクラスを表す.
448 %</ja>
449 %<*en>
450 \item In this document, natural numbers start from~0.
451 %</en>
452 %<*ja>
453 \item 本ドキュメントでは,自然数は0から始まる.
454 %</ja>
455 \end{itemize}
456
457 %<en>\subsection{About the project}
458 %<ja>\subsection{プロジェクトについて}
459
460 %<en>\paragraph{Project Wiki} Project Wiki is under construction.
461 %<ja>\paragraph{プロジェクトWiki} プロジェクトWikiは構築中である.
462 %<*en>
463 \begin{itemize}
464 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28en%29} (English)
465 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage} (Japanese)
466 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28zh%29} (Chinese)
467 \end{itemize}
468 %</en>
469 %<*ja>
470 \begin{itemize}
471 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage}(日本語)
472 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28en%29}(英語)
473 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28zh%29}(中国語)
474 \end{itemize}
475 %</ja>
476
477 %<en>This project is hosted by SourceForge.JP.
478 %<ja>本プロジェクトはSourceForge.JPのサービスを用いて運営されている.
479
480 %<en>\paragraph{Members}\
481 %<ja>\paragraph{開発メンバー}\
482
483 %<*en>
484 \begin{multienumerate}
485 \def\labelenumi{$\bullet$}
486 \mitemxxx{Hironori KITAGAWA}{Kazuki MAEDA}{Takayuki YATO}
487 \mitemxxx{Yusuke KUROKI}{Noriyuki ABE}{Munehiro YAMAMOTO}
488 \mitemxxx{Tomoaki HONDA}{Shuzaburo SAITO}{MA Qiyuan}
489 \end{multienumerate}
490 %</en>
491 %<*ja>
492 \begin{multienumerate}
493 \def\labelenumi{$\bullet$}
494 \mitemxxx{北川 弘典}{前田 一貴}{八登 崇之}
495 \mitemxxx{黒木 裕介}{阿部 紀行}{山本 宗宏}
496 \mitemxxx{本田 知亮}{齋藤 修三郎}{馬 起園}
497 \end{multienumerate}
498 %</ja>
499
500 % \paragraph{Acknowledgments} -- 挿入するならここ
501
502 \clearpage
503 %<en>\section{Getting Started}
504 %<ja>\section{使い方}
505 %<en>\subsection{Installation}
506 %<ja>\subsection{インストール}
507
508 %<en>To install the \LuaTeX-ja\ package, you will need:
509 %<ja>\LuaTeX-jaパッケージのインストールには,次のものが必要である.
510 \begin{itemize}
511 \item \LuaTeX\ beta-0.74.0 (or later)
512 \item \Pkg{luaotfload} v2.2 (or later)
513 \item \Pkg{luatexbase} v0.6
514 \item \Pkg{xunicode} v0.981~(2011/09/09)
515 \item \Pkg{adobemapping} (Adobe cmap and pdfmapping files)
516 \end{itemize}
517
518 %<*en>
519 \emph{From this version of \LuaTeX-ja, \TeX~Live~2012 (or older version) is
520 no longer supported, since \LuaTeX\ binary and \Pkg{luaotfload} is updated in
521 \TeX~Live~2013.} 
522 And conversely, older versions of \LuaTeX-ja (20130318.1 or earlier) don't work in
523 \TeX~Live~2013.
524
525 \medskip
526
527 Now \LuaTeX-ja is available from the following archive and distributions:
528   \begin{itemize}
529   \item CTAN (in the \texttt{macros/luatex/generic/luatexja} directory)
530   \item MiK\TeX\ (in \texttt{luatexja.tar.lzma})
531   \item \TeX\ Live (in \texttt{texmf-dist/tex/luatex/luatexja})
532   \item W32\TeX\ (in \texttt{luatexja.tar.xz})
533   \end{itemize}
534
535 If you are using \TeX~Live~2013, you can install \LuaTeX-ja 
536 from \TeX~Live manager (\texttt{tlmgr}):
537 \begin{verbatim}
538 $ tlmgr install luatexja
539 \end{verbatim}
540 %</en>
541 %<*ja>
542 \emph{本バージョン以降の\LuaTeX-jaは\TeX~Live~2012以前では動作しない.}
543 これは,\LuaTeX と\Pkg{luaotfload}が\TeX~Live~2013において更新されたことによる.
544 逆に,20130318.1以前の\LuaTeX-jaは\TeX~Live~2013では動作しない.
545
546 \medskip
547
548 現在,\LuaTeX-jaは以下のアーカイブ,およびディストリビューションに収録されている:
549   \begin{itemize}
550   \item CTAN (\texttt{macros/luatex/generic/luatexja})
551   \item MiK\TeX\ (\texttt{luatexja.tar.lzma})
552   \item \TeX\ Live (\texttt{texmf-dist/tex/luatex/luatexja})
553   \item W32\TeX\ (\texttt{luatexja.tar.xz})
554   \end{itemize}
555
556 例えば\TeX~Live~2013を利用しているなら,\LuaTeX-jaは\TeX~Live manager (\texttt{tlmgr})を
557 使ってインストールすることができる.
558 \begin{verbatim}
559 $ tlmgr install luatexja
560 \end{verbatim}
561 %</ja>
562
563 %<en>\paragraph{Manual installation}
564 %<ja>\paragraph{手動インストール方法}
565
566 \begin{enumerate}
567 %<*en>
568 \item Download the source archive, by one of the following method.
569       At the present, \LuaTeX-ja has no \emph{stable} release.
570
571 \begin{itemize}
572 \item Copy the Git repository:
573 \begin{verbatim}
574 $ git clone git://git.sourceforge.jp/gitroot/luatex-ja/luatexja.git
575 \end{verbatim}
576 \item Download the \texttt{tar.gz} archive of HEAD in the \texttt{master} branch from
577 \begin{flushleft}
578 \url{http://git.sourceforge.jp/view?p=luatex-ja/luatexja.git;a=snapshot;h=HEAD;sf=tgz}.
579 \end{flushleft}
580 \end{itemize} 
581
582 Note that the \texttt{master} branch, and hence the archive in CTAN, are not updated frequently;
583 the forefront of development is not the \texttt{master} branch.
584 %</en>
585 %<*ja>
586 \item ソースアーカイブを以下のいずれかの方法で取得する.現在公開されているのはあくまでも
587       開発版であって,安定版でないことに注意.
588
589 \begin{itemize}
590 \item Gitリポジトリの内容をコピーする:
591 \begin{verbatim}
592 $ git clone git://git.sourceforge.jp/gitroot/luatex-ja/luatexja.git
593 \end{verbatim}
594 \item \texttt{master}ブランチのスナップショット(\texttt{tar.gz}形式)をダウンロードする.
595 \begin{flushleft}
596 \url{http://git.sourceforge.jp/view?p=luatex-ja/luatexja.git;a=snapshot;h=HEAD;sf=tgz}.
597 \end{flushleft}
598 \end{itemize}
599 \texttt{master}ブランチ(従って,CTAN内のアーカイブも)はたまにしか更新されないことに注意.
600 主な開発は\texttt{master}の外で行われ,比較的まとまってきたらそれを\texttt{master}に
601 反映させることにしている.
602 %</ja>
603
604 %<*en>
605 \item Extract the archive. You will see \texttt{src/} and several other sub-directories.
606 But only the contents in \texttt{src/} are needed to work \LuaTeX-ja.
607 %</en>
608 %<*ja>
609 \item 「Gitリポジトリをコピー」以外の方法でアーカイブを取得したならば,それを展開する.
610       \texttt{src/}をはじめとしたいくつかのディレクトリができるが,
611       動作には\texttt{src/}以下の内容だけで十分.
612 %</ja>
613
614 %<*en>
615 \item If you downloaded this package from CTAN, you have to run following commands
616     to generate classes 
617     and \texttt{ltj-kinsoku.lua} (the file which stores default ``\textit{kinsoku}'' parameters):
618 %</en>
619 %<*ja>
620 \item もしCTANから本パッケージを取得したのであれば,日本語用クラスファイルや
621 標準の禁則処理用パラメータを
622 格納した \texttt{ltj-kinsoku.lua} を生成するために,
623 以下を実行する必要がある:
624 %</ja>
625 \begin{verbatim}
626 $ cd src
627 $ lualatex ltjclasses.ins
628 $ lualatex ltjsclasses.ins
629 $ lualatex ltjltxdoc.ins
630 $ luatex   ltj-kinsoku_make.tex
631 \end{verbatim}
632 %<*en>
633 Note that \texttt{*.\{dtx,ins\}} and \texttt{ltj-kinsoku\_make.tex} are not needed in regular use.
634 %</en>
635 %<*ja>
636 ここで使用した \texttt{*.\{dtx,ins\}} と \texttt{ltj-kinsoku\_make.tex} は
637 通常の使用にあたっては必要ない.
638 %</ja>
639
640
641
642 %<*en>
643 \item Copy all the contents of \texttt{src/} into one of your \texttt{TEXMF} tree.
644       \texttt{TEXMF/tex/luatex/luatexja/} is an example location.
645       If you cloned entire Git repository, making a symbolic link of \texttt{src/}
646       instead copying is also good.
647 %</en>
648 %<*ja>
649 \item \texttt{src}の中身を自分の\texttt{TEXMF}ツリーにコピーする.
650       場所の例としては,例えば\texttt{TEXMF/tex/luatex/luatexja/}がある.
651       シンボリックリンクが利用できる環境で,かつリポジトリを直接取得したのであれば,
652       (更新を容易にするために)コピーではなくリンクを貼ることを勧める.
653 %</ja>
654 %<*en>
655 \item If \texttt{mktexlsr} is needed to update the file name database, make it so.
656 %</en>
657 %<*ja>
658 \item 必要があれば,\texttt{mktexlsr}を実行する.
659 %</ja>
660 \end{enumerate}
661
662 %<*en>
663 \paragraph{Note for MiK\TeX\ Users}
664 \LuaTeX-ja requires that two CMap files, 
665 \texttt{UniJIS2004-UTF32-H} and \texttt{Adobe-Japan1-UCS2},
666 must be found from \LuaTeX.
667 Strictly speaking, those CMaps are needed 
668 only in the first run of \LuaTeX-ja after installing or updating.
669
670 But it seems that MiK\TeX\ does not satisfy this condition, 
671 so you will encounter an error like the following:
672 %</en>
673 %<*ja>
674 \LuaTeX-jaが動作するためには,\emph{導入・更新後の初回起動時に}
675 \texttt{UniJIS2004-UTF32-H}, \texttt{Adobe-Japan1-UCS2}という2つのCMapが
676 \LuaTeX によって見つけられることが必要である.
677 しかしMiK\TeX ではそのようになっていないので,次のエラーが発生するだろう:
678 %</ja>
679 \begin{verbatim}
680 ! LuaTeX error ...iles (x86)/MiKTeX 2.9/tex/luatex/luatexja/ltj-rmlgbm.lua
681 bad argument #1 to 'open' (string expected, got nil)
682 \end{verbatim}
683
684 %<*en>
685 If so, please execute a batch file which is written on
686 \href{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28en%29}{ the Project Wiki (English)}.
687 This batch file creates a temporaly directory, copy CMaps in it, 
688 run \LuaTeX-ja in this directory, and finally delete the temporaly directory.
689 %</en>
690 %<*ja>
691 そのような場合には,
692 \href{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28en%29}{%
693   プロジェクトWiki英語版トップページ}中に書かれているバッチファイルを
694 実行して欲しい.このバッチファイルは,作業用ディレクトリにCMap達を
695 コピーし,その中で\LuaTeX-ja の初回起動を行い,作業用ディレクトリを消す作業をしている.
696 %</ja>
697
698 %<en>\subsection{Cautions}
699 %<ja>\subsection{注意点}
700
701 \begin{itemize}
702 %<*en>
703 \item The encoding of your source file must be UTF-8. No other
704       encodings, such as EUC-JP or Shift-JIS, are not supported.
705 %</en>
706 %<*ja>
707 \item 原稿のソースファイルの文字コードはUTF-8固定である.
708       従来日本語の文字コードとして用いられてきたEUC-JPやShift-JISは使用できない.
709 %</ja>
710 %<*en>
711 \item \LuaTeX-ja is very slower than \pTeX. 
712 Using LuaJIT\TeX\ usually improve the situation, but not always.
713 %</en>
714 %<*ja>
715 \item \LuaTeX-jaは動作が\pTeX に比べて非常に遅い.
716 コードを調整して徐々に速くしているが,まだ満足できる速度ではない.
717 LuaJIT\TeX を用いると\LuaTeX のだいたい1.3倍の速度で動くようであるが,
718 IPA mj明朝などの大きいフォントを用いた場合には\LuaTeX よりも遅くなることもある.
719 %</ja>
720 \end{itemize}
721
722 %<en>\subsection{Using in plain \TeX}
723 %<ja>\subsection{plain \TeX で使う}
724 \label{ssec-plain}
725
726 %<en>To use \LuaTeX-ja in plain \TeX, simply put the following at the beginning of the document:
727 %<ja>\LuaTeX-jaを plain \TeX で使うためには,単に次の行をソースファイルの冒頭に追加すればよい:
728 \begin{verbatim}
729 \input luatexja.sty
730 \end{verbatim}
731 %<en>This does minimal settings (like \texttt{ptex.tex}) for typesetting Japanese documents:
732 %<ja>これで(\texttt{ptex.tex}のように)日本語組版のための最低限の設定がなされる:
733
734 \begin{itemize}
735 %<*en>
736 \item The following 6~Japanese fonts are preloaded:
737 \begin{center}\small
738 \begin{tabular}{ccccc}
739 \toprule
740 \textbf{classification}&\textbf{font name}&\bf `10\,pt'&\bf`7\,pt'&\bf`5\,pt'\\\midrule
741 \emph{mincho}&Ryumin-Light    &\verb+\tenmin+&\verb+\sevenmin+&\verb+\fivemin+\\
742 \emph{gothic}&GothicBBB-Medium&\verb+\tengt+ &\verb+\sevengt+ &\verb+\fivegt+\\
743 \bottomrule
744 \end{tabular}
745 \end{center}
746 %</en>
747 %<*ja>
748 \item 以下の6つの和文フォントが定義される:
749 \begin{center}\small
750 \begin{tabular}{ccccc}
751 \toprule
752 \emph{字体}&\emph{フォント名}&\bf `10\,pt'&\bf`7\,pt'&\bf`5\,pt'\\\midrule
753 明朝体&Ryumin-Light    &\verb+\tenmin+&\verb+\sevenmin+&\verb+\fivemin+\\
754 ゴシック体&GothicBBB-Medium&\verb+\tengt+ &\verb+\sevengt+ &\verb+\fivegt+\\
755 \bottomrule
756 \end{tabular}
757 \end{center}
758 %</ja>
759 \begin{itemize}
760 %<*en>
761 \item It is widely accepted that fonts ``Ryumin-Light'' and
762       ``GothicBBB-Medium'' aren't embedded into PDF files, and a PDF reader
763       substitute them by some external Japanese fonts (\textit{e.g.},
764       Ryumin-Light is substituted with Kozuka Mincho in Adobe Reader). 
765       We adopt this custom to the default setting.
766 %</en>
767 %<*ja>
768 \item ``Ryumin-Light''と``GothicBBB-Medium''はPDFファイルに埋め込まずに
769       名前参照のみで用いることが広く受け入れられており,この場合PDFリーダーが
770       適切な外部フォントで代用する(例えば,Adobe ReaderではRyumin-Lightは
771       小塚明朝で代替される).そこで,これらを引き続きデフォルトのフォントと
772       して採用する.
773 %</ja>
774
775 %<*en>
776 \item A character in an alphabetic font is generally smaller than a
777       Japanese font in the same size. So actual size specification of
778       these Japanese fonts is in fact smaller than that of alphabetic
779       fonts, namely scaled by 0.962216.
780 %</en>
781 %<*ja>
782 \item 欧文フォントの文字は和文フォントの文字よりも,同じ文字サイズでも
783       一般に小さくデザインされている.そこで,標準ではこれらの和文フォントの実際のサイズは指定された値よりも
784       小さくなるように設定されており,具体的には指定の0.962216倍にスケールされる.
785       この0.962216という数値も,\pTeX におけるスケーリングを踏襲した値である.
786 %</ja>
787 \end{itemize}
788
789 %<*en>
790 \item The amount of glue that are inserted between a \textbf{JAchar} and
791       an \textbf{ALchar} (the parameter \Param{\hyperlink{fld:xks}{xkanjiskip}}) is set to
792 %</en>
793 %<*ja>
794 \item \textbf{JAchar}と\textbf{ALchar}の間に入るグルー(\Param{\hyperlink{fld:xks}{xkanjiskip}})の
795       量は次のように設定されている:
796 %</ja>
797 \[
798  (0.25\cdot 0.962216\cdot 10\,\mathrm{pt})^{+1\,\text{pt}}_{-1\,\text{pt}}
799  = 2.40554\,\mathrm{pt}^{+1\,\text{pt}}_{-1\,\text{pt}}.
800 \]
801 \end{itemize}
802
803 %<en>\subsection{Using in \LaTeX}
804 %<ja>\subsection{\LaTeX で使う}
805 \label{ssec-ltx}
806
807 \paragraph{\LaTeXe}
808
809 %<*en>
810 Using in \LaTeXe\ is basically same. To set up the minimal environment
811 for Japanese, you only have to load \texttt{luatexja.sty}:
812 %</en>
813 %<*ja>
814 \LaTeXe を用いる場合も基本的には同じである.日本語組版のための最低限の環境を
815 設定するためには,\texttt{luatexja.sty}を読み込むだけでよい:
816 %</ja>
817 \begin{verbatim}
818 \usepackage{luatexja}
819 \end{verbatim}
820 %<*en>
821 It also does minimal settings (counterparts in \pLaTeX\ are \texttt{%
822 plfonts.dtx} and \texttt{pldefs.ltx}):
823 %</en>
824 %<*ja>
825 これで\pLaTeX の\texttt{plfonts.dtx}と\texttt{pldefs.ltx}に相当する最低限の設定が
826 なされる:
827 %</ja>
828
829 \begin{itemize}
830 %<*en>
831 \item \texttt{JY3} is the font encoding for Japanese fonts (in horizontal direction).\\
832 When vertical typesetting is supported by \LuaTeX-ja in the future, \texttt{JT3} will be used for vertical fonts.
833 %</en>
834 %<*ja>
835 \item \texttt{JY3}は和文フォント用のフォントエンコーディングである(横書き用).\\
836 将来的に,\LuaTeX-jaで縦書きがサポートされる際には,\texttt{JT3}を縦書き用として
837 用いる予定である.
838 %</ja>
839
840 %<*en>
841 \item Traditionally, Japanese documents use two typeface category: \emph{mincho}~(明朝体) and
842  \emph{gothic}~(\textgt{ゴシック体}). \emph{mincho} is used in the main text, while \emph{gothic}
843       is used in the headings or for emphasis.
844 \begin{center}\small
845 \begin{tabular}{lllc}
846 \toprule
847 \textbf{classification}&&&\textbf{family name}\\\midrule
848 \emph{mincho} (明朝体)&\verb+\textmc{...}+&\verb+{\mcfamily ...}+&\verb+\mcdefault+\\
849 \emph{gothic} (\textgt{ゴシック体})&\verb+\textgt{...}+&\verb+{\gtfamily ...}+&\verb+\gtdefault+\\
850 \bottomrule
851 \end{tabular}
852 \end{center}
853 \item 
854 By default, the following fonts are used for \emph{mincho} and \emph{gothic}:
855 \begin{center}\small
856 \begin{tabular}{ccccc}
857 \toprule
858 \textbf{classification}&\textbf{family name}&\verb+\mdseries+&\verb+\bfseries+&\textbf{scale}\\\midrule
859 \emph{mincho} (明朝体)&\tt mc&Ryumin-Light    &GothicBBB-Medium&0.962216\\
860 \emph{gothic} (\textgt{ゴシック体})&\tt gt&GothicBBB-Medium&GothicBBB-Medium&0.962216\\
861 \bottomrule
862 \end{tabular}
863 \end{center}
864 Note that the bold series in both family are same as the medium series of \emph{gothic} family.
865 This is a convention in \pLaTeX. This is trace that there were only 2~fonts (these are Ryumin-Light
866 and GothicBBB-Medium) in early years of DTP. There is no italic nor slanted shape for
867       these \texttt{mc}~and~\texttt{gt}.
868 %</en>
869 %<*ja>
870 \item \pLaTeX と同様に,標準では「明朝体」「ゴシック体」の2種類を用いる:
871 \begin{center}\small
872 \begin{tabular}{cllc}
873 \toprule
874 \emph{字体}&&&\emph{ファミリ名}\\\midrule
875 明朝体&\verb+\textmc{...}+&\verb+{\mcfamily ...}+&\verb+\mcdefault+\\
876 \textgt{ゴシック体}&\verb+\textgt{...}+&\verb+{\gtfamily ...}+&\verb+\gtdefault+\\
877 \bottomrule
878 \end{tabular}
879 \end{center}
880 \item 標準では,次のフォントファミリが用いられる:
881 \begin{center}\small
882 \begin{tabular}{ccccc}
883 \toprule
884 \emph{字体}&\emph{ファミリ}&\verb+\mdseries+&\verb+\bfseries+&\emph{スケール}\\\midrule
885 明朝体&\tt mc&Ryumin-Light    &GothicBBB-Medium&0.962216\\
886 ゴシック体&\tt gt&GothicBBB-Medium&GothicBBB-Medium&0.962216\\
887 \bottomrule
888 \end{tabular}
889 \end{center}
890 どちらのファミリにおいても,そのboldシリーズで使われるフォントは
891 ゴシック体のmediumシリーズで使われるフォントと同じあることに注意.
892 これは初期のDTPにおいて和文フォントが2つ(それがちょうど\
893 Ryumin-Light, GothicBBB-Mediumだった)しか利用できなかった時の名残であり,\pLaTeX{}
894 での標準設定とも同じである.
895 %</ja>
896
897
898 %<en>\item Japanese characters in math mode are typeset by the font family \texttt{mc}.
899 %<ja>\item 数式モード中の和文文字は明朝体(\texttt{mc})で出力される.
900 \end{itemize}
901
902 %<*en>
903 However, above settings are not sufficient for Japanese-based
904 documents. To typeset Japanese-based documents, you are better to use
905 class files other than \texttt{article.cls}, \texttt{book.cls}, and so on.  At
906 the present, we have the counterparts of \Pkg{jclasses} (standard
907 classes in \pLaTeX) and \Pkg{jsclasses} (classes by Haruhiko
908 Okumura), namely, \Pkg{ltjclasses} and \Pkg{ltjsclasses}.
909 %</en>
910 %<*ja>
911 しかしながら,上記の設定は日本語の文書にとって十分とは言えない.
912 日本語文書を組版するためには,\texttt{article.cls}, \texttt{book.cls}といった
913 欧文用のクラスファイルではなく,和文用のクラスファイルを用いた方がよい.
914 現時点では,\Pkg{jclasses}(\pLaTeX の標準クラス)と\Pkg{jsclasses}
915 (奥村晴彦氏によるクラスファイル)に対応するものとして,\Pkg{ltjclasses},
916 \Pkg{ltjsclasses}がそれぞれ用意されている.
917 %</ja>
918
919 %<en>\section{Changing Fonts}
920 %<ja>\section{フォントの変更}
921
922 \subsection{plain \TeX~and~\LaTeXe}
923 \label{ssub-chgfnt}
924
925 \paragraph{plain \TeX}
926 %<*en>
927 To change Japanese fonts in plain \TeX, you must use the control sequence
928 \verb+\jfont+. So please see Subsection~\ref{ssec-jfont}.
929 %</en>
930 %<*ja>
931 plain \TeX で和文フォントを変更するためには,\pTeX のように \verb+\jfont+ 命令を直接用いる.
932 \ref{ssec-jfont}節を参照.
933 %</ja>
934
935 \paragraph{\LaTeXe\ (NFSS2)}
936 %<*en>
937 For \LaTeXe, \LuaTeX-ja adopted most of the font selection system of \pLaTeXe\ (in \texttt{plfonts.dtx}).
938 %</en>
939 %<*ja>
940 \LaTeXe については,\LuaTeX-jaではフォント選択システムを\pLaTeXe\ (\texttt{plfonts.dtx})
941 の大部分をそのまま採用している.
942 %</ja>
943 \begin{itemize}
944 %<*en>
945 \item Commands \verb+\fontfamily+, \verb+\fontseries+,
946       \verb+\fontshape+, and \verb+\selectfont+ can be used to change
947       attributes of Japanese fonts.
948 %</en>
949 %<*ja>
950 \item \verb+\fontfamily+, \verb+\fontseries+, \verb+\fontshape+, そして
951       \verb+\selectfont+ が和文フォントの属性を変更するために使用できる.
952 %</ja>
953
954 %<*en>
955 \begin{center}\small
956 \begin{tabular}{cccccc}
957 \toprule
958 &\textbf{encoding}&\textbf{family}&\textbf{series}&\textbf{shape}&\textbf{selection}\\\midrule
959 alphabetic fonts
960 &\verb+\romanencoding+&\verb+\romanfamily+&\verb+\romanseries+&\verb+\romanshape+
961 &\verb+\useroman+\\
962 Japanese fonts
963 &\verb+\kanjiencoding+&\verb+\kanjifamily+&\verb+\kanjiseries+&\verb+\kanjishape+
964 &\verb+\usekanji+\\
965 both&---&--&\verb+\fontseries+&\verb+\fontshape+&---\\
966 auto select&\verb+\fontencoding+&\verb+\fontfamily+&---&---&\verb+\usefont+\\
967 \bottomrule
968 \end{tabular}
969 \end{center}
970 %</en>
971 %<*ja>
972 \begin{center}\small
973 \begin{tabular}{cccccc}
974 \toprule
975 &\emph{エンコーディング}&\emph{ファミリ}&\emph{シリーズ}&\emph{シェープ}&\emph{選択}\\\midrule
976 欧文
977 &\verb+\romanencoding+&\verb+\romanfamily+&\verb+\romanseries+&\verb+\romanshape+
978 &\verb+\useroman+\\
979 和文
980 &\verb+\kanjiencoding+&\verb+\kanjifamily+&\verb+\kanjiseries+&\verb+\kanjishape+
981 &\verb+\usekanji+\\
982 両方&---&--&\verb+\fontseries+&\verb+\fontshape+&---\\
983 自動選択&\verb+\fontencoding+&\verb+\fontfamily+&---&---&\verb+\usefont+\\
984 \bottomrule
985 \end{tabular}
986 \end{center}
987 %</ja>
988
989 %<*en>
990       \verb+\fontencoding{<encoding>}+ changes the encoding of alphabetic fonts
991       or Japanese fonts depending on the argument. For example,
992       \verb+\fontencoding{JY3}+ changes the encoding of Japanese fonts to
993       \texttt{JY3}a nd \verb+\fontencoding{T1}+ changes the encoding of
994       alphabetic fonts to \texttt{T1}.
995       \verb+\fontfamily+ also changes the family of Japanese fonts, alphabetic
996       fonts, \emph{or both}. For detail, see Subsection~\ref{ssub-nfsspat}.
997 %</en>
998 %<*ja>
999       ここで,\verb+\fontencoding{<encoding>}+ は,引数により和文側か欧文
1000       側かのどちらかのエンコーディングを変更する.例えば,
1001       \verb+\fontencoding{JY3}+ は和文フォントのエンコーディングを
1002       \texttt{JY3}に変更し,\verb+\fontencoding{T1}+ は欧文フォント側を
1003       \texttt{T1}へと変更する.\verb+\fontfamily+ も引数により和文側,欧文
1004       側,\emph{あるいは両方}のフォントファミリを変更する.詳細は
1005       \ref{ssub-nfsspat}節を参照すること.
1006 %</ja>
1007
1008 %<*en>
1009 \item For defining a Japanese font family, use
1010       \verb+\DeclareKanjiFamily+ instead of
1011       \verb+\DeclareFontFamily+. However, in the present implementation,
1012       using \verb+\DeclareFontFamily+ doesn't cause any problem.
1013 \item Defining a Japanese font shape can be done by usual \verb+\DeclareFontShape+:
1014 %</en>
1015 %<*ja>
1016 \item 和文フォントファミリの定義には \verb+\DeclareFontFamily+ の
1017       代わりに \verb+\DeclareKanjiFamily+ を用いる.しかし,現在の
1018       実装では \verb+\DeclareFontFamily+ を用いても問題は生じない.
1019 \item 和文フォントのシェイプを定義するには,通常の \verb+\DeclareFontShape+ を使えば良い:
1020 %</ja>
1021 \begin{verbatim}
1022 \DeclareFontShape{JY3}{mc}{bx}{n}{<-> s*KozMinPr6N-Bold:jfm=ujis}{}
1023     % Kozuka Mincho Pr6N Bold
1024 \end{verbatim}
1025 %<*ja>
1026 仮名書体を使う場合など,複数の和文フォントを組み合わせて使いたい場合は
1027 \ref{ssec-altfont}節の \verb+\ltjdeclarealtfont+ と,その\LaTeX 版の\ 
1028 \verb+\DeclareAlternateKanjiFont+(\ref{ssub-nfsspat}節)を参照せよ.
1029 %</ja>
1030 \end{itemize}
1031
1032 %<*en>
1033 \paragraph{Remark: Japanese Characters in Math Mode}
1034 Since \pTeX\ supports Japanese characters in math mode, there are
1035 sources like the following:
1036 %</en>
1037 %<*ja>
1038 \paragraph{注意:数式モード中の和文文字}
1039 \pTeX では,特に何もしないでも数式中に和文文字を記述することができた.そのため,
1040 以下のようなソースが見られた:
1041 %</ja>
1042
1043 \begin{LTXexample}
1044 $f_{高温}$~($f_{\text{high temperature}}$).
1045 \[ y=(x-1)^2+2\quad よって\quad y>0 \]
1046 $5\in 素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
1047 \end{LTXexample}
1048 %<*en>
1049 We (the project members of \LuaTeX-ja) think that using
1050 Japanese characters in math mode are allowed if and only if these are used as identifiers.
1051 In this point of view,
1052 %</en>
1053 %<*ja>
1054 \LuaTeX-jaプロジェクトでは,数式モード中での和文文字はそれらが識別子として用いられる
1055 ときのみ許されると考えている.
1056 この観点から,
1057 %</ja>
1058
1059 \begin{itemize}
1060 %<*en>
1061 \item The lines 1~and~2 above are not correct, since ``高温'' in above is used as a textual label, and
1062 ``よって'' is used as a conjunction.
1063 %</en>
1064 %<*ja>
1065 \item 上記数式のうち1, 2行目は正しくない.なぜならば「高温」が意味のあるラベルと
1066       して,「よって」が接続詞として用いられているからである.
1067 %</ja>
1068 %<en>\item However, the line~3 is correct, since ``素'' is used as an identifier.
1069 %<ja>\item しかしながら,3行目は「素」が単なる識別子として用いられているので正しい.
1070 \end{itemize}
1071 %<en>Hence, in our opinion, the above input should be corrected as:
1072 %<ja>したがって,\LuaTeX-jaプロジェクトの意見としては,上記の入力は次のように直されるべきである:
1073 \begin{LTXexample}
1074 $f_{\text{高温}}$~%
1075 ($f_{\text{high temperature}}$).
1076 \[ y=(x-1)^2+2\quad
1077   \mathrel{\text{よって}}\quad y>0 \]
1078 $5\in 素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
1079 \end{LTXexample}
1080 %<*en>
1081 We also believe that using Japanese characters as identifiers is rare,
1082 hence we don't describe how to change Japanese fonts in math mode in
1083 this chapter. For the method, please see Subsection~\ref{ssec-math}.
1084 %</en>
1085 %<*ja>
1086 また\LuaTeX-jaプロジェクトでは,和文文字が識別子として用いられることはほとんどない
1087 と考えており,したがってこの節では数式モード中の和文フォントを変更する方法については
1088 記述しない.この方法については\ref{ssec-math}節を参照のこと.
1089 %</ja>
1090
1091
1092 \subsection{fontspec}
1093 \label{ssec-fontspec}
1094 %<*en>
1095 To coexist with the \Pkg{fontspec} package, it is needed to load
1096 \Pkg{luatexja-fontspec} package in the preamble. This additional
1097 package automatically loads \Pkg{luatexja} and \Pkg{fontspec}
1098 package, if needed.
1099 %</en>
1100 %<*ja>
1101 \Pkg{fontspec}パッケージと同様の機能を和文フォントに対しても用いるためには,
1102 \Pkg{luatexja-fontspec}パッケージをプリアンブルで読み込む必要がある.このパッケージ
1103 は必要ならば自動で\Pkg{luatexja}パッケージと\Pkg{fontspec}パッケージを読み込む.
1104 %</ja>
1105
1106 %<*en>
1107 In \Pkg{luatexja-fontspec} package, the following 7~commands are defined as
1108 counterparts of original commands in the \Pkg{fontspec} package:
1109 %</en>
1110 %<*ja>
1111 \Pkg{luatexja-fontspec}パッケージでは,以下の7つのコマンドを\Pkg{fontspec}
1112 パッケージの元のコマンドに対応するものとして定義している:
1113 %</ja>
1114
1115 %<*en>
1116 \begin{center}\small
1117 \begin{tabular}{ccccc}
1118 \toprule
1119 Japanese fonts
1120 &\verb+\jfontspec+&\verb+\setmainjfont+&\verb+\setsansjfont+&\verb+\newjfontfamily+\\
1121 alphabetic fonts
1122 &\verb+\fontspec+&\verb+\setmainfont+&\verb+\setsansfont+&\verb+\newfontfamily+\\
1123 \midrule
1124 Japanese fonts
1125 &\verb+\newjfontface+&\verb+\defaultjfontfeatures+&\verb+\addjfontfeatures+\\
1126 alphabetic fonts
1127 &\verb+\newfontface+&\verb+\defaultfontfeatures+&\verb+\addfontfeatures+\\
1128 \bottomrule
1129 \end{tabular}
1130 \end{center}
1131 %</en>
1132 %<*ja>
1133 \begin{center}\small
1134 \begin{tabular}{cccc}
1135 \toprule
1136 和文
1137 &\verb+\jfontspec+&\verb+\setmainjfont+&\verb+\setsansjfont+\\
1138 欧文
1139 &\verb+\fontspec+&\verb+\setmainfont+&\verb+\setsansfont+\\
1140 \midrule
1141 和文
1142 &\verb+\newjfontfamily+&\verb+\newjfontface+&\verb+\defaultjfontfeatures+\\
1143 欧文
1144 &\verb+\newfontfamily+&\verb+\newfontface+&\verb+\defaultfontfeatures+\\
1145 \midrule
1146 和文
1147 &\verb+\addjfontfeatures+\\
1148 欧文
1149 &\verb+\addfontfeatures+\\
1150 \bottomrule
1151 \end{tabular}
1152 \end{center}
1153 %</ja>
1154 \begin{LTXexample}[width=0.4\textwidth]
1155 \fontspec[Numbers=OldStyle]{LMSans10-Regular}
1156 \jfontspec[CJKShape=NLC]{KozMinPr6N-Regular}
1157 JIS~X~0213:2004→辻
1158
1159 \jfontspec[CJKShape=JIS1990]{KozMinPr6N-Regular}
1160 JIS~X~0208:1990→辻
1161 \end{LTXexample}
1162
1163 %<*en>
1164 Note that there is no command named \verb+\setmonojfont+, since it is
1165 popular for Japanese fonts that nearly all Japanese glyphs have same
1166 widths.  Also note that the kerning feature is set off by default in
1167 these 7~commands, since this feature and \textbf{JAglue} will clash (see
1168 \ref{para-kern}).
1169 %</en>
1170 %<*ja>
1171 和文フォントについては全ての和文文字のグリフがほぼ等幅であるのが普通であるため,
1172 \verb+\setmonojfont+ コマンドは存在しないことに注意.また,これらの和文用の7つのコマ
1173 ンドではKerning featureはデフォルトではoffとなっている.これはこの
1174 featureが\textbf{JAglue}と衝突するためである(\ref{para-kern}節を参照).
1175 %</ja>
1176
1177 %<en>\subsection{Presets}
1178 %<ja>\subsection{プリセット設定}
1179 \label{ssec-preset}
1180
1181 %<*en>
1182 To use standard Japanese font settings easily, one can load \Pkg{luatexja-preset}
1183 package with several options. This package provides functions in a part of
1184 \Pkg{otf} package and a part of \Pkg{PXchfon} package by Takayuki Yato,
1185 and loads \Pkg{luatexja-fontspec}, hence \Pkg{fontspec} internally.
1186
1187 If you need to pass some options to \Pkg{fontspec}, load \Pkg{fontspec} manually
1188 before \Pkg{luatexja-preset}:
1189 %</en>
1190 %<*ja>
1191 よく使われている和文フォント設定を一行で指定できるようにしたのが
1192 \Pkg{luatexja-preset}パッケージである.このパッケージは,
1193 \Pkg{otf}パッケージの一部機能と八登崇之氏による\Pkg{PXchfon}パッケージの一部機能とを
1194 合わせたような格好をしており,内部で\Pkg{luatexja-fontspec},従って
1195 \Pkg{fontspec}を読み込んでいる.
1196
1197 もし\Pkg{fontspec}パッケージに何らかのオプションを渡す必要がある
1198 \footnote{例えば,数式フォントまで置換されてしまい,\texttt{\char92mathit}によってギリシャ文字の
1199 斜体大文字が出なくなる,など.}場合は,
1200 次のように\Pkg{luatexja-preset}の前に\Pkg{fontspec}を手動で読みこめば良い:
1201 %</ja>
1202 \begin{verbatim}
1203 \usepackage[no-math]{fontspec}
1204 \usepackage[...]{luatexja-preset}
1205 \end{verbatim}
1206
1207 %<en>\paragraph{General options}
1208 %<ja>\paragraph{一般的なオプション}
1209 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}\advance\leftmargin1\zw}
1210 \item[nodeluxe]
1211 %<*en>
1212 Use one-weighted \textit{mincho} and \textit{gothic} font families.
1213 This means that \verb+\mcfamily\bfseries+, \verb+\gtfamily\bfseries+ and 
1214 \verb+\gtfamily\mdseries+ use the same font.
1215 \emph{This option is enabled by default.}
1216 %</en>
1217 %<*ja>
1218 \LaTeXe 環境下での標準設定のように,明朝体・ゴシック体を各1ウェイトで使用する.
1219 より具体的に言うと,この設定の下では
1220 \verb+\mcfamily\bfseries+, \verb+\gtfamily\bfseries+, \verb+\gtfamily\mdseries+は
1221 みな同じフォントとなる.\emph{このオプションは標準で有効になっている.}
1222 %</ja>
1223 \item[deluxe]
1224 %<*en>
1225 Use \textit{mincho} with two weights (medium~and~bold),
1226 \textit{gothic} with three weights (medium, bold~and~heavy), and \textit{rounded gothic}%
1227 \footnote{Provided by \texttt{\char92mgfamily} and \texttt{\char92textmg\{...\}},
1228 because \textit{rounded gothic} is called \textit{maru gothic} (丸ゴシック) in Japanese.}.
1229 The heavy weight of \textit{gothic} can be used by ``changing the family'' \verb+\gtebfamily+,
1230 or \verb+\textgteb{...}+.
1231 This is because \Pkg{fontspec} package can handle only medium (\verb+\mdseries+) and
1232 bold (\verb+\bfseries+).
1233 %</en>
1234 %<*ja>
1235 明朝体2ウェイト・ゴシック体3ウェイトと,
1236 丸ゴシック体 (\verb+\mgfamily+, \verb+\textmg{...}+) を使用可能とする.
1237 ゴシック体は細字・太字・極太の3ウェイトがあるが,
1238 極太ゴシック体はファミリの切り替え (\verb+\gtebfamily+, \verb+\textgteb{...}+) %
1239 で実現している.\Pkg{fontspec}では通常 (\verb+\mdseries+) と太字 (\verb+\bfseries+) しか扱えないために
1240 このような中途半端な実装になっている.
1241 %</ja>
1242 \item[expert]
1243 %<*en>
1244 Use horizontal kana alternates, and define a control sequence \verb+\rubyfamily+ to use kana
1245 characters designed for ruby.
1246 %</en>
1247 %<ja>横組専用仮名を用いる.また,\verb+\rubyfamily+ でルビ用仮名が使用可能となる.
1248 \item[bold]
1249 %<en>Substitute bold series of \textit{gothic} for  bold series of \textit{mincho}.
1250 %<ja>「明朝の太字」をゴシック体の太字によって代替する.
1251 \item[90jis]
1252 %<en>Use 90JIS glyph variants if possible.
1253 %<ja>出来る限り90JISの字形を使う.
1254 \item[jis2004]
1255 %<en>Use JIS2004 glyph variants if possible.
1256 %<ja>出来る限りJIS2004の字形を使う.
1257 \item[jis]
1258 %<*en>
1259 Use the JFM \texttt{jfm-jis.lua}, instead of \texttt{jfm-ujis.lua}, which is the default JFM of
1260 \LuaTeX-ja.
1261 %</en>
1262 %<*ja>
1263 用いるJFMを(JISフォントメトリック類似の)\texttt{jfm-jis.lua}にする.このオプションがない時は
1264 \LuaTeX-ja標準の\texttt{jfm-ujis.lua}が用いられる.
1265 %</ja>
1266 \end{list}
1267 %<*en>
1268 Note that \texttt{90jis} and \texttt{jis2004} only affect with \textit{mincho},
1269 \textit{gothic} (and possibly \textit{rounded gothic}) defined by this package.
1270 We didn't taken account of  when both \texttt{90jis} and \texttt{jis2004} are specified.
1271 %</en>
1272 %<*ja>
1273 \texttt{90jis}と\texttt{jis2004}については本パッケージで定義された
1274 明朝体・ゴシック体(・丸ゴシック体)にのみ有効である.両オプションが
1275 同時に指定された場合の動作については全く考慮していない.
1276 %</ja>
1277
1278 %<en>\paragraph{Presets for multi weight settings}
1279 %<ja>\paragraph{多ウェイト用プリセットの一覧}
1280 %<*en>
1281 Besides \texttt{morisawa-pro}~and~\texttt{morisawa-pr6n} presets,
1282 fonts are specified by fontname, not by filename.
1283 %</en>
1284 %<*ja>
1285 \texttt{morisawa-pro}, \texttt{morisawa-pr6n}以外はフォントの指定は
1286 (ファイル名でなく)フォント名で行われる.
1287 %</ja>
1288 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}\advance\leftmargin1\zw}
1289  \item[kozuka-pro] Kozuka Pro (Adobe-Japan1-4) fonts.
1290 %<en>    \\[-\dimexpr\medskipamount+\baselineskip\relax]
1291  \item[kozuka-pr6] Kozuka Pr6 (Adobe-Japan1-6)  fonts.
1292 %<en>    \\[-\dimexpr\medskipamount+\baselineskip\relax]
1293  \item[kozuka-pr6n] Kozuka Pr6N (Adobe-Japan1-6, JIS04-savvy) fonts.
1294
1295 %<*en>
1296 Kozuka Pro/Pr6N fonts are bundled with Adobe's software, such as Adobe~InDesign.
1297 There is not rounded gothic family in Kozuka fonts.
1298 %</en>
1299 %<*ja>
1300 小塚Pro書体・Pr6N書体はAdobe InDesign等のAdobe製品にバンドルされている.
1301 「小塚丸ゴシック」は存在しないので,便宜的に小塚ゴシックHによって代用している.
1302 %</ja>
1303 \begin{center}\small
1304 \begin{tabular}{cllll}
1305 \toprule
1306 \bf family&\bf series&\tt kozuka-pro&\tt kozuka-pr6&\tt kozuka-pr6n\\
1307 \midrule
1308  &medium&KozMinPro-Regular&KozMinProVI-Regular&KozMinPr6N-Regular\\
1309 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
1310 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
1311  &bold&KozMinPro-Bold&KozMinProVI-Bold&KozMinPr6N-Bold\\
1312 \midrule
1313  &&KozGoPro-Regular*&KozGoProVI-Regular*&KozGoPr6N-Regular*\\
1314  &\smash{\raisebox{1.5ex}{medium}}
1315  &KozGoPro-Medium&KozGoProVI-Medium&KozGoPr6N-Medium\\
1316 \cmidrule(l){2-5}
1317 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
1318 %<ja>\smash{\raisebox{2ex}{\gt ゴシック}}%
1319  &bold&KozGoPro-Bold&KozGoProVI-Bold&KozGoPr6N-Bold\\
1320  &heavy&KozGoPro-Heavy&KozGoProVI-Heavy&KozGoPr6N-Heavy\\
1321 \midrule
1322 %<en>\textit{rounded gothic}
1323 %<ja>\gt 丸ゴシック
1324 &&KozGoPro-Heavy&KozGoProVI-Heavy&KozGoPr6N-Heavy\\
1325 \bottomrule
1326 \end{tabular}
1327 \end{center}
1328
1329 %<*en>
1330 In above table, starred fonts (KozGo\dots-Regular) are used for medium series of \textit{gothic},
1331 \emph{if and only if \texttt{deluxe} option is specified}.
1332 %</en>
1333 %<*ja>
1334 上の表において,*つきのフォント(KozGo\dots-Regular)は,\emph{\texttt{deluxe}オプション非指定時に}
1335 ゴシック体細字として用いられる.
1336 %</ja>
1337
1338 %<ja>\medskip
1339
1340  \item[hiragino-pro]  Hiragino Pro (Adobe-Japan1-5) fonts.
1341 %<en>    \\[-\dimexpr\medskipamount+\baselineskip\relax]
1342  \item[hiragino-pron] Hiragino ProN (Adobe-Japan1-5, JIS04-savvy) fonts.
1343
1344 %<*en>
1345 Hiragino fonts are bundled with Mac OS~X 10.5 or later.
1346 Some editions of a Japanese word-processor ``一太郎2012'' includes Hiragino ProN fonts.
1347 Note that the heavy weight of \textit{gothic} family only supports
1348 Adobe-Japan1-3 character collection (Std/StdN).
1349 %</en>
1350 %<*ja>
1351 ヒラギノフォントは,Mac OS~X以外にも,一太郎2012の上位エディションにもバンドルされている.
1352 極太ゴシックとして用いるヒラギノ角ゴW8は,Adobe-Japan1-3の範囲しかカバーしていない
1353 Std/StdNフォントであり,その他はAdobe-Japan1-5対応である.
1354 %</ja>
1355 \begin{center}\small
1356 \begin{tabular}{clll}
1357 \toprule
1358 \bf family&\bf series&\tt hiragino-pro&\tt hiragino-pron\\
1359 \midrule
1360  &medium&Hiragino~Mincho~Pro~W3&Hiragino~Mincho~ProN~W3\\
1361 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
1362 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
1363  &bold&Hiragino~Mincho~Pro~W6&Hiragino~Mincho~ProN~W6\\
1364 \midrule
1365  &&Hiragino~Kaku~Gothic~Pro~W3*&Hiragino~Kaku~Gothic~ProN~W3*\\
1366  &\smash{\raisebox{1.5ex}{medium}}
1367  &Hiragino~Kaku~Gothic~Pro~W6&Hiragino~Kaku~Gothic~ProN~W6\\
1368 \cmidrule(l){2-4}
1369 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
1370 %<ja>\smash{\raisebox{2ex}{\gt ゴシック}}%
1371  &bold&Hiragino~Kaku~Gothic~Pro~W6&Hiragino~Kaku~Gothic~ProN~W6\\
1372  &heavy&Hiragino~Kaku~Gothic~Std~W8&Hiragino~Kaku~Gothic~StdN~W8\\
1373 \midrule
1374 %<en>\textit{rounded gothic}
1375 %<ja>\gt 丸ゴシック
1376 &&Hiragino~Maru~Gothic~ProN~W4&Hiragino~Maru~Gothic~ProN~W4\\
1377 \bottomrule
1378 \end{tabular}
1379 \end{center}
1380
1381 %<ja>\medskip
1382
1383  \item[morisawa-pro]  Morisawa Pro (Adobe-Japan1-4) fonts.
1384 %<en>    \\[-\dimexpr\medskipamount+\baselineskip\relax]
1385  \item[morisawa-pr6n]  Morisawa Pr6N (Adobe-Japan1-6, JIS04-savvy) fonts.
1386 \begin{center}\small
1387 \begin{tabular}{cl>{\tt}l>{\tt}l}
1388 \toprule
1389 \bf family&\bf series&morisawa-pro&morisawa-pr6n\\
1390 \midrule
1391  &medium&A-OTF-RyuminPro-Light.otf&A-OTF-RyuminPr6N-Light.otf\\
1392 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
1393 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
1394  &bold&A-OTF-FutoMinA101Pro-Bold.otf&A-OTF-FutoMinA101Pr6N-Bold.otf\\
1395 \midrule
1396  &medium
1397  &A-OTF-GothicBBBPro-Medium.otf&A-OTF-GothicBBBPr6N-Medium.otf\\
1398 %<en>\textit{gothic}%
1399 %<ja>\gt ゴシック
1400  &bold&A-OTF-FutoGoB101Pro-Bold.otf&A-OTF-FutoGoB101Pr6N-Bold.otf\\
1401  &heavy&A-OTF-MidashiGoPro-MB31.otf&A-OTF-MidashiGoPr6N-MB31.otf\\
1402 \midrule
1403 %<en>\textit{rounded gothic}
1404 %<ja>\gt 丸ゴシック
1405 &&A-OTF-Jun101Pro-Light.otf&A-OTF-Jun101Pr6N-Light.otf\\
1406 \bottomrule
1407 \end{tabular}
1408 \end{center}
1409
1410  \item[yu-win]  Yu fonts bundled with Windows~8.1. 
1411 %<en>    \\[-\dimexpr\medskipamount+\baselineskip\relax]
1412  \item[yu-osx]  Yu fonts bundled with OSX~Mavericks. 
1413 \begin{center}\small
1414 \begin{tabular}{clll}
1415 \toprule
1416 \bf family&\bf series&\tt yu-win&\tt yu-osx\\
1417 \midrule
1418  &medium&YuMincho-Regular&YuMincho~Medium\\
1419 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
1420 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
1421  &bold&YuMincho-Demibold&YuMincho~Demibold\\
1422 \midrule
1423  &&YuGothic-Regular*&YuGothic~Medium*\\
1424  &\smash{\raisebox{1.5ex}{medium}}
1425  &YuGothic-Bold&YuGothic~Bold\\
1426 \cmidrule(l){2-4}
1427 %<en>\textit{gothic}%
1428 %<ja>\gt ゴシック
1429  &bold&YuGothic-Bold&YuGothic~Bold\\
1430  &heavy&YuGothic-Bold&YuGothic~Bold\\
1431 \midrule
1432 %<en>\textit{rounded gothic}
1433 %<ja>\gt 丸ゴシック
1434 &&YuGothic-Bold&YuGothic~Bold\\
1435 \bottomrule
1436 \end{tabular}
1437 \end{center}
1438
1439 \end{list}
1440 %<en>\paragraph{Presets for single weight}
1441 %<ja>\paragraph{単ウェイト用プリセット一覧}
1442 %<*en>
1443 Next, we describe settings for using only single weight.
1444 In four settings below, we use same fonts for medium and bold (and heavy) weights.
1445 (Hence \verb+\mcfamily\bfseries+ and \verb+\mcfamily\mdseries+ yields same Japanese fonts,
1446 even if \texttt{deluxe} option is also specified).
1447 %</en>
1448 %<*ja>
1449 次に,単ウェイト用の設定を述べる.この4設定では「細字」「太字」の区別はない.
1450 また,丸ゴシック体はゴシック体と同じフォントを用いる.
1451 %</ja>
1452 \par\nobreak\medskip
1453 {\centering\small
1454 \begin{tabular}{lllll}
1455 \toprule
1456 &\tt noembed&\tt ipa&\tt ipaex&\tt ms\\
1457 \midrule
1458 %<*en>
1459 \it mincho&Ryumin-Light (non-embedded)
1460 &IPAMincho&IPAexMincho&MS Mincho\\
1461 \it gothic&GothicBBB-Medium (non-embedded)
1462 &IPAGothic&IPAexGothic&MS Gothic\\
1463 %</en>
1464 %<*ja>
1465 \gtfamily 明朝体&Ryumin-Light(非埋込)
1466 &IPA明朝&IPAex明朝&MS明朝\\
1467 \gtfamily ゴシック体&GothicBBB-Medium(非埋込)
1468 &IPAゴシック&IPAexゴシック&MSゴシック\\
1469 %</ja>
1470 \bottomrule
1471 \end{tabular}\par\medskip}
1472
1473
1474 %<en>\paragraph{Using HG fonts}
1475 %<ja>\paragraph{HGフォントの利用}
1476 %<*en>
1477 We can use HG~fonts bundled with Microsoft~Office for realizing multiple weights.
1478 %</en>
1479 %<*ja>
1480 すぐ前に書いた単ウェイト用設定を,Microsoft Office等に付属するHGフォントを使って
1481 多ウェイト化した設定もある.
1482 %</ja>
1483 \par\nobreak\medskip
1484 {\centering\small
1485 \begin{tabular}{llll}
1486 \toprule
1487 &\tt ipa-hg&\tt ipaex-hg&\tt ms-hg\\
1488 \midrule
1489 %<*en>
1490 \bf mincho medium
1491 &IPAMincho&IPAexMincho&MS Mincho\\\midrule
1492 \bf mincho bold&
1493 \multicolumn{3}{c}{HG Mincho E}\\\midrule
1494 \bf Gothic medium\\
1495 ~~without \texttt{deluxe}
1496 &IPAGothic&IPAexGothic&MS Gothic\\
1497 ~~with {\tt jis2004}
1498 &IPAGothic&IPAexGothic&MS Gothic\\
1499 \cmidrule(lr){1-4}
1500 ~~otherwise&
1501 \multicolumn{3}{c}{HG Gothic M}\\\midrule
1502 \bf gothic bold&
1503 \multicolumn{3}{c}{HG Gothic E}\\\midrule
1504 \bf gothic heavy&
1505 \multicolumn{3}{c}{HG Soei Kaku Gothic UB}\\\midrule
1506 \bf rounded gothic&
1507 \multicolumn{3}{c}{HG Maru Gothic PRO}\\
1508 %</en>
1509 %<*ja>
1510 \gtfamily 明朝体細字
1511 &IPA明朝&IPAex明朝&MS明朝\\\midrule
1512 \gtfamily 明朝体太字&
1513 \multicolumn{3}{c}{HG明朝E}\\\midrule
1514 \gtfamily ゴシック体細字\\
1515  単ウェイト時
1516 &IPAゴシック&IPAexゴシック&MSゴシック\\
1517  {\tt jis2004}指定時
1518 &IPAゴシック&IPAexゴシック&MSゴシック\\
1519 \cmidrule(lr){1-4}
1520  それ以外の時&
1521 \multicolumn{3}{c}{HGゴシックM}\\\midrule
1522 \gtfamily ゴシック体太字&
1523 \multicolumn{3}{c}{HGゴシックE}\\\midrule
1524 \gtfamily ゴシック体極太&
1525 \multicolumn{3}{c}{HG創英角ゴシックUB}\\\midrule
1526 \gtfamily 丸ゴシック体&
1527 \multicolumn{3}{c}{HG丸ゴシック体PRO}\\
1528 %</ja>
1529 \bottomrule
1530 \end{tabular}\par\medskip}
1531
1532 %<*en>
1533 Note that HG~Mincho~E, HG~Gothic~E, HG Soei Kaku Gothic UB, and HG Maru Gothic PRO
1534 are internally specified by:
1535 \begin{description}
1536 \item[default] by font name (\texttt{HGMinchoE}, etc.).
1537 \item[{\tt 90jis}] by filename (\texttt{hgrme.ttc}, \texttt{hgrge.ttc}, \texttt{hgrsgu.ttc}, \texttt{hgrsmp.ttf}).
1538 \item[{\tt jis2004}] by filename (\texttt{hgrme04.ttc}, \texttt{hgrge04.ttc}, \texttt{hgrsgu04.ttc}, \texttt{hgrsmp04.ttf}).
1539 \end{description}
1540 %</en>
1541 %<*ja>
1542 なお,HG明朝E・HGゴシックE・HG創英角ゴシックUB・HG丸ゴシック体PROの4つについては,内部で
1543 \begin{description}
1544 \item[標準] フォント名(\texttt{HGMinchoE} など)
1545 \item[{\tt 90jis}指定時] ファイル名 (%
1546 \texttt{hgrme.ttc}, \texttt{hgrge.ttc}, \texttt{hgrsgu.ttc}, \texttt{hgrsmp.ttf})
1547 \item[{\tt jis2004}指定時] ファイル名 (%
1548 \texttt{hgrme04.ttc}, \texttt{hgrge04.ttc}, \texttt{hgrsgu04.ttc}, \texttt{hgrsmp04.ttf})
1549 \end{description}
1550 として指定を行っているので注意すること.
1551 %</ja>
1552
1553
1554 %<*en>
1555 \subsection{\texttt{\char`\\CID}, \texttt{\char`\\UTF}, and macros in \Pkg{otf} package}
1556 Under \pLaTeX, \Pkg{otf} package (developed by Shuzaburo Saito) is
1557 used for typesetting characters which is in Adobe-Japan1-6 CID but not
1558 in JIS~X~0208. Since this package is widely used, \LuaTeX-ja
1559 supports some of functions in \Pkg{otf} package.
1560 If you want to use these functions, load \Pkg{luatexja-otf} package.
1561 %</en>
1562 %<*ja>
1563 \subsection{\texttt{\char`\\CID}, \texttt{\char`\\UTF}と\Pkg{otf}パッケージのマクロ}
1564 \pLaTeX では,JIS~X~0208にないAdobe-Japan1-6の文字を出力するために,
1565 齋藤修三郎氏による\Pkg{otf}パッケージが用いられていた.このパッケージは
1566 広く用いられているため,\LuaTeX-jaにおいても\Pkg{otf}パッケージの機能の
1567 一部をサポートしている.これらの機能を用いるためには\Pkg{luatexja-otf}パッケージ
1568 を読み込めばよい.
1569 %</ja>
1570
1571 \begin{LTXexample}
1572 \jfontspec{KozMinPr6N-Regular.otf}
1573 森\UTF{9DD7}外と内田百\UTF{9592}とが\UTF{9AD9}島屋に行く。
1574
1575 \CID{7652}飾区の\CID{13706}野家,
1576 \CID{1481}城市,葛西駅,
1577 高崎と\CID{8705}\UTF{FA11}
1578
1579 \aj半角{はんかくカタカナ}
1580 \end{LTXexample}
1581
1582 %<*ja>
1583 \Pkg{otf}パッケージでは,それぞれ次のようなオプションが存在した:
1584 \begin{description}
1585 \item[\texttt{deluxe}] 明朝体・ゴシック体各2ウェイトと,丸ゴシック体を扱えるようになる.
1586 \item[\texttt{expert}] 仮名が横組・縦組専用のものに切り替わり,ルビ用仮名も扱えるようになる.
1587 \item[\texttt{bold}] ゴシック体を標準で太いウェイトのものに設定する.
1588 \end{description}
1589 しかしこれらのオプションは\Pkg{luatexja-otf}パッケージには存在しない.
1590 \Pkg{otf}パッケージが文書中で使用する和文用TFMを自前の物に置き換えていたのに対し,
1591 \Pkg{luatexja-otf}パッケージでは,そのようなことは行わないからである.
1592
1593 これら3オプションについては,
1594 \Pkg{luatexja-preset} パッケージにプリセットを使う時に一緒に指定するか,
1595 あるいは対応する内容を\ref{ssub-chgfnt}節 (NFSS2) や
1596 \ref{ssec-fontspec}節 (\Pkg{fontspec}) の方法で手動で指定する必要がある.
1597 %</ja>
1598
1599
1600 %<en>\section{Changing Parameters}
1601 %<ja>\section{パラメータの変更}
1602
1603 %<*en>
1604 There are many parameters in \LuaTeX-ja. And due to the behavior of \LuaTeX,
1605 most of them are not stored as internal register of \TeX, but as an
1606 original storage system in \LuaTeX-ja. Hence, to assign or acquire those
1607 parameters, you have to use commands \verb+\ltjsetparameter+ and
1608 \verb+\ltjgetparameter+.
1609 %</en>
1610 %<*ja>
1611 \LuaTeX-jaには多くのパラメータが存在する.そして\LuaTeX の仕様のために,
1612 その多くは\TeX のレジスタにではなく,\LuaTeX-ja独自の方法で保持されている.
1613 これらのパラメータを設定・取得するためには \verb+\ltjsetparameter+ と \verb+\ltjgetparameter+ を
1614 用いる.
1615 %</ja>
1616
1617 %<en>\subsection{Editing the range of \textbf{JAchar}s}
1618 %<ja>\subsection{\textbf{JAchar}の範囲の設定}
1619 \label{ssec-setrange}
1620
1621 %<*en>
1622 \LuaTeX-ja divides the Unicode codespace into \emph{character ranges}, 
1623 numbered 1 to 216. The grouping can be (globally) customized by \verb+\ltjdefcharrange+.
1624 The next line adds whole characters in Supplementary Ideographic Plane
1625 and the character ``漢'' to the character range~100.
1626 %</en>
1627 %<*ja>
1628 \LuaTeX-jaは,Unicode全体の空間を1番から216番までの\emph{文字範囲}に分割している.
1629 区分けは \verb+\ltjdefcharrange+ を用いることで(グローバルに)変更することができ,
1630 例えば,次は追加漢字面(SIP)にある全ての文字と「漢」を「100番の文字範囲」に追加する.
1631 %</ja>
1632 \begin{lstlisting}
1633 \ltjdefcharrange{100}{"20000-"2FFFF,`漢}
1634 \end{lstlisting}
1635 %<*en>
1636 A character can belong to only one character range.
1637 For example, whole SIP belong to the range~4 in the default setting of \LuaTeX-ja, 
1638 and if you execute the above line, then SIP will belong to the range~100 and be
1639 removed from the range~4.
1640 %</en>
1641 %<*ja>
1642 各文字はただ一つの文字範囲に所属することができる.
1643 例えば,SIPは全て\LuaTeX-jaのデフォルトでは4番の文字範囲に
1644 属しているが,上記の指定を行えばSIPは100番に属すようになり,4番からは除かれる.
1645 %</ja>
1646
1647 %<*en>
1648 The distinction between \textbf{ALchar} and \textbf{JAchar} is done for character ranges.
1649 This can be edited by setting the \textsf{jacharrange} parameter.
1650 For example, this is just the default setting of \LuaTeX-ja, and
1651 it sets
1652 \begin{itemize}
1653  \item a character which belongs character ranges 1,~4, and~5 is \textbf{ALchar},
1654  \item a character which belongs character ranges 2,~3, 6, 7, and~8 is \textbf{JAchar}.
1655 \end{itemize}
1656 %</en>
1657 %<*ja>
1658 \textbf{ALchar}と\textbf{JAchar}の区別は文字範囲ごとに行われる.
1659 これは\textsf{jacharrange}パラメータによって編集できる.
1660 例えば,以下は\LuaTeX-jaの初期設定であり,次の内容を設定している:
1661 \begin{itemize}
1662  \item 1番,4番,5番の文字範囲に属する文字は\textbf{ALchar}.
1663  \item 2番,3番,6番,7番,8番の文字範囲に属する文字は\textbf{JAchar}.
1664 \end{itemize}
1665 %</ja>
1666 \begin{verbatim}
1667 \ltjsetparameter{jacharrange={-1, +2, +3, -4, -5, +6, +7, +8}}
1668 \end{verbatim}
1669 %<*en>
1670 The argument to \textsf{jacharrange} parameter is a list of non-zero integer.
1671 Negative integer $-n$ in the list means that ``each character in the range~$n$ is a \textbf{ALchar}'', and positive integer $+n$ means
1672 that ``\dots\ is a \textbf{JAchar}''.
1673 %</en>
1674 %<*ja>
1675 \textsf{jacharrange}パラメータの引数は非零の整数のリストである.
1676 リスト中の負の整数$-n$は「文字範囲$n$に属する文字は\textbf{ALchar}として
1677 扱う」ことを意味し,正の整数$+n$は「\textbf{JAchar}として扱う」ことを意味する.
1678 %</ja>
1679
1680 %<*en>
1681 \paragraph{Default Setting}
1682 \LuaTeX-ja predefines eight character ranges for convenience. They are
1683 determined from the following data:
1684 %</en>
1685 %<*ja>
1686 \paragraph{初期設定}
1687 \LuaTeX-jaでは8つの文字範囲を予め定義しており,
1688 これらは以下のデータに基づいて決定している.
1689 %</ja>
1690 \begin{itemize}
1691 %<en>\item Blocks in Unicode~6.0.
1692 %<ja>\item Unicode~6.0のブロック.
1693 %<en>\item The \texttt{Adobe-Japan1-UCS2} mapping between a CID Adobe-Japan1-6 and Unicode.
1694 %<ja>\item Adobe-Japan1-6のCIDとUnicodeの間の対応表\texttt{Adobe-Japan1-UCS2}.
1695 %<en>\item The \Pkg{PXbase} bundle for \upTeX\ by Takayuki Yato.
1696 %<ja>\item 八登崇之氏による\upTeX 用の\Pkg{PXbase}バンドル.
1697 \end{itemize}
1698
1699 %<*en>
1700 Now we describe these eight ranges. The alphabet ``J'' or ``A'' after the
1701 number shows whether each character in the range is treated as
1702 \textbf{JAchar}s or not by default. These settings are similar to the
1703 \texttt{prefercjk} settings defined in \texttt{PXbase} bundle.
1704 %</en>
1705 %<*ja>
1706 以下ではこれら8つの文字範囲について記述する.番号のあとのアルファベット「J」「A」
1707 は,その文字範囲内の文字が\textbf{JAchar}か\textbf{ALchar}かを表している.これらの設定は
1708 \texttt{PXbase}バンドルで定義されている\texttt{prefercjk}と類似のものである.
1709 %</ja>
1710 \begin{description}
1711 %<*en>
1712 \item[Range~8${}^{\text{J}}$] The intersection of the upper half of ISO~8859-1
1713          (Latin-1 Supplement) and JIS~X~0208 (a basic character set for Japanese). This character range
1714          consists of the following characters:
1715 %</en>
1716 %<*ja>
1717 \item[範囲8${}^{\text{J}}$] ISO~8859-1の上位領域(ラテン1補助)と
1718                              JIS~X~0208の共通部分.この文字範囲は
1719                              以下の文字で構成される:
1720 %</ja>
1721 \begin{multicols}{2}
1722 \begin{itemize}
1723 \def\ch#1#2{\item \char"#1\ (\texttt{U+00#1}, #2)}%"
1724 \ch{A7}{Section Sign}
1725 \ch{A8}{Diaeresis}
1726 \ch{B0}{Degree sign}
1727 \ch{B1}{Plus-minus sign}
1728 \ch{B4}{Spacing acute}
1729 \ch{B6}{Paragraph sign}
1730 \ch{D7}{Multiplication sign}
1731 \ch{F7}{Division Sign}
1732 \end{itemize}
1733 \end{multicols}
1734
1735 %<*en>
1736 \item[Range~1${}^{\text{A}}$] Latin characters that some of them are included in Adobe-Japan1-6.
1737 This range consists of the following Unicode ranges, \emph{except characters in the range~8 above}:
1738 %</en>
1739 %<*ja>
1740 \item[範囲1${}^{\text{A}}$] ラテン文字のうち,Adobe-Japan1-6との共通部分があるもの.
1741                              この範囲は以下のUnicodeのブロックのうち
1742                              \emph{範囲8を除いた}部分で構成されている:
1743 %</ja>
1744 \begin{multicols}{2}
1745 \begin{itemize}
1746 \item \texttt{U+0080}--\texttt{U+00FF}: Latin-1 Supplement
1747 \item \texttt{U+0100}--\texttt{U+017F}: Latin Extended-A
1748 \item \texttt{U+0180}--\texttt{U+024F}: Latin Extended-B
1749 \item \texttt{U+0250}--\texttt{U+02AF}: IPA Extensions
1750 \item \texttt{U+02B0}--\texttt{U+02FF}: Spacing Modifier Letters
1751 \item \texttt{U+0300}--\texttt{U+036F}: \\\null\hfill Combining Diacritical Marks
1752 \item \texttt{U+1E00}--\texttt{U+1EFF}: \\\null\hfill Latin Extended Additional
1753 \par\
1754 \end{itemize}
1755 \end{multicols}
1756 %<*en>
1757 \item[Range~2${}^{\text{J}}$] Greek and Cyrillic letters. JIS~X~0208 (hence most of Japanese
1758            fonts) has some of these characters.
1759 %</en>
1760 %<*ja>
1761 \item[範囲2${}^{\text{J}}$] ギリシャ文字とキリル文字.JIS~X~0208(したがってほとんどの
1762                              和文フォント)はこれらの文字を持つ.
1763 %</ja>
1764 \begin{multicols}{2}
1765 \begin{itemize}
1766 \item \texttt{U+0370}--\texttt{U+03FF}: Greek and Coptic
1767 \item \texttt{U+0400}--\texttt{U+04FF}: Cyrillic
1768 \item \texttt{U+1F00}--\texttt{U+1FFF}: Greek Extended
1769 \\\
1770 \end{itemize}
1771 \end{multicols}
1772 %<*en>
1773 \item[Range~3${}^{\text{J}}$] Punctuations and Miscellaneous symbols. The block list is
1774            indicated in Table~\ref{table-rng3}.
1775 %</en>
1776 %<*ja>
1777 \item[範囲3${}^{\text{J}}$] 句読点と記号類.ブロックのリストは表\ref{table-rng3}%
1778                              に示してある.
1779 %</ja>
1780 \begin{table}[!tb]
1781 %<en>\caption{Unicode blocks in predefined character range~3.}
1782 %<ja>\caption{文字範囲3に指定されているUnicodeブロック.}
1783 \label{table-rng3}
1784 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
1785 \centering\small
1786 \begin{tabular}{llll}
1787 "2000--"206F&General Punctuation&
1788 "2070--"209F&Superscripts and Subscripts\\
1789 "20A0--"20CF&Currency Symbols&
1790 "20D0--"20FF&Comb.\ Diacritical Marks for Symbols\\
1791 "2100--"214F&Letterlike Symbols&
1792 "2150--"218F&Number Forms\\
1793 "2190--"21FF&Arrows&
1794 "2200--"22FF&Mathematical Operators\\
1795 "2300--"23FF&Miscellaneous Technical&
1796 "2400--"243F&Control Pictures\\
1797 "2500--"257F&Box Drawing&
1798 "2580--"259F&Block Elements\\
1799 "25A0--"25FF&Geometric Shapes&
1800 "2600--"26FF&Miscellaneous Symbols\\
1801 "2700--"27BF&Dingbats&
1802 "2900--"297F&Supplemental Arrows-B\\
1803 "2980--"29FF&Misc.\ Mathematical Symbols-B&
1804 "2B00--"2BFF&Miscellaneous Symbols and Arrows
1805 \end{tabular}
1806 \end{table}
1807 %<*en>
1808 \item[Range~4${}^{\text{A}}$] Characters usually not in Japanese fonts. This range consists
1809            of almost all Unicode blocks which are not in other
1810            predefined ranges. Hence, instead of showing the block list,
1811            we put the definition of this range itself:
1812 %</en>
1813 %<*ja>
1814 \item[範囲4${}^{\text{A}}$] 通常和文フォントには含まれていない文字.
1815                              この範囲は他の範囲にないほとんど全てのUnicodeブロック
1816                              で構成されている.したがって,ブロックのリストを示す
1817                              代わりに,範囲の定義そのものを示す:
1818 %</ja>
1819 \begin{lstlisting}
1820 \ltjdefcharrange{4}{%
1821    "500-"10FF, "1200-"1DFF, "2440-"245F, "27C0-"28FF, "2A00-"2AFF,
1822   "2C00-"2E7F, "4DC0-"4DFF, "A4D0-"A82F, "A840-"ABFF, "FB00-"FE0F,
1823   "FE20-"FE2F, "FE70-"FEFF, "10000-"1FFFF, "E000-"F8FF} % non-Japanese
1824 \end{lstlisting}
1825 %<en>\item[Range~5${}^{\text{A}}$] Surrogates and Supplementary Private Use Areas.
1826 %<ja>\item[範囲5${}^{\text{A}}$] 代用符号と補助私用領域.
1827 %<en>\item[Range~6${}^{\text{J}}$] Characters used in Japanese. The block list is indicated in Table~\ref{table-rng6}.
1828 %<ja>\item[範囲6${}^{\text{J}}$] 日本語で用いられる文字.ブロックのリストは表\ref{table-rng6}に示す.
1829 \begin{table}[!tb]
1830 %<en>\caption{Unicode blocks in predefined character range~6.}
1831 %<ja>\caption{文字範囲6に指定されているUnicodeブロック.}
1832 \label{table-rng6}
1833 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
1834 \centering\small
1835 \begin{tabular}{llll}
1836 "2460--"24FF&Enclosed Alphanumerics&
1837 "2E80--"2EFF&CJK Radicals Supplement\\
1838 "3000--"303F&CJK Symbols and Punctuation&
1839 "3040--"309F&Hiragana\\
1840 "30A0--"30FF&Katakana&
1841 "3190--"319F&Kanbun\\
1842 "31F0--"31FF&Katakana Phonetic Extensions&
1843 "3200--"32FF&Enclosed CJK Letters and Months\\
1844 "3300--"33FF&CJK Compatibility&
1845 "3400--"4DBF&CJK Unified Ideographs Extension A\\
1846 "4E00--"9FFF&CJK Unified Ideographs&
1847 "F900--"FAFF&CJK Compatibility Ideographs\\
1848 "FE10--"FE1F&Vertical Forms&
1849 "FE30--"FE4F&CJK Compatibility Forms\\
1850 "FE50--"FE6F&Small Form Variants&
1851 "{20}000--"{2F}FFF&(Supplementary Ideographic Plane)
1852 \end{tabular}
1853 \end{table}
1854 %<*en>
1855 \item[Range~7${}^{\text{J}}$] Characters used in CJK languages, but not included in  Adobe-Japan1-6.
1856 The block list is indicated in Table~\ref{table-rng7}.
1857 %</en>
1858 %<*ja>
1859 \item[範囲7${}^{\text{J}}$] CJK言語で用いられる文字のうち,Adobe-Japan1-6に
1860                             含まれていないもの.
1861                             ブロックのリストは表\ref{table-rng7}に示す.
1862 %</ja>
1863 \begin{table}[!tb]
1864 %<en>\caption{Unicode blocks in predefined character range~7.}
1865 %<ja>\caption{文字範囲7に指定されているUnicodeブロック.}
1866 \label{table-rng7}
1867 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
1868 \centering\small
1869 \begin{tabular}{llll}
1870 "1100--"11FF&Hangul Jamo&
1871 "2F00--"2FDF&Kangxi Radicals\\
1872 "2FF0--"2FFF&Ideographic Description Characters&
1873 "3100--"312F&Bopomofo\\
1874 "3130--"318F&Hangul Compatibility Jamo&
1875 "31A0--"31BF&Bopomofo Extended\\
1876 "31C0--"31EF&CJK Strokes&
1877 "A000--"A48F&Yi Syllables\\
1878 "A490--"A4CF&Yi Radicals&
1879 "A830--"A83F&Common Indic Number Forms\\
1880 "AC00--"D7AF&Hangul Syllables&
1881 "D7B0--"D7FF&Hangul Jamo Extended-B
1882 \end{tabular}
1883 \end{table}
1884 \end{description}
1885
1886
1887 %<en>\subsection{\Param{kanjiskip} and \Param{xkanjiskip}}
1888 %<ja>\subsection{\Param{kanjiskip}と\Param{xkanjiskip}}
1889 \label{subs-kskip}
1890
1891 %<en>\textbf{JAglue} is divided into the following three categories:
1892 %<ja>\textbf{JAglue}は以下の3つのカテゴリに分類される:
1893 \begin{itemize}
1894 %<*en>
1895 \item Glues/kerns specified in JFM. If \verb+\inhibitglue+ is issued
1896       around a Japanese character, this glue will not be inserted at the
1897       place.
1898 %</en>
1899 %<*ja>
1900 \item JFMで指定されたグルー/カーン.もし \verb+\inhibitglue+ が和文文字の周りで
1901       発行されていれば,このグルーは挿入されない.
1902 %</ja>
1903 %<*en>
1904 \item The default glue which inserted between two \textbf{JAchar}s (\Param{%
1905       kanjiskip}).
1906 %</en>
1907 %<*ja>
1908 \item デフォルトで2つの\textbf{JAchar}の間に挿入されるグルー(\Param{\hyperlink{fld:kanjiskip}{kanjiskip}}).
1909 %</ja>
1910 %<*en>
1911 \item The default glue which inserted between a \textbf{JAchar} and an
1912       \textbf{ALchar} (\Param{\hyperlink{fld:xks}{xkanjiskip}}).
1913 %</en>
1914 %<*ja>
1915 \item デフォルトで\textbf{JAchar}と\textbf{ALchar}の間に挿入されるグルー(\Param{\hyperlink{fld:xks}{xkanjiskip}}).
1916 %</ja>
1917 \end{itemize}
1918 %<*en>
1919 The value (a skip) of \Param{\hyperlink{fld:kanjiskip}{kanjiskip}} or 
1920 \Param{\hyperlink{fld:xks}{xkanjiskip}} can be changed as the following.
1921 Note that only their values \emph{at the end of a paragraph or a horizontal box are
1922 adopted in the whole paragraph or the whole horizontal box.
1923 }
1924 %</en>
1925 %<*ja>
1926 \Param{\hyperlink{fld:kanjiskip}{kanjiskip}}や\Param{\hyperlink{fld:xks}{xkanjiskip}}の値
1927 は以下のようにして変更可能である.
1928 %</ja>
1929 \begin{lstlisting}
1930 \ltjsetparameter{kanjiskip={0pt plus 0.4pt minus 0.4pt},
1931                  xkanjiskip={0.25\zw plus 1pt minus 1pt}}
1932 \end{lstlisting}
1933
1934 %<*en>
1935 It may occur that JFM contains the data of ``ideal width of 
1936 \Param{\hyperlink{fld:kanjiskip}{kanjiskip}}''
1937 and/or ``ideal width of \Param{\hyperlink{fld:xks}{xkanjiskip}}''.
1938 To use these data from JFM, set the value of \Param{\hyperlink{fld:kanjiskip}{kanjiskip}} or
1939 \Param{\hyperlink{fld:xks}{xkanjiskip}} to \verb+\maxdimen+.
1940 %</en>
1941 %<*ja>
1942 JFMは「望ましい\Param{\hyperlink{fld:kanjiskip}{kanjiskip}}の値」や
1943 「望ましい\Param{\hyperlink{fld:xks}{xkanjiskip}}の値」を持っていることがある.
1944 これらのデータを使うためには,\Param{\hyperlink{fld:kanjiskip}{kanjiskip}}や%
1945 \Param{\hyperlink{fld:xks}{xkanjiskip}}の値を \verb+\maxdimen+ の値に設定すればよい.
1946 %</ja>
1947
1948 %<en>\subsection{Insertion Setting of \Param{xkanjiskip}}
1949 %<ja>\subsection{\Param{xkanjiskip} の挿入設定}
1950
1951 %<*en>
1952 It is not desirable that \Param{\hyperlink{fld:xks}{xkanjiskip}} is inserted into every
1953 boundary between \textbf{JAchar}s and \textbf{ALchar}s. For example,
1954 \Param{\hyperlink{fld:xks}{xkanjiskip}} should not be inserted after opening parenthesis
1955 (\textit{e.g.}, compare ``(あ'' and ``(\hskip\ltjgetparameter{xkanjiskip}あ'').
1956 \LuaTeX-ja can control whether \Param{\hyperlink{fld:xks}{xkanjiskip}} can be inserted
1957 before/after a character, by changing \Param{jaxspmode} for \textbf{JAchar}s and
1958 \Param{alxspmode} parameters \textbf{ALchar}s respectively.
1959 %</en>
1960 %<*ja>
1961 \Param{\hyperlink{fld:xks}{xkanjiskip}}がすべての\textbf{JAchar}と\textbf{ALchar}の境界に
1962 挿入されるのは望ましいことではない.例えば,\Param{\hyperlink{fld:xks}{xkanjiskip}}は開き括弧の
1963 後には挿入されるべきではない(「(あ」と「(\hskip\ltjgetparameter{xkanjiskip}あ」を
1964 比べてみよ).
1965 \LuaTeX-jaでは\Param{\hyperlink{fld:xks}{xkanjiskip}}をある文字の前/後に挿入するかどうかを,
1966 \textbf{JAchar}に対しては\Param{jaxspmode}を,\textbf{ALchar}に対しては
1967 \Param{alxspmode}をそれぞれ変えることで制御することができる.
1968 %</ja>
1969 \begin{LTXexample}
1970 \ltjsetparameter{jaxspmode={`あ,preonly}, alxspmode={`\!,postonly}}
1971 pあq い!う
1972 \end{LTXexample}
1973
1974 %<*en>
1975 The second argument \texttt{preonly} means that the insertion of
1976 \Param{\hyperlink{fld:xks}{xkanjiskip}} is allowed before this character, but not after.
1977 the other possible values are \texttt{postonly}, \texttt{allow}, and \texttt{
1978 inhibit}.
1979 %</en>
1980 %<*ja>
1981 2つ目の引数の \texttt{preonly}は「\Param{\hyperlink{fld:xks}{xkanjiskip}}の挿入はこの文字の
1982 前でのみ許され,後では許さない」ことを意味する.他に指定可能な値は
1983 \texttt{postonly}, \texttt{allow}, \texttt{inhibit}である.
1984 %</ja>
1985
1986 %<*en>
1987 \Param{jaxspmode} and \Param{alxspmode} use a same table to store the parameters
1988 on the current version. Therefore, line~1 in the code above can be rewritten
1989 as follows:
1990 %</en>
1991 %<*ja>
1992 なお,現行の
1993 仕様では,\Param{jaxspmode}, \Param{alxspmode}はテーブルを共有しており,
1994 上のコードの1行目を次のように変えても同じことになる:
1995 %</ja>
1996 \begin{verbatim}
1997 \ltjsetparameter{alxspmode={`あ,preonly}, jaxspmode={`\!,postonly}}
1998 \end{verbatim}
1999 %<*en>
2000 One can use also numbers to specify these two parameters (see Subsection~\ref{ssec-param}).
2001 %</en>
2002 %<*ja>
2003 また,これら2パラメータには数値で値を指定することもできる(\ref{ssec-param}節を参照).
2004 %</ja>
2005
2006 %<*en>
2007 If you want to enable/disable all insertions of \Param{\hyperlink{fld:kanjiskip}{kanjiskip}} and
2008 \Param{\hyperlink{fld:xks}{xkanjiskip}}, set \Param{autospacing} and \Param{autoxspacing}
2009 parameters to \texttt{true}/\texttt{false}, respectively.
2010 %</en>
2011 %<*ja>
2012 もし全ての\Param{\hyperlink{fld:kanjiskip}{kanjiskip}}と\Param{\hyperlink{fld:xks}{xkanjiskip}}の挿入を有効化/無効化
2013 したければ,それぞれ\Param{autospacing}と\Param{autoxspacing}を
2014 \texttt{true}/\texttt{false}に設定すればよい.
2015 %</ja>
2016
2017 %<en>\subsection{Shifting Baseline}
2018 %<ja>\subsection{ベースラインの移動}
2019 %<*en>
2020 To make a match between a Japanese font and an alphabetic font, sometimes
2021 shifting of the baseline of one of the pair is needed. In \pTeX, this is achieved
2022 by setting \verb+\ybaselineshift+ to a non-zero length (the
2023 baseline of \textbf{ALchar} is shifted below). However, for documents
2024 whose main language is not Japanese, it is good to shift the baseline of
2025 Japanese fonts, but not that of alphabetic fonts.
2026 Because of this, \LuaTeX-ja can independently set the shifting amount
2027 of the baseline of alphabetic fonts (\Param{yalbaselineshift}
2028 parameter) and that of Japanese fonts (\Param{yjabaselineshift}
2029 parameter).
2030 %</en>
2031 %<*ja>
2032 和文フォントと欧文フォントを合わせるためには,時々どちらかのベースラインの移動が
2033 必要になる.\pTeX ではこれは \verb+\ybaselineshift+ を設定することで
2034 なされていた(\textbf{ALchar}のベースラインがその分だけ下がる).しかし,日本語が主ではない
2035 文書に対しては,欧文フォントではなく和文フォントのベースラインを移動した方がよい.
2036 このため,\LuaTeX-jaでは欧文フォントのベースラインのシフト量
2037 (\Param{yalbaselineshift}パラメータ)と和文フォントのベースラインのシフト量
2038 (\Param{yjabaselineshift}パラメータ)を独立に設定できるようになっている.
2039 %</ja>
2040
2041 \begin{LTXexample}
2042 \vrule width 150pt height 0.4pt depth 0pt \hskip-120pt
2043 \ltjsetparameter{yjabaselineshift=0pt, yalbaselineshift=0pt}abcあいう
2044 \ltjsetparameter{yjabaselineshift=5pt, yalbaselineshift=2pt}abcあいう
2045 \end{LTXexample}
2046 %<*en>
2047 Here the horizontal line in above is the baseline of a line.
2048 %</en>
2049 %<*ja>
2050 上の例において引かれている水平線がベースラインである.
2051 %</ja>
2052
2053 %<*en>
2054 There is an interesting side-effect: characters in different size can be
2055 vertically aligned center in a line, by setting two parameters appropriately.
2056 The following is an example (beware the value is not well tuned):
2057 %</en>
2058 %<*ja>
2059 この機能には面白い使い方がある:2つのパラメータを適切に設定することで,サイズの
2060 異なる文字を中心線に揃えることができる.
2061 以下は一つの例である(値はあまり調整されていないことに注意):
2062 %</ja>
2063 \begin{LTXexample}
2064 xyz漢字
2065 {\scriptsize
2066   \ltjsetparameter{yjabaselineshift=-1pt,
2067     yalbaselineshift=-1pt}
2068   XYZひらがな
2069 }abcかな
2070 \end{LTXexample}
2071
2072
2073 %<*ja>
2074 \paragraph{数式における挙動:\pTeX との違い}
2075 \textbf{ALchar}のベースラインを補正する \Param{yalbaselineshift} パラメータは
2076 ほぼ\pTeX における \verb+\ybaselineshift+ に対応しているものであるが,
2077 数式中の挙動は異なっているので注意が必要である.
2078 例えば,表\ref{tab:math_bsa}のように,数式中に明示的に現れた \verb+\hbox+ は,
2079 \begin{itemize}
2080  \item \pTeX では,ボックス全体が \verb+\ybaselineshift+ だとシフトされるので,
2081  表\ref{tab:math_bsa}中の``い''のように,ボックス中の和文文字は
2082  \verb+\ybaselineshift+だけシフトされ,一方,``for all''のように,
2083  ボックス内の欧文文字は2重にシフトされることになる.
2084  \item 一方,\LuaTeX-jaではそのようなことはおこらず,
2085  数式中に明示的に現れた \verb+\hbox+ はシフトしない.そのため,
2086  表\ref{tab:math_bsa}中の``い''も``for all''も,それぞれ本文中に
2087  書かれたときと同じ上下位置に組まれる.
2088 \end{itemize}
2089 \begin{table}
2090 \small\centering
2091 \caption{数式関係のベースライン補正($\Param{yalbaselineshift}=10\,\textrm{pt}$)}
2092 \label{tab:math_bsa}
2093 \newdimen\origbaselineskip
2094 \origbaselineskip=\baselineskip
2095 \begin{tabular}{lp{30\zw}}
2096 \toprule
2097 \emph{入力}&\vspace*{\dimexpr-\origbaselineskip-\smallskipamount}
2098 \begin{verbatim}
2099 数式abc: $あa\hbox{い}$, $\int_0^x t\,dt=x^2\!/2$,
2100 $\Phi\vdash F(x)\ \hbox{for all}\ x\in A$
2101 \end{verbatim}\\
2102 \noalign{\vskip-\origbaselineskip}
2103 \midrule
2104 \emph{\pTeX}&
2105 {\ltjsetparameter{yalbaselineshift=10pt}%
2106 数式abc: $あa\lower10pt\hbox{い}$, $\int_0^x t\,dt=x^2\!/2$,
2107 $\Phi\vdash F(x)\ \lower10pt\hbox{for all}\ x\in A$
2108 \par}\\
2109 \midrule
2110 \emph{\LuaTeX-ja}&
2111 {\ltjsetparameter{yalbaselineshift=10pt}%
2112 数式abc: $あa\hbox{い}$, $\int_0^x t\,dt=x^2\!/2$,
2113 $\Phi\vdash F(x)\ \hbox{for all}\ x\in A$
2114 \par}\\
2115 \noalign{\vskip-\origbaselineskip}
2116 \bottomrule
2117 \end{tabular} 
2118 \end{table}
2119 %</ja>
2120
2121 %<en>\part{Reference}
2122 %<ja>\part{リファレンス}
2123 \label{part-ref}
2124
2125 %<*ja>
2126 \section{\LuaTeX-jaにおける \texttt{\char92catcode}}
2127 \subsection{予備知識:\pTeX と\upTeX における \texttt{\char92kcatcode}}
2128 \pTeX,\upTeX においては,和文文字が制御綴内で利用できるかどうか
2129 は \verb+\kcatcode+ の値によって決定されるのであった.
2130 \verb+\kcatcode+ の値によってどのように変わるかは表\ref{table-kcat}を参照されたい.
2131
2132 \begin{table}[t]
2133 \small
2134 \caption{\texttt{\char92kcatcode} in \upTeX}
2135 \label{table-kcat}
2136
2137 \noindent\hfill
2138 \begin{tabular}{ccccc}
2139 \toprule
2140 \bfseries \verb+\kcatcode+&
2141 \bfseries 意図&
2142 \bfseries 制御綴中に使用&
2143 \bfseries 文字ウィドウ処理\hbox{}$^*$&
2144 \bfseries 直後での改行\\
2145 \midrule
2146 15&non-cjk&\multicolumn{3}{c}{(treated as usual \LaTeX)}\\
2147 16&kanji&Y&Y&ignored\\
2148 17&kana&Y&Y&ignored\\
2149 18&other&N&N&ignored\\
2150 19&hangul&Y&Y&space\\
2151 \bottomrule
2152 \end{tabular}\hfill\null
2153
2154 \medskip
2155
2156 文字ウィドウ処理\hbox{}$^*$: 「漢字が一文字だけ次の行に行くのを防ぐ」\ 
2157 \texttt{\char`\\jcharwidowpenalty} が,
2158 その文字の直前に挿入されうるか否か,を示す.
2159 \end{table} 
2160
2161 \pTeX では \verb+\kcatcode+ はJIS~X~0208の区単位,
2162 \upTeX では概ねUnicodeブロック単位\footnote{%
2163   \texttt{U+FF00}--\texttt{U+FFEF} (Halfwidth and Fullwidth Forms)は
2164   「全角英数字」「半角カナ」「その他」と3つに分割されており,
2165   それぞれ別々に \texttt{\char92kcatcode} が指定できるようになっている.
2166 }で設定可能になっている.そのため,\pTeX と\upTeX の初期状態では
2167 制御綴内で使用可能な文字が微妙に異なっている.
2168
2169 \subsection{\LuaTeX-jaの場合}
2170 \LuaTeX-jaでは,従来の\pTeX・\upTeX における \verb+\kcatcode+ の役割を
2171 分割している:
2172 \begin{description}
2173  \item[欧文/和文の区別 (\upTeX)] 
2174 \verb+\ltjdefcharrange+ と\textsf{jacharrange}パラメータ(\ref{ssec-setrange}節)
2175  \item[制御綴中に使用可か]
2176 \LuaTeX 自身の \verb+\catcode+ でよい
2177  \item[\Param{jcharwidowpenalty}が挿入可か]
2178 \Param{kcatcode}パラメータの最下位ビット
2179  \item[改行をスペースと認識するか]
2180 日本語しか想定していないので\textbf{JAchar}については一律有効
2181 \end{description}
2182
2183
2184 ネイティブにUnicode全部の文字を扱える\XeTeX や\LuaTeX では,
2185 文字が制御綴内で使用できるかは通常の欧文文字と同じく \verb+\catcode+
2186 で指定することとなる.\XeTeX における \verb+\catcode+ の初期設定は\ 
2187 \texttt{unicode-letters.tex} 中に記述されており,\LuaTeX ではそれを
2188 元にした \texttt{luatex-unicode-letters.tex} を用いている.
2189
2190 だが,\XeTeX における \verb+\catcode+ の初期設定と
2191 \LuaTeX におけるそれは一致していない:
2192 \begin{itemize}
2193  \item \texttt{luatex-unicode-letters.tex} の元になった\ 
2194 \texttt{unicode-letters.tex} が古い
2195  \item \texttt{unicode-letters.tex} の後半部では
2196 \verb+\XeTeXcharclass+ の設定を行なっており,
2197 それによって漢字や仮名の \verb+\catcode+ が11に設定されている.
2198
2199 しかし,\texttt{luatex-unicode-letters.tex} ではこの「後半部」が
2200 まるごと省略されており,漢字や仮名の \verb+\catcode+ は12のまま.
2201 \end{itemize}
2202 言い換えると,\LuaTeX の初期状態では漢字や仮名を制御綴内に
2203 使用することはできない.
2204
2205 これでは \pTeX で使用できた \verb+\西暦+ などが使えないこととなり,
2206 \LuaTeX-jaへの移行で手間が生じる.そのため,\LuaTeX-jaでは
2207 \texttt{unicode-letters.tex} の後半部にあたる内容を自前でパッチし,
2208 結果として\textbf{\XeTeX における初期設定と同じになるようにしている.}
2209
2210 \begin{table}
2211  \centering\small
2212 \caption{制御綴中に使用出来るJIS~X~0208非漢字の違い}
2213 \label{table-kcat-diff}
2214 \def\D#1#2#3#4{%
2215   {\fboxsep0pt\fcolorbox{cyan}{white}%
2216   {\large\char"#1#2#3#4}}\ (\texttt{U+#1#2#3#4})} %"
2217 \leavevmode\hbox to 0pt{\hss\begin{tabular}{cccccc}
2218 \toprule
2219 &\bf 区&\bf 点&\bf \pTeX&\bf \upTeX&\fontseries{b}\selectfont\LuaTeX-ja\\
2220 \midrule
2221 \D 3000&1&1&×&×&◯\\
2222 \D 30FB&1&6&×&◯&×\\
2223 \D 309B&1&11&×&◯&×\\
2224 \D 309C&1&12&×&◯&×\\
2225 \D FF40&1&14&×&×&◯\\
2226 \D FF3E&1&16&×&×&◯\\
2227 \D FFE3&1&17&×&×&◯\\
2228 \D FF3F&1&18&×&×&◯\\
2229 \D 30FD&1&19&×&◯&◯\\
2230 \D 30FE&1&20&×&◯&◯\\
2231 \D 309D&1&21&×&◯&◯\\
2232 \D 309E&1&22&×&◯&◯\\
2233 \D 3003&1&23&×&×&◯\\
2234 \D 4EDD&1&24&×&◯&◯\\
2235 \D 3005&1&25&×&×&◯\\
2236 \D 3006&1&26&×&×&◯\\
2237 \D 3007&1&27&×&×&◯\\
2238 \D 30FC&1&28&×&◯&◯\\
2239 \bottomrule
2240 \end{tabular}\qquad
2241 \begin{tabular}{cccccc}
2242 \toprule
2243 &\bf 区&\bf 点&\bf \pTeX&\bf \upTeX&\fontseries{b}\selectfont\LuaTeX-ja\\
2244 \midrule
2245 \D FF0F&1&31&×&×&◯\\
2246 \D FF3C&1&32&×&×&◯\\
2247 \D FF5C&1&35&×&×&◯\\
2248 \D FF0B&1&60&×&×&◯\\
2249 \D FF1D&1&65&×&×&◯\\
2250 \D FF1C&1&67&×&×&◯\\
2251 \D FF1E&1&68&×&×&◯\\
2252 \D FF03&1&84&×&×&◯\\
2253 \D FF06&1&85&×&×&◯\\
2254 \D FF0A&1&86&×&×&◯\\
2255 \D FF20&1&87&×&×&◯\\
2256 \D 3012&2&9&×&×&◯\\
2257 \D 3013&2&14&×&×&◯\\
2258 \D FFE2&2&44&×&×&◯\\
2259 \D 212B&2&82&×&×&◯\\
2260 \multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}ギリシャ文字(6区)}&◯&×&◯\\
2261 \multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}キリル文字(7区)}&×&×&◯\\
2262 $\vphantom{\D 3000}$\\
2263 \bottomrule
2264 \end{tabular}\hss}\par
2265 \end{table}
2266
2267 \subsection{制御綴中に使用出来るJIS非漢字の違い}
2268
2269 エンジンが異なるので,\pTeX, \upTeX, \LuaTeX-ja
2270 において制御綴中に使用可能なJIS~X~0208の文字は異なる.
2271 異なっているところだけを載せると,表\ref{table-kcat-diff}のようになる.
2272 「・」「゛」「゜」「゠」を除けば,\LuaTeX-jaでは\upTeX より多くの文字が
2273 制御綴に使用可能になっている.
2274 \textbf{特に重要なのは,全角空白(\texttt{U+3000})が
2275 \LuaTeX-jaでは制御綴中に使用可能であることである.}
2276
2277 JIS~X~0213の範囲に広げると,差異はさらに大きくなる.
2278 詳細については例えば \url{https://github.com/h-kitagawa/kct} 中の\ 
2279 \texttt{kct-uni-out.pdf} などを参照すること.
2280 %</ja>
2281
2282
2283 %<en>\section{Font Metric and Japanese Font}
2284 %<ja>\section{フォントメトリックと和文フォント}
2285 %<en>\subsection{\texttt{\char92jfont}}
2286 %<ja>\subsection{\texttt{\char92jfont} 命令}
2287 \label{ssec-jfont}
2288
2289 %<*en>
2290 To load a font as a Japanese font, you must use the
2291 \verb+\jfont+ instead of~\verb+\font+, while
2292 \verb+\jfont+ admits the same syntax used in~\verb+\font+.
2293 \LuaTeX-ja automatically loads \Pkg{luaotfload} package,
2294 so TrueType/OpenType fonts with features can be used for Japanese fonts:
2295 %</en>
2296 %<*ja>
2297 フォントを和文フォントとして読み込むためには,\verb+\jfont+ を
2298 \verb+\font+ プリミティブの代わりに用いる.
2299 \verb+\jfont+ の文法は \verb+\font+ と同じである.
2300 \LuaTeX-jaは\Pkg{luaotfload}パッケージを自動的に読み込むので,
2301 TrueType/OpenTypeフォントにfeatureを指定したものを和文フォントとして用いる
2302 ことができる:
2303 %</ja>
2304 \begin{LTXexample}[width=0.3\textwidth]
2305 \jfont\tradgt={file:KozMinPr6N-Regular.otf:script=latn;%
2306   +trad;-kern;jfm=ujis} at 14pt
2307 \tradgt 当/体/医/区
2308 \end{LTXexample}
2309
2310 %<*en>
2311 Note that the defined control sequence
2312 (\verb+\tradgt+ in the example above) using \verb+\jfont+ is not a
2313 \textit{font\_def} token, hence the input like \verb+\fontname\tradgt+
2314 causes a error.  We denote control sequences which are defined in
2315 \verb+\jfont+ by <jfont\_cs>.
2316 %</en>
2317 %<*ja>
2318 なお,\verb+\jfont+ で定義されたコントロールシーケンス(上の例だと \verb+\tradgt+)
2319 は\textit{font\_def}トークンではないので,\verb+\fontname\tradgt+ のような
2320 入力はエラーとなることに注意する.以下では \verb+\jfont+ で定義された
2321 コントロールシーケンスを<jfont\_cs>で表す.
2322 %</ja>
2323
2324 \paragraph{JFM}
2325 %<*en>
2326 As noted in Introduction, a JFM has measurements of characters and
2327 glues/kerns that are automatically inserted for Japanese
2328 typesetting. The structure of JFM will be described in the next
2329 subsection. At the calling of \verb+\jfont+, you must specify
2330 which JFM will be used for this font by the following keys:
2331 %</en>
2332 %<*ja>
2333 「はじめに」の節で述べたように,JFMは文字と和文組版で自動的に挿入される
2334 グルー/カーンの寸法情報を持っている.JFMの構造は次の小節で述べる.
2335 \verb+\jfont+ 命令の呼び出しの際には,どのJFMを用いるのかを以下のキーで
2336 指定する必要がある:
2337 %</ja>
2338
2339 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}\advance\leftmargin1\zw}
2340 \item[jfm=<name>]
2341 %<*en>
2342 Specify the name of JFM. If specified JFM has not been loaded, \LuaTeX-ja search and load
2343 a file named \texttt{jfm-<name>.lua}.
2344
2345 The following JFMs are shipped with \LuaTeX-ja:
2346 %</en>
2347 %<*ja>
2348 JFMの名前を指定する.もし以前に指定されたJFMが読み込まれていなければ,
2349 \texttt{jfm-<name>.lua}を読み込む.以下のJFMが\LuaTeX-jaには同梱されている:
2350 %</ja>
2351 \begin{description}
2352 %<*en>
2353 \item[\tt jfm-ujis.lua] A standard JFM in \LuaTeX-ja. This JFM is
2354   based on \verb+upnmlminr-h.tfm+, a metric for UTF/OTF package that
2355   is used in \upTeX. When you use the \Pkg{luatexja-otf} package, you should use this JFM.
2356 %</en>
2357 %<*ja>
2358 \item[\tt jfm-ujis.lua] \LuaTeX-jaの標準JFMである.このJFMは\upTeX で
2359   用いられるUTF/OTFパッケージ用の和文用TFMである \verb+upnmlminr-h.tfm+ を
2360   元にしている.\Pkg{luatexja-otf}パッケージを使うときはこのJFMを指定するべきである.
2361 %</ja>
2362 %<*en>
2363 \item[\tt jfm-jis.lua] A counterpart for \verb+jis.tfm+, ``JIS font
2364   metric'' which is widely used in \pTeX. A major difference between
2365   \texttt{jfm-ujis.lua} and this \texttt{jfm-jis.lua} is that
2366   most characters under \texttt{jfm-ujis.lua} are square-shaped,
2367   while that under \texttt{jfm-jis.lua} are horizontal
2368   rectangles.
2369 %</en>
2370 %<*ja>
2371 \item[\tt jfm-jis.lua] \pTeX で広く用いられている「JISフォントメトリック」
2372   \verb+jis.tfm+ に相当するJFMである.\texttt{jfm-ujis.lua}とこの
2373   \texttt{jfm-jis.lua}の主な違いは,\texttt{jfm-ujis.lua}ではほとんどの文字が
2374   正方形状であるのに対し,\texttt{jfm-jis.lua}では横長の長方形状である.
2375 %</ja>
2376 %<*en>
2377 \item[\tt jfm-min.lua] A counterpart for \verb+min10.tfm+, which is one
2378   of the default Japanese font metric shipped with \pTeX. There
2379   are notable difference between this JFM and other 2~JFMs, as
2380   shown in Table~\ref{tab-difjfm}.
2381 %</en>
2382 %<*ja>
2383 \item[\tt jfm-min.lua] \pTeX に同梱されているデフォルトの和文用TFM
2384   である \verb+min10.tfm+ に相当するJFMである.このJFMと他の2つのJFMの間には
2385   表\ref{tab-difjfm}に示すような特筆すべき違いがある.
2386 %</ja>
2387 \end{description}
2388
2389 %<*en>
2390 \item[jfmvar=<string>] Sometimes there is a need that \ldots.
2391 %</en>
2392 %<*ja>
2393 \item[jfmvar=<string>] 標準では,JFMとサイズが同じで,
2394   実フォントだけが異なる2つの和文フォントは「区別されない」.例えば
2395 下の例において,最初の「)」と「【」の実フォントは異なるが,
2396 JFMもサイズも同じなので,普通に「)【」と入力した時と同じように半角空きとなる.
2397
2398 しかし,時には……
2399
2400 %</ja>
2401 \begin{LTXexample}[width=0.3\textwidth]
2402 \ltjsetparameter{differentjfm=both}
2403 \jfont\F=file:KozMinPr6N-Regular.otf:jfm=ujis
2404 \jfont\G=file:KozGoPr6N-Medium.otf:jfm=ujis
2405 \jfont\H=file:KozGoPr6N-Medium.otf:jfm=ujis;jfmvar=hoge
2406
2407 \F ){\G 【】}( % halfwidth space
2408    ){\H 『』}( % fullwidth space
2409
2410 \ltjsetparameter{differentjfm=paverage}
2411 \end{LTXexample}
2412 \end{list}
2413
2414 \begin{table}[t]
2415 %<en>\caption{Differences between JFMs shipped with \LuaTeX-ja}
2416 %<ja>\caption{\LuaTeX-ja に同梱されている JFM の違い}
2417 \label{tab-difjfm}
2418 \ltjsetparameter{jacharrange={+3}}
2419 \centering\small
2420 \def\r#1{{\jfont\g=file:KozMinPr6N-Regular.otf:jfm=#1 at 14.43324pt \g
2421 \setbox0=\vtop{\hsize=7\zw\noindent ◆◆◆◆◆◆◆
2422 ある日モモちゃんがお使いで迷子になって泣きました.}\copy0
2423 \vrule height 0pt depth \dp0}}
2424 \def\s#1{{\jfont\g=file:KozMinPr6N-Regular.otf:jfm=#1 at 14.43324pt \g
2425 \setbox0=\vtop{\hsize=7\zw\noindent ちょっと!何}\copy0}}
2426 \def\t#1{{\jfont\g=file:KozMinPr6N-Regular.otf:jfm=#1 at 19.24432pt \g
2427 \setbox0=\hbox{漢}%
2428 \vrule width 0.4pt height\ht0 depth\dp0\kern-.2pt\copy0
2429 \kern-\wd0\vrule width\wd0height .2pt depth .2pt
2430 \kern-\wd0\raise\ht0\hbox{\vrule width\wd0height .2pt depth .2pt}%
2431 \kern-\wd0\lower\dp0\hbox{\vrule width\wd0height .2pt depth .2pt}%
2432 \kern-.2pt\vrule width 0.4pt height\ht0 depth \dp0}}
2433 \begin{tabular}{rccc}
2434 \toprule
2435 &\tt jfm-ujis.lua&\tt jfm-jis.lua&\tt jfm-min.lua\\
2436 \midrule
2437 %<en>Example~1\cite{min10}
2438 %<ja>例1\cite{min10}
2439 &\r{ujis}&\r{jis}&\r{min}\\
2440 %<en>Example~2
2441 %<ja>例2
2442 &\s{ujis}&\s{jis}&\s{min}\\
2443 Bounding Box&\t{ujis}&\t{jis}&\t{min}\\
2444 \bottomrule
2445 \end{tabular}
2446 \ltjsetparameter{jacharrange={-3}}
2447 \end{table}
2448
2449 %<en>\paragraph{Note: kern feature}
2450 %<ja>\paragraph{注意:kern feature}
2451 \label{para-kern}
2452 %<*en>
2453 Some fonts have information for inter-glyph spacing. However, this
2454 information is not well-compatible with \LuaTeX-ja.  More concretely,
2455 this kerning space from this information are inserted \emph{before} the
2456 insertion process of \textbf{JAglue}, and this causes incorrect spacing
2457 between two characters when both a glue/kern from the data in the font
2458 and it from JFM are present.
2459 %</en>
2460 %<*ja>
2461 いくつかのフォントはグリフ間のスペースについての情報を持っている.しかし,
2462 この情報は\LuaTeX-ja とはあまり相性がよくない.具体的には,この情報に基づいて挿入
2463 されるカーニングスペースは\textbf{JAglue}の挿入過程の\textbf{前に}挿入され,
2464 JFMに基づくグルー/カーンも挿入される場合には2文字間の意図しないスペースの原因と
2465 なる.
2466 %</ja>
2467 \begin{itemize}
2468 %<*en>
2469 \item You should specify \texttt{-kern} in
2470   \verb+jfont+ when you want to use other font features,
2471   such as \texttt{script=...}\,.
2472 %</en>
2473 %<*ja>
2474 \item  \texttt{script=...}といったfeatureを使いたい場合には,\verb+\jfont+
2475   に\texttt{-kern}を指定するべきである.
2476 %</ja>
2477 %<*en>
2478 \item If you want to use Japanese fonts in proportional width, and use
2479       information from this font, use \texttt{jfm-prop.lua} for its JFM, and\,\ldots.
2480 %</en>
2481 %<*ja>
2482 \item もしプロポーショナル幅の和文フォントをそのフォントの情報に基づいて使いたい
2483   ならば,\texttt{jfm-prop.lua}をJFMとして指定し,……
2484 %</ja>
2485 TODO: kanjiskip?
2486 \end{itemize}
2487
2488
2489 %<*ja>
2490 \paragraph{\texttt{extend}と\texttt{slant}}
2491 OpenType font featureと見かけ上同じような形式で指定できるものに,
2492 \begin{description}
2493 \item[\texttt{extend=}<extend>] 横方向に<extend>倍拡大する.
2494 \item[\texttt{slant=}<slant>] <slant>に指定された割合だけ傾ける.
2495 \end{description}  
2496 の2つがある.
2497 \texttt{extend}や\texttt{slant}を指定した場合は,それに応じたJFMを指定すべきである%
2498 \footnote{\LuaTeX-jaでは,これらに対するJFMを特に提供することはしない予定である.}.
2499 例えば,次の例では無理やり通常のJFMを使っているために,文字間隔やイタリック補正量が
2500 正しくない:
2501 %</ja>
2502 %<*en>
2503 \paragraph{\texttt{extend} and \texttt{slant}}
2504 The following setting can be specified as OpenType font features:
2505 \begin{description}
2506 \item[\texttt{extend=}<extend>] expand the font horizontally by <extend>.
2507 \item[\texttt{slant=}<slant>] slant the font.
2508 \end{description}
2509 Note that \LuaTeX-ja doesn't adjust JFMs by these \texttt{extend} and \texttt{slant}
2510 settings; you have to write new JFMs on purpose. 
2511 For example, the following example uses the standard JFM \texttt{jfm-ujis.lua}, hence
2512 letter-spacing and the width of italic correction are not correct:
2513 %</en>
2514 \begin{LTXexample}[width=0.3\textwidth]
2515 \jfont\E=file:KozMinPr6N-Regular.otf:extend=1.5;jfm=ujis
2516 \E あいうえお
2517
2518 \jfont\S=file:KozMinPr6N-Regular.otf:slant=1;jfm=ujis
2519 \S あいう\/ABC
2520 \end{LTXexample}
2521
2522
2523 %<en>\subsection{Prefix \texttt{psft}}
2524 %<ja>\subsection{\texttt{psft}プリフィックス}
2525 \label{ssec-psft}
2526 %<*en>
2527 Besides ``\texttt{file:}''\ and ``\texttt{name:}''\ prefixes which
2528 are introduced in the \Pkg{luaotfload} package, 
2529 \LuaTeX-ja adds ``\texttt{psft:}''\ prefix in \verb+\jfont+ (and~\verb+\font+),
2530 to specify a ``name-only'' Japanese font which
2531 will not be embedded to PDF. Typical use of this prefix is to specify
2532 standard, non-embedded Japanese fonts, namely, ``Ryumin-Light'' and
2533 ``GothicBBB-Medium''.
2534
2535 \emph{OpenType font features, such as ``{\tt +jp90}'', 
2536 have no meaning in name-only fonts using this ``{\tt psft:}''\ prefix.
2537 This is because we can't expect what fonts are actually used by the PDF reader.}
2538 Note that \texttt{extend}~and~\texttt{slant} settings (see~above) are supported
2539 with \texttt{psft} prefix, because they are only simple linear transformations.
2540 %</en>
2541 %<*ja>
2542 \Pkg{luaotfload}で使用可能になった
2543 \texttt{file:}\ と \texttt{name:}\ のプリフィックスに加えて,
2544 \verb+\jfont+(と \verb+\font+ プリミティブ)では
2545 \texttt{psft:}プリフィックスを用いることができる.
2546 このプリフィックスを用いることで,PDFには埋め込まれない「名前だけの」
2547 和文フォントを指定することができる.「標準的な」非埋め込み和文フォント,
2548 つまり「Ryumin-Light」「GothicBBB-Medium」の指定でこのプリフィックスが使われる.
2549
2550 \emph{\texttt{psft} プリフィックスの下では
2551 \texttt{+jp90} などのOpenType font featureの効力はない.
2552 非埋込フォントをPDFに使用すると,実際にどのようなフォントが
2553 表示に用いられるか予測できないからである.}\
2554 \texttt{extend} と \texttt{slant} 指定は単なる変形のため
2555 \texttt{psft} プリフィックスでも使用可能である.
2556 %</ja>
2557
2558 %<en>\paragraph{\texttt{cid} key}
2559 %<ja>\paragraph{\texttt{cid}キー}
2560 \label{para-cid}
2561
2562 %<*en>
2563 The default font defined by using \texttt{psft:} prefix is for Japanese typesetting;
2564 it is Adobe-Japan1-6 CID-keyed font.
2565 One can specify \texttt{cid} key to use other CID-keyed non-embedded fonts
2566 for Chinese or Korean typesetting.
2567 %</en>
2568 %<*ja>
2569 標準で\texttt{psft:}プリフィックスで定義されるフォントは日本語用のもので
2570 あり,Adobe-Japan1-6のCIDに対応したものとなる.しかし,\LuaTeX-jaは中国語
2571 の組版にも威力を発揮することが分かり,日本語フォントでない非埋込フォント
2572 の対応も必要となった.そのために追加されたのが\texttt{cid}キーである.
2573
2574 \texttt{cid}キーに値を指定すると,そのCIDを持った非埋込フォントを定義することができる:
2575 %</ja>
2576 \begin{lstlisting}[numbers=left]
2577 \jfont\testJ={psft:Ryumin-Light:cid=Adobe-Japan1-6;jfm=jis}     % Japanese
2578 \jfont\testD={psft:Ryumin-Light:jfm=jis}                        % default value is Adobe-Japan1-6
2579 \jfont\testC={psft:AdobeMingStd-Light:cid=Adobe-CNS1-6;jfm=jis} % Traditional Chinese
2580 \jfont\testG={psft:SimSun:cid=Adobe-GB1-5;jfm=jis}              % Simplified Chinese
2581 \jfont\testK={psft:Batang:cid=Adobe-Korea1-2;jfm=jis}           % Korean
2582 \end{lstlisting}
2583 %<*en>
2584 Note that the code above specifies \texttt{jfm-jis.lua}, which is for Japanese fonts,
2585 as JFM for Chinese and Korean fonts.
2586 %</en>
2587 %<*ja>
2588 上のコードでは中国語・韓国語用フォントに対してもJFMに
2589 日本語用の\texttt{jfm-jis.lua}を指定しているので注意されたい.
2590 %</ja>
2591
2592 %<*en>
2593 At present, \LuaTeX-ja supports only 4 values written in the sample code above.
2594 Specifying other values, e.g.,
2595 %</en>
2596 %<*ja>
2597 今のところ,\LuaTeX-jaは上のサンプルコード中に書いた4つの値しかサポートしていない.
2598 %</ja>
2599 \begin{lstlisting}
2600 \jfont\test={psft:Ryumin-Light:cid=Adobe-Japan2;jfm=jis}
2601 \end{lstlisting}
2602 %<*en>
2603 produces the following error:
2604 %</en>
2605 %<*ja>
2606 のようにそれら以外の値を指定すると,エラーが発生する:
2607 %</ja>
2608 \begin{lstlisting}[numbers=left]
2609 ! Package luatexja Error: bad cid key `Adobe-Japan2'.
2610
2611 See the luatexja package documentation for explanation.
2612 Type  H <return>  for immediate help.
2613 <to be read again>
2614                    \par
2615 l.78
2616
2617 ? h
2618 I couldn't find any non-embedded font information for the CID
2619 `Adobe-Japan2'. For now, I'll use `Adobe-Japan1-6'.
2620 Please contact the LuaTeX-ja project team.
2621 ?
2622 \end{lstlisting}
2623
2624 %<en>\subsection{Structure of JFM file}
2625 %<ja>\subsection{JFMファイルの構造}
2626 \label{ssec-jfm-str}
2627 %<en>A JFM file is a Lua script which has only one function call:
2628 %<ja>JFMファイルはただ一つの関数呼び出しを含むLuaスクリプトである:
2629 \begin{verbatim}
2630 luatexja.jfont.define_jfm { ... }
2631 \end{verbatim}
2632 %<*en>
2633 Real data are stored in the table which indicated above by
2634 \verb+{ ... }+.  So, the rest of this subsection are devoted to describe the
2635 structure of this table.  Note that all lengths in a JFM file are
2636 floating-point numbers in design-size unit.
2637 %</en>
2638 %<*ja>
2639 実際のデータは上で \verb+{ ... }+ で示されたテーブルの中に格納されている.
2640 以下ではこのテーブルの構造について記す.
2641 なお,JFMファイル中の長さは全てdesign-sizeを単位とする浮動小数点数であることに
2642 注意する.
2643 %</ja>
2644
2645 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}\advance\leftmargin1\zw}
2646
2647 \item[dir=<direction>]
2648 %<en>(required)
2649 %<ja>(必須)
2650
2651 %<en>The direction of JFM. At the present, only \texttt{'yoko'} is supported.
2652 %<ja>JFMの書字方向.現時点では横書き(\texttt{'yoko'})のみがサポートされる.
2653
2654 \item[zw=<length>]
2655 %<en>(required)
2656 %<ja>(必須)
2657
2658 %<en>The amount of the length of the ``full-width''.
2659 %<ja>「全角幅」の長さ.
2660
2661 \item[zh=<length>]
2662 %<en>(required)
2663 %<ja>(必須)
2664
2665 %<en>The amount of the ``full-height'' (height + depth). 
2666 %<ja>「全角高さ」(height + depth)の長さ.通常は全角幅と同じ長さになるだろう.
2667
2668 \item[kanjiskip=\{<natural>, <stretch>, <shrink>\}]
2669 %<en>(optional)
2670 %<ja>(任意)
2671
2672 %<*en>
2673 This field specifies the ``ideal'' amount of \Param{\hyperlink{fld:kanjiskip}{kanjiskip}}. As noted
2674              in Subsection~\ref{subs-kskip}, if the parameter
2675              \Param{\hyperlink{fld:kanjiskip}{kanjiskip}} is \verb+\maxdimen+, the value specified
2676              in this field is actually used (if this field is not specified in
2677              JFM, it is regarded as 0\,pt). Note that <stretch> and <shrink>
2678              fields are in design-size unit too.
2679 %</en>
2680 %<*ja>
2681 理想的な\Param{\hyperlink{fld:kanjiskip}{kanjiskip}}の量を指定する.\ref{subs-kskip}節で述べたように,
2682 もし\Param{\hyperlink{fld:kanjiskip}{kanjiskip}}が \verb+\maxdimen+ の値ならば,このフィールドで指定された
2683 値が実際には用いられる(指定なしは0\,ptとして扱われる).<stretch>と<shrink>のフィールドもdesign-size
2684 が単位であることに注意せよ.
2685 %</ja>
2686
2687 \item[xkanjiskip=\{<natural>, <stretch>, <shrink>\}]
2688 %<en>(optional)
2689 %<ja>(任意)
2690
2691 %<*en>
2692 Like the \texttt{kanjiskip} field, this field specifies the ``ideal''
2693              amount of \Param{\hyperlink{fld:xks}{xkanjiskip}}.
2694 %</en>
2695 %<*ja>
2696 \texttt{kanjiskip}フィールドと同様に,\Param{\hyperlink{fld:xks}{xkanjiskip}}の理想的な量を
2697 指定する.
2698 %</ja>
2699 \end{list}
2700
2701 %<*en>
2702 \paragraph{Character classes}
2703 Besides from above fields, a JFM file have several sub-tables those
2704 indices are natural numbers.  The table indexed by~$i\in\omega$ stores
2705 information of \emph{character class}~$i$. At least, the character class~0 is
2706 always present, so each JFM file must have a sub-table whose index is
2707 \texttt{[0]}.  Each sub-table (its numerical index is denoted by $i$) has
2708 the following fields:
2709 %</en>
2710 %<*ja>
2711 \paragraph{文字クラス}
2712 上記のフィールドに加えて,JFMファイルはそのインデックスが自然数であるいくつかの
2713 サブテーブルを持つ.インデックスが$i\in\omega$であるテーブルは\emph{文字クラス}$i$の
2714 情報を格納する.少なくとも,文字クラス0は常に存在するので,JFMファイルはインデックス
2715 が\texttt{[0]}のサブテーブルを持たなければならない.それぞれのサブテーブル
2716 (そのインデックスを$i$で表わす)は以下のフィールドを持つ:
2717 %</ja>
2718
2719 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}\advance\leftmargin1\zw}
2720 \item[chars=\{<character>, ...\}]
2721 %<en>(required except character class~0)
2722 %<ja>(文字クラス0を除いて必須)
2723
2724 %<*en>
2725 This field is a list of characters which are in this character
2726              type~$i$. This field is optional if $i=0$, since all
2727              \textbf{JAchar} which do not belong  any character classes other
2728              than 0 are in the character class 0
2729              (hence, the character class~0 contains most of
2730              \textbf{JAchar}s). In the list, character(s) can be specified in the following form:
2731 \begin{itemize}
2732 \item a Unicode code point
2733 \item the character itself (as a Lua string, like \hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ'+})
2734 \item a string like \hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ*'+} (the character followed by an asterisk)
2735 \item several ``imaginary'' characters (We will describe these later.)
2736 \end{itemize}
2737 %</en>
2738 %<*ja>
2739 このフィールドは文字クラス$i$に属する文字のリストである.このフィールドは$i=0$の
2740 場合には任意である(文字クラス0には,0以外の文字クラスに属するものを
2741 除いた全ての\textbf{JAchar}が属するから).このリスト中で文字を指定するには,以下の方法がある:
2742 \begin{itemize}
2743 \item Unicode におけるコード番号
2744 \item 「\hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ'+}」のような,文字それ自体
2745 \item 「\hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ*'+}」のような,文字それ自体の後にアスタリスクをつけたもの
2746 \item いくつかの「仮想的な文字」(後に説明する)
2747 \end{itemize}
2748 %</ja>
2749
2750 \item[width=<length>, height=<length>, depth=<length>, italic=<length>]
2751 %<en>(required)
2752 %<ja>(必須)
2753
2754 %<*en>
2755 Specifythe width of characters in character class~$i$, the height, the depth and
2756 the amount of italic correction. All characters in character class~$i$ are regarded that its width, height, and depth are
2757 as values of these fields.
2758 But there is one exception: if \texttt{'prop'} is specified in \texttt{width} field, width of a character becomes that of its ``real'' glyph.
2759 %</en>
2760 %<*ja>
2761 文字クラス$i$に属する文字の幅,高さ,深さ,イタリック補正の量を指定する.
2762 文字クラス$i$に属する全ての文字は,その幅,高さ,深さがこのフィールドで指定した
2763 値であるものとして扱われる.
2764 しかし,例外が一つある:もし \texttt{'prop'} が \texttt{width} フィールドに
2765 指定された場合,文字の幅はその「実際の」グリフの幅となる.
2766 %</ja>
2767
2768 \item[left=<length>, down=<length>, align=<align>]\
2769
2770 %<*en>
2771 These fields are for adjusting the position of the ``real'' glyph. Legal
2772              values of \texttt{align} field are \texttt{'left'},
2773              \texttt{'middle'}, and \texttt{'right'}. If one of these
2774              3~fields are omitted, \texttt{left} and \texttt{down} are
2775              treated as~0, and \texttt{align} field is treated as
2776              \texttt{'left'}.
2777 The effects of these 3~fields are indicated in Figure~\ref{fig-pos}.
2778 %</en>
2779 %<*ja>
2780 これらのフィールドは実際のグリフの位置を調整するためにある.
2781 \texttt{align} フィールドに指定できる値は \texttt{'left'}, \texttt{'middle'},
2782 \texttt{'right'} のいずれかである.もしこれら3つのフィールドのうちの1つが省かれた
2783 場合,\texttt{left} と \texttt{down} は0,\texttt{align} フィールドは
2784 \ \texttt{'left'} であるものとして扱われる.
2785 これら3つのフィールドの意味については図\ref{fig-pos}で説明する.
2786 %</ja>
2787
2788 %<*en>
2789 In most cases, \texttt{left} and \texttt{down} fields are~0, while
2790 it is not uncommon that the \texttt{align} field is \texttt{'middle'} or \texttt{'right'}.
2791 For example, setting the \texttt{align} field to \texttt{'right'} is practically needed
2792 when the current character class is the class for opening delimiters'.
2793 %</en>
2794 %<*ja>
2795 多くの場合,\texttt{left}と\texttt{down}は0である一方,
2796 \texttt{align}フィールドが\texttt{'middle'}や\texttt{'right'}であることは
2797 珍しいことではない.
2798 例えば,\texttt{align}フィールドを\texttt{'right'}に指定することは,
2799 文字クラスが開き括弧類であるときに実際必要である.
2800 %</ja>
2801
2802 \begin{figure}[!tb]
2803 \begin{minipage}{0.4\textwidth}%
2804 \begin{center}\unitlength=10pt\small
2805 \begin{picture}(15,12)(-1,-4)
2806 \color{black!10!white}% real glyph :step1
2807 \put(0,0){\vrule width 12\unitlength height 8\unitlength depth 3\unitlength}
2808
2809 \color{red!20!white}% real glyph :step1
2810 \put(-1,-1.5){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
2811
2812 \color{red}% real glyph
2813 \thicklines
2814 \put(-1,-1.5){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
2815 \put(5,-1.5){\line(0,1){7}\line(0,-1){2.5}}
2816 \put(-1,5.5){\line(1,0){6}}
2817 \put(-1,-4){\line(1,0){6}}
2818
2819 \color{green!20!white}% real glyph :step1
2820 \put(3,0){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
2821
2822 \color{black}% real glyph :step1
2823 \thicklines
2824 \put(0,0){\vector(0,1){8}\line(0,-1){3}\vector(1,0){12}}
2825 \put(12,0){\line(0,1){8}\vector(0,-1){3}}
2826 \put(0,8){\line(1,0){12}}
2827 \put(0,-3){\line(1,0){12}}
2828 \put(0.2,4){\makebox(0,0)[l]{\texttt{height}}}
2829 \put(12.2,-1.5){\makebox(0,0)[l]{\texttt{depth}}}
2830 \put(6,0.2){\makebox(0,0)[b]{\texttt{width}}}
2831
2832 \color{green!50!black}% real glyph :step1
2833 \thicklines
2834 \put(3,0){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
2835 \put(9,0){\line(0,1){7}\line(0,-1){2.5}}
2836 \put(3,7){\line(1,0){6}}
2837 \put(3,-2.5){\line(1,0){6}}
2838 \newsavebox{\eqdist}
2839 \savebox{\eqdist}(0,0)[b]{%
2840   \thinlines
2841   \put(-0.08,0.2){\line(0,-1){0.4}}%
2842   \put(0.08,0.2){\line(0,-1){0.4}}}
2843 \put(1.5,0){\usebox{\eqdist}}
2844 \put(10.5,0){\usebox{\eqdist}}
2845
2846 \color{blue}% shifted
2847 \thicklines
2848 \put(3,-1.5){\vector(-1,0){4}}
2849 \put(1,-1.7){\makebox(0,0)[t]{\texttt{left}}}
2850 \put(3,0){\vector(0,-1){1.5}}
2851 \put(3.2,-0.75){\makebox(0,0)[l]{\texttt{down}}}
2852 \end{picture}
2853 \end{center}
2854 \end{minipage}%
2855 \begin{minipage}{0.6\textwidth}%
2856 %<*en>
2857 Consider a node containing Japanese character whose value of the \texttt{align}
2858 field is \texttt{'middle'}.
2859 %</en>
2860 %<*ja>
2861 \texttt{align}フィールドの値が\texttt{'middle'}である和文文字を含むノードを
2862 考えよう.
2863 %</ja>
2864 \begin{itemize}
2865 \item
2866 %<*en>
2867 The black rectangle is a frame of the node.
2868 Its width, height, and depth are specified by JFM.
2869 %</en>
2870 %<*ja>
2871 黒色の長方形はノードの枠である.
2872 その幅,高さ,深さはJFMによって指定される.
2873 %</ja>
2874 \item
2875 %<*en>
2876 Since the \texttt{align} field is \texttt{'middle'},
2877 the ``real'' glyph is centered horizontally (the green rectangle).
2878 %</en>
2879 %<*ja>
2880 \texttt{align}フィールドは\texttt{middle}なので,実際のグリフは
2881 水平方向の中心に配置される(緑色の長方形).
2882 %</ja>
2883 \item
2884 %<*en>
2885 Furthermore, the glyph is shifted according to values of fields
2886       \texttt{left} and \texttt{down}. The ultimate position of the real
2887       glyph is indicated by the red rectangle.
2888 %</en>
2889 %<*ja>
2890 さらに,グリフは\texttt{left}と\texttt{down}の値に従ってシフトされる.
2891 最終的な実際のグリフの位置は赤色の長方形で示された位置になる.
2892 %</ja>
2893 \end{itemize}
2894 \end{minipage}
2895 \medskip
2896
2897 \caption{%
2898 %<en>The position of the real glyph.
2899 %<ja>「実際の」グリフの位置.
2900 }
2901 \label{fig-pos}
2902 \end{figure}
2903
2904 \item[kern={\{[$j$]=<kern>, [$j'$]=\{<kern>, [<ratio>]\}, ...\}}]
2905
2906 \item[glue={\{[$j$]=\{<width>, <stretch>, <shrink>, [<priority>], [<ratio>]\}, ...\}}]
2907 %<*ja>
2908 文字クラス$i$の文字と$j$の文字の間に挿入されるkernやglueの量を指定する.
2909
2910              <priority>は \Pkg{luatexja-adjust} による優先順位付き
2911              行長調整(\ref{ssec-adj}節)が有効なときのみ意味を持つ.
2912 このフィールドは省略可能であり,行調整処理におけるこのglueの優先
2913              度を$-2$から$+2$の間の整数で指定する.<priority>の省略時の値
2914              は0であり,範囲外の値が指定されたときの動作は未定義である.
2915
2916 <ratio>も省略可能フィールドであり,$-1$から$+1$の実数値をとる.省略時の値は0である.
2917 \begin{itemize}
2918 \item $-1$はこのグルーが「前の文字」由来であることを示す.
2919 \item $+1$はこのグルーが「後の文字」由来であることを示す.
2920 \item それ以外の値は,「前の文字」由来のグルーと「後の文字」由来の
2921 グルーが混合されていることを示す.
2922 \end{itemize}
2923 なお,このフィールドの値は\Param{\hyperlink{fld:diffjfm}{differentjfm}}の値が
2924 \texttt{pleft},~\texttt{pright},~\texttt{paverage}の値のときのみ実際に用いられる.
2925
2926 例えば,\cite{x4051}では,句点と中点の間には,
2927 句点由来の二分空きと中点由来の四分空きが挿入されるが,この場合には
2928 \begin{itemize}
2929 \item <width>には$0.5+0.25=0.75$を指定する.
2930 \item <ratio>には次の値を指定する.
2931 \[
2932  -1\cdot \frac{0.5}{0.5+0.25} + 1 \cdot \frac{0.25}{0.5+0.25} = -\frac13
2933 \]
2934 \end{itemize}
2935 %</ja>
2936 %<*en>
2937 Specifies the width of kern or glue which will be inserted 
2938 between characters in character class~$i$ and those in character class~$j$.
2939
2940 <priority> is an integer in $[-2,2]$ (treated as 0 if omitted), and this is
2941 used only in line adjustment with priority by \Pkg{luatexja-adjust}
2942 (see Subsection~\ref{ssec-adj}). 
2943
2944 <ratio> is \dots
2945 %</en>
2946
2947
2948 \item[end\_stretch=<kern>]
2949 \item[end\_shrink=<kern>]
2950 %<*ja>
2951 これらのフィールドは省略可能である.
2952 優先順位付き行長調整が有効であり,かつ現在の文字クラスの文字が行
2953              末に来た時に,行長を詰める調整・伸ばす調整のた
2954              めにこの文字と行末の間に挿入可能なカーンの大きさを指定する.
2955 %</ja>
2956
2957 \end{list}
2958
2959 %<*ja>
2960 \paragraph{文字クラスの決定}
2961 文字からその文字の属する文字クラスを算出する過程は少々複雑である.
2962 次の内容を一部に含んだ \texttt{jfm-test.lua} を用いて説明する.
2963 \begin{lstlisting}
2964    [0] = {
2965       chars = { '漢', 'ヒ*' },
2966       align = 'left', left = 0.0, down = 0.0,
2967       width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
2968    },
2969    [2000] = {
2970       chars = { '。', '、*', 'ヒ' },
2971       align = 'left', left = 0.0, down = 0.0,
2972       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
2973    },
2974 \end{lstlisting}
2975 句点「。」の幅は二分であるので
2976 \begin{LTXexample}[width=0.3\textwidth]
2977 \jfont\a=file:KozMinPr6N-Regular.otf:jfm=test;+vert
2978 \setbox0\hbox{\a 。\inhibitglue 漢}
2979 \the\wd0
2980 \end{LTXexample}
2981 では,全角二分(15.0\,pt)となるのが自然……と思うかもしれないが,上の実行結果では20\,ptとなっている.
2982 それは以下の事情によるものである:
2983 \begin{enumerate}
2984 \item \verb+vert+ featureによって句点が縦書き用のグリフと置き換わる(\Pkg{luaotfload} による処理).
2985 \item しかしこのグリフは「文字コード」\texttt{U+F0000}以降とみなされている
2986 (実際にいくらになるかは,フォントによって異なる).
2987 \item よって,文字クラス0とみなされるため,結果として「。」の幅は全角だと認識されてしまう.
2988 \end{enumerate}
2989
2990 一方,「\texttt{'、*'}」のようにアスタリスクつきの指定があると,
2991 状況は異なってくる.
2992 \begin{LTXexample}[width=0.3\textwidth]
2993 \jfont\a=file:KozMinPr6N-Regular.otf:jfm=test;+vert
2994 \a 漢、\inhibitglue 漢
2995 \end{LTXexample}
2996 ここで,読点「、」の文字クラスは,以下のようにして決まる.
2997 \begin{enumerate}
2998 \item とりあえず句点の時と同じように,\Pkg{luaotfload} によって縦書き用読点のグリフに置き換わる.
2999 \item 置換後のグリフの「文字コード」は\texttt{U+F0000}以降であり,
3000 そのままでは文字クラスは0と判定される.
3001 \item ところが,JFMには「\texttt{'、*'}」指定があるので,置換前の横書き用読点のグリフ「、」(\texttt{U+3001})によって文字クラスを判定する.
3002 \item 結果として,上の出力例中の読点の文字クラスは2000となる.
3003 \end{enumerate}
3004
3005 なお,置換後のグリフで判定した文字クラスの値が0でなければ,そちらをそのまま作用する.
3006 \begin{LTXexample}[width=0.3\textwidth]
3007 \jfont\a=file:KozMinPr6N-Regular.otf:jfm=test;+hwid
3008 \a 漢ヒひ
3009 \end{LTXexample}
3010 上の例では,
3011 \texttt{hwid} featureにより,「ヒ」が半角の「ヒ」に置き換わるが,
3012 文字クラスは「ヒ」の属する0\emph{ではなく},「ヒ」の属する2000となる.
3013 %</ja>
3014
3015 %<ja>\paragraph{仮想的な文字}
3016 %<en>\paragraph{Imaginary characters}
3017 %<*en>
3018 As described before, you can specify several \emph{imaginary characters} in
3019 \texttt{chars} field. The most of these characters are regarded as the
3020 characters of class 0 in \pTeX.
3021 As a result, \LuaTeX-ja can control typesetting finer than \pTeX.
3022 The following is the list of imaginary characters:
3023 %</en>
3024 %<*ja>
3025 上で説明した通り,\texttt{chars}フィールド中にはいくつかの「特殊文字」も
3026 指定可能である.これらは,大半が\pTeX のJFMグルーの挿入処理ではみな「文字
3027 クラス0の文字」として扱われていた文字であり,その結果として\pTeX より細か
3028 い組版調整ができるようになっている.以下でその一覧を述べる:
3029 %</ja>
3030
3031 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}\advance\leftmargin1\zw}
3032 %%\item['diffmet']
3033 %%<en>Used at a boundary between two \textbf{JAchar}s whose JFM or size is different.
3034 %%<ja>JFMやサイズが異なる2つの\textbf{JAchar}の間の境界として用いられる.
3035
3036 \item['boxbdd']
3037 %<en>The beginning/ending of a horizontal box, and the beginning of a noindented paragraph.
3038 %<ja>水平ボックスの先頭と末尾,及びインデントされていない(\verb+\noindent+ で開始された)段落の先頭を表す.
3039
3040 \item['parbdd']
3041 %<en>The beginning of an (indented) paragraph.
3042 %<ja>通常の(\verb+\noindent+ で開始されていない)段落の先頭.
3043
3044 \item['jcharbdd']
3045 %<en>A boundary between \textbf{JAchar} and anything else (such as \textbf{ALchar}, kern, glue,\,\ldots).
3046 %<ja>和文文字と「その他のもの」(欧文文字,glue,kern等)との境界.
3047
3048 \item[$-1$]
3049 %<en>The left/right boundary of an inline math formula.
3050 %<ja>行中数式と地の文との境界.
3051 \end{list}
3052
3053 %<en>\paragraph{Porting JFM from \pTeX}
3054 %<ja>\paragraph{\pTeX 用和文用TFMの移植}
3055
3056 % ToDo: English version.
3057
3058 %<*en>
3059 \ldots
3060 %</en>
3061
3062 %<*ja>
3063 以下に,\pTeX 用に作られた和文用TFMを\LuaTeX-ja用に移植する場合の注意点を挙げておく.
3064 \begin{itemize}
3065 \item 実際に出力される和文フォントのサイズがdesign sizeとなる.
3066 このため,例えば$1\,\textrm{zw}$がdesign sizeの0.962216倍であるJISフォン
3067       トメトリック等を移植する場合は,次のようにするべきである:
3068 \begin{itemize}
3069 \item JFM中の全ての数値を$1/0.962216$倍しておく.
3070 \item \TeX ソース中で使用するところで,サイズ指定を0.962216倍にする.
3071       \LaTeX でのフォント宣言なら,例えば次のように:
3072 \begin{verbatim}
3073 \DeclareFontShape{JY3}{mc}{m}{n}{<-> s*[0.962216] psft:Ryumin-Light:jfm=jis}{}
3074 \end{verbatim}
3075 \end{itemize}
3076 \item 上に述べた特殊文字は,\texttt{'boxbdd'}を除き文字クラスを全部0とする
3077       (JFM中に単に書かなければよい).
3078 \item \texttt{'boxbdd'}については,それのみで一つの文字クラスを形成し,その
3079       文字クラスに関してはグルー/カーンの設定はしない.
3080
3081 これは,\pTeX では,
3082       水平ボックスの先頭・末尾とインデントされていない(\verb+\noindent+ で開始さ
3083       れた)段落の先頭にはJFMグルーは入らないという仕様を実現させるためである.
3084 \item \pTeX の組版を再現させようというのが目的であれば以上の注意を守れば十分である.
3085
3086 ところで,\pTeX では通常の段落の先頭にJFMグルーが残るという仕様があるので,
3087       段落先頭の開き括弧は全角二分下がりになる.全角下がりを実現させるに
3088       は,段落の最初に手動で \verb+\inhibitglue+ を追加するか,あるいは
3089       \ \verb+\everypar+ のハックを行い,それを自動化させるしかなかった.
3090
3091 一方,\LuaTeX-jaでは,\texttt{'parbdd'}によって,それがJFM側で調整できるよ
3092 うになった.例えば,\LuaTeX-ja同梱のJFMのように,\texttt{'boxbdd'}と同じ文字クラスに
3093 \texttt{'parbdd'}を入れれば全角下がりとなる.
3094
3095 \begin{LTXexample}[width=0.4\textwidth]
3096 \jfont\g=file:KozMinPr6N-Regular.otf:jfm=test \g
3097 \parindent1\zw\noindent{}◆◆◆◆◆
3098 \par 「◆◆←二分下がり
3099 \par 【◆◆←全角下がり
3100 \par 〔◆◆←全角二分下がり
3101 \end{LTXexample}
3102 \end{itemize}
3103
3104 但し,\verb+\everypar+ を利用している場合にはこの仕組みは正しく動かない.
3105 そのような例としては箇条書き中の \verb+\item+ で始まる段落があり,\Pkg{ltjsclasses}では
3106 人工的に「\texttt{'parbdd'}の意味を持つ」whatsitノードを作ることによって対処している%
3107 \footnote{\texttt{ltjsclasses.dtx} を参照されたい.
3108 JFM側で一部の対処ができることにより,\Pkg{jsclasses}のようにif文の判定はしていない.}.
3109 %</ja>
3110
3111
3112 %<en>\subsection{Math Font Family}
3113 %<ja>\subsection{数式フォントファミリ}
3114 \label{ssec-math}
3115
3116 %<*en>
3117 \TeX\ handles fonts in math formulas by 16~font families\footnote{Omega,
3118 Aleph, \LuaTeX~and $\varepsilon$-\kern-.125em(u)\pTeX\ can handles 256~families, but
3119 an external package is needed to support this in plain \TeX\ and
3120 \LaTeX.}, and each family has three fonts:
3121 \verb+\textfont+, \verb+\scriptfont+ and \verb+\scriptscriptfont+.
3122 %</en>
3123 %<*ja>
3124 \TeX\ は数式フォントを16のファミリ\footnote{Omega, Aleph, \LuaTeX,そして
3125   $\varepsilon$-\kern-.125em(u)\pTeX\ では256の数式ファミリを扱うことができるが,
3126   これをサポートするためにplain \TeX と\LaTeX では外部パッケージを読み込む必要が
3127   ある.}で管理し,それぞれのファミリは3つのフォントを持っている:
3128 \verb+\textfont+, \verb+\scriptfont+ そして \verb+\scriptscriptfont+ である.
3129 %</ja>
3130
3131 %<*en>
3132 \LuaTeX-ja's handling of Japanese fonts in math formulas is similar;
3133 Table~\ref{tab-math} shows counterparts to \TeX's primitives for math
3134 font families. There is no relation between the value of
3135 \verb+\fam+ and that of \verb+\jfam+; with appropriate settings,
3136 you can set both \verb+\fam+ and \verb+\jfam+ to the same value.
3137 %</en>
3138 %<*ja>
3139 \LuaTeX-jaの数式中での和文フォントの扱いも同様である.
3140 表\ref{tab-math}は数式フォントファミリに対する \TeX のプリミティブと対応する
3141 ものを示している.\verb+\fam+ と \verb+\jfam+ の値の間には関係はなく,
3142 適切な設定の下では \verb+\fam+ と \verb+\jfam+ の両方に同じ値を設定することができる.
3143 %</ja>
3144
3145 \begin{table}[!tb]
3146 %<en>\caption{Control sequences for Japanese math fonts}
3147 %<ja>\caption{和文数式フォントに対する命令}
3148 \label{tab-math}
3149 \centering
3150 \def\{{\char`\{}\def\}{\char`\}}\small
3151 \begin{tabular}{ll}
3152 \toprule
3153 %<en>\bf Japanese fonts&\bf alphabetic fonts\\
3154 %<ja>\bf 和文フォント&\bf 欧文フォント\\
3155 \midrule
3156 \verb+\jfam+${}\in [0,256)$&\verb+\fam+\\
3157 \tt\Param{jatextfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\verb+\textfont+<fam>=<font\_cs>\\
3158 \tt\Param{jascriptfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\verb+\scriptfont+<fam>=<font\_cs>\\
3159 \tt\Param{jascriptscriptfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\verb+\scriptscriptfont+<fam>=<font\_cs>\\
3160 \bottomrule
3161 \end{tabular}
3162 \end{table}
3163
3164 %<en>\subsection{Callbacks}
3165 %<ja>\subsection{コールバック}
3166
3167 %<*en>
3168 Like \LuaTeX\ itself, \LuaTeX-ja also has callbacks. These callbacks can
3169 be accessed via \verb+luatexbase.add_to_callback+ function and so on, as other callbacks.
3170 %</en>
3171 %<*ja>
3172 \LuaTeX 自体のものに加えて,\LuaTeX-jaもコールバックを持っている.
3173 これらのコールバックには,他のコールバックと同様に \verb+luatexbase.add_to_callback+
3174 関数などを用いることでアクセスすることができる.
3175 %</ja>
3176 \begin{list}{}%
3177 {\def\makelabel#1{\bfseries#1}}
3178 %<en>\item[\texttt{luatexja.load\_jfm} callback]
3179 %<ja>\item[\texttt{luatexja.load\_jfm}コールバック]
3180 %<*en>
3181 With this callback you can overwrite JFMs.
3182 This callback is called when a new JFM is loaded.
3183 %</en>
3184 %<*ja>
3185 このコールバックを用いることでJFMを上書きすることができる.
3186 このコールバックは新しいJFMが読み込まれるときに呼び出される.
3187 %</ja>
3188
3189 \begin{lstlisting}[numbers=left]
3190 function (<table> jfm_info, <string> jfm_name)
3191   return <table> new_jfm_info
3192 end
3193 \end{lstlisting}
3194
3195 %<*en>
3196 The argument \verb+jfm_info+ contains a table similar to the table in a JFM file, except
3197 this argument has \texttt{chars} field which contains character codes
3198              whose character class is not~0.
3199 %</en>
3200 %<*ja>
3201 引数 \verb+jfm_info+ はJFMファイルのテーブルと似たものが格納されるが,
3202 クラス0を除いた文字のコードを含んだ\texttt{chars}フィールドを持つ点が異なる.
3203 %</ja>
3204
3205 %<*en>
3206 An example of this callback is the \texttt{ltjarticle} class, with
3207              forcefully assigning character class~0 to \texttt{'parbdd'}
3208              in the JFM \texttt{jfm-min.lua}.
3209 %</en>
3210 %<*ja>
3211 このコールバックの使用例は\texttt{ltjarticle}クラスにあり,
3212 \texttt{jfm-min.lua}中の\texttt{'parbdd'}を強制的にクラス0に割り当てている.
3213 %</ja>
3214
3215 %<en>\item[\texttt{luatexja.define\_font} callback]
3216 %<ja>\item[\texttt{luatexja.define\_font}コールバック]
3217 %<*en>
3218 This callback and the next callback form a pair, and you can assign letters which don't have
3219              fixed code points in Unicode to non-zero character classes.
3220 This \texttt{luatexja.define\_font} callback is called just when new Japanese font is loaded.
3221 %</en>
3222 %<*ja>
3223 このコールバックと次のコールバックは組をなしており,Unicode中に固定された文字コード
3224 番号を持たない文字を非零の文字クラスに割り当てることができる.
3225 このコールバックは新しい和文フォントが読み込まれたときに呼び出される.
3226 %</ja>
3227
3228 \begin{lstlisting}[numbers=left]
3229 function (<table> jfont_info, <number> font_number)
3230   return <table> new_jfont_info
3231 end
3232 \end{lstlisting}
3233
3234 %<*en>
3235 You may assume that \verb+jfont_info+ has the following fields:
3236 %</en>
3237 %<*ja>
3238 \verb+jfont_info+ は以下の2フィールドを持つ:
3239 %</ja>
3240 \begin{description}
3241 \item[\tt size\_cache]
3242 %<*ja>
3243 使用されているJFMの情報が格納されているテーブルで,
3244 \emph{このテーブルを書き換えてはならない}.
3245 中身はほぼJFMファイルに書かれている唯一のテーブルであるが,次のように若干変わっている:
3246 \begin{itemize}
3247 \item 各文字クラス$i$に属する文字達のテーブル\
3248 \texttt{[$i$].chars=\{<character>, ...\}} は,トップレベルにまとめられ,
3249 \texttt{chars=\{[<character>]=\,$i$, ...\}} という形になっている.
3250 \item \texttt{zw},~\texttt{zh}, \texttt{kanjiskip},~\texttt{xkanjiskip} の各フィールドの値は,
3251 実際に使われるフォントサイズに合わせたsp ($1\,\mathrm{sp}=2^{-16}\,\mathrm{pt}$)単位の長さに変わっている.
3252 \item 各文字クラス$i$の情報を格納したテーブルも,\texttt{char\_type} フィールドの下にまとめられている.
3253 例えば,文字クラス1に属する文字の高さは \texttt{char\_type[1].height} で参照できる.
3254 \item \texttt{dir} フィールドはこのテーブルにはない.
3255 \end{itemize}
3256 %</ja>
3257 %<*en>
3258 A table which contains the information of a JFM, and \emph{this table must not be changed}.
3259 The contents of this table are similar to that which is written is the JFM file, but
3260 the following differ:
3261 \begin{itemize}
3262 \item There is a \texttt{chars} table, \dots
3263 \item The value in \texttt{zw},~\texttt{zh}, \texttt{kanjiskip},~\texttt{xkanjiskip} fields are
3264 now scaled by real font size, and in scaled-pont unit.
3265 \item ...
3266 \item There is no \texttt{dir} field in this table.
3267 \end{itemize}
3268 %</en>
3269
3270 \item[\tt var]
3271 %<en>The value specified in \texttt{jfmvar=...} at a call of \verb+\jfont+.
3272 %<ja>\verb+\jfont+ の呼び出しの際に\texttt{jfmvar=...}で指定された値.
3273 \end{description}
3274
3275 %<*en>
3276 The returned table \verb+new_jfont_info+ also should include these two fields.
3277 The \verb+font_number+ is a font number.
3278 %</en>
3279 %<*ja>
3280 戻り値の \verb+new_jfont_info+ テーブルもこれら2つのフィールドを含まなければならないが,
3281 それ以外にユーザが勝手にフィールドを付け加えることは自由である.
3282 \verb+font_number+ はフォント番号である.
3283 %</ja>
3284
3285 %<*en>
3286 A good example of this and the next callbacks is the \Pkg{luatexja-otf}
3287              package, supporting \verb+"AJ1-xxx"+ form for Adobe-Japan1
3288              CID characters in a JFM. This callback doesn't replace any
3289              code of \LuaTeX-ja.
3290 %</en>
3291 %<*ja>
3292 これと次のコールバックの良い使用例は\Pkg{luatexja-otf}パッケージであり,
3293 JFM中でAdobe-Japan1 CIDの文字を \verb+"AJ1-xxx"+ の形で指定するために
3294 用いられている.
3295 %</ja>
3296
3297 %<en>\item[\texttt{luatexja.find\_char\_class} callback]
3298 %<ja>\item[\texttt{luatexja.find\_char\_class}コールバック]
3299 %<*en>
3300 This callback is called just when \LuaTeX-ja is trying to determine which
3301              character class a character \verb+chr_code+ belongs.
3302 A function used in this callback should be in the following form:
3303 %</en>
3304 %<*ja>
3305 このコールバックは\LuaTeX-jaが \verb+chr_code+ の文字がどの文字クラスに
3306 属するかを決定しようとする際に呼び出される.
3307 このコールバックで呼び出される関数は次の形をしていなければならない:
3308 %</ja>
3309 \begin{lstlisting}[numbers=left]
3310 function (<number> char_class, <table> jfont_info, <number> chr_code)
3311   if char_class~=0 then return char_class
3312   else
3313     ....
3314     return (<number> new_char_class or 0)
3315   end
3316 end
3317 \end{lstlisting}
3318
3319 %<*en>
3320 The argument \verb+char_class+ is the result of \LuaTeX-ja's default
3321              routine or previous function calls in this callback, hence
3322              this argument may not be 0. Moreover, the returned
3323              \verb+new_char_class+ should be as same as \verb+char_class+ when \verb+char_class+
3324              is not~0, otherwise you will overwrite the \LuaTeX-ja's
3325              default routine.
3326 %</en>
3327 %<*ja>
3328 引数 \verb+char_class+ は\LuaTeX-jaのデフォルトルーチンか,このコールバックの
3329 直前の関数呼び出しの結果を含んでおり,したがってこの値は0ではないかもしれない.
3330 さらに,戻り値の \verb+new_char_class+ は \verb+char_class+ が非零のときには
3331 \verb+char_class+ の値と同じであるべきで,そうでないときは\LuaTeX-jaの
3332 デフォルトルーチンを書き換えることになる.
3333 %</ja>
3334
3335 %<en>\item[\texttt{luatexja.set\_width} callback]
3336 %<ja>\item[\texttt{luatexja.set\_width}コールバック]
3337 %<*en>
3338 This callback is called when \LuaTeX-ja is trying to encapsule a
3339              \textbf{JAchar} \textit{glyph\_node}, to adjust its
3340              dimension and position.
3341 %</en>
3342 %<*ja>
3343 このコールバックは\LuaTeX-jaが\textbf{JAchar}の寸法と位置を調節するために
3344 その\textit{glyph\_node}をカプセル化しようとする際に呼び出される.
3345 %</ja>
3346 \begin{lstlisting}[numbers=left]
3347 function (<table> shift_info, <table> jfont_info, <number> char_class)
3348   return <table> new_shift_info
3349 end
3350 \end{lstlisting}
3351
3352 %<*en>
3353 The argument \verb+shift_info+ and the returned \verb+new_shift_info+ have
3354 \texttt{down} and \texttt{left} fields, which are the amount of shifting
3355              down/left the character in a scaled-point.
3356 %</en>
3357 %<*ja>
3358 引数 \verb+shift_info+ と戻り値の \verb+new_shift_info+ は
3359 \texttt{down}と\texttt{left}のフィールドを持ち,これらの値は
3360 文字の下/左へのシフト量(スケールド・ポイント単位)である.
3361 %</ja>
3362
3363 %<*en>
3364 A good example is \Pkg{test/valign.lua}.
3365 After loading this file, the vertical position of glyphs is automatically
3366 adjusted; the ratio $(\hbox{height}:\hbox{depth})$ of glyphs is adjusted
3367 to be that of letters in the character class~0. For example, suppose that
3368 \begin{itemize}
3369 \item The setting of the JFM: $(\hbox{height})=88x$, $(\hbox{depth})=12x$
3370   (the standard values of Japanese OpenType fonts);
3371 \item The value of the real font: $(\hbox{height})=28y$, $(\hbox{depth})=5y$
3372   (the standard values of Japanese TrueType fonts).
3373 \end{itemize}
3374 Then, the position of glyphs is shifted up by
3375 %</en>
3376 %<*ja>
3377 良い例が\Pkg{test/valign.lua}である.このファイルが読み込まれた状態では,
3378              JFM内で規定された文字クラス0の文字における$(\hbox{高
3379              さ}):(\hbox{深さ})$の比になるように,実際のフォントの出力上
3380              下位置が自動調整される.例えば,
3381 \begin{itemize}
3382 \item JFM側の設定:$(\hbox{高さ})=88x$, $(\hbox{深さ})=12x$%
3383 (和文OpenTypeフォントの標準値)
3384 \item 実フォント側の数値:$(\hbox{高さ})=28y$, $(\hbox{深さ})=5y$(和文TrueTypeフォントの標準値)
3385 \end{itemize}
3386 となっていたとする.すると,実際の文字の出力位置は,以下の量だけ上にぜらされることとなる:
3387 %</ja>
3388 \[
3389  \frac{88x}{88x+12x} (28y+5y) - 28y = \frac{26}{25}y= 1.04y.
3390 \]
3391 \end{list}
3392
3393
3394
3395 %<en>\section{Parameters}
3396 %<ja>\section{パラメータ}
3397 \subsection{\texttt{\char`\\ltjsetparameter}}
3398
3399 %<*en>
3400 As described before, \verb+\ltjsetparameter+ and \verb+\ltjgetparameter+ are
3401 control sequences for accessing most parameters of \LuaTeX-ja. One of the main
3402 reason that \LuaTeX-ja didn't adopted the syntax similar to that of \pTeX\
3403 (\textit{e.g.},~\verb+\prebreakpenalty`)=10000+)
3404 is the position of \verb+hpack_filter+ callback in the source
3405 of \LuaTeX, see Section~\ref{sec-para}.
3406 %</en>
3407 %<*ja>
3408 先に述べたように,\verb+\ltjsetparameter+ と \verb+\ltjgetparameter+ は
3409 \LuaTeX-jaのほとんどのパラメータにアクセスするための命令である.
3410 \LuaTeX-jaが\pTeX のような文法(例えば,\verb+\prebreakpenalty`)=10000+)を
3411 採用しない理由の一つは,\LuaTeX のソースにおける \verb+hpack_filter+
3412 コールバックの位置にある.\ref{sec-para}節を参照.
3413 %</ja>
3414
3415 %<*en>
3416 \verb+\ltjsetparameter+ and \verb+\ltjglobalsetparameter+ are control sequences
3417 for assigning parameters. These take one argument which is a
3418 \texttt{<key>=<value>} list. 
3419 The list of allowed keys are described in the next subsection.
3420 The difference between
3421 \verb+\ltjsetparameter+ and \verb+\ltjglobalsetparameter+ is only the
3422 scope of assignment;
3423 \verb+\ltjsetparameter+ does a local assignment and
3424 \verb+\ltjglobalsetparameter+ does a global one.
3425 They also obey the value of \verb+\globaldefs+,
3426 like other assignment.
3427 %</en>
3428 %<*ja>
3429 \verb+\ltjsetparameter+ と \verb+\ltjglobalsetparameter+ はパラメータを
3430 指定するための命令である.これらは\texttt{<key>=<value>}のリストを
3431 引数としてとる.許されるキーの一覧は次の節にある.
3432 \verb+\ltjsetparameter+ と \verb+\ltjglobalsetparameter+ の違いはスコープの
3433 違いのみで,
3434 \verb+\ltjsetparameter+ はローカルな指定,\verb+\ltjglobalsetparameter+ は
3435 グローバルな指定を行う.
3436 これらは他のパラメータ指定と同様に \verb+\globaldefs+ の値に従う.
3437 %</ja>
3438
3439 %<*en>
3440 \verb+\ltjgetparameter+ is for acquiring parameters. It
3441 always takes a parameter name as first argument, and also takes the
3442 additional argument---a character code, for example---in some cases.
3443 %</en>
3444 %<*ja>
3445 \verb+\ltjgetparameter+ はパラメータの値を取得するための命令であり,
3446 常にパラメータの名前を第一引数にとる.
3447 そして,いくつかの場合には加えてさらに引数(例えば文字コード)をとる.
3448 %</ja>
3449 \begin{LTXexample}
3450 \ltjgetparameter{differentjfm},
3451 \ltjgetparameter{autospacing},
3452 \ltjgetparameter{prebreakpenalty}{`)}.
3453 \end{LTXexample}
3454 %<*en>
3455 \emph{The return value of\/ {\normalfont\tt\char92ltjgetparameter} is
3456 always a string}. This is outputted by \texttt{tex.write()}, so any
3457 character other than space~``\texttt{\char32}''~(\texttt{U+0020}) has the category code
3458 12~(other), while the space has 10~(space).
3459 %</en>
3460 %<*ja>
3461 \emph{{\normalfont\tt\char92ltjgetparameter}の戻り値は常に文字列である.}
3462 これは\texttt{tex.write()}によって出力しているためで,空白「\texttt{\char32}」
3463 (\texttt{U+0020})を除いた文字のカテゴリーコードは全て12~(other)となる.
3464 一方,空白のカテゴリーコードは10~(space)である.
3465 %</ja>
3466
3467 %<en>\subsection{List of Parameters}
3468 %<ja>\subsection{パラメータ一覧}
3469 \label{ssec-param}
3470
3471 %<*en>
3472 The following is the list of parameters which can be specified by the
3473 \verb+\ltjsetparameter+ command. [\verb+\cs+] indicates the counterpart
3474 in \pTeX, and symbols beside each parameter has the following meaning:
3475 %</en>
3476 %<*ja>
3477 以下は \verb+\ltjsetparameter+ に指定することができるパラメータの一覧である.
3478 [\verb+\cs+]は\pTeX における対応物を示す.
3479 また,それぞれのパラメータの右上にある記号には次の意味がある:
3480 %</ja>
3481 \begin{itemize}
3482 %<*en>
3483 \item ``\ast'' : values at the end of a paragraph or a horizontal box are
3484 adopted in the whole paragraph or the whole horizontal box.
3485 %</en>
3486 %<*ja>
3487 \item ``\ast'':段落や水平ボックスの終端での値がその段落/水平ボックス全体で用いられる.
3488 %</ja>
3489 %<*en>
3490 \item ``\dagger'': assignments are always global.
3491 %</en>
3492 %<*ja>
3493 \item ``\dagger'':指定は常にグローバルになる.
3494 %</ja>
3495 \end{itemize}
3496
3497 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}\advance\leftmargin1\zw}
3498 \item[\Param{jcharwidowpenalty}\,=<penalty>$^\ast$] [\verb+\jcharwidowpenalty+]
3499 %<*en>
3500 Penalty value for suppressing orphans. This penalty is inserted just
3501              after the last \textbf{JAchar} which is not regarded as a
3502              (Japanese) punctuation mark.
3503 %</en>
3504 %<*ja>
3505 パラグラフの最後の字が孤立して改行されるのを防ぐためのペナルティの値.
3506 このペナルティは(日本語の)句読点として扱われない最後の\textbf{JAchar}の直後に
3507 挿入される.
3508 %</ja>
3509
3510 \item[\Param{kcatcode}\,=\{<chr\_code>,<natural number>\}$^\ast$]\
3511 %<*en>
3512 An additional attributes which each character whose character code is <chr\_code> has.
3513 At the present version, the lowermost bit of <natural number> indicates
3514              whether the character is considered as a punctuation mark
3515              (see the description of \Param{jcharwidowpenalty} above).
3516 %</en>
3517 %<*ja>
3518 文字コードが<chr\_code>の文字が持つ付加的な属性値(attribute).
3519 現在のバージョンでは,<natural number>の最下位ビットが,その文字が句読点と
3520 みなされるかどうかを表している(上の\Param{jcharwidowpenalty}の記述を参照).
3521 %</ja>
3522
3523 \item[\Param{\hypertarget{fld:prebp}{prebreakpenalty}}\,=\{<chr\_code>,<penalty>\}$^\ast$] [\verb+\prebreakpenalty+]\
3524 %<*ja>
3525 文字コード<chr\_code>の\textbf{JAchar}が行頭にくることを抑止するために,
3526              この文字の前に挿入/追加されるペナルティの量を指定する.
3527
3528 例えば閉じ括弧「〗」は絶対に行頭にきてはならないので,
3529 \begin{verbatim}
3530 \ltjsetparameter{prebreakpenalty={`〙,10000}}
3531 \end{verbatim}
3532 と,最大値の10000が標準で指定されている.他にも,小書きのカナなど,絶対禁止とい
3533              うわけではないができれば行頭にはきて欲しくない場合に,0と
3534              10000の間の値を指定するのも有用であろう.
3535 %</ja>
3536 %<*en>
3537 Set a penalty which is inserted automatically before the character <chr\_code>,
3538 to prevent a line starts from this character. For example, a line cannot started
3539 with one of closing brackets ``〗'', so \LuaTeX-ja sets
3540 \begin{verbatim}
3541 \ltjsetparameter{prebreakpenalty={`〙,10000}}
3542 \end{verbatim}
3543 by default.
3544 %</en>
3545
3546
3547 \item[\Param{\hypertarget{fld:postbp}{postbreakpenalty}}\,=\{<chr\_code>,<penalty>\}$^\ast$] [\verb+\postbreakpenalty+]
3548 %<*ja>
3549 文字コード<chr\_code>の\textbf{JAchar}が行末にくることを抑止するために,
3550              この文字の後に挿入/追加されるペナルティの量を指定する.
3551
3552 \pTeX では,\verb+\prebreakpenalty+, \verb+\postbreakpenalty+において,
3553 \begin{itemize}
3554 \item 一つの文字に対して,pre, postどちらか一つしか指定することができなかっ
3555       た(後から指定した方で上書きされる).
3556 \item pre, post合わせて256文字分の情報を格納することしかできなかった.
3557 \end{itemize}
3558 という制限があったが,\LuaTeX-jaではこれらの制限は解消されている.
3559 %</ja>
3560 %<*en>
3561 Set a penalty which is inserted automatically after the character <chr\_code>,
3562 to prevent a line ends with this character. 
3563 \pTeX\ has following restrictions on \verb+\prebreakpenalty+ and \verb+\postbreakpenalty+,
3564 but they don't exist in \LuaTeX-ja:
3565 \dots
3566 %</en>
3567
3568 \item[\Param{jatextfont}\,=\{<jfam>,<jfont\_cs>\}$^\ast$]
3569 %<en>[\verb+\textfont+ in \TeX]
3570 %<ja>[\TeX の \verb+\textfont+]
3571 \item[\Param{jascriptfont}\,=\{<jfam>,<jfont\_cs>\}$^\ast$]
3572 %<en>[\verb+\scriptfont+ in \TeX]
3573 %<ja>[\TeX の \verb+\scriptfont+]
3574 \item[\Param{jascriptscriptfont}\,=\{<jfam>,<jfont\_cs>\}$^\ast$]
3575 %<en>[\verb+\scriptscriptfont+ in \TeX]
3576 %<ja>[\TeX の \verb+\scriptscriptfont+]
3577 \item[\Param{yjabaselineshift}\,=<dimen>]\
3578 \item[\Param{yalbaselineshift}\,=<dimen>] [\verb+\ybaselineshift+]
3579
3580 \item[\Param{jaxspmode}\,=\{<chr\_code>,<mode>\}$^\ast$]
3581
3582 %<*en>
3583 Setting whether inserting \Param{\hyperlink{fld:xks}{xkanjiskip}} is allowed before/after a \textbf{JAchar} whose character code is <chr\_code>.
3584 The followings are allowed for <mode>:
3585 %</en>
3586 %<*ja>
3587 文字コードが<chr\_code>の\textbf{JAchar}の前/後ろに\Param{\hyperlink{fld:xks}{xkanjiskip}}の
3588 挿入を許すかどうかの設定.
3589 以下の<mode>が許される:
3590 %</ja>
3591 \begin{description}
3592 %<en>\item[0, \texttt{inhibit}] Insertion of \Param{\hyperlink{fld:xks}{xkanjiskip}} is inhibited before the character, nor after the character.
3593 %<ja>\item[0, \texttt{inhibit}] \Param{\hyperlink{fld:xks}{xkanjiskip}}の挿入は文字の前/後ろのいずれでも禁止される.
3594 %<en>\item[1, \texttt{preonly}] Insertion of \Param{\hyperlink{fld:xks}{xkanjiskip}} is allowed before the character, but not after.
3595 %<ja>\item[1, \texttt{preonly}] \Param{\hyperlink{fld:xks}{xkanjiskip}}の挿入は文字の前では許されるが,後ろでは許されない.
3596 %<en>\item[2, \texttt{postonly}] Insertion of \Param{\hyperlink{fld:xks}{xkanjiskip}} is allowed after the character, but not before.
3597 %<ja>\item[2, \texttt{postonly}] \Param{\hyperlink{fld:xks}{xkanjiskip}}の挿入は文字の後ろでは許されるが,前では許されない.
3598 %<en>\item[3, \texttt{allow}] Insertion of \Param{\hyperlink{fld:xks}{xkanjiskip}} is allowed both before the character and after the character. This is the default value.
3599 %<ja>\item[3, \texttt{allow}] \Param{\hyperlink{fld:xks}{xkanjiskip}}の挿入は文字の前/後ろのいずれでも許される.これがデフォルトの値である.
3600 \end{description}
3601 %<*en>
3602 This parameter is similar to the \verb+\inhibitxspcode+ primitive of \pTeX, but not compatible with \verb+\inhibitxspcode+.
3603 %</en>
3604 %<*ja>
3605 このパラメータは\pTeX の \verb+\inhibitxspcode+ プリミティブと似ているが,
3606 互換性はない.
3607 %</ja>
3608 \item[\Param{alxspmode}\,=\{<chr\_code>,<mode>\}$^\ast$] [\verb+\xspcode+]
3609
3610 %<*en>
3611 Setting whether inserting \Param{\hyperlink{fld:xks}{xkanjiskip}} is allowed before/after a
3612              \textbf{ALchar} whose character code is <chr\_code>.
3613              The followings are allowed for <mode>:
3614 %</en>
3615 %<*ja>
3616 文字コードが<chr\_code>の\textbf{ALchar}の前/後ろに\Param{\hyperlink{fld:xks}{xkanjiskip}}の
3617 挿入を許すかどうかの設定.
3618 以下の<mode>が許される:
3619 %</ja>
3620 \begin{description}
3621 %<en>\item[0, \texttt{inhibit}] Insertion of \Param{\hyperlink{fld:xks}{xkanjiskip}} is inhibited before the character, nor after the character.
3622 %<ja>\item[0, \texttt{inhibit}] \Param{\hyperlink{fld:xks}{xkanjiskip}}の挿入は文字の前/後ろのいずれでも禁止される.
3623 %<en>\item[1, \texttt{preonly}] Insertion of \Param{\hyperlink{fld:xks}{xkanjiskip}} is allowed before the character, but not after.
3624 %<ja>\item[1, \texttt{preonly}] \Param{\hyperlink{fld:xks}{xkanjiskip}}の挿入は文字の前では許されるが,後ろでは許されない.
3625 %<en>\item[2, \texttt{postonly}] Insertion of \Param{\hyperlink{fld:xks}{xkanjiskip}} is allowed after the character, but not before.
3626 %<ja>\item[2, \texttt{postonly}] \Param{\hyperlink{fld:xks}{xkanjiskip}}の挿入は文字の後ろでは許されるが,前では許されない.
3627 %<en>\item[3, \texttt{allow}] Insertion of \Param{\hyperlink{fld:xks}{xkanjiskip}} is allowed before the character and after the character. This is the default value.
3628 %<ja>\item[3, \texttt{allow}] \Param{\hyperlink{fld:xks}{xkanjiskip}}の挿入は文字の前/後ろのいずれでも許される.これがデフォルトの値である.
3629 \end{description}
3630 %<*en>
3631 Note that parameters \Param{jaxspmode} and \Param{alxspmode} share a common table, hence these two parameters are synonyms of each other.
3632 %</en>
3633 %<*ja>
3634 \Param{jaxspmode}と\Param{alxspmode}は共通のテーブルを用いているため,
3635 これら2つのパラメータは互いの異名となっていることに注意する.
3636 %</ja>
3637
3638 \item[\Param{autospacing}\,=<bool>] [\verb+\autospacing+]
3639 \item[\Param{autoxspacing}\,=<bool>] [\verb+\autoxspacing+]
3640 \item[\Param{\hypertarget{fld:kanjiskip}{kanjiskip}}\,=<skip>$^\ast$] [\verb+\kanjiskip+]
3641 %<*ja>
3642 デフォルトで2つの\textbf{JAchar}の間に挿入されるグルーである.
3643 通常では,\pTeX と同じようにフォントサイズに比例して変わることはない.
3644 しかし,自然長が \verb+\maxdimen+ の場合は,例外的に和文フォントのJFM側で指定されている
3645 値を採用(こちらはフォントサイズに比例)することになっている.
3646 %</ja>
3647
3648 \item[\Param{\hypertarget{fld:xks}{xkanjiskip}}\,=<skip>$^\ast$] [\verb+\xkanjiskip+]
3649 %<*ja>
3650 デフォルトで\textbf{JAchar}と\textbf{ALchar}の間に挿入されるグルーである.
3651 \Param{\hyperlink{fld:kanjiskip}{kanjiskip}}と同じように,通常ではフォントサイズに比例して変わることはないが,
3652 自然長が \verb+\maxdimen+ の場合が例外である.
3653 %</ja>
3654
3655
3656 \item[\Param{\hypertarget{fld:diffjfm}{differentjfm}}\,=<mode>$^\dagger$]
3657
3658 %<*en>
3659 Specify how glues/kerns between two \textbf{JAchar}s whose JFM (or size) are different.
3660 The allowed arguments are the followings:
3661 %</en>
3662 %<*ja>
3663 JFM(もしくはサイズ)が異なる2つの\textbf{JAchar}の間にグルー/カーンをどのように
3664 入れるかを指定する.
3665 許される値は以下の通り:
3666 %</ja>
3667 \begin{quote}
3668 \texttt{average}, 
3669 \texttt{both}, 
3670 \texttt{large}, 
3671 \texttt{small}, 
3672 \texttt{pleft}, 
3673 \texttt{pright}, 
3674 \texttt{paverage}
3675 \end{quote}
3676 %<*en>
3677 The default value is \texttt{paverage}. \dots
3678 %</en>
3679 %<*ja>
3680 デフォルト値は \texttt{paverage} である.
3681 各々の値による差異の詳細は\ref{ssec-cluster-wa}節の「『右空白』の算出」を参照してほしい.
3682 %</ja>
3683
3684 \item[\Param{jacharrange}\,=<ranges>]
3685 \item[\Param{kansujichar}\,=\{<digit>, <chr\_code>\}$^\ast$] [\verb+\kansujichar+]
3686 \end{list}
3687
3688
3689 %<en>\section{Other Control Sequences for plain \TeX\ and \LaTeXe}
3690 %<ja>\section{plainでも\LaTeX でも利用可能なその他の命令}
3691 %<en>\subsection{Control Sequences for Compatibility with \pTeX}
3692 %<ja>\subsection{\pTeX 互換用命令}
3693
3694 %<*en>
3695 The following control sequences are implemented for compatibility with \pTeX.
3696 Note that these don't support JIS~X~0213, but only JIS~X~0208.
3697 %</en>
3698 %<*ja>
3699 以下の命令は\pTeX との互換性のために実装されている.そのため,JIS~X~0213には対応せず,
3700 \pTeX と同じようにJIS~X~0208の範囲しかサポートしていない.
3701 %</ja>
3702 \begin{center}
3703 \verb+\kuten+, \verb+\jis+, \verb+\euc+, \verb+\sjis+, \verb+\jis+, \verb+\kansuji+
3704 \end{center}
3705 %<*en>
3706 These 6 control sequence takes an internal integer, and returns a \emph{string}.
3707 %</en>
3708 %<*ja>
3709 これら6命令は内部整数を引数とするが,実行結果は\textbf{文字列}であることに注意.
3710 %</ja>
3711 \begin{LTXexample}
3712 \newcount\hoge
3713 \hoge="2423 %"
3714 \the\hoge, \kansuji\hoge\\
3715 \jis\hoge, \char\jis\hoge\\
3716 \kansuji1701
3717 \end{LTXexample}
3718
3719
3720
3721 %<en>\subsection{\texttt{\char`\\inhibitglue}}
3722 %<ja>\subsection{\texttt{\char`\\inhibitglue}}
3723 %<*en>
3724 \verb+\inhibitglue+ suppresses the insertion of \textbf{JAglue}.
3725 The following is an example, using a special JFM that there will be a glue between
3726 the beginning of a box and ``あ'', and also between ``あ''~and~``ウ''.
3727 %</en>
3728 %<*ja>
3729 \verb+\inhibitglue+ は\textbf{JAglue}の挿入を抑制する.
3730 以下は,ボックスの始めと「あ」の間,「あ」「ウ」の間にグルーが入る特別なJFMを用いた例で
3731 ある.
3732 %</ja>
3733
3734 \begin{LTXexample}
3735 \jfont\g=file:KozMinPr6N-Regular.otf:jfm=test \g
3736 \fbox{\hbox{あウあ\inhibitglue ウ}}
3737 \inhibitglue\par\noindent あ1
3738 \par\inhibitglue\noindent あ2
3739 \par\noindent\inhibitglue あ3
3740 \par\hrule\noindent あoff\inhibitglue ice
3741 \end{LTXexample}
3742
3743 %<*en>
3744 With the help of this example, we remark the specification of \verb+\inhibitglue+:
3745 %</en>
3746 %<*ja>
3747 この例を援用して,\verb+\inhibitglue+ の仕様について述べる.
3748 %</ja>
3749 \begin{itemize}
3750 %<*en>
3751 \item The call of \verb+\inhibitglue+ in the (internal) vertical mode is
3752       simply ignored.
3753 %</en>
3754 %<*ja>
3755 \item \verb+\inhibitglue+ の垂直モード中での呼び出しは意味を持たない.
3756 4行目の入力で有効にならないのは,\verb+\inhibitglue+ の時点では垂直モードであり,
3757 \verb+\noindent+ の時点で水平モードになるからである.
3758 %</ja>
3759
3760 %<*en>
3761 \item The call of \verb+\inhibitglue+ in the (restricted) horizontal
3762       mode is only effective on the spot; does not get over boundary of
3763       paragraphs. Moreover, \verb+\inhibitglue+ cancels ligatures and
3764       kernings, as shown in the last line of above example.
3765 %</en>
3766 %<*ja>
3767 \item \verb+\inhibitglue+ の(制限された)水平モード中での呼び出しはその場でのみ
3768   有効であり,段落の境界を乗り越えない.
3769   さらに,\verb+\inhibitglue+ は上の例の最終行のように(欧文における)リガチャとカーニングを
3770   打ち消す.これは,\verb+\inhibitglue+ が内部的には「現在のリスト中にwhatsitノードを
3771   追加する」ことを行なっているからである.
3772 %</ja>
3773
3774 %<*en>
3775 \item The call of \verb+\inhibitglue+ in math mode is just ignored.
3776 %</en>
3777 %<*ja>
3778 \item \verb+\inhibitglue+ を数式モード中で呼び出した場合はただ無視される.
3779 %</ja>
3780
3781 %<*ja>
3782 \item \LaTeX で\LuaTeX-ja を使用する場合は,
3783 \verb+\inhibitglue+ の代わりとして \verb+\<+ を使うことができる.
3784 既に \verb+\<+ が定義されていた場合は,\LuaTeX-ja の読み込みで強制的に上書きされるので
3785 注意すること.
3786 %</ja>
3787 \end{itemize}
3788
3789
3790 \subsection{\texttt{\char`\\ltjdeclarealtfont}}
3791 \label{ssec-altfont}
3792 %<en>\dots
3793 %<*ja>
3794 \verb+\jfont+ の書式を見ればわかるように,基本的には\LuaTeX-jaにおける1つの和文フォントに
3795 使用出来る「実際のフォント」は1つである.
3796 しかし,\verb+\ltjdeclarealtfont+ を用いると,この原則から外れることができる.
3797
3798 \verb+\ltjdeclarealtfont+ は以下の書式で使用する:
3799 \begin{quote}
3800 \ttfamily \char`\\ltjdeclarealtfont<base\_font\_cs><alt\_font\_cs>{<range>}
3801 \end{quote}
3802 これは「現在の和文フォント」が<base\_font\_cs>であるとき,
3803 <range>に属する文字は<alt\_font\_cs>を用いて組版される,という意味である.
3804 \begin{itemize}
3805  \item <base\_font\_cs>, <alt\_font\_cs>は
3806 \verb+\jfont+ によって定義された和文フォントである.
3807  \item <range>は文字コードの範囲を表すコンマ区切りのリストであるが,
3808    例外として負数$-n$は「<base\_font\_cs>のJFMの文字クラス$n$に属する全ての文字」
3809    を意味する.
3810
3811 <range>中に<alt\_font\_cs>中に実際には存在しない文字が指定された場合は,
3812 その文字に対する設定は無視される.
3813 \end{itemize}
3814
3815 例えば,\verb+\hoge+ のJFMが\LuaTeX-ja標準の
3816 \ \texttt{jfm-ujis.lua} であった場合,
3817 \begin{verbatim}
3818 \ltjdeclarealtfont\hoge\piyo{"3000-"30FF, {-1}-{-1}}
3819 \end{verbatim}
3820 は「\verb+\hoge+ を利用しているとき,
3821 \texttt{U+3000}-\texttt{U+30FF}と
3822 文字クラス1(開き括弧類)中の文字だけは \verb+\piyo+ を用いる」
3823 ことを設定する.\verb+{-1}-{-1}+ という変わった指定の仕方をしているのは,
3824 普通に \texttt{-1} と指定したのでは正しく$-1$と読み取られないという
3825 マクロの都合による.
3826 %</ja>
3827
3828
3829
3830 %<en>\section{Control Sequences for \LaTeXe}
3831 %<ja>\section{\LaTeXe 用の命令}
3832
3833 %<en>\subsection{Patch for NFSS2}
3834 %<ja>\subsection{NFSS2へのパッチ}
3835 \label{ssub-nfsspat}
3836
3837 \begin{figure}[!tb]
3838 \begin{lstlisting}[numberstyle=\tiny, numbers=left, numbersep=1em]
3839 \DeclareKanjiFamily{JY3}{edm}{}
3840 \DeclareFontShape{JY3}{edm}{m}{n}    {<-> s*IPAexMincho:jfm=ujis}{}
3841 \DeclareFontShape{JY3}{edm}{m}{green}{<-> s*IPAexMincho:jfm=ujis;color=007F00}{}
3842 \DeclareFontShape{JY3}{edm}{m}{blue} {<-> s*IPAexMincho:jfm=ujis;color=0000FF}{}
3843 \DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{green}{"4E00-"67FF,{-2}-{-2}}
3844 \DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{blue}{ "6800-"9FFF}
3845 {\kanjifamily{edm}\selectfont
3846 日本国民は、正当に選挙された国会における代表者を通じて行動し、……}
3847 \end{lstlisting}
3848 \begin{quote}
3849 \DeclareKanjiFamily{JY3}{edm}{}
3850 \DeclareFontShape{JY3}{edm}{m}{n}    {<-> s*KozMinPr6N-Regular:jfm=ujis}{}
3851 \DeclareFontShape{JY3}{edm}{m}{green}{<-> s*KozMinPr6N-Regular:jfm=ujis;color=007F00}{}
3852 \DeclareFontShape{JY3}{edm}{m}{blue} {<-> s*KozMinPr6N-Regular:jfm=ujis;color=0000FF}{}
3853 \DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{green}{"4E00-"67FF,{-2}-{-2}}
3854 \DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{blue}{ "6800-"9FFF}
3855
3856 {\kanjifamily{edm}\selectfont
3857 日本国民は、正当に選挙された国会における代表者を通じて行動し、……}
3858 \end{quote}
3859 %<ja>\caption{\texttt{\char92DeclareAlternateKanjiFont} の使用例}
3860 %<en>\caption{An example of \texttt{\char92DeclareAlternateKanjiFont}}
3861 \label{fig:altkanji}
3862 \end{figure}
3863
3864 %<*en>
3865 As described in Subsection~\ref{ssec-ltx}, Japanese patch for NFSS2 in \LuaTeX-ja
3866 is based on \texttt{plfonts.dtx} which plays the same role in \pLaTeXe.
3867 For an convenience, we will describe
3868 control sequences which are not described in Subsection~\ref{ssub-chgfnt}.
3869 %</en>
3870 %<*ja>
3871 \ref{ssec-ltx}節で述べたように,\LuaTeX-jaのNFSS2への日本語パッチは
3872 \pLaTeXe で同様の役割を果たす \texttt{plfonts.dtx} をほぼそのまま利用している.
3873 便宜のため,ここでは\ref{ssub-chgfnt}節で述べていなかった命令について
3874 記述しておく.
3875 %</ja>
3876
3877 \begin{cslist}%
3878 \item[DeclareYokoKanjiEncoding\{<encoding>\}\{<text-settings>\}\{<math-settings>\}]
3879
3880 %<*en>
3881 In NFSS2 under \LuaTeX-ja, distinction between alphabetic font families
3882              and Japanese font families are only made by their
3883              encodings. For example, encodings OT1 and T1 are for
3884              alphabetic font families, and a Japanese font family cannot
3885              have these encodings. This command defines a new encoding
3886              scheme for Japanese font family (in horizontal direction).
3887 %</en>
3888 %<*ja>
3889 \LuaTeX-jaのNFSS2においては,欧文フォントファミリと和文フォントファミリは
3890 そのエンコーディングによってのみ区別される.
3891 例えば,OT1とT1のエンコーディングは欧文フォントファミリに対するものであり,
3892 和文フォントファミリはこれらのエンコーディングを持つことはできない.
3893 このコマンドは横書き用和文フォントのための新しいエンコーディングを
3894 定義する.
3895 %</ja>
3896
3897 \item[DeclareKanjiEncodingDefaults\{<text-settings>\}\{<math-settings>\}]
3898 \item[DeclareKanjiSubstitution\{<encoding>\}\{<family>\}\{<series>\}\{<shape>\}]
3899 \item[DeclareErrorKanjiFont\{<encoding>\}\{<family>\}\{<series>\}\{<shape>\}\{<size>\}]
3900
3901 %<*en>
3902 The above 3~commands are just the counterparts for \verb+DeclareFontEncodingDefaults+ and~others.
3903 %</en>
3904 %<*ja>
3905 上記3つのコマンドはちょうど \verb+DeclareFontEncodingDefaults+ などに対応するものである.
3906 %</ja>
3907
3908 \item[reDeclareMathAlphabet\{<unified-cmd>\}\{<al-cmd>\}\{<ja-cmd>\}]
3909
3910 % ToDo: en
3911 %<*ja>
3912 和文・欧文の数式用フォントファミリを一度に変更する命令を作成する.
3913 具体的には,欧文数式用フォントファミリ変更の命令<al-cmd>(\verb+\mathrm+ 等)と,和文数式用フォ
3914              ントファミリ変更の命令<ja-cmd>(\verb+\mathmc+ 等)の2つを同時に行う命令として
3915              <unified-cmd>を(再)定義する.実際の使用では<unified-cmd>と
3916              <al-cmd>に同じものを指定する,すなわち,<al-cmd>で和文側も変
3917              更させるようにするのが一般的と思われる.
3918
3919 本命令は
3920 {\let\item=\origitem
3921 \begin{center}\tt
3922 <unified-cmd>\{<arg>\}\quad$\longrightarrow$\quad
3923 (<al-cmd>の1段展開結果)\{<ja-cmd>の1段展開結果)\{<arg>\}\}
3924 \end{center}
3925 と定義を行うので,使用には注意が必要である:
3926 \vspace{-\medskipamount}
3927 \begin{itemize}
3928 \item <al-cmd>,~<ja-cmd>は既に定義されていなければならない.
3929       \verb+\reDeclareMathAlphabet+\\の後に
3930 両命令の内容を再定義しても,<unified-cmd>の内容にそれは反映されない.
3931 \item <al-cmd>,~<ja-cmd>に\verb+\@mathrm+などと\texttt{@}をつけた命令を指定した時の動作は保証できない.
3932 \end{itemize}}
3933 %</ja>
3934
3935 \item[DeclareRelationFont\{<ja-encoding>\}\{<ja-family>\}\{<ja-series>\}\{<ja-shape>\}\\
3936   \hfill\{<al-encoding>\}\{<al-family>\}\{<al-series>\}\{<al-shape>\}]
3937 %<*en>
3938 This command sets the ``accompanied'' alphabetic font family (given by the latter 4~arguments)
3939 with respect to a Japanese font family given by the former 4~arguments.
3940 %</en>
3941 %<*ja>
3942 いわゆる「従属欧文」を設定するための命令である.前半の4引数で表される和文フォントファミリに対して,
3943 そのフォントに対応する「従属欧文」のフォントファミリを後半の4引数により与える.
3944 %</ja>
3945 \item[SetRelationFont]
3946 %<*en>
3947 This command is almost same as \verb+\DeclareRelationFont+, except that this command does a local
3948 assignment, where \verb+\DeclareRelationFont+ does a global assignment.
3949 %</en>
3950 %<*ja>
3951 このコマンドは \verb+\DeclareRelationFont+ とローカルな指定であることを除いて
3952 ほとんど同じである(\verb+\DeclareRelationFont+ はグローバル).
3953 %</ja>
3954
3955 \item[userelfont]
3956 %<*en>
3957 Change current alphabetic font encoding/family/\dots\ to the `accompanied' alphabetic
3958              font family with respect to current Japanese font family,
3959              which was set by
3960              \verb+\DeclareRelationFont+ or \verb+\SetRelationFont+.
3961 Like \verb+\fontfamily+, \verb+\selectfont+ is required to take an effect.
3962 %</en>
3963 %<*ja>
3964 現在の欧文フォントエンコーディング/ファミリ/…… を,
3965 \verb+\DeclareRelationFont+ か \verb+\SetRelationFont+ で指定された
3966 現在の和文フォントファミリに対応する「従属欧文」フォントファミリに変更する.
3967 \verb+\fontfamily+ のように,有効にするためには \verb+\selectfont+ が必要である.
3968 %</ja>
3969
3970 \item[adjustbaseline]
3971 \ldots
3972
3973 \item[fontfamily\{<family>\}]
3974 %<*en>
3975 As in \LaTeXe, this command changes current font family (alphabetic, Japanese,~\emph{or both})
3976 to <family>. Which family will be changed is determined as follows:
3977 %</en>
3978 %<*ja>
3979 元々の\LaTeXe におけるものと同様に,このコマンドは現在のフォントファミリ(欧文,
3980 和文,\emph{もしくは両方})を<family>に変更する.
3981 どのファミリが変更されるかは以下のようにして決定される:
3982 %</ja>
3983 {\let\item\origitem
3984 \vspace{-\medskipamount}
3985 \begin{itemize}
3986 %<*en>
3987 \item Let current encoding scheme for Japanese fonts be
3988       <ja-enc>. Current Japanese font family will be changed to
3989       <family>, if one of the following two conditions is met:
3990 %</en>
3991 %<*ja>
3992 \item 現在の和文フォントに対するエンコーディングが<ja-enc>であるとしよう.
3993   現在の和文フォントファミリは,以下の2つの条件のうちの1つが満たされているときに
3994   <family>に変更される:
3995 %</ja>
3996 \begin{itemize}
3997 %<*en>
3998 \item The family <family> under the encoding <ja-enc> has been already defined by
3999       \verb+\DeclareKanijFamily+.
4000 %</en>
4001 %<*ja>
4002 \item エンコーディング<ja-enc>におけるファミリ<family>が既に \verb+\DeclareKanjiFamily+ によって定義されている.
4003 %</ja>
4004 %<*en>
4005 \item A font definition named \texttt{<ja-enc><family>.fd} (the file name is
4006       all lowercase) exists.
4007 %</en>
4008 %<*ja>
4009 \item フォント定義ファイル\texttt{<ja-enc><family>.fd}(ファイル名は全て小文字)が存在する.
4010 %</ja>
4011 \end{itemize}
4012 %<*en>
4013 \item Let current encoding scheme for alphabetic fonts be
4014       <al-enc>. For alphabetic font family, the criterion as above is used.
4015 %</en>
4016 %<*ja>
4017 \item 現在の欧文フォントに対するエンコーディングを<al-enc>とする.
4018   欧文フォントファミリに対しても,上記の基準が用いられる.
4019 %</ja>
4020 %<*en>
4021 \item There is a case which none of the above applies, that is, the font
4022       family named <family> doesn't seem to be defined neither under the
4023       encoding <ja-enc>, nor under <al-enc>.
4024 In this case, the default family for font substitution is used for
4025       alphabetic and Japanese fonts. Note that current encoding will not
4026       be set to <family>, unlike the original implementation in \LaTeX.
4027 %</en>
4028 %<*ja>
4029 \item 上記のいずれもが適用されない,つまり<family>が<ja-enc>と<al-enc>の
4030   どちらでも定義されないような場合がある.
4031   この場合,代替フォントに用いられるデフォルトのフォントファミリが欧文フォントと
4032   和文フォントに用いられる.\LaTeX のオリジナルの実装とは異なり,
4033   現在のエンコーディングは<family>には設定されないことに注意する.
4034 %</ja>
4035 \end{itemize}%
4036 %<en>\vspace{-\medskipamount}
4037 }
4038
4039 \item[DeclareAlternateKanjiFont\{<base-encoding>\}\{<base-family>\}\{<base-series>\}\{<base-shape>\}\\
4040   \hfill\{<alt-encoding>\}\{<alt-family>\}\{<alt-series>\}\{<alt-shape>\}\{<range>\}]
4041 %<*ja>
4042 \ref{ssec-altfont}節の
4043 \verb+\ltjdeclarealtfont+ と同様に,前半の4引数の和文フォント(基底フォント)のうち<range>中の文字を
4044 第5--第8引数の和文フォントを使って組むように指示する.使用例を図\ref{fig:altkanji}に載せた.
4045
4046 {\let\item\origitem
4047 \vspace{-\medskipamount}
4048 \begin{itemize}
4049  \item 
4050 \verb+\ltjdeclarealtfont+ では基底フォント・置き換え先和文フォントはあらかじめ定義されてい
4051              ないといけない(その代わり即時発効)であったが,
4052 \verb+\DeclareAlternateKanjiFont+ の設定が
4053 実際に効力が発揮するのは,書体変更やサイズ変更を行った時,
4054 あるいは(これらを含むが)\verb+\selectfont+ が実行された時である.
4055  \item 
4056 段落や水平ボックスの最後での設定値が段落/水平ボックス全体にわたって通用する点や,
4057 <range>に負数$-n$を指定した場合,それが「基底フォントの文字クラス$n$に属する文字全体」
4058 と解釈されるのは \verb+\ltjdeclarealtfont+ と同じである.
4059 \end{itemize}%
4060 %<en>\vspace{-\medskipamount}
4061 }
4062 %</ja>
4063 %<*en>
4064 As \verb+\ltjdeclarealtfont+, characters in <range> of the Japanese font (we say the \emph{base font})
4065 which specified by first 4 arguments are typeset 
4066 by the Japanese font which specified by fifth to eighth arguments.
4067 An example is shown in Figure~\ref{fig:altkanji}.
4068 %</en>
4069 \end{cslist}
4070
4071 %<*en>
4072 As closing this subsection, we shall introduce an example of
4073 \verb+\SetRelationFont+ and \verb+\userelfont+:
4074 %</en>
4075 %<*ja>
4076 この節の終わりに,\verb+\SetRelationFont+ と \verb+\userelfont+ の例を
4077 紹介しておこう.\verb+\userelfont+ の使用によって,「abc」の部分のフォントが
4078 Avant Garde (OT1/pag/m/n) に変わっていることがわかる.
4079 %</ja>
4080 \begin{LTXexample}[width=0.3\textwidth]
4081 \makeatletter
4082 \SetRelationFont{JY3}{\k@family}{m}{n}{OT1}{pag}{m}{n}
4083   % \k@family: current Japanese font family
4084 \userelfont\selectfont あいうabc
4085 \end{LTXexample}
4086
4087 %<en>\section{Extensions}
4088 %<ja>\section{拡張}
4089 \subsection{\texttt{luatexja-fontspec.sty}}
4090
4091 %<*en>
4092 As described in Subsection~\ref{ssec-fontspec}, this optional package
4093 provides the counterparts for several commands defined in the
4094 \Pkg{fontspec} package.
4095 In addition to OpenType font features in the original \Pkg{fontspec},
4096 the following ``font features'' specifications are allowed for
4097 the commands of Japanese version:
4098 %</en>
4099 %<*ja>
4100 \ref{ssec-fontspec}節で述べたように,この追加パッケージは\Pkg{fontspec}
4101 パッケージで定義されているコマンドに対応する和文フォント用のコマンドを提供する.
4102 \Pkg{fontspec}パッケージで指定可能な各種font featureに加えて,和文版のコマンドには
4103 以下の``font feature''を指定することができる:
4104 %</ja>
4105
4106
4107 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}\advance\leftmargin1\zw}
4108 \item[CID=<name>]
4109 \item[JFM=<name>]
4110 \item[JFM-var=<name>] \
4111
4112 %<*en>
4113 These 3 font features correspond to \texttt{cid}, \texttt{jfm} and
4114 \texttt{jfmvar} keys for \verb+\jfont+ respectively.
4115 \texttt{CID} is effective only when with \texttt{NoEmbed}
4116 described below.
4117 See Subsections~\ref{ssec-jfont} and \ref{ssec-psft} for details.
4118 %</en>
4119 %<*ja>
4120 これら3つのキーはそれぞれ \verb+\jfont+ に対する
4121 \texttt{cid}, \texttt{jfm}, \texttt{jfmvar}キーとそれぞれ対応する.
4122 \texttt{CID} は下の \texttt{NoEmbed} と合わせて用いられたときのみ有効である.
4123 \verb+\jfont+ プリミティブに対する
4124 \texttt{cid}, \texttt{jfm}, \texttt{jfmvar}キーの詳細は\ref{ssec-jfont}節
4125              と\ref{ssec-psft}節を参照.
4126 %</ja>
4127
4128 \item[NoEmbed]
4129 %<*en>
4130 By specifying this font feature, one can use ``name-only'' Japanese font which
4131 will not be embedded in the output PDF file. See Subsection~\ref{ssec-psft}.
4132 %</en>
4133 %<*ja>
4134 これを指定することで,PDFに埋め込まれない「名前だけ」のフォントを指定することが
4135 できる.\ref{ssec-psft}節を参照.
4136 %</ja>
4137 \end{list}
4138
4139 %<*ja>
4140 なお,\Pkg{luatexja-fontspec} 読み込み時には和文フォント定義ファイル%
4141 \texttt{<ja-enc><family>.fd}は全く参照されなくなる.
4142 %</ja>
4143
4144
4145
4146 \subsection{\texttt{luatexja-otf.sty}}
4147
4148 %<*en>
4149 This optional package supports typesetting characters in
4150 Adobe-Japan1. the package \Pkg{luatexja-otf} offers the following 2~low-level
4151 commands:
4152 %</en>
4153 %<*ja>
4154 この追加パッケージはAdobe-Japan1の文字の出力をサポートする.
4155 \Pkg{luatexja-otf}は以下の2つの低レベルコマンドを提供する:
4156 %</ja>
4157 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}\advance\leftmargin1\zw}
4158 \item[\char92CID\{<number>\}]
4159 %<*en>
4160 Typeset a character whose CID number is <number>.
4161 %</en>
4162 %<*ja>
4163 CID番号が<number>の文字を出力する.
4164 %</ja>
4165
4166 \item[\char92UTF\{<hex\_number>\}]
4167 %<*en>
4168 Typeset a character whose character code is <hex\_number> (in hexadecimal).
4169 This command is similar to \verb+\char"+<hex\_number>,\ %"
4170 but please remind remarks below.
4171 %</en>
4172 %<*ja>
4173 文字コードが(16進で)<hex\_number>の文字を出力する.
4174 このコマンドは \verb+\char"+<hex\_number>と似ているが,下の記述に注意すること.%"
4175 %</ja>
4176 \end{list}
4177
4178 %<en>\paragraph{Remarks}
4179 %<ja>\paragraph{注意}
4180 %<*en>
4181 Characters by \verb+\CID+ and \verb+\UTF+ commands are different from
4182 ordinary characters in the following points:
4183 %</en>
4184 %<*ja>
4185 \verb+\CID+ と \verb+\UTF+ コマンドによって出力される文字は
4186 以下の点で通常の文字と異なる:
4187 %</ja>
4188 \begin{itemize}
4189 %<*en>
4190 \item Always treated as \textbf{JAchar}s.
4191 %</en>
4192 %<*ja>
4193 \item 常に\textbf{JAchar}として扱われる.
4194 %</ja>
4195 %<*en>
4196 \item Processing codes for supporting OpenType features (\textit{e.g.},
4197       glyph replacement and kerning) by the \Pkg{luaotfload} package
4198       is not performed to these characters.
4199 %</en>
4200 %<*ja>
4201 \item OpenType feature(例えばグリフ置換やカーニング)をサポートするための
4202   \Pkg{luaotfload}パッケージのコードはこれらの文字には働かない.
4203 %</ja>
4204 \end{itemize}
4205
4206
4207 %<en>\paragraph{Additional Syntax of JFM}
4208 %<ja>\paragraph{JFMへの記法の追加}
4209
4210 %<*en>
4211 The package \Pkg{luatexja-otf} extends the syntax of JFM; the entries of \texttt{
4212 chars} table in JFM now allows a string in the form
4213 \verb+'AJ1-xxx'+, which stands for the character
4214 whose CID number in Adobe-Japan1 is \verb+xxx+.
4215
4216 This extened notation is used in the standard JFM \texttt{jfm-ujis.lua}
4217 to typeset halfwidth Hiragana glyphs (CID~516--598) in halfwidth.
4218 %</en>
4219 %<*ja>
4220 \Pkg{luatexja-otf}パッケージを読み込むと,
4221 JFMの\texttt{chars}テーブルのエントリとして \verb+'AJ1-xxx'+ の形の文字列が
4222 使えるようになる.これはAdobe-Japan1におけるCID番号が \verb+xxx+ の文字を表す.
4223
4224 この拡張記法は,標準JFM~\texttt{jfm-ujis.lua}で,半角ひらがなのグリフ(CID~516--598)を
4225 正しく半角幅で組むために利用されている.
4226 %</ja>
4227
4228 \def\IVS#1{\char\numexpr "E0100+#1\relax}%"
4229 \def\IVSA#1#2#3#4#5{%
4230   \textcolor{blue}{\raisebox{3.5pt}{\tt%
4231     \fboxsep=1pt\fbox{\tiny \oalign{0#1#2\crcr#3#4#5\crcr}}}}\ignorespaces
4232 }
4233 {\catcode`\%=11
4234   \gdef\IVSB#1{\expandafter\IVSA\directlua{tex.sprint(string.format('%X', 0xE0100+#1))}}}
4235 %<*en>
4236 \paragraph{IVS Support}
4237 Recent fonts support Ideographic Variation Selector (IVS).
4238 It seems that \Pkg{luaotfload} and \Pkg{fontspec} packages do not support
4239 IVS, so we implemented IVS support in \Pkg{luatexja-otf}.
4240 \emph{IVS support is experimental; if you want to enable this, load
4241 \Pkg{luatexja-otf} and execute the following:}
4242 %</en>
4243 %<*ja>
4244 \paragraph{IVSサポート}
4245 最近のOpenTypeフォントやTrueTypeフォントには,
4246 \texttt{U+E0100}--\texttt{U+E01EF}の範囲の「文字」
4247 (漢字用異体字セレクタ)を後置することによって
4248 字形を指定する仕組み(IVS)が含まれている.
4249 執筆時点の2013年12月では,\Pkg{luaotfload}や\Pkg{fontspec}パッケージ類は
4250 IVSに対応してはいないようである.これらのパッケージで対応してくれるのが理想的だが,
4251 それまでのつなぎとして,\Pkg{luatexja-otf}パッケージ内にIVS対応を仕込んでおいた.
4252
4253 \medskip
4254
4255 \emph{IVS対応は試験的なものである.
4256 有効にするには,\Pkg{luatexja-otf}パッケージを読み込んだ上で以下の命令を実行する%
4257 \footnote{この命令を2回以上実行しても意味がない.}:}
4258 %</ja>
4259 \begin{verbatim}
4260 \directlua{luatexja.otf.enable_ivs()}
4261 \end{verbatim}
4262 %<ja> すると,上の命令を実行した箇所以降では,以下のようにIVSによる字形指定が有効となる.
4263 %<en> After executing the command above, you can use IVS like the following:
4264 \begin{LTXexample}[explpreset={escapechar=\'}, preset={\let\IVSB=\IVS\catcode`\'=9 } ]
4265 \Large
4266 \jfontspec{KozMinPr6N-Regular}
4267 奈良県葛'\IVSB0'城市と,東京都葛'\IVSB1'飾区.\\
4268 こんにちは,渡%
4269 邉'\IVSB{00}'邉'\IVSB{01}'邉'\IVSB{02}'邉'\IVSB{03}'邉'\IVSB{04}'%
4270 邉'\IVSB{05}'邉'\IVSB{06}'邉'\IVSB{07}'邉'\IVSB{08}'邉'\IVSB{09}'%
4271 邉'\IVSB{10}'邉'\IVSB{11}'邉'\IVSB{12}'邉'\IVSB{13}'邉'\IVSB{14}'%
4272 さん.
4273 \end{LTXexample}
4274 %<*en>
4275 In above input, we displayed  \texttt{U+E0102} as \IVSB2, to indicate variation selectors.
4276 %</en>
4277 %<*ja>
4278 左上側の入力においては,漢字用異体字セレクタを明示するため,
4279 例えば \texttt{U+E0102} を\IVSB2のように表記している.
4280 %</ja>
4281 \medskip
4282
4283 %<*en>
4284 Specifying glyph variants by IVS precedes glyph replacement by font features.
4285 For example, only ``葛'' in ``葛西'' is changed by font features
4286 \texttt{jp78}~or~\texttt{jp90}, which does not followed by any variation selector.
4287 %</en>
4288 %<*ja>
4289 また,IVSによる字形指定は,font featureによるそれに優先されることとした.
4290 下の例において,\texttt{jp78}, \texttt{jp90} 指定で字形が変化した文字は
4291 異体字セレクタが続いていない「葛西」中の「葛」のみである.
4292 %</ja>
4293 \begin{LTXexample}[explpreset={escapechar=\'}, preset={\let\IVSB=\IVS\catcode`\'=9 } ]
4294  \def\TEST#1{%
4295    {\jfontspec[#1]{KozMinPr6N-Regular}%
4296    葛'\IVSB0'城市,葛'\IVSB1'飾区,葛西}\\}
4297  指定なし:\TEST{}
4298  \texttt{jp78}:\TEST{CJKShape=JIS1978}
4299  \texttt{jp90}:\TEST{CJKShape=JIS1990}
4300 \end{LTXexample}
4301
4302 %<*ja>
4303 現状では,\TeX 側のインターフェースとなる \Pkg{luatexja-otf.sty} は一切変更していない
4304 ので,ZRさんによる\Pkg{PXipamjm}パッケージ%
4305 \footnote{\url{https://github.com/zr-tex8r/PXipamjm}. 説明は彼のブログ記事
4306 「pxipamjm パッケージの説明書のような何か(\url{http://d.hatena.ne.jp/zrbabbler/20131221})」
4307 にある.}
4308 にあるような気の利いた命令はまだない.
4309 異体字の一覧表示を行いたい場合は,gitリポジトリ内の \texttt{test/test19-ivs.tex} 中にある
4310 Lua・\TeX コードが参考になるだろう.
4311 %</ja>
4312
4313
4314 \subsection{\texttt{luatexja-adjust.sty}}
4315 \label{ssec-adj}
4316 \begin{figure}[t]
4317 \def\sq{%
4318   \hbox to 1\zw{\hss\fboxsep=-.5\fboxrule\fbox{%
4319    \hskip\dimexpr-.5\zw-.2pt\vrule width.4pt height.08\zw depth.12\zw%
4320   \hskip\dimexpr.5\zw-.2pt\relax}\hss}}
4321 \def\sb{\hbox to 1\zw{\hss\fboxsep=-.5\fboxrule\fbox{%
4322   ■\hskip\dimexpr-.5\zw-.2pt\vrule width.4pt height.08\zw depth.12\zw%
4323   \hskip\dimexpr.5\zw-.2pt\relax}\hss}}
4324 \newbox\gridbox
4325 \def\outbox#1{{\Large%
4326   \ltjsetparameter{kanjiskip=0pt plus .2\zw minus .2\zw}%
4327   \setbox\gridbox=\hbox to 20\zw{\sq\sq\sq\sq\sb\sq\sq\sq\sq\sb\sq\sq\sq\sq\sb\sq\sq\sq\sq\sb}%
4328   \hbox{\textcolor{cyan!50!white}{\copy\gridbox}\hskip-20\zw%
4329   \vbox{\hsize=20\zw\noindent\leftskip0pt\rightskip0pt\parfillskip0pt#1}\vrule}%
4330 }}
4331
4332 {\centering
4333 \begin{tabular}{lc}
4334 \toprule
4335 no adjustment&\outbox{以上の原理は,「包除原理」とよく呼ばれるが\hskip-.5\zw\null}\\
4336 without priority&%
4337 \ltjdisableadjust
4338 \outbox{以上の原理は,「包除原理」とよく呼ばれるが}%
4339 \ltjenableadjust\\
4340 with priority&%
4341 \outbox{以上の原理は,「包除原理」とよく呼ばれるが}
4342 %<en>\ltjdisableadjust
4343 \\
4344 \bottomrule
4345 \end{tabular}\par}
4346 \smallskip
4347
4348 Note: the value of 
4349 \Param{\hyperlink{fld:kanjiskip}{kanjiskip}} is 0\,pt${}^{+1/5\,\mathrm{em}}_{-1/5\,\mathrm{em}}$ in this figure,
4350 for making the difference obvious.
4351 %<ja>\caption{行長調整}\label{fig-adj}
4352 %<en>\caption{Line adjustment}\label{fig-adj}
4353 \end{figure}
4354
4355
4356 %<*en>
4357 ...
4358 %</en>
4359 %<*ja>
4360 \pTeX では,行長調整において優先度の概念が存在しなかったため,図
4361 \ref{fig-adj}上段における半角分の半端は,図\ref{fig-adj}中段のように,鍵
4362 括弧周辺の空白と和文間空白(\Param{\hyperlink{fld:kanjiskip}{kanjiskip}})の両方によって負担される.し
4363 かし,「日本語組版処理の要件」\cite{jlreq}やJIS~X~4051~\cite{x4051}におい
4364 ては,このような状況では半端は鍵括弧周辺の空白のみで負担し,その他の和文
4365 文字はベタ組で組まれる(図\ref{fig-adj}下段)ことになっている.この追加
4366 パッケージは\cite{jlreq}や\cite{x4051}における規定のような,優先順位付き
4367 の行長調整を提供する.詳細な仕様については\ref{sec-adjspec}を参照.
4368
4369
4370 \Pkg{luatexja-adjust} は,以下の命令を提供する.これらはすべてグローバルに効力を発揮する.
4371
4372 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}\advance\leftmargin1\zw}
4373 \item[\char92ltjdisableadjust]
4374 優先順位付きの行長調整を無効化する.
4375
4376 \item[\char92ltjenableadjust]
4377 優先順位付きの行長調整を有効化する.
4378
4379 \end{list}
4380
4381
4382
4383
4384
4385 %</ja>
4386
4387
4388
4389 %<en>\part{Implementations}
4390 %<ja>\part{実装}
4391 \label{part-imp}
4392 %<en>\section{Storing Parameters}
4393 %<ja>\section{パラメータの保持}
4394 \label{sec-para}
4395 %<en>\subsection{Used Dimensions, Attributes and whatsit nodes}
4396 %<ja>\subsection{\LuaTeX-jaで用いられる寸法レジスタ,属性レジスタ,whatsitノード}
4397
4398 %<*en>
4399 Here the following is the list of dimensions and attributes which are used in \LuaTeX-ja.
4400 %</en>
4401 %<*ja>
4402 以下は\LuaTeX-jaで用いられる寸法レジスタ(dimension),属性レジスタ(attribute)の
4403 リストである.
4404 %</ja>
4405 \begin{list}{}{%
4406 \def\makelabel{\ttfamily}\advance\leftmargin1\zw
4407 \def\dim#1{\item[\char`\\#1\ \textrm{(dimension)}]}
4408 \def\attr#1{\item[\char`\\#1\ \textrm{(attribute)}]}
4409 }
4410
4411 \dim{jQ}
4412 %<*en>
4413 \verb+\jQ+ is equal to
4414                         $1\,\textrm{Q}=0.25\,\textrm{mm}$, where ``Q''~(also called ``級'') is
4415                         a unit used in Japanese phototypesetting. 
4416 So one should not change the value of this dimension.
4417 %</en>
4418 %<*ja>
4419 \verb+\jQ+ は写植で用いられた$1\,\textrm{Q}=0.25\,\textrm{mm}$%
4420 (「級」とも書かれる)に等しい.したがって,
4421 この寸法レジスタの値を変更してはならない.
4422 %</ja>
4423
4424 \dim{jH}
4425 %<*en>
4426 There is also a unit called ``歯'' which equals to $0.25\,\textrm{mm}$ and
4427                          used in Japanese phototypesetting. 
4428 This \verb+\jH+ is the same \verb+\dimen+ register as \verb+\jQ+.
4429 %</en>
4430 %<*ja>
4431 同じく写植で用いられていた単位として「歯」があり,これも$0.25\,\textrm{mm}$と
4432 等しい.この \verb+\jH+ は \verb+\jQ+ と同じ寸法レジスタを指す.
4433 %</ja>
4434
4435 \dim{ltj@zw}
4436 %<*en>
4437 A temporal register for the ``full-width'' of current Japanese font.
4438 %</en>
4439 %<*ja>
4440 現在の和文フォントの「全角幅」を保持する一時レジスタ.
4441 %</ja>
4442
4443 \dim{ltj@zh}
4444 %<*en>
4445 A temporal register for the ``full-height'' (usually the sum of height of imaginary body and its depth) of current Japanese font.
4446 %</en>
4447 %<*ja>
4448 現在の和文フォントの「全角高さ」(通常,高さと深さの和)を保持する一時レジスタ.
4449 %</ja>
4450
4451 \attr{jfam}
4452 %<*en>
4453 Current number of Japanese font family for math formulas.
4454 %</en>
4455 %<*ja>
4456 数式用の和文フォントファミリの現在の番号.
4457 %</ja>
4458
4459 \attr{ltj@curjfnt}
4460 %<*en>
4461 The font index of current Japanese font.
4462 %</en>
4463 %<*ja>
4464 現在の和文フォントのフォント番号.
4465 %</ja>
4466
4467 \attr{ltj@charclass}
4468 %<*en>
4469 The character class of Japanese \textit{glyph\_node}.
4470 %</en>
4471 %<*ja>
4472 和文文字の\textit{glyph\_node}の文字クラス.
4473 %</ja>
4474
4475 \attr{ltj@yablshift}
4476 %<*en>
4477 The amount of shifting the baseline of alphabetic fonts in scaled point ($2^{-16}\,\textrm{pt}$).
4478 %</en>
4479 %<*ja>
4480 スケールド・ポイント($2^{-16}\,\textrm{pt}$)を単位とした欧文フォントのベースラインの移動量.
4481 %</ja>
4482
4483 \attr{ltj@ykblshift}
4484 %<*en>
4485 The amount of shifting the baseline of Japanese fonts in scaled point ($2^{-16}\,\textrm{pt}$).
4486 %</en>
4487 %<*ja>
4488 スケールド・ポイント($2^{-16}\,\textrm{pt}$)を単位とした和文フォントのベースラインの移動量.
4489 %</ja>
4490
4491 \attr{ltj@autospc}
4492 %<*en>
4493 Whether the auto insertion of \Param{\hyperlink{fld:kanjiskip}{kanjiskip}} is allowed at the node.
4494 %</en>
4495 %<*ja>
4496 そのノードで\Param{\hyperlink{fld:kanjiskip}{kanjiskip}}の自動挿入が許されるかどうか.
4497 %</ja>
4498
4499 \attr{ltj@autoxspc}
4500 %<*en>
4501 Whether the auto insertion of \Param{\hyperlink{fld:xks}{xkanjiskip}} is allowed at the node.
4502 %</en>
4503 %<*ja>
4504 そのノードで\Param{\hyperlink{fld:xks}{xkanjiskip}}の自動挿入が許されるかどうか.
4505 %</ja>
4506
4507 \attr{ltj@icflag}
4508 %<*en>
4509 An attribute for distinguishing ``kinds'' of a node. One of the following value is
4510 assigned to this attribute:
4511 %</en>
4512 %<*ja>
4513 ノードの「種類」を区別するための属性.以下のうちのひとつが値として割り当てられる:
4514 %</ja>
4515 \begin{description}
4516 \item[\textit{italic} (1)]
4517 %<*en>
4518 Glues from an italic correction
4519            (\verb+\/+). This distinction of origins of glues
4520            (from explicit \verb+\kern+, or from \verb+\/+)
4521            is needed in the insertion process of \Param{\hyperlink{fld:xks}{xkanjiskip}}.
4522 %</en>
4523 %<*ja>
4524 イタリック補正(\verb+\/+)によるグルー.このグルーの由来の区別(\verb+\kern+ か
4525 \hskip\ltjgetparameter{xkanjiskip}
4526 \verb+\/+ か)は\Param{\hyperlink{fld:xks}{xkanjiskip}}の挿入過程において必要になる.
4527 %</ja>
4528
4529 \item[\textit{packed} (2)]
4530
4531 \item[\textit{kinsoku} (3)]
4532 %<*en>
4533 Penalties inserted for the word-wrapping process of Japanese characters (\emph{kinsoku}).
4534 %</en>
4535 %<*ja>
4536 和文文字のワードラップ過程において挿入されたペナルティ(\emph{kinsoku}).
4537 %</ja>
4538
4539 \item[\textit{from\_jfm} (6)]
4540 %<*en>
4541 Glues/kerns from JFM.
4542 %</en>
4543 %<*ja>
4544 JFM由来のグルー/カーン.
4545 %</ja>
4546
4547 %%\item[\textit{line\_end} (5)]
4548 %%%<*en>
4549 %%Kerns for \ldots
4550 %%%</en>
4551 %%%<*ja>
4552 %%和文文字が行末にきたとき,行末との間に挿入されるカーンである.
4553 %%% ぶら下げ組への応用
4554 %%%</ja>
4555
4556 \item[\textit{kanji\_skip} (9)]
4557 %<*en>
4558 Glues for \Param{\hyperlink{fld:kanjiskip}{kanjiskip}}.
4559 %</en>
4560 %<*ja>
4561 \Param{\hyperlink{fld:kanjiskip}{kanjiskip}}のグルー.
4562 %</ja>
4563
4564 \item[\textit{xkanji\_skip} (10)]
4565 %<*en>
4566 Glues for \Param{\hyperlink{fld:xks}{xkanjiskip}}.
4567 %</en>
4568 %<*ja>
4569 \Param{\hyperlink{fld:xks}{xkanjiskip}}のグルー.
4570 %</ja>
4571
4572 \item[\textit{processed} (11)]
4573 %<*en>
4574 Nodes which is already processed by \ldots.
4575 %</en>
4576 %<*ja>
4577 \LuaTeX-ja の内部処理によって既に処理されたノード.
4578 %</ja>
4579
4580 \item[\textit{ic\_processed} (12)]
4581 %<*en>
4582 Glues from an italic correction, but also already processed.
4583 %</en>
4584 %<*ja>
4585 イタリック補正に由来するグルーであるが,まだ処理されていないもの.
4586 %</ja>
4587
4588 \item[\textit{boxbdd} (15)]
4589 %<*en>
4590 Glues/kerns that inserted just the beginning or the ending of an hbox or a paragraph.
4591 %</en>
4592 %<*ja>
4593 ある水平ボックスか段落の最初か最後に挿入されたグルー/カーン.
4594 %</ja>
4595 \end{description}
4596
4597 \attr{ltj@kcat$i$}
4598 %<*en>
4599 Where $i$~is a natural number which is less than~7.
4600 These 7~attributes store bit~vectors indicating which character block is regarded as a block of \textbf{JAchar}s.
4601 %</en>
4602 %<*ja>
4603 $i$は7より小さい自然数.
4604 これら7つの属性レジスタは,どの文字ブロックが\textbf{JAchar}のブロックとして
4605 扱われるかを示すビットベクトルを格納する.
4606 %</ja>
4607 \end{list}
4608
4609 %<*en>
4610 Furthermore, \LuaTeX-ja uses several user-defined whatsit nodes for
4611 inrernal processing. All those nodes store a natural number (hence the node's
4612 \texttt{type} is 100). 
4613 Their \texttt{user\_id} (used for distinguish user-defined whatsits) 
4614 are allocated by \texttt{luatexbase.newuserwhatsitid}.
4615 %</en>
4616 %<*ja>
4617 さらに,\LuaTeX-jaはいくつかのuser-defined whatsit nodeを内部処理に用いる.
4618 これらのwhatsitノードの \texttt{type} は100であり,ノードは自然数を格納している.
4619 user-defined whatsitを識別するための \texttt{user\_id} は\ 
4620 \texttt{luatexbase.newuserwhatsitid} により確保されている.
4621 %</ja>
4622 \begin{description}
4623 \item[\textit{inhibitglue}]
4624 %<*en>
4625 Nodes for indicating that \verb+\inhibitglue+ is
4626            specified. The \texttt{value} field of these nodes doesn't matter.
4627 %</en>
4628 %<*ja>
4629 \verb+\inhibitglue+ が指定されたことを示すノード.これらのノードの\ 
4630 \texttt{value} フィールドは意味を持たない.
4631 %</ja>
4632
4633 \item[\textit{stack\_marker}]
4634 %<*en>
4635 Nodes for \LuaTeX-ja's stack system (see the next
4636            subsection). The \texttt{value} field of these nodes is
4637            current group level.
4638 %</en>
4639 %<*ja>
4640 \LuaTeX-jaのスタックシステム(次の節を参照)のためのノード.
4641 これらのノードの \texttt{value} フィールドは現在のグループネストレベルを表す.
4642 %</ja>
4643
4644 \item[\textit{char\_by\_cid}]
4645 %<*en>
4646 Nodes for Japanese Characters which the callback process of
4647            \Pkg{luaotfload} won't be applied, and the character code is
4648            stored in the \texttt{value} field. Each node of this type are 
4649            converted to a \textit{glyph\_node} \emph{after}
4650            the callback process of luaotfload.
4651 Nodes of this type is used in \verb+\CID+, \verb+\UTF+ and IVS support.
4652 %</en>
4653 %<*ja>
4654 \Pkg{luaotfload}のコールバックによる処理が適用されない和文文字のためのノードで,
4655 \texttt{value} フィールドに文字コードが格納されている.
4656 この種類のノードはそれぞれが\Pkg{luaotfload}のコールバックの処理の
4657 \emph{後で}\textit{glyph\_node}に変換される.
4658 \verb+\CID+, \verb+\UTF+やIVS対応処理でこの種類のノードが利用されている.
4659 %</ja>
4660
4661 \item[\textit{begin\_par}]
4662 %<*en>
4663 Nodes for indicating beginning of a paragraph.
4664 A paragraph which is started by \verb+\item+ in list-like environments has a horizontal box
4665 for its label before the actual contents. So \dots
4666 %</en>
4667 %<*ja>
4668 「段落の開始」を意味するノード.
4669 list環境,itemize環境などにおいて,\verb+\item+ で始まる各項目は……
4670 %</ja>
4671 \end{description}
4672
4673 %<*en>
4674 These whatsits will be removed during the process of inserting \textbf{JAglue}s.
4675 %</en>
4676 %<*ja>
4677 これらのwhatsitノードは\textbf{JAglue}の挿入処理の間に取り除かれる.
4678 %</ja>
4679
4680 %<en>\subsection{Stack System of \LuaTeX-ja}
4681 %<ja>\subsection{\LuaTeX-jaのスタックシステム}
4682 \label{ssec-stack}
4683
4684 %<en>\paragraph{Background}
4685 %<ja>\paragraph{背景}
4686 %<*en>
4687 \LuaTeX-ja has its own stack system, and most parameters of \LuaTeX-ja
4688 are stored in it. To clarify the reason, imagine the parameter
4689 \Param{\hyperlink{fld:kanjiskip}{kanjiskip}} is stored by a skip, and consider the following
4690 source:
4691 %</en>
4692 %<*ja>
4693 \LuaTeX-jaは独自のスタックシステムを持ち,\LuaTeX-jaのほとんどのパラメータは
4694 これを用いて保持されている.その理由を明らかにするために,
4695 \Param{\hyperlink{fld:kanjiskip}{kanjiskip}}パラメータがスキップレジスタで保持されているとし,
4696 以下のコードを考えてみよう:
4697 %</ja>
4698 \begin{LTXexample}
4699 \ltjsetparameter{kanjiskip=0pt}ふがふが.%
4700 \setbox0=\hbox{\ltjsetparameter{kanjiskip=5pt}ほげほげ}
4701 \box0.ぴよぴよ\par
4702 \end{LTXexample}
4703
4704 %<*en>
4705 As described in Subsection~\ref{ssec-param}, the only effective value of
4706 \Param{\hyperlink{fld:kanjiskip}{kanjiskip}} in an hbox is the latest value, so the value of
4707 \Param{\hyperlink{fld:kanjiskip}{kanjiskip}} which applied in the entire hbox should be 5\,pt.
4708 However, by the implementation method of \LuaTeX, this ``5\,pt'' cannot be
4709 known from any callbacks.  In the \texttt{tex/packaging.w} (which is a
4710 file in the source of \LuaTeX), there are the following codes:
4711 %</en>
4712 %<*ja>
4713 \ref{ssec-param}節で述べたように,ある水平ボックスの中で効力を持つ
4714 \Param{\hyperlink{fld:kanjiskip}{kanjiskip}}の値は最後に現れた値のみであり,したがってボックス全体に適用される
4715 \Param{\hyperlink{fld:kanjiskip}{kanjiskip}}は5\,ptであるべきである.しかし,\LuaTeX の実装のために,
4716 この5\,ptという長さはどのコールバックからも知ることはできない.
4717 \texttt{tex/packaging.w}(これは\LuaTeX のソースファイルである)の中に,
4718 以下のコードがある:
4719 %</ja>
4720 \begin{lstlisting}
4721 void package(int c)
4722 {
4723     scaled h;                   /* height of box */
4724     halfword p;                 /* first node in a box */
4725     scaled d;                   /* max depth */
4726     int grp;
4727     grp = cur_group;
4728     d = box_max_depth;
4729     unsave();
4730     save_ptr -= 4;
4731     if (cur_list.mode_field == -hmode) {
4732         cur_box = filtered_hpack(cur_list.head_field,
4733                                  cur_list.tail_field, saved_value(1),
4734                                  saved_level(1), grp, saved_level(2));
4735         subtype(cur_box) = HLIST_SUBTYPE_HBOX;
4736 \end{lstlisting}
4737 %<*en>
4738 Notice that \verb+unsave+ is executed \emph{before}
4739 \verb+filtered_hpack+ (this is where \verb+hpack_filter+ callback is
4740 executed): so ``5\,pt'' in the above source is orphaned at
4741 \verb+unsave+, and hence it can't be accessed from \verb+hpack_filter+
4742 callback.
4743 %</en>
4744 %<*ja>
4745 \verb+unsave+ が \verb+filtered_hpack+(これは \verb+hpack_filter+ コールバックが
4746 実行されるところである)の\emph{前に}実行されていることに注意する.
4747 したがって,上記ソース中で5\,ptは \verb+unsave+ のところで捨てられ,
4748 \verb+hpack_filter+ からはアクセスすることができない.
4749 %</ja>
4750
4751 %<en>\paragraph{The method}
4752 %<ja>\paragraph{解決法}
4753
4754 %<*en>
4755 The code of stack system is based on that in a post of Dev-luatex mailing list\footnote{%
4756 \texttt{[Dev-luatex] tex.currentgrouplevel}, a post at 2008/8/19 by Jonathan Sauer.}.
4757 %</en>
4758 %<*ja>
4759 スタックシステムのコードはDev-luatexメーリングリストのある投稿\footnote{\texttt{[Dev-luatex] tex.currentgrouplevel}: Jonathan Sauerによる2008/8/19の投稿.}を
4760 ベースにしている.
4761 %</ja>
4762
4763 %<*en>
4764 These are two \TeX\ count registers for maintaining information:
4765 \verb+\ltj@@stack+ for the stack level, and \verb+\ltj@@group@level+ for
4766 the \TeX's group level when the last assignment was done.  Parameters
4767 are stored in one big table named \texttt{charprop\_stack\_table}, where
4768 \texttt{charprop\_stack\_table[$i$]} stores data of stack level~$i$. If
4769 a new stack level is created by \verb+\ltjsetparameter+, all data of the
4770 previous level is copied.
4771 %</en>
4772 %<*ja>
4773 情報を保持するために,2つの\TeX の整数レジスタを用いている:
4774 \verb+\ltj@@stack+ でスタックレベル,\verb+\ltj@@group@level+ で最後の代入が
4775 なされた時点での\TeX のグループレベルを保持している.
4776 パラメータは\texttt{charprop\_stack\_table}という名前のひとつの大きなテーブルに
4777 格納される.ここで,\texttt{charprop\_stack\_table[$i$]}はスタックレベル$i$の
4778 データを格納している.もし新しいスタックレベルが \verb+\ltjsetparameter+ によって
4779 生成されたら,前のレベルの全てのデータがコピーされる.
4780 %</ja>
4781
4782 %<*en>
4783 To resolve the problem mentioned in above paragraph ``Background'', \LuaTeX-ja uses
4784 another thing: When a new stack level is about to be created, a whatsit
4785 node whose type, subtype and value are 44~(\textit{user\_defined}),
4786 \textit{stack\_marker} and current group level respectively is appended to the current
4787 list (we refer this node by \textit{stack\_flag}). This enables us to
4788 know whether assignment is done just inside a hbox. Suppose that the
4789 stack level is~$s$ and the \TeX's group level is~$t$ just after the hbox
4790 group, then:
4791 %</en>
4792 %<*ja>
4793 上の「背景」で述べた問題を解決するために,\LuaTeX-jaではもう一つの手法を導入する:
4794 新しいスタックレベルが生成されようとするとき,type, subtype, valueがそれぞれ
4795 44~(\textit{user\_defined}), \textit{stack\_marker},そして現在のグループレベルであるwhatsitノード
4796 を現在のリストに付け加える(このノードを\textit{stack\_flag}とする).
4797 これにより,ある水平ボックスの中で代入がなされたかどうかを知ることが可能
4798 となる.スタックレベルを$s$,その水平ボックスグループの直後の\TeX のグループレベルを
4799 $t$とすると:
4800 %</ja>
4801 \begin{itemize}
4802 %<*en>
4803 \item If there is no \textit{stack\_flag} node in the list of the hbox, then
4804       no assignment was occurred inside the hbox. Hence values of
4805       parameters at the end of the hbox are stored in the stack
4806       level~$s$.
4807 %</en>
4808 %<*ja>
4809 \item もしその水平ボックスのリストの中に\textit{stack\_flag}ノードがなければ,
4810   水平ボックスの中では代入は起こらなかったということになる.
4811   したがって,その水平ボックスの終わりにおけるパラメータの値はスタックレベル$s$に
4812   格納されている.
4813 %</ja>
4814
4815 %<*en>
4816 \item If there is a \textit{stack\_flag} node whose value is~$t+1$, then
4817       an assignment was occurred just inside the hbox group. Hence
4818       values of parameters at the end of the hbox are stored in the
4819       stack level~$s+1$.
4820 %</en>
4821 %<*ja>
4822 \item もし値が$t+1$の\textit{stack\_flag}ノードがあれば,その
4823   水平ボックスグループの中で代入が起こったことになる.
4824   したがって,水平ボックスの終わりにおけるパラメータの値はスタックレベル$s+1$に
4825   格納されている.
4826 %</ja>
4827
4828 %<*en>
4829 \item If there are \textit{stack\_flag} nodes but all of their values
4830       are more than~$t+1$, then an assignment was occurred in the box,
4831       but it is done in more internal group. Hence values of
4832       parameters at the end of the hbox are stored in the stack
4833       level~$s$.
4834 %</en>
4835 %<*ja>
4836 \item もし\textit{stack\_flag}ノードがあるがそれらの値が全て$t+1$より大きい
4837   場合,そのボックスの中で代入が起こったが,それは「より内部の」グループで
4838   起こったということになる.したがって,水平ボックスの終わりでのパラメータの
4839   値はスタックレベル$s$に格納されている.
4840 %</ja>
4841 \end{itemize}
4842
4843 %<*en>
4844 Note that to work this trick correctly, assignments to
4845 \verb+\ltj@@stack+ and \verb+\ltj@@group@level+ have to be local always,
4846 regardless the value of \verb+\globaldefs+.
4847 This problem is resolved by using
4848 \hbox{\verb+\directlua{tex.globaldefs=0}+} (this assignment is local).
4849 %</en>
4850 %<*ja>
4851 このトリックを正しく働かせるためには,\verb+\ltj@@stack+ と \verb+\ltj@@group@level+ への
4852 代入は \verb+\globaldefs+ の値によらず常にローカルでなければならないことに注意する.
4853 この問題は \hbox{\verb+\directlua{tex.globaldefs=0}+}(この代入は常にローカル)を
4854 用いることで解決している.
4855 %</ja>
4856
4857 %<en>\section{Linebreak after Japanese Character}
4858 %<ja>\section{和文文字直後の改行}
4859 \label{sec-lbreak}
4860 %<en>\subsection{Reference: Behavior in \pTeX}
4861 %<ja>\subsection{参考:\pTeX の動作}
4862 %<*en>
4863 In~\pTeX, a line break after a Japanese character doesn't emit a space,
4864 since words are not separated by spaces in Japanese writings. However,
4865 this feature isn't fully implemented in \LuaTeX-ja due to the
4866 specification of callbacks in~\LuaTeX. To clarify the difference between
4867 \pTeX~and~\LuaTeX, We briefly describe the handling of a line break in~\pTeX, in
4868 this subsection.
4869
4870 \pTeX's input processor can be described in terms of a finite state
4871 automaton, as that of~\TeX\ in~Section~2.5 of~\cite{texbytopic}. The
4872 internal states are as follows:
4873 \begin{itemize}
4874 \item State~$N$: new line
4875 \item State~$S$: skipping spaces
4876 \item State~$M$: middle of line
4877 \item State~$K$: after a Japanese character
4878 \end{itemize}
4879 The first three states---$N$,~$S$, and~$M$---are as same as \TeX's input
4880 processor.  State~$K$ is similar to state~$M$, and is entered after
4881 Japanese characters.  The diagram of state transitions are indicated in
4882 Figure~\ref{fig-ptexipro}.  Note that \pTeX\ doesn't leave state~$K$
4883 after ``beginning/ending of a group'' characters.
4884 %</en>
4885
4886 %<*ja>
4887 欧文では文章の改行は単語間でしか行わない.そのため,\TeX では,(文字の直後の)改行は
4888 空白文字と同じ扱いとして扱われる.一方,和文ではほとんどどこでも改行が可能なため,
4889 \pTeX では和文文字の直後の改行は単純に無視されるようになっている.
4890
4891 このような動作は,\pTeX が\TeX からエンジンとして拡張されたことによって可能になったことである.
4892 \pTeX の入力処理部は,\TeX におけるそれと同じように,有限オートマトンとして記述することができ,
4893 以下に述べるような4状態を持っている.
4894
4895 \begin{itemize}
4896 \item State~$N$: 行の開始.
4897 \item State~$S$: 空白読み飛ばし.
4898 \item State~$M$: 行中.
4899 \item State~$K$: 行中(和文文字の後).
4900 \end{itemize}
4901 また,状態遷移は,図\ref{fig-ptexipro}のようになっており,図中の数字は
4902 カテゴリーコードを表している.最初の3状態は\TeX の入力処理部と同じであり,
4903 図中から状態$K$と「$j$」と書かれた矢印を取り除けば,\TeX の入力処理部と同
4904 じものになる.
4905
4906 この図から分かることは,
4907 \begin{quote}
4908 行が和文文字(とグループ境界文字)で終わっていれば,改行は無視される
4909 \end{quote}
4910 ということである.
4911 %</ja>
4912
4913 \begin{figure}[!tb]
4914 \let\sp\textvisiblespace\small
4915 \begin{minipage}{.6\textwidth}%
4916 \begin{center}
4917 \unitlength=6.5mm\sf\mathversion{bold}
4918 \begin{tikzpicture}[
4919   ->, auto, shorten >=1pt
4920 ]
4921 \node [shape=rectangle, font=\scriptsize] (init) at (2,7) {start};
4922 \node [shape=circle,draw, fill=blue!20] (newline) at (4,7) {$N$};
4923 \node [shape=circle,draw, fill=blue!20] (midline) at (4,4) {$M$};
4924 \node [shape=circle,draw, fill=blue!20] (skipspc) at (8,7) {$S$};
4925 \node [shape=circle,draw, fill=red!20]  (kanji) at (8,4) {$K$};
4926 \node [shape=rectangle,draw, fill=green!20] (scanacs) at (6,8) {scan a c.s.};
4927 \node (endk) at (8,2.5) {} ;
4928 \node (endm) at (4,2.5) {} ;
4929 \node (ends) at (8,8.5) {} ;
4930 \node (endn) at (4,8.5) {} ;
4931 \begin{scope}[font=\scriptsize]
4932 \path (newline) edge [bend right]    node [left]{G, O} (midline)
4933       (init)    edge                 node {} (newline)
4934       (midline) edge [bend right=10] node {10} (skipspc)
4935       (skipspc) edge [bend right]    node [left,right=10,above=7]{G, O} (midline)
4936       (skipspc) edge [loop right]    node {10} (skipspc)
4937       (newline) edge [loop right]    node {10} (newline)
4938       (scanacs) edge [bend left]     node [left=3,below]{$(*)$} (skipspc)
4939       (scanacs) edge [bend right]    node [right=30,above=20]{$(*)$} (midline)
4940       (midline) edge                 node {5\ [\sp]} (endm)
4941       (midline) edge [loop left]     node {G, O} (midline)
4942       (skipspc) edge                 node [right] {5} (ends)
4943       (newline) edge                 node {5 [{\tt\char92par}]} (endn);
4944 \begin{scope}[red]
4945 \path (newline) edge [bend right]    node [right=25,below=3]{J} (kanji)
4946       (midline) edge                 node [below]{J} (kanji)
4947       (kanji)   edge [bend left]     node {O} (midline)
4948       (kanji)   edge                 node {10} (skipspc)
4949       (kanji)   edge [loop right]    node {G, J} (kanji)
4950       (skipspc) edge [bend left]     node {J} (kanji)
4951       (kanji)   edge                 node {5} (endk)
4952 ;
4953 \end{scope}
4954 \end{scope}
4955 \end{tikzpicture}
4956 \end{center}
4957 \end{minipage}%
4958 \begin{minipage}{.4\textwidth}
4959 \begin{description}
4960 \item[\textsf{G}] Beginning of group (usually \verb+{+)\\
4961  and ending of group (usually \verb+}+).
4962 \item[\textsf{J}] Japanese characters.
4963 \item[\textsf{5}] \textit{end-of-line} (usually \verb+^+\verb+^J+).
4964 \item[\textsf{10}] space (usually \sp).
4965 \item[\textsf{O}] other characters, whose category code is in $\{3,4,6,7,8,11,12,13\}$.
4966 \item[\textsf{[\sp]}, \textsf{[{\tt\char92par}]}]
4967 emits a space, or~\verb+\par+.
4968 \end{description}
4969 \end{minipage}
4970 \begin{itemize}
4971 \item We omitted about category codes
4972 9~(\textit{ignored}), 14~(\textit{comment}), and~15~(\textit{invalid})
4973 from the above diagram. We also ignored the input like ``\verb+^+\verb+^A+'' or ``\verb+^+\verb+^df+''.
4974 \item When a character whose category code is 0 (\textit{escape character}) is seen by \TeX,
4975 the input processor scans a control sequence (\textsf{scan a c.s.}).
4976 These paths are not shown in the above diagram.
4977
4978 After that, the state is changed to State~$S$ (skipping blanks) in most cases, but
4979 to State~$M$ (middle of line) sometimes.
4980 \end{itemize}
4981 %<en>\caption{State transitions of \pTeX's input processor}
4982 %<ja>\caption{\pTeX の入力処理部の状態遷移}
4983 \label{fig-ptexipro}
4984 \end{figure}
4985
4986
4987 %<en>\subsection{Behavior in \LuaTeX-ja}
4988 %<ja>\subsection{\LuaTeX-jaの動作}
4989 %<*en>
4990 States in the input processor of \LuaTeX\ is the same as that of \TeX,
4991 and they can't be customized by any callbacks. Hence, we can only use
4992 \verb+process_input_buffer+ and \verb+token_filter+ callbacks for to
4993 suppress a space by a line break which is after Japanese characters.
4994
4995 However, \verb+token_filter+ callback cannot be used either, since a
4996 character in category code 5~(\textit{end-of-line}) is converted into an space
4997 token \emph{in the input processor}.  So we can use only the
4998 \verb+process_input_buffer+ callback.  This means that suppressing a
4999 space must be done \emph{just before} an input line is read.
5000
5001 Considering these situations, handling of an end-of-line in \LuaTeX-ja are as follows:
5002 \begin{quote}
5003 A character \texttt{U+FFFFF} (its category code is set to 14~(\textit{comment}) by
5004 \LuaTeX-ja) is appended to an input line, \emph{before \LuaTeX\ actually
5005 process it}, if and only if the following three conditions are satisfied:
5006 \begin{enumerate}
5007 \item The category code of \verb+\endlinechar+%
5008 \footnote{Usually, it is $\langle${return}$\rangle$
5009       (whose character code is 13).} is 5~(\textit{end-of-line}).
5010 \item The category code of \texttt{U+FFFFF} itself is 14~(\textit{comment}).
5011 \item The input line matches the following ``regular expression'':
5012 \[
5013   (\text{any char})^*(\textbf{JAchar})
5014   \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
5015 \]
5016 \end{enumerate}
5017 \end{quote}
5018
5019 \paragraph{Remark}
5020 The following example shows the major difference from the behavior of \pTeX.
5021 \begin{LTXexample}
5022 \fontspec[Ligatures=TeX]{TeX Gyre Termes}
5023 \ltjsetparameter{autoxspacing=false}
5024 \ltjsetparameter{jacharrange={-6}}xあ
5025 y\ltjsetparameter{jacharrange={+6}}zい
5026 u
5027 \end{LTXexample}
5028 It is not strange that ``あ'' does not printed in the above output.
5029 This is because \TeX\ Gyre\ Termes does not contain ``あ'', and because 
5030 ``あ'' in line~3 is considered as an \textbf{ALchar}.
5031
5032 Note that there is no space before ``y'' in the output, but
5033 there is a space before ``u''. This follows from following reasons:
5034 \begin{itemize}
5035 \item When line~3 is processed by \texttt{process\_input\_buffer} callback,
5036 ``あ'' is considered as an \textbf{JAchar}.
5037 Since  line~3 ends with an \textbf{JAchar}, 
5038 the comment character \texttt{U+FFFFF} is appended to this line,
5039 and hence the linebreak immediately after this line is ignored.
5040 \item When line~4 is processed by \texttt{process\_input\_buffer} callback,
5041 ``い'' is considered as an \textbf{ALchar}.
5042 Since  line~4 ends with an \textbf{ALchar}, the linebreak immediately after this line
5043 emits a space.
5044 \end{itemize}
5045 %</en>
5046
5047 %<*ja>
5048 \LuaTeX の入力処理部は\TeX のそれと全く同じであり,コールバックによりユーザが
5049 カスタマイズすることはできない.このため,改行抑制の目的でユーザが利用で
5050 きそうなコールバックとしては,\verb+process_input_buffer+や
5051 \verb+token_filter+に限られてしまう.しかし,\TeX の入力処理部をよく見る
5052 と,後者も役には経たないことが分かる:改行文字は,入力処理部によってトー
5053 クン化される時に,カテゴリーコード10の32番文字へと置き換えられてしまうた
5054 め,\verb+token_filter+で非標準なトークン読み出しを行おうとしても,空白文
5055 字由来のトークンと,改行文字由来のトークンは区別できないのだ.
5056
5057 すると,我々のとれる道は,\verb+process_input_buffer+を用いて
5058 \LuaTeX の入力処理部に引き渡される前に入力文字列を編集するというものしかない.
5059 以上を踏まえ,\LuaTeX-jaにおける「和文文字直後の改行抑制」の処理は,次のようになっている:
5060
5061 \begin{quote}
5062 各入力行に対し,\emph{その入力行が読まれる前の内部状態で}
5063 以下の3条件が満たされている場合,\LuaTeX-jaは\texttt{U+FFFFF}の文字
5064 \footnote{この文字はコメント文字として扱われるように\LuaTeX-ja内部で設定をしている.}
5065 を末尾に追加する.よって,その場合に改行は空白とは見做されないこととなる.
5066 \begin{enumerate}
5067 \item \verb+\endlinechar+の文字\footnote{普通は,改行文字(文字コード13番)である.}
5068 のカテゴリーコードが5~(\textit{end-of-line})である.
5069 \item \texttt{U+FFFFF}のカテゴリーコードが14~(\textit{comment})である.
5070 \item 入力行は次の「正規表現」にマッチしている:
5071 \[
5072   (\text{any char})^*(\textbf{JAchar})
5073   \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
5074 \]
5075 \end{enumerate}
5076 \end{quote}
5077
5078 この仕様は,前節で述べた\pTeX の仕様にできるだけ近づけたものとなっている.条件1.は,
5079 \texttt{verbatim}系環境などの日本語対応マクロを書かなくてすませるためのものである.
5080
5081 しかしながら,\pTeX と完全に同じ挙動が実現できたわけではない.
5082 次のように,和文文字の範囲を変更したちょうどその行においては挙動が異なる:
5083 \begin{LTXexample}
5084 \fontspec[Ligatures=TeX]{TeX Gyre Termes}
5085 \ltjsetparameter{autoxspacing=false}
5086 \ltjsetparameter{jacharrange={-6}}xあ
5087 y\ltjsetparameter{jacharrange={+6}}zい
5088 u
5089 \end{LTXexample}
5090 上ソース中の「あ」は欧文文字扱いであり.
5091 ここで使用している欧文フォント\TeX\ Gyre Termesは「あ」を含まない.
5092 よって,出力に「あ」は現れないことは不思議ではない.
5093 それでも,\pTeX とまったく同じ挙動を示すならば,出力は
5094 「\hbox{\ltjsetparameter{autoxspacing=false}x yzいu}」となるはずである.しかし,実際には
5095 上のように異なる挙動となっているが,それは以下の理由による:
5096 \begin{itemize}
5097 \item 3行目を \texttt{process\_input\_buffer} で処理する時点では,
5098       「あ」は和文文字扱いである.よって3行目は和文文字で終わることになり,
5099       コメント文字 \texttt{U+FFFFF} が追加される.
5100       よって,直後の改行文字は無視されることになり,空白は入らない.
5101 \item 4行目を \texttt{process\_input\_buffer} で処理する時点では,
5102       「い」は欧文文字扱いである.よって4行目は欧文文字で終わることになり,
5103       直後の改行文字は空白に置き換わる.
5104 \end{itemize}
5105 このため,トラブルを避けるために,和文文字の範囲を\verb+\ltjsetparameter+で編集した場合,
5106 その行はそこで改行するようにした方がいいだろう.
5107 %</ja>
5108
5109 %<*ja>
5110
5111 %<en>\section{Insertion of JFM glues, \Param{kanjiskip} and \Param{xkanjiskip}}
5112 %<ja>\section{JFMグルーの挿入,\Param{kanjiskip}と\Param{xkanjiskip}}
5113 \label{sec-jfmglue}
5114 %<en>\subsection{Overview}
5115 %<ja>\subsection{概要}
5116
5117 \LuaTeX-jaにおける \textbf{JAglue} の挿入方法は,\pTeX のそれとは全く異なる.
5118 \pTeX では次のような仕様であった:
5119 \begin{itemize}
5120 \item JFMグルーの挿入は,和文文字を表すトークンを元に水平リストに(文字を表す)<char\_node>を
5121 追加する過程で行われる.
5122 \item \Param{\hyperlink{fld:xks}{xkanjiskip}}の挿入は,水平ボックスへのパッケージングや行分割前に行われる.
5123 \item \Param{\hyperlink{fld:kanjiskip}{kanjiskip}}はノードとしては挿入されない.パッケージングや行分割の計算時に
5124 「和文文字を表す2つの<char\_node>の間には\Param{\hyperlink{fld:kanjiskip}{kanjiskip}}がある」ものとみなされる.
5125 \end{itemize}
5126 しかし,\LuaTeX-jaでは,水平ボックスへのパッケージングや行分割前に全ての
5127 \textbf{JAglue},即ちJFMグルー・\Param{\hyperlink{fld:xks}{xkanjiskip}}・\Param{\hyperlink{fld:kanjiskip}{kanjiskip}}の
5128 3種類を一度に挿入することになっている.これは,\LuaTeX において欧文の合字・
5129 カーニング処理がノードベースになったことに対応する変更である.
5130
5131 \LuaTeX-jaにおける\textbf{JAglue}挿入処理では,次節で定義する
5132 「クラスタ」を単位にして行われる.大雑把にいうと,「クラスタ」は文字とそれに付随す
5133 るノード達(アクセント位置補正用のカーンや,イタリック補正)をまとめたもの
5134 であり,2つのクラスタの間には,ペナルティ,\verb+\vadjust+,whatsitなど,行組版
5135 には関係しないものがある.
5136
5137
5138 %<en>\subsection{definition of a cluster}
5139 %<ja>\subsection{「クラスタ」の定義}
5140
5141 \def\OA{$\text{\sf O}_{\text{\sf A}}$}
5142 \def\OB{$\text{\sf O}_{\text{\sf B}}$}
5143 \begin{defn}
5144 %<*en>
5145 A \emph{cluster} is a list of consecutive nodes in one of the following forms,
5146 with the \textit{id} of it:
5147 %</en>
5148 %<*ja>
5149 \emph{クラスタ}は以下の形のうちのどれかひとつをとる連続的なノードのリストである:
5150 %</ja>
5151 \begin{enumerate}
5152 %<*en>
5153 \item Nodes whose value of\ \verb+\ltj@icflag+ is in $[3,15)$.  These
5154       nodes come from a hbox which is already packaged, by unpackaging
5155       (\verb+\unhbox+).
5156       The \textit{id} is \textit{id\_pbox}.
5157 %</en>
5158 %<*ja>
5159 \item その \verb+\ltj@icflag+ の値が$[3,15)$に入るノードのリスト.
5160   これらのノードはある既にパッケージングされた水平ボックスから \verb+\unhbox+ で
5161   アンパックされたものである.
5162   その\textit{id}は\textit{id\_pbox}である.
5163 %</ja>
5164
5165 %<*en>
5166 \item A inline math formula, including two \textit{math\_node}s at the boundary of it.
5167       The \textit{id} is \textit{id\_math}.
5168 %</en>
5169 %<*ja>
5170 \item インライン数式でその境界に2つの\textit{math\_node}を含むもの.
5171   その\textit{id}は\textit{id\_math}である.
5172 %</ja>
5173
5174 %<*en>
5175 \item A \textit{glyph\_node}~$p$ with nodes which relate with it:
5176 %</en>
5177 %<*ja>
5178 \item \textit{glpyh\_node}~$p$とそれに関係するノード:
5179 %</ja>
5180 \begin{enumerate}
5181 %<*en>
5182 \item A kern for the italic correction of~$p$.
5183 %</en>
5184 %<*ja>
5185 \item $p$のイタリック補正のためのカーン.
5186 %</ja>
5187
5188 %<*en>
5189 \item An accent attached to $p$ by \verb+\accent+.
5190 %</en>
5191 %<*ja>
5192 \item \verb+\accent+ による$p$に付随したアクセント.
5193 %</ja>
5194 \end{enumerate}
5195 \[
5196 \overbrace{%
5197  \Node{kern}{$\mathit{subtype}=2$}\longrightarrow
5198 \left\{\begin{array}{c}
5199 \Node{glyph}{accent}\\\noalign{\medskip}
5200 \Node{hbox}{accent (shifted vert.)}
5201 \end{array}\right\}\longrightarrow
5202 \Node{kern}{$\mathit{subtype}=2$}}^{\text{(a)}}
5203 \longrightarrow
5204 \Node{glyph}{$p$}\longrightarrow
5205 \overbrace{%
5206 \Node{kern}{italic corr.}}^{\text{(b)}}
5207 \]
5208
5209 %<*en>
5210 The \textit{id} is \textit{id\_jglyph} or
5211 \textit{id\_glyph}, according to whether the \textit{glyph\_node}
5212 represents a Japanese character or not.
5213 %</en>
5214 %<*ja>
5215 \textit{id}は\textit{glyph\_node}が和文文字を表すかどうかによって
5216 \textit{id\_jglyph},もしくは\textit{id\_glyph}となる.
5217 %</ja>
5218
5219 %<*en>
5220 \item An box-like node, that is, an hbox, a vbox, a rule (\verb+\vrule+) and an \textit{unset\_node}.
5221 The \textit{id} is \textit{id\_hlist} if the node is an
5222       hbox which is not shifted vertically, or \textit{id\_box\_like}
5223       otherwise.
5224 %</en>
5225 %<*ja>
5226 \item ボックス様のノード,つまり水平ボックス,垂直ボックス,罫線 (\verb+\vrule+),
5227   そして\textit{unset\_node}.
5228   その\textit{id}は垂直に移動していない水平ボックスならば\textit{id\_hlist},
5229   そうでなければ\textit{id\_box\_like}となる.
5230 %</ja>
5231
5232 %<*en>
5233 \item A glue, a kern whose subtype is not 2~(\textit{accent}), and a discretionary break.
5234 The \textit{id} is \textit{id\_glue}, \textit{id\_kern}
5235       and \textit{id\_disc}, respectively.
5236 %</en>
5237 %<*ja>
5238 \item グルー,subtypeが 2~(\textit{accent})ではないカーン,そして任意改行.
5239   その\textit{id}はそれぞれ\textit{id\_glue}, \textit{id\_kern},そして
5240   \textit{id\_disc}である.
5241 %</ja>
5242 \end{enumerate}
5243 %<*en>
5244 Let \textit{Np}, \textit{Nq} and \textit{Nr} denote a cluster.
5245 %</en>
5246 %<*ja>
5247 以下では\textit{Np}, \textit{Nq}, \textit{Nr}でクラスタを表す.
5248 %</ja>
5249 \end{defn}
5250
5251 \paragraph{\textit{id}の意味}
5252 $\mathit{Np}.\mathit{id}$の意味を述べるとともに,
5253 「先頭の文字」を表す\textit{glyph\_node}~$\mathit{Np}.\mathit{head}$と,
5254 「最後の文字」を表す\textit{glyph\_node}~$\mathit{Np}.\mathit{tail}$を次のように定義する.
5255 直感的に言うと,\textit{Np}は$\mathit{Np}.\mathit{head}$で始まり$\mathit{Np}.\mathit{tail}$で終わるような単語,
5256 と見做すことができる.これら$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は
5257 説明用に準備した概念であって,実際のLuaコード中にそのように書かれているわけではないことに注意.
5258
5259 \begin{description}
5260 \item[\textit{id\_jglyph}] 和文文字.\\
5261 $\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は,その和文文字を表している
5262 \textit{glyph\_node}そのものである.
5263 \item[\textit{id\_glyph}] 和文文字を表していない\textit{glyph\_node}~$p$.\\
5264 多くの場合,$p$は欧文文字を格納しているが,「ffi」などの合字によって作られた
5265 \textit{glyph\_node}である可能性もある.
5266 前者の場合,$\mathit{Np}.\mathit{head}$,~$\mathit{Np}.\mathit{tail} = p$である.
5267 一方,後者の場合,
5268 \begin{itemize}
5269 \item $\mathit{Np}.\mathit{head}$は,
5270 合字の構成要素の先頭→(その\textit{glyph\_node}における)合字の構成要素の先頭→……
5271 と再帰的に検索していってたどり着いた\textit{glyph\_node}である.
5272 \item $\mathit{Np}.\mathit{last}$は,同様に末尾→末尾→と検索してたどり着いた\textit{glyph\_node}である.
5273 \end{itemize}
5274 \item[\textit{id\_math}] インライン数式.\\
5275 便宜的に,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$ともに
5276 「文字コード$-1$の欧文文字」とおく.
5277 \item[\textit{id\_hlist}] 縦方向にシフトされていない水平ボックス.\\
5278 この場合,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$はそれぞれ$p$の内容を表すリストの,
5279 先頭・末尾のノードである.
5280 \begin{itemize}
5281 \item 状況によっては,\TeX ソースで言うと
5282 \begin{verbatim}
5283 \hbox{\hbox{abc}...\hbox{\lower1pt\hbox{xyz}}}
5284 \end{verbatim}
5285 のように,$p$の内容が別の水平ボックスで開始・終了している可能性も十分あり得る.そのような場合,
5286 $\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$の算出は,
5287 \emph{垂直方向にシフトされていない}水平ボックスの
5288 場合だけ内部を再帰的に探索する.例えば上の例では,$\mathit{Np}.\mathit{head}$は文字「a」を表すノードであり,
5289 一方$\mathit{Np}.\mathit{tail}$は垂直方向にシフトされた水平ボックス,
5290 \verb+\lower1pt\hbox{xyz}+ に対応するノードである.
5291 \item また,先頭にアクセント付きの文字がきたり,末尾にイタリック補正用のカーンが
5292 来ることもあり得る.この場合は,クラスタの定義のところにもあったように,それらは無視して算出を行う.
5293 \item 最初・最後のノードが合字によって作られた\textit{glyph\_node}のときは,それぞれに対して\textit{id\_glyph}%
5294 と同様に再帰的に構成要素をたどっていく.
5295 \end{itemize}
5296 \item[\textit{id\_pbox}] 「既に処理された」ノードのリストであり,これらのノードが二度処理を受けないために
5297 まとめて1つのクラスタとして取り扱うだけである.
5298 \textit{id\_hlist}と同じ方法で$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$を算出する,
5299 \item[\textit{id\_disc}] discretionary break (\verb+\discretionary{pre}{post}{nobreak}+).\\
5300 \textit{id\_hlist}と同じ方法で$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$を算出するが,
5301 第3引数の \texttt{nobreak}(行分割が行われない時の内容)を使う.言い換えれば,ここで行分割が発生した時の状況は
5302 全く考慮に入れない.
5303 \item[\textit{id\_box\_like}] \textit{id\_hlist}とならないboxや,rule.\\
5304 この場合は,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$のデータは利用されないので,2つの算出は無意味である.
5305 敢えて明示するならば,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は共にnil値である.
5306 \item[他] 以上にない\textit{id}に対しても,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$の算出は無意味.
5307 \end{description}
5308
5309 \paragraph{クラスタの別の分類}
5310 さらに,JFMグルー挿入処理の実際の説明により便利なように,\textit{id}とは別のクラスタの分類を行っておく.
5311 挿入処理では2つの隣り合ったクラスタの間に
5312 空白等の実際の挿入を行うことは前に書いたが,ここでの説明では,問題にしているクラスタ\textit{Np}は「後ろ側」のクラスタである
5313 とする.「前側」のクラスタについては,以下の説明で\textit{head}が\textit{last}に置き換わることに注意すること.
5314 \begin{description}
5315 \item[和文A] リスト中に直接出現している和文文字.
5316 \textit{id}が\textit{id\_jglyph}であるか,\\
5317 \textit{id}が\textit{id\_pbox}であって$\mathit{Np}.\mathit{head}$が\textbf{JAchar}であるとき.
5318
5319 \item[和文B] リスト中の水平ボックスの中身の先頭として出現した和文文字.和文Aとの違いは,これの前に
5320 JFMグルーの挿入が行われない(\Param{\hyperlink{fld:xks}{xkanjiskip}},~\Param{\hyperlink{fld:kanjiskip}{kanjiskip}}は入り得る)ことである.\\
5321 \textit{id}が\textit{id\_hlist}か\textit{id\_disc}であって$\mathit{Np}.\mathit{head}$が\textbf{JAchar}であるとき.
5322
5323 \item[欧文] リスト中に直接/水平ボックスの中身として出現している欧文文字.次の3つの場合が該当:
5324 \begin{itemize}
5325 \item \textit{id}が\textit{id\_glyph}である.
5326 \item \textit{id}が\textit{id\_math}である.
5327 \item \textit{id}が\textit{id\_pbox}か\textit{id\_hlist}か\textit{id\_disc}であって,$\mathit{Np}.\mathit{head}$が\textbf{ALchar}.
5328 \end{itemize}
5329 \item[箱] box,またはそれに類似するもの.次の2つが該当:
5330 \begin{itemize}
5331 \item \textit{id}が\textit{id\_pbox}か\textit{id\_hlist}か\textit{id\_disc}であって,$\mathit{Np}.\mathit{head}$が\textit{glyph\_node}でない.
5332 \item \textit{id}が\textit{id\_box\_like}である.
5333 \end{itemize}
5334
5335 \end{description}
5336
5337 \subsection{段落/水平ボックスの先頭や末尾}
5338 \paragraph{先頭部の処理}
5339 まず,段落/水平ボックスの一番最初にあるクラスタ\textit{Np}を探索する.
5340 水平ボックスの場合は何の問題もないが,段落の場合では以下のノード達を事前に読み飛ばしておく:
5341 \begin{itemize}
5342 \item \verb+\parindent+ 由来の水平ボックス($\mathit{subtype}=3$)
5343 \item \textit{subtype}が44~(\textit{user\_defined})でないようなwhatsit
5344 \end{itemize}
5345 これは,\verb+\parindent+由来の水平ボックスがクラスタを構成しないようにするためである.
5346
5347 次に,\textit{Np}の直前に空白$g$を必要なら挿入する:
5348 \begin{enumerate}
5349 \item この処理が働くような\textit{Np}は\textsf{和文A}である.
5350 \item 問題のリストが字下げありの段落(\verb+\parindent+ 由来の水平ボックスあり)の場合は,
5351 この空白$g$は「文字コード \texttt{'parbdd'} の文字」と\textit{Np}の間に入るグルー/カーンである.
5352 \item そうでないとき(\verb+noindent+ で開始された段落や水平ボックス)は,
5353 $g$は「文字コード \texttt{'boxbdd'} の文字」と\textit{Np}の間に入るグルー/カーンである.
5354 \end{enumerate}
5355 ただし,もし$g$がglueであった場合,この挿入によって\textit{Np}による行分割が新たに可能になるべきではない.
5356 そこで,以下の場合には,$g$の直前に \verb+\penalty10000+ を挿入する:
5357 \begin{itemize}
5358 \item 問題にしているリストが段落であり,かつ
5359 \item \textit{Np}の前には予めペナルティがなく,$g$はglue.
5360 \end{itemize}
5361
5362 \paragraph{末尾の処理}
5363 末尾の処理は,問題のリストが段落のものか水平ボックスのものかによって異なる.
5364 後者の場合は容易い:最後のクラスタを\textit{Nq}とおくと,\textit{Nq}と「文字コード\ 
5365 \texttt{'boxbdd'} の文字」の間に入るグルー/カーンを,
5366 \textit{Nq}の直後に挿入するのみである.
5367
5368 一方.前者(段落)の場合は,リストの末尾は常に \verb+\penalty10000+ と,
5369 \verb+\parfillskip+ 由来のグルーが存在する.%よって,最後のクラスタ\textit{Np}は
5370 %この \verb+\parfillskip+ 由来のグルーとなり,実質的な中身の最後はその1つ前のクラスタ\textit{Nq}となる.
5371 段落の最後の「通常の和文文字${}+{}$句点」が独立した行となるのを防ぐために,
5372 \Param{jcharwidowpenalty}の値の分だけ適切な場所のペナルティを増やす.
5373
5374 ペナルティ量を増やす場所は,\textit{head}が\textbf{JAchar}であり,
5375 かつその文字の\Param{kcatcode}が偶数であるような
5376 最後のクラスタの直前にあるものたちである%
5377 \footnote{大雑把に言えば,\Param{kcatcode}が奇数であるような\textbf{JAchar}%
5378 を約物として考えていることになる.
5379 \Param{kcatcode}の最下位ビットはこの\Param{jcharwidowpenalty}用にのみ利用される.}.
5380
5381 \subsection{概観と典型例:2つの「和文A」の場合}
5382 \label{ssec-cluster-wa}
5383 先に述べたように,2つの隣り合ったクラスタ,\textit{Nq}と\textit{Np}の間には,
5384 ペナルティ,\verb+\vadjust+,whatsitなど,行組版には関係しないものがある.模式的に表すと,
5385 \[
5386  \Node{cluster}{\textit{Nq}}\longrightarrow
5387 \overbrace{
5388 \Node{penalty}{$p$}\longrightarrow \cdots\longrightarrow \Node{whatsit}{}}^{\textrm{(a)}}
5389 \longrightarrow \Node{cluster}{\textit{Np}}
5390 \]
5391 のようになっている.間の(a)に相当する部分には,何のノードもない場合ももちろんあり得る.
5392 そうして,JFMグルー挿入後には,この2クラスタ間は次のようになる:
5393 \[
5394  \Node{cluster}{\textit{Nq}}\longrightarrow%\Node{kern}{左空白}\longrightarrow
5395 \overbrace{
5396 \Node{penalty}{$p+x$}\longrightarrow \cdots\longrightarrow 
5397 \Node{whatsit}{}}^{\textrm{(a)}}\longrightarrow 
5398 \Node{glue or kern}{\raisebox{-.2\zw}{右空白}}\longrightarrow
5399 \Node{cluster}{\textit{Np}}
5400 \]
5401
5402 以後,\emph{典型的な例として,クラスタ\textit{Nq}と\textit{Np}が共に\textsf{\textmd{和文A}}である場合を見ていこう,}
5403 この場合が全ての場合の基本となる.
5404
5405 \paragraph{「右空白」の算出}
5406 まず,「右空白」にあたる量を算出する.通常はこれが,隣り合った2つの和文文字間に入る空白量となる.
5407 \begin{description}
5408 \item[JFM由来{[M]}] JFMの文字クラス指定によって入る空白を以下によって求める.この段階で空白量が未定義(未指定)だった場合,
5409       デフォルト値\Param{\hyperlink{fld:kanjiskip}{kanjiskip}}を採用することとなるので,次へ.
5410 \begin{enumerate}
5411 \item もし両クラスタの間で \verb+\inhibitglue+ が実行されていた場合(証としてwhatsitノードが自動挿入される),
5412       代わりに\Param{\hyperlink{fld:kanjiskip}{kanjiskip}}が挿入されることとなる.次へ.
5413 \item \textit{Nq}と\textit{Np}が同じJFM・同じ\texttt{jfmvar}キー・同じサイズの和文フォントであったならば,
5414       共通に使っているJFM内で挿入される空白(グルーかカーン)が決まっているか調べ,決まっていればそれを採用.
5415 \item 1.でも2.でもない場合は,JFM・\texttt{jfmvar}・サイズの3つ組は\textit{Nq}と\textit{Np}で異なる.
5416 この場合,まず
5417 \[
5418 \vcenter{\halign{\hfil$#:={}$&\inhibitglue#\inhibitglue\cr
5419 gb&(\textit{Nq}と「使用フォントが\textit{Nq}のそれと同じで,\hfil\cr
5420 \omit&\quad 文字コードが\textit{Np}のそれの文字」との間に入るグルー/カーン)\hfil\cr
5421 ga&(\inhibitglue 「使用フォントが\textit{Np}のそれと同じで,\hfil\cr
5422 \omit&\quad 文字コードが\textit{Nq}のそれの文字」と\textit{Np}との間に入るグルー/カーン)\hfil\cr
5423 }}
5424 \]
5425 として,前側の文字のJFMを使った時の空白(グルー/カーン)と,後側の文字のJFMを使った時のそれを求める.
5426
5427 $\mathit{gb}$,~$\mathit{ga}$それぞれに対する<ratio>の値を$d_b$,~$d_a$とする.
5428 \begin{itemize}
5429 \item 
5430 $\mathit{ga}$と$\mathit{gb}$の両方が未定義であるならば,JFM由来のグルーは挿入されず,
5431 \Param{\hyperlink{fld:kanjiskip}{kanjiskip}}を採用することとなる.
5432 どちらか片方のみが未定義であるならば,次のステップでその未定義の方は長さ0のkernで,<ratio>の値は0であるかのように扱われる.
5433 \item 
5434 \Param{\hyperlink{fld:diffjfm}{diffrentjfm}}の値が \texttt{pleft}, \texttt{pright},
5435       \texttt{paverage} のとき,
5436 <ratio>の指定に従って比例配分を行う.
5437 JFM由来のグルー/カーンは以下の値となる:
5438 \[
5439  f\left(\frac{1-d_b}2\textit{gb} + \frac{1+d_b}2\textit{ga},
5440 \frac{1-d_a}2\textit{gb} + \frac{1+d_a}2\textit{ga}\right)
5441 \]
5442 ここで.$f(x,y)$は
5443 \[
5444  f(x,y)=\begin{cases}
5445 x&\text{if\ }\Param{\hyperlink{fld:diffjfm}{diffrentjfm}}=\texttt{pleft};\\
5446 y&\text{if\ }\Param{\hyperlink{fld:diffjfm}{diffrentjfm}}=\texttt{pright};\\
5447 (x+y)/2&\text{if\ }\Param{\hyperlink{fld:diffjfm}{diffrentjfm}}=\texttt{paverage};
5448 \end{cases}.
5449 \]
5450 \item 
5451 \Param{differentjfm}がそれ以外の値の時は,<ratio>の値は無視され,JFM由来のグルー/カーンは以下の値となる:
5452 \[
5453  f(\textit{gb},\textit{ga})
5454 \]
5455 ここで.$f(x,y)$は
5456 \[
5457  f(x,y)=\begin{cases}
5458 \min(x,y)&\text{if\ }\Param{\hyperlink{fld:diffjfm}{diffrentjfm}}=\texttt{small};\\
5459 \max(x,y)&\text{if\ }\Param{\hyperlink{fld:diffjfm}{diffrentjfm}}=\texttt{large};\\
5460 (x+y)/2&\text{if\ }\Param{\hyperlink{fld:diffjfm}{diffrentjfm}}=\texttt{average};\\
5461 x+y&\text{if\ }\Param{\hyperlink{fld:diffjfm}{diffrentjfm}}=\texttt{both};
5462 \end{cases}.
5463 \]
5464 \end{itemize}
5465 \end{enumerate}
5466
5467 例えば,
5468 \begin{verbatim}
5469 \jfont\foo=psft:Ryumin-Light:jfm=ujis
5470 \jfont\bar=psft:GothicBBB-Medium:jfm=ujis
5471 \jfont\baz=psft:GothicBBB-Medium:jfm=ujis;jfmvar=piyo
5472 \end{verbatim}
5473 という3フォントを考え,
5474 \[
5475  \overbrace{\Node{glyph}{{\tt\char`\\foo}, `あ'}}^{p}
5476 \longrightarrow \overbrace{\Node{glyph}{{\tt\char`\\bar}, `い'}}^{q}
5477 \longrightarrow \overbrace{\Node{glyph}{{\tt\char`\\baz}, `う'}}^{r}
5478 \]
5479 という3ノードを考える(それぞれ単独でクラスタをなす).
5480 この場合,$p$と$q$の間は,実フォントが異なるにもかかわらず2.の状況となる一方で,
5481 $q$と$r$の間は(実フォントが同じなのに)\texttt{jfmvar} キーの内容が異なるので3.の状況となる.
5482 \item[\Param{kanjiskip}~{[K]}] 上の[M]において空白が定まらなかった場合,
5483 以下で定めた量「右空白」として採用する.
5484 この段階においては,\verb+\inhibitglue+ は効力を持たないため,
5485 結果として,2つの和文文字間には常に何らかのグルー/カーンが挿入されることとなる.
5486 \begin{enumerate}
5487 \item 両クラスタ(厳密には$\mathit{Nq}.\mathit{tail}$,$\mathit{Np}.\mathit{head}$)の中身の文字コードに対する
5488 \Param{autospacing}パラメタが両方ともfalseだった場合は,長さ0のglueとする.
5489 \item ユーザ側から見た\Param{\hyperlink{fld:kanjiskip}{kanjiskip}}パラメタの自然長が${\tt \char`\\maxdimen}=(2^{30}-1)\,{\rm sp}$で
5490 なければ,\Param{\hyperlink{fld:kanjiskip}{kanjiskip}}パラメタの値を持つglueを採用する.
5491 \item 2.でない場合は,\textit{Nq}, \textit{Np}で使われているJFMに指定されている\Param{\hyperlink{fld:kanjiskip}{kanjiskip}}の値を用いる.
5492 どちらか片方のクラスタだけが和文文字(\textsf{和文A}・\textsf{和文B})のときは,そちらのクラスタで使われている
5493 JFM由来の値だけを用いる.もし両者で使われているJFMが異なった場合は,上の[M]~3.と同様の方法を用いて調整する.
5494 \end{enumerate}
5495 \end{description}
5496 %\paragraph{「左空白」の算出とそれに伴う補正}
5497 %「左空白」は過去のバージョンでは定義していたが,このバージョンでは
5498 %挿入は一切行われない(機能自体削除している).
5499 %しかし,仕様は流動的であり,将来復活する可能性もあるため,マニュアル中の記述は今のところ極力変更しない.
5500 \paragraph{禁則用ペナルティの挿入}
5501 まず,
5502 \[
5503  a:=(\text{\textit{Nq}{\footnotemark}の文字に対する\Param{\hyperlink{fld:postbp}{postbreakpenalty}}の値})
5504 +(\text{\textit{Np}{\footnotemark}の文字に対する\Param{\hyperlink{fld:prebp}{prebreakpenalty}}の値})
5505 \]
5506 とおく\footnotetext{厳密にはそれぞれ$\mathit{Nq}.\mathit{tail}$,$\mathit{Np}.\mathit{head}$.}.
5507 ペナルティは通常$[-10000,10000]$の整数値をとり,また$\pm 10000$は正負の無限大を意味することになっているが,この$a$の
5508 算出では単純な整数の加減算を行う.
5509
5510 $a$は禁則処理用に\textit{Nq}と\textit{Np}の間に加えられるべきペナルティ量である.
5511 \begin{description}
5512 \item[P-normal~{[PN]}]
5513 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティ(\textit{penalty\_node})があれば処理は簡単である:
5514 それらの各ノードにおいて,ペナルティ値を($\pm 10000$を無限大として扱いつつ)$a$だけ増加させればよい.
5515 また,$10000 + (-10000) = 0$としている.
5516
5517 少々困るのは,(a)部分にペナルティが存在していない場合である.
5518 直感的に,補正すべき量$a$が0でないとき,その値をもつ\textit{penalty\_node}を作って
5519 「右空白」の(もし未定義なら\textit{Np}の)直前に挿入……
5520 ということになるが,実際には僅かにこれより複雑である.
5521 \begin{itemize}
5522 \item 「右空白」がカーンであるとき,
5523 それは「\textit{Nq}と\textit{Np}の間で改行は許されない」ことを意図している.そのため,
5524 この場合は$a\neq 0$であってもペナルティの挿入はしない.
5525 \item そうでないないときは,$a\neq 0$ならば\textit{penalty\_node}を作って挿入する.
5526 %\item 「左空白」がカーンとしてきっちり定義されている時(このとき,「右空白」はカーンでない),
5527 %この「左空白」の直後での行分割を許容しないといけないので,$a=0$であっても
5528 %\textit{penalty\_node}を作って挿入する.
5529 %\item 以上のどれでもないときは,$a\neq 0$ならば\textit{penalty\_node}を作って挿入する.
5530 \end{itemize}
5531 \end{description}
5532
5533 \def\gkf#1#2#3{\sf$\displaystyle\vphantom{\Bigg(}%
5534   \frac{\hbox to 4\zw{\hss#2\hss}}{\hbox{#3}}$}
5535 \begin{table}[t]
5536 %<en>\caption{Summary of JFM glues}
5537 %<ja>\caption{JFM グルーの概要}
5538 \label{tab-jfmglue}
5539 \begin{center}
5540 \small
5541 \begin{tabular}{c|cccccc}
5542 \toprule
5543 {\bf\textit{Np}}↓&\sf 和文A&\sf 和文B&\sf 欧文&\sf 箱&\sf glue&\sf kern\\\midrule
5544 \sf 和文A&
5545 \gkf{E}{M→K}{PN}&
5546 \gkf{---}{\OA →K}{PN}&
5547 \gkf{---}{\OA →X}{PN}&
5548 \gkf{---}{\OA}{PA}&
5549 \gkf{---}{\OA}{PN}&
5550 \gkf{---}{\OA}{PS}\\
5551 \sf 和文B&
5552 \gkf{E}{\OB→K}{PA}&
5553 \gkf{---}{K}{PS}&
5554 \gkf{---}{X}{PS}\\
5555 \sf 欧文&
5556 \gkf{E}{\OB →X}{PA}&
5557 \gkf{---}{X}{PS}\cr
5558 \sf 箱&\gkf{E}{\OB}{PA}\\
5559 \sf glue&\gkf{E}{\OB}{PN}\\
5560 \sf kern&\gkf{E}{\OB}{PS}\\
5561 \bottomrule
5562 \end{tabular}
5563 \end{center}
5564 \begin{quote}
5565 %<*en>
5566 In the table above, {\small\gkf{E}{M→K}{PN}} means that
5567 %</en>
5568 %<*ja>
5569 上の表において,{\small\gkf{E}{M→K}{PN}}は次の意味である:
5570 %</ja>
5571 \begin{enumerate}
5572 %<*en>
5573 \item To determine the ``right-space'', \LuaTeX-ja first attempts by the method ``\textsf{JFM-origin~[M]}''.
5574 If this attempt fails, \LuaTeX-ja use the method ``\textsf{\Param{kanjiskip}~[K]}''.
5575 %</en>
5576 %<*ja>
5577 \item 「右空白」を決めるために,\LuaTeX-ja はまず「JFM由来{[M]}」の方法を試みる.
5578   これが失敗したら,\LuaTeX-ja は「\Param{kanjiskip}~{[K]}」の方法を試みる.
5579 %</ja>
5580
5581 % %<*en>
5582 % \item The ``left space'' between \textit{Nq}~and~\textit{Np} is 
5583 %   determined by the method ``\textsf{line-end~[E]}''.
5584 % %</en>
5585 % %<*ja>
5586 % \item \textit{Nq} と \textit{Np} の間の「左空白」は「\textsf{line-end~[E]}」の
5587 %   方法で決定される.
5588 % %</ja>
5589
5590 %<*en>
5591 \item \LuaTeX-ja adopts the method ``\textsf{P-normal~[PN]}'' to adjust the penalty 
5592   between two clusters for \emph{kinsoku shori}.
5593 %</en>
5594 %<*ja>
5595 \item \LuaTeX-jaは2つのクラスタの間の禁則処理用のペナルティを調節するために「\textsf{P-normal~[PN]}」の方法を採用する.
5596 %</ja>
5597 \end{enumerate}
5598 \end{quote}
5599 \end{table}
5600
5601 \subsection{その他の場合}
5602 本節の内容は表\ref{tab-jfmglue}にまとめてある.
5603
5604 \paragraph{和文Aと欧文の間}
5605 \textit{Nq}が\textsf{和文A}で,\textit{Np}が\textsf{欧文}の場合,JFMグルー挿入処理は次のようにして行われる.
5606 \begin{itemize}
5607 \item 「右空白」については,まず以下に述べる\textsf{Boundary-B~[\OB]}により空白を決定しようと試みる.
5608 それが失敗した場合は,\textsf{\Param{\hyperlink{fld:xks}{xkanjiskip}}~[X]}によって定める.
5609 %\item 「左空白」については,既に述べた\textsf{line-end~[E]}をそのまま採用する.それに伴う「右空白」の補正も%同じ.
5610 \item 禁則用ペナルティも,以前述べた\textsf{P-normal~[PN]}と同じである.
5611 \end{itemize}
5612 \begin{description}
5613 \item[Boundary-B~{[\OB]}] 和文文字と「和文でないもの」との間に入る空白を以下によって求め,
5614 未定義でなければそれを「右空白」として採用する.
5615 \textsf{JFM-origin~[M]}の変種と考えて良い.
5616 これによって定まる空白の典型例は,和文の閉じ括弧と欧文文字の間に入る半角アキである.
5617 \begin{enumerate}
5618 \item もし両クラスタの間で \verb+\inhibitglue+ が実行されていた場合%
5619 (証としてwhatsitノードが自動挿入される),「右空白」は未定義.
5620 \item そうでなければ,
5621 \textit{Nq}と「文字コードが {\tt'jcharbdd'} の文字」との間に入るグルー/カーンとして定まる.
5622 \end{enumerate}
5623 \item[\Param{xkanjiskip}~{[X]}]
5624 この段階では,\textsf{\Param{kanjiskip}~[K]}のときと同じように,
5625 以下で定めた量を「右空白」として採用する.
5626 \verb+\inhibitglue+ は効力を持たない.
5627 \begin{enumerate}
5628 \item 以下のいずれかの場合は,\Param{\hyperlink{fld:xks}{xkanjiskip}}の挿入は抑止される.しかし,実際には行分割を許容するために,長さ0のglueを採用する:
5629 \begin{itemize}
5630 \item 両クラスタにおいて,それらの中身の文字コードに対する\Param{autoxspacing}パラメタが共にfalseである.
5631 \item \textit{Nq}の中身の文字コードについて,「直後への\Param{\hyperlink{fld:xks}{xkanjiskip}}の挿入」が禁止されている
5632 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメタが2以上).
5633 \item \textit{Np}の中身の文字コードについて,「直前への\Param{\hyperlink{fld:xks}{xkanjiskip}}の挿入」が禁止されている
5634 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメタが偶数).
5635 \end{itemize}
5636 \item ユーザ側から見た\Param{\hyperlink{fld:xks}{xkanjiskip}}パラメタの自然長が${\tt \char`\\maxdimen}=(2^{30}-1)\,{\rm sp}$で
5637 なければ,\Param{\hyperlink{fld:xks}{xkanjiskip}}パラメタの値を持つglueを採用する.
5638 \item 2.でない場合は,\textit{Nq}, \textit{Np}(\textsf{和文A}/\textsf{和文B}なのは片方だけ)
5639 で使われているJFMに指定されている\Param{\hyperlink{fld:xks}{xkanjiskip}}の値を用いる.
5640 \end{enumerate}
5641 \end{description}
5642
5643 \paragraph{欧文と和文Aの間}
5644 \textit{Nq}が\textsf{欧文}で,\textit{Np}が\textsf{和文A}の場合,JFMグルー挿入処理は上の場合とほぼ同じである.
5645 \textsf{和文A}のクラスタが逆になるので,\textsf{Boundary-A~[\OA]}の部分が変わるだけ.
5646 \begin{itemize}
5647 \item 「右空白」については,まず以下に述べる\textsf{Boundary-A~[\OA]}により空白を決定しようと試みる.
5648 それが失敗した場合は,\textsf{\Param{\hyperlink{fld:xks}{xkanjiskip}}~[X]}によって定める.
5649 %\item \textit{Nq}が和文でないので,「左空白」は算出されない.
5650 \item 禁則用ペナルティは,以前述べた\textsf{P-normal~[PN]}と同じである.
5651 \end{itemize}
5652 \begin{description}
5653 \item[Boundary-A~{[\OA]}] 「和文でないもの」と和文文字との間に入る空白を以下によって求め,
5654 未定義でなければそれを「右空白」として採用する.
5655 \textsf{JFM-origin~[M]}の変種と考えて良い.
5656 これによって定まる空白の典型例は,欧文文字と和文の開き括弧との間に入る半角アキである.
5657 \begin{enumerate}
5658 \item もし両クラスタの間で \verb+\inhibitglue+ が実行されていた場合(証としてwhatsitノードが自動挿入される),次へ.
5659 \item そうでなければ,
5660 「文字コードが {\tt'jcharbdd'} の文字」と\textit{Np}との間に入るグルー/カーンとして定まる.
5661 \end{enumerate}
5662 \end{description}
5663
5664 \paragraph{和文Aと箱・グルー・カーンの間}
5665 \textit{Nq}が\textsf{和文A}で,\textit{Np}が\textsf{箱}・グルー・カーンのいずれかであった場合,
5666 両者の間に挿入されるJFMグルーについては同じ処理である.しかし,そこでの行分割に対する仕様が異なるので,
5667 ペナルティの挿入処理は若干異なったものとなっている.
5668
5669 \begin{itemize}
5670 \item 「右空白」については,既に述べた\textsf{Boundary-B~[\OB]}により空白を決定しようと試みる.
5671 それが失敗した場合は,「右空白」は挿入されない.
5672 %\item 「左空白」については,既に述べた\textsf{line-end~[E]}の算出方法をそのまま採用する.それに伴う「右空白」の補正も同じ.
5673 \item 禁則用ペナルティの処理は,後ろのクラスタ\textit{Np}の種類によって異なる.
5674 なお,$\mathit{Np}.\mathit{head}$は無意味であるから,
5675 「$\mathit{Np}.\mathit{head}$に対する\Param{\hyperlink{fld:prebp}{prebreakpenalty}}の値」は0とみなされる.言い換えれば,
5676 \[
5677  a:=(\text{\textit{Nq}の文字に対する\Param{\hyperlink{fld:postbp}{postbreakpenalty}}の値}).
5678 \]
5679 \begin{description}
5680 \item[箱] \textit{Np}が\textsf{箱}であった場合は,両クラスタの間での行分割は
5681 (明示的に両クラスタの間に \verb+\penalty10000+ があった場合を除き)いつも許容される.そのため,
5682 ペナルティ処理は,後に述べる\textsf{P-allow~[PA]}が\textsf{P-normal~[PN]}の代わりに用いられる.
5683 \item[グルー] \textit{Np}がグルーの場合,ペナルティ処理は\textsf{P-normal~[PN]}を用いる.
5684 \item[カーン] \textit{Np}がカーンであった場合は,両クラスタの間での行分割は
5685 (明示的に両クラスタの間にペナルティがあった場合を除き)許容されない.
5686 ペナルティ処理は,後に述べる\textsf{P-suppress~[PS]}を使う.
5687 \end{description}
5688 これらの\textsf{P-normal~[PN]},\textsf{P-allow~[PA]},\textsf{P-suppress~[PS]}の違いは,
5689 \textit{Nq}と\textit{Np}の間(以前の図だと(a)の部分)にペナルティが存在しない場合にのみ存在する.
5690 \end{itemize}
5691
5692 \begin{description}
5693 \item[P-allow~{[PA]}]
5694 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティがあれば,\textsf{P-normal~[PN]}と同様に,
5695 それらの各ノードにおいてペナルティ値を$a$だけ増加させる.
5696
5697 (a)部分にペナルティが存在していない場合,
5698 \LuaTeX-ja は\textit{Nq}と\textit{Np}の間の行分割を可能にしようとする.
5699 そのために,以下の場合に$a$をもつ\textit{penalty\_node}を作って
5700 「右空白」の(もし未定義なら\textit{Np}の)直前に挿入する:
5701 \begin{itemize}
5702 \item 「右空白」がグルーでない(カーンか未定義)であるとき.
5703 %\item 「左空白」がカーンとしてきっちり定義されている時.
5704 \end{itemize}
5705
5706 \item[P-suppress~{[PS]}]
5707 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティがあれば,\textsf{P-normal~[PN]}と同様に,
5708 それらの各ノードにおいてペナルティ値を$a$だけ増加させる.
5709
5710 (a)部分にペナルティが存在していない場合,
5711 \textit{Nq}と\textit{Np}の間の行分割は元々不可能のはずだったのであるが,
5712 \LuaTeX-ja はそれをわざわざ行分割可能にはしない.
5713 そのため,「右空白」がglueであれば,その直前に \verb+\penalty10000+ を挿入する.
5714 \end{description}
5715
5716 なお,「右空白」はカーンの%,「左空白」は未定義の
5717 \[
5718  \overbrace{\Node{glyph}{`あ'}}^{\mathit{Nq}}\longrightarrow \overbrace{\Node{glue}{1\,pt}}^{\mathit{Np}}
5719 \]
5720 のような状況を考える.
5721 このとき,$a$,即ち「あ」の\Param{\hyperlink{fld:postbp}{postbreakpenalty}}がいかなる値であっても,
5722 この2クラスタ間は最終的に
5723 \begin{equation}
5724  \overbrace{\Node{glyph}{`あ'}}^{\mathit{Nq}}\longrightarrow
5725 \Node{kern}{右空白}\longrightarrow \overbrace{\Node{glue}{1\,pt}}^{\mathit{Np}}
5726 \label{eq-gref}
5727 \end{equation}
5728 となり,$a$分のペナルティは挿入されないことに注意して欲しい.
5729 \Param{\hyperlink{fld:postbp}{postbreakpenalty}}は($a$は)殆どの場合が非負の値と考えられ,そのような場合では
5730 \eqref{eq-gref}と
5731 \[
5732  \overbrace{\Node{glyph}{`あ'}}^{\mathit{Nq}}\longrightarrow
5733 \Node{penalty}{$a$}\longrightarrow
5734 \Node{kern}{右空白}\longrightarrow \overbrace{\Node{glue}{1\,pt}}^{\mathit{Np}}
5735 \]
5736 との間に差異は生じない%
5737 \footnote{kern$\rightarrow$glueが1つの行分割可能点(行分割に伴うペナルティは0)
5738 であるため,たとえ$a=10000$であっても,\textit{Nq}と\textit{Np}の間で行分割を禁止することはできない.}.
5739
5740 \paragraph{箱・グルー・カーンと和文Aの間}
5741 \textit{Np}が\textsf{箱}・グルー・カーンのいずれかで,\textit{Np}が\textsf{和文A}であった場合は,
5742 すぐ上の(\textit{Nq}と\textit{Np}の順序が逆になっている)場合と同じである.
5743 %が,「左空白」がなくなることにのみ注意.
5744 \begin{itemize}
5745 \item 「右空白」については,既に述べた\textsf{Boundary-A~[\OA]}により空白を決定しようと試みる.
5746 それが失敗した場合は,「右空白」は挿入されない.
5747 %\item \textit{Nq}が和文でないので,「左空白」は算出されない.
5748 \item 禁則用ペナルティの処理は,\textit{Nq}の種類によって異なる.
5749 $\mathit{Nq}.\mathit{tail}$は無意味なので,
5750 \[
5751  a:=(\text{\textit{Np}の文字に対する\Param{\hyperlink{fld:prebp}{prebreakpenalty}}の値}).
5752 \]
5753 \begin{description}
5754 \item[箱] \textit{Nq}が\textsf{箱}の場合は,\textsf{P-allow~[PA]}を用いる.
5755 \item[グルー] \textit{Nq}がグルーの場合は,\textsf{P-normal~[PN]}を用いる.
5756 \item[カーン] \textit{Nq}がカーンの場合は,\textsf{P-suppress~[PS]}を用いる.
5757 \end{description}
5758 \end{itemize}
5759
5760 \paragraph{和文Aと和文Bの違い}
5761 先に述べたように,\textsf{和文B}は水平ボックスの中身の先頭(or 末尾)として出現している
5762 和文文字である.リスト内に直接ノードとして現れている和文文字(\textsf{和文A})との違いは,
5763 \begin{itemize}
5764 \item \textsf{和文B}に対しては,JFMの文字クラス指定から定まる空白
5765 \textsf{JFM-origin~[M]},\textsf{Boundary-A~[\OA]},\textsf{Boundary-B~[\OB]})の挿入は行われない.
5766 %「左空白」の算出も行われない.
5767 例えば,
5768 \begin{itemize}
5769 \item 片方が\textsf{和文A},もう片方が\textsf{和文B}のクラスタの場合,
5770 \textsf{Boundary-A~[\OA]}または\textsf{Boundary-B~[\OB]}の挿入を試み,それがダメなら
5771 \Param{kanjiskip}~\textsf{[K]}の挿入を行う.
5772 \item \textsf{和文B}の2つのクラスタの間には,\Param{kanjiskip}~\textsf{[K]}が自動的に入る.
5773 \end{itemize}
5774 \item \textsf{和文B}と箱・グルー・カーンが隣接したとき(どちらが前かは関係ない),間にJFMグルー・ペナルティの挿入は一切しない.
5775 \item \textsf{和文B}と\textsf{和文B},また\textsf{和文B}と\textsf{欧文}とが隣接した時は,禁則用ペナルティ挿入処理は
5776 \textsf{P-suppress~[PS]}が用いられる.
5777 \item \textsf{和文B}の文字に対する\Param{\hyperlink{fld:prebp}{prebreakpenalty}},~\Param{\hyperlink{fld:postbp}{postbreakpenalty}}の値は使われず,0として計算される.
5778 \end{itemize}
5779
5780
5781 次が具体例である:
5782 \begin{LTXexample}
5783 あ.\inhibitglue A\\
5784 \hbox{あ.}A\\
5785 あ.A
5786 \end{LTXexample}
5787 \begin{itemize}
5788 \item 1行目の\verb+\inhibitglue+は\textsf{Boundary-B~[\OB]}の処理のみを抑止するので,ピリオドと「A」の間には
5789 \Param{\hyperlink{fld:xks}{xkanjiskip}}(四分アキ)が入ることに注意.
5790 \item 2行目のピリオドと「A」の間においては,前者が\textsf{和文B}となる(水平ボックスの中身の末尾として登場しているから)ので,
5791 そもそも\textsf{Boundary-B~[\OB]}の処理は行われない.よって,\Param{\hyperlink{fld:xks}{xkanjiskip}}が入ることとなる.
5792 \item 3行目では,ピリオドの属するクラスタは\textsf{和文A}である.これによって,
5793 ピリオドと「A」の間には\textsf{Boundary-B~[\OB]}由来の半角アキが入ることになる.
5794 \end{itemize}
5795 %</ja>
5796
5797 %<en>\section{Patch for the \Pkg{listings} package}
5798 %<ja>\section{\Pkg{listings} パッケージへの対応}
5799
5800 %<*en>
5801 It is well-known that the \Pkg{listings} package outputs weird results
5802 for Japanese input.
5803 The \Pkg{listings} package makes most of letters active and assigns
5804 output command for each letter~(\cite{listings}).
5805 But Japanese characters are not included in these activated letters.
5806 For \pTeX{} series, there is no method to make Japanese characters active;
5807 a patch \Pkg{jlisting.sty}~(\cite{jlisting}) resolves the problem forcibly.
5808 %</en>
5809 %<*ja>
5810 \Pkg{listings} パッケージが,そのままでは日本語をまともに出力できないこと
5811 はよく知られている.きちんと整形して出力するために,\Pkg{listings}パッケー
5812 ジは内部で「ほとんどの文字」をアクティブにし,各文字に対してその文字の出
5813 力命令を割り当てている(\cite{listings}).
5814 しかし,そこでアクティブにする文字の中に,和文文
5815 字がないためである.\pTeX 系列では,和文文字をアクティブにする手法がなく,
5816 \Pkg{jlisting.sty} というパッチ(\cite{jlisting})を用いることで無理やり解決していた.
5817 %</ja>
5818
5819 %<*en>
5820 In \LuaTeX-ja, the problem is resolved by using the \verb+process_input_buffer+ callback.
5821 The callback function inserts the output command (active character \texttt{U+FFFFF})
5822 before each letter above \texttt{U+0080}.
5823 This method can omits the process to make all Japanese characters active
5824 (most of the activated characters are not used in many cases).
5825 %</en>
5826 %<*ja>
5827 \LuaTeX-jaでは,\verb+process_input_buffer+ コールバックを利用することで,
5828 「各行に出現する\texttt{U+0080}以降の文字に対して,それらの出力命令を前置する」
5829 という方法をとっている.出力命令としては,アクティブ文字化した \texttt{U+FFFFF} を用いている.
5830 これにより,(入力には使用されていないかもしれない)和文文字をもすべてアクティブ化する手間もなく,
5831 見通しが良い実装になっている.
5832 %</ja>
5833
5834
5835 %<*en>
5836 If the \Pkg{listings} package  and \LuaTeX-ja were loaded,
5837 then the patch \Pkg{lltjp-listings} is loaded automatically at \verb+\begin{document}+.
5838 %</en>
5839 %<*ja>
5840 \LuaTeX-ja で利用される \Pkg{listings} パッケージへのパッチ \Pkg{lltjp-listings} は,
5841 \Pkg{listings} と\LuaTeX-jaを読み込んでおけば,
5842 \verb+\begin{document}+ の箇所において自動的に読み込まれるので,通常はあまり
5843 意識する必要はない.
5844 %</ja>
5845
5846 %<*en>
5847 \paragraph{A note to ``Escaping to \LaTeX''}
5848 We used the \verb+process_input_buffer+ callback to output \textbf{JAchar}s.
5849 But it has a drawback; any control sequences whose name contains a \textbf{JAchar}
5850 cannot be used in any ``escape to \LaTeX''.
5851
5852 Consider the following input:
5853 %</en>
5854 %<*ja>
5855 \paragraph{「\LaTeX へのエスケープ」についての注意}
5856 日本語対応を行うために \verb+process_input_buffer+ を使用したことで,
5857 \texttt{texcl},~\texttt{escapeinside}といった\emph{「\LaTeX へのエスケープ」中では,
5858 \textbf{JAchar}を名称の一部に含む制御綴は使用不可能}である.
5859 例えば次のような入力を考えよう:
5860 %</ja>
5861 \begin{verbatim*}
5862 \begin{lstlisting}[escapechar=`\#]
5863 #\ほげ xぴよ#
5864 \end{lstlisting}
5865 \end{verbatim*}
5866 %<en>The line~2 is transformed by the callback to
5867 %<ja>ここで,2行目は \verb+process_input_buffer+ の作用により,
5868 \begin{lstlisting}[showspaces, escapechar=\!]
5869 #\!\IVSA FFFFF!ほ!\IVSA FFFFF !げ x!\IVSA FFFFF !ぴ!\IVSA FFFFF !よ#
5870 \end{lstlisting}
5871 %<*en>
5872 before the line is actually processed.
5873 In the escape (between the character ``\verb+#+''), 
5874 the category code of \texttt{U+FFFFF} is set to 9~(\emph{ignored}).
5875 Hence the control symbol ``\verb+\+\IVSA FFFFF'' will be executed,
5876 instead ``\verb+\ほげ+''.
5877 %</en>
5878 %<*ja>
5879 と変換されてから,実際の処理に回される.
5880 「\verb+#+」で挟まれた「\LaTeX へのエスケープ」中では\
5881 \texttt{U+FFFFF} のカテゴリーコードは9~(\textit{ignored})となるので,
5882 結局「\verb+\ほげ+」の代わりに
5883 「\verb+\+\IVSA FFFFF」というcontrol symbolが実行されることになる.
5884 %</ja>
5885
5886 %<en>\paragraph{Class of characters}
5887 %<ja>\paragraph{文字種}
5888
5889 %<en>Roughly speaking, the \Pkg{listings} package processes input as follows:
5890 %<ja>\Pkg{listings} パッケージの内部では,大雑把に言うと
5891 \begin{enumerate}
5892 %<en>\item Collects \textit{letters} and \textit{digits}, which can be used for the name of identifiers.
5893 %<ja>\item 識別子として使える文字 (``letter'',~``digit'') たちを集める.
5894 %<en>\item When reading an \textit{other}, outputs the collected character string (with modification, if needed).
5895 %<ja>\item letterでもdigitでもない文字が現れた時に,収集した文字列を(必要なら修飾して)出力する.
5896 %<en>\item Collects \textit{others}.
5897 %<ja>\item 今度は逆に,letterでない文字たちをletterが現れるまで集める.
5898 %<en>\item When reading a \textit{letter} or a \textit{digit}, outputs the collected character string.
5899 %<ja>\item letterが出現したら集めた文字列を出力する.
5900 %<en>\item Turns back to 1.
5901 %<ja>\item 1.に戻る.
5902 \end{enumerate}
5903 %<*en>
5904 By the above process, line breaks inside of an identifier are blocked.
5905 A flag \verb+\lst@ifletter+ indicates whether the previous character can be used
5906 for the name of identifiers or not.
5907 %</en>
5908 %<*ja>
5909 という処理が行われている.これにより,識別子の途中では行分割が行われないようになっている.
5910 直前の文字が識別子として使えるか否かは \verb+\lst@ifletter+ というフラグに格納されている.
5911 %</ja>
5912
5913 %<*en>
5914 For Japanese characters, line breaks are permitted on both sides
5915 except for parentheses, dashes, etc.
5916 To process Japanese characters,
5917 The pacth \Pkg{lltjp-listings} introduces a new flag \verb+\lst@ifkanji+, which indicates
5918 whether the previous character is Japanese character or not.
5919 For illustration, we introduce the following classes of character:
5920 %</en>
5921 %<*ja>
5922 さて,日本語の処理である.殆どの和文文字の前後では行分割が可能であるが,その一方で
5923 括弧類や音引きなどでは禁則処理が必要なことから,\Pkg{lltjp-listings} では,
5924 直前が和文文字であるかを示すフラグ \verb+\lst@ifkanji+ を新たに導入した.
5925 以降,説明のために以下のように文字を分類する:
5926 %</ja>
5927 \begin{center}
5928 \small
5929 \begin{tabular}{lccccc}
5930 \toprule
5931 &Letter&Other&Kanji&Open&Close\\\midrule
5932 \verb+\lst@ifletter+&T&F&T&F&T\\
5933 \verb+\lst@ifkanji+&F&F&T&T&F\\
5934 %<en>Meaning&identifier char&other alphabet&most of Japanese char&open paren&close paren\\
5935 %<ja>意図&識別子中の文字&その他欧文文字&殆どの和文文字&開き括弧類&閉じ括弧類\\
5936 \bottomrule
5937 \end{tabular}
5938 \end{center}
5939 %<*en>
5940 Note that \textit{digits} in the \Pkg{listings} package can be Letter or
5941 Other according to circumstances.
5942 %</en>
5943 %<*ja>
5944 なお,本来の\Pkg{listings} パッケージでの分類``digit''は,
5945 出現状況によって,上の表のLetterとOtherのどちらにもなりうる.
5946 また,KanjiとCloseは \verb+\lst@ifletter+ と \verb+\lst@ifkanji+ の値が一致しているが,
5947 これは間違いではない.
5948 %</ja>
5949
5950 %<*en>
5951 For example, let us consider the case an Open comes after a Letter.
5952 Since an Open represents Japanese open parenthesis,
5953 it is preferred to be permitted to insert line break after the Letter.
5954 Therefore, the collected character string is output in this case.
5955 %</en>
5956 %<*ja>
5957 例えば,Letterの直後にOpenが来た場合を考える.
5958 文字種Openは和文開き括弧類を想定しているので,Letterの直後では行分割が可能であることが望ましい.
5959 そのため,この場合では,すでに収集されている文字列を出力することで行分割を許容するようにした.
5960 %</ja>
5961
5962 %<*en>
5963 The following table summarizes $5\times 5=25$ cases:
5964 %</en>
5965 %<*ja>
5966 同じように,$5\times 5=25$通り全てについて書くと,次のようになる:
5967 %</ja>
5968 \begin{center}
5969 \small
5970 \begin{tabular}{llccccc}
5971 \toprule
5972 %<*en>
5973 &&\multicolumn{4}{c}{Next}\\\cmidrule(lr){3-7}
5974 &&\hbox to 4em{\hss Letter\hss}&\hbox to 4em{\hss Other\hss}
5975 &\hbox to 4em{\hss Kanji\hss}&\hbox to 4em{\hss Open\hss}&Close\\\midrule
5976 &Letter&collects&\multicolumn{3}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
5977 &Other&outputs&collects&\multicolumn{2}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
5978 Prev&Kanji&\multicolumn{4}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
5979 &Open&\multicolumn{5}{c}{\hrulefill \ collects\ \hrulefill}\\
5980 &Close&\multicolumn{4}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
5981 %</en>
5982 %<*ja>
5983 &&\multicolumn{4}{c}{後ろ側の文字}\\\cmidrule(lr){3-7}
5984 &&\hbox to 4em{\hss Letter\hss}&\hbox to 4em{\hss Other\hss}
5985 &\hbox to 4em{\hss Kanji\hss}&\hbox to 4em{\hss Open\hss}&Close\\\midrule
5986 直&Letter&収集&\multicolumn{3}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
5987 前&Other&出力&収集&\multicolumn{2}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
5988 文&Kanji&\multicolumn{4}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
5989 字&Open&\multicolumn{5}{c}{\hrulefill \ 収集\ \hrulefill}\\
5990 種&Close&\multicolumn{4}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
5991 %</ja>
5992 \bottomrule
5993 \end{tabular}
5994 \end{center}
5995 %<en>In the above table,
5996 %<ja>上の表において,
5997 \begin{itemize}
5998 %<en>\item ``outputs'' means to output the collected character string (i.e., line breaking is permitted there).
5999 %<ja>\item 「出力」は,それまでに集めた文字列を出力(≒ここで行分割可能)を意味する.
6000
6001 %<en>\item ``collects'' means to append the next character to the collected character string (i.e., line breaking is prohibited there).
6002 %<ja>\item 「収集」は,後側の文字を,現在収集された文字列に追加(行分割不可)を意味する.
6003 \end{itemize}
6004
6005 %<en>\paragraph{Classification of characters}
6006 %<ja>\paragraph{和文文字扱いとなる文字}
6007
6008 %<*en>
6009 Characters are classified according to \Param{jacharrange} parameter (see Section \ref{ssec-setrange}):
6010 %</en>
6011 %<*ja>
6012 \Pkg{listings} パッケージにおいて和文文字と扱われる
6013 (前に述べたKanji, Open,あるいは「閉じ括弧類」分類)か否かは,
6014 通常の\textbf{JAchar}/\textbf{Alchar}の範囲の設定(\Param{jacharrange} パラメータ,\ref{ssec-setrange}節を参照)に従って行われる:
6015 %</ja>
6016 \begin{itemize}
6017
6018 %<en>\item \textbf{ALchars} above U+0080 are Letter.
6019 %<ja>\item (U+0080以降の)\textbf{ALchar}は,すべてLetter扱いである.
6020
6021 %<en>\item \textbf{JAchars} are classified in the order as follows:
6022 %<ja>\item (U+0080以降の)\textbf{JAchar}については,以下の順序に従って文字種を決める:
6023 \begin{enumerate}
6024 %<en>\item Characters whose \Param{\hyperlink{fld:prebp}{prebreakpenalty}} is greater than or equal to 0 are Open.
6025 %<ja>\item \Param{\hyperlink{fld:prebp}{prebreakpenalty}}が0以上の文字はOpen扱いである.
6026
6027 %<en>\item Characters whose \Param{\hyperlink{fld:postbp}{postbreakpenalty}} is greater than or equal to 0 are Close.
6028 %<ja>\item \Param{\hyperlink{fld:postbp}{postbreakpenalty}}が0以上の文字はClose扱いである.
6029
6030 %<en>\item Characters that don't satisfy the above two conditions are Kanji.
6031 %<ja>\item 上の2条件のどちらにも当てはまらなかった文字は,Kanji扱いである.
6032 \end{enumerate}
6033 \end{itemize}
6034
6035 %<*en>
6036 The width of halfwidth kana (U+FF61--U+FF9F) is same as the width of \textbf{ALchar};
6037 the width of the other \textbf{JAchars} is double the width of \textbf{ALchar}.
6038 %</en>
6039 %<*ja>
6040 なお,半角カナ(U+FF61--U+FF9F)以外の\textbf{JAchar}は欧文文字2文字分の幅をとるものとみなされる.
6041 半角カナは欧文文字1文字分の幅となる.
6042 %</ja>
6043
6044 %<*en>
6045 The classification process is executed every time a character appears in
6046 listing environments.
6047 %</en>
6048 %<*ja>
6049 これらの文字種決定は,実際に \texttt{lstlisting} 環境などの内部で文字が出てくるたびに行われる.
6050 %</ja>
6051
6052 %<*ja>
6053 \section{和文の行長補正方法}
6054 \label{sec-adjspec}
6055 \Pkg{luatexja-adjust} で提供される優先順位付きの行長調整の詳細を述
6056 べる.大まかに述べると,次のようになる.
6057 \begin{itemize}
6058 \item 通常の\TeX の行分割方法に従って,段落を行分割する.この段階では,行
6059       長に半端が出た場合,その半端分は\textbf{JAglue}(\Param{\hyperlink{fld:xks}{xkanjiskip}},
6060       \Param{\hyperlink{fld:kanjiskip}{kanjiskip}},JFMグルー)と
6061       それ以外のグルーの全てで(優先順位なく)負担される.
6062 \item その後,\texttt{post\_linebreak\_filter} callbackを使い,\emph{段
6063       落中の各行ごとに},行末文字の位置を調整したり,優先度付きの行長調整
6064       を実現するためにグルーの伸縮度を調整する.
6065       その処理においては,グルーの自然長と\textbf{JAglue}以外の
6066       グルーの伸び量・縮み量は変更せず,必要に応じて\textbf{JAglue}の伸び量・縮み量のみを
6067       変更する設計とした.
6068
6069 \Pkg{luatexja-adjust} の作用は,この処理を行うcallbackを追加するだけであり,
6070       この章の残りではcallbackでの処理について解説する.
6071 \end{itemize}
6072
6073 \paragraph{準備:合計伸縮量の計算}
6074 グルーの伸縮度(\texttt{plus} や \texttt{minus} で指定されている値)には,
6075 有限値の他に,\texttt{fi},\texttt{fil},\texttt{fill},\texttt{filll}と
6076 いう4つの無限大レベル(後ろの方ほど大きい)があり,行の調整に
6077 \texttt{fi} などの\emph{無限大レベルの伸縮度が用いられている場合は,そ
6078 の行に対しての処理を中止}する.
6079
6080 よって,以降,問題にしている行の行長調整は伸縮度が有限長のグルーを用いて
6081 行われているとして良い.さらに,簡単のため,この行はグルーが広げられている
6082 (自然長で組むと望ましい行長よりの短い)場合しか扱わない.
6083
6084 まず,段落中の行中のグルーを
6085 \begin{itemize}
6086 \item \textbf{JAglue}ではないグルー
6087 \item JFMグルー(優先度\footnote{%
6088   \ref{ssec-jfm-str}節にあるように,
6089   各JFMグルーには$-2$から2までの優先度がついている.}%
6090 別にまとめられる)
6091 \item 和欧文間空白(\Param{\hyperlink{fld:xks}{xkanjiskip}})
6092 \item 和文間空白(\Param{\hyperlink{fld:kanjiskip}{kanjiskip}})
6093 \end{itemize}
6094 の$1+1+5+1=8$つに類別し,それぞれの種別ごとに
6095 許容されている伸び量(\texttt{stretch}の値)の合計を計算する.
6096 また,行長と自然長との差を\textit{total}とおく.
6097
6098
6099 \subsection{第1段階:行末文字の位置調整}
6100 行末が文字クラス$n$の\textbf{JAchar}であった場合,
6101 それを動かすことによって,\textit{total}のうち
6102 \textbf{JAglue}が負担する分を少なくしようとする.
6103 この行末文字の左右の移動可能量は,
6104 JFM中にある文字クラス$n$の定義の
6105 \texttt{end\_stretch},~\texttt{end\_shrink}フィールドに
6106 全角単位の値として記述されている.
6107
6108 例えば,行末文字が句点「。」であり,そこで用いられているJFM中に
6109 \begin{verbatim}
6110   [2] = {
6111     chars = { '。', ... }, width = 0.5, ...,
6112     end_stretch = 0.5, end_shrink = 0.5,
6113   }, 
6114 \end{verbatim}
6115 という指定があった場合,この行末の句点は
6116 \begin{itemize}
6117 \item 通常の\TeX の行分割処理で「半角以上の詰め」が行われていた場合,
6118 この行中の\textbf{JAglue}の負担を軽減するため,
6119 行末の句点を半角だけ右に移動する(ぶら下げ組を行う).
6120 \item 通常の\TeX の行分割処理で「半角以上の空き」が行われていた場合,
6121 逆に行末句点を半角左に移動させる(見た目的に全角取りとなる).
6122 \item 以上のどちらでもない場合,行末句点の位置調整は行わない.
6123 \end{itemize}
6124 となる.
6125
6126 行末文字を移動した場合,その分だけ\textit{total}の値を引いておく.
6127
6128 \subsection{グルーの調整}
6129 \textit{total}の分だけが,行中のグルーの伸び量に応じて負担されることになる.
6130 負担するグルーの優先度は以下の順であり,
6131 できるだけ\Param{\hyperlink{fld:kanjiskip}{kanjiskip}}を自然長のままにすることを
6132 試みている.
6133 \begin{enumerate}\def\labelenumi{(\Alph{enumi})}
6134  \item \textbf{JAglue}以外のグルー
6135  \item 優先度2のJFMグルー
6136  \item 優先度1のJFMグルー
6137  \item 優先度0のJFMグルー
6138  \item 優先度$-1$のJFMグルー
6139  \item 優先度$-2$のJFMグルー
6140  \item \Param{\hyperlink{fld:xks}{xkanjiskip}}
6141  \item \Param{\hyperlink{fld:kanjiskip}{kanjiskip}}
6142 \end{enumerate}
6143 \begin{enumerate}
6144  \item 行末の和文文字を移動したことで$\textit{total}=0$となれば,
6145 調整の必要はなく,行が格納されている水平ボックスの
6146 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算すればよい.
6147 以降,$\textit{total}\neq 0$と仮定する.
6148  \item \textit{total}が「\textbf{JAglue}以外のグルーの伸び量の合計」(以下,(A)の伸び量の
6149        合計,と称す)よりも小さければ,
6150 それらのグルーに\textit{total}を負担させ,\textbf{JAglue}達自身は自然長で組むことができる.
6151 よって,以下の処理を行う:
6152 \begin{enumerate}
6153 \item 各\textbf{JAglue}の伸び量を0とする.
6154 \item 行が格納されている水平ボックスの
6155 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算する.
6156 これによって,\textit{total}は\textbf{JAglue}以外のグルーによって負担される.
6157 \end{enumerate}
6158 \item \textit{total}が「(A)の伸び量の合計」以上ならば,(A)--(H)のどこまで負担すれば
6159 \textit{total}以上になるかを計算する.
6160 例えば,
6161 \[\catcode`\<=12
6162  \textit{total} = (\text{(A)--(B)の伸び量の合計}) + p\cdot (\text{(C)の伸び量の合計}),
6163  \qquad 0\le p<1
6164 \]
6165 であった場合,各グルーは次のように組まれる:
6166 \begin{itemize}
6167  \item (A),~(B)に属するグルーは各グルーで許された伸び量まで伸ばす.
6168  \item (C)に属するグルーはそれぞれ$p\times (\text{伸び量})$だけ伸びる.
6169  \item (D)--(H)に属するグルーは自然長のまま.
6170 \end{itemize}
6171 実際には,前に述べた「設計」に従い,次のように処理している:
6172 \begin{enumerate}
6173 \item (C)に属するグルーの伸び量を$p$倍する.
6174 \item (D)--(H)に属するグルーの伸び量を0とする.
6175 \item 行が格納されている水平ボックスの
6176 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算する.
6177 これによって,\textit{total}は\textbf{JAglue}以外のグルーによって負担される.
6178 \end{enumerate}
6179 \item \textit{total}が(A)--(H)の伸び量の合計よりも大きい場合,どうしようもないので
6180       \verb+^^;+何もせず,何もしない.
6181 \end{enumerate}
6182
6183 %</ja>
6184
6185 %<*ja>
6186 \section{IVS対応(未完)}
6187 \section{複数フォントの「合成」(未完)}
6188
6189 \section{\LuaTeX-jaにおけるキャッシュ}
6190 \Pkg{luaotfload}パッケージが,各TrueType・]OpenTypeフォントの情報を
6191 キャッシュとして保存しているのと同様の方法で,
6192 \LuaTeX-jaもいくつかのキャッシュファイルを作成するようになった.
6193 \begin{itemize}
6194  \item 通常,キャッシュは\texttt{\$TEXMFVAR/luatexja/}以下に保存され,
6195 そこから読み込みが行われる.
6196  \item 「通常の」テキスト形式のキャッシュ(拡張子は \texttt{.lua})以外にも,
6197 それをバイナリ形式(バイトコード)に変換したものもサポートしている.
6198 \begin{itemize}
6199  \item \LuaTeX とLuaJIT\TeX ではバイトコードの形式が異なるため,バイナリ形式の
6200 キャッシュは共有できない.\LuaTeX 用のバイナリキャッシュは \texttt{.luc},
6201 LuaJIT\TeX 用のは \texttt{.lub} と拡張子を変えることで対応している.
6202  \item キャッシュを読み込む時,同名のバイナリキャッシュがあれば,
6203 テキスト形式のものよりそちらを優先して読み込む.
6204  \item テキスト形式のキャッシュが更新/作成される際は,そのバイナリ版も
6205 同時に更新される.
6206 また,(バイナリ版が見つからず)テキスト形式のキャッシュ側が読み込まれたときは,
6207 \LuaTeX-jaはバイナリキャッシュを作成する.
6208 \end{itemize}
6209 \end{itemize}
6210 %</ja>
6211 %<*en>
6212 \section{Cache Management of \LuaTeX-ja}
6213 \LuaTeX-ja creates some cache files to reduce the loading time. 
6214 in a similar way to the \Pkg{luaotfload} package:
6215 \begin{itemize}
6216  \item Cache files are usually stored in (and loaded from)
6217 \texttt{\$TEXMFVAR/luatexja/}.
6218  \item In addition to caches of the text form (the extension is ``\texttt{.lua}''),
6219 caches of the \emph{binary}, precompiled form are supported.
6220 \begin{itemize}
6221  \item We cannot share same binary cache for \LuaTeX\ and LuaJIT\TeX.
6222 Hence we distinguish them by their extension, ``\texttt{.luc}'' for \LuaTeX\
6223 and ``\texttt{.lub}'' for LuaJIT\TeX.
6224  \item In loading a cache, the binary cache precedes 
6225 the text form.
6226  \item When \LuaTeX-ja updates a cache \texttt{hoge.lua}, 
6227 its binary version is also updated.
6228 \end{itemize}
6229 \end{itemize}
6230 %</en>
6231
6232
6233
6234 %<*ja>
6235 \subsection{キャッシュの使用箇所}
6236
6237 \LuaTeX-ja では以下の3種類のキャッシュを使用している:
6238 \begin{list}{}%
6239 {\def\makelabel#1{\ttfamily#1}}
6240 \item[ltj-cid-auto-adobe-japan1.lua] 
6241 Ryumin-Lightのような非埋め込みフォントの情報を格納しており,
6242 (それらが\LuaTeX-jaの標準和文フォントなので)\LuaTeX-jaの読み込み時に自動で読まれる.
6243 生成には\texttt{UniJIS2004-UTF32-H}, \texttt{Adobe-Japan1-UCS2}という2つの
6244 CMapが必要である.
6245
6246 \pageref{para-cid}ページで述べたように,\texttt{cid}キーを使って
6247 非埋め込みの中国語・韓国語フォントを定義する場合,同様のキャッシュが生成される.
6248 キャッシュの名称,必要となるCMapについては表\ref{tab:cid-cache}を参照して欲しい.
6249
6250 \item[ivs\_***.lua]
6251 フォント``\texttt{***}''における異体字情報を格納している.構造は以下の通り:
6252 %</ja>
6253 %<*en>
6254 \subsection{Use of Cache}
6255
6256 \LuaTeX-ja uses the following cache:
6257 \begin{list}{}%
6258 {\def\makelabel#1{\ttfamily#1}}
6259 \item[ltj-cid-auto-adobe-japan1.lua] 
6260 The font table of a CID-keyed non-embedded Japanese font.
6261 This is loaded in every run.
6262 It is created from two CMaps, \texttt{UniJIS2004-UTF32-H} and
6263              \texttt{Adobe-Japan1-UCS2}, 
6264 and this is why these two CMaps are needed in the first run of \LuaTeX-ja.
6265
6266 Similar caches are created as Table~\ref{tab:cid-cache}, 
6267 if you specified \texttt{cid} key in \verb+\jfont+
6268 to use other CID-keyed non-embedded fonts for Chinese or Korean,
6269 as in Page~\pageref{para-cid}.
6270
6271 \item[ivs\_***.lua]
6272 This file stores the table of Unicode variants in a font ``\texttt{***}''. 
6273 The structure of the table is the following:
6274 %</en>
6275
6276 \begin{table}[!tb]
6277  \centering
6278 \caption{\texttt{cid} key and corresponding files}
6279 \label{tab:cid-cache}
6280 \vspace*{\medskipamount}
6281 \begin{tabular}{>{\tt}l>{\tt}l>{\tt}l>{\tt}l}
6282 \toprule
6283 \bf \texttt{cid} key&\bf name of the cache &
6284 \multicolumn{2}{c}{\bf used CMaps}\\
6285 \midrule
6286 Adobe-Japan1-*&ltj-cid-auto-adobe-japan1.lua&UniJIS2004-UTF32-H&Adobe-Japan1-UCS2\\
6287 Adobe-Korea1-*&ltj-cid-auto-adobe-korea1.lua&UniKS-UTF32-H&Adobe-Korea1-UCS2\\
6288 Adobe-GB1-*&ltj-cid-auto-adobe-gb1.lua&UniGB-UTF32-H&Adobe-GB1-UCS2\\
6289 Adobe-CNS1-*&ltj-cid-auto-adobe-cns1.lua&UniCNS-UTF32-H&Adobe-CNS1-UCS2\\
6290 \bottomrule
6291 \end{tabular}
6292 \end{table}
6293
6294 \begin{lstlisting}
6295 return {
6296  {
6297   [10955]={    -- U+2ACB "Subset Of Above Not Equal To"
6298    [65024]=983879, -- <2ACB FE00>
6299   },
6300   [37001]={    -- U+9089 "邉"
6301    [0]=37001,  --   <9089 E0100>
6302    991049,     --   <9089 E0101>
6303    ...
6304   },
6305   ...
6306  },
6307  ["chksum"]="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", -- checksum of the fontfile
6308  ["version"]=4, -- version of the cache
6309 }
6310 \end{lstlisting}
6311 %<*ja>
6312 \item[ltj-jisx0208.\{luc|lub\}]
6313 \LuaTeX-ja配布中の\texttt{ltj-jisx0208.lua}をバイナリ化したものである.
6314 これはJIS~X~0208とUnicodeとの変換テーブルであり,
6315 \pTeX との互換目的の文字コード変換命令で用いられる.
6316 %</ja>
6317 %<*en>
6318 \item[ltj-jisx0208.\{luc|lub\}]
6319 The binary version of \texttt{ltj-jisx0208.lua}. 
6320 This is the conversion table between JIS~X~0208 and Unicode
6321 which is used in Kanji-code conversion control sequences for compatibility with \pTeX.
6322 %</en>
6323 \end{list}
6324
6325 %<*en>
6326 \subsection{Internal}
6327 Cache management system of \LuaTeX-ja is stored in \texttt{luatexja.base}
6328 (\texttt{ltj-base.lua}).
6329 There are three public functions for cache management in \texttt{luatexja.base}, 
6330 where <filename> stands for the filename \emph{without suffix}:
6331 \begin{list}{}%
6332 {\def\makelabel#1{\ttfamily#1}}
6333 \item[save\_cache(<filename>, <data>)]
6334 Save a non-nil table <data> into a cache <filename>.
6335 Both the text form <filename>\texttt{.lua} and its binary version 
6336 are created or updated.
6337
6338 \item[save\_cache\_luc(<filename>, <data>{[, <serialized\_data>]})]\ 
6339
6340 Same as \texttt{save\_cache}, except that only the binary cache is updated. 
6341 The third argument <serialized data> is not usually given.
6342 But if this is given, it is treated as a string representation of <data>.
6343
6344 \item[load\_cache(<filename>, <outdate>)]
6345 Load the cache <filename>.
6346 <outdate> is a function which takes one argument (the contents of the cache),
6347 and its return value is whether the cache is outdated.
6348
6349 \texttt{load\_cache} first tries to 
6350 read the binary cache <filename>\texttt{.\{luc|lub\}}.
6351 If its contents is up-to-date, \texttt{load\_cache} returns the contents.
6352 If the binary cache is not found or 
6353 its contents is outdated, \texttt{load\_cache} tries to 
6354 read the text form <filename>\texttt{.lua}.
6355 Hence, the return value of \texttt{load\_cache} is non-nil,
6356 if and only if the updated cache is found.
6357 \end{list}
6358 %</en>
6359
6360 \begin{thebibliography}{99}
6361   \addcontentsline{toc}{section}{\refname}
6362 \bibitem{texbytopic}
6363 Victor Eijkhout. \newblock \textit{\TeX\ by Topic, A \TeX nician's Reference}, Addison-Wesley, 1992.
6364 \bibitem{listings} C.\ Heinz, B.\ Moses. \newblock The \textsf{Listings} Package.
6365 \bibitem{uptex} Takuji Tanaka. \newblock
6366 upTeX---Unicode version of pTeX with CJK extensions, 
6367 TUG 2013, October 2013.
6368 %<ja>\newblock
6369 %<en>\\\null\hfill
6370 \url{http://tug.org/tug2013/slides/TUG2013_upTeX.pdf}
6371 \bibitem{jlisting} Thor Watanabe. \newblock Listings\ -\ MyTeXpert. 
6372 %<en>\newblock
6373 %<ja>\\\null\hfill
6374 \url{http://mytexpert.sourceforge.jp/index.php?Listings}
6375 \bibitem{jlreq}  W3C Japanese Layout Task Force~(ed). \newblock
6376 Requirements for Japanese Text Layout (W3C Working Group Note), 2011, 2012. \newblock
6377 \url{http://www.w3.org/TR/jlreq/}%
6378 %<ja> \\日本語訳の書籍版:W3C日本語組版タスクフォース(編),『W3C技術ノート 日本語組版処理の要件』,東京電機大学出版局,2012.
6379 \bibitem{min10} 乙部厳己,min10フォントについて.\\\null\hfill
6380 \url{http://argent.shinshu-u.ac.jp/~otobe/tex/files/min10.pdf}
6381 \bibitem{x4051} 日本工業規格(Japanese Industrial Standard), JIS~X~4051,
6382 日本語文書の組版方法(Formatting rules for Japanese documents), 1993, 1995, 2004.
6383 \end{thebibliography}
6384
6385 \newpage
6386 \appendix
6387
6388 \section{Package versions used in this document}
6389 This document was typeset using the following packages:
6390
6391 \medskip
6392
6393 {\makeatletter\tt\footnotesize
6394   \def\@pkglist#1{%
6395     \filename@parse{#1}\def\@temp{sty}
6396     \ifx\@temp\filename@ext
6397       \edef\reserved@a{%
6398         \filename@base.%
6399         \ifx\filename@ext\relax tex\else\filename@ext\fi}%
6400       \leavevmode\hskip-13em\hbox to 13em{\filename@area\reserved@a\hss}%
6401       \csname ver@\reserved@a\endcsname\par
6402     \fi
6403   }%
6404 \parindent0pt\leftskip13em
6405 \ltjpkglist
6406
6407 \makeatother}
6408 \end{document}
6409 %</!showexpl>
6410 %<*showexpl>
6411 %%
6412 %% config file for showexpl.sty
6413 %%
6414 %% Copyright The LuaTeX-ja project team, 2012
6415 %%
6416 \ProvidesFile{showexpl.cfg}
6417   [2012/05/20 v0.01 Definitions for the showexpl package (luatexja)]
6418 \lstset{}
6419 \def\SX@Info{}
6420 \endinput
6421 %</*showexpl>