OSDN Git Service

Merge branch 'master' into kitagawa_test
[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 %%%%% section ==> 章
10 %%%%% subsection => 節
11
12 %<en>\documentclass[a4paper,titlepage]{article}
13 %<ja>\documentclass[a4paper,titlepage]{ltjsarticle}
14
15 %%%%%%%%
16 \makeatletter
17 %%%%%%%%
18 \directlua{if jit then jit.on() end}
19
20 \usepackage{amsmath,array,tikz,pict2e,multienum,float}
21 \usepackage{booktabs,multicol,luatexja-ruby}
22 \usepackage[all]{xy}
23 \usepackage{lltjext,alltt}
24
25 %%%%%%%% fonts
26 \usepackage{luatexja-otf}
27 \directlua{luatexja.otf.enable_ivs()}
28 \usepackage[match]{luatexja-fontspec}
29 \usepackage[kozuka-pr6n]{luatexja-preset}
30 \usepackage{unicode-math}
31 \setmainfont[Ligatures=TeX]{Linux Libertine O}
32 \setmonofont[Scale=MatchLowercase, ItalicFont=lmmono10-italic.otf,
33   BoldFont=lmmonolt10-bold.otf, BoldItalicFont=lmmonolt10-boldoblique.otf
34 ]{lmmono10-regular.otf}
35 \setmonojfont{KozGoPr6N-Regular.otf}
36 \setmathfont[Scale=MatchLowercase]{xits-math.otf}
37 \setsansfont[Scale=MatchLowercase,Ligatures=TeX]{Linux Biolinum O}
38 %<*ja>
39 \def\emph#1{\textbf{\textgt{#1}}}
40 \def\headfont{\normalfont\bfseries\gtfamily}\normalsize
41 %</ja>
42 %<*en>
43 \frenchspacing
44 \usepackage[margin=25mm,lmargin=30mm,rmargin=30mm,footskip=6mm]{geometry}
45 \usepackage{luatexja-adjust}\ltjdisableadjust
46 \parskip=\smallskipamount
47 \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
48     {3.25ex \@plus1ex \@minus.2ex}%
49     {-1em}%
50     {\normalfont\normalsize\bfseries\raisebox{.2ex}{$\mdlgblksquare\mkern1mu$}}}
51 %</en>
52 %<*ja>
53 \usepackage[textwidth=45\zw, lines=45, footskip=6mm]{geometry}
54 \usepackage{luatexja-adjust}%\ltjdisableadjust
55 \advance\leftmargini-1\zw\advance\leftmarginii-1\zw
56 %</ja>
57
58 %%%%%%%% listings
59
60 %%%%%%%% IVS
61
62 \def\IVS#1{\char\numexpr "E0100+#1\relax}%"
63 \def\IVSA#1#2#3#4#5{%
64   \textcolor{blue}{\raisebox{3.5pt}{\tt%
65     \fboxsep=0.5pt\fbox{\tiny \oalign{0#1#2\crcr#3#4#5\crcr}}}}%
66 }
67 {\catcode`\%=11
68   \gdef\IVSB#1{\expandafter\IVSA\directlua{
69     local cat_str = luatexbase.catcodetables['string']
70     tex.sprint(cat_str, string.format('%X', 0xE00EF+#1))
71 }}}
72
73 \usepackage{listings,showexpl,enumitem}
74 \lstset{
75   basicstyle=\ttfamily\small, pos=r, breaklines=true,
76   numbers=none, rframe={}, basewidth=0.5em, numberstyle=\tiny, numbersep=0.5em,
77   explpreset={numberstyle=\tiny, numbers=left, numbersep=1em, columns=fixed}
78 }
79 % Suppress output from showexpl to stdout.
80 \let\SX@Info\relax
81
82 %%%%%%%% colors
83 %% modified from http://jfly.iam.u-tokyo.ac.jp/colorset/
84 \usepackage{transparent}
85 \definecolor{red}{rgb}{1, 0.16, 0}
86 \definecolor{blue}{rgb}{0, 0.25, 1}
87 \definecolor{gray}{rgb}{.50, .53, .56}
88 \definecolor{green}{rgb}{.21, .63, .42}
89 \definecolor{cyan}{rgb}{0.40, .80, 1}
90 \definecolor{b_gray}{rgb}{0.78, 0.78, 0.80}
91 \definecolor{b_pink}{rgb}{1, 0.82, 0.82}
92 \definecolor{b_green}{rgb}{.53, .91, .69}
93 \definecolor{b_cyan}{rgb}{0.70, .92, 98}
94
95 %%%%%%%% hyperref
96 \usepackage{hyperref,bookmark}
97 %<*en>
98 \title{The \LuaTeX-ja package}
99 \author{The \LuaTeX-ja project team}
100 %</en>
101 %<*ja>
102 \title{\LuaTeX-jaパッケージ}
103 \author{\LuaTeX-jaプロジェクトチーム}
104 %</ja>
105 \hypersetup{%
106         unicode,
107         colorlinks,
108         allbordercolors=1 1 1,
109         allcolors=blue,
110 %<*en>
111         pdfauthor={The LuaTeX-ja project team},
112         pdftitle={The LuaTeX-ja package}
113 %</en>
114 %<*ja>
115         pdfauthor={LuaTeX-jaプロジェクトチーム},
116         pdftitle={LuaTeX-jaパッケージ}
117 %</ja>
118 }
119
120 %%%%%%%% definition env.
121 \usepackage{amsthm}
122 \theoremstyle{definition}
123 %<en>\newtheorem{defn}{Definition}
124 %<ja>\newtheorem{defn}{定義}
125
126 %%%%%%%% logo
127 \usepackage{metalogo}
128 \DeclareRobustCommand\eTeX{\ensuremath{\varepsilon}-\kern-.125em\TeX}
129 \DeclareRobustCommand\LuaTeX{Lua\TeX}
130 \DeclareRobustCommand\pdfTeX{pdf\TeX}
131 \DeclareRobustCommand\pTeX{p\kern-.15em\TeX}
132 \DeclareRobustCommand\upTeX{up\kern-.15em\TeX}
133 \DeclareRobustCommand\pLaTeX{p\kern-.05em\LaTeX}
134 \DeclareRobustCommand\pLaTeXe{p\kern-.05em\LaTeXe}
135 \DeclareRobustCommand\epTeX{\ensuremath{\varepsilon}-\pTeX}
136
137 %%%%%%%% other macros
138 \newlist{cslist}{description}{1}
139 \setlist[cslist]{%
140     style=nextline,font=\mdseries\ttfamily,
141     before*=\def\<{\char`\<}\def\>{\char`\>}\def\{{\char`\{}\def\}{\char`\}},
142 %<ja> leftmargin=2\zw,
143 %<en> leftmargin=2em,
144 }
145
146 \def\labelenumii{(\arabic{enumii})}
147 \long\def\@makecaption#1#2{%
148   \vskip\abovecaptionskip
149   \sbox\@tempboxa{{\small #1. #2}}%
150   \ifdim \wd\@tempboxa >\hsize
151     {\small #1. #2}\par
152   \else
153     \global \@minipagefalse
154     \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
155   \fi
156   \vskip\belowcaptionskip}
157
158 \def\_{\leavevmode \kern .06em\vbox {\hrule \@width .333em}}
159 \def\cs#1{\texttt{\upshape\textbackslash\ltjsetparameter{autoxspacing=false}#1}}
160
161 %%%%%%%%
162 \makeatother
163 %%%%%%%%
164
165 \def\Node#1#2{\,\vcenter{\hbox{\fboxsep=1pt\fbox{\vbox{\small\halign{\hfil##\hfil\cr
166   #1\mathstrut\cr\noalign{\vskip1pt\hrule height.4pt\vskip1pt}\strut#2\cr}}}}}\,}
167 \def\HNode#1#2#3#4{\,\vcenter{\hbox{\fboxsep=1pt\fbox{\vbox{\small\halign{\hfil##\hfil\cr
168   #1\mathstrut\cr\noalign{\vskip1pt\hrule height.4pt\vskip1pt}%
169   width:\hfill\ #2\cr height:\hfill\ #3\cr depth:\hfill\ #4\cr
170   }}}}}\,}
171
172 \protected\def\Param#1{\hyperlink{fld:#1}{\textsf{#1}}} % parameter name
173 \protected\def\DParam#1{\hypertarget{fld:#1}{\textsf{#1}}} % parameter name (definition)
174 \protected\def\Pkg#1{\underline{\smash{\texttt{#1}}}} % packages/classes
175
176
177 \begin{document}
178 \lstset{
179   vscmd=\IVSB
180 }
181
182 \catcode`\<=13
183 \def<#1>{{\normalfont\rm\itshape$\langle$#1\/$\rangle$}}
184 \let\LARG=<
185 \maketitle
186
187 \tableofcontents
188 \bigskip
189
190 %<*en>
191 \textbf{This documentation is far from complete. It may have many
192 grammatical (and contextual) errors.} Also, several parts
193 are written in Japanese only.
194 %</en>
195 %<*ja>
196 \emph{\large 本ドキュメントはまだまだ未完成です.}
197 %</ja>
198
199 \clearpage
200 %<en>\part{User's manual}
201 %<ja>\part{ユーザーズマニュアル}
202
203 %<en>\section{Introduction}
204 %<ja>\section{はじめに}
205
206
207 %<*en>
208 The \LuaTeX-ja package is a macro package for typesetting high-quality
209 Japanese documents when using \LuaTeX.
210 %</en>
211 %<*ja>
212 \LuaTeX-jaパッケージは,次世代標準\TeX である\LuaTeX の上で,\pTeX と同等
213 /それ以上の品質の日本語組版を実現させようとするマクロパッケージである.
214 %</ja>
215 %<en>\subsection{Backgrounds}
216 %<ja>\subsection{背景}
217
218 %<*en>
219 Traditionally, ASCII \pTeX, an extension of \TeX, and its derivatives
220 are used to typeset Japanese documents in \TeX. \pTeX\ is an engine
221 extension of \TeX: so it can produce high-quality Japanese documents
222 without using very complicated macros. But this point is a mixed
223 blessing: \pTeX\ is left behind from other extensions of \TeX,
224 especially \eTeX\ and \pdfTeX, and from changes about
225 Japanese processing in computers (\textit{e.g.}, the UTF-8 encoding).
226 %</en>
227 %<*ja>
228 従来,「\TeX を用いて日本語組版を行う」といったとき,エンジンとしては
229 ASCII \pTeX やそれの拡張物が用いられることが一般的であった.\pTeX は\TeX
230 のエンジン拡張であり,(少々仕様上不便な点はあるものの)商業印刷の分野に
231 も用いられるほどの高品質な日本語組版を可能としている.だが,それは弱点に
232 もなってしまった.\pTeX という(組版的に)満足なものがあったため,海外で
233 行われている数々の\TeX の拡張――例えば\eTeX や\pdfTeX ――や,TrueType,
234 OpenType, Unicodeといった計算機で日本語を扱う際の状況の変化に追従すること
235 を怠ってしまったのだ.
236 %</ja>
237
238 %<*en>
239 Recently extensions of \pTeX, namely \upTeX\ (Unicode-implementation
240 of \pTeX) and \epTeX\ (merging of \pTeX\ and
241 \eTeX\ extension), have developed to fill those gaps to some
242 extent, but gaps still exist.
243 %</en>
244 %<*ja>
245 ここ数年,若干状況は改善されてきた.現在手に入る大半の\pTeX バイナリでは
246 外部UTF-8入力が利用可能となり,さらにUnicode化を推進し,\pTeX の内部処理
247 までUnicode化した\upTeX も開発されている.また,\pTeX に\eTeX 拡張をマー
248 ジした\epTeX も登場し,\TeX\ Live\ 2011では\pLaTeX が\epTeX の上で動作す
249 るようになった.だが,\pdfTeX 拡張(PDF直接出力やmicro-typesetting)を
250 \pTeX に対応させようという動きはなく,海外とのgapは未だにあるのが現状であ
251 る.
252 %</ja>
253
254 %<*en>
255 However, the appearance of \LuaTeX\ changed the whole situation. With
256 using Lua ``callbacks'', users can customize the internal processing of
257 \LuaTeX. So there is no need to modify sources of engines to
258 support Japanese typesetting: to do this, we only have to write Lua
259 scripts for appropriate callbacks.
260 %</en>
261 %<*ja>
262 しかし,\LuaTeX の登場で,状況は大きく変わることになった.Luaコードで
263 ``callback''を書くことにより,\LuaTeX の内部処理に割り込みをかけることが可
264 能となった.これは,エンジン拡張という真似をしなくても,Luaコードとそれに
265 関する\TeX マクロを書けば,エンジン拡張とほぼ同程度のことができるようになっ
266 たということを意味する.\LuaTeX-jaは,このアプローチによってLuaコード・
267 \TeX マクロによって日本語組版を\LuaTeX の上で実現させようという目的で開発
268 が始まったパッケージである.
269 %</ja>
270
271 %<en>\subsection{Major Changes from \pTeX}
272 %<ja>\subsection{\pTeX からの主な変更点}
273 \label{ssec:chgptex}
274
275 %<*en>
276 The \LuaTeX-ja package is under much influence of \pTeX\ engine. The initial
277 target of development was to implement features of \pTeX. However,
278 implementing all feature of \pTeX\ is impossible,
279 since all process of \LuaTeX-ja must be implemented only by Lua and \TeX\ macros.
280 Hence \emph{\LuaTeX-ja is not a just porting of \pTeX; unnatural
281 specifications/behaviors of \pTeX\ were not adopted}.
282 %</en>
283 %<*ja>
284 \LuaTeX-jaは,\pTeX に多大な影響を受けている.初期の開発目標は,\pTeX の機
285 能をLuaコードにより実装することであった.しかし,(\pTeX はエンジン拡張であったのに対し)
286 \LuaTeX-jaはLuaコードと\TeX マクロを用いて全てを実装していなければならないため,\pTeX
287 の完全な移植は不可能であり,また\pTeX における実装がいささか不可解になっ
288 ているような状況も発見された.そのため,\emph{\LuaTeX-jaは,もはや
289 \pTeX の完全な移植は目標とはしない.\pTeX における不自然な仕様・挙動があ
290 れば,そこは積極的に改める.}
291 %</ja>
292
293 %<*en>
294 The followings are major changes from \pTeX.
295 For more detailed information, see Part~\ref{part-imp} or other sections of this manual.
296 %</en>
297 %<*ja>
298 以下は \pTeX からの主な変更点である.
299 より詳細については第\ref{part-imp}部など本文書の残りを参照.
300 %</ja>
301
302 %<*en>
303 \paragraph{Command names} \pTeX\ addes several primitives, such as \cs{kanjiskip},
304 \cs{prebreakpenalty},~and,~\cs{ifydir}. They can be used as follows:
305 %</en>
306 %<*ja>
307 \paragraph{命令の名称} 例えば\pTeX で追加された次のようなプリミティブ
308 %</ja>
309 \begin{verbatim}
310 \kanjiskip=10pt  \dimen0=kanjiskip
311 \tbaselineshift=0.1zw
312 \dimen0=\tbaselineshift
313 \prebreakpenalty`ぁ=100
314 \ifydir ... \fi
315 \end{verbatim}
316 %<en> However, we cannot use them under \LuaTeX-ja.
317 %<en> Instead of them, we have to write as the following.
318 %<ja> は\LuaTeX-jaには存在しない.\LuaTeX-jaでは以下のように記述することになる.
319 \begin{verbatim}
320 \ltjsetparameter{kanjiskip=10pt}  \dimen0=\ltjgetparameter{kanjiskip}
321 \ltjsetparameter{talbaselineshift=0.1\zw}
322 \dimen0=\ltjgetparameter{talbaselineshift}
323 \ltjsetparameter{prebreakpenalty={`ぁ,100}}
324 \ifnum\ltjgetparemeter{direction}=4 ... \fi
325 \end{verbatim}
326 %<*en>
327 Note that \pTeX\ adds new two useful units, namely \texttt{zw}~and~\texttt{zh}.
328 As shown above, they are changed by \cs{zw}~and~\cs{zh} respectively, in \LuaTeX-ja.
329 %</en>
330 %<*ja>
331 特に注意してほしいのは,\pTeX で追加された \texttt{zw} と \texttt{zh} という単位を
332 \LuaTeX-ja で扱うには,\cs{zw}, \cs{zh} と制御綴の形にしないといけないという点である.
333 %</ja>
334
335 %<*en>
336 \paragraph{Linebreak after a Japanese character}
337 In \pTeX, a line break after Japanese character is ignored (and
338       doesn't yield a space), since line breaks (in source files) are
339       permitted almost everywhere in Japanese texts. However, \LuaTeX-ja
340       doesn't have this feature completely, because of a specification
341       of \LuaTeX. For the detail, see Section~\ref{sec-lbreak}.
342 %</en>
343 %<*ja>
344 \paragraph{和文文字直後の改行}
345 日本語の文書中では改行はほとんどどこでも許されるので,\pTeX では和文文字
346       直後の改行は無視される(スペースが入らない)ようになっていた.しかし,
347       \LuaTeX-ja では \LuaTeX の仕様のためにこの機能は完全には実装されていない.
348       詳しくは\ref{sec-lbreak}章を参照.
349 %</ja>
350
351 %<*en>
352
353 \paragraph{Spaces related to Japanese characters}
354 The insertion process of glues/kerns between two Japanese
355       characters and between a Japanese character and other characters
356       (we refer glues/kerns of both kinds as \textbf{JAglue}) is rewritten from
357       scratch.
358 %</en>
359 %<*ja>
360 \paragraph{和文関連の空白}
361 2つの和文文字の間や,和文文字と欧文文字の間に入るグルー/カーン
362       (両者をあわせて\textbf{JAglue}と呼ぶ)の挿入処理が0から書き直されている.
363 %</ja>
364
365 \begin{itemize}
366 %<*en>
367 \item As \LuaTeX's internal ligature handling is \emph{node-based}
368       (\textit{e.g.}, \verb+of{}fice+ doesn't prevent ligatures), the
369       insertion process of \textbf{JAglue} is now \emph{node-based}.
370 %</en>
371 %<*ja>
372 \item \LuaTeX の内部での合字の扱いは「ノード」を単位として行われるようになっている(例えば,
373       \verb+of{}fice+ で合字は抑制されない).それに合わせ,\textbf{JAglue}の挿入処理も
374       ノード単位で実行される.
375 %</ja>
376
377 %<*en>
378 \item Furthermore, nodes between two characters which have no effects in
379       line break (\textit{e.g.}, \cs{special} node) and kerns from
380       italic correction are ignored in the insertion process.
381 %</en>
382 %<*ja>
383 \item さらに,2つの文字の間にある行末では効果を持たないノード(例えば \cs{special} ノード)や,
384   イタリック補正に伴い挿入されるカーンは挿入処理中では無視される.
385 %</ja>
386
387 %<*en>
388 \item \emph{Caution: due to above two points, many methods which did for the
389       dividing the process of the insertion of \textbf{JAglue} in \pTeX\ are not
390       effective anymore.} In concrete terms, the following two methods are not effective anymore:
391 %</en>
392 %<*ja>
393 \item \emph{注意:上の2つの変更により,従来\textbf{JAglue}の挿入処理を分断するのに
394       使われていたいくつかの方法は用いることができない.具体的には,次の方法はもはや無効である:}
395 %</ja>
396 \begin{lstlisting}
397 ちょ{}っと    ちょ\/っと
398 \end{lstlisting}
399 %<*en>
400       If you want to do so, please put an empty horizontal box (hbox) between it instead:
401 %</en>
402 %<*ja>
403       もし同じことをやりたければ,空の水平ボックス(hbox)を間に挟めばよい:
404 %</ja>
405 \begin{lstlisting}
406 ちょ\hbox{}っと
407 \end{lstlisting}
408
409 %<*en>
410 \item In the process, two Japanese fonts which only differ in their ``real''
411       fonts are identified.
412 %</en>
413 %<*ja>
414 \item 処理中では,2つの和文フォントは,実フォントが異なるだけの場合には同一視
415       される.
416 %</ja>
417 \end{itemize}
418
419 %<*en>
420 \paragraph{Directions}
421 From this version, \LuaTeX-ja supports vertical writing;
422 but this feature must \emph{not} be confused with $\Omega$-style direction support of \LuaTeX\
423 itself. ...
424 %</en>
425 %<*ja>
426 \paragraph{組方向}
427 本版からは,不安定ながらも\LuaTeX-ja における縦組みをサポートしている.
428 なお,\LuaTeX 本体も,$\Omega$流の組方向をサポートしているが,それとは全くの別物であること
429 に注意してほしい.
430 \LuaTeX のコールバックや実装により,特に異なった組方向のボックスを扱う場合には
431 \cs{wd}, \cs{ht}, \cs{dp}等の仕様が異なるので注意.詳細は第\ref{sec-direction}章を参照.
432 %</ja>
433
434 %<*en>
435 \paragraph{\cs{discretionary}}
436 Japanese characters in discretionary break (\cs{discretionary}) is not supported.
437 %</en>
438 %<*ja>
439 \paragraph{\cs{discretionary}}
440  \cs{discretionary} 内に直接和文文字を記述することは,\pTeX においても想定されていなかった
441  感があるが.\LuaTeX-jaにおいても想定していない.和文文字をどう
442       しても使いたい場合は \cs{hbox} で括ること.
443 %</ja>
444
445
446
447 %<en>\subsection{Notations}
448 %<ja>\subsection{用語と記法}
449
450 %<*en>
451 In this document, the following terms and notations are used:
452 %</en>
453 %<*ja>
454 本ドキュメントでは,以下の用語と記法を用いる:
455 %</ja>
456 \begin{itemize}
457 %<*en>
458 \item Characters are classified into following two types.
459       Note that the classification can be customized by a user
460       (see Subsection~\ref{ssec-setrange}).
461 %</en>
462 %<*ja>
463 \item 文字は次の2種類に分けられる.この類別は固定されているものではなく,ユーザが後から変更可能である
464       (\ref{ssec-setrange}節を参照).
465 %</ja>
466 \begin{itemize}
467 %<*en>
468 \item \textbf{JAchar}: standing for characters which is used in Japanese typesetting,
469       such as Hiragana,~Katakana, Kanji, and~other Japanese punctuation marks.
470 %</en>
471 %<*ja>
472 \item \textbf{JAchar}: ひらがな,カタカナ,漢字,和文用の約物といった
473       日本語組版に使われる文字のことを指す.
474 %</ja>
475
476 %<en>\item \textbf{ALchar}: standing for all other characters like latin alphabets.
477 %<ja>\item \textbf{ALchar}: ラテンアルファベットを始めとする,その他全ての文字を指す.
478 \end{itemize}
479
480 %<*en>
481 We say \emph{alphabetic fonts} for fonts used in \textbf{ALchar},
482 and \emph{Japanese fonts} for fonts used in \textbf{JAchar}.
483 %</en>
484 %<*ja>
485 そして,\textbf{ALchar}の出力に用いられるフォントを\emph{欧文フォント}と呼び,
486 \textbf{JAchar}の出力に用いられるフォントを\emph{和文フォント}と呼ぶ.
487 %</ja>
488 %<*en>
489 \item A word in a sans-serif font (like \Param{prebreakpenalty})
490       means an internal parameter for Japanese typesetting, and it
491       is used as a key in \cs{ltjsetparameter} command.
492 %</en>
493 %<*ja>
494 \item サンセリフ体で書かれた語(例:\Param{prebreakpenalty})は日本語組版用の
495       パラメータを表し,これらは \cs{ltjsetparameter} 命令のキーとして
496       用いられる.
497 %</ja>
498 %<*en>
499 \item A word in typewriter font with underline (like \Pkg{fontspec})
500       means a package or a class of \LaTeX.
501 %</en>
502 %<*ja>
503 \item 下線付きタイプライタ体の語(例:\Pkg{fontspec})は\LaTeX の
504       パッケージやクラスを表す.
505 %</ja>
506 %<*en>
507 \item In this document, natural numbers start from~zero.
508   $\omega$ denotes the set of all natural numbers.
509 %</en>
510 %<*ja>
511 \item 本ドキュメントでは,自然数は0から始まる.自然数全体の集合は$\omega$と表記する.
512 %</ja>
513 \end{itemize}
514
515 %<en>\subsection{About the Project}
516 %<ja>\subsection{プロジェクトについて}
517
518 %<en>\paragraph{Project Wiki} Project Wiki is under construction.
519 %<ja>\paragraph{プロジェクトWiki} プロジェクトWikiは構築中である.
520 %<*en>
521 \begin{itemize}
522 \item \url{https://osdn.jp/projects/luatex-ja/wiki/FrontPage%28en%29} (English)
523 \item \url{https://osdn.jp/projects/luatex-ja/wiki/FrontPage} (Japanese)
524 \item \url{https://osdn.jp/projects/luatex-ja/wiki/FrontPage%28zh%29} (Chinese)
525 \end{itemize}
526 %</en>
527 %<*ja>
528 \begin{itemize}
529 \item \url{https://osdn.jp/projects/luatex-ja/wiki/FrontPage}(日本語)
530 \item \url{https://osdn.jp/projects/luatex-ja/wiki/FrontPage%28en%29}(英語)
531 \item \url{https://osdn.jp/projects/luatex-ja/wiki/FrontPage%28zh%29}(中国語)
532 \end{itemize}
533 %</ja>
534
535 %<en>This project is hosted by OSDN.
536 %<ja>本プロジェクトはOSDNのサービスを用いて運営されている.
537
538 %<en>\paragraph{Members}\
539 %<ja>\paragraph{開発メンバー}\
540
541 %<*en>
542 \begin{multienumerate}
543 \def\labelenumi{$\bullet$}
544 \mitemxxx{Hironori KITAGAWA}{Kazuki MAEDA}{Takayuki YATO}
545 \mitemxxx{Yusuke KUROKI}{Noriyuki ABE}{Munehiro YAMAMOTO}
546 \mitemxxx{Tomoaki HONDA}{Shuzaburo SAITO}{MA Qiyuan}
547 \end{multienumerate}
548 %</en>
549 %<*ja>
550 \begin{multienumerate}
551 \def\labelenumi{$\bullet$}
552 \mitemxxx{北川 弘典}{前田 一貴}{八登 崇之}
553 \mitemxxx{黒木 裕介}{阿部 紀行}{山本 宗宏}
554 \mitemxxx{本田 知亮}{齋藤 修三郎}{馬 起園}
555 \end{multienumerate}
556 %</ja>
557
558 % \paragraph{Acknowledgments} -- 挿入するならここ
559
560 \clearpage
561 %<en>\section{Getting Started}
562 %<ja>\section{使い方}
563 %<en>\subsection{Installation}
564 %<ja>\subsection{インストール}
565
566 %<en>The following packages are needed for the \LuaTeX-ja\ package.
567 %<ja>\LuaTeX-jaパッケージの動作には次のパッケージ類が必要である.
568 \begin{itemize}
569 \item \LuaTeX\ beta-0.80.0 (or later)
570 \item \Pkg{luaotfload} v2.5 (or later)
571 \item \Pkg{adobemapping} (Adobe cmap and pdfmapping files)
572 \item \Pkg{everysel} (if you want to use \LuaTeX-ja with \LaTeXe)
573 \item \Pkg{fontspec} v2.4
574 %<en>\item \emph{IPAex fonts} (\url{http://ipafont.ipa.go.jp/})
575 %<ja>\item \emph{IPAexフォント(\url{http://ipafont.ipa.go.jp/})}
576 \end{itemize}
577 %<en>In summary, this version of \LuaTeX-ja no longer supports \TeX~Live~2014 (or older version).
578 %<*ja>
579 要約すると,本バージョンの\LuaTeX-jaは\TeX~Live~2014以前では動作しない\footnote{%
580   もっとも,自分で\LuaTeX のバイナリをSubversionリポジトリからビルドしていれば話は別である.
581 }.
582 %</ja>
583
584 %<*en>
585 Now \LuaTeX-ja is available from
586 CTAN (in the \texttt{macros/luatex/generic/luatexja} directory), and
587 the following distributions:
588   \begin{itemize}
589   \item MiK\TeX\ (in \texttt{luatexja.tar.lzma}); see the next subsection
590   \item \TeX\ Live (in \texttt{texmf-dist/tex/luatex/luatexja})
591   \item W32\TeX\ (in \texttt{luatexja.tar.xz})
592   \end{itemize}
593 IPAex fonts are also available in these distributions.
594 %</en>
595 %<*ja>
596 現在,\LuaTeX-jaはCTAN (\texttt{macros/luatex/generic/luatexja})に収録されている他,
597 以下のディストリビューションにも収録されている:
598   \begin{itemize}
599   \item MiK\TeX\ (\texttt{luatexja.tar.lzma})
600   \item \TeX\ Live (\texttt{texmf-dist/tex/luatex/luatexja})
601   \item W32\TeX\ (\texttt{luatexja.tar.xz})
602   \end{itemize}
603 これらのディストリビューションはIPAexフォントも収録している.
604 W32\TeX においてはIPAexフォントは \texttt{luatexja.tar.xz} 内にある.
605 %</ja>
606
607 % %<*ja>
608 % 例えば\TeX~Live~2015を利用しているなら,\LuaTeX-jaは\TeX~Live manager (\texttt{tlmgr})を
609 % 使ってインストールすることができる.
610 % \begin{lstlisting}
611 % $ tlmgr install luatexja
612 % \end{lstlisting}
613 % %</ja>
614 % %<*en>
615 % If you are using \TeX~Live~2015, you can install \LuaTeX-ja
616 % from \TeX~Live manager (\texttt{tlmgr}):
617 % \begin{lstlisting}
618 % $ tlmgr install luatexja
619 % \end{lstlisting}
620 % %</en>
621
622 %<en>\paragraph{Manual installation}
623 %<ja>\paragraph{手動インストール方法}
624
625 \begin{enumerate}
626 %<*en>
627 \item Download the source, by one of the following method.
628       At the present, \LuaTeX-ja has no \emph{stable} release.
629
630 \begin{itemize}
631 \item Clone the Git repository:
632 \begin{lstlisting}
633 $ git clone git://git.osdn.jp/gitroot/luatex-ja/luatexja.git
634 \end{lstlisting}
635 \item Download the \texttt{tar.gz} archive of HEAD in the \texttt{master} branch from
636 \begin{flushleft}
637 \url{http://git.osdn.jp/view?p=luatex-ja/luatexja.git;a=snapshot;h=HEAD;sf=tgz}.
638 \end{flushleft}
639 \end{itemize}
640
641 Note that the \texttt{master} branch, and hence the archive in CTAN, are not updated frequently;
642 the forefront of development is not the \texttt{master} branch.
643 %</en>
644 %<*ja>
645 \item ソースを以下のいずれかの方法で取得する.現在公開されているのはあくまでも
646       開発版であって,安定版でないことに注意.
647
648 \begin{itemize}
649 \item Gitリポジトリをクローンする:
650 \begin{lstlisting}
651 $ git clone git://git.osdn.jp/gitroot/luatex-ja/luatexja.git
652 \end{lstlisting}
653 \item \texttt{master}ブランチのスナップショット(\texttt{tar.gz}形式)をダウンロードする.
654 \begin{flushleft}
655 \url{http://git.osdn.jp/view?p=luatex-ja/luatexja.git;a=snapshot;h=HEAD;sf=tgz}.
656 \end{flushleft}
657 \end{itemize}
658 \texttt{master}ブランチ(従って,CTAN内のアーカイブも)はたまにしか更新されないことに注意.
659 主な開発は\texttt{master}の外で行われ,比較的まとまってきたらそれを\texttt{master}に
660 反映させることにしている.
661 %</ja>
662
663 %<*en>
664 \item Extract the archive. You will see \texttt{src/} and several other sub-directories.
665 But only the contents in \texttt{src/} are needed to work \LuaTeX-ja.
666 %</en>
667 %<*ja>
668 \item 「Gitリポジトリをクローン」以外の方法でアーカイブを取得したならば,それを展開する.
669       \texttt{src/}をはじめとしたいくつかのディレクトリができるが,
670       動作には\texttt{src/}以下の内容だけで十分.
671 %</ja>
672
673 %<*en>
674 \item If you downloaded this package from CTAN, you have to run following commands
675     to generate classes
676     and \texttt{ltj-kinsoku.lua} (the file which stores default ``\textit{kinsoku}'' parameters):
677 %</en>
678 %<*ja>
679 \item もしCTANから本パッケージを取得したのであれば,日本語用クラスファイルや
680 標準の禁則処理用パラメータを
681 格納した \texttt{ltj-kinsoku.lua} を生成するために,
682 以下を実行する必要がある:
683 %</ja>
684 \begin{lstlisting}
685 $ cd src
686 $ lualatex ltjclasses.ins
687 $ lualatex ltjsclasses.ins
688 $ lualatex ltjltxdoc.ins
689 $ luatex   ltj-kinsoku_make.tex
690 \end{lstlisting}
691 %<*en>
692 \emph{Do not forget The last line (processing \texttt{ltj-kinsoku\_make.tex})}.
693 \texttt{*.\{dtx,ins\}} and \texttt{ltj-kinsoku\_make.tex} used here are not needed in regular use.
694 %</en>
695 %<*ja>
696 \emph{最後の \texttt{ltj-kinsoku\_make.tex} の実行を忘れないように注意}.
697 ここで使用した \texttt{*.\{dtx,ins\}} と \texttt{ltj-kinsoku\_make.tex} は
698 通常の使用にあたっては必要ない.
699 %</ja>
700
701
702
703 %<*en>
704 \item Copy all the contents of \texttt{src/} into one of your \texttt{TEXMF} tree.
705       \texttt{TEXMF/tex/luatex/luatexja/} is an example location.
706       If you cloned entire Git repository, making a symbolic link of \texttt{src/}
707       instead copying is also good.
708 %</en>
709 %<*ja>
710 \item \texttt{src}の中身を自分の\texttt{TEXMF}ツリーにコピーする.
711       場所の例としては,例えば
712 \begin{quote}
713  \texttt{TEXMF/tex/luatex/luatexja/}
714 \end{quote}
715       がある.
716       シンボリックリンクが利用できる環境で,かつリポジトリを直接取得したのであれば,
717       (更新を容易にするために)コピーではなくリンクを貼ることを勧める.
718 %</ja>
719 %<*en>
720 \item If \texttt{mktexlsr} is needed to update the file name database, make it so.
721 %</en>
722 %<*ja>
723 \item 必要があれば,\texttt{mktexlsr} を実行する.
724 %</ja>
725 \end{enumerate}
726
727 %<*en>
728 \subsection{Cautions}
729 For changes from \pTeX, see Subsection~\ref{ssec:chgptex}.
730 %</en>
731 %<*ja>
732 \subsection{注意点}
733 \pTeX からの変更点として,\ref{ssec:chgptex}節も熟読するのが望ましい.
734 ここでは一般的な注意点を述べる.
735 %</ja>
736 \begin{itemize}
737 %<*en>
738 \item The encoding of your source file must be UTF-8. No other
739       encodings, such as EUC-JP or Shift-JIS, are not supported.
740 %</en>
741 %<*ja>
742 \item 原稿のソースファイルの文字コードはUTF-8固定である.
743       従来日本語の文字コードとして用いられてきたEUC-JPやShift-JISは使用できない.
744 %</ja>
745 %<*en>
746 \item \LuaTeX-ja is very slower than \pTeX.
747 Generally speaking, LuaJIT\TeX\ processes \LuaTeX-ja
748 about 30\% faster than \LuaTeX, but not always.
749 %</en>
750 %<*ja>
751 \item \LuaTeX-jaは動作が\pTeX に比べて非常に遅い.
752 コードを調整して徐々に速くしているが,まだ満足できる速度ではない.
753 LuaJIT\TeX を用いると\LuaTeX のだいたい1.3倍の速度で動くようであるが,
754 IPA mj明朝などの大きいフォントを用いた場合には\LuaTeX よりも遅くなることもある.
755 %</ja>
756 \item%
757 %<*en>
758 \textbf{Outdated note for MiK\TeX\ users}\quad
759 \LuaTeX-ja requires that several CMap files%
760 \footnote{\texttt{UniJIS2004-UTF32-\{H,V\}} and \texttt{Adobe-Japan1-UCS2}.}
761 must be found from \LuaTeX.
762 Strictly speaking, those CMaps are needed
763 only in the first run of \LuaTeX-ja after installing or updating.
764 But it seems that MiK\TeX\ does not satisfy this condition,
765 so you will encounter an error like the following:
766 %</en>
767 %<*ja>
768 \LuaTeX-jaが動作するためには,\emph{導入・更新後の初回起動時に}
769 \texttt{UniJIS2004-UTF32-\{H,V\}}, \texttt{Adobe-Japan1-UCS2}という3つのCMapが
770 \LuaTeX によって見つけられることが必要である.
771 しかしやや古いMiK\TeX ではそのようになっていないので,次のエラーが発生するだろう:
772 %</ja>
773 \begin{lstlisting}
774 ! LuaTeX error ...iles (x86)/MiKTeX 2.9/tex/luatex/luatexja/ltj-rmlgbm.lua
775 bad argument #1 to 'open' (string expected, got nil)
776 \end{lstlisting}
777
778 %<*en>
779 If so, please execute a batch file which is written on
780 \href{https://osdn.jp/projects/luatex-ja/wiki/FrontPage%28en%29}{ the Project Wiki (English)}.
781 This batch file creates a temporary directory, copy CMaps in it,
782 run \LuaTeX-ja in this directory, and finally delete the temporary directory.
783 %</en>
784 %<*ja>
785 そのような場合には,
786 \href{https://osdn.jp/projects/luatex-ja/wiki/FrontPage%28en%29}{%
787   プロジェクトWiki英語版トップページ}中に書かれているバッチファイルを
788 実行して欲しい.このバッチファイルは,作業用ディレクトリにCMap達を
789 コピーし,その中で\LuaTeX-ja の初回起動を行い,作業用ディレクトリを消す作業をしている.
790 %</ja>
791
792 \end{itemize}
793
794 %<en>\subsection{Using in plain \TeX}
795 %<ja>\subsection{plain \TeX で使う}
796 \label{ssec-plain}
797
798 %<en>To use \LuaTeX-ja in plain \TeX, simply put the following at the beginning of the document:
799 %<ja>\LuaTeX-jaを plain \TeX で使うためには,単に次の行をソースファイルの冒頭に追加すればよい:
800 \begin{lstlisting}
801 \input luatexja.sty
802 \end{lstlisting}
803 %<en>This does minimal settings (like \texttt{ptex.tex}) for typesetting Japanese documents:
804 %<ja>これで(\texttt{ptex.tex}のように)日本語組版のための最低限の設定がなされる:
805
806 \begin{itemize}
807 %<*en>
808 \item The following 12~Japanese fonts are preloaded:
809 \begin{center}\small
810 \begin{tabular}{cccccc}
811 \toprule
812 \textbf{direction}&
813 \textbf{classification}&\textbf{font name}&\bf ``10\,pt''&\bf``7\,pt''&\bf``5\,pt''\\\midrule
814 \smash{\raisebox{-1ex}{\emph{yoko} (horizontal)}}&
815 \emph{mincho}&IPAex Mincho&\cs{tenmin}&\cs{sevenmin}&\cs{fivemin}\\
816 &\emph{gothic}&IPAex Gothic&\cs{tengt} &\cs{sevengt} &\cs{fivegt}\\
817 \midrule
818 \smash{\raisebox{-1ex}{\emph{tate} (vertical)}}&
819 \emph{mincho}&IPAex Mincho&\cs{tentmin}&\cs{seventmin}&\cs{fivetmin}\\
820 &\emph{gothic}&IPAex Gothic&\cs{tentgt} &\cs{seventgt} &\cs{fivetgt}\\
821 \bottomrule
822 \end{tabular}
823 \end{center}
824 %</en>
825 %<*ja>
826 \item 以下の12個の和文フォントが定義される:
827 \begin{center}\small
828 \begin{tabular}{cccccc}
829 \toprule
830 \emph{組方向}&\emph{字体}&\emph{フォント名}&\bf ``10\,pt''&\bf``7\,pt''&\bf``5\,pt''\\\midrule
831 \smash{\raisebox{-1ex}{横組}}&
832 明朝体&IPAex明朝&\cs{tenmin}&\cs{sevenmin}&\cs{fivemin}\\
833 &ゴシック体&IPAexゴシック&\cs{tengt} &\cs{sevengt} &\cs{fivegt}\\
834 \midrule
835 \smash{\raisebox{-1ex}{縦組}}&
836 明朝体&IPAex明朝&\cs{tentmin}&\cs{seventmin}&\cs{fivetmin}\\
837 &ゴシック体&IPAexゴシック&\cs{tentgt} &\cs{seventgt} &\cs{fivetgt}\\
838 \bottomrule
839 \end{tabular}
840 \end{center}
841 %</ja>
842 \begin{itemize}
843 %<*en>
844 \item With \texttt{luatexja.cfg}, one can use other fonts
845 as ``default'' Japanese fonts (Subsection~\ref{ssec-cfg}).
846 %</en>
847 %<*ja>
848 \item \texttt{luatexja.cfg} を用いることによって,標準和文フォントを
849 IPAexフォントから別のフォントに置き換えることができる.\ref{ssec-cfg}節を参照.
850 %</ja>
851
852 %<*en>
853 \item A character in an alphabetic font is generally smaller than a
854       Japanese font in the same size. So actual size specification of
855       these Japanese fonts is in fact smaller than that of alphabetic
856       fonts, namely scaled by 0.962216.
857 %</en>
858 %<*ja>
859 \item 欧文フォントの文字は和文フォントの文字よりも,同じ文字サイズでも
860       一般に小さくデザインされている.そこで,標準ではこれらの和文フォントの実際のサイズは指定された値よりも
861       小さくなるように設定されており,具体的には指定の0.962216倍にスケールされる.
862       この0.962216という数値も,\pTeX におけるスケーリングを踏襲した値である.
863 %</ja>
864 \end{itemize}
865
866 %<*en>
867 \item The amount of glue that are inserted between a \textbf{JAchar} and
868       an \textbf{ALchar} (the parameter \Param{xkanjiskip}) is set to
869 %</en>
870 %<*ja>
871 \item \textbf{JAchar}と\textbf{ALchar}の間に入るグルー(\Param{xkanjiskip})の
872       量は次のように設定されている:
873 %</ja>
874 \[
875  (0.25\cdot 0.962216\cdot 10\,\mathrm{pt})^{+1\,\text{pt}}_{-1\,\text{pt}}
876  = 2.40554\,\mathrm{pt}^{+1\,\text{pt}}_{-1\,\text{pt}}.
877 \]
878 \end{itemize}
879
880 %<en>\subsection{Using in \LaTeX}
881 %<ja>\subsection{\LaTeX で使う}
882 \label{ssec-ltx}
883
884 %<*en>
885 Using in \LaTeXe\ is basically same. To set up the minimal environment
886 for Japanese, you only have to load \texttt{luatexja.sty}:
887 %</en>
888 %<*ja>
889 \LaTeXe を用いる場合も基本的には同じである.日本語組版のための最低限の環境を
890 設定するためには,\texttt{luatexja.sty}を読み込むだけでよい:
891 %</ja>
892 \begin{lstlisting}
893 \usepackage{luatexja}
894 \end{lstlisting}
895 %<*en>
896 It also does minimal settings (counterparts in \pLaTeX\ are \texttt{%
897 plfonts.dtx} and \texttt{pldefs.ltx}):
898 %</en>
899 %<*ja>
900 これで\pLaTeX の\texttt{plfonts.dtx}と\texttt{pldefs.ltx}に相当する最低限の設定が
901 なされる:
902 %</ja>
903
904 \begin{itemize}
905 %<*en>
906 \item Font encodings for Japanese fonts is \texttt{JY3}~(for horizontal direction) and
907 \texttt{JT3}~(for vertical direction).
908 %</en>
909 %<*ja>
910 \item 和文フォントのエンコーディングとしては,横組用には \texttt{JY3},縦組用には\
911 \texttt{JT3}が用いられる.
912 %</ja>
913
914 %<*en>
915 \item Traditionally, Japanese documents use two typeface categories: \emph{mincho}~(明朝体) and
916  \emph{gothic}~(\textgt{ゴシック体}). \emph{mincho} is used in the main text, while \emph{gothic}
917       is used in the headings or for emphasis.
918 \begin{center}\small
919 \begin{tabular}{lllc}
920 \toprule
921 \textbf{classification}&&&\textbf{family name}\\\midrule
922 \emph{mincho} (明朝体)&\verb+\textmc{...}+&\verb+{\mcfamily ...}+&\cs{mcdefault}\\
923 \emph{gothic} (\textgt{ゴシック体})&\verb+\textgt{...}+&\verb+{\gtfamily ...}+&\cs{gtdefault}\\
924 \bottomrule
925 \end{tabular}
926 \end{center}
927 \item
928 By default, the following fonts are used for \emph{mincho} and \emph{gothic}:
929 \begin{center}\small
930 \begin{tabular}{ccccc}
931 \toprule
932 \textbf{classification}&\textbf{family}&\cs{mdseries}&\cs{bfseries}&\textbf{scale}\\\midrule
933 \emph{mincho} (明朝体)&\tt mc&IPAex Mincho&IPAex Gothic&0.962216\\
934 \emph{gothic} (\textgt{ゴシック体})&\tt gt&IPAex Gothic&IPAex Gothic&0.962216\\
935 \bottomrule
936 \end{tabular}
937 \end{center}
938 Note that the bold series in both family are same as the medium series of \emph{gothic}
939      family. There is no italic nor slanted shape for
940       these \texttt{mc}~and~\texttt{gt}.
941 %</en>
942 %<*ja>
943 \item \pLaTeX と同様に,標準では「明朝体」「ゴシック体」の2種類を用いる:
944 \begin{center}\small
945 \begin{tabular}{cllc}
946 \toprule
947 \emph{字体}&&&\emph{ファミリ名}\\\midrule
948 明朝体&\verb+\textmc{...}+&\verb+{\mcfamily ...}+&\cs{mcdefault}\\
949 \textgt{ゴシック体}&\verb+\textgt{...}+&\verb+{\gtfamily ...}+&\cs{gtdefault}\\
950 \bottomrule
951 \end{tabular}
952 \end{center}
953 \item 標準では,次のフォントファミリが用いられる:
954 \begin{center}\small
955 \begin{tabular}{ccccc}
956 \toprule
957 \emph{字体}&\emph{ファミリ}&\cs{mdseries}&\cs{bfseries}&\emph{スケール}\\\midrule
958 明朝体&\tt mc&IPAex明朝&IPAexゴシック&0.962216\\
959 ゴシック体&\tt gt&IPAexゴシック&IPAexゴシック&0.962216\\
960 \bottomrule
961 \end{tabular}
962 \end{center}
963 どちらのファミリにおいても,そのboldシリーズで使われるフォントは
964 ゴシック体のmediumシリーズで使われるフォントと同じであることに注意.
965 また,どちらのファミリでもイタリック体・スラント体は定義されない.
966 %</ja>
967
968 %<en>\item Japanese characters in math mode are typeset by the font family \texttt{mc}.
969 %<ja>\item 数式モード中の和文文字は明朝体(\texttt{mc})で出力される.
970
971 %<*en>
972 \item If you use the \Pkg{beamer} class with the default font theme (which uses sans serif
973       fonts) and with \LuaTeX-ja, you might want to change default Japanese fonts to
974       \emph{gothic} family. The following line  changes  the default Japanese font family
975       to \emph{gothic}:
976 %</en>
977 %<*ja>
978 \item \Pkg{beamer}クラスを既定のフォント設定で使う場合,既定欧文フォントがサンセリフなの
979       で,既定和文フォントもゴシック体にしたいと思うかもしれない.その場合はプリアンブルに
980 次を書けばよい:
981 %</ja>
982 \begin{lstlisting}
983  \renewcommand{\kanjifamilydefault}{\gtdefault}
984 \end{lstlisting}
985
986
987 \end{itemize}
988
989 %<*en>
990 However, above settings are not sufficient for Japanese-based
991 documents. To typeset Japanese-based documents, you are better to use
992 class files other than \texttt{article.cls}, \texttt{book.cls}, and so on.  At
993 the present, we have the counterparts of \Pkg{jclasses} (standard
994 classes in \pLaTeX) and \Pkg{jsclasses} (classes by Haruhiko
995 Okumura), namely, \Pkg{ltjclasses}\footnote{%
996   \texttt{ltjarticle.cls},~\texttt{ltjbook.cls}, \texttt{ltjreport.cls},
997   \texttt{ltjtarticle.cls}, \texttt{ltjtbook.cls}, \texttt{ltjtreport.cls}.
998   The latter \texttt{ltjt*.cls} are for vertically writtened Japanese documents.
999 } and \Pkg{ltjsclasses}\footnote{%
1000   \texttt{ltjsarticle.cls},~\texttt{ltjsbook.cls},~\texttt{ltjskiyou.cls}.}.
1001 %</en>
1002 %<*ja>
1003 しかしながら,上記の設定は日本語の文書にとって十分とは言えない.
1004 日本語文書を組版するためには,\texttt{article.cls}, \texttt{book.cls}といった
1005 欧文用のクラスファイルではなく,和文用のクラスファイルを用いた方がよい.
1006 現時点では,\Pkg{jclasses}(\pLaTeX の標準クラス)と\Pkg{jsclasses}
1007 (奥村晴彦氏による「\pLaTeXe 新ドキュメントクラス」)に対応するものとして,
1008 \Pkg{ltjclasses}\footnote{%
1009   横組用は \texttt{ltjarticle.cls},~\texttt{ltjbook.cls}, \texttt{ltjreport.cls} であり,
1010   縦組用は \texttt{ltjtarticle.cls}, \texttt{ltjtbook.cls}, \texttt{ltjtreport.cls} である.
1011 },
1012 \Pkg{ltjsclasses}\footnote{%
1013   \texttt{ltjsarticle.cls},~\texttt{ltjsbook.cls},~\texttt{ltjskiyou.cls}.}%
1014 がそれぞれ用意されている.
1015 %</ja>
1016
1017 %<*ja>
1018 \paragraph{脚注とボトムフロートの出力順序}
1019 オリジナルの\LaTeX では脚注がボトムフロートの上に来るようになっており,
1020 \pLaTeX では脚注がボトムフロートの下に来るように変更されている.
1021
1022 \LuaTeX-jaでは「欧文クラスの中にちょっとだけ日本語を入れる」という利用も考慮し,
1023 脚注とボトムフロートの順序は\LaTeX 通りとした.もし\pLaTeX の出力順序が好みならば,
1024 \Pkg{stfloats}パッケージを利用して
1025 \begin{lstlisting}
1026  \usepackage{stfloats}\fnbelowfloat
1027 \end{lstlisting}
1028 のようにすればよい.\Pkg{footmisc}パッケージを \texttt{bottom}\ オプションを指定して
1029 読み込むという方法もあるが,それだとボトムフロートと脚注の間が開いてしまう.
1030 %</ja>
1031 %%% ↑は英訳しない
1032
1033 %<*en>
1034 \paragraph{\Pkg{geometry} package and classes for vertical writing}
1035 It is well-known that the \Pkg{geometry} package produces the following error, when classes for
1036 vertical writing is used:
1037 %</en>
1038 %<*ja>
1039 \paragraph{縦組での\Pkg{geometry}パッケージ}
1040 \pLaTeX の縦組用標準クラスファイルでは\Pkg{geometry}パッケージを利用することは出来ず,
1041 %</ja>
1042 \begin{lstlisting}
1043 ! Incompatible direction list can't be unboxed.
1044 \@begindvi ->\unvbox \@begindvibox
1045                                    \global \let \@begindvi \@empty
1046 \end{lstlisting}
1047 %<*en>
1048 Now, \LuaTeX-ja automatically applies the patch \Pkg{lltjp-geometry} to the
1049 \Pkg{geometry} package, when the direction of the document is \emph{tate} (vertical
1050 writing).
1051 This patch \Pkg{lltjp-geometry} also can be used in \pLaTeX; for the detail, please refer
1052 \url{lltjp-geometry.pdf}~(Japanese).
1053 %</en>
1054 %<*ja>
1055 というようなエラーが発生することが知られている.
1056 \LuaTeX-jaでは, \texttt{ltjtarticle.cls} といった縦組クラスの下でも
1057 \Pkg{geometry}パッケージが利用できるようにパッチ\Pkg{lltjp-geometry}パッケージを自動的に当てている.
1058
1059 なお,\Pkg{lltjp-geometry}パッケージは\pTeX 系列でも明示的に読み込むことによって
1060 使用可能である.詳細や注意事項は \url{lltjp-geometry.pdf} を参照のこと.
1061 %</ja>
1062
1063
1064 %<en>\section{Changing Fonts}
1065 %<ja>\section{フォントの変更}
1066
1067 \subsection{plain \TeX~and~\LaTeXe}
1068 \label{ssec-chgfnt}
1069
1070 \paragraph{plain \TeX}
1071 %<*en>
1072 To change Japanese fonts in plain \TeX, you must use the command
1073 \cs{jfont}~and~\cs{tfont}. So please see Subsection~\ref{ssec-jfont}.
1074 %</en>
1075 %<*ja>
1076 plain \TeX で和文フォントを変更するためには,
1077 \pTeX のように \cs{jfont} 命令や \cs{tfont} 命令を直接用いる.
1078 \ref{ssec-jfont}節を参照.
1079 %</ja>
1080
1081 \paragraph{\LaTeXe\ (NFSS2)}
1082 %<*en>
1083 For \LaTeXe, \LuaTeX-ja adopted most of the font selection system of \pLaTeXe\ (in \texttt{plfonts.dtx}).
1084 %</en>
1085 %<*ja>
1086 \LaTeX で用いる際には,\pLaTeXe\ (\texttt{plfonts.dtx})用のフォント選択機構の大部分を流用している.
1087 %</ja>
1088 \begin{itemize}
1089 %<*en>
1090 \item Commands \cs{fontfamily}, \cs{fontseries},
1091       \cs{fontshape}, and \cs{selectfont} can be used to change
1092       attributes of Japanese fonts.
1093 %</en>
1094 %<*ja>
1095 \item 和文フォントの属性を変更するには,\cs{fontfamily}, \cs{fontseries}, \cs{fontshape},
1096       そしてそれらを反映させるために \cs{selectfont} を用いればよい.
1097 %</ja>
1098
1099 %<*en>
1100 \begin{center}\small
1101 \begin{tabular}{cccccc}
1102 \toprule
1103 &\textbf{encoding}&\textbf{family}&\textbf{series}&\textbf{shape}&\textbf{selection}\\\midrule
1104 alphabetic fonts
1105 &\cs{romanencoding}&\cs{romanfamily}&\cs{romanseries}&\cs{romanshape}
1106 &\cs{useroman}\\
1107 Japanese fonts
1108 &\cs{kanjiencoding}&\cs{kanjifamily}&\cs{kanjiseries}&\cs{kanjishape}
1109 &\cs{usekanji}\\
1110 both&---&--&\cs{fontseries}&\cs{fontshape}&---\\
1111 auto select&\cs{fontencoding}&\cs{fontfamily}&---&---&\cs{usefont}\\
1112 \bottomrule
1113 \end{tabular}
1114 \end{center}
1115 %</en>
1116 %<*ja>
1117 \begin{center}\small
1118 \begin{tabular}{cccccc}
1119 \toprule
1120 &\emph{エンコーディング}&\emph{ファミリ}&\emph{シリーズ}&\emph{シェープ}&\emph{選択}\\\midrule
1121 欧文
1122 &\cs{romanencoding}&\cs{romanfamily}&\cs{romanseries}&\cs{romanshape}
1123 &\cs{useroman}\\
1124 和文
1125 &\cs{kanjiencoding}&\cs{kanjifamily}&\cs{kanjiseries}&\cs{kanjishape}
1126 &\cs{usekanji}\\
1127 両方&---&--&\cs{fontseries}&\cs{fontshape}&---\\
1128 自動選択&\cs{fontencoding}&\cs{fontfamily}&---&---&\cs{usefont}\\
1129 \bottomrule
1130 \end{tabular}
1131 \end{center}
1132 %</ja>
1133
1134 %<*en>
1135       \verb+\fontencoding{+<encoding>\verb+}+ changes the encoding of alphabetic fonts
1136       or Japanese fonts depending on the argument. For example,
1137       \verb+\fontencoding{JY3}+ changes the encoding of Japanese fonts to
1138       \texttt{JY3}, and \verb+\fontencoding{T1}+ changes the encoding of
1139       alphabetic fonts to \texttt{T1}.
1140       \cs{fontfamily} also changes the current Japanese font family,
1141       the current alphabetic font family, \emph{or both}.
1142       For the detail, see Subsection~\ref{ssec-nfsspat}.
1143 %</en>
1144 %<*ja>
1145       ここで,\verb+\fontencoding{+<encoding>\verb+}+ は,引数により和文側か欧文
1146       側かのどちらかのエンコーディングを変更する.例えば,
1147       \verb+\fontencoding{JY3}+ は和文フォントのエンコーディングを
1148       \texttt{JY3}に変更し,\verb+\fontencoding{T1}+ は欧文フォント側を
1149       \texttt{T1}へと変更する.\cs{fontfamily} も引数により和文側,欧文
1150       側,\emph{あるいは両方}のフォントファミリを変更する.詳細は
1151       \ref{ssec-nfsspat}節を参照すること.
1152 %</ja>
1153
1154 %<*en>
1155 \item For defining a Japanese font family, use
1156       \cs{DeclareKanjiFamily} instead of
1157       \cs{DeclareFontFamily}. However, in the present implementation,
1158       using \cs{DeclareFontFamily} doesn't cause any problem.
1159 \item Defining a Japanese font shape can be done by usual \cs{DeclareFontShape}:
1160 %</en>
1161 %<*ja>
1162 \item 和文フォントファミリの定義には \cs{DeclareFontFamily} の
1163       代わりに \cs{DeclareKanjiFamily} を用いる.しかし,現在の
1164       実装では \cs{DeclareFontFamily} を用いても問題は生じない.
1165 \item 和文フォントのシェイプを定義するには,通常の \cs{DeclareFontShape} を使えば良い:
1166 %</ja>
1167 \begin{lstlisting}
1168 \DeclareFontShape{JY3}{mc}{bx}{n}{<-> s*KozMinPr6N-Bold:jfm=ujis;-kern}{}
1169     % Kozuka Mincho Pr6N Bold
1170 \end{lstlisting}
1171 %<*ja>
1172 仮名書体を使う場合など,複数の和文フォントを組み合わせて使いたい場合は
1173 \ref{ssec-altfont}節の \cs{ltjdeclarealtfont} と,その\LaTeX 版の\
1174 \cs{DeclareAlternateKanjiFont}(\ref{ssec-nfsspat}節)を参照せよ.
1175 %</ja>
1176
1177 \end{itemize}
1178
1179 %<*en>
1180 \paragraph{Remark: Japanese characters in math mode}
1181 Since \pTeX\ supports Japanese characters in math mode, there are
1182 sources like the following:
1183 %</en>
1184 %<*ja>
1185 \paragraph{注意:数式モード中の和文文字}
1186 \pTeX では,特に何もしないでも数式中に和文文字を記述することができた.そのため,
1187 以下のようなソースが見られた:
1188 %</ja>
1189
1190 \begin{LTXexample}
1191 $f_{高温}$~($f_{\text{high temperature}}$).
1192 \[ y=(x-1)^2+2\quad よって\quad y>0 \]
1193 $5\in 素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
1194 \end{LTXexample}
1195 %<*en>
1196 We (the project members of \LuaTeX-ja) think that using
1197 Japanese characters in math mode are allowed if and only if these are used as identifiers.
1198 In this point of view,
1199 %</en>
1200 %<*ja>
1201 \LuaTeX-jaプロジェクトでは,数式モード中での和文文字はそれらが識別子として用いられる
1202 ときのみ許されると考えている.
1203 この観点から,
1204 %</ja>
1205
1206 \begin{itemize}
1207 %<*en>
1208 \item The lines 1~and~2 above are not correct, since ``高温'' in above is used as a textual label, and
1209 ``よって'' is used as a conjunction.
1210 %</en>
1211 %<*ja>
1212 \item 上記数式のうち1, 2行目は正しくない.なぜならば「高温」が意味のあるラベルと
1213       して,「よって」が接続詞として用いられているからである.
1214 %</ja>
1215 %<en>\item However, the line~3 is correct, since ``素'' is used as an identifier.
1216 %<ja>\item しかしながら,3行目は「素」が単なる識別子として用いられているので正しい.
1217 \end{itemize}
1218 %<en>Hence, in our opinion, the above input should be corrected as:
1219 %<ja>したがって,\LuaTeX-jaプロジェクトの意見としては,上記の入力は次のように直されるべきである:
1220 \begin{LTXexample}
1221 $f_{\text{高温}}$~%
1222 ($f_{\text{high temperature}}$).
1223 \[ y=(x-1)^2+2\quad
1224   \mathrel{\text{よって}}\quad y>0 \]
1225 $5\in 素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
1226 \end{LTXexample}
1227 %<*en>
1228 We also believe that using Japanese characters as identifiers is rare,
1229 hence we don't describe how to change Japanese fonts in math mode in
1230 this chapter. For the method, please see Subsection~\ref{ssec-math}.
1231 %</en>
1232 %<*ja>
1233 また\LuaTeX-jaプロジェクトでは,和文文字が識別子として用いられることはほとんどない
1234 と考えており,したがってこの節では数式モード中の和文フォントを変更する方法については
1235 記述しない.この方法については\ref{ssec-math}節を参照のこと.
1236 %</ja>
1237
1238
1239 \subsection{fontspec}
1240 \label{ssec-fontspec}
1241 %<*en>
1242 To coexist with the \Pkg{fontspec} package, it is needed to load
1243 the \Pkg{luatexja-fontspec} package in the preamble, as follows:
1244 \begin{quote}
1245 \ttfamily \textbackslash usepackage[<options>]\{luatexja-fontspec\}
1246 \end{quote}
1247 This \Pkg{luatexja-fontspec} package
1248 automatically loads \Pkg{luatexja} and \Pkg{fontspec}
1249 packages, if needed.
1250 %</en>
1251 %<*ja>
1252 \Pkg{fontspec}パッケージと同様の機能を和文フォントに対しても用いる場合,
1253 \Pkg{luatexja-fontspec}パッケージを読み込めばよい.
1254 \begin{quote}
1255 \ttfamily \textbackslash usepackage[<options>]\{luatexja-fontspec\}
1256 \end{quote}
1257 このパッケージ
1258 は必要ならば自動で\Pkg{luatexja}パッケージと\Pkg{fontspec}パッケージを読み込む.
1259 %</ja>
1260
1261 %<*en>
1262 In the \Pkg{luatexja-fontspec} package, the following seven~commands are defined as
1263 counterparts of original commands in the \Pkg{fontspec} package:
1264 %</en>
1265 %<*ja>
1266 \Pkg{luatexja-fontspec}パッケージでは,以下の7つのコマンドを\Pkg{fontspec}
1267 パッケージの元のコマンドに対応するものとして定義している:
1268 %</ja>
1269 %<*en>
1270 \begin{center}\small
1271 \begin{tabular}{ccccc}
1272 \toprule
1273 Japanese fonts
1274 &\cs{jfontspec}&\cs{setmainjfont}&\cs{setsansjfont}&\cs{setmonojfont}$^*$\\
1275 alphabetic fonts
1276 &\cs{fontspec}&\cs{setmainfont}&\cs{setsansfont}&\cs{setmonofont}\\
1277 \midrule
1278 Japanese fonts
1279 &\cs{newjfontfamily}&\cs{newjfontface}
1280 &\cs{defaultjfontfeatures}&\cs{addjfontfeatures}\\
1281 alphabetic fonts
1282 &\cs{newfontfamily}&\cs{newfontface}
1283 &\cs{defaultfontfeatures}&\cs{addfontfeatures}\\
1284 \bottomrule
1285 \end{tabular}
1286 \end{center}
1287 %</en>
1288 %<*ja>
1289 \begin{center}\small
1290 \begin{tabular}{cccc}
1291 \toprule
1292 和文
1293 &\cs{jfontspec}&\cs{setmainjfont}&\cs{setsansjfont}\\
1294 欧文
1295 &\cs{fontspec}&\cs{setmainfont}&\cs{setsansfont}\\
1296 \midrule
1297 和文
1298 &\cs{newjfontfamily}&\cs{newjfontface}&\cs{defaultjfontfeatures}\\
1299 欧文
1300 &\cs{newfontfamily}&\cs{newfontface}&\cs{defaultfontfeatures}\\
1301 \midrule
1302 和文
1303 &\cs{addjfontfeatures}\\
1304 欧文
1305 &\cs{addfontfeatures}\\
1306 \bottomrule
1307 \end{tabular}
1308 \end{center}
1309 %</ja>
1310 %<*en>
1311 The package option of \Pkg{luatexja-fontspec} are the followings:
1312 \begin{cslist}
1313  \item[match]
1314 If this option is specified, usual family-changing commands such as
1315 \cs{rmfamily},~\cs{textrm}, \cs{sffamily},~\dots\ also change Japanese font family.
1316
1317 Note that \emph{\cs{setmonojfont} is defined
1318 if and only if this \texttt{\textup{match}} option is specified}.
1319
1320  \item[pass=<opts>]
1321 Specify options <opts> which will be passed to the \Pkg{fontspec} package.
1322 \end{cslist}
1323 The reason that \cs{setmonojfont} is not defined by default is that
1324 it is popular for Japanese fonts that nearly all Japanese glyphs have same
1325 widths.  Also note that kerning information in a font is not used
1326 (that is, \texttt{kern} feature is set off) by default in these seven (or~eight) commands.
1327 This is because of the compatibility with previous versions of \LuaTeX-ja
1328 (see \ref{para-kern}).
1329
1330 Below is an example of \cs{jfontspec}.
1331 %</en>
1332 %<*ja>
1333 \Pkg{luatexja-fontspec} パッケージのオプションは以下の通りである:
1334 \begin{cslist}
1335  \item[match]
1336 このオプションが指定されると,「\pLaTeXe 新ドキュメントクラス」のように\
1337 \cs{rmfamily}, \verb+\textrm{...}+, \cs{sffamily} 等が
1338 欧文フォントだけでなく和文フォントも変更するようになる.
1339
1340 \emph{なお,\cs{setmonojfont} はこの \texttt{match} オプションが
1341 指定された時のみ定義される.}この命令は標準の「タイプライタ体に対応する和文フォント」を指定する.
1342
1343  \item[pass=<opts>]
1344 \Pkg{fontspec} パッケージに渡すオプション <opts> を指定する.
1345 \end{cslist}
1346 標準で \cs{setmonojfont} コマンドが定義されないのは,
1347 和文フォントではほぼ全ての和文文字のグリフが等幅であるのが伝統的であったことによる.
1348 また,これらの和文用のコマンドではフォント内のペアカーニング情報は標準では使用されない,
1349 言い換えれば \texttt{kern} featureは標準では無効化となっている.
1350 これは以前のバージョンの\LuaTeX-jaとの互換性のためである(\ref{para-kern}節を参照).
1351
1352 以下に\cs{jfontspec}の使用例を示す.
1353 %</ja>
1354
1355 \begin{LTXexample}[width=0.4\textwidth]
1356 \jfontspec[CJKShape=NLC]{KozMinPr6N-Regular}
1357 JIS~X~0213:2004→辻\par
1358 \jfontspec[CJKShape=JIS1990]{KozMinPr6N-Regular}
1359 JIS~X~0208:1990→辻
1360 \end{LTXexample}
1361
1362 %<en>\subsection{Presets}
1363 %<ja>\subsection{プリセット設定}
1364 \label{ssec-preset}
1365
1366 %<*en>
1367 To use standard Japanese font settings easily, one can load the \Pkg{luatexja-preset}
1368 package with several options. This package provides functions in a part of
1369 \Pkg{japanese-otf} package and a part of \Pkg{PXchfon} package by Takayuki Yato.
1370 %</en>
1371 %<*ja>
1372 よく使われている和文フォント設定を一行で指定できるようにしたのが
1373 \Pkg{luatexja-preset}パッケージである.このパッケージは,
1374 \Pkg{otf}パッケージの一部機能と八登崇之氏による\Pkg{PXchfon}パッケージの一部機能とを
1375 合わせたような格好をしている.
1376 %</ja>
1377
1378 %<en>\paragraph{General options}
1379 %<ja>\paragraph{一般的なオプション}
1380 \begin{cslist}[before*=]
1381
1382 \item[fontspec]
1383 %<*en>
1384 With this option, Japanese fonts are selected using functionality of
1385 the \Pkg{luatexja-fontspec} package. This means that the \Pkg{fontspec} package is
1386              automatically loaded by this package.
1387 \emph{This option is enabled by default.}
1388
1389 If you need to pass some options to \Pkg{fontspec}, load \Pkg{fontspec} manually
1390 before \Pkg{luatexja-preset}:
1391 %</en>
1392 %<*ja>
1393 \Pkg{luatexja-fontspec}パッケージの機能を用いて和文フォントを選択する.
1394 これは,\Pkg{fontspec}パッケージが自動で読み込まれることを意味する.
1395 \emph{このオプションは標準で有効になっている.}
1396
1397 もし\Pkg{fontspec}パッケージに何らかのオプションを渡す必要がある
1398 \footnote{例えば,数式フォントまで置換されてしまい,\cs{mathit}によってギリシャ文字の
1399 斜体大文字が出なくなる,など.}場合は,
1400 次のように\Pkg{luatexja-preset}の前に\Pkg{fontspec}を手動で読みこめば良い:
1401 %</ja>
1402 \begin{lstlisting}
1403 \usepackage[no-math]{fontspec}
1404 \usepackage[...]{luatexja-preset}
1405 \end{lstlisting}
1406
1407 \item[nfssonly]
1408 %<*en>
1409 With this option,selecting Japanese fonts won't be performed using  the functionality of
1410              the \Pkg{fontspec} package, but only standard NFSS2.
1411
1412 This option will be disabled when \Pkg{luatexja-fontspec} package is loaded.
1413 Note that the \Pkg{fontspec} can coexist with the option as the following:
1414 \begin{lstlisting}
1415 \usepackage{fontspec}
1416 \usepackage[hiragino-pron,nfssonly]{luatexja-preset}
1417 \end{lstlisting}
1418 Note that the functionality of the \Pkg{luatexja-fontspec} package, such as
1419              \cs{setmainjfont}, cannot be used in the example above.
1420 %</en>
1421 %<*ja>
1422 \LaTeX 標準のフォント選択機構(NFSS2)を用いて
1423 \texttt{ltjpm}(明朝),\texttt{ltjpg}(ゴシック),それに後に述べる \texttt{deluxe} オプ
1424              ションが指定された場合には \texttt{ltjpmg}(丸ゴシック)という
1425 3つの和文フォントファミリを定義し,これらを用いる.
1426
1427 欧文フォントの指定で\Pkg{fontspec}パッケージを読み込んでいる場合でも
1428 \begin{lstlisting}
1429 \usepackage{fontspec}
1430 \usepackage[hiragino-pron,nfssonly]{luatexja-preset}
1431 \end{lstlisting}
1432 のようにこのオプションを指定することは可能である.一方,
1433 パッケージ読み込み時に既に\Pkg{luatexja-fontspec}パッケージが読み込まれて
1434              いる場合は \texttt{nfssonly} オプションは無視される.
1435 %</ja>
1436
1437 \item[nodeluxe]
1438 %<*en>
1439 Use one-weighted \textit{mincho} and \textit{gothic} font families.
1440 This means that \verb+\mcfamily\bfseries+, \verb+\gtfamily\bfseries+ and
1441 \verb+\gtfamily\mdseries+ use the same font.
1442 \emph{This option is enabled by default.}
1443 %</en>
1444 %<*ja>
1445 \LaTeXe 環境下の標準設定のように,明朝体・ゴシック体を各1ウェイトで使用する.
1446 より具体的に言うと,この設定の下では
1447 \ \verb+\mcfamily\bfseries+, \verb+\gtfamily\bfseries+,
1448 \verb+\gtfamily\mdseries+はみな同じフォントとなる.
1449 \emph{このオプションは標準で有効になっている.}
1450 %</ja>
1451 \item[deluxe]
1452 %<*en>
1453 Use \textit{mincho} with two weights (medium~and~bold),
1454 \textit{gothic} with three weights (medium, bold~and~heavy), and \textit{rounded gothic}%
1455 \footnote{Provided by \cs{mgfamily} and \cs{textmg},
1456 because \textit{rounded gothic} is called \textit{maru gothic} (丸ゴシック) in Japanese.}.
1457 The heavy weight of \textit{gothic} can be used by ``changing the family'' \cs{gtebfamily},
1458 or \verb+\textgteb{...}+.
1459 This is because the \Pkg{fontspec} package can handle only medium (\cs{mdseries}) and
1460 bold (\cs{bfseries}).
1461 %</en>
1462 %<*ja>
1463 明朝体2ウェイト・ゴシック体3ウェイトと,
1464 丸ゴシック体 (\cs{mgfamily}, \verb+\textmg{...}+) を使用可能とする.
1465 ゴシック体は中字・太字・極太の3ウェイトがあるが,
1466 極太ゴシック体を使う場合,
1467 \begin{itemize}
1468  \item \cs{gtebfamily}, \verb+\textgteb{...}+
1469  \item \cs{ebseries} (周囲がゴシック体のとき,\texttt{nfssonly} オプション指定時のみ)
1470 \end{itemize}
1471 のいずれかを用いる.標準で \cs{ebseries} が準備されていないのは,バージョンが古い
1472 \Pkg{fontspec}では中字(\cs{mdseries})と太字(\cs{bfseries})しか扱えなかった名残である.
1473 %</ja>
1474 \item[expert]
1475 %<*en>
1476 Use horizontal/vertical kana alternates, and define a command \cs{rubyfamily} to use kana
1477 characters designed for ruby.
1478 %</en>
1479 %<*ja>
1480 横組・縦組専用仮名を用いる.また,\cs{rubyfamily} でルビ用仮名が使用可能となる\footnote{%
1481   \cs{rubyfamily}とはいいつつ,実際にはフォントファミリを切り替えるのではない(通常では
1482   font featureの追加,\texttt{nfssonly} 指定時にはシェイプを \texttt{rb} に切り替え).
1483 }.
1484 %</ja>
1485 \item[bold]
1486 %<en>Substitute bold series of \textit{gothic} for  bold series of \textit{mincho}.
1487 %<ja>「明朝の太字」をゴシック体の太字によって代替する.
1488 \item[90jis]
1489 %<en>Use 90JIS glyph variants if possible.
1490 %<ja>出来る限り90JISの字形を使う.
1491 \item[jis2004]
1492 %<en>Use JIS2004 glyph variants if possible.
1493 %<ja>出来る限りJIS2004の字形を使う.
1494 \item[jis]
1495 %<*en>
1496 Use the JFM \texttt{jfm-jis.lua}, instead of \texttt{jfm-ujis.lua}, which is the default JFM of
1497 \LuaTeX-ja.
1498 %</en>
1499 %<*ja>
1500 用いるJFMを(JISフォントメトリック類似の)\texttt{jfm-jis.lua}にする.このオプションがない時は
1501 \LuaTeX-ja標準の\texttt{jfm-ujis.lua}が用いられる.
1502 %</ja>
1503 \end{cslist}
1504 %<*en>
1505 Note that \texttt{90jis} and \texttt{jis2004} only affect with \textit{mincho},
1506 \textit{gothic} (and possibly \textit{rounded gothic}) defined by this package.
1507 We didn't taken account of  when both \texttt{90jis} and \texttt{jis2004} are specified.
1508 %</en>
1509 %<*ja>
1510 \texttt{90jis}と\texttt{jis2004}については本パッケージで定義された
1511 明朝体・ゴシック体(・丸ゴシック体)にのみ有効である.両オプションが
1512 同時に指定された場合の動作については全く考慮していない.
1513 %</ja>
1514
1515 %<en>\paragraph{Presets for multi weight}
1516 %<ja>\paragraph{多ウェイト用プリセットの一覧}
1517 %<*en>
1518 Besides \texttt{morisawa-pro}~and~\texttt{morisawa-pr6n} presets,
1519 fonts are specified by font name, not by file name.
1520 In following tables, starred fonts (e.g.~KozGo\dots-Regular) are used for medium series of \textit{gothic},
1521 \emph{if and only if \texttt{deluxe} option is specified}.
1522 %</en>
1523 %<*ja>
1524 \texttt{morisawa-pro}, \texttt{morisawa-pr6n}以外はフォントの指定は
1525 (ファイル名でなく)フォント名で行われる.
1526 以下の表において,*\,つきのフォント(e,g,~KozGo\dots-Regular)は,\emph{\texttt{deluxe}オプション指定時に}
1527 ゴシック体中字として用いられるものを示している.
1528 %</ja>
1529 \begin{cslist}[style=standard]
1530  \item[kozuka-pro] Kozuka Pro (Adobe-Japan1-4) fonts.
1531 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
1532  \item[kozuka-pr6] Kozuka Pr6 (Adobe-Japan1-6)  fonts.
1533 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
1534  \item[kozuka-pr6n] Kozuka Pr6N (Adobe-Japan1-6, JIS04-savvy) fonts.
1535
1536 %<*en>
1537 Kozuka Pro/Pr6N fonts are bundled with Adobe's software, such as Adobe~InDesign.
1538 There is not rounded gothic family in Kozuka fonts.
1539 %</en>
1540 %<*ja>
1541 小塚Pro書体・Pr6N書体はAdobe InDesign等のAdobe製品にバンドルされている.
1542 「小塚丸ゴシック」は存在しないので,便宜的に小塚ゴシックHによって代用している.
1543 %</ja>
1544 \begin{center}\small
1545 \begin{tabular}{cllll}
1546 \toprule
1547 \bf family&\bf series&\tt kozuka-pro&\tt kozuka-pr6&\tt kozuka-pr6n\\
1548 \midrule
1549  &medium&KozMinPro-Regular&KozMinProVI-Regular&KozMinPr6N-Regular\\
1550 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
1551 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
1552  &bold&KozMinPro-Bold&KozMinProVI-Bold&KozMinPr6N-Bold\\
1553 \midrule
1554  &&KozGoPro-Regular*&KozGoProVI-Regular*&KozGoPr6N-Regular*\\
1555  &\smash{\raisebox{1.5ex}{medium}}
1556  &KozGoPro-Medium&KozGoProVI-Medium&KozGoPr6N-Medium\\
1557 \cmidrule(l){2-5}
1558 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
1559 %<ja>\smash{\raisebox{2ex}{\gt ゴシック}}%
1560  &bold&KozGoPro-Bold&KozGoProVI-Bold&KozGoPr6N-Bold\\
1561  &heavy&KozGoPro-Heavy&KozGoProVI-Heavy&KozGoPr6N-Heavy\\
1562 \midrule
1563 %<en>\textit{rounded gothic}
1564 %<ja>\gt 丸ゴシック
1565 &&KozGoPro-Heavy&KozGoProVI-Heavy&KozGoPr6N-Heavy\\
1566 \bottomrule
1567 \end{tabular}
1568 \end{center}
1569
1570 %<ja>\newpage
1571
1572  \item[hiragino-pro]  Hiragino Pro (Adobe-Japan1-5) fonts.
1573 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
1574  \item[hiragino-pron] Hiragino ProN (Adobe-Japan1-5, JIS04-savvy) fonts.
1575
1576 %<*en>
1577 Hiragino fonts are bundled with Mac OS~X 10.5 or later.
1578 Some editions of a Japanese word-processor ``一太郎2012'' includes Hiragino ProN fonts.
1579 Note that the heavy weight of \textit{gothic} family only supports
1580 Adobe-Japan1-3 character collection (Std/StdN).
1581 %</en>
1582 %<*ja>
1583 ヒラギノフォントは,Mac OS~X以外にも,一太郎2012の上位エディションにもバンドルされている.
1584 極太ゴシックとして用いるヒラギノ角ゴW8は,Adobe-Japan1-3の範囲しかカバーしていない
1585 Std/StdNフォントであり,その他はAdobe-Japan1-5対応である.
1586 %</ja>
1587 \begin{center}\small
1588 \begin{tabular}{clll}
1589 \toprule
1590 \bf family&\bf series&\tt hiragino-pro&\tt hiragino-pron\\
1591 \midrule
1592  &medium&Hiragino~Mincho~Pro~W3&Hiragino~Mincho~ProN~W3\\
1593 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
1594 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
1595  &bold&Hiragino~Mincho~Pro~W6&Hiragino~Mincho~ProN~W6\\
1596 \midrule
1597  &&Hiragino~Kaku~Gothic~Pro~W3*&Hiragino~Kaku~Gothic~ProN~W3*\\
1598  &\smash{\raisebox{1.5ex}{medium}}
1599  &Hiragino~Kaku~Gothic~Pro~W6&Hiragino~Kaku~Gothic~ProN~W6\\
1600 \cmidrule(l){2-4}
1601 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
1602 %<ja>\smash{\raisebox{2ex}{\gt ゴシック}}%
1603  &bold&Hiragino~Kaku~Gothic~Pro~W6&Hiragino~Kaku~Gothic~ProN~W6\\
1604  &heavy&Hiragino~Kaku~Gothic~Std~W8&Hiragino~Kaku~Gothic~StdN~W8\\
1605 \midrule
1606 %<en>\textit{rounded gothic}
1607 %<ja>\gt 丸ゴシック
1608 &&Hiragino~Maru~Gothic~Pro~W4&Hiragino~Maru~Gothic~ProN~W4\\
1609 \bottomrule
1610 \end{tabular}
1611 \end{center}
1612
1613 %<ja>\medskip
1614
1615  \item[morisawa-pro]  Morisawa Pro (Adobe-Japan1-4) fonts.
1616 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
1617  \item[morisawa-pr6n]  Morisawa Pr6N (Adobe-Japan1-6, JIS04-savvy) fonts.
1618
1619 \begin{center}\small
1620 \begin{tabular}{cl>{\tt}l>{\tt}l}
1621 \toprule
1622 \bf family&\bf series&morisawa-pro&morisawa-pr6n\\
1623 \midrule
1624  &medium&A-OTF-RyuminPro-Light.otf&A-OTF-RyuminPr6N-Light.otf\\
1625 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
1626 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
1627  &bold&A-OTF-FutoMinA101Pro-Bold.otf&A-OTF-FutoMinA101Pr6N-Bold.otf\\
1628 \midrule
1629  &medium
1630  &A-OTF-GothicBBBPro-Medium.otf&A-OTF-GothicBBBPr6N-Medium.otf\\
1631 %<en>\textit{gothic}%
1632 %<ja>\gt ゴシック
1633  &bold&A-OTF-FutoGoB101Pro-Bold.otf&A-OTF-FutoGoB101Pr6N-Bold.otf\\
1634  &heavy&A-OTF-MidashiGoPro-MB31.otf&A-OTF-MidashiGoPr6N-MB31.otf\\
1635 \midrule
1636 %<en>\textit{rounded gothic}
1637 %<ja>\gt 丸ゴシック
1638 &&A-OTF-Jun101Pro-Light.otf&A-OTF-ShinMGoPr6N-Light.otf\\
1639 \bottomrule
1640 \end{tabular}
1641 \end{center}
1642
1643  \item[yu-win]  Yu fonts bundled with Windows~8.1.
1644 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
1645  \item[yu-osx]  Yu fonts bundled with OSX~Mavericks.
1646
1647 \begin{center}\small
1648 \begin{tabular}{clll}
1649 \toprule
1650 \bf family&\bf series&\tt yu-win&\tt yu-osx\\
1651 \midrule
1652  &medium&YuMincho-Regular&YuMincho~Medium\\
1653 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
1654 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
1655  &bold&YuMincho-Demibold&YuMincho~Demibold\\
1656 \midrule
1657  &&YuGothic-Regular*&YuGothic~Medium*\\
1658  &\smash{\raisebox{1.5ex}{medium}}
1659  &YuGothic-Bold&YuGothic~Bold\\
1660 \cmidrule(l){2-4}
1661 %<en>\textit{gothic}%
1662 %<ja>\gt ゴシック
1663  &bold&YuGothic-Bold&YuGothic~Bold\\
1664  &heavy&YuGothic-Bold&YuGothic~Bold\\
1665 \midrule
1666 %<en>\textit{rounded gothic}
1667 %<ja>\gt 丸ゴシック
1668 &&YuGothic-Bold&YuGothic~Bold\\
1669 \bottomrule
1670 \end{tabular}
1671 \end{center}
1672
1673  \item[moga-mobo]  MogaMincho, MogaGothic, and MoboGothic.
1674 %<en>These fonts can be downloaded from\\\hfill \url{http://yozvox.web.fc2.com/}.
1675 %<ja>これらのフォントは \url{http://yozvox.web.fc2.com/} からダウンロードできる.
1676
1677 \begin{center}\small
1678 \begin{tabular}{clll}
1679 \toprule
1680 \bf family&\bf series&\bf default, \texttt{90jis}~option&\bf \texttt{jis2004} option\\
1681 \midrule
1682  &medium&Moga90Mincho&MogaMincho\\
1683 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
1684 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
1685  &bold&Moga90Mincho Bold&MogaMincho Bold\\
1686 \midrule
1687  &&Moga90Gothic&MogaGothic\\
1688  &\smash{\raisebox{1.5ex}{medium}}
1689  &Moga90Gothic&MogaGothic\\
1690 \cmidrule(l){2-4}
1691 %<en>\textit{gothic}%
1692 %<ja>\gt ゴシック
1693  &bold&Moga90Gothic Bold&MogaGothic Bold\\
1694  &heavy&Moga90Gothic Bold&MogaGothic Bold\\
1695 \midrule
1696 %<en>\textit{rounded gothic}
1697 %<ja>\gt 丸ゴシック
1698 &&Mobo90Gothic&MoboGothic\\
1699 \bottomrule
1700 \end{tabular}
1701 \end{center}
1702
1703
1704 \end{cslist}
1705 %<en>\paragraph{Presets for single weight}
1706 %<ja>\paragraph{単ウェイト用プリセット一覧}
1707 %<*en>
1708 Next, we describe settings for using only single weight.
1709 %</en>
1710 %<*ja>
1711 次に,単ウェイト用の設定を述べる.この4設定では
1712 明朝体太字・丸ゴシック体はゴシック体と同じフォントが用いられる.
1713 %</ja>
1714 \par\nobreak\medskip
1715 {\centering\small
1716 \begin{tabular}{lllll}
1717 \toprule
1718 &\tt noembed&\tt ipa&\tt ipaex&\tt ms\\
1719 \midrule
1720 %<*en>
1721 \it mincho&Ryumin-Light (non-embedded)
1722 &IPA Mincho&IPAex Mincho&MS Mincho\\
1723 \it gothic&GothicBBB-Medium (non-embedded)
1724 &IPA Gothic&IPAex Gothic&MS Gothic\\
1725 %</en>
1726 %<*ja>
1727 \gtfamily 明朝体&Ryumin-Light(非埋込)
1728 &IPA明朝&IPAex明朝&MS明朝\\
1729 \gtfamily ゴシック体&GothicBBB-Medium(非埋込)
1730 &IPAゴシック&IPAexゴシック&MSゴシック\\
1731 %</ja>
1732 \bottomrule
1733 \end{tabular}\par\medskip}
1734
1735 %<en>\paragraph{Using HG fonts}
1736 %<ja>\paragraph{HGフォントの利用}
1737 %<*en>
1738 We can use HG~fonts bundled with Microsoft~Office for realizing multiple weights.
1739 %</en>
1740 %<*ja>
1741 すぐ前に書いた単ウェイト用設定を,Microsoft Office等に付属するHGフォントを使って
1742 多ウェイト化した設定もある.
1743 %</ja>
1744 \par\nobreak\medskip
1745 {\centering\small
1746 \begin{tabular}{llll}
1747 \toprule
1748 &\tt ipa-hg&\tt ipaex-hg&\tt ms-hg\\
1749 \midrule
1750 %<*en>
1751 \bf mincho medium
1752 &IPA Mincho&IPAex Mincho&MS Mincho\\\midrule
1753 \bf mincho bold&
1754 \multicolumn{3}{c}{HG Mincho E}\\\midrule
1755 \bf Gothic medium\\
1756 ~~without \texttt{deluxe}
1757 &IPA Gothic&IPAex Gothic&MS Gothic\\
1758 ~~with {\tt jis2004}
1759 &IPA Gothic&IPAex Gothic&MS Gothic\\
1760 \cmidrule(lr){1-4}
1761 ~~otherwise&
1762 \multicolumn{3}{c}{HG Gothic M}\\\midrule
1763 \bf gothic bold&
1764 \multicolumn{3}{c}{HG Gothic E}\\\midrule
1765 \bf gothic heavy&
1766 \multicolumn{3}{c}{HG Soei Kaku Gothic UB}\\\midrule
1767 \bf rounded gothic&
1768 \multicolumn{3}{c}{HG Maru Gothic PRO}\\
1769 %</en>
1770 %<*ja>
1771 \gtfamily 明朝体中字
1772 &IPA明朝&IPAex明朝&MS明朝\\\midrule
1773 \gtfamily 明朝体太字&
1774 \multicolumn{3}{c}{HG明朝E}\\\midrule
1775 \gtfamily ゴシック体中字\\
1776  単ウェイト時
1777 &IPAゴシック&IPAexゴシック&MSゴシック\\
1778  {\tt jis2004}指定時
1779 &IPAゴシック&IPAexゴシック&MSゴシック\\
1780 \cmidrule(lr){1-4}
1781  それ以外の時&
1782 \multicolumn{3}{c}{HGゴシックM}\\\midrule
1783 \gtfamily ゴシック体太字&
1784 \multicolumn{3}{c}{HGゴシックE}\\\midrule
1785 \gtfamily ゴシック体極太&
1786 \multicolumn{3}{c}{HG創英角ゴシックUB}\\\midrule
1787 \gtfamily 丸ゴシック体&
1788 \multicolumn{3}{c}{HG丸ゴシック体PRO}\\
1789 %</ja>
1790 \bottomrule
1791 \end{tabular}\par\medskip}
1792
1793 %<*en>
1794 Note that HG~Mincho~E, HG~Gothic~E, HG Soei Kaku Gothic UB, and HG Maru Gothic PRO
1795 are internally specified by:
1796 \begin{description}
1797 \item[default] by font name (\texttt{HGMinchoE}, etc.).
1798 \item[{\tt 90jis}] by file name (\texttt{hgrme.ttc}, \texttt{hgrge.ttc}, \texttt{hgrsgu.ttc}, \texttt{hgrsmp.ttf}).
1799 \item[{\tt jis2004}] by file name (\texttt{hgrme04.ttc}, \texttt{hgrge04.ttc}, \texttt{hgrsgu04.ttc}, \texttt{hgrsmp04.ttf}).
1800 \end{description}
1801 %</en>
1802 %<*ja>
1803 なお,HG明朝E・HGゴシックE・HG創英角ゴシックUB・HG丸ゴシック体PROの4つについては,内部で
1804 \begin{description}
1805 \item[標準] フォント名(\texttt{HGMinchoE} など)
1806 \item[{\tt 90jis}指定時] ファイル名 (%
1807 \texttt{hgrme.ttc}, \texttt{hgrge.ttc}, \texttt{hgrsgu.ttc}, \texttt{hgrsmp.ttf})
1808 \item[{\tt jis2004}指定時] ファイル名 (%
1809 \texttt{hgrme04.ttc}, \texttt{hgrge04.ttc}, \texttt{hgrsgu04.ttc}, \texttt{hgrsmp04.ttf})
1810 \end{description}
1811 として指定を行っているので注意すること.
1812 %</ja>
1813
1814
1815 %<*en>
1816 \subsection{\cs{CID}, \cs{UTF}, and macros in \Pkg{japanese-otf} package}
1817 Under \pLaTeX, \Pkg{japanese-otf} package (developed by Shuzaburo Saito) is
1818 used for typesetting characters which is in Adobe-Japan1-6 CID but not
1819 in JIS~X~0208. Since this package is widely used, \LuaTeX-ja
1820 supports some of functions in the \Pkg{japanese-otf} package,
1821 as an external package \Pkg{luatexja-otf}.
1822 %</en>
1823 %<*ja>
1824 \subsection{\cs{CID}, \cs{UTF}と\Pkg{otf}パッケージのマクロ}
1825 \pLaTeX では,JIS~X~0208にないAdobe-Japan1-6の文字を出力するために,
1826 齋藤修三郎氏による\Pkg{otf}パッケージが用いられていた.このパッケージは
1827 広く用いられているため,\LuaTeX-jaにおいても\Pkg{otf}パッケージの機能の
1828 一部を(\Pkg{luatexja-otf}という別のパッケージとして)実装した.
1829 %</ja>
1830
1831 \begin{LTXexample}
1832 \jfontspec{KozMinPr6N-Regular.otf}
1833 森\UTF{9DD7}外と内田百\UTF{9592}とが\UTF{9AD9}島屋に行く。
1834
1835 \CID{7652}飾区の\CID{13706}野家,
1836 \CID{1481}城市,葛西駅,
1837 高崎と\CID{8705}\UTF{FA11}
1838
1839 \aj半角{はんかくカタカナ}
1840 \end{LTXexample}
1841
1842 %<*ja>
1843 \Pkg{otf}パッケージでは,それぞれ次のようなオプションが存在した:
1844 \begin{cslist}
1845 \item[deluxe] 明朝体・ゴシック体各3ウェイトと,丸ゴシック体を扱えるようになる.
1846 \item[expert] 仮名が横組・縦組専用のものに切り替わり,ルビ用仮名も
1847 \ \cs{rubyfamily}\ によって扱えるようになる.
1848 \item[bold] ゴシック体を標準で太いウェイトのものに設定する.
1849 \end{cslist}
1850 しかしこれらのオプションは\Pkg{luatexja-otf}パッケージには存在しない.
1851 \Pkg{otf}パッケージが文書中で使用する和文用TFMを自前の物に置き換えていたのに対し,
1852 \Pkg{luatexja-otf}パッケージでは,そのようなことは行わないからである.
1853
1854 これら3オプションについては,
1855 \Pkg{luatexja-preset} パッケージにプリセットを使う時に一緒に指定するか,
1856 あるいは対応する内容を\ref{ssec-chgfnt}節,\ref{ssec-nfsspat}節 (NFSS2) や
1857 \ref{ssec-fontspec}節 (\Pkg{fontspec}) の方法で手動で指定する必要がある.
1858 %</ja>
1859
1860 %<en>\subsection{Changing default Japanese fonts}
1861 %<ja>\subsection{標準和文フォントの変更}
1862 \label{ssec-cfg}
1863 %<*en>
1864 If \texttt{luatexja.cfg} can be seen from \LuaTeX, \LuaTeX-ja automatically reads it.
1865 The main use of \texttt{luatexja.cfg} is for changing default Japanese fonts,
1866 when IPAex fonts cannot be installed in \TeX~system.
1867 One should not overuse this \texttt{luatexja.cfg}; fonts which will be used in
1868 a document should be specified in its source.
1869
1870 For example,
1871 \begin{lstlisting}
1872 \def\ltj@stdmcfont{IPAMincho}
1873 \def\ltj@stdgtfont{IPAGothic}
1874 \end{lstlisting}
1875 makes that IPA~Mincho and IPA~Gothic will be used as default Japanese fonts, instead of
1876 IPAex~Mincho and IPAex~Gothic.
1877
1878 For another example, the following two lines makes that
1879 non-embedded fonts Ryumin-Light~and~GothicBBB-Medium as default Japanese fonts
1880 (as the earlier version of \LuaTeX-ja):
1881 \begin{lstlisting}
1882 \def\ltj@stdmcfont{psft:Ryumin-Light}
1883 \def\ltj@stdgtfont{psft:GothicBBB-Medium}
1884 \end{lstlisting}
1885 %</en>
1886 %<*ja>
1887 \LuaTeX から見える位置に \texttt{luatexja.cfg} があれば,\LuaTeX-jaはそれを読み込む.
1888 このファイルを用いるとplain~\TeX, \LaTeXe における標準和文フォントを
1889 IPAex明朝・IPAexゴシックから変更することができる.
1890 しかし,基本的には\emph{文章中で用いるフォントは(例えば \Pkg{luatexja-preset} などで)
1891 文書ソース内で指定するべき}であり,この \texttt{luatexja.cfg} は,
1892 「IPAexフォントがインストールできない」など,IPAexフォントが使用できない場合にのみ
1893 応急処置的に用いるべきである.
1894
1895 例えば
1896 \begin{lstlisting}
1897 \def\ltj@stdmcfont{IPAMincho}
1898 \def\ltj@stdgtfont{IPAGothic}
1899 \end{lstlisting}
1900 と記述しておけば,標準和文フォントがIPA明朝・IPAゴシックへと変
1901 更される.
1902
1903
1904 なお,20140906.0以前のバージョンのように,
1905 Ryumin-Light, GothicBBB-Mediumという名前の非埋込フォントを用いる場合は
1906 \begin{lstlisting}
1907 \def\ltj@stdmcfont{psft:Ryumin-Light}
1908 \def\ltj@stdgtfont{psft:GothicBBB-Medium}
1909 \end{lstlisting}
1910 と記述すればよい.
1911 %</ja>
1912
1913
1914 %<en>\section{Changing Internal Parameters}
1915 %<ja>\section{パラメータの変更}
1916
1917 %<*en>
1918 There are many internal parameters in \LuaTeX-ja. And due to the behavior of \LuaTeX,
1919 most of them are not stored as internal register of \TeX, but as an
1920 original storage system in \LuaTeX-ja. Hence, to assign or acquire those
1921 parameters, you have to use commands \cs{ltjsetparameter} and
1922 \cs{ltjgetparameter}.
1923 %</en>
1924 %<*ja>
1925 \LuaTeX-jaには多くのパラメータが存在する.そして\LuaTeX の仕様のために,
1926 その多くは\TeX のレジスタにではなく,\LuaTeX-ja独自の方法で保持されている.
1927 これらのパラメータを設定・取得するためには \cs{ltjsetparameter} と \cs{ltjgetparameter} を
1928 用いる.
1929 %</ja>
1930
1931 %<en>\subsection{Editing the Range of \textbf{JAchar}s}
1932 %<ja>\subsection{\textbf{JAchar}の範囲の設定}
1933 \label{ssec-setrange}
1934
1935 %<*en>
1936 \LuaTeX-ja divides the Unicode codespace \texttt{U+0080}--\texttt{U+10FFFF}
1937 into \emph{character ranges},
1938 numbered 1 to 217. The grouping can be (globally) customized by \cs{ltjdefcharrange}.
1939 The next line adds whole characters in Supplementary Ideographic Plane
1940 and the character ``漢'' to the character range~100.
1941 %</en>
1942 %<*ja>
1943 \LuaTeX-jaは,Unicodeの \texttt{U+0080}--\texttt{U+10FFFF} の空間を
1944 1番から217番までの\emph{文字範囲}に分割している.
1945 区分けは \cs{ltjdefcharrange} を用いることで(グローバルに)変更することができ,
1946 例えば,次は追加漢字面(SIP)にある全ての文字と「漢」を「100番の文字範囲」に追加する.
1947 %</ja>
1948 \begin{lstlisting}
1949 \ltjdefcharrange{100}{"20000-"2FFFF,`漢}
1950 \end{lstlisting}
1951 %<*en>
1952 A character can belong to only one character range.
1953 For example, whole SIP belong to the range~4 in the default setting of \LuaTeX-ja,
1954 and if you execute the above line, then SIP will belong to the range~100 and be
1955 removed from the range~4.
1956 %</en>
1957 %<*ja>
1958 各文字はただ一つの文字範囲に所属することができる.
1959 例えば,SIPは全て\LuaTeX-jaのデフォルトでは4番の文字範囲に
1960 属しているが,上記の指定を行えばSIPは100番に属すようになり,4番からは除かれる.
1961 %</ja>
1962
1963 %<*en>
1964 The distinction between \textbf{ALchar} and \textbf{JAchar} is done for character ranges.
1965 This can be edited by setting the \textsf{jacharrange} parameter.
1966 For example, this is just the default setting of \LuaTeX-ja, and
1967 it sets
1968 \begin{itemize}
1969  \item a character which belongs character ranges 1,~4, and~5 is \textbf{ALchar},
1970  \item a character which belongs character ranges 2,~3, 6, 7, and~8 is \textbf{JAchar}.
1971 \end{itemize}
1972 %</en>
1973 %<*ja>
1974 \textbf{ALchar}と\textbf{JAchar}の区別は文字範囲ごとに行われる.
1975 これは\textsf{jacharrange}パラメータによって編集できる.
1976 例えば,以下は\LuaTeX-jaの初期設定であり,次の内容を設定している:
1977 \begin{itemize}
1978  \item 1番,4番,5番の文字範囲に属する文字は\textbf{ALchar}.
1979  \item 2番,3番,6番,7番,8番の文字範囲に属する文字は\textbf{JAchar}.
1980 \end{itemize}
1981 %</ja>
1982 \begin{lstlisting}
1983 \ltjsetparameter{jacharrange={-1, +2, +3, -4, -5, +6, +7, +8}}
1984 \end{lstlisting}
1985 %<*en>
1986 The argument to \textsf{jacharrange} parameter is a list of non-zero integer.
1987 Negative integer $-n$ in the list means that ``each character in the range~$n$ is an
1988 \textbf{ALchar}'',
1989 and positive integer $+n$ means that ``\dots\ is a \textbf{JAchar}''.
1990 %</en>
1991 %<*ja>
1992 \textsf{jacharrange}パラメータの引数は非零の整数のリストである.
1993 リスト中の負の整数$-n$は「文字範囲$n$に属する文字は\textbf{ALchar}として
1994 扱う」ことを意味し,正の整数$+n$は「\textbf{JAchar}として扱う」ことを意味する.
1995 %</ja>
1996
1997 %<*en>
1998 \paragraph{Default setting}
1999 \LuaTeX-ja predefines eight character ranges for convenience. They are
2000 determined from the following data:
2001 %</en>
2002 %<*ja>
2003 \paragraph{初期設定}
2004 \LuaTeX-jaでは8つの文字範囲を予め定義しており,
2005 これらは以下のデータに基づいて決定している.
2006 %</ja>
2007 \begin{itemize}
2008 %<en>\item Blocks in Unicode~6.0.
2009 %<ja>\item Unicode~6.0のブロック.
2010 %<en>\item The \texttt{Adobe-Japan1-UCS2} mapping between a CID Adobe-Japan1-6 and Unicode.
2011 %<ja>\item Adobe-Japan1-6のCIDとUnicodeの間の対応表\texttt{Adobe-Japan1-UCS2}.
2012 %<en>\item The \Pkg{PXbase} bundle for \upTeX\ by Takayuki Yato.
2013 %<ja>\item 八登崇之氏による\upTeX 用の\Pkg{PXbase}バンドル.
2014 \end{itemize}
2015
2016 %<*en>
2017 Now we describe these eight ranges. The superscript ``J'' or ``A'' after the
2018 number shows whether each character in the range is treated as
2019 \textbf{JAchar}s or not by default. These settings are similar to the
2020 \texttt{prefercjk} settings defined in \texttt{PXbase} bundle.
2021 Any characters above \texttt{U+0080} which does not belong to
2022 these eight ranges belongs to the character range~217.
2023 %</en>
2024 %<*ja>
2025 以下ではこれら8つの文字範囲について記述する.添字のアルファベット「J」「A」
2026 は,その文字範囲内の文字が\textbf{JAchar}か\textbf{ALchar}かを表している.これらの設定は
2027 \texttt{PXbase}バンドルで定義されている\texttt{prefercjk}と類似のものである.
2028 なお,\texttt{U+0080} 以降でこれら8つの文字範囲に属さない文字は,217番の文字範囲に属することになっている.
2029 %</ja>
2030 \begin{description}
2031 %<*en>
2032
2033 \item[Range~8${}^{\kern.1em\text{J}}$] The intersection of the upper half of ISO~8859-1
2034          (Latin-1 Supplement) and JIS~X~0208 (a basic character set for Japanese). This character range
2035          consists of the following characters:
2036 %</en>
2037 %<*ja>
2038 \item[範囲8${}^{\kern.1em\text{J}}$] ISO~8859-1の上位領域(ラテン1補助)と
2039                              JIS~X~0208の共通部分.この文字範囲は
2040                              以下の文字で構成される:
2041 %</ja>
2042 \begin{multicols}{2}
2043 \begin{itemize}
2044 \def\ch#1#2{\item \char"#1\ (\texttt{U+00#1}, #2)}%"
2045 \ch{A7}{Section Sign}
2046 \ch{A8}{Diaeresis}
2047 \ch{B0}{Degree sign}
2048 \ch{B1}{Plus-minus sign}
2049 \ch{B4}{Spacing acute}
2050 \ch{B6}{Paragraph sign}
2051 \ch{D7}{Multiplication sign}
2052 \ch{F7}{Division Sign}
2053 \end{itemize}
2054 \end{multicols}
2055
2056 %<*en>
2057 \item[Range~1${}^{\text{A}}$] Latin characters that some of them are included in Adobe-Japan1-6.
2058 This range consists of the following Unicode ranges, \emph{except characters in the range~8 above}:
2059 %</en>
2060 %<*ja>
2061 \item[範囲1${}^{\text{A}}$] ラテン文字のうち,Adobe-Japan1-6との共通部分があるもの.
2062                              この範囲は以下のUnicodeのブロックのうち
2063                              \emph{範囲8を除いた}部分で構成されている:
2064 %</ja>
2065 \begin{multicols}{2}
2066 \begin{itemize}
2067 \item \texttt{U+0080}--\texttt{U+00FF}: Latin-1 Supplement
2068 \item \texttt{U+0100}--\texttt{U+017F}: Latin Extended-A
2069 \item \texttt{U+0180}--\texttt{U+024F}: Latin Extended-B
2070 \item \texttt{U+0250}--\texttt{U+02AF}: IPA Extensions
2071 \item \texttt{U+02B0}--\texttt{U+02FF}: Spacing Modifier Letters
2072 \item \texttt{U+0300}--\texttt{U+036F}: \\\null\hfill Combining Diacritical Marks
2073 \item \texttt{U+1E00}--\texttt{U+1EFF}: \\\null\hfill Latin Extended Additional
2074 \par\
2075 \end{itemize}
2076 \end{multicols}
2077 %<*en>
2078 \item[Range~2${}^{\text{\kern.1emJ}}$] Greek and Cyrillic letters. JIS~X~0208 (hence most of Japanese
2079            fonts) has some of these characters.
2080 %</en>
2081 %<*ja>
2082 \item[範囲2${}^{\text{\kern.1emJ}}$] ギリシャ文字とキリル文字.JIS~X~0208(したがってほとんどの
2083                              和文フォント)はこれらの文字を持つ.
2084 %</ja>
2085 \begin{multicols}{2}
2086 \begin{itemize}
2087 \item \texttt{U+0370}--\texttt{U+03FF}: Greek and Coptic
2088 \item \texttt{U+0400}--\texttt{U+04FF}: Cyrillic
2089 \item \texttt{U+1F00}--\texttt{U+1FFF}: Greek Extended
2090 \\\
2091 \end{itemize}
2092 \end{multicols}
2093 %<*en>
2094 \item[Range~3${}^{\text{\kern.1emJ}}$] Punctuations and Miscellaneous symbols. The block list is
2095            indicated in Table~\ref{table-rng3}.
2096 %</en>
2097 %<*ja>
2098 \item[範囲3${}^{\text{\kern.1emJ}}$] 句読点と記号類.ブロックのリストは表\ref{table-rng3}%
2099                              に示してある.
2100 %</ja>
2101 \begin{table}[!tb]
2102 %<en>\caption{Unicode blocks in predefined character range~3.}\medskip
2103 %<ja>\caption{文字範囲3に指定されているUnicodeブロック.}
2104 \label{table-rng3}
2105 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
2106 \centering\small
2107 \begin{tabular}{llll}
2108 "2000--"206F&General Punctuation&
2109 "2070--"209F&Superscripts and Subscripts\\
2110 "20A0--"20CF&Currency Symbols&
2111 "20D0--"20FF&Comb.\ Diacritical Marks for Symbols\\
2112 "2100--"214F&Letterlike Symbols&
2113 "2150--"218F&Number Forms\\
2114 "2190--"21FF&Arrows&
2115 "2200--"22FF&Mathematical Operators\\
2116 "2300--"23FF&Miscellaneous Technical&
2117 "2400--"243F&Control Pictures\\
2118 "2500--"257F&Box Drawing&
2119 "2580--"259F&Block Elements\\
2120 "25A0--"25FF&Geometric Shapes&
2121 "2600--"26FF&Miscellaneous Symbols\\
2122 "2700--"27BF&Dingbats&
2123 "2900--"297F&Supplemental Arrows-B\\
2124 "2980--"29FF&Misc.\ Mathematical Symbols-B&
2125 "2B00--"2BFF&Miscellaneous Symbols and Arrows
2126 \end{tabular}
2127 \end{table}
2128 %<*en>
2129 \item[Range~4${}^{\text{A}}$] Characters usually not in Japanese fonts. This range consists
2130            of almost all Unicode blocks which are not in other
2131            predefined ranges. Hence, instead of showing the block list,
2132            we put the definition of this range itself:
2133 %</en>
2134 %<*ja>
2135 \item[範囲4${}^{\text{A}}$] 通常和文フォントには含まれていない文字.
2136                              この範囲は他の範囲にないほとんど全てのUnicodeブロック
2137                              で構成されている.したがって,ブロックのリストを示す
2138                              代わりに,範囲の定義そのものを示す:
2139 %</ja>
2140 \begin{lstlisting}
2141 \ltjdefcharrange{4}{%
2142    "500-"10FF, "1200-"1DFF, "2440-"245F, "27C0-"28FF, "2A00-"2AFF,
2143   "2C00-"2E7F, "4DC0-"4DFF, "A4D0-"A82F, "A840-"ABFF, "FB00-"FE0F,
2144   "FE20-"FE2F, "FE70-"FEFF, "10000-"1FFFF, "E000-"F8FF} % non-Japanese
2145 \end{lstlisting}
2146 %<en>\item[Range~5${}^{\text{A}}$] Surrogates and Supplementary Private Use Areas.
2147 %<ja>\item[範囲5${}^{\text{A}}$] 代用符号と補助私用領域.
2148 %<en>\item[Range~6${}^{\text{\kern.1emJ}}$] Characters used in Japanese. The block list is indicated in Table~\ref{table-rng6}.
2149 %<ja>\item[範囲6${}^{\text{\kern.1emJ}}$] 日本語で用いられる文字.ブロックのリストは表\ref{table-rng6}に示す.
2150 \begin{table}[!tb]
2151 %<en>\caption{Unicode blocks in predefined character range~6.}\medskip
2152 %<ja>\caption{文字範囲6に指定されているUnicodeブロック.}
2153 \label{table-rng6}
2154 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
2155 \centering\small
2156 \begin{tabular}{llll}
2157 "2460--"24FF&Enclosed Alphanumerics&
2158 "2E80--"2EFF&CJK Radicals Supplement\\
2159 "3000--"303F&CJK Symbols and Punctuation&
2160 "3040--"309F&Hiragana\\
2161 "30A0--"30FF&Katakana&
2162 "3190--"319F&Kanbun\\
2163 "31F0--"31FF&Katakana Phonetic Extensions&
2164 "3200--"32FF&Enclosed CJK Letters and Months\\
2165 "3300--"33FF&CJK Compatibility&
2166 "3400--"4DBF&CJK Unified Ideographs Extension A\\
2167 "4E00--"9FFF&CJK Unified Ideographs&
2168 "F900--"FAFF&CJK Compatibility Ideographs\\
2169 "FE10--"FE1F&Vertical Forms&
2170 "FE30--"FE4F&CJK Compatibility Forms\\
2171 "FE50--"FE6F&Small Form Variants&
2172 "{20}000--"{2F}FFF&(Supplementary Ideographic Plane)\\
2173 "{E0}100--"{E0}1EF&Variation Selectors Supplement
2174 \end{tabular}
2175 \end{table}
2176 %<*en>
2177 \item[Range~7${}^{\text{\kern.1emJ}}$] Characters used in CJK languages, but not included in  Adobe-Japan1-6.
2178 The block list is indicated in Table~\ref{table-rng7}.
2179 %</en>
2180 %<*ja>
2181 \item[範囲7${}^{\text{\kern.1emJ}}$] CJK言語で用いられる文字のうち,Adobe-Japan1-6に
2182                             含まれていないもの.
2183                             ブロックのリストは表\ref{table-rng7}に示す.
2184 %</ja>
2185 \begin{table}[!tb]
2186 %<en>\caption{Unicode blocks in predefined character range~7.}\medskip
2187 %<ja>\caption{文字範囲7に指定されているUnicodeブロック.}
2188 \label{table-rng7}
2189 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
2190 \centering\small
2191 \begin{tabular}{llll}
2192 "1100--"11FF&Hangul Jamo&
2193 "2F00--"2FDF&Kangxi Radicals\\
2194 "2FF0--"2FFF&Ideographic Description Characters&
2195 "3100--"312F&Bopomofo\\
2196 "3130--"318F&Hangul Compatibility Jamo&
2197 "31A0--"31BF&Bopomofo Extended\\
2198 "31C0--"31EF&CJK Strokes&
2199 "A000--"A48F&Yi Syllables\\
2200 "A490--"A4CF&Yi Radicals&
2201 "A830--"A83F&Common Indic Number Forms\\
2202 "AC00--"D7AF&Hangul Syllables&
2203 "D7B0--"D7FF&Hangul Jamo Extended-B
2204 \end{tabular}
2205 \end{table}
2206 \end{description}
2207
2208 %<en>\subsection{\Param{kanjiskip} and \Param{xkanjiskip}}
2209 %<ja>\subsection{\Param{kanjiskip}と\Param{xkanjiskip}}
2210 \label{subs-kskip}
2211
2212 %<en>\textbf{JAglue} is divided into the following three categories:
2213 %<ja>\textbf{JAglue}は以下の3つのカテゴリに分類される:
2214 \begin{itemize}
2215 %<*en>
2216 \item Glues/kerns specified in JFM. If \cs{inhibitglue} is issued
2217       around a \textbf{JAchar}, this glue will not be inserted at the
2218       place.
2219 %</en>
2220 %<*ja>
2221 \item JFMで指定されたグルー/カーン.もし \cs{inhibitglue} が\textbf{JAchar}の周りで
2222       発行されていれば,このグルーは挿入されない.
2223 %</ja>
2224 %<*en>
2225 \item The default glue which inserted between two \textbf{JAchar}s (\Param{%
2226       kanjiskip}).
2227 %</en>
2228 %<*ja>
2229 \item デフォルトで2つの\textbf{JAchar}の間に挿入されるグルー(\Param{kanjiskip}).
2230 %</ja>
2231 %<*en>
2232 \item The default glue which inserted between a \textbf{JAchar} and an
2233       \textbf{ALchar} (\Param{xkanjiskip}).
2234 %</en>
2235 %<*ja>
2236 \item デフォルトで\textbf{JAchar}と\textbf{ALchar}の間に挿入されるグルー(\Param{xkanjiskip}).
2237 %</ja>
2238 \end{itemize}
2239 %<*en>
2240 The value (a skip) of \Param{kanjiskip} or
2241 \Param{xkanjiskip} can be changed as the following.
2242 Note that only their values \emph{at the end of a paragraph or a hbox are
2243 adopted in the whole paragraph or the whole hbox.
2244 }
2245 %</en>
2246 %<*ja>
2247 \Param{kanjiskip}や\Param{xkanjiskip}の値
2248 は以下のようにして変更可能である.
2249 %</ja>
2250 \begin{lstlisting}
2251 \ltjsetparameter{kanjiskip={0pt plus 0.4pt minus 0.4pt},
2252                  xkanjiskip={0.25\zw plus 1pt minus 1pt}}
2253 \end{lstlisting}
2254 %<*en>
2255 Here \cs{zw} is a internal dimension
2256 which stores fullwidth of the current Japanese font.
2257 This \cs{zw} can be used as the unit \texttt{zw} in \pTeX.
2258
2259 The value of these parameter can be get by \cs{ltjgetparameter}.
2260 Note that the result by \cs{ltjgetparameter} is \emph{not} the internal quantities,
2261 but \emph{a string} (hence \cs{the} cannot be prefixed).
2262 %</en>
2263 %<*ja>
2264 ここで,\cs{zw} は現在の和文フォントの全角幅を表す長さであり,
2265 \pTeX における長さ単位 \texttt{zw} と同じように使用できる.
2266
2267 これらのパラメータの値は以下のように取得できる.
2268 戻り値は内部値ではなく\emph{文字列}である(\cs{the} は前置できない)ことに注意してほしい:
2269 %</ja>
2270 \begin{LTXexample}
2271 kanjiskip: \ltjgetparameter{kanjiskip},\\
2272 xkanjiskip: \ltjgetparameter{xkanjiskip}
2273 \end{LTXexample}
2274
2275 %<*en>
2276 It may occur that JFM contains the data of ``ideal width of
2277 \Param{kanjiskip}''
2278 and/or ``ideal width of \Param{xkanjiskip}''.
2279 To use these data from JFM, set the value of \Param{kanjiskip} or
2280 \Param{xkanjiskip} to \cs{maxdimen}
2281 (these ``ideal width'' cannot be retrived by \cs{ltjgetparameter}).
2282 %</en>
2283 %<*ja>
2284 JFMは「望ましい\Param{kanjiskip}の値」や
2285 「望ましい\Param{xkanjiskip}の値」を持っていることがある.
2286 これらのデータを使うためには,\Param{kanjiskip}や%
2287 \Param{xkanjiskip}の値を \cs{maxdimen} の値に設定すればよいが,
2288 \cs{ltjgetparameter} によって取得することはできないので注意が必要である.
2289 %</ja>
2290
2291 %<en>\subsection{Insertion Setting of \Param{xkanjiskip}}
2292 %<ja>\subsection{\Param{xkanjiskip} の挿入設定}
2293
2294 %<*en>
2295 It is not desirable that \Param{xkanjiskip} is inserted into every
2296 boundary between \textbf{JAchar}s and \textbf{ALchar}s. For example,
2297 \Param{xkanjiskip} should not be inserted after opening parenthesis
2298 (\textit{e.g.}, compare ``(あ'' and ``(\hskip\ltjgetparameter{xkanjiskip}あ'').
2299 \LuaTeX-ja can control whether \Param{xkanjiskip} can be inserted
2300 before/after a character, by changing \Param{jaxspmode} for \textbf{JAchar}s and
2301 \Param{alxspmode} parameters \textbf{ALchar}s respectively.
2302 %</en>
2303 %<*ja>
2304 \Param{xkanjiskip}がすべての\textbf{JAchar}と\textbf{ALchar}の境界に
2305 挿入されるのは望ましいことではない.例えば,\Param{xkanjiskip}は開き括弧の
2306 後には挿入されるべきではない(「(あ」と「(\hskip\ltjgetparameter{xkanjiskip}あ」を
2307 比べてみよ).
2308 \LuaTeX-jaでは\Param{xkanjiskip}をある文字の前/後に挿入するかどうかを,
2309 \textbf{JAchar}に対しては\Param{jaxspmode}を,\textbf{ALchar}に対しては
2310 \Param{alxspmode}をそれぞれ変えることで制御することができる.
2311 %</ja>
2312 \begin{LTXexample}
2313 \ltjsetparameter{jaxspmode={`あ,preonly}, alxspmode={`\!,postonly}}
2314 pあq い!う
2315 \end{LTXexample}
2316
2317 %<*en>
2318 The second argument \texttt{preonly} means that the insertion of
2319 \Param{xkanjiskip} is allowed before this character, but not after.
2320 the other possible values are \texttt{postonly}, \texttt{allow}, and \texttt{inhibit}.
2321 %</en>
2322 %<*ja>
2323 2つ目の引数の \texttt{preonly}は「\Param{xkanjiskip}の挿入はこの文字の
2324 前でのみ許され,後では許さない」ことを意味する.他に指定可能な値は
2325 \texttt{postonly}, \texttt{allow}, \texttt{inhibit}である.
2326 %</ja>
2327
2328 %<*en>
2329 \Param{jaxspmode} and \Param{alxspmode} use a same table to store the parameters
2330 on the current version. Therefore, line~1 in the code above can be rewritten
2331 as follows:
2332 %</en>
2333 %<*ja>
2334 なお,現行の
2335 仕様では,\Param{jaxspmode}, \Param{alxspmode}はテーブルを共有しており,
2336 上のコードの1行目を次のように変えても同じことになる:
2337 %</ja>
2338 \begin{lstlisting}
2339 \ltjsetparameter{alxspmode={`あ,preonly}, jaxspmode={`\!,postonly}}
2340 \end{lstlisting}
2341 %<*en>
2342 One can use also numbers to specify these two parameters (see Subsection~\ref{ssec-param}).
2343 %</en>
2344 %<*ja>
2345 また,これら2パラメータには数値で値を指定することもできる(\ref{ssec-param}節を参照).
2346 %</ja>
2347
2348 %<*en>
2349 If you want to enable/disable all insertions of \Param{kanjiskip} and
2350 \Param{xkanjiskip}, set \Param{autospacing} and \Param{autoxspacing}
2351 parameters to \texttt{true}/\texttt{false}, respectively.
2352 %</en>
2353 %<*ja>
2354 もし全ての\Param{kanjiskip}と\Param{xkanjiskip}の挿入を有効化/無効化
2355 したければ,それぞれ\Param{autospacing}と\Param{autoxspacing}を
2356 \texttt{true}/\texttt{false}に設定すればよい.
2357 %</ja>
2358
2359 %<en>\subsection{Shifting the baseline}
2360 %<ja>\subsection{ベースラインの移動}
2361 %<*en>
2362 To make a match between a Japanese font and an alphabetic font, sometimes
2363 shifting of the baseline of one of the pair is needed. In \pTeX, this is achieved
2364 by setting \cs{ybaselineshift} (or \cs{tbaselineshift}) to a non-zero length (the
2365 baseline of \textbf{ALchar} is shifted below). However, for documents
2366 whose main language is not Japanese, it is good to shift the baseline of
2367 Japanese fonts, but not that of alphabetic fonts.
2368 Because of this, \LuaTeX-ja can independently set the shifting amount
2369 of the baseline of alphabetic fonts and that of Japanese fonts.
2370 \begin{center}
2371  \small
2372 \begin{tabular}{>{\bfseries}lcc}
2373 \toprule
2374 &\bfseries Horizontal writing (\emph{yoko} direction) etc.
2375 &\bfseries Vertical writing(\emph{tate} direction)\\
2376 \midrule
2377 Alphabetic fonts&\Param{yalbaselineshift}
2378      parameter&\Param{talbaselineshift} parameter\\
2379 Japanese fonts&\Param{yjabaselineshift}
2380      parameter&\Param{tjabaselineshift} parameter\\
2381 \bottomrule
2382 \end{tabular}
2383 \end{center}
2384 %</en>
2385 %<*ja>
2386 和文フォントと欧文フォントを合わせるためには,時々どちらかのベースラインの移動が
2387 必要になる.\pTeX ではこれは \cs{ybaselineshift}(または\cs{tbaselineshift})を設定することで
2388 なされていた(\textbf{ALchar}のベースラインがその分だけ下がる).しかし,日本語が主ではない
2389 文書に対しては,欧文フォントではなく和文フォントのベースラインを移動した方がよい.
2390 このため,\LuaTeX-jaでは欧文フォントのベースラインのシフト量
2391 と和文フォントのベースラインのシフト量を独立に設定できるようになっている.
2392 \begin{center}
2393  \small
2394 \begin{tabular}{>{\bfseries}lcc}
2395 \toprule
2396 &\bfseries 横組など&\bfseries 縦組\\
2397 \midrule
2398 欧文フォントのシフト量&\Param{yalbaselineshift}
2399      parameter&\Param{talbaselineshift} parameter\\
2400 和文フォントのシフト量&\Param{yjabaselineshift}
2401      parameter&\Param{tjabaselineshift} parameter\\
2402 \bottomrule
2403 \end{tabular}
2404 \end{center}
2405 %</ja>
2406
2407 %<*en>
2408 Here the horizontal line in the below example is the baseline of a line.
2409 %</en>
2410 %<*ja>
2411 下の例において引かれている水平線がベースラインである.
2412 %</ja>
2413 \begin{LTXexample}
2414 \vrule width 150pt height 0.4pt depth 0pt \hskip-120pt
2415 \ltjsetparameter{yjabaselineshift=0pt, yalbaselineshift=0pt}abcあいう
2416 \ltjsetparameter{yjabaselineshift=5pt, yalbaselineshift=2pt}abcあいう
2417 \end{LTXexample}
2418
2419 %<*en>
2420 There is an interesting side-effect: characters in different size can be
2421 vertically aligned center in a line, by setting two parameters appropriately.
2422 The following is an example (beware the value is not well tuned):
2423 %</en>
2424 %<*ja>
2425 この機能には面白い使い方がある:2つのパラメータを適切に設定することで,サイズの
2426 異なる文字を中心線に揃えることができる.
2427 以下は一つの例である(値はあまり調整されていないことに注意):
2428 %</ja>
2429 \begin{LTXexample}
2430 xyz漢字
2431 {\scriptsize
2432   \ltjsetparameter{yjabaselineshift=-1pt,
2433     yalbaselineshift=-1pt}
2434   XYZひらがな
2435 }abcかな
2436 \end{LTXexample}
2437
2438 %<*en>
2439 Note that setting positive \Param{yalbaselineshift}~or~\Param{talbaselineshift}
2440 parameters does not increase the depth of one-letter \emph{syllable} $p$ of \textbf{Alchar}, if
2441 its left-protrusion~(\cs{lpcode}) and right-protrusion~(\cs{rpcode}) are both non-zero.
2442 This is because
2443 \begin{itemize}
2444 \item These two parameters are implemented by setting \texttt{yoffset} field of a
2445 glyph node, and this does not increase the depth of the glyph.
2446 \item To cope with the above situation, \LuaTeX-ja automatically supplies
2447 a rule in every syllable.
2448 \item However, we cannot use this ``supplying a rule'' method if a syllable comprises just
2449       one letter whose \cs{lpcode}~and~\cs{rpcode} are both non-zero.
2450 \end{itemize}
2451
2452 This problem does not apply for \Param{yjabaselineshift}~nor~\Param{tjabaselineshift},
2453 becuse a \emph{JAchar} is encapsulated by a horizontal box if needed.
2454 %</en>
2455 %<*ja>
2456 なお,以下の場合には1文字の\textbf{ALchar}からなる「音節」の深さは増加しないことに注意.
2457 \begin{itemize}
2458  \item \Param{yalbaselineshift},~\Param{talbaselineshift}パラメータが正になっている.
2459  \item 「音節」を構成する唯一の文字$p$の
2460 左余白への突出量(\cs{lpcode}),右余白への突出量(\cs{rpcode})がどちらも非零である.
2461 \end{itemize}
2462 \emph{JAchar}は必要に応じて1文字ずつボックスにカプセル化されるため,
2463 \Param{yjabaselineshift},~\Param{tjabaselineshift}パラメータについてはこのような問題は起こらない.
2464 %</ja>
2465
2466 %<*ja>
2467 \paragraph{数式における挙動:\pTeX との違い}
2468 \textbf{ALchar}のベースラインを補正する \Param{yalbaselineshift} パラメータは
2469 ほぼ\pTeX における \cs{ybaselineshift} に対応しているものであるが,
2470 数式中の挙動は異なっているので注意が必要である.
2471 例えば,表\ref{tab:math_bsa}のように,数式中に明示的に現れた \cs{hbox} は,
2472 \begin{itemize}
2473  \item \pTeX では,ボックス全体が \cs{ybaselineshift} だとシフトされるので,
2474  表\ref{tab:math_bsa}中の``い''のように,ボックス中の和文文字は
2475  \ \cs{ybaselineshift} だけシフトされ,一方,``for all''のように,
2476  ボックス内の欧文文字は2重にシフトされることになる.
2477  \item 一方,\LuaTeX-jaではそのようなことはおこらず,
2478  数式中に明示的に現れた \cs{hbox} はシフトしない.そのため,
2479  表\ref{tab:math_bsa}中の``い''も``for all''も,それぞれ本文中に
2480  書かれたときと同じ上下位置に組まれる.
2481 \end{itemize}
2482 \begin{table}
2483 \small\centering
2484 \caption{数式関係のベースライン補正($\Param{yalbaselineshift}=10\,\textrm{pt}$)}
2485 \label{tab:math_bsa}
2486 \newdimen\origbaselineskip
2487 \origbaselineskip=\baselineskip
2488 \begin{tabular}{lp{30\zw}}
2489 \toprule
2490 \emph{入力}&\vspace*{\dimexpr-\origbaselineskip-\smallskipamount}
2491 \begin{lstlisting}
2492 数式abc: $あa\hbox{い}$, $\int_0^x t\,dt=x^2\!/2$,
2493 $\Phi\vdash F(x)\ \hbox{for all}\ x\in A$
2494 \end{lstlisting}\\
2495 \noalign{\vskip-\origbaselineskip}
2496 \midrule
2497 \emph{\pTeX}&
2498 {\ltjsetparameter{yalbaselineshift=10pt}%
2499 数式abc: $あa\lower10pt\hbox{い}$, $\int_0^x t\,dt=x^2\!/2$,
2500 $\Phi\vdash F(x)\ \lower10pt\hbox{for all}\ x\in A$
2501 \par}\\
2502 \midrule
2503 \emph{\LuaTeX-ja}&
2504 {\ltjsetparameter{yalbaselineshift=10pt}%
2505 数式abc: $あa\hbox{い}$, $\int_0^x t\,dt=x^2\!/2$,
2506 $\Phi\vdash F(x)\ \hbox{for all}\ x\in A$
2507 \par}\\
2508 \noalign{\vskip-\origbaselineskip}
2509 \bottomrule
2510 \end{tabular}
2511 \end{table}
2512 %</ja>
2513
2514 %<*en>
2515 \subsection{\emph{kinsoku} parameters and OpenType features}
2516 Among parameters which related to Japanese word-wrapping process (\emph{kinsoku shori}),
2517 \begin{quote}
2518  \Param{jaxspmode},~\Param{alxspmode}, \Param{prebreakpenalty},
2519  \Param{postbreakpenalty}~and~\Param{kcatcode}
2520 \end{quote}
2521 are stored by each character codes. ...
2522
2523 For example, a fullwidth katakana ``ア'' on line~10 in the below input is replaced to
2524 its halfwidth variant ``ア'', by \verb+hwid+ feature.
2525 However, the penalty inserted after it is 10 which is the \Param{postbreakpenalty} of
2526 ``ア'', not 20.
2527 %</en>
2528 %<*ja>
2529 \subsection{禁則処理関連パラメータとfont feature}
2530 禁則処理や \Param{kanjiskip}, \Param{xkanjiskip} の挿入に関連したパラメータのうち
2531 \begin{quote}
2532  \Param{jaxspmode},~\Param{alxspmode}, \Param{prebreakpenalty},
2533  \Param{postbreakpenalty}, \Param{kcatcode}
2534 \end{quote}
2535 は,文字コードごとに設定する量である.
2536
2537 \Pkg{fontspec}パッケージを使う(\ref{ssec-fontspec}節)場合など,
2538 各種のOpenType featureを適用することもあると思うが,前段落に述べたパラメータ類は,
2539 \emph{OpenType featureの適用前の文字コードによって判定される.}
2540 例えば,以下の例において10行目の「ア」は,\verb+hwid+ featureの適用により半角カタカナの「ア」
2541 に置き換わる.しかし,その直後に挿入される \Param{postbreakpenalty}は,置換前の「ア」に対する値10である.
2542 %</ja>
2543
2544 \begin{LTXexample}[width=0.2\textwidth]
2545 \ltjsetparameter{postbreakpenalty={`ア, 10}}
2546 \ltjsetparameter{postbreakpenalty={`ア, 20}}
2547
2548 \newcommand\showpostpena[1]{%
2549   \leavevmode\setbox0=\hbox{#1\hbox{}}%
2550   \unhbox0\setbox0=\lastbox\the\lastpenalty}
2551
2552 \showpostpena{ア},
2553 \showpostpena{ア},
2554 {\addjfontfeatures{CharacterWidth=Half}\showpostpena{ア}}
2555 \end{LTXexample}
2556
2557 \clearpage
2558 %<en>\part{Reference}
2559 %<ja>\part{リファレンス}
2560 \label{part-ref}
2561 \suppressfloats[t]
2562 %<*ja>
2563 \section{\LuaTeX-jaにおける \cs{catcode}}
2564 \label{sec-catcode}
2565 \subsection{予備知識:\pTeX と\upTeX における \cs{kcatcode}}
2566 \pTeX,\upTeX においては,和文文字が制御綴内で利用できるかどうか
2567 は \cs{kcatcode} の値によって決定されるのであった.
2568 詳細は表\ref{table-kcat}を参照されたい.
2569 %</ja>
2570 %<*en>
2571 \section{\cs{catcode} in \LuaTeX-ja}
2572 \label{sec-catcode}
2573 \subsection{Preliminaries: \cs{kcatcode} in \pTeX\ and \upTeX}
2574 In \pTeX~and~\upTeX, the value of \cs{kcatcode} determines
2575 whether a Japanese character can be used in a control word.
2576 For the detail, see Table~\ref{table-kcat}.
2577 %</en>
2578
2579 \begin{table}[t]
2580 \small
2581 \caption{\cs{kcatcode} in \upTeX}
2582 \label{table-kcat}
2583 %<en>\medskip
2584
2585 \noindent\hfill
2586 \begin{tabular}{ccccc}
2587 \toprule
2588 \bfseries \cs{kcatcode}&
2589 %<*en>
2590 \bfseries meaning&
2591 \bfseries control word&
2592 \bfseries widow penalty\hbox{}$^*$&
2593 \bfseries linebreak\\
2594 %</en>
2595 %<*ja>
2596 \bfseries 意図&
2597 \bfseries 制御綴中に使用&
2598 \bfseries 文字ウィドウ処理\hbox{}$^*$&
2599 \bfseries 直後での改行\\
2600 %</ja>
2601 \midrule
2602 15&non-cjk&\multicolumn{3}{c}{(treated as usual \LaTeX)}\\
2603 16&kanji&Y&Y&ignored\\
2604 17&kana&Y&Y&ignored\\
2605 18&other&N&N&ignored\\
2606 19&hangul&Y&Y&space\\
2607 \bottomrule
2608 \end{tabular}\hfill\null
2609
2610 \medskip
2611
2612 %<*ja>
2613 文字ウィドウ処理\hbox{}$^*$: 「漢字が一文字だけ次の行に行くのを防ぐ」\
2614 \cs{jcharwidowpenalty} が,
2615 その文字の直前に挿入されうるか否か,を示す.
2616 %</ja>
2617 \end{table}
2618
2619 %<*en>
2620 \cs{kcatcode} can be set by a row of JIS~X~0208 in \pTeX,
2621 and generally by a Unicode block\footnote{%
2622   \upTeX\ divides \texttt{U+FF00}--\texttt{U+FFEF} (Halfwidth and Fullwidth Forms)
2623   into three subblocks, and \cs{kcatcode} can be set by a subblock.
2624 }
2625 in \upTeX. So characters which can be used in a control word
2626 slightly differ between \pTeX~and~\upTeX.
2627 %</en>
2628 %<*ja>
2629 \pTeX では \cs{kcatcode} はJIS~X~0208の区単位,
2630 \upTeX では概ねUnicodeブロック単位\footnote{%
2631   \texttt{U+FF00}--\texttt{U+FFEF} (Halfwidth and Fullwidth Forms)は
2632   「全角英数字」「半角カナ」「その他」と3つに分割されており,
2633   それぞれ別々に \cs{kcatcode} が指定できるようになっている.
2634 }で設定可能になっている.そのため,\pTeX と\upTeX の初期状態では
2635 制御綴内で使用可能な文字が微妙に異なっている.
2636 %</ja>
2637
2638 %<*en>
2639 \subsection{Case of \LuaTeX-ja}
2640 The role of \cs{kcatcode} in \pTeX~and~\upTeX\ can be
2641 divided into the following four kinds,
2642 and \LuaTeX-ja can control these four kinds separately:
2643 \begin{itemize}
2644  \item
2645 \emph{Distinction between \textbf{JAchar} or \textbf{ALchar}}
2646 is controlled by the character range, see Subsection~\ref{ssec-setrange}.
2647  \item
2648 \emph{Whether the character can be used in a control word}
2649 is controlled by setting \cs{catcode} to 11~(enabled) or 12~(disabled), as usual.
2650  \item
2651 \emph{Whether \Param{jcharwidowpenalty} can be inserted before the character}
2652 is controlled by the lowermost bit of the \Param{kcatcode} parameter.
2653  \item
2654 \emph{Linebreak after a \textbf{JAchar}} does not produce a space.
2655 \end{itemize}
2656 %</en>
2657 %<*ja>
2658 \subsection{\LuaTeX-jaの場合}
2659 \LuaTeX-jaでは,従来の\pTeX・\upTeX における \cs{kcatcode} の役割を
2660 分割している:
2661 \begin{description}
2662  \item[欧文/和文の区別 (\upTeX)]
2663 \cs{ltjdefcharrange} と\textsf{jacharrange}パラメータ(\ref{ssec-setrange}節)
2664  \item[制御綴中に使用可か]
2665 \LuaTeX 自身の \cs{catcode} でよい
2666  \item[\Param{jcharwidowpenalty}が挿入可か]
2667 \Param{kcatcode}パラメータの最下位ビット
2668  \item[直後の改行]
2669 日本語しか想定していないので,\textbf{JAchar}直後の改行で半角スペースが挿入されることはない.
2670 \end{description}
2671 %</ja>
2672
2673 %<*en>
2674 Default setting of \cs{catcode} of Unicode characters are located in
2675 \begin{description}
2676  \item[plain \LuaTeX] \texttt{luatex-unicode-letters.tex}, which is based on \texttt{unicode-letters.tex}
2677 (for \XeTeX).
2678  \item[\LuaLaTeX] now included in \LaTeX\ kernel  as~\texttt{unicode-letters.def}.
2679 \end{description}
2680 However, the default setting of \cs{catcode} differs
2681 between \XeTeX\ and \LuaTeX, by the following reasons:
2682 \begin{itemize}
2683  \item (plain format) \texttt{luatex-unicode-letters.tex} is based on old \texttt{unicode-letters.tex}.
2684  \item The latter half of \texttt{unicode-letters.tex}~and~\texttt{unicode-letters.def}
2685 sets\cs{catcode} of Kanji and kana characters to 11, via setting \cs{XeTeXcharclass}.
2686
2687 However, this latter half does not exist (plain case), or not executed (\LaTeX~case) in \LuaTeX, hence
2688 \cs{catcode} of Kanji and kana characters remains 12 in \LuaTeX.
2689 \end{itemize}
2690 In other words, Kanji nor kana characters cannot be used in
2691 a control word, in the default setting of \LuaTeX.
2692
2693 This would be inconvenient for \pTeX~users to shifting to \LuaTeX-ja,
2694 since several control words containing Kanji, such as \verb+\西暦+,
2695 are used in \pTeX.
2696 Hence, \LuaTeX-ja have a counterpart of \texttt{unicode-letters.tex}
2697 for \LuaTeX, \emph{to match the \cs{catcode} setting with that of \XeTeX.}
2698 %</en>
2699 %<*ja>
2700 ネイティブにUnicode全部の文字を扱える\XeTeX や\LuaTeX では,
2701 文字が制御綴内で使用できるかは通常の欧文文字と同じく \cs{catcode}
2702 で指定することとなる.plain \XeTeX における \cs{catcode} の初期設定は\
2703 \texttt{unicode-letters.tex} 中に記述されており,plain \LuaTeX ではそれを
2704 元にした \texttt{luatex-unicode-letters.tex} を用いている.
2705 \LaTeX では \cs{catcode} の設定はカーネルに \texttt{unicode-letters.def} として統合され.
2706 このファイルを\XeLaTeX, \LuaLaTeX の両方が用いている.
2707
2708
2709 だが,\XeTeX における \cs{catcode} の初期設定と
2710 \LuaTeX におけるそれは一致していない:
2711 \begin{itemize}
2712  \item \texttt{luatex-unicode-letters.tex} の元になった\
2713 \texttt{unicode-letters.tex} が古い
2714  \item \texttt{unicode-letters.tex} 後半部や \texttt{unicode-letters.def} 後半部では
2715 \cs{XeTeXcharclass} の設定を行なっており,
2716 それによって漢字や仮名の \cs{catcode} が11に設定されている.
2717
2718 しかし,\texttt{luatex-unicode-letters.tex} ではこの「後半部」が
2719 まるごと省略されており,また\LuaLaTeX でも \texttt{unicode-letters.def} 後半部は実行されな
2720        い.従って漢字や仮名の \cs{catcode} は12のままになっている.
2721 \end{itemize}
2722 言い換えると,\LuaTeX の初期状態では漢字や仮名を制御綴内に
2723 使用することはできない.
2724
2725 これでは \pTeX で使用できた \verb+\西暦+ などが使えないこととなり,
2726 \LuaTeX-jaへの移行で手間が生じる.そのため,\LuaTeX-jaでは
2727 \texttt{unicode-letters.tex} の後半部にあたる内容を自前でパッチし,
2728 結果として\textbf{\XeTeX における初期設定と同じになるようにしている.}
2729 %</ja>
2730
2731 \begin{table}
2732  \centering\small
2733 %<en>\caption{Difference of the set of non-kanji JIS~X~0208 characters which can be used in a control word}
2734 %<ja>\caption{制御綴中に使用出来るJIS~X~0208非漢字の違い}
2735 %<en>\medskip
2736 \label{table-kcat-diff}
2737 \def\D#1#2#3#4{%
2738   {\fboxsep0pt\fcolorbox{cyan}{white}%
2739   {\large\char"#1#2#3#4}}\ (\texttt{U+#1#2#3#4})} %"
2740 \leavevmode\hbox to 0pt{\hss\begin{tabular}{cccccc}
2741 \toprule
2742 %<en>&\bf row&\bf col.&\bf \pTeX&\bf \upTeX&\bf\LuaTeX-ja\\
2743 %<ja>&\bf 区&\bf 点&\bf \pTeX&\bf \upTeX&\fontseries{b}\selectfont\LuaTeX-ja\\
2744 \midrule
2745 %\D 3000&1&1&N&N&Y\\
2746 \D 30FB&1&6&N&Y&N\\
2747 \D 309B&1&11&N&Y&N\\
2748 \D 309C&1&12&N&Y&N\\
2749 \D FF40&1&14&N&N&Y\\
2750 \D FF3E&1&16&N&N&Y\\
2751 \D FFE3&1&17&N&N&Y\\
2752 \D FF3F&1&18&N&N&Y\\
2753 %\D 30FD&1&19&N&Y&Y\\
2754 %\D 30FE&1&20&N&Y&Y\\
2755 %\D 309D&1&21&N&Y&Y\\
2756 %\D 309E&1&22&N&Y&Y\\
2757 \D 3003&1&23&N&N&Y\\
2758 \D 4EDD&1&24&N&Y&Y\\
2759 \D 3005&1&25&N&N&Y\\
2760 \D 3006&1&26&N&N&Y\\
2761 \D 3007&1&27&N&N&Y\\
2762 \D 30FC&1&28&N&Y&Y\\
2763 \D FF0F&1&31&N&N&Y\\
2764 \D FF3C&1&32&N&N&Y\\
2765 \bottomrule
2766 \end{tabular}\qquad
2767 \begin{tabular}{cccccc}
2768 \toprule
2769 %<en>&\bf row&\bf col.&\bf \pTeX&\bf \upTeX&\bf\LuaTeX-ja\\
2770 %<ja>&\bf 区&\bf 点&\bf \pTeX&\bf \upTeX&\fontseries{b}\selectfont\LuaTeX-ja\\
2771 \midrule
2772 \D FF5C&1&35&N&N&Y\\
2773 \D FF0B&1&60&N&N&Y\\
2774 \D FF1D&1&65&N&N&Y\\
2775 \D FF1C&1&67&N&N&Y\\
2776 \D FF1E&1&68&N&N&Y\\
2777 \D FF03&1&84&N&N&Y\\
2778 \D FF06&1&85&N&N&Y\\
2779 \D FF0A&1&86&N&N&Y\\
2780 \D FF20&1&87&N&N&Y\\
2781 \D 3012&2&9&N&N&Y\\
2782 \D 3013&2&14&N&N&Y\\
2783 \D FFE2&2&44&N&N&Y\\
2784 \D 212B&2&82&N&N&Y\\
2785 %<en>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}Greek letters (row 6)}&Y&N&Y\\
2786 %<en>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}Cyrillic letters (row 7)}&N&N&Y\\
2787 %<ja>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}ギリシャ文字(6区)}&Y&N&Y\\
2788 %<ja>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}キリル文字(7区)}&N&N&Y\\
2789 \bottomrule
2790 \end{tabular}\hss}\par
2791 \end{table}
2792
2793 %<*en>
2794 \subsection{Non-kanji Characters in a Control Word}
2795 Because the engine differ, so non-kanji JIS~X~0208 characters
2796 which can be used in a control word differ in \pTeX, in \upTeX,~and~in \LuaTeX-ja.
2797 Table~\ref{table-kcat-diff} shows the difference.
2798 Except for four characters ``・'',~``゛'', ``゜'',~``゠'',
2799 \LuaTeX-ja admits more characters in a control word than \upTeX.
2800
2801 Difference becomes larger, if we consider
2802 non-kanji JIS~X~0213 characters.
2803 For the detail, see \url{https://github.com/h-kitagawa/kct}.
2804 %</en>
2805 %<*ja>
2806 \subsection{制御綴中に使用出来るJIS非漢字の違い}
2807
2808 エンジンが異なるので,\pTeX, \upTeX, \LuaTeX-ja
2809 において制御綴中に使用可能なJIS~X~0208の文字は異なる.
2810 異なっているところだけを載せると,表\ref{table-kcat-diff}のようになる.
2811 「・」「゛」「゜」「゠」を除けば,\LuaTeX-jaでは\upTeX より多くの文字が
2812 制御綴に使用可能になっている.
2813
2814 JIS~X~0213の範囲に広げると,差異はさらに大きくなる.
2815 詳細については例えば \url{https://github.com/h-kitagawa/kct} 中の\
2816 \texttt{kct-out.pdf} などを参照すること.
2817 %</ja>
2818
2819
2820 %<*en>
2821 \section{Directions}
2822 \LuaTeX\ supports four $\Omega$-style directions: \texttt{TLT},~\texttt{TRT}, \texttt{RTT}
2823 and \texttt{LTL}.
2824 However, neither directions are not well-suited for typesetting Japanese vertically, hence we
2825 implemented vertical writing by rotating \texttt{TLT}-box by 90~degrees.
2826 %</en>
2827 %<*ja>
2828 \section{縦組}
2829 \label{sec-direction}
2830 \LuaTeX 本体でも,$\Omega$・$\aleph$由来の機能として,複数の組方向をサポートしている.
2831 しかし,\LuaTeX がサポートするのは \texttt{TLT},~\texttt{TRT}, \texttt{RTT},~\texttt{LTL}\
2832 のみであり,日本語の縦組に使うのは望ましくない\footnote{%
2833 和文文字だけならば \texttt{RTT} を使えばなんとかなると思うが,
2834 欧文文字が入ってきた場合はうまくいかず,\texttt{RTR} という組方向が必要になる.
2835 }.そのため,\LuaTeX-jaでは横組(\texttt{TLT})で組んだボックスを回転させる方式で
2836 縦組を実装した.
2837 %</ja>
2838
2839 %<ja>\subsection{サポートする組方向}
2840 \begin{table}[t]
2841 %<ja>\caption{\LuaTeX-ja のサポートする組方向}
2842 %<en>\caption{Directions supported by \LuaTeX-ja}
2843 %<en>\medskip
2844 \label{tab-dir}
2845 \centering\small
2846 \def\obox#1{%
2847   \setbox0=\hbox{\yoko\hbox{#1%
2848   \large\ltjsetparameter{talbaselineshift=0pt}%
2849   \vrule height 25pt width 0.4pt depth 15pt\kern-.2pt%
2850   \raise25pt\hbox to 0pt{\hss\composite{*r^@{>>}}\hss}%
2851   \raise-15pt\hbox to 0pt{\hss\composite{*l^@{>|}}\hss}\kern.2pt%
2852   \vrule height.2pt depth.2pt width 60pt\hbox to 0pt{\hss\composite{*d^@{>}}\hss}\kern-60pt
2853   \hbox to 60pt{\,銀は、Ag\hss}}}%
2854   \raise\dimexpr 0.5\ltjgetdp0-0.5\ltjgetht0\box0%
2855 }
2856 %<*ja>
2857 \begin{tabular}{>{\bfseries}lcccc}
2858 \toprule
2859 &横組&縦組 &「dtou方向」&「utod方向」\\
2860 \midrule
2861 命令&\cs{yoko}&\cs{tate}&\cs{dtou}&\cs{utod}\\
2862 字送り方向&水平右向き(→)&垂直下向き(↓)&垂直上向き(↑)&垂直下向き(↓)\\
2863 行送り方向&垂直下向き(↓)&水平左向き(←)&水平右向き(→)&水平左向き(←)\\
2864 使用する和文フォント&横組用(\cs{jfont})&縦組用(\cs{tfont})&
2865 \multicolumn{2}{c}{%
2866   横組用(\cs{jfont})の$90^\circ$回転}\\[\smallskipamount]
2867 組版例\null $^*$ &\obox{\yoko}&\obox{\tate}&\obox{\dtou}&\obox{\utod}\\
2868 \noalign{\medskip}
2869 \bottomrule
2870 \end{tabular}
2871
2872 \medskip\raggedright
2873 \def\R#1{%
2874   \raise0.38\zw\hbox{%
2875     \vrule height.2pt  depth.2pt width2\zw%
2876     \hbox to 0pt{\hss\composite{*d^@{#1}}\hss}%
2877   }%
2878 }
2879 $^*$\ 幅(width),高さ(height),深さ(depth)の増加方向を,
2880 それぞれ「\R{>}」,「\R{>>}」,「\R{>|}」で表している.
2881 \raggedright
2882 %</ja>
2883
2884 %<*en>
2885 \begin{tabular}{>{\bfseries}lcccc}
2886 \toprule
2887 &horizontal (\emph{yoko}~direction)&vertical (\emph{tate}~direction)&%
2888   \emph{dtou} direction&\emph{utod} direction\\
2889 \midrule
2890 Commands&\cs{yoko}&\cs{tate}&\cs{dtou}&\cs{utod}\\
2891 Beginning of the page&Top&Right&Left&Right\\
2892 Beginning of the line&Left&Top&Bottom&Top\\
2893 Used Japanese font&horizontal (\cs{jfont})&vertical (\cs{tfont})&
2894 \multicolumn{2}{c}{%
2895   horizontal ($90^\circ$ rotated)}\\[\smallskipamount]
2896 Example&\obox{\yoko}&\obox{\tate}&\obox{\dtou}&\obox{\utod}\\
2897 \noalign{\medskip}
2898 (Notation used in $\Omega$)&TLT&RTR, RTT&LBL&RTR\\
2899 \bottomrule
2900 \end{tabular}
2901
2902 \medskip\raggedright
2903 \def\R#1{%
2904   \raise0.38\zw\hbox{%
2905     \vrule height.2pt  depth.2pt width2\zw%
2906     \hbox to 0pt{\hss\composite{*d^@{#1}}\hss}%
2907   }%
2908 }
2909 \raggedright
2910 %</en>
2911 \end{table}
2912
2913 %<*en>
2914 \LuaTeX-ja supports four directions, as shown in Table~\ref{tab-dir}.
2915 The second column (\emph{yoko} direction) is just horizontal writing,
2916 and the third column (\emph{tate} direction) is vertical writing.
2917 The fourth column (\emph{dtou} direction) is actually a hidden feature of \pTeX.
2918 We implemented this for debugging purpose.
2919 The fifth column (\emph{utod} direction) corresponds the ``\texttt{tate (math) direction}'' of \pTeX.
2920
2921 Directions can be changed by \cs{yoko},~\cs{tate}, \cs{dtou},~\cs{utod},
2922 only when the current list is null. Also, the direction of a math formula is changed to
2923 \emph{utod}, when the direction outside the math formula is \emph{tate} (vertical writing).
2924 %</en>
2925
2926 %<*ja>
2927 \LuaTeX-jaがサポートする組方向は表\ref{tab-dir}に示す4つである.
2928 4列目の \cs{dtou} は聞き慣れない命令だと思うが,
2929 実は\pTeX に同名の命令が(ドキュメントには書かれていないが)存在する.
2930 Down-TO-Upの意味なのだろう.\cs{dtou} を使用する機会はないだろうが,
2931 \LuaTeX-jaではデバッグ用に実装している.
2932 5列目の \cs{utod} は,\pTeX で言う「縦数式ディレクション」に相当するものである.
2933
2934 組方向は,\cs{yoko},~\cs{tate}, \cs{dtou},~\cs{utod} をそれぞれ使用することで,
2935 現在作成中のリストやボックスが空の時にのみ変更可能である.
2936 また,縦組中の数式内のボックスは\pTeX と同じように組方向が \cs{utod} となる.
2937 %</ja>
2938
2939 %<*en>
2940 \subsection{Boxes in different direction}
2941
2942 As in \pTeX, one can use boxes of different direction in one document.
2943 The below is an example.
2944 \begin{LTXexample}
2945 ここは横組%     yoko
2946 \hbox{\tate %   tate
2947   \hbox{縦組}%  tate
2948   の中に
2949   \hbox{\yoko 横組の内容}% yoko
2950   を挿入する
2951 }
2952 また横組に戻る% yoko
2953 \end{LTXexample}
2954
2955 Table~\ref{tab-diffdir} shows how a box is arranged when
2956 the direction  inside the box and that outside the box differ.
2957 %</en>
2958 %<*ja>
2959 \subsection{異方向のボックス}
2960
2961 縦組の中に「42」などの2桁以上の算用数字を横組で組むなど,
2962 異なる組方向を混在させることがしばしば行われる.
2963 組方向の混在も\pTeX と同じようにできる:
2964 \begin{LTXexample}
2965 ここは横組%     yoko
2966 \hbox{\tate %   tate
2967   \hbox{縦組}%  tate
2968   の中に
2969   \hbox{\yoko 横組の内容}% yoko
2970   を挿入する
2971 }
2972 また横組に戻る% yoko
2973 \end{LTXexample}
2974
2975 異なる組方向のボックスを配置した場合にどう組まれるかの仕様も,\pTeX を
2976 踏襲している.表\ref{tab-diffdir}に示す.
2977 %</ja>
2978
2979 \begin{table}[t]
2980 %<ja>\caption{異方向のボックスの配置}
2981 %<en>\caption{Boxes in different direction}
2982 %<en>\medskip
2983 \label{tab-diffdir}
2984  \centering\small\unitlength3mm
2985  \def\TATEeg{%
2986    \hbox{\smash{\begin{picture}(0,0)(-2,0)
2987      \thicklines
2988      \polyline(-2,0)(-2,-7)(5,-7)(5,0)
2989      \put(0,0){\circle*{0.3}}
2990      \put(2.5,-4){\makebox(0,0){\hbox{\tate\bfseries \emph{tate}/\emph{utod}}}}
2991      \put(0,0){\vector(1,0){5}} \put(2.5,-0.2){\makebox(0,0)[t]{$h_{\mathrm{T}}$}}
2992      \put(0,0){\vector(-1,0){2}}\put(-1,-0.2){\makebox(0,0)[t]{$d_{\mathrm{T}}$}}
2993      \put(0,0){\vector(0,-1){7}}\put(0.2,-3.5){\makebox(0,0)[l]{$w_{\mathrm{T}}$}}
2994    \end{picture}}}
2995  }
2996  \def\DTOUeg{%
2997    \hbox{\smash{\begin{picture}(0,0)(-5,0)
2998      \thicklines
2999      \polyline(-5,0)(-5,7)(2,7)(2,0)
3000      \put(0,0){\circle*{0.3}}
3001      \put(-2.5,4){\makebox(0,0){\hbox{\dtou\bfseries \emph{dtou}}}}
3002      \put(0,0){\vector(-1,0){5}} \put(-2.5,0.3){\makebox(0,0)[b]{$h_{\mathrm{D}}$}}
3003      \put(0,0){\vector(1,0){2}}\put(1,0.3){\makebox(0,0)[b]{$d_{\mathrm{D}}$}}
3004      \put(0,0){\vector(0,1){7}}\put(-0.2,3.5){\makebox(0,0)[r]{$w_{\mathrm{D}}$}}
3005    \end{picture}}}
3006  }
3007  \def\YOKOeg{%
3008    \hbox{\smash{\begin{picture}(0,0)
3009      \thicklines
3010      \polyline(0,5)(7,5)(7,-2)(0,-2)
3011      \put(4,2.5){\makebox(0,0){\hbox{\yoko\bfseries \emph{yoko}}}}
3012      \put(0,0){\circle*{0.3}}
3013      \put(0,0){\vector(0,1){5}} \put(0.3,2.5){\makebox(0,0)[l]{$h_{\mathrm{Y}}$}}
3014      \put(0,0){\vector(0,-1){2}}\put(0.3,-1){\makebox(0,0)[l]{$d_{\mathrm{Y}}$}}
3015      \put(0,0){\vector(1,0){7}}\put(3.5,0.2){\makebox(0,0)[b]{$w_{\mathrm{Y}}$}}
3016    \end{picture}}}
3017  }
3018 \begin{tabular}{ccc}
3019 \toprule
3020 %<ja>\emph{横組中に配置}&\emph{縦組中に配置}&%
3021 %<ja>\emph{組方向 \cs{dtou} 中に配置}\\
3022 %<en>\textbf{typeset in \emph{yoko} direction}
3023 %<en>&\textbf{typeset in \emph{tate} or \emph{utod} direction}
3024 %<en>&\textbf{typeset in \emph{dtou} direction}\\
3025 \midrule
3026  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3027    \put(0,0){\line(1,0){3.8}}
3028    \put(4,7){\TATEeg}
3029    \put(11.2,0){\line(1,0){3.8}}
3030 %
3031    \put(2,7){\line(1,0){1.8}}
3032    \put(3,3.5){\vector(0,1){3.5}\vector(0,-1){3.5}}
3033    \put(2.8,3.5){\makebox(0,0)[r]{$H_{\mathrm{Y}}$}}
3034    \put(3,-2){\vector(0,1){2}}
3035    \put(2.8,-1){\makebox(0,0)[r]{$D_{\mathrm{Y}}$}}
3036 %
3037    \put(4,7.2){\line(0,1){1.8}}
3038    \put(11,7.2){\line(0,1){1.8}}
3039    \put(6,8){\vector(-1,0){2}}
3040    \put(9,8){\vector(1,0){2}}
3041    \put(7.5,8){\makebox(0,0){$W_{\mathrm{Y}}$}}
3042 %
3043  \end{picture}\vspace{-\baselineskip}
3044    \begin{align*}
3045    W_{\mathrm{Y}} &= h_{\mathrm{T}}+d_{\mathrm{T}},\\
3046    H_{\mathrm{Y}} &= w_{\mathrm{T}},\\
3047    D_{\mathrm{Y}} &=0\,\mathrm{pt}
3048    \end{align*}%
3049  }&
3050  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3051    \put(7.5,-0.2){\line(0,-1){2.8}}
3052    \put(4,2){\YOKOeg}
3053    \put(7.5, 7.2){\line(0,1){3.8}}
3054 %
3055    \put(2,7){\line(1,0){1.8}}
3056    \put(2,0){\line(1,0){1.8}}
3057    \put(3,5){\vector(0,1){2}}
3058    \put(3,2){\vector(0,-1){2}}
3059    \put(3,3.5){\makebox(0,0){$W_{\mathrm{T}}$}}
3060 %
3061    \put(4,7.2){\line(0,1){1.8}}
3062    \put(11,7.2){\line(0,1){1.8}}
3063    \put(8,8){\vector(-1,0){0.5}\vector(1,0){3}}
3064    \put(7,8){\vector(-1,0){3}\vector(1,0){0.5}}
3065    \put(9.25,8.2){\makebox(0,0)[b]{$H_{\mathrm{T}}$}}
3066    \put(5.75,8.2){\makebox(0,0)[b]{$D_{\mathrm{T}}$}}
3067 %
3068  \end{picture}\vspace{-\baselineskip}
3069    \begin{align*}
3070    W_{\mathrm{T}} &= h_{\mathrm{Y}}+d_{\mathrm{Y}},\\
3071    H_{\mathrm{T}} &= w_{\mathrm{Y}}/2,\\
3072    D_{\mathrm{T}} &= w_{\mathrm{Y}}/2
3073    \end{align*}%
3074  }&
3075  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3076    \put(11,-0.2){\line(0,-1){2.8}}
3077    \put(4,2){\YOKOeg}
3078    \put(11, 7.2){\line(0,1){3.8}}
3079 %
3080    \put(2,7){\line(1,0){1.8}}
3081    \put(2,0){\line(1,0){1.8}}
3082    \put(3,5){\vector(0,1){2}}
3083    \put(3,2){\vector(0,-1){2}}
3084    \put(3,3.5){\makebox(0,0){$W_{\mathrm{D}}$}}
3085 %
3086    \put(4,7.2){\line(0,1){1.8}}
3087    \put(11,7.2){\line(0,1){1.8}}
3088    \put(7.5,8){\vector(-1,0){3.5}\vector(1,0){3.5}}
3089    \put(13,8){\vector(-1,0){2}}
3090    \put(7.5,8.2){\makebox(0,0)[b]{$H_{\mathrm{D}}$}}
3091    \put(12,8.2){\makebox(0,0)[b]{$D_{\mathrm{D}}$}}
3092 %
3093  \end{picture}\vspace{-\baselineskip}
3094    \begin{align*}
3095    W_{\mathrm{D}} &= h_{\mathrm{Y}}+d_{\mathrm{Y}},\\
3096    H_{\mathrm{D}} &= w_{\mathrm{Y}},\\
3097    D_{\mathrm{D}} &= 0\,\mathrm{pt}
3098    \end{align*}%
3099  }%
3100 \\\midrule
3101  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3102    \put(0,0){\line(1,0){3.8}}
3103    \put(4,0){\DTOUeg}
3104    \put(11.2,0){\line(1,0){3.8}}
3105 %
3106    \put(2,7){\line(1,0){1.8}}
3107    \put(3,3.5){\vector(0,1){3.5}\vector(0,-1){3.5}}
3108    \put(2.8,3.5){\makebox(0,0)[r]{$H_{\mathrm{Y}}$}}
3109    \put(3,-2){\vector(0,1){2}}
3110    \put(2.8,-1){\makebox(0,0)[r]{$D_{\mathrm{Y}}$}}
3111 %
3112    \put(4,7.2){\line(0,1){1.8}}
3113    \put(11,7.2){\line(0,1){1.8}}
3114    \put(6,8){\vector(-1,0){2}}
3115    \put(9,8){\vector(1,0){2}}
3116    \put(7.5,8){\makebox(0,0){$W_{\mathrm{Y}}$}}
3117 %
3118  \end{picture}\vspace{-\baselineskip}
3119    \begin{align*}
3120    W_{\mathrm{Y}} &= h_{\mathrm{D}}+d_{\mathrm{D}},\\
3121    H_{\mathrm{Y}} &= w_{\mathrm{D}},\\
3122    D_{\mathrm{Y}} &= 0\,pt
3123    \end{align*}%
3124  }&
3125  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3126    \put(9,-0.2){\line(0,-1){2.8}}
3127    \put(4,0){\DTOUeg}
3128    \put(9, 7.2){\line(0,1){3.8}}
3129 %
3130    \put(2,7){\line(1,0){1.8}}
3131    \put(2,0){\line(1,0){1.8}}
3132    \put(3,5){\vector(0,1){2}}
3133    \put(3,2){\vector(0,-1){2}}
3134    \put(3,3.5){\makebox(0,0){$W_{\mathrm{T}}$}}
3135 %
3136    \put(4,7.2){\line(0,1){1.8}}
3137    \put(11,7.2){\line(0,1){1.8}}
3138    \put(6.5,8){\vector(-1,0){2.5}\vector(1,0){2.5}}
3139    \put(10,8){\vector(-1,0){1}\vector(1,0){1}}
3140    \put(10,8.2){\makebox(0,0)[b]{$H_{\mathrm{T}}$}}
3141    \put(6.5,8.2){\makebox(0,0)[b]{$D_{\mathrm{T}}$}}
3142 %
3143  \end{picture}\vspace{-\baselineskip}
3144    \begin{align*}
3145    W_{\mathrm{T}} &= h_{\mathrm{D}}+d_{\mathrm{D}},\\
3146    H_{\mathrm{T}} &= d_{\mathrm{D}},\\
3147    D_{\mathrm{T}} &= h_{\mathrm{D}}
3148    \end{align*}%
3149  }&
3150  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3151    \put(6,-0.2){\line(0,-1){2.8}}
3152    \put(4,7){\TATEeg}
3153    \put(6, 7.2){\line(0,1){3.8}}
3154 %
3155    \put(2,7){\line(1,0){1.8}}
3156    \put(2,0){\line(1,0){1.8}}
3157    \put(3,5){\vector(0,1){2}}
3158    \put(3,2){\vector(0,-1){2}}
3159    \put(3,3.5){\makebox(0,0){$W_{\mathrm{D}}$}}
3160 %
3161    \put(4,7.2){\line(0,1){1.8}}
3162    \put(11,7.2){\line(0,1){1.8}}
3163    \put(5,8){\vector(-1,0){1}\vector(1,0){1}}
3164    \put(8.5,8){\vector(-1,0){2.5}\vector(1,0){2.5}}
3165    \put(5,8.2){\makebox(0,0)[b]{$H_{\mathrm{D}}$}}
3166    \put(8.5,8.2){\makebox(0,0)[b]{$D_{\mathrm{D}}$}}
3167 %
3168  \end{picture}\vspace{-\baselineskip}
3169    \begin{align*}
3170    W_{\mathrm{D}} &= w_{\mathrm{T}},\\
3171    H_{\mathrm{D}} &= d_{\mathrm{T}},\\
3172    D_{\mathrm{D}} &= h_{\mathrm{T}}
3173    \end{align*}%
3174  }\\
3175 \bottomrule
3176 \end{tabular}
3177 \end{table}
3178
3179
3180
3181 %<*en>
3182 \paragraph{\cs{wd} and direction}
3183 In \pTeX, \cs{wd},~\cs{ht},~\cs{dp} means the dimensions of a box register
3184 \emph{with respact to the current direction}.
3185 This means that the value of \cs{wd0} etc.\ might differ when the current direction is
3186 different, even if \cs{box0} stores the same box.
3187 However, this no longer applies in \LuaTeX-ja.
3188
3189 \begin{LTXexample}
3190 % yoko direction
3191 \setbox0=\hbox to 20pt{foo}
3192 \the\wd0,~\hbox{\tate\vrule\the\wd0}
3193 \wd0=100pt
3194 \the\wd0,~\hbox{\tate \the\wd0}
3195 \end{LTXexample}
3196
3197 To access box dimensions \emph{with respect to current direction},
3198 one have to use the following commands instead of \cs{wd} wtc.
3199 \begin{cslist}
3200
3201  \item[\cs{ltjgetwd}<num>\textrm{, }\cs{ltjgetht}<num>\textrm{, }%
3202   \cs{ltjgetdp}<num>]
3203 These commands return \emph{an internal dimension} of \cs{box<num>} with respect to
3204 the current direction. One can use these in \cs{dimexpr} primitive, as the followings.
3205 \begin{lstlisting}
3206 \dimexpr 2\ltjgetwd42-3pt\relax, \the\ltjgetwd1701
3207 \end{lstlisting}
3208 The following is an example.
3209 \begin{LTXexample}[width=0.3\textwidth]
3210 \parindent0pt
3211 \setbox32767=\hbox{\yoko よこぐみ}
3212 \fboxsep=0mm\fbox{\copy32767}
3213 \vbox{\hsize=20mm
3214 \yoko YOKO \the\ltjgetwd32767, \\
3215   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3216 \vbox{\hsize=20mm\raggedleft
3217 \tate TATE \the\ltjgetwd32767, \\
3218   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3219 \vbox{\hsize=20mm\raggedleft
3220 \dtou DTOU \the\ltjgetwd32767, \\
3221   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3222 \end{LTXexample}
3223
3224  \item[\cs{ltjsetwd}<num>=<dimen>\textrm{, }\cs{ltjsetht}<num>=<dimen>\textrm{, }%
3225   \cs{ltjsetdp}<num>=<dimen>]
3226 These commands set the dimension of \cs{box<num>}. One does not need
3227         to group the argument <num>; four calls of \cs{ltjsetwd} below have the same meaning.
3228 \begin{lstlisting}
3229 \ltjsetwd42 20pt,  \ltjsetwd42=20pt,  \ltjsetwd=42 20pt,  \ltjsetwd=42=20pt
3230 \end{lstlisting}
3231
3232 \end{cslist}
3233 %</en>
3234 %<*ja>
3235 \paragraph{\cs{wd} 達と組方向}
3236 ボックスレジスタ \cs{box}<num> にセットされているボックスの幅・高さ・深さの取得や
3237 変更にはそれぞれ \cs{wd},~\cs{ht},~\cs{dp} プリミティブを用いるのであった.
3238 \pTeX ではこれらのプリミティブは,「現在の組方向におけるボックスの寸法」を指すもので,
3239 同じボックスに対しても現在の組方向によって返る値は異なるもであった.
3240
3241 \LuaTeX-jaにおいては状況が異なり,\cs{wd},~\cs{ht},~\cs{dp} が返す値は
3242 現在の組方向には依存しない.下の例のように,横組のボックスが格納されていれば
3243 \cs{wd}等は常に「横組におけるボックスの寸法」を意味する.
3244
3245 \begin{LTXexample}
3246 % yoko direction
3247 \setbox0=\hbox to 20pt{foo}
3248 \the\wd0,~\hbox{\tate\vrule\the\wd0}
3249 \wd0=100pt
3250 \the\wd0,~\hbox{\tate \the\wd0}
3251 \end{LTXexample}
3252
3253 \pTeX のように現在の組方向に応じたボックスの寸法の取得・設定を行うには,
3254 代わりに次の命令を使用する.
3255
3256 \begin{cslist}
3257
3258  \item[\cs{ltjgetwd}<num>\textrm{, }\cs{ltjgetht}<num>\textrm{, }%
3259   \cs{ltjgetdp}<num>]
3260 現在の組方向に応じたボックスの寸法の取得を行う.結果は内部長さであるため,
3261 \begin{lstlisting}
3262 \dimexpr 2\ltjgetwd42-3pt\relax, \the\ltjgetwd1701
3263 \end{lstlisting}
3264 のように \cs{wd}<num> の代わりとして扱うことができる.
3265 使用例は以下の通りである.
3266 \begin{LTXexample}[width=0.3\textwidth]
3267 \parindent0pt
3268 \setbox32767=\hbox{\yoko よこぐみ}
3269 \fboxsep=0mm\fbox{\copy32767}
3270 \vbox{\hsize=20mm
3271 \yoko YOKO \the\ltjgetwd32767, \\
3272   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3273 \vbox{\hsize=20mm\raggedleft
3274 \tate TATE \the\ltjgetwd32767, \\
3275   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3276 \vbox{\hsize=20mm\raggedleft
3277 \dtou DTOU \the\ltjgetwd32767, \\
3278   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3279 \end{LTXexample}
3280
3281  \item[\cs{ltjsetwd}<num>=<dimen>\textrm{, }\cs{ltjsetht}<num>=<dimen>\textrm{, }%
3282   \cs{ltjsetdp}<num>=<dimen>]
3283 現在の組方向に応じたボックスの寸法の設定を行う.\cs{afterassignment} を2回利用して
3284 実装しているので,次の4通りは全て同じ意味である.
3285 \begin{lstlisting}
3286 \ltjsetwd42 20pt,  \ltjsetwd42=20pt,  \ltjsetwd=42 20pt,  \ltjsetwd=42=20pt
3287 \end{lstlisting}
3288
3289 設定値は「横組」「縦組及び \cs{utod} 方向」「\cs{dtou} 方向」
3290 の3種ごとに独立して記録される.参考として,Gitリポジトリ内の
3291               \verb+test/test55-boxdim_diffdir.{tex,pdf}+ を挙げておく.
3292
3293 \end{cslist}
3294 %</ja>
3295
3296 %<*en>
3297 \subsection{Getting current direction}
3298 The \Param{direction} parameter returns the current direction, and
3299 the \Param{boxdir} parameter (with the argument <num>)
3300 returns the direction of a box register \cs{box}<num>.
3301 The returned value of these parameters are a \emph{string}:
3302 \begin{center}
3303 \small
3304 \begin{tabular}{>{\bfseries}lccccc}
3305 \toprule
3306 Direction&\emph{yoko}&\emph{tate}&\emph{dtou}&\emph{utod}&(empty)\\
3307 \midrule
3308 Returned value&\texttt{4}&\texttt{3}&\texttt{1}&\texttt{11}&\texttt{0}\\
3309 \bottomrule
3310 \end{tabular}
3311 \end{center}
3312 \begin{LTXexample}[width=0.3\textwidth]
3313 \leavevmode\def\DIR{\ltjgetparameter{direction}}
3314 \hbox{\yoko \DIR}, \hbox{\tate\DIR},
3315 \hbox{\dtou\DIR}, \hbox{\utod\DIR},
3316 \hbox{\tate$\hbox{tate math: \DIR}$}
3317
3318 \setbox2=\hbox{\tate}\ltjgetparameter{boxdir}{2}
3319 \end{LTXexample}
3320 %</en>
3321 %<*ja>
3322 \subsection{組方向の取得}
3323 「現在の組方向」や「<num>番のボックスの組方向」は,
3324 \pTeX では \cs{ifydir} や \cs{ifybox}<num> といった条件判断文を使って
3325 判断することができた.
3326 しかし,\LuaTeX-jaはあくまでも\TeX マクロとLuaコードで
3327 記述されており,それでは新たな条件判断命令を作るのは難しい.
3328
3329 \LuaTeX-jaでは,\Param{direction}パラメータで現在の組方向を,
3330 \Param{boxdir}パラメータ(と追加の引数<num>)によって
3331 \cs{box}<num>の組方向をそれぞれ取得できるようにした.
3332 戻り値は文字列である:
3333 \begin{center}
3334 \small
3335 \begin{tabular}{>{\bfseries}lccccc}
3336 \toprule
3337 組方向&\emph{横組}&\emph{tate縦組}&\emph{dtou方向}&\emph{utod方向}&(未割り当て)\\
3338 \midrule
3339 戻り値&\texttt{4}&\texttt{3}&\texttt{1}&\texttt{11}&\texttt{0}\\
3340 \bottomrule
3341 \end{tabular}
3342 \end{center}
3343
3344 \begin{LTXexample}[width=0.3\textwidth]
3345 \leavevmode\def\DIR{\ltjgetparameter{direction}}
3346 \hbox{\yoko\DIR}, \hbox{\tate\DIR},
3347 \hbox{\dtou\DIR}, \hbox{\utod\DIR},
3348 \hbox{\tate$\hbox{tate math: \DIR}$}
3349
3350 \setbox2=\hbox{\tate}\ltjgetparameter{boxdir}{2}
3351 \end{LTXexample}
3352
3353 これらを用いれば,例えば
3354 \pTeX の \cs{ifydir},~\cs{ifybox200} と同等の条件判断を
3355 \begin{lstlisting}
3356 \ifnum\ltjgetparameter{direction}=4
3357 \ifnum\ltjgetparameter{boxdir}{200}=4
3358 \end{lstlisting}
3359 のように行うことができる.
3360 \cs{iftdir} は少々面倒であるが,8で割った余りが3であるか否かを判断すれば良いから
3361 \begin{lstlisting}
3362 \ifnum\numexpr
3363   \ltjgetparameter{direction}-(\ltjgetparameter{direction}/8)*8=3
3364 \end{lstlisting}
3365 とすればよい.
3366 %</ja>
3367
3368 %<*en>
3369 \subsection{Overridden box primitives}
3370 To cope with multiple directions, the following primitives are
3371 overridden by \LuaTeX-ja, using~\verb+\protected\def+.
3372 \begin{cslist}[style=standard]
3373  \item[\cs{unhbox}<num>\textrm{, }\cs{unvbox}<num>\textrm{, }\cs{unhcopy}<num>\textrm{, }\cs{unvcopy}<num>]
3374  \item[\cs{vadjust}\{<material>\}]
3375  \item[\cs{insert}<number>\{<material>\}]
3376  \item[\cs{lastbox}]
3377  \item[\cs{raise}<dimen><box>\textrm{, }\cs{lower}<dimen><box>\textrm{\ etc., }\cs{vcenter}]
3378  \item[\cs{vcenter}]
3379 \end{cslist}
3380 %</en>
3381 %<*ja>
3382 \subsection{プリミティブの再定義}
3383 異なる組方向に対応するために,以下に挙げるプリミティブは
3384 \LuaTeX-jaによる前処理もしくは後処理が行われるように
3385 \ \verb+\protected\def+ により再定義してある.
3386
3387 \begin{cslist}
3388  \item[\cs{unhbox}<num>\textrm{, }\cs{unvbox}<num>\textrm{, }\cs{unhcopy}<num>\textrm{, }\cs{unvcopy}<num>]
3389  ボックスの組方向が現在のリストと異なる場合は事前にエラーメッセージを出力する.
3390  \pTeX と異なり,エラーを無視して無理矢理 \cs{unhbox}, \cs{unvbox} を
3391  続行させることもできるが,その場合の組版結果は保証しない.
3392  \item[\cs{vadjust}\{<material>\}] 一旦プリミティブ本来の挙動を行う.その後,<material>の組方向が
3393  周囲の垂直リストの組方向と一致しない場合にエラーを出力し,
3394  該当の \cs{vadjust} を無効にする.
3395  \item[\cs{insert}<number>\{<material>\}]
3396  一旦プリミティブ本来の挙動を行い,その後<material>内の各ボックス・罫線の直前に組方向を示
3397               すdirection whatsitを挿入する.
3398  \item[\cs{lastbox}] ボックスの「中身」を現在の組方向に合わせるためのノード
3399               (\textit{dir\_box}という)を必要ならば除去し,
3400  正しく「中身」のボックスが返されるように前処理をする.
3401  \item[\cs{raise}<dimen><box>\textrm{, }\cs{lower}<dimen><box>\textrm{\ etc., }\cs{vcenter}]
3402  一方,こちらでは必要に応じて\textit{dir\_box}を作成する前処理を追加している.
3403 \end{cslist}
3404 %</ja>
3405
3406 %<en>\section{Font Metric and Japanese Font}
3407 %<ja>\section{フォントメトリックと和文フォント}
3408 %<en>\subsection{\cs{jfont}}
3409 %<ja>\subsection{\cs{jfont} 命令}
3410 \label{ssec-jfont}
3411
3412 %<*en>
3413 To load a font as a Japanese font (for horizontal direction), you must use the
3414 \cs{jfont} instead of~\cs{font}, while
3415 \cs{jfont} admits the same syntax used in~\cs{font}.
3416 \LuaTeX-ja automatically loads \Pkg{luaotfload} package,
3417 so TrueType/OpenType fonts with features can be used for Japanese fonts:
3418 %</en>
3419 %<*ja>
3420 フォントを(横組用)和文フォントとして読み込むためには,\cs{jfont} を
3421 \ \cs{font} プリミティブの代わりに用いる.
3422 \cs{jfont} の文法は \cs{font} と同じである.
3423 \LuaTeX-jaは\Pkg{luaotfload}パッケージを自動的に読み込むので,
3424 TrueType/OpenTypeフォントにfeatureを指定したものを和文フォントとして用いる
3425 ことができる:
3426 %</ja>
3427 \begin{LTXexample}[width=0.3\textwidth]
3428 \jfont\tradgt={file:KozMinPr6N-Regular.otf:script=latn;%
3429   +trad;-kern;jfm=ujis} at 14pt
3430 \tradgt 当/体/医/区
3431 \end{LTXexample}
3432
3433 %<*en>
3434 Note that the defined control sequence
3435 (\cs{tradgt} in the example above) using \cs{jfont} is not a
3436 \textit{font\_def} token,  but a macro.
3437 Hence the input like \verb+\fontname\tradgt+
3438 causes a error.  We denote control sequences which are defined in
3439 \cs{jfont} by <jfont\_cs>.
3440 %</en>
3441 %<*ja>
3442 なお,\cs{jfont} で定義された制御綴(上の例だと \cs{tradgt})
3443 は\textit{font\_def}トークンではなくマクロである.従って,\verb+\fontname\tradgt+ のような
3444 入力はエラーとなる.以下では \cs{jfont} で定義された
3445 制御綴を<jfont\_cs>で表す.
3446 %</ja>
3447
3448 \paragraph{JFM}
3449 %<*en>
3450 a JFM has measurements of characters and
3451 glues/kerns that are automatically inserted for Japanese
3452 typesetting. The structure of JFM will be described in the next
3453 subsection. At the calling of \cs{jfont}, you must specify
3454 which JFM will be used for this font by the following keys:
3455 %</en>
3456 %<*ja>
3457 JFMは文字と和文組版で自動的に挿入される
3458 グルー/カーンの寸法情報を持っている.JFMの構造は次の節で述べる.
3459 \cs{jfont} 命令の呼び出しの際には,どのJFMを用いるのかを以下のキーで
3460 指定する必要がある:
3461 %</ja>
3462
3463
3464 \begin{table}[t]
3465 %<en>\caption{Differences between horizontal JFMs shipped with \LuaTeX-ja}
3466 %<ja>\caption{\LuaTeX-ja に同梱されている横組用JFMの違い}
3467 %<en>\medskip
3468 \label{tab-difjfm}
3469 \ltjsetparameter{jacharrange={+3}}
3470 \centering\small
3471 \def\r#1#2{%
3472   \hbox{\Large\vrule
3473   \parbox[b]{7\zw}{%
3474     \addjfontfeatures{YokoFeatures={Opacity=0.5, Color=#2, JFM=#1}}\noindent
3475     ◆◆◆◆◆◆◆
3476     ある日モモちゃんがお使いで迷子になって泣きました.
3477   }\vrule}}
3478 \def\s#1#2{%
3479   \Large
3480   \parbox[b]{7\zw}{%
3481     \addjfontfeatures{YokoFeatures={Opacity=0.5, Color=#2, JFM=#1}}\noindent
3482     ちょっと!何
3483   }}
3484 \def\t#1#2#3{\hbox to 0pt{\hss%
3485   \setbox0=\hbox{\addjfontfeatures{YokoFeatures={JFM=#1}}\huge #3}%
3486   \textcolor{#2}{\transparent{0.5}\vrule width 0.4pt height\ht0 depth\dp0}\kern-.2pt\copy0
3487   \textcolor{#2}{\transparent{0.5}\kern-\wd0\vrule width\wd0height .2pt depth .2pt
3488   \kern-\wd0\raise\ht0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3489   \kern-\wd0\lower\dp0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3490   \kern-.2pt\vrule width 0.4pt height\ht0 depth \dp0}\hss}}
3491 {\Large\tabcolsep0pt
3492 \begin{tabular}{m{8\zw}m{8\zw}m{8\zw}}
3493 \leavevmode\hbox to 0pt{\r{ujis}{blue}\hss}\r{jis}{black}&
3494 \leavevmode\hbox to 0pt{\r{jis}{black}\hss}\r{min}{red}&
3495 \leavevmode\hbox to 0pt{\r{ujis}{blue}\hss}\r{min}{red}\\
3496 \leavevmode\hbox to 0pt{\s{ujis}{blue}\hss}\s{jis}{black}&
3497 \leavevmode\hbox to 0pt{\s{jis}{black}\hss}\s{min}{red}&
3498 \leavevmode\hbox to 0pt{\s{ujis}{blue}\hss}\s{min}{red}\\
3499 \leavevmode\qquad\t{ujis}{blue}{漢}\t{jis}{black}{漢}\qquad
3500            \t{ujis}{blue}{っ}\t{jis}{black}{っ}&
3501 \leavevmode\qquad\t{jis}{black}{漢}\t{min}{red}{漢}\qquad
3502            \t{jis}{black}{っ}\t{min}{red}{っ}&
3503 \leavevmode\qquad\t{ujis}{blue}{漢}\t{min}{red}{漢}\qquad
3504            \t{ujis}{blue}{っ}\t{min}{red}{っ}\\
3505 \end{tabular}\par}
3506
3507 (\textcolor{blue}{Blue: \texttt{jfm-ujis.lua}},
3508 \textcolor{black}{Black: \texttt{jfm-jis.lua}},
3509 \textcolor{red}{Red: \texttt{jfm-min.lua}})
3510 \ltjsetparameter{jacharrange={-3}}
3511 \end{table}
3512
3513 \begin{cslist}
3514 \item[jfm=<name>]
3515 %<*en>
3516 Specify the name of (horizontal) JFM.
3517 If specified JFM has not been loaded, \LuaTeX-ja search and load
3518 a file named \texttt{jfm-<name>.lua}.
3519
3520 The following JFMs are shipped with \LuaTeX-ja:
3521 %</en>
3522 %<*ja>
3523 用いる(横組用)JFMの名前を指定する.もし以前に指定されたJFMが読み込まれていなければ,
3524 \texttt{jfm-<name>.lua}を読み込む.以下の横組用JFMが\LuaTeX-jaには同梱されている:
3525 %</ja>
3526 \begin{description}
3527 %<*en>
3528 \item[\tt jfm-ujis.lua] A standard JFM in \LuaTeX-ja. This JFM is
3529   based on \verb+upnmlminr-h.tfm+, a metric for UTF/OTF package that
3530   is used in \upTeX. When you use the \Pkg{luatexja-otf} package, you should use this JFM.
3531 %</en>
3532 %<*ja>
3533 \item[\tt jfm-ujis.lua] \LuaTeX-jaの標準JFMである.このJFMは\upTeX で
3534   用いられるUTF/OTFパッケージ用の和文用TFMである \verb+upnmlminr-h.tfm+ を
3535   元にしている.\Pkg{luatexja-otf}パッケージを使うときはこのJFMを指定するべきである.
3536 %</ja>
3537 %<*en>
3538 \item[\tt jfm-jis.lua] A counterpart for \verb+jis.tfm+, ``JIS font
3539   metric'' which is widely used in \pTeX. A major difference between
3540   \texttt{jfm-ujis.lua} and this \texttt{jfm-jis.lua} is that
3541   most characters under \texttt{jfm-ujis.lua} are square-shaped,
3542   while that under \texttt{jfm-jis.lua} are horizontal
3543   rectangles.
3544 %</en>
3545 %<*ja>
3546 \item[\tt jfm-jis.lua] \pTeX で広く用いられている「JISフォントメトリック」
3547   \verb+jis.tfm+ に相当するJFMである.\texttt{jfm-ujis.lua} とこの
3548   \texttt{jfm-jis.lua} の主な違いは,\texttt{jfm-ujis.lua} ではほとんどの文字が
3549   正方形状であるのに対し,\texttt{jfm-jis.lua} では横長の長方形状であることと,
3550   \texttt{jfm-ujis.lua} では「?」「!」の直後に半角空白が挿入されることである.
3551 %</ja>
3552 %<*en>
3553 \item[\tt jfm-min.lua] A counterpart for \verb+min10.tfm+, which is one
3554   of the default Japanese font metric shipped with \pTeX.
3555 %</en>
3556 %<*ja>
3557 \item[\tt jfm-min.lua] \pTeX に同梱されているデフォルトの和文用TFM
3558 (\verb+min10.tfm+)に相当し,行末で文字が揃うようにするために「っ」など一部の文字幅が変わっ
3559            ている.\verb+min10.tfm+ については\cite{min10}が詳しい.
3560 %</ja>
3561 \end{description}
3562 %<*en>
3563 The difference among these three~JFMs is  shown in Table~\ref{tab-difjfm}.
3564 %</en>
3565 %<*ja>
3566 これら3つのJFMの違いは表\ref{tab-difjfm}に示した.表中の文例の一部には,
3567 \cite{min10}の図3,~4のものを用いた.
3568 %</ja>
3569
3570 \begin{figure}
3571 \begin{LTXexample}[width=0.3\textwidth]
3572 \ltjsetparameter{differentjfm=both}
3573 \jfont\F=file:KozMinPr6N-Regular.otf:jfm=ujis
3574 \jfont\G=file:KozGoPr6N-Medium.otf:jfm=ujis
3575 \jfont\H=file:KozGoPr6N-Medium.otf:jfm=ujis;jfmvar=hoge
3576 \F ){\G 【】}( % halfwidth space
3577    ){\H 『』}( % fullwidth space
3578
3579 ほげ,{\G 「ほげ」}(ほげ)\par
3580 ほげ,{\H 「ほげ」}(ほげ)% pTeX-like
3581
3582 \ltjsetparameter{differentjfm=paverage}
3583 \end{LTXexample}
3584 \caption{Example of \texttt{jfmvar} key}
3585 \label{fig:jfmvar}
3586 \end{figure}
3587
3588 %<*en>
3589 \item[jfmvar=<string>]
3590 Sometimes there is a need that \ldots.
3591 %</en>
3592 %<*ja>
3593 \item[jfmvar=<string>]
3594 標準では,JFMとサイズが同じで,
3595   実フォントだけが異なる2つの和文フォントは「区別されない」.例えば
3596 図\ref{fig:jfmvar}において,最初の「)」と「【」の実フォントは異なるが,
3597 JFMもサイズも同じなので,普通に「)【」と入力した時と同じように半角空きとなる.
3598
3599 しかし,JFMとサイズが同じであっても,\texttt{jfmvar} キーの異なる
3600 2つの和文フォント,例えば図\ref{fig:jfmvar}で言う \cs{F} と \cs{H},
3601 は「区別される」.異なる和文フォントに異なる \texttt{jfmvar} キーを割り当て,
3602 かつ\Param{differentjfm}パラメータを \texttt{both} に設定すれば,
3603 \pTeX と似た状況で組版されることになる.
3604 %</ja>
3605 \end{cslist}
3606
3607 \begin{figure}
3608 \begin{LTXexample}[pos=t]
3609 \newcommand\test{\vrule ダイナミックダイクマ\vrule\\}
3610 \jfont\KMFW = KozMinPr6N-Regular:jfm=prop;-kern at 17pt
3611 \jfont\KMFK = KozMinPr6N-Regular:jfm=prop at 17pt % kern is activated
3612 \jfont\KMPW = KozMinPr6N-Regular:jfm=prop;script=dflt;+pwid;-kern at 17pt
3613 \jfont\KMPK = KozMinPr6N-Regular:jfm=prop;script=dflt;+pwid;+kern at 17pt
3614 \begin{multicols}{2}
3615 \ltjsetparameter{kanjiskip=0pt}
3616 {\KMFW\test \KMFK\test \KMPW\test \KMPK\test}
3617
3618 \ltjsetparameter{kanjiskip=3pt}
3619 {\KMFW\test \KMFK\test \KMPW\test \KMPK\test}
3620 \end{multicols}
3621 \end{LTXexample}
3622 \caption{Kerning information and \Param{kanjiskip}}
3623 \label{fig:kern-jfm}
3624 \end{figure}
3625
3626 %<en>\paragraph{Using kerning information in a font}
3627 %<ja>\paragraph{ペアカーニング情報の使用}
3628 \label{para-kern}
3629 %<*en>
3630 Some fonts have information for inter-glyph spacing.
3631 This version of \LuaTeX-ja treats kerning spaces like an italic correction;
3632 any glue and/or kern from the JFM and a kerning space can coexist.
3633 See Figure~\ref{fig:kern-jfm} for detail.
3634
3635 Note that in \cs{setmainjfont} etc.\ which are provided by \Pkg{luatexja-fontspec}
3636 package, kerning option is set \emph{off} (\texttt{Kerning=Off}) by default,
3637 because of the compatibility with previous versions of \LuaTeX-ja.
3638 %</en>
3639 %<*ja>
3640 いくつかのフォントはグリフ間のスペースについての情報を持っている.
3641 このカーニング情報は以前の\LuaTeX-ja とはあまり相性が良くなかったが,
3642 本バージョンではカーニングによる空白はイタリック補正と同様に扱うことになっている.
3643 つまり,カーニング由来の空白とJFM由来のグルー・カーンは同時に入りうる.
3644 図\ref{fig:kern-jfm}を参照.
3645 \begin{itemize}
3646  \item \emph{\cs{jfont} や,
3647 NFSS2用の命令(\ref{ssec-chgfnt}節,\ref{ssec-nfsspat}節)における指定では
3648 カーニング情報は標準で使用する}ことになっているようである.
3649 言い換えれば,カーニング情報を使用しない設定にするには,面倒でも
3650 \begin{lstlisting}
3651 \jfont\hoge=KozMinPr6N-Regular:jfm=ujis;-kern at 3.5mm
3652 \DeclareFontShape{JY3}{fuga}{m}{n} {<-> s*KozMinPr6N-Regular:jfm=ujis;-kern}{}
3653 \end{lstlisting}
3654 のように,\texttt{-kern} という指定を自分で追加しなければいけない.
3655  \item
3656 一方,\emph{\Pkg{luatexja-fontspec} の提供する \cs{setmainjfont}\
3657 などの命令の標準設定ではカーニング情報は使用しない}(\texttt{Kerning=Off})
3658 ことになっている.これは以前のバージョンの\LuaTeX-jaとの互換性のためである.
3659 \end{itemize}
3660 %</ja>
3661
3662 %<*ja>
3663 \paragraph{\texttt{extend}と\texttt{slant}}
3664 OpenType font featureと見かけ上同じような形式で指定できるものに,
3665 \begin{description}
3666 \item[\texttt{extend=}<extend>] 横方向に<extend>倍拡大する.
3667 \item[\texttt{slant=}<slant>] <slant>に指定された割合だけ傾ける.
3668 \end{description}
3669 の2つがある.
3670 \texttt{extend}や\texttt{slant}を指定した場合は,それに応じたJFMを指定すべきである%
3671 \footnote{\LuaTeX-jaでは,これらに対するJFMを特に提供することはしない予定である.}.
3672 例えば,次の例では無理やり通常のJFMを使っているために,文字間隔やイタリック補正量が
3673 正しくない:
3674 %</ja>
3675 %<*en>
3676 \paragraph{\texttt{extend} and \texttt{slant}}
3677 The following setting can be specified as OpenType font features:
3678 \begin{cslist}[style=standard]
3679 \item[\cs{extend=}<extend>] expand the font horizontally by <extend>.
3680 \item[\cs{slant=}<slant>] slant the font.
3681 \end{cslist}
3682 Note that \LuaTeX-ja doesn't adjust JFMs by these \texttt{extend} and \texttt{slant}
3683 settings; you have to write new JFMs on purpose.
3684 For example, the following example uses the standard JFM \texttt{jfm-ujis.lua}, hence
3685 letter-spacing and the width of italic correction are not correct:
3686 %</en>
3687 \begin{LTXexample}[width=0.3\textwidth]
3688 \jfont\E=KozMinPr6N-Regular:extend=1.5;jfm=ujis;-kern
3689 \E あいうえお
3690
3691 \jfont\S=KozMinPr6N-Regular:slant=1;jfm=ujis;-kern
3692 \S あいう\/ABC
3693 \end{LTXexample}
3694
3695 %<en>\subsection{\cs{tfont}}
3696 %<ja>\subsection{\cs{tfont} 命令}
3697
3698
3699 \begin{table}[t]
3700 %<en>\caption{Differences between vertical JFMs shipped with \LuaTeX-ja}
3701 %<ja>\caption{\LuaTeX-ja に同梱されている縦組用 JFM の違い}
3702 %<en>\medskip
3703 \label{tab-difjfm-tate}
3704 \catcode`\<=12\catcode`\>=12
3705 \ltjsetparameter{jacharrange={+3}}
3706 \small
3707
3708 \def\r#1#2{%
3709   \hbox{\tate\Large\vrule
3710   \parbox{7\zw}{%
3711     \addjfontfeatures{TateFeatures={Opacity=0.5, Color=#2, JFM=#1}}\noindent
3712     ◆◆◆◆◆◆◆
3713     ある日モモちゃんがお使いで迷子になって泣きました.
3714   }\vrule}}
3715 \def\s#1#2{%
3716   \hbox{\tate\Large
3717   \parbox{7\zw}{%
3718     \addjfontfeatures{TateFeatures={Opacity=0.5, Color=#2, JFM=#1}}\noindent
3719     ちょっと!何
3720   }}}
3721 \def\t#1#2#3{\hbox to 0pt{\hss%
3722   \setbox0=\hbox{\addjfontfeatures{TateFeatures={JFM=#1}}\huge #3}%
3723   \textcolor{#2}{\transparent{0.5}\vrule width 0.4pt height\ht0 depth\dp0}\kern-.2pt\copy0
3724   \textcolor{#2}{\transparent{0.5}\kern-\wd0\vrule width\wd0height .2pt depth .2pt
3725   \kern-\wd0\raise\ht0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3726   \kern-\wd0\lower\dp0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3727   \kern-.2pt\vrule width 0.4pt height\ht0 depth \dp0}\hss}}
3728
3729 \begin{minipage}{.7\textwidth}
3730 \centering
3731 \leavevmode\hbox to 0pt{\r{ujisv}{blue}\hss}\r{tmin}{red}\quad
3732 \leavevmode\hbox to 0pt{\s{ujisv}{blue}\hss}\s{tmin}{red}\quad
3733 \raise4\zw\hbox{\tate\Large\t{ujisv}{black}{漢}\t{tmin}{red}{漢}\qquad
3734            \t{ujisv}{black}{っ}\t{tmin}{red}{っ}}
3735 \end{minipage}%
3736 \begin{minipage}{.3\textwidth}
3737 \textcolor{blue}{Blue: \texttt{jfm-ujisv.lua}}\\
3738 \textcolor{red}{Red: \texttt{jfm-tmin.lua}}
3739 \end{minipage}
3740 \ltjsetparameter{jacharrange={-3}}
3741 \end{table}
3742
3743 %<*en>
3744 ...
3745 %</en>
3746 %<*ja>
3747 \cs{tfont} はフォントを縦組用の和文フォントとして読み込む命令であり,
3748 \cs{tfont} の文法は \cs{jfont} と同じである.
3749 \cs{tfont} で定義された縦組用和文フォントは,
3750 以下の点が \cs{jfont} による横組用和文フォントとは異なる:
3751 \begin{itemize}
3752  \item 自動的に \texttt{vert}, \texttt{vrt2} の両OpenType featureが有効化される.
3753 但し,以下の例の3行目に示すように,明示的に \texttt{vert}, \texttt{vrt2}(のいずれか)の
3754 有効・無効を指定した場合は別である.
3755 \begin{lstlisting}
3756 \tfont\S=file:KozMinPr6N-Regular.otf:jfm=ujisv
3757     % vert and vrt2 are automatically activated
3758 \tfont\T=file:KozMinPr6N-Regular.otf:jfm=ujisv;-vert % vert and vrt2 are not activated
3759 \end{lstlisting}
3760  \item \ref{ssec-math}節で述べる,数式中の和文フォントには縦組用和文フォントは指定できない.
3761  \item \texttt{jfm=<name>}\ の部分には縦組用JFMを指定する.
3762 以下の縦組用JFMが\LuaTeX-jaには同梱されており,違いを表\ref{tab-difjfm-tate}に示した.
3763 \begin{description}
3764 \item[\tt jfm-ujisv.lua] \LuaTeX-jaの標準縦組用JFMである.このJFMは\upTeX で
3765   用いられるUTF/OTFパッケージ用の和文用TFMである \verb+upnmlminr-v.tfm+ を
3766   元にしている.
3767 \item[\tt jfm-tmin.lua] \pTeX に同梱されているデフォルトの和文用縦組TFM
3768   である \verb+tmin10.tfm+ に相当し,\texttt{min10.tfm} と同様に
3769   「っ」など一部の文字幅が狭められている.
3770 \end{description}
3771 \end{itemize}
3772
3773 なお,\pTeX では,\cs{font},~\cs{jfont},~\cs{tfont}のどれでも欧文フォント・横組用和文フォン
3774 ト・縦組用和文フォントの定義が可能であったが,\LuaTeX-jaではそうでないので注意.
3775 %</ja>
3776
3777 %<en>\subsection{Prefix \texttt{psft}}
3778 %<ja>\subsection{\texttt{psft}プリフィックス}
3779 \label{ssec-psft}
3780 %<*en>
3781 Besides ``\texttt{file:}''\ and ``\texttt{name:}''\ prefixes which
3782 are introduced in the \Pkg{luaotfload} package,
3783 \LuaTeX-ja adds ``\texttt{psft:}''\ prefix in \cs{jfont} (and~\cs{font}),
3784 to specify a ``name-only'' Japanese font which
3785 will not be embedded to PDF.
3786 Note that these non-embedded fonts under current \LuaTeX\ has Identity-H encoding,
3787 and this violates the standard ISO32000-1:2008~(\cite{pdfstd}).
3788
3789 \emph{OpenType font features, such as ``{\tt +jp90}'',
3790 have no meaning in name-only fonts using ``{\tt psft:}''\ prefix,
3791 because we can't expect what fonts are actually used by the PDF reader.}
3792 Note that \texttt{extend}~and~\texttt{slant} settings (see~above) are supported
3793 with \texttt{psft} prefix, because they are only simple linear transformations.
3794 %</en>
3795 %<*ja>
3796 \Pkg{luaotfload}で使用可能になった
3797 \texttt{file:}\ と \texttt{name:}\ のプリフィックスに加えて,
3798 \cs{jfont}(と \cs{font} プリミティブ)では
3799 \texttt{psft:}プリフィックスを用いることができる.
3800 このプリフィックスを用いることで,PDFには埋め込まれない「名前だけの」
3801 和文フォントを指定することができる.
3802 なお,現行の\LuaTeX で非埋め込みフォントを作成するとPDF内でのエンコーディングが
3803 Identity-Hとなり,PDFの標準規格ISO32000-1:2008~(\cite{pdfstd})に非準拠になってしまう
3804 ので注意してほしい.
3805
3806 \emph{\texttt{psft} プリフィックスの下では
3807 \texttt{+jp90} などのOpenType font featureの効力はない.
3808 非埋込フォントをPDFに使用すると,実際にどのようなフォントが
3809 表示に用いられるか予測できないからである.}\
3810 \texttt{extend} と \texttt{slant} 指定は単なる変形のため
3811 \texttt{psft} プリフィックスでも使用可能である.
3812 %</ja>
3813
3814 %<en>\paragraph{\texttt{cid} key}
3815 %<ja>\paragraph{\texttt{cid}キー}
3816 \label{para-cid}
3817
3818 %<*en>
3819 The default font defined by using \texttt{psft:} prefix is for Japanese typesetting;
3820 it is Adobe-Japan1-6 CID-keyed font.
3821 One can specify \texttt{cid} key to use other CID-keyed non-embedded fonts
3822 for Chinese or Korean typesetting.
3823 %</en>
3824 %<*ja>
3825 標準で\texttt{psft:}プリフィックスで定義されるフォントは日本語用のもので
3826 あり,Adobe-Japan1-6のCIDに対応したものとなる.しかし,\LuaTeX-jaは中国語
3827 の組版にも威力を発揮することが分かり,日本語フォントでない非埋込フォント
3828 の対応も必要となった.そのために追加されたのが\texttt{cid}キーである.
3829
3830 \texttt{cid}キーに値を指定すると,そのCIDを持った非埋込フォントを定義することができる:
3831 %</ja>
3832 \begin{lstlisting}[numbers=left]
3833 \jfont\testJ={psft:Ryumin-Light:cid=Adobe-Japan1-6;jfm=jis}     % Japanese
3834 \jfont\testD={psft:Ryumin-Light:jfm=jis}                        % default value is Adobe-Japan1-6
3835 \jfont\testC={psft:AdobeMingStd-Light:cid=Adobe-CNS1-6;jfm=jis} % Traditional Chinese
3836 \jfont\testG={psft:SimSun:cid=Adobe-GB1-5;jfm=jis}              % Simplified Chinese
3837 \jfont\testK={psft:Batang:cid=Adobe-Korea1-2;jfm=jis}           % Korean
3838 \end{lstlisting}
3839 %<*en>
3840 Note that the code above specifies \texttt{jfm-jis.lua}, which is for Japanese fonts,
3841 as JFM for Chinese and Korean fonts.
3842 %</en>
3843 %<*ja>
3844 上のコードでは中国語・韓国語用フォントに対してもJFMに
3845 日本語用の\texttt{jfm-jis.lua}を指定しているので注意されたい.
3846 %</ja>
3847
3848 %<*en>
3849 At present, \LuaTeX-ja supports only 4 values written in the sample code above.
3850 Specifying other values, e.g.,
3851 %</en>
3852 %<*ja>
3853 今のところ,\LuaTeX-jaは上のサンプルコード中に書いた4つの値しかサポートしていない.
3854 %</ja>
3855 \begin{lstlisting}
3856 \jfont\test={psft:Ryumin-Light:cid=Adobe-Japan2;jfm=jis}
3857 \end{lstlisting}
3858 %<*en>
3859 produces the following error:
3860 %</en>
3861 %<*ja>
3862 のようにそれら以外の値を指定すると,エラーが発生する:
3863 %</ja>
3864 \begin{lstlisting}[numbers=left]
3865 ! Package luatexja Error: bad cid key `Adobe-Japan2'.
3866
3867 See the luatexja package documentation for explanation.
3868 Type  H <return>  for immediate help.
3869 <to be read again>
3870                    \par
3871 l.78
3872
3873 ? h
3874 I couldn't find any non-embedded font information for the CID
3875 `Adobe-Japan2'. For now, I'll use `Adobe-Japan1-6'.
3876 Please contact the LuaTeX-ja project team.
3877 ?
3878 \end{lstlisting}
3879
3880 %<en>\subsection{Structure of a JFM File}
3881 %<ja>\subsection{JFMファイルの構造}
3882 \label{ssec-jfm-str}
3883 %<en>A JFM file is a Lua script which has only one function call:
3884 %<ja>JFMファイルはただ一つの関数呼び出しを含むLuaスクリプトである:
3885 \begin{lstlisting}
3886 luatexja.jfont.define_jfm { ... }
3887 \end{lstlisting}
3888 %<*en>
3889 Real data are stored in the table which indicated above by
3890 \verb+{ ... }+.  So, the rest of this subsection are devoted to describe the
3891 structure of this table.  Note that all lengths in a JFM file are
3892 floating-point numbers in design-size unit.
3893 %</en>
3894 %<*ja>
3895 実際のデータは上で \verb+{ ... }+ で示されたテーブルの中に格納されている.
3896 以下ではこのテーブルの構造について記す.
3897 なお,JFMファイル中の長さは全てdesign-sizeを単位とする浮動小数点数であることに
3898 注意する.
3899 %</ja>
3900
3901 \begin{cslist}[style=standard]
3902
3903 \item[dir=<direction>]
3904 %<en>(required)
3905 %<ja>(必須)
3906
3907 %<*en>
3908 The direction of JFM. \texttt{'yoko'}~(horizontal)
3909 or \texttt{'tate'}~(vertical) are supported.
3910 %</en>
3911 %<*ja>
3912 JFMの書字方向.\texttt{'yoko'}(横組)と \texttt{'tate'}(縦組)がサポートされる.
3913 %</ja>
3914
3915 \item[zw=<length>]
3916 %<en>(required)
3917 %<ja>(必須)
3918
3919 %<en>The amount of the length of the ``full-width''.
3920 %<*ja>
3921 「全角幅」の長さ.この量が \cs{zw} の長さとなる.\pTeX では
3922 「全角幅」\texttt{1zw} は「文字クラス0の文字」の幅と決められていたが,
3923 \LuaTeX-jaではここで指定する.
3924 %</ja>
3925
3926 \item[zh=<length>]
3927 %<en>(required)
3928 %<ja>(必須)
3929
3930 %<en>The amount of the ``full-height'' (height + depth).
3931 %<*ja>
3932 「全角高さ」(height + depth)の長さ.通常は全角幅と同じ長さになるだろう.
3933 \pTeX では 「全角高さ」\texttt{1zh} は「文字クラス0の文字」の高さと深さの和と決められていたが,
3934 \LuaTeX-jaではここで指定する.
3935 %</ja>
3936
3937 \item[kanjiskip=\{<natural>, <stretch>, <shrink>\}]
3938 %<en>(optional)
3939 %<ja>(任意)
3940
3941 %<*en>
3942 This field specifies the ``ideal'' amount of \Param{kanjiskip}. As noted
3943              in Subsection~\ref{subs-kskip}, if the parameter
3944              \Param{kanjiskip} is \cs{maxdimen}, the value specified
3945              in this field is actually used (if this field is not specified in
3946              JFM, it is regarded as 0\,pt). Note that <stretch> and <shrink>
3947              fields are in design-size unit too.
3948 %</en>
3949 %<*ja>
3950 理想的な\Param{kanjiskip}の量を指定する.\ref{subs-kskip}節で述べたように,
3951 もし\Param{kanjiskip}が \cs{maxdimen} の値ならば,このフィールドで指定された
3952 値が実際には用いられる(指定なしは0\,ptとして扱われる).<stretch>と<shrink>のフィールドもdesign-size
3953 が単位であることに注意せよ.
3954 %</ja>
3955
3956 \item[xkanjiskip=\{<natural>, <stretch>, <shrink>\}]
3957 %<en>(optional)
3958 %<ja>(任意)
3959
3960 %<*en>
3961 Like the \texttt{kanjiskip} field, this field specifies the ``ideal''
3962              amount of \Param{xkanjiskip}.
3963 %</en>
3964 %<*ja>
3965 \texttt{kanjiskip}フィールドと同様に,\Param{xkanjiskip}の理想的な量を
3966 指定する.
3967 %</ja>
3968 \end{cslist}
3969
3970 %<*en>
3971 \paragraph{Character classes}
3972 Besides from above fields, a JFM file have several sub-tables those
3973 indices are natural numbers.  The table indexed by~$i\in\omega$ stores
3974 information of \emph{character class}~$i$. At least, the character class~0 is
3975 always present, so each JFM file must have a sub-table whose index is
3976 \texttt{[0]}.  Each sub-table (its numerical index is denoted by $i$) has
3977 the following fields:
3978 %</en>
3979 %<*ja>
3980 \paragraph{文字クラス}
3981 上記のフィールドに加えて,JFMファイルはそのインデックスが自然数であるいくつかの
3982 サブテーブルを持つ.インデックスが$i\in\omega$であるテーブルは\emph{文字クラス}$i$の
3983 情報を格納する.少なくとも,文字クラス0は常に存在するので,JFMファイルはインデックス
3984 が\texttt{[0]}のサブテーブルを持たなければならない.それぞれのサブテーブル
3985 (そのインデックスを$i$で表わす)は以下のフィールドを持つ:
3986 %</ja>
3987
3988 \begin{cslist}[style=standard]
3989 \item[chars=\{<character>, ...\}]
3990 %<en>(required except character class~0)
3991 %<ja>(文字クラス0を除いて必須)
3992
3993 %<*en>
3994 This field is a list of characters which are in this character
3995              type~$i$. This field is optional if $i=0$, since all
3996              \textbf{JAchar} which do not belong  any character classes other
3997              than 0 are in the character class 0
3998              (hence, the character class~0 contains most of
3999              \textbf{JAchar}s). In the list, character(s) can be specified in the following form:
4000 \begin{itemize}
4001 \item a Unicode code point
4002 \item the character itself (as a Lua string, like \hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ'+})
4003 \item a string like \hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ*'+} (the character followed by an asterisk)
4004 \item several ``imaginary'' characters (We will describe these later.)
4005 \end{itemize}
4006 %</en>
4007 %<*ja>
4008 このフィールドは文字クラス$i$に属する文字のリストである.このフィールドは$i=0$の
4009 場合には任意である(文字クラス0には,0以外の文字クラスに属するものを
4010 除いた全ての\textbf{JAchar}が属するから).このリスト中で文字を指定するには,以下の方法がある:
4011 \begin{itemize}
4012 \item Unicode におけるコード番号
4013 \item 「\hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ'+}」のような,文字それ自体
4014 \item 「\hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ*'+}」のような,文字それ自体の後にアスタリスクをつけたもの
4015 \item いくつかの「仮想的な文字」(後に説明する)
4016 \end{itemize}
4017 %</ja>
4018
4019 \item[width=<length>, height=<length>, depth=<length>, italic=<length>]
4020 %<en>(required)
4021 %<ja>(必須)
4022
4023 %<*en>
4024 Specify the width of characters in character class~$i$, the height, the depth and
4025 the amount of italic correction. All characters in character class~$i$ are regarded that its width, height, and depth are
4026 as values of these fields.
4027
4028 But there is one exception: \texttt{width} field can be \texttt{'prop'}.
4029 This means that width of a character becomes that of its ``real'' glyph.
4030 %</en>
4031 %<*ja>
4032 文字クラス$i$に属する文字の幅,高さ,深さ,イタリック補正の量を指定する.
4033 文字クラス$i$に属する全ての文字は,その幅,高さ,深さがこのフィールドで指定した
4034 値であるものとして扱われる.
4035
4036 例外として,\emph{\texttt{width} フィールドには数値以外に \texttt{'prop'} が指定可能である}.
4037 この場合,文字の幅はその「実際の」グリフの幅となる.OpenTypeの \texttt{prop} featureと併用
4038              すれば,これによってプロポーショナル組を行うことができる.
4039 %</ja>
4040
4041 \item[left=<length>, down=<length>, align=<align>]\
4042
4043 %<*en>
4044 These fields are for adjusting the position of the ``real'' glyph. Legal
4045              values of \texttt{align} field are \texttt{'left'},
4046              \texttt{'middle'}, and \texttt{'right'}. If one of these
4047              3~fields are omitted, \texttt{left} and \texttt{down} are
4048              treated as~0, and \texttt{align} field is treated as
4049              \texttt{'left'}.
4050 The effects of these 3~fields are indicated in
4051 Figures \ref{fig-pos}~and~\ref{fig-pos-tate}.
4052 %</en>
4053 %<*ja>
4054 これらのフィールドは実際のグリフの位置を調整するためにある.
4055 \texttt{align} フィールドに指定できる値は \texttt{'left'}, \texttt{'middle'},
4056 \texttt{'right'} のいずれかである.もしこれら3つのフィールドのうちの1つが省かれた
4057 場合,\texttt{left} と \texttt{down} は0,\texttt{align} フィールドは
4058 \ \texttt{'left'} であるものとして扱われる.
4059 これら3つのフィールドの意味については図\ref{fig-pos}(横組用和文フォント),
4060 図\ref{fig-pos-tate}(縦組用和文フォント)で説明する.
4061 %</ja>
4062
4063 %<*en>
4064 In most cases, \texttt{left} and \texttt{down} fields are~0, while
4065 it is not uncommon that the \texttt{align} field is \texttt{'middle'} or \texttt{'right'}.
4066 For example, setting the \texttt{align} field to \texttt{'right'} is practically needed
4067 when the current character class is the class for opening delimiters'.
4068 %</en>
4069 %<*ja>
4070 多くの場合,\texttt{left}と\texttt{down}は0である一方,
4071 \texttt{align}フィールドが\texttt{'middle'}や\texttt{'right'}であることは
4072 珍しいことではない.
4073 例えば,\texttt{align}フィールドを\texttt{'right'}に指定することは,
4074 文字クラスが開き括弧類であるときに実際必要である.
4075 %</ja>
4076
4077 \begin{figure}[!tb]
4078 \begin{minipage}{0.4\textwidth}%
4079 \begin{center}\unitlength=10pt\small
4080 \begin{picture}(15,12)(-1,-4)
4081 \color{b_gray}% jfm
4082 \put(0,0){\vrule width 12\unitlength height 8\unitlength depth 3\unitlength}
4083
4084 \color{b_pink}% step1
4085 \put(-1,-1.5){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
4086
4087 \color{red}% real glyph
4088 \thicklines
4089 \put(-1,-1.5){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
4090 \put(5,-1.5){\line(0,1){7}\line(0,-1){2.5}}
4091 \put(-1,5.5){\line(1,0){6}}
4092 \put(-1,-4){\line(1,0){6}}
4093
4094 \color{b_green}% real glyph
4095 \put(3,0){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
4096
4097 \color{black}% jfm
4098 \thicklines
4099 \put(0,0){\vector(0,1){8}\line(0,-1){3}\vector(1,0){12}}
4100 \put(12,0){\line(0,1){8}\vector(0,-1){3}}
4101 \put(0,8){\line(1,0){12}}
4102 \put(0,-3){\line(1,0){12}}
4103 \put(0.2,4){\makebox(0,0)[l]{\texttt{height}}}
4104 \put(12.2,-1.5){\makebox(0,0)[l]{\texttt{depth}}}
4105 \put(6,0.2){\makebox(0,0)[b]{\texttt{width}}}
4106
4107 \color{green}% step1
4108 \thicklines
4109 \put(3,0){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
4110 \put(9,0){\line(0,1){7}\line(0,-1){2.5}}
4111 \put(3,7){\line(1,0){6}}
4112 \put(3,-2.5){\line(1,0){6}}
4113 \newsavebox{\eqdist}
4114 \savebox{\eqdist}(0,0)[b]{%
4115   \thinlines
4116   \put(-0.08,0.2){\line(0,-1){0.4}}%
4117   \put(0.08,0.2){\line(0,-1){0.4}}}
4118 \put(1.5,0){\usebox{\eqdist}}
4119 \put(10.5,0){\usebox{\eqdist}}
4120
4121 \color{blue}% shifted
4122 \thicklines
4123 \put(3,-1.5){\vector(-1,0){4}}
4124 \put(1,-1.7){\makebox(0,0)[t]{\texttt{left}}}
4125 \put(3,0){\vector(0,-1){1.5}}
4126 \put(3.2,-0.75){\makebox(0,0)[l]{\texttt{down}}}
4127 \end{picture}
4128 \end{center}
4129 \end{minipage}%
4130 \begin{minipage}{0.6\textwidth}%
4131 %<*en>
4132 Consider a  Japanese character node which belongs to
4133 a character class whose the \texttt{align}
4134 field is \texttt{'middle'}.
4135 %</en>
4136 %<*ja>
4137 \texttt{align}フィールドの値が \texttt{'middle'} であるような文字クラスに属する
4138 和文文字ノードを考えよう.
4139 %</ja>
4140 \begin{itemize}
4141 \item
4142 %<*en>
4143 The black rectangle is the imaginary body of the node.
4144 Its width, height, and depth are specified by JFM.
4145 %</en>
4146 %<*ja>
4147 黒色の長方形はノードの枠であり,
4148 その幅,高さ,深さはJFMによって指定されている.
4149 %</ja>
4150 \item
4151 %<*en>
4152 Since the \texttt{align} field is \texttt{'middle'},
4153 the ``real'' glyph is centered horizontally (the green rectangle) first.
4154 %</en>
4155 %<*ja>
4156 \texttt{align}フィールドは \texttt{'middle'} なので,
4157 実際のグリフの位置はまず水平方向に中央揃えしたものとなる(緑色の長方形).
4158 %</ja>
4159 \item
4160 %<*en>
4161 Furthermore, the glyph is shifted according to values of fields
4162       \texttt{left} and \texttt{down}. The ultimate position of the real
4163       glyph is indicated by the red rectangle.
4164 %</en>
4165 %<*ja>
4166 さらに,グリフは \texttt{left} と \texttt{down} の値に従ってシフトされる.
4167 最終的な実際のグリフの位置は赤色の長方形で示された位置になる.
4168 %</ja>
4169 \end{itemize}
4170 \end{minipage}
4171 \medskip
4172
4173 \caption{%
4174 %<en>The position of the real glyph (horizontal Japanese fonts)
4175 %<ja>横組和文フォントにおける「実際の」グリフの位置
4176 }
4177 \label{fig-pos}
4178 \end{figure}
4179 \begin{figure}[!tb]
4180 \begin{minipage}{0.4\textwidth}%
4181 \begin{center}\unitlength=10pt\small
4182 \begin{picture}(15,12)(-6,0)
4183 \color{b_gray}% jfm
4184 \put(-6,0){\vrule width 12\unitlength height 11\unitlength}
4185
4186 \color{b_pink}% real glyph
4187 \put(-6.5,5.5){\vrule width 8\unitlength height 6\unitlength depth 3\unitlength}
4188
4189 \color{red}% real glyph
4190 \thicklines
4191 \put(-6.5,5.5){\vector(0,1){6}\vector(0,-1){3}\vector(1,0){8}}
4192 \put( 1.5,5.5){\line(0,1){6}\line(0,-1){3}}
4193 \put(-6.5,11.5){\line(1,0){8}}
4194 \put(-6.5,2.5){\line(1,0){8}}
4195
4196 \color{b_green}% step1
4197 \put(-4,3){\vrule width 8\unitlength height 6\unitlength depth 3\unitlength}
4198
4199 \color{black}% jfm
4200 \thicklines
4201 \put(0,11){\vector(1,0){6}\vector(-1,0){6}\vector(0,-1){11}}
4202 \put(0,0){\line(1,0){6}\line(-1,0){6}}
4203 \put(-6,0){\line(0,1){11}}
4204 \put( 6,0){\line(0,1){11}}
4205 \put( 3,10.8){\makebox(0,0)[t]{\texttt{height}}}
4206 \put(-3,10.8){\makebox(0,0)[t]{\texttt{depth}}}
4207 \put(0.2,5.5){\makebox(0,0)[l]{\texttt{width}}}
4208
4209 \color{green}% step1
4210 \thicklines
4211 \put(-4,3){\vector(0,1){6}\vector(0,-1){3}\vector(1,0){8}}
4212 \put( 4,3){\line(0,1){6}\line(0,-1){3}}
4213 \put(-4,9){\line(1,0){8}}
4214 \put(-4,0){\line(1,0){8}}
4215 \savebox{\eqdist}(0,0)[b]{%
4216   \thinlines
4217   \put(-0.08,0.2){\line(0,-1){0.4}}%
4218   \put(0.08,0.2){\line(0,-1){0.4}}}
4219 \put(2,9){\usebox{\eqdist}}
4220 \put(-2,9){\usebox{\eqdist}}
4221
4222
4223 \color{blue}% shifted
4224 \thicklines
4225 \put(-4,3){\vector(0,1){2.5}}
4226 \put(-3.8,4.25){\makebox(0,0)[l]{\texttt{left}}}
4227 \put(-4,5.5){\vector(-1,0){2.5}}
4228 \put(-5.,5.7){\makebox(0,0)[b]{\texttt{down}}}
4229 \end{picture}
4230 \end{center}
4231 \end{minipage}%
4232 \begin{minipage}{0.6\textwidth}%
4233 %<*en>
4234 (\dots)
4235 %</en>
4236 %<*ja>
4237 \texttt{align}フィールドの値が \texttt{'right'} であるような文字クラスに属する
4238 和文文字を考えよう.
4239 \begin{itemize}
4240 \item
4241 実際のグリフの「垂直位置」は,まずベースラインが文字の物理的な左右方向の中央を通る
4242 位置となる.
4243 \item
4244 また,この場合 \texttt{align} フィールドは \texttt{'right'} なので,
4245 「水平位置」は字送り方向に「右寄せ」したものとなる(緑色の長方形).
4246 \item
4247 その後さらに \texttt{left} と \texttt{down} の値に従ってシフトされる
4248 のは横組用和文フォントと変わらない.
4249 \end{itemize}
4250 %</ja>
4251 \end{minipage}
4252 \medskip
4253
4254 \caption{%
4255 %<en>The position of the real glyph (vertical Japanese fonts)
4256 %<ja>縦組和文フォントにおける「実際の」グリフの位置
4257 }
4258 \label{fig-pos-tate}
4259 \end{figure}
4260
4261 \item[kern={\{[$j$]=<kern>, [$j'$]=\{<kern>, [<ratio>]\}, ...\}}]
4262
4263 \item[glue={\{[$j$]=\{<width>, <stretch>, <shrink>, [<priority>], [<ratio>]\}, ...\}}]\
4264 %<*ja>
4265
4266 文字クラス$i$の文字と$j$の文字の間に挿入されるkernやglueの量を指定する.
4267
4268              <priority>は \Pkg{luatexja-adjust} による優先順位付き
4269              行長調整(\ref{ssec-adj}節)が有効なときのみ意味を持つ.
4270 このフィールドは省略可能であり,行調整処理におけるこのglueの優先
4271              度を$-2$から$+2$の間の整数で指定する.大きい値ほど「伸びやすく,縮みやすい」
4272              ことを意味する.省略時の値
4273              は0であり,範囲外の値が指定されたときの動作は未定義である.
4274
4275 <ratio>も省略可能フィールドであり,$-1$から$+1$の実数値をとる.省略時の値は0である.
4276 \begin{itemize}
4277 \item $-1$はこのグルーが「前の文字」由来であることを示す.
4278 \item $+1$はこのグルーが「後の文字」由来であることを示す.
4279 \item それ以外の値は,「前の文字」由来のグルーと「後の文字」由来の
4280 グルーが混合されていることを示す.
4281 \end{itemize}
4282 なお,このフィールドの値は\Param{differentjfm}の値が
4283 \texttt{pleft},~\texttt{pright},~\texttt{paverage}の値のときのみ実際に用いられる.
4284
4285 例えば,\cite{x4051}では,句点と中点の間には,
4286 句点由来の二分空きと中点由来の四分空きが挿入されるが,この場合には
4287 \begin{itemize}
4288 \item <width>には$0.5+0.25=0.75$を指定する.
4289 \item <ratio>には次の値を指定する.
4290 \[
4291  -1\cdot \frac{0.5}{0.5+0.25} + 1 \cdot \frac{0.25}{0.5+0.25} = -\frac13
4292 \]
4293 \end{itemize}
4294 %</ja>
4295 %<*en>
4296 \
4297
4298 Specifies the width of kern or glue which will be inserted
4299 between characters in character class~$i$ and those in character class~$j$.
4300
4301 <priority> is an integer in $[-2,2]$ (treated as 0 if omitted), and this is
4302 used only in line adjustment with priority by \Pkg{luatexja-adjust}
4303 (see Subsection~\ref{ssec-adj}). Higher value means the glue is easy to shretch,
4304 and is also easy to shrink.
4305
4306 <ratio> is also an optional value between $-1$ and 1. For example,
4307 The width of a glue between an ideographic full stop ``。''
4308 and a fullwidth middle dot ``・'' is three-fourth of fullwidth,
4309 namely halfwidth from the ideographic full stop, and
4310 quarter-width from the fullwidth middle dot.  In this case,
4311 we specify <ratio> to
4312 \[
4313   -1\cdot \frac{0.5}{0.5+0.25} + 1 \cdot \frac{0.25}{0.5+0.25} = -\frac13.
4314 \]
4315 %</en>
4316
4317
4318 \item[end\_stretch=<kern>, end\_shrink=<kern>]
4319 %<*ja>
4320 (任意)
4321
4322 優先順位付き行長調整が有効であり,かつ現在の文字クラスの文字が行
4323              末に来た時に,行長を詰める調整・伸ばす調整のた
4324              めにこの文字と行末の間に挿入可能なカーンの大きさを指定する.
4325 %</ja>
4326
4327 \end{cslist}
4328
4329 %<*ja>
4330 \paragraph{文字クラスの決定}
4331 文字からその文字の属する文字クラスを算出する過程について,
4332 次の内容を含んだ \texttt{jfm-test.lua} を用いて説明する.
4333 %</ja>
4334 %<*en>
4335 \paragraph{Character to character classes}
4336 We explain how the character class of a character is determined,
4337 using  \texttt{jfm-test.lua} which contains the following:
4338 %</en>
4339 \begin{lstlisting}
4340    [0] = {
4341       chars = { '漢' },
4342       align = 'left', left = 0.0, down = 0.0,
4343       width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
4344    },
4345    [2000] = {
4346       chars = { '。', 'ヒ' },
4347       align = 'left', left = 0.0, down = 0.0,
4348       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
4349    },
4350 \end{lstlisting}
4351 %<ja>ここで,次のような入力とその実行結果を考える:
4352 %<en>Now consider the following input/output:
4353 \begin{LTXexample}[width=0.3\textwidth]
4354 \jfont\a=file:KozMinPr6N-Regular.otf:jfm=test;+hwid
4355 \setbox0\hbox{\a ヒ漢}
4356 \the\wd0
4357 \end{LTXexample}
4358 %<*en>
4359 Now we look why the above source outputs 15\,pt.
4360 \begin{enumerate}
4361 \item The character ``ヒ'' is converted to its half width  form ``ヒ'' by \verb+hwid+ feature.
4362 \item According to the JFM, the character class of ``ヒ'' is 2000, hence its width is halfwidth.
4363 \item The character class of ``漢'' is zero,  hence its width is fullwidth.
4364 \item Hence the width of \cs{hbox} equals to 15\,pt.
4365 \end{enumerate}
4366 This example shows that the character class of a character is generally determined \emph{after
4367 applying font features by \Pkg{luaotfload}}.
4368 %</en>
4369 %<*ja>
4370 上記の出力結果が,15\,ptとなっているのは理由によるものである:
4371 \begin{enumerate}
4372 \item \verb+hwid+ featureによって「ヒ」が半角幅のグリフ「ヒ」と置き換わる(\Pkg{luaotfload} による処理).
4373 \item JFMによれば,この「ヒ」のグリフの文字クラスは2000である.
4374 \item 以上により文字クラス2000とみなされるため,結果として「ヒ」の幅は半角だと認識される.
4375 \end{enumerate}
4376 この例は,\emph{文字クラスの決定はfont featureの適用によるグリフ置換の結果に基づく}ことを
4377 示している.
4378 %</ja>
4379
4380 %<*en>
4381 However, if the class determined by the glyph after application of features is zero,
4382 \LuaTeX-ja adopts the class determined by the glyph \emph{before} application of features.
4383 The following input is an example.
4384 %</en>
4385 %<*ja>
4386 但し,JFMによって決まる置換後のグリフの文字クラスが0である場合は,置換前の文字クラスを採用する.
4387 %</ja>
4388 \begin{LTXexample}[width=0.3\textwidth]
4389 \jfont\a=file:KozMinPr6N-Regular.otf:jfm=test;+vert
4390 \a 漢。\inhibitglue 漢
4391 \end{LTXexample}
4392 %<*en>
4393 Here, the character class of the ideographic full stop ``。''~(\texttt{U+3002}) is determined
4394 as follows:
4395 \begin{enumerate}
4396 \item As the case of ``ヒ'', the ideographic full stop ``。'' is converted to its vertical
4397       form ``\char"FE12''~(\texttt{U+FE12}) by \verb+vert+ feature.%"
4398 \item The character class of ``\char"FE12'', according to the JFM  is \emph{zero}.
4399 \item However, \LuaTeX-ja remembers that this ``\char"FE12'' is obtained from ``。'' by
4400       font features. The character class of ``。'' is \emph{non-zero value}, namely, 2000.
4401 \item Hence the ideographic full stop ``。'' in above belongs the character class~2000.
4402 \end{enumerate}
4403 %</en>
4404 %<*ja>
4405 ここで,句点「。」(\texttt{U+3002})の文字クラスは,以下のようにして決まる.
4406 \begin{enumerate}
4407 \item \Pkg{luaotfload} によって縦組用句点のグリフに置き換わる.
4408 \item 置換後のグリフは \texttt{U+FE12} であり,JFMに従えば文字クラスは\emph{0}と判定される.
4409 \item この場合,置換前の横組用句点のグリフによって文字クラスを判定する.
4410 \item 結果として,上の出力例中の句点の文字クラスは2000となる.
4411 \end{enumerate}
4412 %</ja>
4413
4414
4415 %<ja>\paragraph{仮想的な文字}
4416 %<en>\paragraph{Imaginary characters}
4417 %<*en>
4418 As described before, you can specify several \emph{imaginary characters} in
4419 \texttt{chars} field. The most of these characters are regarded as the
4420 characters of class 0 in \pTeX.
4421 As a result, \LuaTeX-ja can control typesetting finer than \pTeX.
4422 The following is the list of imaginary characters:
4423 %</en>
4424 %<*ja>
4425 上で説明した通り,\texttt{chars}フィールド中にはいくつかの「特殊文字」も
4426 指定可能である.これらは,大半が\pTeX のJFMグルーの挿入処理ではみな「文字
4427 クラス0の文字」として扱われていた文字であり,その結果として\pTeX より細か
4428 い組版調整ができるようになっている.以下でその一覧を述べる:
4429 %</ja>
4430
4431 \begin{cslist}
4432 %%\item['diffmet']
4433 %%<en>Used at a boundary between two \textbf{JAchar}s whose JFM or size is different.
4434 %%<ja>JFMやサイズが異なる2つの\textbf{JAchar}の間の境界として用いられる.
4435
4436 \item['boxbdd']
4437 %<en>The beginning/ending of a hbox, and the beginning of a noindented (i.e., began by \cs{noindent}) paragraph.
4438 %<ja>hboxの先頭と末尾,及びインデントされていない(\cs{noindent} で開始された)段落の先頭を表す.
4439
4440 \item['parbdd']
4441 %<en>The beginning of an (indented) paragraph.
4442 %<ja>通常の(\cs{noindent} で開始されていない)段落の先頭.
4443
4444 \item['jcharbdd']
4445 %<en>A boundary between \textbf{JAchar} and anything else (such as \textbf{ALchar}, kern, glue,\,\ldots).
4446 %<ja>\textbf{JAchar}と「その他のもの」(欧文文字,glue,kern等)との境界.
4447
4448 \item[$-1$]
4449 %<en>The left/right boundary of an inline math formula.
4450 %<ja>行中数式と地の文との境界.
4451 \end{cslist}
4452
4453 %<en>\paragraph{Porting JFM from \pTeX}
4454 %<ja>\paragraph{\pTeX 用和文用TFMの移植}
4455
4456 % ToDo: English version.
4457
4458 %<*en>
4459 See Japanese version of this manual.
4460 %</en>
4461
4462 %<*ja>
4463 以下に,\pTeX 用に作られた和文用TFMを\LuaTeX-ja用に移植する場合の注意点を挙げておく.
4464 \begin{itemize}
4465 \item 実際に出力される和文フォントのサイズがdesign sizeとなる.
4466 このため,例えば$1\,\textrm{zw}$がdesign sizeの0.962216倍であるJISフォン
4467       トメトリック等を移植する場合は,次のようにするべきである:
4468 \begin{itemize}
4469 \item JFM中の全ての数値を$1/0.962216$倍しておく.
4470 \item \TeX ソース中で使用するところで,サイズ指定を0.962216倍にする.
4471       \LaTeX でのフォント宣言なら,例えば次のように:
4472 \begin{lstlisting}
4473 \DeclareFontShape{JY3}{mc}{m}{n}{<-> s*[0.962216] psft:Ryumin-Light:jfm=jis}{}
4474 \end{lstlisting}
4475 \end{itemize}
4476 \item 上に述べた特殊文字は,\texttt{'boxbdd'}を除き文字クラスを全部0とする
4477       (JFM中に単に書かなければよい).
4478 \item \texttt{'boxbdd'}については,それのみで一つの文字クラスを形成し,その
4479       文字クラスに関してはグルー/カーンの設定はしない.
4480
4481 これは,\pTeX では,
4482       hboxの先頭・末尾とインデントされていない(\cs{noindent} で開始さ
4483       れた)段落の先頭にはJFMグルーは入らないという仕様を実現させるためである.
4484 \item \pTeX の組版を再現させようというのが目的であれば以上の注意を守れば十分である.
4485
4486 ところで,\pTeX では通常の段落の先頭にJFMグルーが残るという仕様があるので,
4487       段落先頭の開き括弧は全角二分下がりになる.全角下がりを実現させるに
4488       は,段落の最初に手動で \cs{inhibitglue} を追加するか,あるいは
4489       \ \cs{everypar} のハックを行い,それを自動化させるしかなかった.
4490
4491 一方,\LuaTeX-jaでは,\texttt{'parbdd'}によって,それがJFM側で調整できるよ
4492 うになった.例えば,\LuaTeX-ja同梱のJFMのように,\texttt{'boxbdd'}と同じ文字クラスに
4493 \texttt{'parbdd'}を入れれば全角下がりとなる.
4494
4495 \begin{LTXexample}[width=0.4\textwidth]
4496 \jfont\g=KozMinPr6N-Regular:jfm=test \g
4497 \parindent1\zw\noindent{}◆◆◆◆◆
4498 \par 「◆◆←二分下がり
4499 \par 【◆◆←全角下がり
4500 \par 〔◆◆←全角二分下がり
4501 \end{LTXexample}
4502 \end{itemize}
4503
4504 但し,\cs{everypar} を利用している場合にはこの仕組みは正しく動かない.
4505 そのような例としては箇条書き中の \cs{item} で始まる段落があり,\Pkg{ltjsclasses}では
4506 人工的に「\texttt{'parbdd'}の意味を持つ」whatsitノードを作ることによって対処している%
4507 \footnote{\texttt{ltjsclasses.dtx} を参照されたい.
4508 JFM側で一部の対処ができることにより,\Pkg{jsclasses}のようにif文の判定はしていない.}.
4509 %</ja>
4510
4511
4512 %<en>\subsection{Math Font Family}
4513 %<ja>\subsection{数式フォントファミリ}
4514 \label{ssec-math}
4515
4516 %<*en>
4517 \TeX\ handles fonts in math formulas by 16~font families\footnote{Omega,
4518 Aleph, \LuaTeX~and $\varepsilon$-\kern-.125em(u)\pTeX\ can handles 256~families, but
4519 an external package is needed to support this in plain \TeX\ and
4520 \LaTeX.}, and each family has three fonts:
4521 \cs{textfont}, \cs{scriptfont} and \cs{scriptscriptfont}.
4522 %</en>
4523 %<*ja>
4524 \TeX\ は数式フォントを16のファミリ\footnote{Omega, Aleph, \LuaTeX,そして
4525   $\varepsilon$-\kern-.125em(u)\pTeX\ では256の数式ファミリを扱うことができるが,
4526   これをサポートするためにplain \TeX と\LaTeX では外部パッケージを読み込む必要が
4527   ある.}で管理し,それぞれのファミリは3つのフォントを持っている:
4528 \cs{textfont}, \cs{scriptfont} そして \cs{scriptscriptfont} である.
4529 %</ja>
4530
4531 %<*en>
4532 \LuaTeX-ja's handling of Japanese fonts in math formulas is similar;
4533 Table~\ref{tab-math} shows counterparts to \TeX's primitives for math
4534 font families. There is no relation between the value of
4535 \cs{fam} and that of \cs{jfam}; with appropriate settings,
4536 you can set both \cs{fam} and \cs{jfam} to the same value.
4537 Here <jfont\_cs> in the argument of \Param{jatextfont} etc.\ is
4538 a control sequence which is defined by \cs{jfont}, i.e.,
4539 a \emph{horizontal} Japanese font.
4540 %</en>
4541 %<*ja>
4542 \LuaTeX-jaの数式中での和文フォントの扱いも同様である.
4543 表\ref{tab-math}は数式フォントファミリに対する \TeX のプリミティブと対応する
4544 ものを示している.\cs{fam} と \cs{jfam} の値の間には関係はなく,
4545 適切な設定の下では \cs{fam} と \cs{jfam} の両方に同じ値を設定することができる.
4546 \Param{jatextfont} 他の第2引数<jfont\_cs>は,\cs{jfont} で定義された
4547 \emph{横組用}和文フォントである.\cs{tfont} で定義された
4548 \emph{縦組用}和文フォントを指定することは想定していない.
4549 %</ja>
4550
4551 \begin{table}[!tb]
4552 %<en>\caption{Commands for Japanese math fonts}
4553 %<ja>\caption{和文数式フォントに対する命令}
4554 \label{tab-math}
4555 %<en>\medskip
4556 \centering
4557 \def\{{\char`\{}\def\}{\char`\}}\small
4558 \begin{tabular}{ll}
4559 \toprule
4560 %<en>\bf Japanese fonts&\bf alphabetic fonts\\
4561 %<ja>\bf 和文フォント&\bf 欧文フォント\\
4562 \midrule
4563 \cs{jfam}${}\in [0,256)$&\cs{fam}\\
4564 \tt\Param{jatextfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\cs{textfont}<fam>=<font\_cs>\\
4565 \tt\Param{jascriptfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\cs{scriptfont}<fam>=<font\_cs>\\
4566 \tt\Param{jascriptscriptfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\cs{scriptscriptfont}<fam>=<font\_cs>\\
4567 \bottomrule
4568 \end{tabular}
4569 \end{table}
4570
4571 %<en>\subsection{Callbacks}
4572 %<ja>\subsection{コールバック}
4573
4574 %<*en>
4575 \LuaTeX-ja also has several callbacks. These callbacks can
4576 be accessed via \verb+luatexbase.add_to_callback+ function and so on, as other callbacks.
4577 %</en>
4578 %<*ja>
4579 \LuaTeX 自体のものに加えて,\LuaTeX-jaもコールバックを持っている.
4580 これらのコールバックには,他のコールバックと同様に \verb+luatexbase.add_to_callback+
4581 関数などを用いることでアクセスすることができる.
4582 %</ja>
4583 \begin{description}[font=\bfseries, style=nextline]
4584 %<en>\item[\texttt{luatexja.load\_jfm} callback]
4585 %<ja>\item[\texttt{luatexja.load\_jfm}コールバック]
4586 %<*en>
4587 With this callback you can overwrite JFMs.
4588 This callback is called when a new JFM is loaded.
4589 %</en>
4590 %<*ja>
4591 このコールバックを用いることでJFMを上書きすることができる.
4592 このコールバックは新しいJFMが読み込まれるときに呼び出される.
4593 %</ja>
4594
4595 \begin{lstlisting}[numbers=left]
4596 function (<table> jfm_info, <string> jfm_name)
4597   return <table> new_jfm_info
4598 end
4599 \end{lstlisting}
4600
4601 %<*en>
4602 The argument \verb+jfm_info+ contains a table similar to the table in a JFM file, except
4603 this argument has \texttt{chars} field which contains character codes
4604              whose character class is not~0.
4605 %</en>
4606 %<*ja>
4607 引数 \verb+jfm_info+ はJFMファイルのテーブルと似たものが格納されるが,
4608 クラス0を除いた文字のコードを含んだ\texttt{chars}フィールドを持つ点が異なる.
4609 %</ja>
4610
4611 %<*en>
4612 An example of this callback is the \texttt{ltjarticle} class, with
4613              forcefully assigning character class~0 to \texttt{'parbdd'}
4614              in the JFM \texttt{jfm-min.lua}.
4615 %</en>
4616 %<*ja>
4617 このコールバックの使用例は\texttt{ltjarticle}クラスにあり,
4618 \texttt{jfm-min.lua}中の\texttt{'parbdd'}を強制的にクラス0に割り当てている.
4619 %</ja>
4620
4621 %<en>\item[\texttt{luatexja.define\_jfont} callback]
4622 %<ja>\item[\texttt{luatexja.define\_jfont}コールバック]
4623 %<*en>
4624 This callback and the next callback form a pair, and you can assign characters
4625  which do not have fixed code points in Unicode to non-zero character classes.
4626 This \texttt{luatexja.define\_font} callback is called just when new Japanese font is loaded.
4627 %</en>
4628 %<*ja>
4629 このコールバックと次のコールバックは組をなしており,Unicode中に固定された文字コード
4630 番号を持たない文字を非零の文字クラスに割り当てることができる.
4631 このコールバックは新しい和文フォントが読み込まれたときに呼び出される.
4632 %</ja>
4633
4634 \begin{lstlisting}[numbers=left]
4635 function (<table> jfont_info, <number> font_number)
4636   return <table> new_jfont_info
4637 end
4638 \end{lstlisting}
4639 %<*en>
4640 \verb+jfont_info+ has the following fields,
4641 \emph{which may not overwritten by a user}:
4642 \begin{description}
4643 \item[\texttt{size}]
4644 The font size specified at \cs{jfont} in scaled points ($1\,\mathrm{sp}=2^{-16}\,\mathrm{pt}$).
4645 \item[\texttt{zw}, \texttt{zh}, \texttt{kanjiskip}, \texttt{xkanjiskip}]
4646 These are scaled value of those specified by the JFM, by the font size.
4647 \item[\texttt{jfm}]
4648 The internal number of the JFM.
4649 \item[\texttt{var}]
4650 The value of \texttt{jfmvar}~key, which is specified at \cs{jfont}.
4651 The default value is the empty string.
4652 \item[\texttt{chars}]
4653 The mapping table from character codes to its character classes.\\
4654 The specification \texttt{[i].chars=\{<character>, ...\}} in the JFM will be  stored in this
4655            field as \texttt{chars=\{[<character>]=\,$i$, ...\}}.
4656 \item[\texttt{char\_type}]
4657 For $i\in\omega$, \texttt{char\_type[$i$]} is information of characters whose class is
4658            $i$, and has the following fields:
4659 \begin{itemize}
4660  \item \texttt{width},~\texttt{height}, \texttt{depth},
4661   \texttt{italic}, \texttt{down},~\texttt{left}\ are just
4662        scaled value of those specified by the JFM, by the font size.
4663  \item \texttt{align} is a number which is determined from \texttt{align}~field in the JFM:
4664 \[
4665  \begin{cases}
4666   0&\text{\texttt{'left'} (default)}\\0.5&\text{\tt 'middle'}\\1&\text{\tt 'right'}
4667  \end{cases}
4668 \]
4669 \item For $j\in \omega$, \texttt{[$j$]} stores a kern or a glue which will be inserted
4670 between character class~$i$ and class~$j$.
4671
4672 If a kern will be inserted, the value of this field is \texttt{[$j$]=\{false, <kern\_node>, <ratio>\}},
4673 where <kern\_node> is a node\footnote{%
4674  This version of \LuaTeX-ja uses ``direct access
4675       model'' for accessing nodes, if possible. }.
4676 If a glue will be inserted, we have \texttt{[$j$]=\{false, <spec\_node>, <ratio>, <icflag>\}},
4677 where <spec\_node> is also a node, and $\text{<icflag>}=\textit{from\_jfm}+\text{<priority>}$.
4678 \end{itemize}
4679 \end{description}
4680 %</en>
4681 %<*ja>
4682 \verb+jfont_info+ は最低限以下のフィールドを持つが,これらを書き換えてはならない:
4683 \begin{cslist}
4684 \item[size]
4685 実際に使われるフォントサイズ(sp単位).$1\,\mathrm{sp}=2^{-16}\,\mathrm{pt}$.
4686 \item[zw\textrm{, }zh\textrm{, }kanjiskip\textrm{, }xkanjiskip]
4687 JFMファイルで指定されているそれぞれの値をフォントサイズに合わせてスケーリングしたものを
4688 sp単位で格納している.
4689 \item[jfm]
4690 利用されているJFMを識別するための番号.
4691 \item[var]
4692 \cs{jfont},~\cs{tfont} で指定された \texttt{jfmvar} キーの値(未指定のときは空文字列).
4693 \item[chars]
4694 文字コードから文字クラスへの対応が記述されたテーブル.\\
4695 JFM内の \texttt{[i].chars=\{<character>, ...\}} という指定は\
4696 \texttt{chars=\{[<character>]=\,$i$, ...\}} という形式に変換されている.
4697 \item[char\_type]
4698 $i\in\omega$に対して,\texttt{char\_type[$i$]} は文字クラス$i$の文字の寸法を格納しており,
4699 以下のフィールドを持つ.
4700 \begin{itemize}
4701  \item \texttt{width},~\texttt{height}, \texttt{depth},
4702   \texttt{italic}, \texttt{down},~\texttt{left}\ は
4703 JFMで指定されているそれぞれの値をスケーリングしたものである.
4704  \item \texttt{align} はJFMで指定されている値によって,
4705 \[
4706  \begin{cases}
4707   0&\text{\texttt{'left'}や省略時}\\0.5&\text{\tt 'middle'}\\1&\text{\tt 'right'}
4708  \end{cases}
4709 \]
4710 のいずれかの値をとる.
4711 \item $j\in \omega$に対して,\texttt{[$j$]} は文字クラス$i$の文字と$j$の文字の間に挿入されるkern
4712       やglueを格納している.
4713 間に入るものがkernであれば,このフィールドの値は\
4714 \texttt{[$j$]=\{false, <kern\_node>, <ratio>\}} である.
4715 <kern\_node>はkernを表すノードそのものである\footnote{%
4716 本バージョンではノードのアクセス手法にdirect access
4717       modelを用いている.そのため,例えば\LuaTeX\ beta-0.78.2では,単なる自然数のようにし
4718       か見えないことに注意.
4719 }.
4720 glueであれば,\texttt{[$j$]=\{false, <spec\_node>, <ratio>, <icflag>\}} である.
4721 <spec\_node>はglueの長さを表すノードそのものであり,
4722       $\text{<icflag>}=\textit{from\_jfm}+\text{<priority>}$である.
4723 \end{itemize}
4724 \item[ascent\textrm{, }descent]
4725 ……
4726 \item[chars\_cbcache]
4727 ……
4728 \end{cslist}
4729 %</ja>
4730
4731 %<*en>
4732 The returned table \verb+new_jfont_info+ also should include these fields, but
4733 you are free to add more fields (to use them in the \texttt{luatexja.find\_char\_class} callback).
4734 The \verb+font_number+ is a font number.
4735 %</en>
4736 %<*ja>
4737 戻り値の \verb+new_jfont_info+ テーブルも上に述べたフィールドをそのまま含まなければならないが,
4738 それ以外にユーザが勝手にフィールドを付け加えることは自由である.
4739 \verb+font_number+ はフォント番号である.
4740 %</ja>
4741
4742 %<*en>
4743 A good example of this and the next callbacks is the \Pkg{luatexja-otf}
4744              package, supporting \verb+"AJ1-xxx"+ form for Adobe-Japan1
4745              CID characters in a JFM. This callback doesn't replace any
4746              code of \LuaTeX-ja.
4747 %</en>
4748 %<*ja>
4749 これと次のコールバックの良い使用例は\Pkg{luatexja-otf}パッケージであり,
4750 JFM中でAdobe-Japan1 CIDの文字を \verb+"AJ1-xxx"+ の形で指定するために
4751 用いられている.
4752 %</ja>
4753
4754 %<en>\item[\texttt{luatexja.find\_char\_class} callback]
4755 %<ja>\item[\texttt{luatexja.find\_char\_class}コールバック]
4756 %<*en>
4757 This callback is called just when \LuaTeX-ja is trying to determine which
4758              character class a character \verb+chr_code+ belongs.
4759 A function used in this callback should be in the following form:
4760 %</en>
4761 %<*ja>
4762 このコールバックは\LuaTeX-jaが \verb+chr_code+ の文字がどの文字クラスに
4763 属するかを決定しようとする際に呼び出される.
4764 このコールバックで呼び出される関数は次の形をしていなければならない:
4765 %</ja>
4766 \begin{lstlisting}[numbers=left]
4767 function (<number> char_class, <table> jfont_info, <number> chr_code)
4768   if char_class~=0 then return char_class
4769   else
4770     ....
4771     return (<number> new_char_class or 0)
4772   end
4773 end
4774 \end{lstlisting}
4775
4776 %<*en>
4777 The argument \verb+char_class+ is the result of \LuaTeX-ja's default
4778              routine or previous function calls in this callback, hence
4779              this argument may not be 0. Moreover, the returned
4780              \verb+new_char_class+ should be as same as \verb+char_class+ when \verb+char_class+
4781              is not~0, otherwise you will overwrite the \LuaTeX-ja's
4782              default routine.
4783 %</en>
4784 %<*ja>
4785 引数 \verb+char_class+ は\LuaTeX-jaのデフォルトルーチンか,このコールバックの
4786 直前の関数呼び出しの結果を含んでおり,したがってこの値は0ではないかもしれない.
4787 さらに,戻り値の \verb+new_char_class+ は \verb+char_class+ が非零のときには
4788 \verb+char_class+ の値と同じであるべきで,そうでないときは\LuaTeX-jaの
4789 デフォルトルーチンを書き換えることになる.
4790 %</ja>
4791
4792 %<en>\item[\texttt{luatexja.set\_width} callback]
4793 %<ja>\item[\texttt{luatexja.set\_width}コールバック]
4794 %<*en>
4795 This callback is called when \LuaTeX-ja is trying to encapsule a
4796              \textbf{JAchar} \textit{glyph\_node}, to adjust its
4797              dimension and position.
4798 %</en>
4799 %<*ja>
4800 このコールバックは\LuaTeX-jaが\textbf{JAchar}の寸法と位置を調節するために
4801 その\textit{glyph\_node}をカプセル化しようとする際に呼び出される.
4802 %</ja>
4803 \begin{lstlisting}[numbers=left]
4804 function (<table> shift_info, <table> jfont_info, <number> char_class)
4805   return <table> new_shift_info
4806 end
4807 \end{lstlisting}
4808
4809 %<*en>
4810 The argument \verb+shift_info+ and the returned \verb+new_shift_info+ have
4811 \texttt{down} and \texttt{left} fields, which are the amount of shifting
4812              down/left the character in a scaled point.
4813 %</en>
4814 %<*ja>
4815 引数 \verb+shift_info+ と戻り値の \verb+new_shift_info+ は
4816 \texttt{down}と\texttt{left}のフィールドを持ち,これらの値は
4817 文字の下/左へのシフト量(sp単位)である.
4818 %</ja>
4819
4820 %<*en>
4821 A good example is \Pkg{test/valign.lua}.
4822 After loading this file, the vertical position of glyphs is automatically
4823 adjusted; the ratio $(\hbox{height}:\hbox{depth})$ of glyphs is adjusted
4824 to be that of letters in the character class~0. For example, suppose that
4825 \begin{itemize}
4826 \item The setting of the JFM: $(\hbox{height})=88x$, $(\hbox{depth})=12x$
4827   (the standard values of Japanese OpenType fonts);
4828 \item The value of the real font: $(\hbox{height})=28y$, $(\hbox{depth})=5y$
4829   (the standard values of Japanese TrueType fonts).
4830 \end{itemize}
4831 Then, the position of glyphs is shifted up by
4832 %</en>
4833 %<*ja>
4834 良い例が\Pkg{test/valign.lua}である.このファイルが読み込まれた状態では,
4835              JFM内で規定された文字クラス0の文字における$(\hbox{高
4836              さ}):(\hbox{深さ})$の比になるように,実際のフォントの出力上
4837              下位置が自動調整される.例えば,
4838 \begin{itemize}
4839 \item JFM側の設定:$(\hbox{高さ})=88x$, $(\hbox{深さ})=12x$%
4840 (和文OpenTypeフォントの標準値)
4841 \item 実フォント側の数値:$(\hbox{高さ})=28y$, $(\hbox{深さ})=5y$(和文TrueTypeフォントの標準値)
4842 \end{itemize}
4843 となっていたとする.すると,実際の文字の出力位置は,以下の量だけ上にぜらされることとなる:
4844 %</ja>
4845 \[
4846  \frac{88x}{88x+12x} (28y+5y) - 28y = \frac{26}{25}y= 1.04y.
4847 \]
4848 \end{description}
4849
4850
4851
4852 %<en>\section{Parameters}
4853 %<ja>\section{パラメータ}
4854 \subsection{\cs{ltjsetparameter}}
4855 \label{ssec-param}
4856
4857 %<*en>
4858 As described before, \cs{ltjsetparameter} and \cs{ltjgetparameter} are
4859 commands for accessing most parameters of \LuaTeX-ja. One of the main
4860 reason that \LuaTeX-ja didn't adopted the syntax similar to that of \pTeX\
4861 (\textit{e.g.},~\verb+\prebreakpenalty`)=10000+)
4862 is the position of \verb+hpack_filter+ callback in the source
4863 of \LuaTeX, see Section~\ref{sec-para}.
4864 %</en>
4865 %<*ja>
4866 先に述べたように,\LuaTeX-jaの内部パラメータにアクセスするには
4867 \cs{ltjsetparameter}(または \cs{ltjglobalsetparameter})と \cs{ltjgetparameter} を用いる.
4868 \LuaTeX-jaが\pTeX のような文法(例えば,\verb+\prebreakpenalty`)=10000+)を
4869 採用しない理由の一つは,\LuaTeX のソースにおける \verb+hpack_filter+
4870 コールバックの位置にある.\ref{sec-para}章を参照.
4871 %</ja>
4872
4873 %<*en>
4874 \cs{ltjsetparameter} and \cs{ltjglobalsetparameter} are commands
4875 for assigning parameters. These take one argument which is a
4876 \texttt{<key>=<value>} list.
4877 The difference between these two commands is the
4878 scope of assignment;
4879 \cs{ltjsetparameter} does a local assignment and
4880 \cs{ltjglobalsetparameter} does a global one.
4881 They also obey the value of \cs{globaldefs}, like other assignments.
4882 %</en>
4883 %<*ja>
4884 \cs{ltjsetparameter} と \cs{ltjglobalsetparameter} はパラメータを
4885 指定するための命令で,\texttt{<key>=<value>}のリストを
4886 引数としてとる.両者の違いはスコープであり,
4887 \cs{ltjsetparameter} はローカルな設定を行うのに対し,
4888 \cs{ltjglobalsetparameter} はグローバルな設定を行う.
4889 また,他のパラメータ指定と同様に \cs{globaldefs} の値にも従う.
4890 %</ja>
4891
4892 %<*en>
4893 The following is the list of parameters which can be specified by the
4894 \cs{ltjsetparameter} command. [\cs{cs}] indicates the counterpart
4895 in \pTeX, and symbols beside each parameter has the following meaning:
4896 %</en>
4897 %<*ja>
4898 以下は \cs{ltjsetparameter} に指定することができるパラメータの一覧である.
4899 [\cs{cs}]は\pTeX における対応物を示す.
4900 また,それぞれのパラメータの右上の記号には次の意味がある:
4901 %</ja>
4902 \begin{itemize}
4903 %<*en>
4904 \item ``\ast'' : values at the end of a paragraph or a hbox are
4905 adopted in the whole paragraph or the whole hbox.
4906 %</en>
4907 %<*ja>
4908 \item ``\ast'':段落やhboxの終端での値がその段落/hbox全体で用いられる.
4909 %</ja>
4910 %<*en>
4911 \item ``\dagger'': assignments are always global.
4912 %</en>
4913 %<*ja>
4914 \item ``\dagger'':指定は常にグローバルになる.
4915 %</ja>
4916 \end{itemize}
4917
4918 \begin{cslist}[style=standard]
4919 \item[\DParam{jcharwidowpenalty}\,=<penalty>$^\ast$] [\cs{jcharwidowpenalty}]\
4920
4921 %<*en>
4922 Penalty value for suppressing orphans. This penalty is inserted just
4923              after the last \textbf{JAchar} which is not regarded as a
4924              (Japanese) punctuation mark.
4925 %</en>
4926 %<*ja>
4927 パラグラフの最後の字が孤立して改行されるのを防ぐためのペナルティの値.
4928 このペナルティは(日本語の)句読点として扱われない最後の\textbf{JAchar}の直後に
4929 挿入される.
4930 %</ja>
4931
4932 \item[\DParam{kcatcode}\,=\{<chr\_code>,<natural number>\}$^\ast$]\
4933
4934 %<*en>
4935 An additional attributes which each character whose character code is <chr\_code> has.
4936 At the present version, the lowermost bit of <natural number> indicates
4937              whether the character is considered as a punctuation mark
4938              (see the description of \Param{jcharwidowpenalty} above).
4939 %</en>
4940 %<*ja>
4941 文字コードが<chr\_code>の文字が持つ付加的な属性値.
4942 現在のバージョンでは,<natural number>の最下位ビットが,その文字が句読点と
4943 みなされるかどうかを表している(上の\Param{jcharwidowpenalty}の記述を参照).
4944 %</ja>
4945
4946 \item[\DParam{prebreakpenalty}\,=\{<chr\_code>,<penalty>\}$^\ast$] [\cs{prebreakpenalty}]\
4947
4948 %<*ja>
4949 文字コード<chr\_code>の\textbf{JAchar}が行頭にくることを抑止するために,
4950              この文字の前に挿入/追加されるペナルティの量を指定する.
4951
4952 例えば閉じ括弧「〗」は絶対に行頭にきてはならないので,
4953 \begin{lstlisting}
4954 \ltjsetparameter{prebreakpenalty={`〙,10000}}
4955 \end{lstlisting}
4956 と,最大値の10000が標準で指定されている.他にも,小書きのカナなど,絶対禁止とい
4957              うわけではないができれば行頭にはきて欲しくない場合に,0と
4958              10000の間の値を指定するのも有用であろう.
4959
4960 \pTeX では,\cs{prebreakpenalty}, \cs{postbreakpenalty}において,
4961 \begin{itemize}
4962 \item 一つの文字に対して,pre, postどちらか一つしか指定することができない%
4963   \footnote{後から指定した方で上書きされる.}
4964 \item pre, post合わせて256文字分の情報を格納することしかできない
4965 \end{itemize}
4966 という制限があったが,\LuaTeX-jaではこれらの制限は解消されている.
4967 %</ja>
4968 %<*en>
4969 Set a penalty which is inserted automatically before the character <chr\_code>,
4970 to prevent a line starts from this character. For example, a line cannot started
4971 with one of closing brackets ``〗'', so \LuaTeX-ja sets
4972 \begin{lstlisting}
4973 \ltjsetparameter{prebreakpenalty={`〙,10000}}
4974 \end{lstlisting}
4975 by default.
4976
4977 \pTeX\ has following restrictions on \cs{prebreakpenalty} and \cs{postbreakpenalty},
4978 but they don't exist in \LuaTeX-ja:
4979 \begin{itemize}
4980  \item Both \cs{prebreakpenalty} and \cs{postbreakpenalty} cannot be set
4981 for the same character.
4982  \item We can set \cs{prebreakpenalty} and \cs{postbreakpenalty} up to 256~characters.
4983 \end{itemize}
4984 %</en>
4985
4986 \item[\DParam{postbreakpenalty}\,=\{<chr\_code>,<penalty>\}$^\ast$]
4987            [\cs{postbreakpenalty}]\
4988
4989 %<*ja>
4990 文字コード<chr\_code>の\textbf{JAchar}が行末にくることを抑止するために,
4991              この文字の後に挿入/追加されるペナルティの量を指定する.
4992 %</ja>
4993 %<*en>
4994 Set a penalty which is inserted automatically after the character <chr\_code>,
4995 to prevent a line ends with this character.
4996 %</en>
4997
4998 \item[\DParam{jatextfont}\,=\{<jfam>,<jfont\_cs>\}$^\ast$]
4999 %<en>[\cs{textfont} in \TeX]
5000 %<ja>[\TeX の \cs{textfont}]
5001 \item[\DParam{jascriptfont}\,=\{<jfam>,<jfont\_cs>\}$^\ast$]
5002 %<en>[\cs{scriptfont} in \TeX]
5003 %<ja>[\TeX の \cs{scriptfont}]
5004 \item[\DParam{jascriptscriptfont}\,=\{<jfam>,<jfont\_cs>\}$^\ast$]
5005 %<en>[\cs{scriptscriptfont} in \TeX]
5006 %<ja>[\TeX の \cs{scriptscriptfont}]
5007 \item[\DParam{yjabaselineshift}\,=<dimen>]\
5008 \item[\DParam{yalbaselineshift}\,=<dimen>] [\cs{ybaselineshift}]
5009 \item[\DParam{tjabaselineshift}\,=<dimen>]\
5010 \item[\DParam{talbaselineshift}\,=<dimen>] [\cs{tbaselineshift}]
5011
5012 \item[\DParam{jaxspmode}\,=\{<chr\_code>,<mode>\}$^\ast$]\
5013
5014 %<*en>
5015 Set whether inserting \Param{xkanjiskip} is allowed before/after a \textbf{JAchar} whose character code is <chr\_code>.
5016 The followings are allowed for <mode>:
5017 %</en>
5018 %<*ja>
5019 文字コードが<chr\_code>の\textbf{JAchar}の前/後ろに\Param{xkanjiskip}の
5020 挿入を許すかどうかの設定.
5021 以下の<mode>が許される:
5022 %</ja>
5023 \begin{description}
5024 %<en>\item[0, \texttt{inhibit}] Insertion of \Param{xkanjiskip} is inhibited before the character, nor after the character.
5025 %<ja>\item[0, \texttt{inhibit}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも禁止される.
5026 %<en>\item[1, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed before the character, but not after.
5027 %<ja>\item[1, \texttt{preonly}] \Param{xkanjiskip}の挿入は文字の前では許されるが,後ろでは許されない.
5028 %<en>\item[2, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed after the character, but not before.
5029 %<ja>\item[2, \texttt{postonly}] \Param{xkanjiskip}の挿入は文字の後ろでは許されるが,前では許されない.
5030 %<en>\item[3, \texttt{allow}] Insertion of \Param{xkanjiskip} is allowed both before the character and after the character. This is the default value.
5031 %<ja>\item[3, \texttt{allow}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも許される.これがデフォルトの値である.
5032 \end{description}
5033 %<*en>
5034 This parameter is similar to the \cs{inhibitxspcode} primitive of \pTeX, but not compatible with \cs{inhibitxspcode}.
5035 %</en>
5036 %<*ja>
5037 このパラメータは\pTeX の \cs{inhibitxspcode} プリミティブと似ているが,
5038 互換性はない.
5039 %</ja>
5040 \item[\DParam{alxspmode}\,=\{<chr\_code>,<mode>\}$^\ast$] [\cs{xspcode}]\
5041
5042 %<*en>
5043 Set whether inserting \Param{xkanjiskip} is allowed before/after a
5044              \textbf{ALchar} whose character code is <chr\_code>.
5045              The followings are allowed for <mode>:
5046 %</en>
5047 %<*ja>
5048 文字コードが<chr\_code>の\textbf{ALchar}の前/後ろに\Param{xkanjiskip}の
5049 挿入を許すかどうかの設定.
5050 以下の<mode>が許される:
5051 %</ja>
5052 \begin{description}
5053 %<en>\item[0, \texttt{inhibit}] Insertion of \Param{xkanjiskip} is inhibited before the character, nor after the character.
5054 %<ja>\item[0, \texttt{inhibit}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも禁止される.
5055 %<en>\item[1, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed before the character, but not after.
5056 %<ja>\item[1, \texttt{preonly}] \Param{xkanjiskip}の挿入は文字の前では許されるが,後ろでは許されない.
5057 %<en>\item[2, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed after the character, but not before.
5058 %<ja>\item[2, \texttt{postonly}] \Param{xkanjiskip}の挿入は文字の後ろでは許されるが,前では許されない.
5059 %<en>\item[3, \texttt{allow}] Insertion of \Param{xkanjiskip} is allowed before the character and after the character. This is the default value.
5060 %<ja>\item[3, \texttt{allow}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも許される.これがデフォルトの値である.
5061 \end{description}
5062 %<*en>
5063 Note that parameters \Param{jaxspmode} and \Param{alxspmode} share a common table, hence these two parameters are synonyms of each other.
5064 %</en>
5065 %<*ja>
5066 \Param{jaxspmode}と\Param{alxspmode}は共通のテーブルを用いているため,
5067 これら2つのパラメータは互いの別名となっていることに注意する.
5068 %</ja>
5069
5070 \item[\DParam{autospacing}\,=<bool>] [\cs{autospacing}]
5071 \item[\DParam{autoxspacing}\,=<bool>] [\cs{autoxspacing}]
5072 \item[\DParam{kanjiskip}\,=<skip>$^\ast$] [\cs{kanjiskip}]\
5073
5074 %<*ja>
5075 デフォルトで2つの\textbf{JAchar}の間に挿入されるグルーである.
5076 通常では,\pTeX と同じようにフォントサイズに比例して変わることはない.
5077 しかし,自然長が \cs{maxdimen} の場合は,例外的に和文フォントのJFM側で指定されている
5078 値を採用(こちらはフォントサイズに比例)することになっている.
5079 %</ja>
5080 %<*en>
5081 The default glue which inserted between two \textbf{JAchar}s.
5082 Changing current Japanese font does not alter this parameter, as \pTeX.
5083
5084 If the natural width of this parameter is \cs{maxdimen}, \LuaTeX-ja uses
5085 the value which is specified in the JFM for current Japanese font (See Subsection~\ref{ssec-jfm-str}).
5086 %</en>
5087
5088 \item[\DParam{xkanjiskip}\,=<skip>$^\ast$] [\cs{xkanjiskip}]\
5089
5090 %<*ja>
5091 デフォルトで\textbf{JAchar}と\textbf{ALchar}の間に挿入されるグルーである.
5092 \Param{kanjiskip}と同じように,通常ではフォントサイズに比例して変わることはないが,
5093 自然長が \cs{maxdimen} の場合が例外である.
5094 %</ja>
5095 %<*en>
5096 The default glue which inserted between a \textbf{JAchar} and an
5097       \textbf{ALchar}.
5098 Changing current font does not alter this parameter, as \pTeX.
5099
5100 As \Param{kanjiskip}, if the natural width of this parameter is \cs{maxdimen}, \LuaTeX-ja uses
5101 the value which is specified in the JFM for current Japanese font (See Subsection~\ref{ssec-jfm-str}).
5102 %</en>
5103
5104
5105 \item[\DParam{differentjfm}\,=<mode>$^\dagger$]\
5106
5107 %<*en>
5108 Specify how glues/kerns between two \textbf{JAchar}s whose JFM (or size) are different.
5109 The allowed arguments are the followings:
5110 %</en>
5111 %<*ja>
5112 JFM(もしくはサイズ)が異なる2つの\textbf{JAchar}の間にグルー/カーンをどのように
5113 入れるかを指定する.
5114 許される値は以下の通り:
5115 %</ja>
5116 \begin{quote}
5117 \texttt{average},
5118 \texttt{both},
5119 \texttt{large},
5120 \texttt{small},
5121 \texttt{pleft},
5122 \texttt{pright},
5123 \texttt{paverage}
5124 \end{quote}
5125 %<*en>
5126 The default value is \texttt{paverage}. \dots
5127 %</en>
5128 %<*ja>
5129 デフォルト値は \texttt{paverage} である.
5130 各々の値による差異の詳細は\ref{ssec-cluster-wa}節の「『右空白』の算出」を参照してほしい.
5131 %</ja>
5132
5133 \item[\DParam{jacharrange}\,=<ranges>]
5134 \item[\DParam{kansujichar}\,=\{<digit>, <chr\_code>\}$^\ast$] [\cs{kansujichar}]
5135
5136 \item[\DParam{direction}\,=<dir>\ \hbox{\rm (always local)}]\
5137
5138 %<*en>
5139 Assigning to this parameter has the same effect as
5140 \cs{yoko}~(if $\hbox{<dir>}=4$), \cs{tate}~(if $\hbox{<dir>}=3$),
5141 \cs{dtou}~(if $\hbox{<dir>}=1$) or \cs{utod}~(if $\hbox{<dir>}=11$).
5142 If the argument <dir> is not one of 4,~3, 1~nor~11,
5143 the behavior of this assignment is undefined.
5144 %</en>
5145 %<*ja>
5146 組方向を変更する \cs{yoko}~(if $\hbox{<dir>}=4$), \cs{tate}~(if $\hbox{<dir>}=3$),
5147 \cs{dtou}~(if $\hbox{<dir>}=1$), \cs{utod}~(if $\hbox{<dir>}=11$) と同じ役割を持つ.
5148 利用可能な状況もこれら4命令と同一である.引数<dir>が4,~3, 1,~11のいずれでも無いときの
5149 動作は未定義である.
5150 %</ja>
5151
5152 \end{cslist}
5153
5154
5155 \subsection{\cs{ltjgetparameter}}
5156 \label{ssec-getpar}
5157 %<*en>
5158 \cs{ltjgetparameter} is a control sequence for acquiring parameters. It
5159 always takes a parameter name as first argument.
5160 %</en>
5161 %<*ja>
5162 \cs{ltjgetparameter} はパラメータの値を取得するための命令であり,
5163 常にパラメータの名前を第一引数にとる.
5164 %</ja>
5165 \begin{LTXexample}
5166 \ltjgetparameter{differentjfm},
5167 \ltjgetparameter{autospacing},
5168 \ltjgetparameter{kanjiskip},
5169 \ltjgetparameter{prebreakpenalty}{`)}.
5170 \end{LTXexample}
5171
5172 %<*en>
5173 \emph{The return value of\/ \cs{ltjgetparameter} is
5174 always a string}, which is outputted by \texttt{tex.write()}.
5175 Hence any character other than space~``\texttt{\char32}''~(\texttt{U+0020}) has the category code
5176 12~(other), while the space has 10~(space).
5177 %</en>
5178 %<*ja>
5179 \emph{\cs{ltjgetparameter} の戻り値は常に文字列である.}
5180 これは\texttt{tex.write()}によって出力しているためで,空白「\texttt{\char32}」
5181 (\texttt{U+0020})を除いた文字のカテゴリーコードは全て12~(other)となる.
5182 一方,空白のカテゴリーコードは10~(space)である.
5183 %</ja>
5184
5185 \begin{itemize}
5186 \item
5187 %<*en>
5188 If first argument is one of the
5189 following, no  additional argument is needed.
5190 %</en>
5191 %<*ja>
5192 第1引数が次のいずれかの場合には,追加の引数は必要ない.
5193 %</ja>
5194 \begin{quote}
5195 \sffamily
5196 jcharwidowpenalty, yjabaselineshift, yalbaselineshift, autospacing, autoxspacing,\\
5197 kanjiskip, xkanjiskip, differentjfm, direction
5198 \end{quote}
5199 %<*en>
5200 Note that \verb+\ltjgetparameter{autospacing}+~and~\verb+\ltjgetparameter{autoxspacing}+
5201 returns 1 or 0, not
5202 \texttt{true}~nor~\texttt{false}.
5203 %</en>
5204 %<*ja>
5205 \verb+\ltjgetparameter{autospacing}+ と \verb+\ltjgetparameter{autoxspacing}+ は,
5206 \texttt{true}や\texttt{false}を返すの\emph{ではなく},
5207 1か0のいずれかを返すことに注意,
5208 %</ja>
5209
5210 \item
5211 %<*en>
5212 If first argument is one of the
5213 following, an additional argument---a character code, for example---is needed.
5214 %</en>
5215 %<*ja>
5216 第1引数が次のいずれかの場合には,さらに文字コードを第2引数としてとる.
5217 %</ja>
5218 \begin{quote}
5219 \sffamily
5220 kcatcode, prebreakpenalty, postbreakpenalty, jaxspmode, alxspmode
5221 \end{quote}
5222 %<*en>
5223 \verb+\ltjgetparameter{jaxspmode}{...}+~and~\verb+\ltjgetparameter{alxspmode}{...}+
5224 returns 0,~1, 2,~or~3, instead of \texttt{preonly} etc.
5225 %</en>
5226 %<*ja>
5227 \verb+\ltjgetparameter{jaxspmode}{...}+ や \verb+\ltjgetparameter{alxspmode}{...}+\
5228 は,\texttt{preonly} などといった文字列ではなく,0から3までの値を返す.
5229 %</ja>
5230
5231 \item
5232 %<*en>
5233 \verb+\ltjgetparameter{jacharrange}{+<range>\verb+}+ returns \texttt{0}
5234 if ``characters which belong to the character range~<range> are \textbf{JAchar}'',
5235 \texttt{1} if ``\dots~are \textbf{ALchar}''.
5236 Although there is no character range~$-1$, specifying $-1$ to <range> does not cause an
5237       error (returns 1).
5238 %</en>
5239 %<*ja>
5240 \verb+\ltjgetparameter{jacharrange}{+<range>\verb+}+ は,<range>が\textbf{JAchar}達の
5241 範囲ならば0を,そうでなければ1を返す.「$-1$番の文字範囲」は存在しないが,<range>に$-1$を
5242 指定してもエラーは発生しない(1を返す).
5243 %</ja>
5244
5245 \item
5246 %<*en>
5247 For an integer~<digit> between 0~and~9,
5248      \verb+\ltjgetparameter{kansujichar}{+<digit>\verb+}+ returns the character code
5249 of the result of \cs{kansuji}<digit>.
5250 %</en>
5251 %<*ja>
5252 0--9の数<digit>に対して,
5253 \verb+\ltjgetparameter{kansujichar}{+<digit>\verb+}+ は,\cs{kansuji}<digit>で出力され
5254      る文字の文字コードを返す.
5255 %</ja>
5256
5257 \item
5258 %<*en>
5259 \verb+\ltjgetparameter{adjustdir}+ returns a integer which represents
5260 the direction of the surrounding vertical list.
5261 As \Param{direction}, the return value 1 means \emph{down-to-up} direction,
5262 3 means \emph{tate} direction (vertical typesetting),
5263 and 4 means \emph{yoko} direction (horizontal typesetting).
5264 %</en>
5265 %<*ja>
5266 \verb+\ltjgetparameter{adjustdir}+ は,周囲のvboxの組方向(言い換えれば,
5267 \cs{vadjust} で用いられる組方向)を表す数値を返す.
5268 \Param{direction}と同様に,1は \cs{dtou} 方向を,
5269 3は縦組みを,4は横組みを表す.
5270 %</ja>
5271
5272 \item
5273 %<*en>
5274 For an integer~<reg\_num> between 0~and~65535,
5275 \verb+\ltjgetparameter{boxdim}{+<reg\_num>\verb+}+ returns the direction of
5276 \cs{box}<reg\_num>. If this box register is void, the returned value is zero.
5277 %</en>
5278 %<*ja>
5279 0--65535の数<reg\_num>に対して,
5280 \verb+\ltjgetparameter{boxdim}{+<reg\_num>\verb+}+ は,\cs{box}<reg\_num>に
5281 格納されているボックスの組方向を表す.もしこのレジスタが空の場合は,0が返される.
5282 %</ja>
5283
5284 \item
5285 %<*en>
5286 The following parameter names \emph{cannot be specified} in \cs{ltjgetparameter}.
5287 %</en>
5288 %<*ja>
5289 次のパラメータ名を \cs{ltjgetparameter} に指定することはできない.
5290 %</ja>
5291 \begin{quote}
5292 \sffamily
5293 jatextfont, jascriptfont, jascriptscriptfont, jacharrange
5294 \end{quote}
5295
5296 \item
5297 %<*en>
5298 \verb+\ltjgetparameter{chartorange}{+<chr\_code>\verb+}+ returns
5299 the range number which <chr\_code> belongs to
5300 (although there is no parameter named ``chartorange'').
5301
5302 If <chr\_code> is between 0 and 127, this <chr\_code> does not belong to
5303 any character range. In this case,
5304       \verb+\ltjgetparameter{chartorange}{+<chr\_code>\verb+}+
5305 returns $-1$.
5306
5307 Hence, one can know whether <chr\_code> is \textbf{JAchar} or not
5308 by the following:
5309 %</en>
5310 %<*ja>
5311 \verb+\ltjgetparameter{chartorange}{+<chr\_code>\verb+}+ によって
5312 <chr\_code>の属する文字範囲の番号を知ることができる.
5313
5314 <chr\_code>に0--127の値を指定した場合(このとき,<chr\_code>が属する
5315 文字範囲は存在しない)は$-1$が返る.
5316
5317 そのため,<chr\_code>が\textbf{JAchar}か\textbf{ALchar}かは
5318 次で知ることができる:
5319 %</ja>
5320 \begin{quote}
5321 \ttfamily \verb+\ltjgetparameter{jacharrange}{\ltjgetparameter{chartorange}{+%
5322   <chr\_code>\verb+}}+\\\null\hfill\verb+% 0 if JAchar, 1 if ALchar+
5323 \end{quote}
5324
5325 %<*en>
5326 \item Because the returned value is string, the following conditionals do not work
5327 if \Param{kanjiskip} (or~\Param{xkanjiskip}) has the stretch part or the shrink part.
5328 \begin{lstlisting}
5329 \ifdim\ltjgetparameter{kanjiskip}>\z@ ... \fi
5330 \ifdim\ltjgetparameter{xkanjiskip}>\z@ ... \fi
5331 \end{lstlisting}
5332 The correct way is using a temporary register.
5333 \begin{lstlisting}
5334 \@tempskipa=\ltjgetparameter{kanjiskip} \ifdim\@tempskipa>\z@ ... \fi
5335 \@tempskipa=\ltjgetparameter{xkanjiskip}\ifdim\@tempskipa>\z@ ... \fi
5336 \end{lstlisting}
5337 %</en>
5338 %<*ja>
5339 \item 返り値が文字列であることから,\Param{kanjiskip}や\Param{xkanjiskip}を直接
5340 \ \cs{ifdim} を使って比較することは望ましくない.伸び量や縮み量を持っている時には,
5341 次はエラーを発生させる:
5342 \begin{lstlisting}
5343 \ifdim\ltjgetparameter{kanjiskip}>\z@ ... \fi
5344 \ifdim\ltjgetparameter{xkanjiskip}>\z@ ... \fi
5345 \end{lstlisting}
5346 レジスタに一旦代入するのが良い:
5347 \begin{lstlisting}
5348 \@tempskipa=\ltjgetparameter{kanjiskip} \ifdim\@tempskipa>\z@ ... \fi
5349 \@tempskipa=\ltjgetparameter{xkanjiskip}\ifdim\@tempskipa>\z@ ... \fi
5350 \end{lstlisting}
5351 %</ja>
5352
5353 \end{itemize}
5354
5355 %<*ja>
5356 \subsection{\cs{ltjsetparameter} の代替}
5357 原則として各種内部パラメータの設定には \cs{ltjsetparameter} もしくは
5358 \ \cs{ltjglobalsetparameter}\ を用いることになるが,
5359 \cs{ltjsetparameter} の実行には時間がかかるという難点があり,
5360 \LuaTeX-ja の内部ではより高速に実行できる別の形式を用いている.
5361 \emph{本節は一般利用者むけの内容ではない.}
5362
5363 \paragraph{\Param{kanjiskip}, \Param{xkanjiskip} の設定}
5364 \pLaTeXe 新ドキュメントクラスでは,
5365 \begin{lstlisting}
5366 \def\@setfontsize#1#2#3{%
5367   ...
5368   \kanjiskip=0zw plus .1zw minus .01zw
5369   \ifdim\xkanjiskip>\z@
5370     \if@slide \xkanjiskip=0.1em \else
5371       \xkanjiskip=0.25em plus 0.15em minus 0.06em
5372     \fi
5373   \fi}
5374 \end{lstlisting}
5375 と,フォントサイズを変更するごとに \cs{kanjiskip}, \cs{xkanjiskip} を変更している.
5376 この \cs{@setfontsize} は文書の中で多数回実行されるので.
5377 \LuaTeX-ja 用に素直に書き換えた
5378 \begin{lstlisting}
5379   \ltjsetparameter{kanjiskip=0\zw plus .1\zw minus .01\zw}
5380   \@tempskipa=\ltjgetparameter{xkanjiskip}
5381   \ifdim\@tempskipa>\z@
5382     \if@slide
5383       \ltjsetparameter{xkanjiskip=0.1em}
5384     \else
5385       \ltjsetparameter{xkanjiskip=0.25em plus 0.15em minus 0.06em}
5386     \fi
5387   \fi
5388 \end{lstlisting}
5389 としたのではタイプセットが遅くなってしまう.
5390 そこで,\cs{ltjsetparameter} の中で
5391 \begin{itemize}
5392 \item \cs{globaldefs} の値を読み取る \cs{ltj@setpar@global}
5393 \item \Param{kanjiskip} の設定を行う \cs{ltjsetkanjiskip}
5394 \item \Param{xkanjiskip} の設定を行う \cs{ltjsetxkanjiskip}
5395 \end{itemize}
5396 を独立させ,\Pkg{ltjsclasses}では,
5397 \begin{lstlisting}
5398   \ltj@setpar@global
5399   \ltjsetkanjiskip{\z@ plus .1\zw minus .01\zw}
5400   \@tempskipa=\ltjgetparameter{xkanjiskip}
5401   \ifdim\@tempskipa>\z@
5402     \if@slide
5403       \ltjsetxkanjiskip.1em
5404     \else
5405       \ltjsetxkanjiskip.25em plus .15em minus .06em
5406     \fi
5407   \fi
5408 \end{lstlisting}
5409 としている.
5410 \cs{ltj@setpar@global}を直前に実行せず,単独で
5411 \cs{ltjsetkanjiskip}, \cs{ltjsetxkanjiskip}を実行することは想定されていないので注意.
5412
5413
5414
5415 \paragraph{ベースライン補正量の設定}
5416 \pLaTeX の\Pkg{ascmac}パッケージでは,縦組の欧文ベースライン補正量の一時待避・復帰処理に
5417 \ \cs{@saveybaselineshift}\ という寸法レジスタを用い
5418 \begin{lstlisting}
5419 \@savetbaselineshift\tbaselineshift\tbaselineshift\z@
5420 ...
5421 \tbaselineshift\@savetbaselineshift
5422 \end{lstlisting}
5423 という処理を行っている.
5424
5425 これを\LuaTeX-ja 用に \cs{ltjsetparameter} を使って書き直すと,
5426 \begin{lstlisting}
5427 \@savetbaselineshift\ltjgetparameter{talbaselineshift}
5428 \ltjsetparameter{talbaselineshift=\z@}
5429 ...
5430 \ltjsetparameter{talbaselineshift=\@savetbaselineshift}
5431 \end{lstlisting}
5432 となる.
5433
5434 さて,縦組の欧文ベースライン補正量\Param{talbaselineshift}は,
5435 実際には \cs{ltj@tablshift} という属性レジスタに格納されている
5436 (\ref{sec-para}\nobreak 節参照).属性レジスタは長さではなく整数値を格納する\footnote{%
5437   従って,\texttt{\textbackslash @savetbaselineshift=\textbackslash ltj@tablshift}\
5438   のように記述することはできない.属性レジスタを \cs{tbaselineshift} という名称にしなかっ
5439   たのはそのためである.
5440 }ものであり,\cs{ltj@tablshift} は補正量を sp 単位で保持することから,
5441 上記のコードと同じ内容をより速い以下のコードで実現することができる.
5442 \begin{lstlisting}
5443 \@savetbaselineshift\ltj@tablshift sp%
5444 \ltj@tablshift\z@
5445 ...
5446 \ltj@tablshift\@savetbaselineshift
5447 \end{lstlisting}
5448 この手法は \Pkg{ascmac} パッケージの\LuaTeX-ja対応パッチ \Pkg{lltjp-tascmac.sty} で
5449 実際に用いられている.\Pkg{lltjp-tascmac.sty} は自動的に読み込まれるので,
5450 ユーザは何も気にせず普通に \Pkg{ascmac} パッケージを \cs{usepackage} で読みこめば良い.
5451 %</ja>
5452
5453
5454 %<en>\section{Other Commands for plain \TeX\ and \LaTeXe}
5455 %<ja>\section{plainでも\LaTeX でも利用可能なその他の命令}
5456 %<en>\subsection{Commands for Compatibility with \pTeX}
5457 %<ja>\subsection{\pTeX 互換用命令}
5458
5459 %<*en>
5460 The following commands are implemented for compatibility with \pTeX.
5461 Note that the former five commands don't support JIS~X~0213, but only JIS~X~0208.
5462 The last \cs{kansuji} converts an integer into its Chinese numerals.
5463 %</en>
5464 %<*ja>
5465 以下の命令は\pTeX との互換性のために実装されている.そのため,JIS~X~0213には対応せず,
5466 \pTeX と同じようにJIS~X~0208の範囲しかサポートしていない.
5467 %</ja>
5468 \begin{center}
5469 \cs{kuten}, \cs{jis}, \cs{euc}, \cs{sjis}, \cs{jis}, \cs{kansuji}
5470 \end{center}
5471 %<*en>
5472 These six commands takes an internal integer, and returns a \emph{string}.
5473 %</en>
5474 %<*ja>
5475 これら6命令は内部整数を引数とするが,実行結果は\textbf{文字列}であることに注意.
5476 %</ja>
5477 \begin{LTXexample}
5478 \newcount\hoge
5479 \hoge="2423 %"
5480 \the\hoge, \kansuji\hoge\\
5481 \jis\hoge, \char\jis\hoge\\
5482 \kansuji1701
5483 \end{LTXexample}
5484
5485 %<*en>
5486 To change characters of Chinese numerals for each digit, set \Param{kansujichar} parameter:
5487 \begin{LTXexample}
5488 \ltjsetparameter{kansujichar={1,`壹}}
5489 \ltjsetparameter{kansujichar={7,`漆}}
5490 \ltjsetparameter{kansujichar={0,`零}}
5491 \kansuji1701
5492 \end{LTXexample}
5493 %</en>
5494
5495
5496 \subsection{\cs{inhibitglue}}
5497 %<*en>
5498 \cs{inhibitglue} suppresses the insertion of \textbf{JAglue}.
5499 The following is an example, using a special JFM that there will be a glue between
5500 the beginning of a box and ``あ'', and also between ``あ''~and~``ウ''.
5501 %</en>
5502 %<*ja>
5503 \cs{inhibitglue} は\textbf{JAglue}の挿入を抑制する.
5504 以下は,ボックスの始めと「あ」の間,「あ」「ウ」の間にグルーが入る特別なJFMを用いた例で
5505 ある.
5506 %</ja>
5507
5508 \begin{LTXexample}[width=0.4\textwidth]
5509 \jfont\g=file:KozMinPr6N-Regular.otf:jfm=test \g
5510 \fbox{\hbox{あウあ\inhibitglue ウ}}
5511 \inhibitglue\par\noindent あ1
5512 \par\inhibitglue\noindent あ2
5513 \par\noindent\inhibitglue あ3
5514 \par\hrule\noindent あoff\inhibitglue ice
5515 \end{LTXexample}
5516
5517 %<*en>
5518 With the help of this example, we remark the specification of \cs{inhibitglue}:
5519 %</en>
5520 %<*ja>
5521 この例を援用して,\cs{inhibitglue} の仕様について述べる.
5522 %</ja>
5523 \begin{itemize}
5524 %<*en>
5525 \item The call of \cs{inhibitglue} in the (internal) vertical mode is
5526       simply ignored.
5527 %</en>
5528 %<*ja>
5529 \item \emph{\cs{inhibitglue} の垂直モード中での呼び出しは意味を持たない}\footnote{%
5530   この点は\TeX~Live~2014での\pTeX における \cs{inhibitglue} の仕様変更と同じである.
5531 }.
5532 4行目の入力で有効にならないのは,\cs{inhibitglue} の時点では垂直モードであり,
5533 \cs{noindent} の時点で水平モードになるからである.
5534 %</ja>
5535
5536 %<*en>
5537 \item The call of \cs{inhibitglue} in the (restricted) horizontal
5538       mode is only effective on the spot; does not get over boundary of
5539       paragraphs. Moreover, \cs{inhibitglue} cancels ligatures and
5540       kernings, as shown in the last line of above example.
5541 %</en>
5542 %<*ja>
5543 \item \cs{inhibitglue} の(制限された)水平モード中での呼び出しはその場でのみ
5544   有効であり,段落の境界を乗り越えない.
5545   さらに,\cs{inhibitglue} は上の例の最終行のように(欧文における)リガチャとカーニングを
5546   打ち消す.これは,\cs{inhibitglue} が内部的には「現在のリスト中にwhatsitノードを
5547   追加する」ことを行なっているからである.
5548 %</ja>
5549
5550 %<*en>
5551 \item The call of \cs{inhibitglue} in math mode is just ignored.
5552 %</en>
5553 %<*ja>
5554 \item \cs{inhibitglue} を数式モード中で呼び出した場合はただ無視される.
5555 %</ja>
5556
5557 %<*ja>
5558 \item \LaTeX で\LuaTeX-ja を使用する場合は,
5559 \cs{inhibitglue} の代わりとして \verb+\<+ を使うことができる.
5560 既に \verb+\<+ が定義されていた場合は,\LuaTeX-ja の読み込みで強制的に上書きされるので
5561 注意すること.
5562 %</ja>
5563 \end{itemize}
5564
5565
5566 \subsection{\cs{ltjdeclarealtfont}}
5567 \label{ssec-altfont}
5568 %<*en>
5569 Using \cs{ltjdeclarealtfont}, one can ``compose'' more than one Japanese fonts.
5570 This \cs{ltjdeclarealtfont} uses in the following form:
5571 \begin{quote}
5572 \ttfamily \textbackslash ltjdeclarealtfont<base\_font\_cs><alt\_font\_cs>{<range>}
5573 \end{quote}
5574 where  <base\_font\_cs>~and~<alt\_font\_cs> are defined by \cs{jfont}.
5575 Its meaning is
5576 \begin{quote}
5577 If the current Japanese font is <base\_font\_cs>, characters which belong to <range>
5578 is typeset by another Japanese font <alt\_font\_cs>, instead of <base\_font\_cs>.
5579 \end{quote}
5580
5581 <range> is a comma-separated list of character codes, but also accepts negative integers:
5582 $-n$~($n≥1$) means that all characters of character classes~$n$, with respect to JFM used
5583 by <base\_font\_cs>. Note that characters which do not exist in <alt\_font\_cs> are
5584 ignored.
5585
5586 For example, if \cs{hoge} uses \texttt{jfm-ujis.lua}, the standard JFM of \LuaTeX-ja,
5587 then
5588 \begin{lstlisting}
5589 \ltjdeclarealtfont\hoge\piyo{"3000-"30FF, {-1}-{-1}}
5590 \end{lstlisting}
5591 does
5592 \begin{quote}
5593 If the current Japanese font is \cs{hoge}, \texttt{U+3000}--\texttt{U+30FF}
5594 and characters in class~1 (ideographic opening brackets)
5595 are typeset by \cs{piyo}.
5596 \end{quote}
5597 %</en>
5598 %<*ja>
5599 \cs{jfont} の書式を見ればわかるように,基本的には\LuaTeX-jaにおける1つの和文フォントに
5600 使用出来る「実際のフォント」は1つである.
5601 しかし,\cs{ltjdeclarealtfont} を用いると,この原則から外れることができる.
5602
5603 \cs{ltjdeclarealtfont} は以下の書式で使用する:
5604 \begin{quote}
5605 \ttfamily \textbackslash ltjdeclarealtfont<base\_font\_cs><alt\_font\_cs>{<range>}
5606 \end{quote}
5607 これは「現在の和文フォント」が<base\_font\_cs>であるとき,
5608 <range>に属する文字は<alt\_font\_cs>を用いて組版される,という意味である.
5609 \begin{itemize}
5610  \item <base\_font\_cs>, <alt\_font\_cs>は
5611 \cs{jfont} によって定義された和文フォントである.
5612  \item <range>は文字コードの範囲を表すコンマ区切りのリストであるが,
5613    例外として負数$-n$は「<base\_font\_cs>のJFMの文字クラス$n$に属する全ての文字」
5614    を意味する.
5615
5616 <range>中に<alt\_font\_cs>中に実際には存在しない文字が指定された場合は,
5617 その文字に対する設定は無視される.
5618 \end{itemize}
5619
5620 例えば,\cs{hoge} のJFMが\LuaTeX-ja標準の
5621 \ \texttt{jfm-ujis.lua} であった場合,
5622 \begin{lstlisting}
5623 \ltjdeclarealtfont\hoge\piyo{"3000-"30FF, {-1}-{-1}}
5624 \end{lstlisting}
5625 は「\cs{hoge} を利用しているとき,
5626 \texttt{U+3000}--\texttt{U+30FF}と
5627 文字クラス1(開き括弧類)中の文字だけは \cs{piyo} を用いる」
5628 ことを設定する.\verb+{-1}-{-1}+ という変わった指定の仕方をしているのは,
5629 普通に \texttt{-1} と指定したのでは正しく$-1$と読み取られないという
5630 マクロの都合による.
5631 %</ja>
5632
5633
5634
5635 %<en>\section{Commands for \LaTeXe}
5636 %<ja>\section{\LaTeXe 用の命令}
5637
5638 %<en>\subsection{Patch for NFSS2}
5639 %<ja>\subsection{NFSS2へのパッチ}
5640 \label{ssec-nfsspat}
5641
5642 %<*en>
5643 Japanese patch for NFSS2 in \LuaTeX-ja
5644 is based on \texttt{plfonts.dtx} which plays the same role in \pLaTeXe.
5645 We will describe
5646 commands which are not described in Subsection~\ref{ssec-chgfnt}.
5647 %</en>
5648 %<*ja>
5649 \LuaTeX-jaのNFSS2への日本語パッチは
5650 \pLaTeXe で同様の役割を果たす \texttt{plfonts.dtx} をベースに,
5651 和文エンコーディングの管理等をLuaで書きなおしたものである.
5652 ここでは\ref{ssec-chgfnt}節で述べていなかった命令について
5653 記述しておく.
5654 %</ja>
5655
5656 \begin{cslist}%
5657 \item[\normalfont\bfseries %
5658 %<ja>追加の長さ変数達
5659 %<en>additonal dimensions
5660 ]
5661 %<*en>
5662 Like \pLaTeXe, \LuaTeX-ja defines the following dimensions
5663 for information of current Japanese font:
5664 %</en>
5665 %<*ja>
5666 \pLaTeXe と同様に,\LuaTeX-jaは「現在の和文フォントの情報」を格納する長さ変数
5667 %</ja>
5668 \begin{quote}
5669  \cs{cht}~(height), \cs{cdp}~(depth), \cs{cHT}~(sum of former two),\\
5670  \cs{cwd}~(width), \cs{cvs}~(lineskip), \cs{chs}~(equals to \cs{cwd})
5671 \end{quote}
5672 %<en>and its \cs{normalsize} version:
5673 %<ja>と,その \cs{normalsize} 版である
5674 \begin{quote}
5675  \cs{Cht}~(height), \cs{Cdp}~(depth),
5676  \cs{Cwd}~(width), \\\cs{Cvs}~(equals to \cs{baselineskip}),
5677  \cs{Chs}~(equals to \cs{cwd})%
5678 %<en>.
5679 \end{quote}
5680 %<*ja>
5681 を定義している.なお,\cs{cwd} と \cs{zw},また
5682 \cs{cHT} と \cs{zh} は一致しない可能性がある.なぜなら,
5683 \cs{cwd},~\cs{cHT} は「あ」の寸法から決定されるのに対し,
5684 \cs{zw} と \cs{zh} はJFMに指定された値に過ぎないからである.
5685 %</ja>
5686 %<*en>
5687 Note that \cs{cwd}~and~\cs{cHT} may  differ from \cs{zw}~and~\cs{zh}
5688 respectively.
5689 On the one hand the former dimensions are determined from the character ``あ'',
5690 but on the other hand \cs{zw}~and~\cs{zh} are specified by JFM.
5691 %</en>
5692
5693
5694 \item[\cs{DeclareYokoKanjiEncoding}\{<encoding>\}\{<text-settings>\}\{<math-settings>\}]
5695 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
5696 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
5697 \item[\cs{DeclareTateKanjiEncoding}\{<encoding>\}\{<text-settings>\}\{<math-settings>\}]
5698
5699 %<*en>
5700 In NFSS2 under \LuaTeX-ja, distinction between alphabetic fonts
5701              and Japanese fonts are only made by their
5702              encodings. For example, encodings OT1 and T1 are encodings for
5703              alphabetic fonts, and Japanese fonts cannot
5704              have these encodings. These command define a new encoding
5705              scheme for Japanese font families.
5706 %</en>
5707 %<*ja>
5708 \LuaTeX-jaのNFSS2においては,欧文フォントと和文フォントは
5709 そのエンコーディングによってのみ区別される.
5710 例えば,OT1とT1のエンコーディングは欧文フォントのエンコーディングであり,
5711 和文フォントはこれらのエンコーディングを持つことはできない.
5712 これらコマンドは横組用・縦組用和文フォントのための新しいエンコーディングを
5713 それぞれ定義する.
5714 %</ja>
5715
5716 \item[\cs{DeclareKanjiEncodingDefaults}\{<text-settings>\}\{<math-settings>\}]
5717 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
5718 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
5719 \item[\cs{DeclareKanjiSubstitution}\{<encoding>\}\{<family>\}\{<series>\}\{<shape>\}]
5720 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
5721 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
5722 \item[\cs{DeclareErrorKanjiFont}\{<encoding>\}\{<family>\}\{<series>\}\{<shape>\}\{<size>\}]
5723
5724 %<*en>
5725 The above 3~commands are just the counterparts for \cs{DeclareFontEncodingDefaults} and~others.
5726 %</en>
5727 %<*ja>
5728 上記3つのコマンドはちょうどNFSS2 の \cs{DeclareFontEncodingDefaults} などに対応するものである.
5729 %</ja>
5730
5731 \item[\cs{reDeclareMathAlphabet}\{<unified-cmd>\}\{<al-cmd>\}\{<ja-cmd>\}]
5732
5733 % ToDo: en
5734 %<*ja>
5735 和文・欧文の数式用フォントファミリを一度に変更する命令を作成する.
5736 具体的には,欧文数式用フォントファミリ変更の命令<al-cmd>(\cs{mathrm} 等)と,和文数式用フォ
5737              ントファミリ変更の命令<ja-cmd>(\cs{mathmc} 等)の2つを同時に行う命令として
5738              <unified-cmd>を(再)定義する.実際の使用では<unified-cmd>と
5739              <al-cmd>に同じものを指定する,すなわち,<al-cmd>で和文側も変
5740              更させるようにするのが一般的と思われる.
5741
5742 本命令は
5743 \begin{center}\tt
5744 <unified-cmd>\{<arg>\}\quad$\longrightarrow$\quad
5745 (<al-cmd>の1段展開結果)\{<ja-cmd>の1段展開結果)\{<arg>\}\}
5746 \end{center}
5747 と定義を行うので,使用には注意が必要である:
5748 %<en>\vspace{-\medskipamount}
5749 \begin{itemize}
5750 \item <al-cmd>,~<ja-cmd>は既に定義されていなければならない.
5751       \cs{reDeclareMathAlphabet}\\の後に
5752 両命令の内容を再定義しても,<unified-cmd>の内容にそれは反映されない.
5753 \item <al-cmd>,~<ja-cmd>に\verb+\@mathrm+などと \texttt{@} をつけた命令を指定した時の動作は保証できない.
5754 \end{itemize}
5755 %</ja>
5756
5757 \item[\cs{DeclareRelationFont}\{<ja-encoding>\}\{<ja-family>\}\{<ja-series>\}\{<ja-shape>\}\\*
5758   \null\hfill\{<al-encoding>\}\{<al-family>\}\{<al-series>\}\{<al-shape>\}]
5759 %<*en>
5760 This command sets the ``accompanied'' alphabetic font (given by the latter 4~arguments)
5761 with respect to a Japanese font given by the former 4~arguments.
5762 %</en>
5763 %<*ja>
5764 いわゆる「従属欧文」を設定するための命令である.前半の4引数で表される和文フォントに対して,
5765 そのフォントに対応する「従属欧文」のフォントを後半の4引数により与える.
5766 %</ja>
5767 \item[\cs{SetRelationFont}]
5768 %<*en>
5769 This command is almost same as \cs{DeclareRelationFont}, except that this command does a local
5770 assignment, where \cs{DeclareRelationFont} does a global assignment.
5771 %</en>
5772 %<*ja>
5773 このコマンドは \cs{DeclareRelationFont} とローカルな指定であることを除いて
5774 ほとんど同じである(\cs{DeclareRelationFont} はグローバル).
5775 %</ja>
5776
5777 \item[\cs{userelfont}]
5778 %<*en>
5779 Change current alphabetic font encoding/family/\dots\ to the `accompanied' alphabetic
5780              font family with respect to current Japanese font family,
5781              which was set by
5782              \cs{DeclareRelationFont} or \cs{SetRelationFont}.
5783 Like \cs{fontfamily}, \cs{selectfont} is required to take an effect.
5784 %</en>
5785 %<*ja>
5786 現在の欧文フォントのエンコーディング/ファミリ/…… を,
5787 \cs{DeclareRelationFont} か \cs{SetRelationFont} で指定された
5788 現在の和文フォントに対応する「従属欧文」フォントに変更する.
5789 \cs{fontfamily} のように,有効にするためには \cs{selectfont} が必要である.
5790 %</ja>
5791
5792 \item[\cs{adjustbaseline}]
5793 %<*en>
5794 In \pLaTeXe, \cs{adjustbaseline} sets \cs{tbaselineshift}
5795 to match the vertical center of ``M'' and that of ``あ''  in vertical typesetting:
5796 \[
5797 \text{\cs{tbaselineshift}} \leftarrow
5798 \frac{(h_{\text{M}}+d_{\text{M}}) - (h_{\text{あ}}+d_{\text{あ}})}2
5799   + d_{\text{あ}} - d_{\text{M}},
5800 \]
5801 where $h_{a}$~and~$d_{a}$ denote the height of ``$a$'' and the depth, respectively.
5802 In \LuaTeX-ja, this \cs{adjustbaseline} does same task, namely setting the
5803              \Param{talbaselineshift} parameter.
5804 %</en>
5805 %<*ja>
5806 \pLaTeXe では,\cs{adjustbaseline} は縦組時に「M」と「あ」の中心線を一致させるために,
5807 \cs{tbaselineshift} を設定する役割を持っていた:
5808 \[
5809 \text{\cs{tbaselineshift}} \leftarrow
5810 \frac{(h_{\text{M}}+d_{\text{M}}) - (h_{\text{あ}}+d_{\text{あ}})}2
5811   + d_{\text{あ}} - d_{\text{M}},
5812 \]
5813 ここで,$h_{a}$,~$d_{a}$はそれぞれ「$a$」の高さ・深さを表す.
5814 \LuaTeX-jaにおいても\cs{adjustbaseline} は同様に\Param{talbaselineshift}パラメータの調整処
5815              理を行っている.
5816
5817 同時に,これも\pLaTeXe の \cs{adjustbaseline} で行われていたが,
5818 「漢」の寸法を元に,(本節の最初に述べた,小文字で始まる)\cs{cht}, \cs{cwd} といった長さ変数を設定する.
5819 %</ja>
5820
5821 \item[\cs{fontfamily}\{<family>\}]
5822 %<*en>
5823 As in \LaTeXe, this command changes current font family (alphabetic, Japanese,~\emph{or both})
5824 to <family>. Which family will be changed is determined as follows:
5825 %</en>
5826 %<*ja>
5827 元々の\LaTeXe におけるものと同様に,このコマンドは現在のフォントファミリ(欧文,
5828 和文,\emph{もしくは両方})を<family>に変更する.
5829 どのファミリが変更されるかは以下のようにして決定される:
5830 %</ja>
5831 \begin{itemize}
5832 %<*en>
5833 \item Let current encoding scheme for Japanese fonts be
5834       <ja-enc>. Current Japanese font family will be changed to
5835       <family>, if one of the following two conditions is met:
5836 %</en>
5837 %<*ja>
5838 \item 現在の和文フォントに対するエンコーディングが<ja-enc>であるとしよう.
5839   現在の和文フォントファミリは,以下の2つの条件のうちの1つが満たされているときに
5840   <family>に変更される:
5841 %</ja>
5842 \begin{itemize}
5843 %<*en>
5844 \item The family <family> under the encoding <ja-enc> has been already defined by
5845       \cs{DeclareKanijFamily}.
5846 %</en>
5847 %<*ja>
5848 \item エンコーディング<ja-enc>におけるファミリ<family>が
5849 既に \cs{DeclareKanjiFamily} によって定義されている.
5850 %</ja>
5851 %<*en>
5852 \item A font definition named \texttt{<ja-enc><family>.fd} (the file name is
5853       all lowercase) exists.
5854 %</en>
5855 %<*ja>
5856 \item フォント定義ファイル\texttt{<ja-enc><family>.fd}(ファイル名は全て小文字)が存在する.
5857 %</ja>
5858 \end{itemize}
5859 %<*en>
5860 \item Let current encoding scheme for alphabetic fonts be
5861       <al-enc>. For alphabetic font family, the criterion as above is used.
5862 %</en>
5863 %<*ja>
5864 \item 現在の欧文フォントに対するエンコーディングを<al-enc>とする.
5865   欧文フォントファミリに対しても,上記の基準が用いられる.
5866 %</ja>
5867 %<*en>
5868 \item There is a case which none of the above applies, that is, the font
5869       family named <family> doesn't seem to be defined neither under the
5870       encoding <ja-enc>, nor under <al-enc>.
5871 In this case, the default family for font substitution is used for
5872       alphabetic and Japanese fonts. Note that current encoding will not
5873       be set to <family>, unlike the original implementation in \LaTeX.
5874 %</en>
5875 %<*ja>
5876 \item 上記のいずれもが適用されない,つまり<family>が<ja-enc>と<al-enc>の
5877   どちらでも定義されないような場合がある.
5878   この場合,代替フォントに用いられるデフォルトのフォントファミリが欧文フォントと
5879   和文フォントに用いられる.\LaTeX のオリジナルの実装とは異なり,
5880   現在のエンコーディングは<family>には設定されないことに注意する.
5881 %</ja>
5882 \end{itemize}%
5883 %<en>\vspace{-\medskipamount}
5884
5885
5886 \begin{figure}[!tb]
5887 \begin{LTXexample}[pos=b]
5888 \DeclareKanjiFamily{JY3}{edm}{}
5889 \DeclareFontShape{JY3}{edm}{m}{n}    {<-> s*KozMinPr6N-Regular:jfm=ujis;}{}
5890 \DeclareFontShape{JY3}{edm}{m}{green}{<-> s*KozMinPr6N-Regular:jfm=ujis;color=007F00}{}
5891 \DeclareFontShape{JY3}{edm}{m}{blue} {<-> s*KozMinPr6N-Regular:jfm=ujis;color=0000FF}{}
5892 \DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{green}{"4E00-"67FF,{-2}-{-2}}
5893 \DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{blue}{ "6800-"9FFF}
5894 {\kanjifamily{edm}\selectfont
5895 日本国民は、正当に選挙された国会における代表者を通じて行動し、……}
5896 \end{LTXexample}
5897 %<ja>\caption{\cs{DeclareAlternateKanjiFont} の使用例}
5898 %<en>\caption{An example of \cs{DeclareAlternateKanjiFont}}
5899 \label{fig:altkanji}
5900 \end{figure}
5901
5902 \item[\cs{DeclareAlternateKanjiFont}\{<base-encoding>\}\{<base-family>\}\{<base-series>\}\{<base-shape>\}\\
5903   \null\hfill\{<alt-encoding>\}\{<alt-family>\}\{<alt-series>\}\{<alt-shape>\}\{<range>\}]
5904 %<*ja>
5905 \ref{ssec-altfont}節の\
5906 \cs{ltjdeclarealtfont} と同様に,前半の4引数の
5907 和文フォント(基底フォント)のうち<range>中の文字を
5908 第5から第8引数の和文フォントを使って組むように指示する.
5909 使用例を図\nobreak\ref{fig:altkanji}に載せた.
5910
5911 \begin{itemize}
5912  \item
5913 \cs{ltjdeclarealtfont} では基底フォント・置き換え先和文フォントはあらかじめ定義されてい
5914              ないといけない(その代わり即時発効)であったが,
5915 \cs{DeclareAlternateKanjiFont} の設定が
5916 実際に効力が発揮するのは,書体変更やサイズ変更を行った時,
5917 あるいは(これらを含むが)\cs{selectfont} が実行された時である.
5918  \item
5919 段落やhboxの最後での設定値が段落/hbox全体にわたって通用する点や,
5920 <range>に負数$-n$を指定した場合,それが「基底フォントの文字クラス$n$に属する文字全体」
5921 と解釈されるのは \cs{ltjdeclarealtfont} と同じである.
5922 \end{itemize}%
5923 %</ja>
5924 %<*en>
5925 As \cs{ltjdeclarealtfont}~(Subsection~\ref{ssec-altfont}),
5926 characters in <range> of the Japanese font (we say the \emph{base font})
5927 which specified by first 4 arguments are typeset
5928 by the Japanese font which specified by fifth to eighth arguments
5929 (we say the \emph{alternate font}).
5930 An example is shown in Figure~\ref{fig:altkanji}.
5931
5932 \begin{itemize}
5933  \item
5934 In \cs{ltjdeclarealtfont}, the base font and the alternate font must be already defined.
5935 But this \cs{DeclareAlternateKanjiFont} is not so.
5936 In other words, \cs{DeclareAlternateKanjiFont} is effective only after
5937 current Japanese font is changed, or only after \cs{selectfont} is executed.
5938  \item \dots
5939 \end{itemize}%
5940 \vspace{-\medskipamount}
5941 %</en>
5942 \end{cslist}
5943
5944 %<*en>
5945 As closing this subsection, we shall introduce an example of
5946 \cs{SetRelationFont} and \cs{userelfont}:
5947 %</en>
5948 %<*ja>
5949 この節の終わりに,\cs{SetRelationFont} と \cs{userelfont} の例を
5950 紹介しておこう.\cs{userelfont} の使用によって,「abc」の部分のフォントが
5951 Avant Garde (OT1/pag/m/n) に変わっていることがわかる.
5952 %</ja>
5953 \begin{LTXexample}[width=0.3\textwidth]
5954 \makeatletter
5955 \SetRelationFont{JY3}{\k@family}{m}{n}{OT1}{pag}{m}{n}
5956   % \k@family: current Japanese font family
5957 \userelfont\selectfont あいうabc
5958 \end{LTXexample}
5959
5960 %<*en>
5961 \section{Addons}
5962 \LuaTeX-ja has several addon packages.
5963 These addons are written as \LaTeX\ packages, but
5964 \Pkg{luatexja-otf} and~\Pkg{luatexja-adjust} can be loaded in plain \LuaTeX\
5965 by \cs{input}.
5966 %</en>
5967 %<*ja>
5968 \section{拡張}
5969 \LuaTeX-jaには(動作には必須ではないが)自由に読み込める拡張が付属している.
5970 これらは\LaTeX のパッケージとして制作しているが,
5971 \Pkg{luatexja-otf}と\Pkg{luatexja-adjust}についてはplain \LuaTeX でも\
5972 \cs{input} で読み込み可能である.
5973 %</ja>
5974 \subsection{\texttt{luatexja-fontspec.sty}}
5975 \label{ssec-fontspec2}
5976 %<*en>
5977 As described in Subsection~\ref{ssec-fontspec}, this optional package
5978 provides the counterparts for several commands defined in the
5979 \Pkg{fontspec} package (requires \Pkg{fontspec}~v2.4).
5980 In addition to OpenType font features in the original \Pkg{fontspec},
5981 the following ``font features'' specifications are allowed for
5982 the commands of Japanese version:
5983 %</en>
5984 %<*ja>
5985 \ref{ssec-fontspec}節で述べたように,この追加パッケージは\Pkg{fontspec}%
5986 パッケージで定義されているコマンドに対応する和文フォント用のコマンドを提供する.
5987
5988 \Pkg{fontspec}パッケージで指定可能な各種font featureに加えて,和文版のコマンドには
5989 以下の``font feature''を指定することができる:
5990 %</ja>
5991
5992
5993 \begin{cslist}
5994 \item[CID=<name>\textrm{, }JFM=<name>\textrm{, }JFM-var=<name>]
5995
5996 %<*en>
5997 These 3 keys correspond to \texttt{cid}, \texttt{jfm} and
5998 \texttt{jfmvar} keys for \cs{jfont}~and~\cs{tfont} respectively.
5999 See Subsections~\ref{ssec-jfont} and \ref{ssec-psft} for details
6000  of \texttt{cid}, \texttt{jfm} and
6001 \texttt{jfmvar} keys.
6002
6003 The \texttt{CID} key is effective only when with \texttt{NoEmbed}
6004 described below. The same JFM cannot be used in both horizontal Japanese fonts and
6005              vertical Japanese fonts, hence the \texttt{JFM} key
6006 will be actually used in \texttt{YokoFeatures}~and~\texttt{TateFeatures} keys.
6007 %</en>
6008 %<*ja>
6009 これら3つのキーはそれぞれ \cs{jfont},~\cs{tfont}に対する
6010 \texttt{cid}, \texttt{jfm}, \texttt{jfmvar}キーとそれぞれ対応する.
6011 \texttt{cid}, \texttt{jfm}, \texttt{jfmvar}キーの詳細は\ref{ssec-jfont}節
6012              と\ref{ssec-psft}節を参照.
6013
6014 \texttt{CID} キーは下の \texttt{NoEmbed} と合わせて用いられたときのみ有効である.
6015 また,横組用JFMと縦組用JFMは共用できないため,実際に \texttt{JFM} キーを用いる際は
6016 後に述べる\ \texttt{YokoFeatures} キーや \texttt{TateFeatures}\ の中で用いる
6017 ことになる.
6018 %</ja>
6019
6020 \item[NoEmbed]
6021 %<*en>
6022 By specifying this key, one can use ``name-only'' Japanese font which
6023 will not be embedded in the output PDF file. See Subsection~\ref{ssec-psft}.
6024 %</en>
6025 %<*ja>
6026 これを指定することで,PDFに埋め込まれない「名前だけ」のフォントを指定することが
6027 できる.\ref{ssec-psft}節を参照.
6028 %</ja>
6029
6030 \begin{figure}[!tb]
6031 \begin{LTXexample}[width=0.25\textwidth]
6032 \jfontspec[
6033   YokoFeatures={Color=007F00}, TateFeatures={Color=00007F},
6034   TateFont=KozGoPr6N-Regular
6035 ]{KozMinPr6N-Regular}
6036 \hbox{\yoko 横組のテスト}\hbox{\tate 縦組のテスト}
6037 \addjfontfeatures{Color=FF0000}
6038 \hbox{\yoko 横組}\hbox{\tate 縦組}
6039 \end{LTXexample}
6040 %<ja>\caption{\texttt{TateFeatures} 等の使用例}
6041 %<en>\caption{An example of \texttt{TateFeatures} etc.}
6042 \label{fig:yokotate-fontspec}
6043 \end{figure}
6044
6045
6046 \item[TateFeatures=\{<features>\}\textrm{, }TateFont=<font>]
6047 %<*en>
6048 The \texttt{TateFeatures} key specifies font features which are only turned~on in
6049 vertical writing, such as \texttt{Style=VerticalKana}~(\texttt{vkna} feature).
6050 Similarly, the \texttt{TateFont} key specifies the Japanese font which will be used only
6051              in vertical writing.
6052 A demonstrarion is shown in Figure~\ref{fig:yokotate-fontspec}.
6053 %</en>
6054 %<*ja>
6055 縦組において使用されるフォントや,縦組においてのみ適用されるfeature達を
6056 指定する.使用例は図\ref{fig:yokotate-fontspec}参照.
6057 %</ja>
6058
6059 \item[YokoFeatures=\{<features>\}]
6060 %<*en>
6061 The \texttt{YokoFeatures} key specifies font features which are only turned~on in
6062 horizontal writing,.
6063 A demonstrarion is shown in Figure~\ref{fig:yokotate-fontspec}.
6064 %</en>
6065 %<*ja>
6066 同様に,横組においてのみ適用されるfeature達を
6067 指定する.使用例は図\ref{fig:yokotate-fontspec}参照.
6068 %</ja>
6069
6070
6071 \begin{figure}[!tb]
6072 \begin{LTXexample}[pos=b]
6073 \jfontspec[
6074   AltFont={
6075     {Range="4E00-"67FF, Color=007F00},
6076     {Range="6800-"9EFF, Color=0000FF},
6077     {Range="3040-"306F, Font=KozGoPr6N-Regular},
6078   }
6079 ]{KozMinPr6N-Regular}
6080 日本国民は、正当に選挙された国会における代表者を通じて行動し、われらとわれらの子孫のために、
6081 諸国民との協和による成果と、わが国全土にわたつて自由のもたらす恵沢を確保し、……
6082 \end{LTXexample}
6083 %<ja>\caption{\texttt{AltFont} の使用例}
6084 %<en>\caption{An example of \texttt{AltFont}}
6085 \label{fig:altkanji-fontspec}
6086 \end{figure}
6087
6088 \item[AltFont]
6089
6090 %<*en>
6091 As \cs{ltjdeclarealtfont}~(Subsection~\ref{ssec-altfont}) and
6092 \cs{DeclareAlternateKanjiFont}~(Subsection~\ref{ssec-nfsspat}),
6093 with this key, one can typeset some Japanese characters
6094 by a different font and/or using different features.
6095 The \texttt{AltFont} feature takes a comma-separated list of comma-separated lists,
6096 as the following:
6097 %</en>
6098 %<*ja>
6099 \ref{ssec-altfont}節の \cs{ltjdeclarealtfont} や,
6100 \ref{ssec-nfsspat}節の \cs{DeclareAlternateKanjiFont} と同様に,
6101 このキーを用いると一部の文字を異なったフォントやfont featureを使って組むことができる.
6102 \texttt{AltFont} キーに指定する値は,次のように二重のコンマ区切りリストである:
6103 %</ja>
6104 \begin{lstlisting}[escapechar=\#]
6105 AltFont = {
6106   ...
6107   { Range=#\LARG range>#, #\LARG features>#},
6108   { Range=#\LARG range>#, Font=#\LARG font~name>#, #\LARG features># },
6109   { Range=#\LARG range>#, Font=#\LARG font~name># },
6110   ...
6111 }
6112 \end{lstlisting}
6113 %<*en>
6114 Each sublist should have the \texttt{Range} key
6115 (sublist which does not contain \texttt{Range} key is simply ignored).
6116 A demonstrarion is shown in Figure~\ref{fig:altkanji-fontspec}.
6117 %</en>
6118 %<*ja>
6119 各部分リストには \texttt{Range} キーが必須である(含まれない部分リストは
6120 単純に無視される).指定例は図\ref{fig:altkanji-fontspec}に示した.
6121 %</ja>
6122 \end{cslist}
6123
6124 %<*ja>
6125 なお,\Pkg{luatexja-fontspec} 読み込み時には和文フォント定義ファイル%
6126 \texttt{<ja-enc><family>.fd}は全く参照されなくなる.
6127 %</ja>
6128
6129
6130 %<*en>
6131 \paragraph{Remark on \texttt{AltFont}, \texttt{YokoFeatures}, \texttt{TateFeatures} keys}
6132 In \texttt{AltFont},~\texttt{YokoFeatures},~\texttt{TateFeatures} keys,
6133 one cannot specify per-shape settings such as \texttt{BoldFeatures}.
6134 For example,
6135 \begin{lstlisting}
6136 AltFont = {
6137   { Font=HogeraMin-Light, BoldFont=HogeraMin-Bold,
6138     Range="3000-"30FF, BoldFeatures={Color=007F00} }
6139 }
6140 \end{lstlisting}
6141 does \emph{not} work. Instead, one have to write
6142 \begin{lstlisting}
6143 UprightFeatures = {
6144   AltFont = { { Font=HogeraMin-Light, Range="3000-"30FF, } },
6145 },
6146 BoldFeatures = {
6147   AltFont =  { { Font=HogeraMin-Bold, Range="3000-"30FF, Color=007F00 } },
6148 }
6149 \end{lstlisting}
6150
6151 On the other hand, \texttt{YokoFeatures}, \texttt{TateFeatures} and  \texttt{TateFont}
6152 keys can be specified in each list in the \texttt{AltFont} key. Also,
6153 one can specify \texttt{AltFont} inside \texttt{YokoFeatures},~\texttt{TateFeatures}.
6154
6155 Note that features which are specified in \texttt{YokoFeatures}~and~\texttt{TateFeatures}
6156 are always interpreted \emph{after} other ``direction-independent'' features.
6157 This explains why \cs{addjfontfeatures} at~line~6 in~Figure~\ref{fig:yokotate-fontspec}
6158 has no effect, because a color specification is already done in
6159 \texttt{YokoFeatures}~and~\texttt{TateFeatures} keys.
6160 %</en>
6161 %<*ja>
6162 \paragraph{\texttt{AltFont}, \texttt{YokoFeatures}, \texttt{TateFeatures} 等の制限}
6163 \texttt{AltFont},~\texttt{YokoFeatures},~\texttt{TateFeatures}の各キーは
6164 シェイプ別に指定されるべきものであり,
6165 内部では \texttt{BoldFeatures} などのシェイプ別の指定は行うことが出来ない.
6166 例えば.
6167 \begin{lstlisting}
6168 AltFont = {
6169   { Font=HogeraMin-Light, BoldFont=HogeraMin-Bold,
6170     Range="3000-"30FF, BoldFeatures={Color=007F00} }
6171 }
6172 \end{lstlisting}
6173 のように指定することは出来ず,
6174 \begin{lstlisting}
6175 UprightFeatures = {
6176   AltFont = { { Font=HogeraMin-Light, Range="3000-"30FF, } },
6177 },
6178 BoldFeatures = {
6179   AltFont =  { { Font=HogeraMin-Bold, Range="3000-"30FF, Color=007F00 } },
6180 }
6181 \end{lstlisting}
6182 のように指定しなければならない.
6183
6184 一方,\texttt{AltFont} キー内の各リストでは
6185 \ \texttt{YokoFeatures},~\texttt{TateFeatures} 及び \texttt{TateFont} キーを
6186 指定することは可能であり.また\ \texttt{YokoFeatures},~\texttt{TateFeatures} キーの
6187 中身に \texttt{AltFont} を指定することができる.
6188
6189 また,図\ref{fig:yokotate-fontspec}後半部では6行目の色の指定が効かず,
6190 2行目で指定した\ \texttt{YokoFeatures},~\texttt{TateFeatures}\ による色の指定が有効になっ
6191 たままである.これは\emph{\ \texttt{YokoFeatures},~\texttt{TateFeatures}\ によるfeature指定は
6192 組方向に依存しないfeature指定より後に解釈される}からである.
6193
6194 %</ja>
6195
6196
6197 \subsection{\texttt{luatexja-otf.sty}}
6198 \label{ssec-ltjotf}
6199 %<*en>
6200 This optional package supports typesetting characters in
6201 Adobe-Japan1 character collection
6202 (or other CID character collection, if the font is supported).
6203 The package \Pkg{luatexja-otf} offers the following 2~low-level
6204 commands:
6205 %</en>
6206 %<*ja>
6207 この追加パッケージはAdobe-Japan1(フォント自身が持っていれば,
6208 別のCID文字セットでも可)の文字の出力をサポートする.
6209 \Pkg{luatexja-otf}は以下の2つの低レベルコマンドを提供する:
6210 %</ja>
6211 \begin{cslist}
6212 \item[\cs{CID}\{<number>\}]
6213 %<*en>
6214 Typeset a character whose CID number is <number>.
6215 %</en>
6216 %<*ja>
6217 CID番号が<number>の文字を出力する.
6218 %</ja>
6219
6220 \item[\cs{UTF}\{<hex\_number>\}]
6221 %<*en>
6222 Typeset a character whose character code is <hex\_number> (in hexadecimal).
6223 This command is similar to \verb+\char"+<hex\_number>,\ %"
6224 but please remind remarks below.
6225 %</en>
6226 %<*ja>
6227 文字コードが(16進で)<hex\_number>の文字を出力する.
6228 このコマンドは \verb+\char"+<hex\_number>と似ているが,下の注意を参照すること.%"
6229 %</ja>
6230 \end{cslist}
6231
6232 %<*ja>
6233 このパッケージは,マクロ集 \texttt{luatexja-ajmacros.sty}\footnote{\Pkg{otf}パッケージ付属の井上浩一氏によるマクロ集
6234 \texttt{ajmacros.sty} に対して
6235 漢字コードをUTF-8にしたり,plain \LuaTeX でも利用可能にするという
6236 修正を加えたものである.}\ も自動的に読み込む.
6237 \texttt{luatexja-ajmacros.sty} は,
6238 そのため,\Pkg{luatexja-otf} を読みこめば \texttt{ajmacros.sty} マクロ集にある \cs{aj半角} などのマクロもそのまま使うことができる.
6239 %</ja>
6240 %<*en>
6241 This package automatically loads \texttt{luatexja-ajmacros.sty}, which is slightly
6242 modified version of \texttt{ajmacros.sty}\footnote{Useful macros by iNOUE Koich!, for the
6243 \Pkg{japanese-otf} package.}.
6244 Hence one can use macros which sre defined in \texttt{ajmacros.sty}, such as~\cs{aj半角}.
6245 %</en>
6246
6247 %<en>\paragraph{Remarks}
6248 %<ja>\paragraph{注意}
6249 %<*en>
6250 Characters by \cs{CID} and \cs{UTF} commands are different from
6251 ordinary characters in the following points:
6252 %</en>
6253 %<*ja>
6254 \cs{CID} と \cs{UTF} コマンドによって出力される文字は
6255 以下の点で通常の文字と異なる:
6256 %</ja>
6257 \begin{itemize}
6258 %<*en>
6259 \item Always treated as \textbf{JAchar}s.
6260 %</en>
6261 %<*ja>
6262 \item 常に\textbf{JAchar}として扱われる.
6263 %</ja>
6264 %<*en>
6265 \item Processing codes for supporting OpenType features (\textit{e.g.},
6266       glyph replacement and kerning) by the \Pkg{luaotfload} package
6267       is not performed to these characters.
6268 %</en>
6269 %<*ja>
6270 \item OpenType feature(例えばグリフ置換やカーニング)をサポートするための
6271   \Pkg{luaotfload}パッケージのコードはこれらの文字には働かない.
6272 %</ja>
6273 \end{itemize}
6274
6275 %<en>\paragraph{Additional syntax of JFM}
6276 %<ja>\paragraph{JFMへの記法の追加}
6277
6278 %<*en>
6279 The package \Pkg{luatexja-otf} extends the syntax of JFM; the entries of \texttt{
6280 chars} table in JFM now allows a string in the form
6281 \verb+'AJ1-xxx'+, which stands for the character
6282 whose CID number in Adobe-Japan1 is \verb+xxx+.
6283
6284 This extended notation is used in the standard JFM \texttt{jfm-ujis.lua}
6285 to typeset halfwidth Hiragana glyphs (CID~516--598) in halfwidth.
6286 %</en>
6287 %<*ja>
6288 \Pkg{luatexja-otf}パッケージを読み込むと,
6289 JFMの\texttt{chars}テーブルのエントリとして \verb+'AJ1-xxx'+ の形の文字列が
6290 使えるようになる.これはAdobe-Japan1におけるCID番号が \verb+xxx+ の文字を表す.
6291
6292 この拡張記法は,標準JFM~\texttt{jfm-ujis.lua}で,半角ひらがなのグリフ(CID~516--598)を
6293 正しく半角幅で組むために利用されている.
6294 %</ja>
6295
6296 %<*en>
6297 \paragraph{IVS support}
6298 Recent fonts support Ideographic Variation Selector (IVS).
6299 It seems that \Pkg{luaotfload} and \Pkg{fontspec} packages do not support
6300 IVS, so we implemented IVS support in \Pkg{luatexja-otf}.
6301 \emph{IVS support is experimental; if you want to enable this, load
6302 \Pkg{luatexja-otf} and execute the following:}
6303 %</en>
6304 %<*ja>
6305 \paragraph{IVSサポート}
6306 最近のOpenTypeフォントやTrueTypeフォントには,
6307 \texttt{U+E0100}--\texttt{U+E01EF}の範囲の「文字」
6308 (漢字用異体字セレクタ)を後置することによって
6309 字形を指定する仕組み(IVS)が含まれている.
6310 執筆時点の2013年12月では,\Pkg{luaotfload}や\Pkg{fontspec}パッケージ類は
6311 IVSに対応してはいないようである.これらのパッケージで対応してくれるのが理想的だが,
6312 それまでのつなぎとして,\Pkg{luatexja-otf}パッケージ内にIVS対応を仕込んでおいた.
6313
6314 \medskip
6315
6316 \emph{IVS対応は試験的なものである.
6317 有効にするには,\Pkg{luatexja-otf}パッケージを読み込んだ上で以下の命令を実行する%
6318 \footnote{この命令を2回以上実行しても意味がない.}:}
6319 %</ja>
6320 \begin{lstlisting}
6321 \directlua{luatexja.otf.enable_ivs()}
6322 \end{lstlisting}
6323 %<ja> すると,上の命令を実行した箇所以降では,以下のようにIVSによる字形指定が有効となる.
6324 %<en> After executing the command above, you can use IVS like the following:
6325 \begin{LTXexample}
6326 \Large
6327 \jfontspec{KozMinPr6N-Regular}
6328 奈良県葛󠄀城市と,東京都葛󠄁飾区.\\
6329 こんにちは,渡
6330 邉󠄀邉󠄁邉󠄂邉󠄃邉󠄄
6331 邉󠄅邉󠄆邉󠄇邉󠄈邉󠄉
6332 邉󠄊邉󠄋邉󠄌邉󠄍邉󠄎
6333 さん.
6334 \end{LTXexample}
6335 %<*ja>
6336 左上側の入力においては,漢字用異体字セレクタを明示するため,
6337 例えばVariation~Selector~18 (\texttt{U+E0101})を\IVSB{18}のように表記している.
6338 %</ja>
6339 \medskip
6340
6341 %<*en>
6342 Specifying glyph variants by IVS precedes glyph replacement by font features.
6343 For example, only ``葛'' in ``葛西'' is changed by font features
6344 \texttt{jp78}~or~\texttt{jp90}, which does not followed by any variation selector.
6345 %</en>
6346 %<*ja>
6347 また,IVSによる字形指定は,font featureによるそれに優先されることとした.
6348 下の例において,\texttt{jp78}, \texttt{jp90} 指定で字形が変化した文字は
6349 異体字セレクタが続いていない「葛西」中の「葛」のみである.
6350 %</ja>
6351 \begin{LTXexample}
6352  \def\TEST#1{%
6353    {\jfontspec[#1]{KozMinPr6N-Regular}%
6354    葛󠄀城市,葛󠄁飾区,葛西}\\}
6355  指定なし:\TEST{}
6356  \texttt{jp78}:\TEST{CJKShape=JIS1978}
6357  \texttt{jp90}:\TEST{CJKShape=JIS1990}
6358 \end{LTXexample}
6359
6360 %<*ja>
6361 現状では,\TeX 側のインターフェースとなる \Pkg{luatexja-otf.sty} は一切変更していない
6362 ので,ZRさんによる\Pkg{PXipamjm}パッケージ%
6363 \footnote{\url{https://github.com/zr-tex8r/PXipamjm}. 説明は彼のブログ記事
6364 「pxipamjm パッケージの説明書のような何か(\url{http://d.hatena.ne.jp/zrbabbler/20131221})」
6365 にある.}
6366 にあるような気の利いた命令はまだない.
6367 異体字の一覧表示を行いたい場合は,gitリポジトリ内の \texttt{test/test19-ivs.tex} 中にある
6368 Lua・\TeX コードが参考になるだろう.
6369 %</ja>
6370
6371
6372 \subsection{\texttt{luatexja-adjust.sty}}
6373 \label{ssec-adj}
6374 \begin{figure}[t]
6375 \def\sq{%
6376   \hbox to 1\zw{\hss\fboxsep=-.5\fboxrule\fbox{%
6377    \hskip\dimexpr-.5\zw-.2pt\vrule width.4pt height.08\zw depth.12\zw%
6378   \hskip\dimexpr.5\zw-.2pt\relax}\hss}}
6379 \def\sb{\hbox to 1\zw{\hss\fboxsep=-.5\fboxrule\fbox{%
6380   ■\hskip\dimexpr-.5\zw-.2pt\vrule width.4pt height.08\zw depth.12\zw%
6381   \hskip\dimexpr.5\zw-.2pt\relax}\hss}}
6382 \newbox\gridbox
6383 \def\outbox#1{{\Large%
6384   \ltjsetparameter{kanjiskip=0pt plus .2\zw minus .2\zw}%
6385   \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}%
6386   \hbox{\textcolor{cyan}{\copy\gridbox}\hskip-20\zw%
6387   \vbox{\hsize=20\zw\noindent\leftskip0pt\rightskip0pt\parfillskip0pt#1}\vrule}%
6388 }}
6389
6390 {\centering
6391 \begin{tabular}{lc}
6392 \toprule
6393 no adjustment&\outbox{以上の原理は,「包除原理」とよく呼ばれるが\hskip-.5\zw\null}\\
6394 without priority&%
6395 \ltjdisableadjust
6396 \outbox{以上の原理は,「包除原理」とよく呼ばれるが}%
6397 \ltjenableadjust\\
6398 with priority&%
6399 \outbox{以上の原理は,「包除原理」とよく呼ばれるが}
6400 %<en>\ltjdisableadjust
6401 \\
6402 \bottomrule
6403 \end{tabular}\par}
6404 \smallskip
6405
6406 Note: the value of
6407 \Param{kanjiskip} is 0\,pt${}^{+1/5\,\mathrm{em}}_{-1/5\,\mathrm{em}}$ in this figure,
6408 for making the difference obvious.
6409 %<ja>\caption{行長調整}\label{fig-adj}
6410 %<en>\caption{Line adjustment}\label{fig-adj}
6411 \end{figure}
6412
6413
6414 %<*en>
6415 (see Japanese version of this manual)
6416 %</en>
6417 %<*ja>
6418 \pTeX では,行長調整において優先度の概念が存在しなかったため,図
6419 \ref{fig-adj}上段における半角分の半端は,図\ref{fig-adj}中段のように,鍵
6420 括弧周辺の空白と和文間空白(\Param{kanjiskip})の両方によって負担される.し
6421 かし,「日本語組版処理の要件」\cite{jlreq}やJIS~X~4051~\cite{x4051}におい
6422 ては,このような状況では半端は鍵括弧周辺の空白のみで負担し,その他の和文
6423 文字はベタ組で組まれる(図\ref{fig-adj}下段)ことになっている.この追加
6424 パッケージは\cite{jlreq}や\cite{x4051}における規定のような,優先順位付き
6425 の行長調整を提供する.詳細な仕様については\ref{sec-adjspec}章を参照してほしい.
6426 \begin{itemize}
6427  \item 優先度付き行長調整は,段落を行分割した後に個々の行について行われるものである.
6428 そのため,行分割の位置は変化することはない.
6429
6430 また,\verb+\hbox to ... {...}+ のような「幅が指定されたhbox」では無効である.
6431  \item 優先度付き行長調整を行うと,和文処理グルーの自然長は変化しないが,伸び量や縮み量は
6432 一般に変化する.そのため,既に組まれた段落を \cs{unhbox} などを利用して組み直す処理を
6433 行う場合には注意が必要である.
6434 \end{itemize}
6435
6436
6437 \Pkg{luatexja-adjust} は,以下の命令を提供する.これらはすべてグローバルに効力を発揮する.
6438
6439 \begin{cslist}
6440 \item[\cs{ltjdisableadjust}]
6441 優先順位付きの行長調整を無効化する.
6442
6443 \item[\cs{ltjenableadjust}]
6444 優先順位付きの行長調整を有効化する.
6445
6446 \item[\textsf{adjust}\,=<bool>] \cs{ltjsetparameter} で指定可能な追加パラメータであり,
6447 <bool>が\textit{true}なら \cs{ltjenableadjust} を,
6448 そうでなければ \cs{ltjdisableadjust} を実行する.
6449 \end{cslist}
6450 %</ja>
6451
6452 \subsection{\texttt{luatexja-ruby.sty}}
6453 %<*en>
6454 This addon package provides functionality of ``ruby'' (\emph{furigana}) annotations
6455 using callbacks of \LuaTeX-ja.
6456 There is no detailed manual of \Pkg{luatexja-ruby.sty} in English.
6457 (Japanese manual is another PDF file, \url{luatexja-ruby.pdf}.)
6458 %</en>
6459 %<*ja>
6460 この追加パッケージは,\LuaTeX-jaの機能を利用したルビ(振り仮名)の組版機能を提供する.
6461 前後の文字種に応じた前後への自動進入や,
6462 行頭形・行中形・行末形の自動的な使い分けが特徴である.
6463
6464 ルビ組版に設定可能な項目や注意事項が多いため,本追加パッケージの詳細な説明は
6465 使用例と共に \url{luatexja-ruby.pdf}\ という別ファイルに載せている.
6466 この節では簡単な使用方法のみ述べる.
6467 %</ja>
6468
6469 \begin{description}
6470 %<*en>
6471  \item[Group-ruby]
6472 By default, ruby characters (the second argument of \cs{ruby})
6473 are attached to base characters (the first argument), as one object.
6474 This type of ruby is called \emph{group-ruby}.
6475 %</en>
6476 %<*ja>
6477  \item[グループルビ] 標準ではグループルビの形で組まれる.第1引数に親文字,
6478 第2引数にルビを記述する.
6479 %</ja>
6480 \begin{LTXexample}[width=0.3\textwidth]
6481 東西線\ruby{妙典}{みようでん}駅は……\\
6482 東西線の\ruby{妙典}{みようでん}駅は……\\
6483 東西線の\ruby{妙典}{みようでん}という駅……\\
6484 東西線\ruby{葛西}{かさい}駅は……
6485 \end{LTXexample}
6486 %<*en>
6487 As the above example, ruby hangover is allowed on the Hiragana before/after
6488 its base characters.
6489 %</en>
6490 %<ja> この例のように,標準では前後の平仮名にルビ全角までかかるようになっている.
6491
6492 %<*en>
6493 \item[Mono-ruby]
6494 To attach ruby characters to each base characters (\emph{mono-ruby}),
6495 one should use \cs{ruby} multiple times:
6496 %</en>
6497 %<*ja>
6498  \item[モノルビ] 親文字を1文字にするとモノルビとなる.
6499 2文字以上の熟語をモノルビの形で組みたい場合は,面倒でも
6500 その数だけ \cs{ruby} を書く必要がある.
6501 %</ja>
6502 \begin{LTXexample}[width=0.3\textwidth]
6503 東西線の\ruby{妙}{みよう}\ruby{典}{でん}駅は……
6504 \end{LTXexample}
6505
6506 %<*en>
6507  \item[Jukugo-ruby]
6508 Vertical bar~\verb+|+ denotes a boundary of \emph{groups}.
6509 %</en>
6510 %<*ja>
6511  \item[熟語ルビ] 引数内の縦棒 \verb+|+ はグループの区切りを表し,
6512 複数グループのルビは熟語ルビとして組まれる.
6513 \cite{x4051}にあるように,
6514 どのグループでも「親文字」が対応するルビ以上の長さの場合は
6515 各グループごとに,そうでないときは全体をまとめて1つのグループルビとして組まれる.
6516 \cite{jlreq}で規定されている組み方とは異なるので注意.
6517 %</ja>
6518 \begin{LTXexample}
6519 \ruby{妙|典}{みよう|でん}\
6520 \ruby{葛|西}{か|さい}\
6521 \ruby{神楽|坂}{かぐら|ざか}
6522 \end{LTXexample}
6523 %<*en>
6524 If there are multiple groups in one \cs{ruby} call,
6525 A linebreak between two groups is allowed.
6526 %</en>
6527 %<ja> 複数ルビではグループとグループの間で改行が可能である.
6528 \begin{LTXexample}[width=0.3\textwidth]
6529 \vbox{\hsize=6\zw\noindent
6530   \hbox to 2.5\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
6531   \hbox to 2.5\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
6532   \hbox to   3\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
6533 }
6534 \end{LTXexample}
6535 \end{description}
6536
6537 %<*en>
6538 If the width of ruby characters are longer than that of base characters,
6539 \cs{ruby} automatically selects the appropriate form
6540 among the line-head form, the line-middle form, and the line-end form.
6541 %</en>
6542 %<*ja>
6543 また,ルビ文字のほうが親文字よりも長い場合は,自動的に
6544 行頭形・行中形・行末形のいずれか適切なものを選択する.
6545 %</ja>
6546 \begin{LTXexample}[width=0.3\textwidth]
6547 \vbox{\hsize=8\zw\noindent
6548 \null\kern3\zw ……を\ruby{承}{うけたまわ}る
6549      \kern1\zw ……を\ruby{承}{うけたまわ}る\\
6550 \null\kern5\zw ……を\ruby{承}{うけたまわ}る
6551 }
6552 \end{LTXexample}
6553
6554
6555 %<*ja>
6556 \subsection{\texttt{lltjext.sty}}
6557 \pLaTeX では縦組用の拡張として \Pkg{plext} パッケージが用意されていたが,
6558 それを\LuaTeX-ja用に書きなおしたものが本追加パッケージ \Pkg{lltjext} である.
6559
6560 従来の \Pkg{plext} パッケージとの違いは,
6561 {\catcode`\<=12
6562 \begin{itemize}
6563  \item 組方向オプション \texttt{<y>}(横組),\texttt{<t>}(縦組),
6564 \texttt{<z>}\ の他に\ \texttt{<d>}(dtou方向),\texttt{<u>}(utod方向)を追加した.
6565 \texttt{<z>} と \texttt{<u>} の違いは,\texttt{<z>} が(\Pkg{plext} パッケージと同様に)
6566 周囲の組方向が縦組のときにしか意味を持たない
6567        のに対し,\texttt{<u>} にはそのような制限がないことである.
6568
6569  \item \Pkg{plext} パッケージでは,表組(\texttt{tabular} 環境,\texttt{align} 環境等)や
6570 \texttt{minipage} 環境,\cs{parbox} 命令において,
6571 垂直位置指定 \texttt{[t]},~\texttt{[b]} の挙動が非読み込み時と微妙に変わることがあった.
6572
6573 \Pkg{lltjext} パッケージでは,垂直位置指定が\LaTeXe と同様の挙動(以下に示す)に
6574 なるように修正した.
6575 \begin{itemize}
6576  \item \texttt{[t]} オプション指定時は,ボックスのベースラインが中身の1行目のベースライン
6577        (1行目の上に罫線などが来た時は,ボックスの上端)に一致するように配置する.
6578  \item \texttt{[b]} オプション指定時は,ボックスのベースラインが中身の最終行のベースライン
6579        (中身の最後が罫線などの時は,ボックスの下端)に一致するように配置する.
6580  \item それ以外のときは,ボックスの中央が「数式の軸」に一致するように配置する.
6581 \end{itemize}
6582
6583  \item 連数字用命令 \cs{rensuji} における位置合わせオプション \texttt{[l]}, \texttt{[c]},
6584        \texttt{[r]} の挙動を若干変更した.
6585
6586 \end{itemize}
6587 }
6588 %</ja>
6589 %<*en>
6590 \subsection{\texttt{lltjext.sty}}
6591 \pLaTeX\ supplies additional macros for vertical writing in the \Pkg{plext} package.
6592 The \Pkg{lltjext} package which we want to describe here is the \LuaTeX-ja
6593 counterpart of the \Pkg{plext} package.
6594 %</en>
6595
6596 %<*ja>
6597 念の為,本 \Pkg{lltjext} パッケージで追加・変更している命令の一覧を載せておく.
6598 \begin{cslist}
6599 \item[tabular\textrm{, }array\textrm{, }minipage環境]
6600 これらの環境は,
6601 \begin{lstlisting}
6602 \begin{tabular}<dir>[pos]{table spec} ... \end{tabular}
6603 \begin{array}<dir>[pos]{table spec}   ... \end{array}
6604 \begin{minipage}<dir>[pos]{width}     ... \end{minipage}
6605 \end{lstlisting}
6606 のように,組方向オプション \texttt{\<dir\>} が拡張されている.
6607 既に述べたように,組方向オプションに指定できる値は以下の5つであり,
6608 それ以外を指定した時や無指定時は周囲の組方向と同じ組方向になる.
6609 \begin{description}
6610  \item[y] 横組(\cs{yoko})
6611  \item[t] 縦組(\cs{tate})
6612  \item[z] 周囲が縦組の時はutod方向,それ以外はそのまま
6613  \item[d] dtou方向
6614  \item[u] utod方向
6615 \end{description}
6616 \item[\cs{parbox}\<<dir>\>{[<pos>]}\{<width>\}\{<contents>\}]
6617 \cs{parbox} 命令も同様に,組方向の指定ができるように拡張されている.
6618
6619 \item[\cs{pbox}\<<dir>\>{[<width>][<pos>]}\{<contents>\}]
6620 組方向<dir>で<contents>の中身をLRモードで組む命令である.
6621 <width>が正の値であるときは,ボックス全体の幅がその値となる.
6622 その際,中身は<pos>の値に従い,左寄せ(\texttt{l}),右揃え(\texttt{r}),
6623 中央揃え(それ以外)される.
6624 \item[picture環境]
6625 図表作成に用いる \texttt{picture} 環境も,
6626 \begin{lstlisting}
6627 \begin{picture}<dir>(x_size, y_size)(x_offset,y_offset)
6628   ...
6629 \end{picture}
6630 \end{lstlisting}
6631 と組方向が指定できるように拡張されている.
6632 $x$成分の増加方向は字送り方向,$y$成分の増加方向は行送り方向の\emph{反対方向}となる.
6633 \Pkg{plext} パッケージと同様に
6634 内部ではベースライン補正(\Param{yalbaselineshift}パラメータなど)の影響を受けないように,
6635 \cs{put},~\cs{line}, \cs{vector}, \cs{dashbox}, \cs{oval},~\cs{circle}も
6636 ベースライン補正を受けないように再定義されている.
6637
6638 \item[\cs{rensuji}{[<pos>]}\{<contents>\}\textrm{, }\cs{rensujiskip}]
6639
6640 \item[\cs{Kanji}\{<counter\_name>\}]
6641
6642 \item[\cs{kasen}\{<contents>\}\textrm{, }\cs{bou}\{<contents>\}\textrm{,
6643                      }\cs{boutenchar}]
6644
6645 \item[参照番号]
6646 \end{cslist}
6647 %</ja>
6648 %<*en>
6649 \begin{cslist}
6650 \item[tabular\textrm{, }array\textrm{, }minipage\textrm{ environments}]
6651 These environments are extended by \texttt{\<dir\>}, which specifies the direction,
6652 as follows:
6653 \begin{lstlisting}
6654 \begin{tabular}<dir>[pos]{table spec} ... \end{tabular}
6655 \begin{array}<dir>[pos]{table spec}   ... \end{array}
6656 \begin{minipage}<dir>[pos]{width}     ... \end{minipage}
6657 \end{lstlisting}
6658 This option permits one of the following five values. If none of them is specified,
6659 the direction inside the environment is same as that outside the enviromnent.
6660 \begin{description}
6661  \item[y] \emph{yoko} direction (horizontal writing)
6662  \item[t] \emph{tate} direction (vertical writing)
6663  \item[z] \emph{utod} direction if direction outside the env.\ is \emph{tate}.
6664  \item[d] \emph{dtou} direction
6665  \item[u] \emph{utod} direction
6666 \end{description}
6667 \item[\cs{parbox}\<<dir>\>{[<pos>]}\{<width>\}\{<contents>\}]
6668 \cs{parbox} command is also extended by \texttt{\<dir\>}.
6669
6670 \item[\cs{pbox}\<<dir>\>{[<width>][<pos>]}\{<contents>\}]
6671 This commands typeset <contents> in LR-mode, in <dir> direction.
6672 If <width> is positive, the width of the box becomes this <width>.
6673 In this case, <contents> will be aligned \dots
6674
6675 \item[picture\textrm{\ environment}]
6676
6677 \item[\cs{rensuji}{[<pos>]}\{<contents>\}\textrm{, }\cs{rensujiskip}]
6678
6679 \item[\cs{Kanji}\{<counter\_name>\}]
6680
6681 \item[\cs{kasen}\{<contents>\}\textrm{, }\cs{bou}\{<contents>\}\textrm{,
6682                      }\cs{boutenchar}]
6683
6684 \item[参照番号]
6685 \end{cslist}
6686 %</en>
6687
6688
6689
6690 %<en>\part{Implementations}
6691 %<ja>\part{実装}
6692 \label{part-imp}
6693 %<en>\section{Storing Parameters}
6694 %<ja>\section{パラメータの保持}
6695 \label{sec-para}
6696 %<en>\subsection{Used Dimensions, Attributes and Whatsit Nodes}
6697 %<ja>\subsection{\LuaTeX-jaで用いられるレジスタとwhatsitノード}
6698
6699 %<*en>
6700 Here the following is the list of dimensions and attributes which are used in \LuaTeX-ja.
6701 %</en>
6702 %<*ja>
6703 以下は\LuaTeX-jaで用いられる寸法レジスタ(dimension),属性レジスタ(attribute)の
6704 リストである.
6705 %</ja>
6706 \begin{list}{}{%
6707 \def\makelabel{\ttfamily}\advance\leftmargin1\zw
6708 \def\dim#1{\item[\textbackslash #1\ \textrm{(dimension)}]}
6709 \def\cnt#1{\item[\textbackslash #1\ \textrm{(counter)}]}
6710 \def\attr#1{\item[\textbackslash #1\ \textrm{(attribute)}]}
6711 }
6712
6713 \dim{jQ}
6714 %<*en>
6715 \cs{jQ} is equal to
6716                         $1\,\textrm{Q}=0.25\,\textrm{mm}$, where ``Q''~(also called ``級'') is
6717                         a unit used in Japanese phototypesetting.
6718 So one should not change the value of this dimension.
6719 %</en>
6720 %<*ja>
6721 \cs{jQ} は写植で用いられた$1\,\textrm{Q}=0.25\,\textrm{mm}$%
6722 (「級」とも書かれる)に等しい.したがって,
6723 この寸法レジスタの値を変更してはならない.
6724 %</ja>
6725
6726 \dim{jH}
6727 %<*en>
6728 There is also a unit called ``歯'' which equals to $0.25\,\textrm{mm}$ and
6729                          used in Japanese phototypesetting.
6730 This \cs{jH} is the same \cs{dimen} register as \cs{jQ}.
6731 %</en>
6732 %<*ja>
6733 同じく写植で用いられていた単位として「歯」があり,これも$0.25\,\textrm{mm}$と
6734 等しい.この \cs{jH} は \cs{jQ} と同じ寸法レジスタを指す.
6735 %</ja>
6736
6737 \dim{ltj@zw}
6738 %<*en>
6739 A temporal register for the ``full-width'' of current Japanese font.
6740 The command \cs{zw} sets this register to the correct value, and
6741 ``return'' this register itself.
6742 %</en>
6743 %<*ja>
6744 現在の和文フォントの「全角幅」を保持する一時レジスタ.
6745 \cs{zw} 命令は,このレジスタを適切な値に設定した後,
6746 「このレジスタ自体を返す」.
6747 %</ja>
6748
6749 \dim{ltj@zh}
6750 %<*en>
6751 A temporal register for the ``full-height'' (usually the sum of height of imaginary body and its depth) of current Japanese font.
6752 The command \cs{zh} sets this register to the correct value, and
6753 ``return'' this register itself.
6754 %</en>
6755 %<*ja>
6756 現在の和文フォントの「全角高さ」(通常,高さと深さの和)を保持する一時レジスタ.
6757 \cs{zh} 命令は,このレジスタを適切な値に設定した後,
6758 「このレジスタ自体を返す」.
6759 %</ja>
6760
6761 \attr{jfam}
6762 %<*en>
6763 Current number of Japanese font family for math formulas.
6764 %</en>
6765 %<*ja>
6766 数式用の和文フォントファミリの現在の番号.
6767 %</ja>
6768
6769 \attr{ltj@curjfnt}
6770 %<*en>
6771 The font index of current Japanese font for horizontal direction.
6772 %</en>
6773 %<*ja>
6774 現在の横組用和文フォントのフォント番号.
6775 %</ja>
6776
6777 \attr{ltj@curtfnt}
6778 %<*en>
6779 The font index of current Japanese font for vertical direction.
6780 %</en>
6781 %<*ja>
6782 現在の縦組用和文フォントのフォント番号.
6783 %</ja>
6784
6785 \attr{ltj@charclass}
6786 %<*en>
6787 The character class of a \textbf{JAchar}. This attribute is only set on a
6788                          \textit{glyph\_node} which contains a \textbf{JAchar}.
6789 %</en>
6790 %<*ja>
6791 \textbf{JAchar}の文字クラス.\textbf{JAchar}が格納された\textit{glyph\_node}でのみ使われる.
6792 %</ja>
6793
6794 \attr{ltj@yablshift}
6795 %<*en>
6796 The amount of shifting the baseline of alphabetic fonts in scaled point ($2^{-16}\,\textrm{pt}$).
6797 %</en>
6798 %<*ja>
6799 スケールド・ポイント($2^{-16}\,\textrm{pt}$)を単位とした欧文フォントのベースラインの移動量.
6800 %</ja>
6801
6802 \attr{ltj@ykblshift}
6803 %<*en>
6804 The amount of shifting the baseline of Japanese fonts in scaled point ($2^{-16}\,\textrm{pt}$).
6805 %</en>
6806 %<*ja>
6807 スケールド・ポイント($2^{-16}\,\textrm{pt}$)を単位とした和文フォントのベースラインの移動量.
6808 %</ja>
6809
6810 \attr{ltj@tablshift}
6811 \attr{ltj@tkblshift}
6812
6813 \attr{ltj@autospc}
6814 %<*en>
6815 Whether the auto insertion of \Param{kanjiskip} is allowed at the node.
6816 %</en>
6817 %<*ja>
6818 そのノードで\Param{kanjiskip}の自動挿入が許されるかどうか.
6819 %</ja>
6820
6821 \attr{ltj@autoxspc}
6822 %<*en>
6823 Whether the auto insertion of \Param{xkanjiskip} is allowed at the node.
6824 %</en>
6825 %<*ja>
6826 そのノードで\Param{xkanjiskip}の自動挿入が許されるかどうか.
6827 %</ja>
6828
6829 \attr{ltj@icflag}
6830 %<*en>
6831 An attribute for distinguishing ``kinds'' of a node. One of the following value is
6832 assigned to this attribute:
6833 %</en>
6834 %<*ja>
6835 ノードの「種類」を区別するための属性.以下のうちのひとつが値として割り当てられる:
6836 %</ja>
6837 \begin{description}
6838 \item[\textit{italic} (1)]
6839 %<*en>
6840 Kerns from italic correction (\verb+\/+), or from kerning information of a Japanese font.
6841 These kerns are ``ignored'' in the insertion process of \textbf{JAglue},
6842 unlike explicit \cs{kern}.
6843 %</en>
6844 %<*ja>
6845 イタリック補正(\verb+\/+)によるカーン,
6846 または \Pkg{luaotfload} によって挿入されたフォントのカーニング情報由来のカーン.
6847 これらのカーンは通常の \cs{kern} とは異なり,
6848 \textbf{JAglue}の挿入処理においては透過する.
6849 %</ja>
6850
6851 \item[\textit{packed} (2)]
6852
6853 \item[\textit{kinsoku} (3)]
6854 %<*en>
6855 Penalties inserted for the word-wrapping process (\emph{kinsoku shori}) of Japanese characters.
6856 %</en>
6857 %<ja>禁則処理のために挿入されたペナルティ.
6858 \item[\mathversion{bold}$(\textit{from\_jfm}-2)$--$(\textit{from\_jfm}+2)$~(4--8)]
6859 %<en>Glues/kerns from JFM.
6860 %<ja>JFM由来のグルー/カーン.
6861 \item[\textit{kanji\_skip}~(9), \textit{kanji\_skip\_jfm}~(10)]
6862 %<en>Glues from \Param{kanjiskip}.
6863 %<ja>和文間空白\Param{kanjiskip}を表すグルー.
6864 \item[\textit{xkanji\_skip}~(11), \textit{xkanji\_skip\_jfm}~(12)]
6865 %<en>Glues from \Param{xkanjiskip}.
6866 %<ja>和欧文間空白\Param{xkanjiskip}を表すグルー.
6867 \item[\textit{processed} (13)]
6868 %<en>Nodes which is already processed by \ldots.
6869 %<ja>\LuaTeX-ja の内部処理によって既に処理されたノード.
6870 \item[\textit{ic\_processed} (14)]
6871 %<*en>
6872 Glues from an italic correction, but already processed in the insertion process of \textbf{JAglue}s.
6873 %</en>
6874 %<ja>イタリック補正に由来するグルーであって,既に \textbf{JAglue} 挿入処理にかかったもの.
6875 \item[\textit{boxbdd} (15)]
6876 %<en>Glues/kerns that inserted just the beginning or the ending of an hbox or a paragraph.
6877 %<ja>hboxか段落の最初か最後に挿入されたグルー/カーン.
6878 \end{description}
6879
6880 %<*ja>
6881 また,挿入処理の結果であるリストの最初のノードでは,\verb+\ltj@icflag+ の値に
6882 \textit{processed\_begin\_flag}~(128)が追加される.これによって,\cs{unhbox} が
6883 連続した場合でも「ボックスの境界」が識別できるようになっている.
6884 %</ja>
6885
6886 \attr{ltj@kcat\,$i$}
6887 %<*en>
6888 Where $i$~is a natural number which is less than~7.
6889 These 7~attributes store bit~vectors indicating which character block is regarded as a block of \textbf{JAchar}s.
6890 %</en>
6891 %<*ja>
6892 $i$は7より小さい自然数.
6893 これら7つの属性レジスタは,どの文字ブロックが\textbf{JAchar}のブロックとして
6894 扱われるかを示すビットベクトルを格納する.
6895 %</ja>
6896
6897 \attr{ltj@dir}
6898 %<*ja>
6899 \textit{direction}~whatsit(後述)において組方向を示すために,あるいは\textit{dir\_box}の
6900                          組方向を用いる.\textit{direction}~whatsitにおいては値は
6901 \begin{quote}
6902  \textit{dir\_dtou} (1), \textit{dir\_tate} (3),
6903  \textit{dir\_yoko} (4), \textit{dir\_utod} (11)
6904 \end{quote}
6905 のいずれかであり,\textit{dir\_box}ではこれらに次を加えた値をとる(\ref{sec-dir-imp}章参照).
6906 %</ja>
6907 \begin{description}
6908 \item[\textit{dir\_node\_auto} (128)]
6909 %<ja> 異なる組方向に配置するために自動的に作られたボックス.
6910 \item[\textit{dir\_node\_manual} (256)]
6911 %<ja> \cs{ltjsetwd} によって「ボックスの本来の組方向とは異なる組方向での寸法」を
6912 %<ja> 設定したときに,それを記録するためのボックス.
6913 \end{description}
6914 %<ja> \TeX 側から見える値,つまり \verb+\the\ltj@dir+ の値は常に0である.
6915
6916 \end{list}
6917
6918 %<*en>
6919 Furthermore, \LuaTeX-ja uses several user-defined whatsit nodes for
6920 internal processing. All those nodes except \emph{direction} whatsits
6921 store a natural number (hence its \texttt{type} is 100).
6922 \emph{direction} whatsits store a node list, hence its \texttt{type} is 110.
6923 Their \texttt{user\_id} (used for distinguish user-defined whatsits)
6924 are allocated by \texttt{luatexbase.newuserwhatsitid}.
6925 %</en>
6926 %<*ja>
6927 さらに,\LuaTeX-jaはいくつかのuser-defined whatsit nodeを内部処理に用いる.
6928 \textit{direction} whatsitはノードリストを格納するが,
6929 それ以外のwhatsitノードの \texttt{type} は100であり,ノードは自然数を格納している.
6930 user-defined whatsitを識別するための \texttt{user\_id} は\
6931 \texttt{luatexbase.newuserwhatsitid} により確保されており,
6932 下の見出しは単なる識別用でしかない.
6933 %</ja>
6934 \begin{description}
6935 \item[\textit{inhibitglue}]
6936 %<*en>
6937 Nodes for indicating that \cs{inhibitglue} is
6938            specified. The \texttt{value} field of these nodes doesn't matter.
6939 %</en>
6940 %<*ja>
6941 \cs{inhibitglue} が指定されたことを示すノード.これらのノードの\
6942 \texttt{value} フィールドは意味を持たない.
6943 %</ja>
6944
6945 \item[\textit{stack\_marker}]
6946 %<*en>
6947 Nodes for \LuaTeX-ja's stack system (see the next
6948            subsection). The \texttt{value} field of these nodes is
6949            current group level.
6950 %</en>
6951 %<*ja>
6952 \LuaTeX-jaのスタックシステム(次の節を参照)のためのノード.
6953 これらのノードの \texttt{value} フィールドは現在のグループネストレベルを表す.
6954 %</ja>
6955
6956 \item[\textit{char\_by\_cid}]
6957 %<*en>
6958 Nodes for \textbf{JAchar} which the callback process of
6959            \Pkg{luaotfload} won't be applied, and the character code is
6960            stored in the \texttt{value} field. Each node of this type are
6961            converted to a \textit{glyph\_node} \emph{after}
6962            the callback process of luaotfload.
6963 Nodes of this type is used in \cs{CID}, \cs{UTF} and IVS support.
6964 %</en>
6965 %<*ja>
6966 \Pkg{luaotfload}のコールバックによる処理が適用されない\textbf{JAchar}のためのノードで,
6967 \texttt{value} フィールドに文字コードが格納されている.
6968 この種類のノードはそれぞれが\Pkg{luaotfload}のコールバックの処理の
6969 \emph{後で}\textit{glyph\_node}に変換される.
6970 \cs{CID}, \cs{UTF}やIVS対応処理でこの種類のノードが利用されている.
6971 %</ja>
6972
6973 \item[\textit{replace\_vs}]
6974 %<*en>
6975 Similar to \textit{char\_by\_cid} whatsits above.
6976 These nodes are for \textbf{ALchar} which the callback process of
6977            \Pkg{luaotfload} won't be applied.
6978 %</en>
6979 %<*ja>
6980 上の\textit{char\_by\_cid}と同様に,
6981 これらのノードは\Pkg{luaotfload}のコールバックによる処理が適用されない\textbf{ALchar}のた
6982            めものである.
6983 %</ja>
6984
6985 \item[\textit{begin\_par}]
6986 %<*en>
6987 Nodes for indicating beginning of a paragraph.
6988 A paragraph which is started by \cs{item} in list-like environments has a horizontal box
6989 for its label before the actual contents. So \dots
6990 %</en>
6991 %<*ja>
6992 「段落の開始」を意味するノード.
6993 list環境,itemize環境などにおいて,\cs{item} で始まる各項目は……
6994 %</ja>
6995
6996 \item[\textit{direction}]
6997
6998 \end{description}
6999
7000 %<*en>
7001 These whatsits will be removed during the process of inserting \textbf{JAglue}s.
7002 %</en>
7003 %<*ja>
7004 これらのwhatsitノードは\textbf{JAglue}の挿入処理の間に取り除かれる.
7005 %</ja>
7006
7007 %<en>\subsection{Stack System of \LuaTeX-ja}
7008 %<ja>\subsection{\LuaTeX-jaのスタックシステム}
7009 \label{ssec-stack}
7010
7011 %<en>\paragraph{Background}
7012 %<ja>\paragraph{背景}
7013 %<*en>
7014 \LuaTeX-ja has its own stack system, and most parameters of \LuaTeX-ja
7015 are stored in it. To clarify the reason, imagine the parameter
7016 \Param{kanjiskip} is stored by a skip, and consider the following
7017 source:
7018 %</en>
7019 %<*ja>
7020 \LuaTeX-jaは独自のスタックシステムを持ち,\LuaTeX-jaのほとんどのパラメータは
7021 これを用いて保持されている.その理由を明らかにするために,
7022 \Param{kanjiskip}パラメータがスキップレジスタで保持されているとし,
7023 以下のコードを考えてみよう:
7024 %</ja>
7025 \begin{LTXexample}
7026 \ltjsetparameter{kanjiskip=0pt}ふがふが.%
7027 \setbox0=\hbox{%
7028   \ltjsetparameter{kanjiskip=5pt}ほげほげ}
7029 \box0.ぴよぴよ\par
7030 \end{LTXexample}
7031
7032 %<*en>
7033 As described in Subsection~\ref{ssec-param}, the only effective value of
7034 \Param{kanjiskip} in an hbox is the latest value, so the value of
7035 \Param{kanjiskip} which applied in the entire hbox should be 5\,pt.
7036 However, by the implementation method of \LuaTeX, this ``5\,pt'' cannot be
7037 known from any callbacks.  In the \texttt{tex/packaging.w}, which is a
7038 file in the source of \LuaTeX, there are the following codes:
7039 %</en>
7040 %<*ja>
7041 \ref{ssec-param}節で述べたように,あるhboxの中で効力を持つ
7042 \Param{kanjiskip}の値は最後に現れた値のみであり,したがってボックス全体に適用される
7043 \Param{kanjiskip}は5\,ptであるべきである.しかし,\LuaTeX の実
7044 装を観察すると,この5\,ptという長さはどのコールバックからも知ることはできないことがわかる.
7045 \LuaTeX のソースファイルの1つ \texttt{tex/packaging.w} の中に,
7046 以下のコードがある:
7047 %</ja>
7048 \begin{lstlisting}[numbers=left,firstnumber=1226]
7049 void package(int c)
7050 {
7051     scaled h;                   /* height of box */
7052     halfword p;                 /* first node in a box */
7053     scaled d;                   /* max depth */
7054     int grp;
7055     grp = cur_group;
7056     d = box_max_depth;
7057     unsave();
7058     save_ptr -= 4;
7059     if (cur_list.mode_field == -hmode) {
7060         cur_box = filtered_hpack(cur_list.head_field,
7061                                  cur_list.tail_field, saved_value(1),
7062                                  saved_level(1), grp, saved_level(2));
7063         subtype(cur_box) = HLIST_SUBTYPE_HBOX;
7064 \end{lstlisting}
7065 %<*en>
7066 Notice that \texttt{unsave()} is executed \emph{before}
7067 \texttt{filtered\_hpack()}, where \texttt{hpack\_filter} callback is
7068 executed) here. So ``5\,pt'' in the above source is orphaned at
7069 \texttt{unsave()}, and hence it can't be accessed from \texttt{hpack\_filter}
7070 callback.
7071 %</en>
7072 %<*ja>
7073 \texttt{unsave()} が \texttt{filtered\_hpack()}(これは \texttt{hpack\_filter} コールバックが
7074 実行されるところである)の\emph{前に}実行されていることに注意する.
7075 したがって,上記ソース中で5\,ptは \texttt{unsave()} のところで捨てられ,
7076 \texttt{hpack\_filter} コールバックからはアクセスすることができない.
7077 %</ja>
7078
7079 %<en>\paragraph{Implementation}
7080 %<ja>\paragraph{解決法}
7081
7082 %<*en>
7083 The code of stack system is based on that in a post of Dev-luatex mailing list\footnote{%
7084 \texttt{[Dev-luatex] tex.currentgrouplevel}, a post at 2008/8/19 by Jonathan Sauer.}.
7085 %</en>
7086 %<*ja>
7087 スタックシステムのコードはDev-luatexメーリングリストのある投稿\footnote{%
7088 \texttt{[Dev-luatex] tex.currentgrouplevel}: Jonathan Sauerによる2008/8/19の投稿.}を
7089 ベースにしている.
7090 %</ja>
7091
7092 %<*en>
7093 These are two \TeX\ count registers for maintaining information:
7094 \verb+\ltj@@stack+ for the stack level, and \verb+\ltj@@group@level+ for
7095 the \TeX's group level when the last assignment was done.  Parameters
7096 are stored in one big table named \texttt{charprop\_stack\_table}, where
7097 \texttt{charprop\_stack\_table[$i$]} stores data of stack level~$i$. If
7098 a new stack level is created by \cs{ltjsetparameter}, all data of the
7099 previous level is copied.
7100 %</en>
7101 %<*ja>
7102 情報を保持するために,2つの\TeX の整数レジスタを用いている:
7103 \verb+\ltj@@stack+ にスタックレベル,\verb+\ltj@@group@level+ に最後の代入が
7104 なされた時点での\TeX のグループレベルを保持している.
7105 パラメータは\texttt{charprop\_stack\_table}という名前のひとつの大きなテーブルに
7106 格納される.ここで,\texttt{charprop\_stack\_table[$i$]}はスタックレベル$i$の
7107 データを格納している.もし新しいスタックレベルが \cs{ltjsetparameter} によって
7108 生成されたら,前のレベルの全てのデータがコピーされる.
7109 %</ja>
7110
7111 %<*en>
7112 To resolve the problem mentioned in above paragraph ``Background'', \LuaTeX-ja uses
7113 another trick. When the stack level is about to be increased, a whatsit
7114 node whose type, subtype and value are 44~(\textit{user\_defined}),
7115 \textit{stack\_marker} and the current group level respectively is appended to the current
7116 list (we refer this node by \textit{stack\_flag}). This enables us to
7117 know whether assignment is done just inside a hbox. Suppose that the
7118 stack level is~$s$ and the \TeX's group level is~$t$ just after the hbox
7119 group, then:
7120 %</en>
7121 %<*ja>
7122 上の「背景」で述べた問題を解決するために,\LuaTeX-jaでは次の手法を用いる:
7123 スタックレベルが増加するするとき,type, subtype, valueがそれぞれ
7124 44~(\textit{user\_defined}), \textit{stack\_marker},そして現在のグループレベルであるwhatsitノード
7125 を現在のリストに付け加える(このノードを\textit{stack\_flag}とする).
7126 これにより,あるhboxの中で代入がなされたかどうかを知ることが可能
7127 となる.スタックレベルを$s$,そのhbox groupの直後の\TeX のグループレベルを
7128 $t$とすると:
7129 %</ja>
7130 \begin{itemize}
7131 %<*en>
7132 \item If there is no \textit{stack\_flag} node in the list of the contents of the hbox, then
7133       no assignment was occurred inside the hbox. Hence values of
7134       parameters at the end of the hbox are stored in the stack
7135       level~$s$.
7136 %</en>
7137 %<*ja>
7138 \item もしそのhboxの中身を表すリストの中に\textit{stack\_flag}ノードがなければ,
7139   hboxの中では代入は起こらなかったということになる.
7140   したがって,そのhboxの終わりにおけるパラメータの値はスタックレベル$s$に
7141   格納されている.
7142 %</ja>
7143
7144 %<*en>
7145 \item If there is a \textit{stack\_flag} node whose value is~$t+1$, then
7146       an assignment was occurred just inside the hbox group. Hence
7147       values of parameters at the end of the hbox are stored in the
7148       stack level~$s+1$.
7149 %</en>
7150 %<*ja>
7151 \item もし値が$t+1$の\textit{stack\_flag}ノードがあれば,その
7152   hboxの中で代入が起こったことになる.
7153   したがって,hboxの終わりにおけるパラメータの値はスタックレベル$s+1$に
7154   格納されている.
7155 %</ja>
7156
7157 %<*en>
7158 \item If there are \textit{stack\_flag} nodes but all of their values
7159       are more than~$t+1$, then an assignment was occurred in the box,
7160       but it is done in more internal group. Hence values of
7161       parameters at the end of the hbox are stored in the stack
7162       level~$s$.
7163 %</en>
7164 %<*ja>
7165 \item もし\textit{stack\_flag}ノードがあるがそれらの値が全て$t+1$より大きい
7166   場合,そのボックスの中で代入が起こったが,それは「より内部の」グループで
7167   起こったということになる.したがって,hboxの終わりでのパラメータの
7168   値はスタックレベル$s$に格納されている.
7169 %</ja>
7170 \end{itemize}
7171
7172 %<*en>
7173 Note that to work this trick correctly, assignments to
7174 \verb+\ltj@@stack+ and \verb+\ltj@@group@level+ have to be local always,
7175 regardless the value of \cs{globaldefs}.
7176 To solve this problem, we use another trick: the assignment
7177 \hbox{\verb+\directlua{tex.globaldefs=0}+} is always local.
7178 %</en>
7179 %<*ja>
7180 このトリックを正しく働かせるためには,\verb+\ltj@@stack+ と \verb+\ltj@@group@level+ への
7181 代入は \cs{globaldefs} の値によらず常にローカルでなければならないことに注意する.
7182 この問題は \hbox{\verb+\directlua{tex.globaldefs=0}+}(この代入は常にローカル)を
7183 用いることで解決している.
7184 %</ja>
7185
7186 %<*en>
7187 \subsection{Lua Functions of the Stack System}
7188 In this subsection, we will see how a user use \LuaTeX-ja's stack system to
7189 store some data which obeys the grouping of \TeX.
7190 %</en>
7191 %<*ja>
7192 \subsection{スタックシステムで使用される関数}
7193 本節では,ユーザが\LuaTeX-jaのスタックシステムを使用して,
7194 \TeX のグルーピングに従うような
7195 独自のデータを取り扱う方法を述べる.
7196 %</ja>
7197
7198 %<*en>
7199 The following function can be used to store data into a stack:
7200 \begin{lstlisting}
7201 luatexja.stack.set_stack_table(index, <any> data)
7202 \end{lstlisting}
7203 Any values which except \texttt{nil}~and~NaN are usable as \textit{index}.
7204 However, a user should use only negative integers or strings as \textit{index},
7205 since natural numbers are used by \LuaTeX-ja itself.
7206 Also, whether \textit{data} is stored locally or globally
7207 is determined by \texttt{luatexja.isglobal}
7208 (stored globally if and only if \texttt{luatexja.isglobal == 'global'}).
7209 %</en>
7210 %<*ja>
7211 スタックに値を設定するには,以下のLua関数を呼び出せば良い:
7212 \begin{lstlisting}
7213 luatexja.stack.set_stack_table(<any> index, <any> data)
7214 \end{lstlisting}
7215 直感的には,スタックテーブル中のインデックス\textit{index}の値を\textit{data}にする,という意味である.
7216 \textit{index}の値としては \texttt{nil} とNaN以外の任意の値を使えるが,
7217 自然数は\LuaTeX-jaが使用する(将来の拡張用も含む)ので,
7218 ユーザが使用する場合は負の整数値か文字列の値にすることが望ましい.
7219 また,ローカルに設定されるかグローバルに設定されるかは,\texttt{luatexja.isglobal} の値に依存する
7220 (グローバルに設定されるのは,\texttt{luatexja.isglobal == 'global'} であるちょうどその時).
7221 %</ja>
7222
7223 %<*en>
7224 Stored data can be obtained as the return value of
7225 \begin{lstlisting}
7226 luatexja.stack.get_stack_table(index, <any> default, <number> level)
7227 \end{lstlisting}
7228 where \textit{level} is the stack level, which is usually the value of \verb+\ltj@@stack+,
7229 and \textit{default} is the default value which will be returned if no values are stored
7230 in the stack table whose level is \textit{level}.
7231 %</en>
7232 %<*ja>
7233 スタックの値は,
7234 \begin{lstlisting}
7235 luatexja.stack.get_stack_table(<any> index, <any> default, <number> level)
7236 \end{lstlisting}
7237 の戻り値で取得できる.\textit{level}はスタックレベルであり,
7238 通常は \verb+\ltj@@stack+ の値を指定することになるだろう.
7239 \textit{default}はレベル\textit{level}のスタックに値が設定されていなかった場合に
7240 返すデフォルト値である.
7241 %</ja>
7242
7243 \begin{figure}[tb]
7244 \begin{lstlisting}[numbers=left, firstnumber=380]
7245 \protected\def\ltj@setpar@global{%
7246   \relax\ifnum\globaldefs>0\directlua{luatexja.isglobal='global'}%
7247     \else\directlua{luatexja.isglobal=''}\fi
7248 }
7249 \protected\def\ltjsetparameter#1{%
7250   \ltj@setpar@global\setkeys[ltj]{japaram}{#1}\ignorespaces}
7251 \protected\def\ltjglobalsetparameter#1{%
7252   \relax\ifnum\globaldefs<0\directlua{luatexja.isglobal=''}%
7253     \else\directlua{luatexja.isglobal='global'}\fi%
7254   \setkeys[ltj]{japaram}{#1}\ignorespaces}
7255 \end{lstlisting}
7256 %<ja>\caption{パラメータ設定命令の定義}
7257 %<en>\caption{Definiton of parameter setting commands}
7258 \label{fig:setpar-def}
7259 \end{figure}
7260
7261 %<*en>
7262 \subsection{Extending Parameters}
7263 Keys for \cs{ltjsetparameter}~and~\cs{ltjgetparameter} can be extended,
7264 as in \Pkg{luatexja-adjust}.
7265 %</en>
7266 %<*ja>
7267 \subsection{パラメータの拡張}
7268 ここでは,\Pkg{luatexja-adjust}で行なっているように,
7269 \cs{ltjsetparameter},~\cs{ltjgetparameter}に指定可能なキーを追加する方法
7270 を述べる.
7271 %</ja>
7272
7273 %<*en>
7274 \paragraph{Setting parameters}
7275 Figure~\ref{fig:setpar-def} shows the \emph{most outer} definition of
7276 two commands,
7277 \cs{ltjsetparameter} and \cs{ltjglobalsetparameter}.
7278 Most important part is the last \cs{setkeys},
7279 which is offered by the \Pkg{xkeyval} package.
7280
7281 Hence, to add a key in \cs{ltjsetparameter}, one only have to add a key
7282 whose prefix is \texttt{ltj} and whose family is \texttt{japaram}, as the following.
7283 \begin{lstlisting}
7284 \define@key[ltj]{japaram}{...}{...}
7285 \end{lstlisting}
7286
7287 \cs{ltjsetparameter}~and~\cs{ltjglobalsetparameter} automatically sets
7288 \texttt{luatexja.isglobal}. Its meaning is the following.
7289 \begin{align}
7290  \texttt{luatexja.isglobal} =
7291 \begin{cases}
7292  \texttt{'global'}&\text{global}\\
7293  \texttt{''}&\text{local}
7294 \end{cases}
7295 \end{align}
7296 This is determined not only by command name
7297 (\cs{ltjsetparameter}~or~\cs{ltjglobalsetparameter}),
7298 but also by the value of \cs{globaldefs}.
7299 %</en>
7300 %<*ja>
7301 \paragraph{パラメータの設定}
7302 \cs{ltjsetparameter} と,\cs{ltjglobalsetparameter} の定義は図\ref{fig:setpar-def}の
7303 のようになっている.
7304 本質的なのは最後の \cs{setkeys} で,これは\Pkg{xkeyval}パッケージの提供する命令である.
7305
7306 このため,\cs{ltjsetparameter} に指定可能なパラメータを追加するには,
7307 <prefix>を \texttt{ltj},<family>を \texttt{japaram} としたキーを
7308 \begin{lstlisting}
7309 \define@key[ltj]{japaram}{...}{...}
7310 \end{lstlisting}
7311 のように定義すれば良いだけである.
7312 なお,パラメータ指定がグローバルかローカルかどうかを示す \texttt{luatexja.isglobal} が,
7313 \begin{align}
7314  \texttt{luatexja.isglobal} =
7315 \begin{cases}
7316  \texttt{'global'}&\text{パラメータ設定はグローバル}\\
7317  \texttt{''}&\text{パラメータ設定はローカル}
7318 \end{cases}
7319 \end{align}
7320 として自動的にセットされる\footnote{命令が \cs{ltjglobalsetparameter} かどうかだけでは
7321 なく,実行時の \cs{globaldefs} の値にも依存して定まる.}.
7322 %</ja>
7323
7324 %<*en>
7325 \paragraph{Getting parameters}
7326 \cs{ltjgetparameter} is implemented by a Lua script.
7327
7328 For parameters that do not need additional arguments, one only have to
7329 define a function in the table \verb+luatexja.unary_pars+.
7330 For example, with the following function,
7331 \verb+\ltjgetparameter{hoge}+ returns a \emph{string} \texttt{42}.
7332 \begin{lstlisting}[numbers=left]
7333 function luatexja.unary_pars.hoge (t)
7334   return 42
7335 end
7336 \end{lstlisting}
7337 Here the argument of \verb+luatexja.unary_pars.hoge+ is
7338 the stack level of \LuaTeX-ja's stack system (see Subsection~\ref{ssec-stack}).
7339
7340 On the other hand, for parameters that need an additional argument
7341 (this must be an integer), one have to define a function in
7342 \verb+luatexja.binary_pars+ first. For example,
7343 \begin{lstlisting}[numbers=left]
7344 function luatexja.binary_pars.fuga (c, t)
7345   return tostring(c) .. ', ' .. tostring(42)
7346 end
7347 \end{lstlisting}
7348 Here the first argument $t$ is the stack level, as before.
7349 The second argument $c$ is just the second argument of \cs{ltjgetparameter}.
7350
7351 For parameters that need an additional argument, one also have to
7352 execute the \TeX\ code like
7353 \begin{lstlisting}
7354 \ltj@@decl@array@param{fuga}
7355 \end{lstlisting}
7356 to indicate that ``the parameter \texttt{fuga} needs an additional argument''.
7357 %</en>
7358 %<*ja>
7359 \paragraph{パラメータの取得}
7360 一方,\cs{ltjgetparameter} はLuaスクリプトによって実装されている.
7361 値を取得するのに追加引数の要らないパラメータについては,\verb+luatexja.unary_pars+\
7362 内に処理内容を記述した関数を定義すれば良い.例えば,Luaスクリプトで
7363 \begin{lstlisting}[numbers=left]
7364 function luatexja.unary_pars.hoge (t)
7365   return 42
7366 end
7367 \end{lstlisting}
7368 を実行すると,\verb+\ltjgetparameter{hoge}+ は \texttt{42} という\emph{文字列}を返す.
7369 関数 \verb+luatexja.unary_pars.hoge+ の引数$t$は,\ref{ssec-stack}節で述べた
7370 \LuaTeX-jaのスタックシステムにおけるスタックレベルである.
7371 戻り値はいかなる値であっても,最終的には文字列として出力されることに注意.
7372
7373 一方,追加引数(\emph{数値しか許容しない})が必要なパラメータについては,
7374 まずLuaスクリプトで処理内容の本体を記述しておく:
7375 \begin{lstlisting}[numbers=left]
7376 function luatexja.binary_pars.fuga (c, t)
7377   return tostring(c) .. ', ' .. tostring(42)
7378 end
7379 \end{lstlisting}
7380 引数$t$は,先に述べた通りのスタックレベルである.一方,引数$c$は\
7381 \cs{ltjgetparameter} の第2引数を表す数値である.
7382 しかしこれだけでは駄目で,
7383 \begin{lstlisting}
7384 \ltj@@decl@array@param{fuga}
7385 \end{lstlisting}
7386 を実行し,\TeX インターフェース側に
7387 「\verb+\ltjgetparameter{fuga}+ は追加引数が必要」ということを通知する必要がある.
7388 %</ja>
7389
7390 %<en>\section{Linebreak after a Japanese Character}
7391 %<ja>\section{和文文字直後の改行}
7392 \label{sec-lbreak}
7393 %<en>\subsection{Reference: Behavior in \pTeX}
7394 %<ja>\subsection{参考:\pTeX の動作}
7395 %<*en>
7396 In~\pTeX, a line break after a Japanese character doesn't emit a space,
7397 since words are not separated by spaces in Japanese writings. However,
7398 this feature isn't fully implemented in \LuaTeX-ja due to the
7399 specification of callbacks in~\LuaTeX. To clarify the difference between
7400 \pTeX~and~\LuaTeX, We briefly describe the handling of a line break in~\pTeX, in
7401 this subsection.
7402
7403 \pTeX's input processor can be described in terms of a finite state
7404 automaton, as that of~\TeX\ in~Section~2.5 of~\cite{texbytopic}. The
7405 internal states are as follows:
7406 \begin{itemize}
7407 \item State~$N$: new line
7408 \item State~$S$: skipping spaces
7409 \item State~$M$: middle of line
7410 \item State~$K$: after a Japanese character
7411 \end{itemize}
7412 The first three states---$N$,~$S$, and~$M$---are as same as \TeX's input
7413 processor.  State~$K$ is similar to state~$M$, and is entered after
7414 Japanese characters.  The diagram of state transitions are indicated in
7415 Figure~\ref{fig-ptexipro}.  Note that \pTeX\ doesn't leave state~$K$
7416 after ``beginning/ending of a group'' characters.
7417 %</en>
7418
7419 %<*ja>
7420 欧文では文章の改行は単語間でしか行わない.そのため,\TeX では,(文字の直後の)改行は
7421 空白文字と同じ扱いとして扱われる.一方,和文ではほとんどどこでも改行が可能なため,
7422 \pTeX では和文文字の直後の改行は単純に無視されるようになっている.
7423
7424 このような動作は,\pTeX が\TeX からエンジンとして拡張されたことによって可能になったことである.
7425 \pTeX の入力処理部は,\TeX におけるそれと同じように,有限オートマトンとして記述することができ,
7426 以下に述べるような4状態を持っている.
7427
7428 \begin{itemize}
7429 \item State~$N$: 行の開始.
7430 \item State~$S$: 空白読み飛ばし.
7431 \item State~$M$: 行中.
7432 \item State~$K$: 行中(和文文字の後).
7433 \end{itemize}
7434 また,状態遷移は,図\ref{fig-ptexipro}のようになっており,図中の数字は
7435 カテゴリーコードを表している.最初の3状態は\TeX の入力処理部と同じであり,
7436 図中から状態$K$と「$j$」と書かれた矢印を取り除けば,\TeX の入力処理部と同
7437 じものになる.
7438
7439 この図から分かることは,
7440 \begin{quote}
7441 行が和文文字(とグループ境界文字)で終わっていれば,改行は無視される
7442 \end{quote}
7443 ということである.
7444 %</ja>
7445
7446 \begin{figure}[!tb]
7447 \let\sp\textvisiblespace\small
7448 \begin{minipage}{.6\textwidth}%
7449 \begin{center}
7450 \unitlength=6.5mm\sf\mathversion{bold}
7451 \begin{tikzpicture}[
7452   ->, auto, shorten >=1pt
7453 ]
7454 \node [shape=rectangle, font=\scriptsize] (init) at (2,7) {start};
7455 \node [shape=circle,draw, fill=b_cyan] (newline) at (4,7) {$N$};
7456 \node [shape=circle,draw, fill=b_cyan] (midline) at (4,4) {$M$};
7457 \node [shape=circle,draw, fill=b_cyan] (skipspc) at (8,7) {$S$};
7458 \node [shape=circle,draw, fill=b_pink]  (kanji) at (8,4) {$K$};
7459 \node [shape=rectangle,draw, fill=b_green] (scanacs) at (6,8) {scan a c.s.};
7460 \node (endk) at (8,2.5) {} ;
7461 \node (endm) at (4,2.5) {} ;
7462 \node (ends) at (8,8.5) {} ;
7463 \node (endn) at (4,8.5) {} ;
7464 \begin{scope}[font=\scriptsize]
7465 \path (newline) edge [bend right]    node [left]{G, O} (midline)
7466       (init)    edge                 node {} (newline)
7467       (midline) edge [bend right=10] node {10} (skipspc)
7468       (skipspc) edge [bend right]    node [left,right=10,above=7]{G, O} (midline)
7469       (skipspc) edge [loop right]    node {10} (skipspc)
7470       (newline) edge [loop right]    node {10} (newline)
7471       (scanacs) edge [bend left]     node [left=3,below]{$(*)$} (skipspc)
7472       (scanacs) edge [bend right]    node [right=30,above=20]{$(*)$} (midline)
7473       (midline) edge                 node {5\ [\sp]} (endm)
7474       (midline) edge [loop left]     node {G, O} (midline)
7475       (skipspc) edge                 node [right] {5} (ends)
7476       (newline) edge                 node {5 [\cs{par}]} (endn);
7477 \begin{scope}[red]
7478 \path (newline) edge [bend right]    node [right=25,below=3]{J} (kanji)
7479       (midline) edge                 node [below]{J} (kanji)
7480       (kanji)   edge [bend left]     node {O} (midline)
7481       (kanji)   edge                 node {10} (skipspc)
7482       (kanji)   edge [loop right]    node {G, J} (kanji)
7483       (skipspc) edge [bend left]     node {J} (kanji)
7484       (kanji)   edge                 node {5} (endk)
7485 ;
7486 \end{scope}
7487 \end{scope}
7488 \end{tikzpicture}
7489 \end{center}
7490 \end{minipage}%
7491 \begin{minipage}{.4\textwidth}
7492 \begin{description}
7493 \item[\textsf{G}] Beginning of group (usually \verb+{+)\\
7494  and ending of group (usually \verb+}+).
7495 \item[\textsf{J}] Japanese characters.
7496 \item[\textsf{5}] \textit{end-of-line} (usually \verb+^+\verb+^J+).
7497 \item[\textsf{10}] space (usually \sp).
7498 \item[\textsf{O}] other characters, whose category code is in $\{3,4,6,7,8,11,12,13\}$.
7499 \item[\textsf{[\sp]}, \textsf{[\cs{par}]}]
7500 emits a space, or~\cs{par}.
7501 \end{description}
7502 \end{minipage}
7503 \begin{itemize}
7504 \item We omitted about category codes
7505 9~(\textit{ignored}), 14~(\textit{comment}), and~15~(\textit{invalid})
7506 from the above diagram. We also ignored the input like ``\verb+^+\verb+^A+'' or ``\verb+^+\verb+^df+''.
7507 \item When a character whose category code is 0 (\textit{escape character}) is seen by \TeX,
7508 the input processor scans a control sequence (\textsf{scan a c.s.}).
7509 These paths are not shown in the above diagram.
7510
7511 After that, the state is changed to State~$S$ (skipping blanks) in most cases, but
7512 to State~$M$ (middle of line) sometimes.
7513 \end{itemize}
7514 %<en>\caption{State transitions of \pTeX's input processor}
7515 %<ja>\caption{\pTeX の入力処理部の状態遷移}
7516 \label{fig-ptexipro}
7517 \end{figure}
7518
7519
7520 %<en>\subsection{Behavior in \LuaTeX-ja}
7521 %<ja>\subsection{\LuaTeX-jaの動作}
7522 %<*en>
7523 States in the input processor of \LuaTeX\ is the same as that of \TeX,
7524 and they can't be customized by any callbacks. Hence, we can only use
7525 \verb+process_input_buffer+ and \verb+token_filter+ callbacks for to
7526 suppress a space by a line break which is after Japanese characters.
7527
7528 However, \verb+token_filter+ callback cannot be used either, since a
7529 character in category code 5~(\textit{end-of-line}) is converted into an space
7530 token \emph{in the input processor}.  So we can use only the
7531 \verb+process_input_buffer+ callback.  This means that suppressing a
7532 space must be done \emph{just before} an input line is read.
7533
7534 Considering these situations, handling of an end-of-line in \LuaTeX-ja are as follows:
7535 \begin{quote}
7536 A character \texttt{U+FFFFF} (its category code is set to 14~(\textit{comment}) by
7537 \LuaTeX-ja) is appended to an input line, \emph{before \LuaTeX\ actually
7538 process it}, if and only if the following three conditions are satisfied:
7539 \begin{enumerate}
7540 \item The category code of \cs{endlinechar}%
7541 \footnote{Usually, it is $\langle$\textit{return}$\rangle$
7542       (whose character code is 13).} is 5~(\textit{end-of-line}).
7543 \item The category code of \texttt{U+FFFFF} itself is 14~(\textit{comment}).
7544 \item The input line matches the following ``regular expression'':
7545 \[
7546   (\text{any char})^*(\textbf{JAchar})
7547   \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
7548 \]
7549 \end{enumerate}
7550 \end{quote}
7551
7552 \paragraph{Remark}
7553 The following example shows the major difference from the behavior of \pTeX.
7554 \begin{LTXexample}
7555 \fontspec[Ligatures=TeX]{Linux Libertine O}
7556 \ltjsetparameter{autoxspacing=false}
7557 \ltjsetparameter{jacharrange={-6}}xあ
7558 y\ltjsetparameter{jacharrange={+6}}zい
7559 u
7560 \end{LTXexample}
7561 It is not strange that ``あ'' does not printed in the above output.
7562 This is because \TeX\ Gyre\ Termes does not contain ``あ'', and because
7563 ``あ'' in line~3 is considered as an \textbf{ALchar}.
7564
7565 Note that there is no space before ``y'' in the output, but
7566 there is a space before ``u''. This follows from following reasons:
7567 \begin{itemize}
7568 \item When line~3 is processed by \texttt{process\_input\_buffer} callback,
7569 ``あ'' is considered as an \textbf{JAchar}.
7570 Since  line~3 ends with an \textbf{JAchar},
7571 the comment character \texttt{U+FFFFF} is appended to this line,
7572 and hence the linebreak immediately after this line is ignored.
7573 \item When line~4 is processed by \texttt{process\_input\_buffer} callback,
7574 ``い'' is considered as an \textbf{ALchar}.
7575 Since  line~4 ends with an \textbf{ALchar}, the linebreak immediately after this line
7576 emits a space.
7577 \end{itemize}
7578 %</en>
7579
7580 %<*ja>
7581 \LuaTeX の入力処理部は\TeX のそれと全く同じであり,コールバックによりユーザが
7582 カスタマイズすることはできない.このため,改行抑制の目的でユーザが利用で
7583 きそうなコールバックとしては,\verb+process_input_buffer+や
7584 \verb+token_filter+に限られてしまう.しかし,\TeX の入力処理部をよく見る
7585 と,後者も役には経たないことが分かる:改行文字は,入力処理部によってトー
7586 クン化される時に,カテゴリーコード10の32番文字へと置き換えられてしまうた
7587 め,\verb+token_filter+で非標準なトークン読み出しを行おうとしても,空白文
7588 字由来のトークンと,改行文字由来のトークンは区別できないのだ.
7589
7590 すると,我々のとれる道は,\verb+process_input_buffer+を用いて
7591 \LuaTeX の入力処理部に引き渡される前に入力文字列を編集するというものしかない.
7592 以上を踏まえ,\LuaTeX-jaにおける「和文文字直後の改行抑制」の処理は,次のようになっている:
7593
7594 \begin{quote}
7595 各入力行に対し,\emph{その入力行が読まれる前の内部状態で}
7596 以下の3条件が満たされている場合,\LuaTeX-jaは\texttt{U+FFFFF}の文字
7597 \footnote{この文字はコメント文字として扱われるように\LuaTeX-ja内部で設定をしている.}
7598 を末尾に追加する.よって,その場合に改行は空白とは見做されないこととなる.
7599 \begin{enumerate}
7600 \item \cs{endlinechar}の文字\footnote{普通は,改行文字(文字コード13番)である.}
7601 のカテゴリーコードが5~(\textit{end-of-line})である.
7602 \item \texttt{U+FFFFF}のカテゴリーコードが14~(\textit{comment})である.
7603 \item 入力行は次の「正規表現」にマッチしている:
7604 \[
7605   (\text{any char})^*(\textbf{JAchar})
7606   \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
7607 \]
7608 \end{enumerate}
7609 \end{quote}
7610
7611 この仕様は,前節で述べた\pTeX の仕様にできるだけ近づけたものとなっている.条件1.は,
7612 \texttt{lstlisting}系環境などの日本語対応マクロを書かなくてすませるためのものである.
7613
7614 しかしながら,\pTeX と完全に同じ挙動が実現できたわけではない.
7615 次のように,\textbf{JAchar}の範囲を変更したちょうどその行においては挙動が異なる:
7616 \begin{LTXexample}
7617 \fontspec[Ligatures=TeX]{TeX Gyre Termes}
7618 \ltjsetparameter{autoxspacing=false}
7619 \ltjsetparameter{jacharrange={-6}}xあ
7620 y\ltjsetparameter{jacharrange={+6}}zい
7621 u
7622 \end{LTXexample}
7623 上ソース中の「あ」は\textbf{ALchar}(欧文扱い)であり.
7624 ここで使用している欧文フォント\TeX\ Gyre Termesは「あ」を含まない.
7625 よって,出力に「あ」は現れないことは不思議ではない.
7626 それでも,\pTeX とまったく同じ挙動を示すならば,出力は
7627 「\hbox{\ltjsetparameter{autoxspacing=false}x yzいu}」となるはずである.しかし,実際には
7628 上のように異なる挙動となっているが,それは以下の理由による:
7629 \begin{itemize}
7630 \item 3行目を \texttt{process\_input\_buffer} で処理する時点では,
7631       「あ」は\textbf{JAchar}(和文扱い)である.よって3行目は\textbf{JAchar}で終わることになり,
7632       コメント文字 \texttt{U+FFFFF} が追加される.
7633       よって,直後の改行文字は無視されることになり,空白は入らない.
7634 \item 4行目を \texttt{process\_input\_buffer} で処理する時点では,
7635       「い」は\textbf{ALchar}である.よって4行目は\textbf{ALchar}で終わることになり,
7636       直後の改行文字は空白に置き換わる.
7637 \end{itemize}
7638 このため,トラブルを避けるために,\textbf{JAchar}の範囲を\cs{ltjsetparameter}で編集した場合,
7639 その行はそこで改行するようにした方がいいだろう.
7640 %</ja>
7641
7642 %<*ja>
7643
7644 %<en>\section{Insertion of JFM glues, \Param{kanjiskip} and \Param{xkanjiskip}}
7645 %<ja>\section{JFMグルーの挿入,\Param{kanjiskip}と\Param{xkanjiskip}}
7646 \label{sec-jfmglue}
7647 %<en>\subsection{Overview}
7648 %<ja>\subsection{概要}
7649
7650 \LuaTeX-jaにおける \textbf{JAglue} の挿入方法は,\pTeX のそれとは全く異なる.
7651 \pTeX では次のような仕様であった:
7652 \begin{itemize}
7653 \item JFMグルーの挿入は,和文文字を表すトークンを元に水平リストに(文字を表す)<char\_node>を
7654 追加する過程で行われる.
7655 \item \Param{xkanjiskip}の挿入は,hboxへのパッケージングや行分割前に行われる.
7656 \item \Param{kanjiskip}はノードとしては挿入されない.パッケージングや行分割の計算時に
7657 「和文文字を表す2つの<char\_node>の間には\Param{kanjiskip}がある」ものとみなされる.
7658 \end{itemize}
7659 しかし,\LuaTeX-jaでは,hboxへのパッケージングや行分割前に全ての
7660 \textbf{JAglue},即ちJFMグルー・\Param{xkanjiskip}・\Param{kanjiskip}の
7661 3種類を一度に挿入することになっている.これは,\LuaTeX において欧文の合字・
7662 カーニング処理がノードベースになったことに対応する変更である.
7663
7664 \LuaTeX-jaにおける\textbf{JAglue}挿入処理では,次節で定義する
7665 「クラスタ」を単位にして行われる.大雑把にいうと,「クラスタ」は文字とそれに付随す
7666 るノード達(アクセント位置補正用のカーンや,イタリック補正)をまとめたもの
7667 であり,2つのクラスタの間には,ペナルティ,\cs{vadjust},whatsitなど,行組版
7668 には関係しないものがある.
7669
7670
7671 %<en>\subsection{Definition of a Cluster}
7672 %<ja>\subsection{「クラスタ」の定義}
7673
7674 \def\OA{$\text{\sf O}_{\text{\sf A}}$}
7675 \def\OB{$\text{\sf O}_{\text{\sf B}}$}
7676 \begin{defn}
7677 %<*en>
7678 A \emph{cluster} is consecutive nodes in one of the following forms,
7679 with the \textit{id} of it:
7680 %</en>
7681 %<*ja>
7682 \emph{クラスタ}は以下の形のうちのどれかひとつをとるノードのリストである:
7683 %</ja>
7684 \begin{enumerate}
7685 %<*en>
7686 \item Nodes whose value of\ \verb+\ltj@icflag+ is in $[3,15)$.  These
7687       nodes come from a hbox which is already packaged, by unpackaging
7688       (\cs{unhbox}).
7689       The \textit{id} of the cluster is \textit{id\_pbox}.
7690 %</en>
7691 %<*ja>
7692 \item その \verb+\ltj@icflag+ の値が$[3,15)$に入るノードのリスト.
7693   これらのノードはある既にパッケージングされたhboxから \cs{unhbox} で
7694   アンパックされたものである.
7695   この場合,クラスタの\textit{id}は\textit{id\_pbox}である.
7696 %</ja>
7697
7698 %<*en>
7699 \item A inline math formula, including two \textit{math\_node}s at the boundary of it.
7700       The \textit{id} of the cluster is \textit{id\_math}.
7701 %</en>
7702 %<*ja>
7703 \item インライン数式でその境界に2つの\textit{math\_node}を含むもの.
7704   この場合,クラスタの\textit{id}は\textit{id\_math}である.
7705 %</ja>
7706
7707 %<*en>
7708 \item A \textit{glyph\_node}~$p$, which represents a \textbf{JAchar}, with nodes which relate with it:
7709 %</en>
7710 %<*ja>
7711 \item \textbf{JAchar}を表す\textit{glyph\_node}~$p$とそれに関係するノード:
7712 %</ja>
7713 \begin{enumerate}
7714 %<*en>
7715 \item[(a)] A kern for the italic correction of~$p$.
7716 %</en>
7717 %<*ja>
7718 \item[(a)] $p$のイタリック補正のためのカーン.
7719 %</ja>
7720
7721 %<*en>
7722 \item[(b)] An accent attached to $p$ by \cs{accent}.
7723 %</en>
7724 %<*ja>
7725 \item[(b)] \cs{accent} による$p$に付随したアクセント.
7726 %</ja>
7727 \end{enumerate}
7728 \[
7729 \overbrace{%
7730  \Node{kern}{$\mathit{subtype}=2$}\longrightarrow
7731 \left\{\begin{array}{c}
7732 \Node{glyph}{accent}\\\noalign{\medskip}
7733 \Node{hbox}{accent (shifted vert.)}
7734 \end{array}\right\}\longrightarrow
7735 \Node{kern}{$\mathit{subtype}=2$}}^{\text{(a)}}
7736 \longrightarrow
7737 \Node{glyph}{$p$}\longrightarrow
7738 \overbrace{%
7739 \Node{kern}{italic corr.}}^{\text{(b)}}
7740 \]
7741
7742 %<*en>
7743 In this case, the \textit{id} is \textit{id\_jglyph}.
7744 %</en>
7745 %<*ja>
7746 この場合の\textit{id}は\textit{id\_jglyph}である.
7747 %</ja>
7748
7749 %<*en>
7750 \item A list which begins from a \textit{glyph\_node} which represents a \textbf{ALchar},
7751       and consists of \textbf{ALchar} \textit{glyph\_node}s,
7752       kerns for adjusting accents~(its subtype is 2), kerns for italic corrections and
7753       kerns which are automatically inserted by \LuaTeX~or~luaotfload.
7754       In this case, the \textit{id} is \textit{id\_glyph}.
7755 %</en>
7756 %<*ja>
7757 \item \textbf{ALchar}を表す\textit{glyph\_node},\cs{accent} によるアクセント位置補正用の
7758       カーン(subtypeが2),そしてイタリック補正・カーニングによって挿入されたカーン達が連続
7759       したもの.この場合の\textit{id}は\textit{id\_glyph}である.
7760 %</ja>
7761
7762 %<*en>
7763 \item An box-like node, that is, an hbox, a vbox, a rule (\cs{vrule}) and an \textit{unset\_node}.
7764 The \textit{id} of the cluster is \textit{id\_hlist} if the node is an
7765       hbox which is not shifted vertically, or \textit{id\_box\_like}
7766       otherwise.
7767 %</en>
7768 %<*ja>
7769 \item 水平ボックス(hbox),垂直ボックス,罫線 (\cs{vrule}),
7770   そして\textit{unset\_node}.
7771   クラスタの\textit{id}は垂直に移動していないhboxならば\textit{id\_hlist},
7772   そうでなければ\textit{id\_box\_like}となる.
7773 %</ja>
7774
7775 %<*en>
7776 \item A glue, a kern whose subtype is not 2~(\textit{accent}), and a discretionary break.
7777 The \textit{id} of the cluster is \textit{id\_glue}, \textit{id\_kern}
7778       and \textit{id\_disc}, respectively.
7779 %</en>
7780 %<*ja>
7781 \item グルー,subtypeが 2~(\textit{accent})ではないカーン,そしてdiscretionary break.
7782   その\textit{id} of the clusterはそれぞれ\textit{id\_glue}, \textit{id\_kern},そして
7783   \textit{id\_disc}である.
7784 %</ja>
7785 \end{enumerate}
7786 %<*en>
7787 We use \textit{Np}, \textit{Nq} and \textit{Nr} to denote a cluster.
7788 %</en>
7789 %<*ja>
7790 以下では\textit{Np}, \textit{Nq}, \textit{Nr}でクラスタを表す.
7791 %</ja>
7792 \end{defn}
7793
7794 \paragraph{\textit{id}の意味}
7795 $\mathit{Np}.\mathit{id}$の意味を述べるとともに,
7796 「先頭の文字」を表す\textit{glyph\_node}~$\mathit{Np}.\mathit{head}$と,
7797 「最後の文字」を表す\textit{glyph\_node}~$\mathit{Np}.\mathit{tail}$を次のように定義する.
7798 直感的に言うと,\textit{Np}は$\mathit{Np}.\mathit{head}$で始まり$\mathit{Np}.\mathit{tail}$で終わるような単語,
7799 と見做すことができる.これら$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は
7800 説明用に準備した概念であって,実際のLuaコード中にそのように書かれているわけではないことに注意.
7801
7802 \begin{description}
7803 \item[\textit{id\_jglyph}] \textbf{JAchar}(和文文字).\\
7804 $\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は,その\textbf{JAchar}を表している
7805 \textit{glyph\_node}そのものである.
7806 \item[\textit{id\_glyph}] \textbf{JAchar}(和文文字)以外のものを表す\textit{glyph\_node}~$p$.\\
7807 多くの場合,$p$は\textbf{ALchar}(欧文文字)を格納しているが,「ffi」などの合字によって作られた
7808 \textit{glyph\_node}である可能性もある.
7809 前者の場合,$\mathit{Np}.\mathit{head}$,~$\mathit{Np}.\mathit{tail} = p$である.
7810 一方,後者の場合,
7811 \begin{itemize}
7812 \item $\mathit{Np}.\mathit{head}$は,
7813 合字の構成要素の先頭→(その\textit{glyph\_node}における)合字の構成要素の先頭→……
7814 と再帰的に検索していってたどり着いた\textit{glyph\_node}である.
7815 \item $\mathit{Np}.\mathit{last}$は,同様に末尾→末尾→と検索してたどり着いた\textit{glyph\_node}である.
7816 \end{itemize}
7817 \item[\textit{id\_math}] インライン数式.\\
7818 便宜的に,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$ともに
7819 「文字コード$-1$の欧文文字」とおく.
7820 \item[\textit{id\_hlist}] 縦方向にシフトされていないhbox.\\
7821 この場合,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$はそれぞれ$p$の内容を表すリストの,
7822 先頭・末尾のノードである.
7823 \medskip
7824 \begin{itemize}
7825 \item 状況によっては,\TeX ソースで言うと
7826 \begin{lstlisting}
7827 \hbox{\hbox{abc}...\hbox{\lower1pt\hbox{xyz}}}
7828 \end{lstlisting}
7829 のように,$p$の内容が別のhboxで開始・終了している可能性も十分あり得る.そのような場合,
7830 $\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$の算出は,
7831 \emph{垂直方向にシフトされていない}hboxの
7832 場合だけ内部を再帰的に探索する.例えば上の例では,$\mathit{Np}.\mathit{head}$は文字「a」を表すノードであり,
7833 一方$\mathit{Np}.\mathit{tail}$は垂直方向にシフトされたhbox,
7834 \verb+\lower1pt\hbox{xyz}+ に対応するノードである.
7835 \item また,先頭にアクセント付きの文字がきたり,末尾にイタリック補正用のカーンが
7836 来ることもあり得る.この場合は,クラスタの定義のところにもあったように,それらは無視して算出を行う.
7837 \item 最初・最後のノードが合字によって作られた\textit{glyph\_node}のときは,それぞれに対して\textit{id\_glyph}%
7838 と同様に再帰的に構成要素をたどっていく.
7839 \end{itemize}
7840 \item[\textit{id\_pbox}] 「既に処理された」ノードのリストであり,これらのノードが二度処理を受けないために
7841 まとめて1つのクラスタとして取り扱うだけである.
7842 \textit{id\_hlist}と同じ方法で$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$を算出する,
7843 \item[\textit{id\_disc}] discretionary break (\verb+\discretionary{pre}{post}{nobreak}+).\\
7844 \textit{id\_hlist}と同じ方法で$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$を算出するが,
7845 第3引数の \texttt{nobreak}(行分割が行われない時の内容)を使う.言い換えれば,ここで行分割が発生した時の状況は
7846 全く考慮に入れない.
7847 \item[\textit{id\_box\_like}] \textit{id\_hlist}とならないboxや,rule.\\
7848 この場合は,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$のデータは利用されないので,2つの算出は無意味である.
7849 敢えて明示するならば,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は共にnil値である.
7850 \item[他] 以上にない\textit{id}に対しても,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$の算出は無意味.
7851 \end{description}
7852
7853 \paragraph{クラスタの別の分類}
7854 さらに,JFMグルー挿入処理の実際の説明により便利なように,\textit{id}とは別のクラスタの分類を行っておく.
7855 挿入処理では2つの隣り合ったクラスタの間に
7856 空白等の実際の挿入を行うことは前に書いたが,ここでの説明では,問題にしているクラスタ\textit{Np}は「後ろ側」のクラスタである
7857 とする.「前側」のクラスタについては,以下の説明で\textit{head}が\textit{last}に置き換わることに注意すること.
7858 \begin{description}
7859 \item[和文A] リスト中に直接出現している\textbf{JAchar}.
7860 \textit{id}が\textit{id\_jglyph}であるか,\\
7861 \textit{id}が\textit{id\_pbox}であって$\mathit{Np}.\mathit{head}$が\textbf{JAchar}であるとき.
7862
7863 \item[和文B] リスト中のhboxの中身の先頭として出現した\textbf{JAchar}.和文Aとの違いは,これの前に
7864 JFMグルーの挿入が行われない(\Param{xkanjiskip},~\Param{kanjiskip}は入り得る)ことである.\\
7865 \textit{id}が\textit{id\_hlist}か\textit{id\_disc}であって$\mathit{Np}.\mathit{head}$が\textbf{JAchar}であるとき.
7866
7867 \item[欧文] リスト中に直接/hboxの中身として出現している「\textbf{JAchar}以外の文字」.次の3つの場合が該当:
7868 \begin{itemize}
7869 \item \textit{id}が\textit{id\_glyph}である.
7870 \item \textit{id}が\textit{id\_math}である.
7871 \item \textit{id}が\textit{id\_pbox}か\textit{id\_hlist}か\textit{id\_disc}であって,$\mathit{Np}.\mathit{head}$が\textbf{ALchar}.
7872 \end{itemize}
7873 \item[箱] box,またはそれに類似するもの.次の2つが該当:
7874 \begin{itemize}
7875 \item \textit{id}が\textit{id\_pbox}か\textit{id\_hlist}か\textit{id\_disc}であって,$\mathit{Np}.\mathit{head}$が\textit{glyph\_node}でない.
7876 \item \textit{id}が\textit{id\_box\_like}である.
7877 \end{itemize}
7878
7879 \end{description}
7880
7881 \subsection{段落/hboxの先頭や末尾}
7882 \paragraph{先頭部の処理}
7883 まず,段落/hboxの一番最初にあるクラスタ\textit{Np}を探索する.
7884 hboxの場合は何の問題もないが,段落の場合では以下のノード達を事前に読み飛ばしておく:
7885 \begin{itemize}
7886 \item \cs{parindent} 由来のhbox($\mathit{subtype}=3$)
7887 \item \textit{subtype}が44~(\textit{user\_defined})でないようなwhatsit
7888 \end{itemize}
7889 これは,\cs{parindent}由来のhboxがクラスタを構成しないようにするためである.
7890
7891 次に,\textit{Np}の直前に空白$g$を必要なら挿入する:
7892 \begin{enumerate}
7893 \item この処理が働くような\textit{Np}は\textsf{和文A}である.
7894 \item 問題のリストが字下げありの段落(\cs{parindent} 由来のhboxあり)の場合は,
7895 この空白$g$は「文字コード \texttt{'parbdd'} の文字」と\textit{Np}の間に入るグルー/カーンである.
7896 \item そうでないとき(\verb+noindent+ で開始された段落やhbox)は,
7897 $g$は「文字コード \texttt{'boxbdd'} の文字」と\textit{Np}の間に入るグルー/カーンである.
7898 \end{enumerate}
7899 ただし,もし$g$がglueであった場合,この挿入によって\textit{Np}による行分割が新たに可能になるべきではない.
7900 そこで,以下の場合には,$g$の直前に \cs{penalty10000} を挿入する:
7901 \begin{itemize}
7902 \item 問題にしているリストが段落であり,かつ
7903 \item \textit{Np}の前には予めペナルティがなく,$g$はglue.
7904 \end{itemize}
7905
7906 \paragraph{末尾の処理}
7907 末尾の処理は,問題のリストが段落のものかhboxのものかによって異なる.
7908 後者の場合は容易い:最後のクラスタを\textit{Nq}とおくと,\textit{Nq}と「文字コード\
7909 \texttt{'boxbdd'} の文字」の間に入るグルー/カーンを,
7910 \textit{Nq}の直後に挿入するのみである.
7911
7912 一方.前者(段落)の場合は,リストの末尾は常に \cs{penalty10000} と,
7913 \cs{parfillskip} 由来のグルーが存在する.%よって,最後のクラスタ\textit{Np}は
7914 %この \cs{parfillskip} 由来のグルーとなり,実質的な中身の最後はその1つ前のクラスタ\textit{Nq}となる.
7915 段落の最後の「通常の\textbf{JAchar}${}+{}$句点」が独立した行となるのを防ぐために,
7916 \Param{jcharwidowpenalty}の値の分だけ適切な場所のペナルティを増やす.
7917
7918 ペナルティ量を増やす場所は,\textit{head}が\textbf{JAchar}であり,
7919 かつその文字の\Param{kcatcode}が偶数であるような
7920 最後のクラスタの直前にあるものたちである%
7921 \footnote{大雑把に言えば,\Param{kcatcode}が奇数であるような\textbf{JAchar}%
7922 を約物として考えていることになる.
7923 \Param{kcatcode}の最下位ビットはこの\Param{jcharwidowpenalty}用にのみ利用される.}.
7924
7925 \subsection{概観と典型例:2つの「和文A」の場合}
7926 \label{ssec-cluster-wa}
7927 先に述べたように,2つの隣り合ったクラスタ,\textit{Nq}と\textit{Np}の間には,
7928 ペナルティ,\cs{vadjust},whatsitなど,行組版には関係しないものがある.模式的に表すと,
7929 \[
7930  \Node{cluster}{\textit{Nq}}\longrightarrow
7931 \overbrace{
7932 \Node{penalty}{$p$}\longrightarrow \cdots\longrightarrow \Node{whatsit}{}}^{\textrm{(a)}}
7933 \longrightarrow \Node{cluster}{\textit{Np}}
7934 \]
7935 のようになっている.間の(a)に相当する部分には,何のノードもない場合ももちろんあり得る.
7936 そうして,JFMグルー挿入後には,この2クラスタ間は次のようになる:
7937 \[
7938  \Node{cluster}{\textit{Nq}}\longrightarrow%\Node{kern}{左空白}\longrightarrow
7939 \overbrace{
7940 \Node{penalty}{$p+x$}\longrightarrow \cdots\longrightarrow
7941 \Node{whatsit}{}}^{\textrm{(a)}}\longrightarrow
7942 \Node{glue or kern}{\raisebox{-.2\zw}{右空白}}\longrightarrow
7943 \Node{cluster}{\textit{Np}}
7944 \]
7945
7946 以後,\emph{典型的な例として,クラスタ\textit{Nq}と\textit{Np}が共に\textsf{\textmd{和文A}}である場合を見ていこう,}
7947 この場合が全ての場合の基本となる.
7948
7949 \paragraph{「右空白」の算出}
7950 まず,「右空白」にあたる量を算出する.通常はこれが,隣り合った2つの\textbf{JAchar}間に入る空白量となる.
7951 \begin{description}
7952 \item[JFM由来{[M]}] JFMの文字クラス指定によって入る空白を以下によって求める.この段階で空白量が未定義(未指定)だった場合,
7953       デフォルト値\Param{kanjiskip}を採用することとなるので,次へ.
7954 \begin{enumerate}
7955 \item もし両クラスタの間で \cs{inhibitglue} が実行されていた場合(証としてwhatsitノードが自動挿入される),
7956       代わりに\Param{kanjiskip}が挿入されることとなる.次へ.
7957 \item \textit{Nq}と\textit{Np}が同じJFM・同じ\texttt{jfmvar}キー・同じサイズの和文フォントであったならば,
7958       共通に使っているJFM内で挿入される空白(グルーかカーン)が決まっているか調べ,決まっていればそれを採用.
7959 \item 1.でも2.でもない場合は,JFM・\texttt{jfmvar}・サイズの3つ組は\textit{Nq}と\textit{Np}で異なる.
7960 この場合,まず
7961 \[
7962 \vcenter{\halign{\hfil$#:={}$&\inhibitglue#\inhibitglue\cr
7963 gb&(\textit{Nq}と「使用フォントが\textit{Nq}のそれと同じで,\hfil\cr
7964 \omit&\quad 文字コードが\textit{Np}のそれの文字」との間に入るグルー/カーン)\hfil\cr
7965 ga&(\inhibitglue 「使用フォントが\textit{Np}のそれと同じで,\hfil\cr
7966 \omit&\quad 文字コードが\textit{Nq}のそれの文字」と\textit{Np}との間に入るグルー/カーン)\hfil\cr
7967 }}
7968 \]
7969 として,前側の文字のJFMを使った時の空白(グルー/カーン)と,後側の文字のJFMを使った時のそれを求める.
7970
7971 $\mathit{gb}$,~$\mathit{ga}$それぞれに対する<ratio>の値を$d_b$,~$d_a$とする.
7972 \begin{itemize}
7973 \item
7974 $\mathit{ga}$と$\mathit{gb}$の両方が未定義であるならば,JFM由来のグルーは挿入されず,
7975 \Param{kanjiskip}を採用することとなる.
7976 どちらか片方のみが未定義であるならば,次のステップでその未定義の方は長さ0のkernで,<ratio>の値は0であるかのように扱われる.
7977 \item
7978 \Param{diffrentjfm}の値が \texttt{pleft}, \texttt{pright},
7979       \texttt{paverage} のとき,
7980 <ratio>の指定に従って比例配分を行う.
7981 JFM由来のグルー/カーンは以下の値となる:
7982 \[
7983  f\left(\frac{1-d_b}2\textit{gb} + \frac{1+d_b}2\textit{ga},
7984 \frac{1-d_a}2\textit{gb} + \frac{1+d_a}2\textit{ga}\right)
7985 \]
7986 ここで.$f(x,y)$は
7987 \[
7988  f(x,y)=\begin{cases}
7989 x&\text{if\ }\Param{diffrentjfm}=\texttt{pleft};\\
7990 y&\text{if\ }\Param{diffrentjfm}=\texttt{pright};\\
7991 (x+y)/2&\text{if\ }\Param{diffrentjfm}=\texttt{paverage};
7992 \end{cases}.
7993 \]
7994 \item
7995 \Param{differentjfm}がそれ以外の値の時は,<ratio>の値は無視され,JFM由来のグルー/カーンは以下の値となる:
7996 \[
7997  f(\textit{gb},\textit{ga})
7998 \]
7999 ここで.$f(x,y)$は
8000 \[
8001  f(x,y)=\begin{cases}
8002 \min(x,y)&\text{if\ }\Param{diffrentjfm}=\texttt{small};\\
8003 \max(x,y)&\text{if\ }\Param{diffrentjfm}=\texttt{large};\\
8004 (x+y)/2&\text{if\ }\Param{diffrentjfm}=\texttt{average};\\
8005 x+y&\text{if\ }\Param{diffrentjfm}=\texttt{both};
8006 \end{cases}.
8007 \]
8008 \end{itemize}
8009 \end{enumerate}
8010
8011 例えば,
8012 \begin{lstlisting}
8013 \jfont\foo=psft:Ryumin-Light:jfm=ujis;-kern
8014 \jfont\bar=psft:GothicBBB-Medium:jfm=ujis;-kern
8015 \jfont\baz=psft:GothicBBB-Medium:jfm=ujis;jfmvar=piyo;-kern
8016 \end{lstlisting}
8017 という3フォントを考え,
8018 \[
8019  \overbrace{\Node{glyph}{\cs{ foo}, `あ'}}^{p}
8020 \longrightarrow \overbrace{\Node{glyph}{\cs{bar}, `い'}}^{q}
8021 \longrightarrow \overbrace{\Node{glyph}{\cs{baz}, `う'}}^{r}
8022 \]
8023 という3ノードを考える(それぞれ単独でクラスタをなす).
8024 この場合,$p$と$q$の間は,実フォントが異なるにもかかわらず2.の状況となる一方で,
8025 $q$と$r$の間は(実フォントが同じなのに)\texttt{jfmvar} キーの内容が異なるので3.の状況となる.
8026 \item[\Param{kanjiskip}~{[K]}] 上の[M]において空白が定まらなかった場合,
8027 以下で定めた量「右空白」として採用する.
8028 この段階においては,\cs{inhibitglue} は効力を持たないため,
8029 結果として,2つの\textbf{JAchar}間には常に何らかのグルー/カーンが挿入されることとなる.
8030 \begin{enumerate}
8031 \item 両クラスタ(厳密には$\mathit{Nq}.\mathit{tail}$,$\mathit{Np}.\mathit{head}$)の中身の文字コードに対する
8032 \Param{autospacing}パラメタが両方ともfalseだった場合は,長さ0のglueとする.
8033 \item ユーザ側から見た\Param{kanjiskip}パラメタの自然長が$\cs{maxdimen}=(2^{30}-1)\,{\rm sp}$で
8034 なければ,\Param{kanjiskip}パラメタの値を持つglueを採用する.
8035 \item 2.でない場合は,\textit{Nq}, \textit{Np}で使われているJFMに指定されている\Param{kanjiskip}の値を用いる.
8036 どちらか片方のクラスタだけが\textbf{JAchar}(\textsf{和文A}・\textsf{和文B})のときは,そちらのクラスタで使われている
8037 JFM由来の値だけを用いる.もし両者で使われているJFMが異なった場合は,上の[M]~3.と同様の方法を用いて調整する.
8038 \end{enumerate}
8039 \end{description}
8040 %\paragraph{「左空白」の算出とそれに伴う補正}
8041 %「左空白」は過去のバージョンでは定義していたが,このバージョンでは
8042 %挿入は一切行われない(機能自体削除している).
8043 %しかし,仕様は流動的であり,将来復活する可能性もあるため,マニュアル中の記述は今のところ極力変更しない.
8044 \paragraph{禁則用ペナルティの挿入}
8045 まず,
8046 \[
8047  a:=(\text{\textit{Nq}{\footnotemark}の文字に対する\Param{postbreakpenalty}の値})
8048 +(\text{\textit{Np}{\footnotemark}の文字に対する\Param{prebreakpenalty}の値})
8049 \]
8050 とおく\footnotetext{厳密にはそれぞれ$\mathit{Nq}.\mathit{tail}$,$\mathit{Np}.\mathit{head}$.}.
8051 ペナルティは通常$[-10000,10000]$の整数値をとり,また$\pm 10000$は正負の無限大を意味することになっているが,この$a$の
8052 算出では単純な整数の加減算を行う.
8053
8054 $a$は禁則処理用に\textit{Nq}と\textit{Np}の間に加えられるべきペナルティ量である.
8055 \begin{description}
8056 \item[P-normal~{[PN]}]
8057 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティ(\textit{penalty\_node})があれば処理は簡単である:
8058 それらの各ノードにおいて,ペナルティ値を($\pm 10000$を無限大として扱いつつ)$a$だけ増加させればよい.
8059 また,$10000 + (-10000) = 0$としている.
8060
8061 少々困るのは,(a)部分にペナルティが存在していない場合である.
8062 直感的に,補正すべき量$a$が0でないとき,その値をもつ\textit{penalty\_node}を作って
8063 「右空白」の(もし未定義なら\textit{Np}の)直前に挿入……
8064 ということになるが,実際には僅かにこれより複雑である.
8065 \begin{itemize}
8066 \item 「右空白」がカーンであるとき,
8067 それは「\textit{Nq}と\textit{Np}の間で改行は許されない」ことを意図している.そのため,
8068 この場合は$a\neq 0$であってもペナルティの挿入はしない.
8069 \item そうでないないときは,$a\neq 0$ならば\textit{penalty\_node}を作って挿入する.
8070 %\item 「左空白」がカーンとしてきっちり定義されている時(このとき,「右空白」はカーンでない),
8071 %この「左空白」の直後での行分割を許容しないといけないので,$a=0$であっても
8072 %\textit{penalty\_node}を作って挿入する.
8073 %\item 以上のどれでもないときは,$a\neq 0$ならば\textit{penalty\_node}を作って挿入する.
8074 \end{itemize}
8075 \end{description}
8076
8077 \def\gkf#1#2#3{\sf$\displaystyle\vphantom{\Bigg(}%
8078   \frac{\hbox to 4\zw{\hss#2\hss}}{\hbox{#3}}$}
8079 \begin{table}[t]
8080 %<en>\caption{Summary of JFM glues}
8081 %<ja>\caption{JFM グルーの概要}
8082 \label{tab-jfmglue}
8083 %<en>\medskip
8084 \begin{center}
8085 \small
8086 \begin{tabular}{c|cccccc}
8087 \toprule
8088 {\bf\textit{Np}}↓&\sf 和文A&\sf 和文B&\sf 欧文&\sf 箱&\sf glue&\sf kern\\\midrule
8089 \sf 和文A&
8090 \gkf{E}{M→K}{PN}&
8091 \gkf{---}{\OA →K}{PN}&
8092 \gkf{---}{\OA →X}{PN}&
8093 \gkf{---}{\OA}{PA}&
8094 \gkf{---}{\OA}{PN}&
8095 \gkf{---}{\OA}{PS}\\
8096 \sf 和文B&
8097 \gkf{E}{\OB→K}{PA}&
8098 \gkf{---}{K}{PS}&
8099 \gkf{---}{X}{PS}\\
8100 \sf 欧文&
8101 \gkf{E}{\OB →X}{PA}&
8102 \gkf{---}{X}{PS}\cr
8103 \sf 箱&\gkf{E}{\OB}{PA}\\
8104 \sf glue&\gkf{E}{\OB}{PN}\\
8105 \sf kern&\gkf{E}{\OB}{PS}\\
8106 \bottomrule
8107 \end{tabular}
8108 \end{center}
8109 \begin{quote}
8110 %<*en>
8111 In the table above, {\small\gkf{E}{M→K}{PN}} means that
8112 %</en>
8113 %<*ja>
8114 上の表において,{\small\gkf{E}{M→K}{PN}}は次の意味である:
8115 %</ja>
8116 \begin{enumerate}
8117 %<*en>
8118 \item To determine the ``right-space'', \LuaTeX-ja first attempts by the method ``\textsf{JFM-origin~[M]}''.
8119 If this attempt fails, \LuaTeX-ja use the method ``\textsf{\Param{kanjiskip}~[K]}''.
8120 %</en>
8121 %<*ja>
8122 \item 「右空白」を決めるために,\LuaTeX-ja はまず「JFM由来{[M]}」の方法を試みる.
8123   これが失敗したら,\LuaTeX-ja は「\Param{kanjiskip}~{[K]}」の方法を試みる.
8124 %</ja>
8125
8126 % %<*en>
8127 % \item The ``left space'' between \textit{Nq}~and~\textit{Np} is
8128 %   determined by the method ``\textsf{line-end~[E]}''.
8129 % %</en>
8130 % %<*ja>
8131 % \item \textit{Nq} と \textit{Np} の間の「左空白」は「\textsf{line-end~[E]}」の
8132 %   方法で決定される.
8133 % %</ja>
8134
8135 %<*en>
8136 \item \LuaTeX-ja adopts the method ``\textsf{P-normal~[PN]}'' to adjust the penalty
8137   between two clusters for \emph{kinsoku shori}.
8138 %</en>
8139 %<*ja>
8140 \item \LuaTeX-jaは2つのクラスタの間の禁則処理用のペナルティを設定するために「\textsf{P-normal~[PN]}」の方法を採用する.
8141 %</ja>
8142 \end{enumerate}
8143 \end{quote}
8144 \end{table}
8145
8146 \subsection{その他の場合}
8147 本節の内容は表\ref{tab-jfmglue}にまとめてある.
8148
8149 \paragraph{和文Aと欧文の間}
8150 \textit{Nq}が\textsf{和文A}で,\textit{Np}が\textsf{欧文}の場合,JFMグルー挿入処理は次のようにして行われる.
8151 \begin{itemize}
8152 \item 「右空白」については,まず以下に述べる\textsf{Boundary-B~[\OB]}により空白を決定しようと試みる.
8153 それが失敗した場合は,\textsf{\Param{xkanjiskip}~[X]}によって定める.
8154 %\item 「左空白」については,既に述べた\textsf{line-end~[E]}をそのまま採用する.それに伴う「右空白」の補正も%同じ.
8155 \item 禁則用ペナルティも,以前述べた\textsf{P-normal~[PN]}と同じである.
8156 \end{itemize}
8157 \begin{description}
8158 \item[Boundary-B~{[\OB]}] \textbf{JAchar}と「\textbf{JAchar}でないもの」との間に入る空白を以下によって求め,
8159 未定義でなければそれを「右空白」として採用する.
8160 \textsf{JFM-origin~[M]}の変種と考えて良い.
8161 これによって定まる空白の典型例は,和文の閉じ括弧と欧文文字の間に入る半角アキである.
8162 \begin{enumerate}
8163 \item もし両クラスタの間で \cs{inhibitglue} が実行されていた場合%
8164 (証としてwhatsitノードが自動挿入される),「右空白」は未定義.
8165 \item そうでなければ,
8166 \textit{Nq}と「文字コードが {\tt'jcharbdd'} の文字」との間に入るグルー/カーンとして定まる.
8167 \end{enumerate}
8168 \item[\Param{xkanjiskip}~{[X]}]
8169 この段階では,\textsf{\Param{kanjiskip}~[K]}のときと同じように,
8170 以下で定めた量を「右空白」として採用する.
8171 \cs{inhibitglue} は効力を持たない.
8172 \begin{enumerate}
8173 \item 以下のいずれかの場合は,\Param{xkanjiskip}の挿入は抑止される.しかし,実際には行分割を許容するために,長さ0のglueを採用する:
8174 \begin{itemize}
8175 \item 両クラスタにおいて,それらの中身の文字コードに対する\Param{autoxspacing}パラメタが共にfalseである.
8176 \item \textit{Nq}の中身の文字コードについて,「直後への\Param{xkanjiskip}の挿入」が禁止されている
8177 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメタが2以上).
8178 \item \textit{Np}の中身の文字コードについて,「直前への\Param{xkanjiskip}の挿入」が禁止されている
8179 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメタが偶数).
8180 \end{itemize}
8181 \item ユーザ側から見た\Param{xkanjiskip}パラメタの自然長が$\cs{maxdimen}=(2^{30}-1)\,{\rm sp}$で
8182 なければ,\Param{xkanjiskip}パラメタの値を持つglueを採用する.
8183 \item 2.でない場合は,\textit{Nq}, \textit{Np}(\textsf{和文A}/\textsf{和文B}なのは片方だけ)
8184 で使われているJFMに指定されている\Param{xkanjiskip}の値を用いる.
8185 \end{enumerate}
8186 \end{description}
8187
8188 \paragraph{欧文と和文Aの間}
8189 \textit{Nq}が\textsf{欧文}で,\textit{Np}が\textsf{和文A}の場合,JFMグルー挿入処理は上の場合とほぼ同じである.
8190 \textsf{和文A}のクラスタが逆になるので,\textsf{Boundary-A~[\OA]}の部分が変わるだけ.
8191 \begin{itemize}
8192 \item 「右空白」については,まず以下に述べる\textsf{Boundary-A~[\OA]}により空白を決定しようと試みる.
8193 それが失敗した場合は,\textsf{\Param{xkanjiskip}~[X]}によって定める.
8194 %\item \textit{Nq}が和文でないので,「左空白」は算出されない.
8195 \item 禁則用ペナルティは,以前述べた\textsf{P-normal~[PN]}と同じである.
8196 \end{itemize}
8197 \begin{description}
8198 \item[Boundary-A~{[\OA]}] 「\textbf{JAchar}でないもの」と\textbf{JAchar}との間に入る空白を以下によって求め,
8199 未定義でなければそれを「右空白」として採用する.
8200 \textsf{JFM-origin~[M]}の変種と考えて良い.
8201 これによって定まる空白の典型例は,欧文文字と和文の開き括弧との間に入る半角アキである.
8202 \begin{enumerate}
8203 \item もし両クラスタの間で \cs{inhibitglue} が実行されていた場合(証としてwhatsitノードが自動挿入される),次へ.
8204 \item そうでなければ,
8205 「文字コードが {\tt'jcharbdd'} の文字」と\textit{Np}との間に入るグルー/カーンとして定まる.
8206 \end{enumerate}
8207 \end{description}
8208
8209 \paragraph{和文Aと箱・グルー・カーンの間}
8210 \textit{Nq}が\textsf{和文A}で,\textit{Np}が\textsf{箱}・グルー・カーンのいずれかであった場合,
8211 両者の間に挿入されるJFMグルーについては同じ処理である.しかし,そこでの行分割に対する仕様が異なるので,
8212 ペナルティの挿入処理は若干異なったものとなっている.
8213
8214 \begin{itemize}
8215 \item 「右空白」については,既に述べた\textsf{Boundary-B~[\OB]}により空白を決定しようと試みる.
8216 それが失敗した場合は,「右空白」は挿入されない.
8217 %\item 「左空白」については,既に述べた\textsf{line-end~[E]}の算出方法をそのまま採用する.それに伴う「右空白」の補正も同じ.
8218 \item 禁則用ペナルティの処理は,後ろのクラスタ\textit{Np}の種類によって異なる.
8219 なお,$\mathit{Np}.\mathit{head}$は無意味であるから,
8220 「$\mathit{Np}.\mathit{head}$に対する\Param{prebreakpenalty}の値」は0とみなされる.言い換えれば,
8221 \[
8222  a:=(\text{\textit{Nq}の文字に対する\Param{postbreakpenalty}の値}).
8223 \]
8224 \begin{description}
8225 \item[箱] \textit{Np}が\textsf{箱}であった場合は,両クラスタの間での行分割は
8226 (明示的に両クラスタの間に \cs{penalty10000} があった場合を除き)いつも許容される.そのため,
8227 ペナルティ処理は,後に述べる\textsf{P-allow~[PA]}が\textsf{P-normal~[PN]}の代わりに用いられる.
8228 \item[グルー] \textit{Np}がグルーの場合,ペナルティ処理は\textsf{P-normal~[PN]}を用いる.
8229 \item[カーン] \textit{Np}がカーンであった場合は,両クラスタの間での行分割は
8230 (明示的に両クラスタの間にペナルティがあった場合を除き)許容されない.
8231 ペナルティ処理は,後に述べる\textsf{P-suppress~[PS]}を使う.
8232 \end{description}
8233 これらの\textsf{P-normal~[PN]},\textsf{P-allow~[PA]},\textsf{P-suppress~[PS]}の違いは,
8234 \textit{Nq}と\textit{Np}の間(以前の図だと(a)の部分)にペナルティが存在しない場合にのみ存在する.
8235 \end{itemize}
8236
8237 \begin{description}
8238 \item[P-allow~{[PA]}]
8239 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティがあれば,\textsf{P-normal~[PN]}と同様に,
8240 それらの各ノードにおいてペナルティ値を$a$だけ増加させる.
8241
8242 (a)部分にペナルティが存在していない場合,
8243 \LuaTeX-ja は\textit{Nq}と\textit{Np}の間の行分割を可能にしようとする.
8244 そのために,以下のいずれかの場合に$a$をもつ\textit{penalty\_node}を作って
8245 「右空白」の(もし未定義なら\textit{Np}の)直前に挿入する:
8246 \begin{itemize}
8247 \item 「右空白」がグルーでない(カーンか未定義)であるとき.
8248 \item $a\neq 0$のときは,「右空白」がグルーであっても\textit{penalty\_node}を作る.
8249 \end{itemize}
8250
8251 \item[P-suppress~{[PS]}]
8252 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティがあれば,\textsf{P-normal~[PN]}と同様に,
8253 それらの各ノードにおいてペナルティ値を$a$だけ増加させる.
8254
8255 (a)部分にペナルティが存在していない場合,
8256 \textit{Nq}と\textit{Np}の間の行分割は元々不可能のはずだったのであるが,
8257 \LuaTeX-ja はそれをわざわざ行分割可能にはしない.
8258 そのため,「右空白」がglueであれば,その直前に \cs{penalty10000} を挿入する.
8259 \end{description}
8260
8261 \paragraph{箱・グルー・カーンと和文Aの間}
8262 \textit{Np}が\textsf{箱}・グルー・カーンのいずれかで,\textit{Np}が\textsf{和文A}であった場合は,
8263 すぐ上の(\textit{Nq}と\textit{Np}の順序が逆になっている)場合と同じである.
8264 %が,「左空白」がなくなることにのみ注意.
8265 \begin{itemize}
8266 \item 「右空白」については,既に述べた\textsf{Boundary-A~[\OA]}により空白を決定しようと試みる.
8267 それが失敗した場合は,「右空白」は挿入されない.
8268 %\item \textit{Nq}が和文でないので,「左空白」は算出されない.
8269 \item 禁則用ペナルティの処理は,\textit{Nq}の種類によって異なる.
8270 $\mathit{Nq}.\mathit{tail}$は無意味なので,
8271 \[
8272  a:=(\text{\textit{Np}の文字に対する\Param{prebreakpenalty}の値}).
8273 \]
8274 \begin{description}
8275 \item[箱] \textit{Nq}が\textsf{箱}の場合は,\textsf{P-allow~[PA]}を用いる.
8276 \item[グルー] \textit{Nq}がグルーの場合は,\textsf{P-normal~[PN]}を用いる.
8277 \item[カーン] \textit{Nq}がカーンの場合は,\textsf{P-suppress~[PS]}を用いる.
8278 \end{description}
8279 \end{itemize}
8280
8281 \paragraph{和文Aと和文Bの違い}
8282 先に述べたように,\textsf{和文B}はhboxの中身の先頭(or 末尾)として出現している
8283 \textbf{JAchar}である.リスト内に直接ノードとして現れている\textbf{JAchar}(\textsf{和文A})との違いは,
8284 \begin{itemize}
8285 \item \textsf{和文B}に対しては,JFMの文字クラス指定から定まる空白
8286 \textsf{JFM-origin~[M]},\textsf{Boundary-A~[\OA]},\textsf{Boundary-B~[\OB]})の挿入は行われない.
8287 %「左空白」の算出も行われない.
8288 例えば,
8289 \begin{itemize}
8290 \item 片方が\textsf{和文A},もう片方が\textsf{和文B}のクラスタの場合,
8291 \textsf{Boundary-A~[\OA]}または\textsf{Boundary-B~[\OB]}の挿入を試み,それがダメなら
8292 \Param{kanjiskip}~\textsf{[K]}の挿入を行う.
8293 \item \textsf{和文B}の2つのクラスタの間には,\Param{kanjiskip}~\textsf{[K]}が自動的に入る.
8294 \end{itemize}
8295 \item \textsf{和文B}と箱・グルー・カーンが隣接したとき(どちらが前かは関係ない),間にJFMグルー・ペナルティの挿入は一切しない.
8296 \item \textsf{和文B}と\textsf{和文B},また\textsf{和文B}と\textsf{欧文}とが隣接した時は,禁則用ペナルティ挿入処理は
8297 \textsf{P-suppress~[PS]}が用いられる.
8298 \item \textsf{和文B}の文字に対する\Param{prebreakpenalty},~\Param{postbreakpenalty}の値は使われず,0として計算される.
8299 \end{itemize}
8300
8301
8302 次が具体例である:
8303 \begin{LTXexample}
8304 あ.\inhibitglue A\\
8305 \hbox{あ.}A\\
8306 あ.A
8307 \end{LTXexample}
8308 \begin{itemize}
8309 \item 1行目の\cs{inhibitglue}は\textsf{Boundary-B~[\OB]}の処理のみを抑止するので,ピリオドと「A」の間には
8310 \Param{xkanjiskip}(四分アキ)が入ることに注意.
8311 \item 2行目のピリオドと「A」の間においては,前者が\textsf{和文B}となる(hboxの中身の末尾として登場しているから)ので,
8312 そもそも\textsf{Boundary-B~[\OB]}の処理は行われない.よって,\Param{xkanjiskip}が入ることとなる.
8313 \item 3行目では,ピリオドの属するクラスタは\textsf{和文A}である.これによって,
8314 ピリオドと「A」の間には\textsf{Boundary-B~[\OB]}由来の半角アキが入ることになる.
8315 \end{itemize}
8316 %</ja>
8317
8318 %<*ja>
8319 \section{ベースライン補正の方法}
8320 \subsection{\texttt{yoffset} フィールド}
8321 \Param{yalbaselineshift}等のベースライン補正は,基本的には対象となっている
8322 \textit{glyph\_node}の \texttt{yoffset} フィールドの値を増減することによって
8323 実装されている.なお,\texttt{yoffset} の値は上方向への移動量であるのに対し,
8324 \Param{yalbaselineshift}などは下方向への移動量である.
8325
8326 さて,\texttt{yoffset} の増減によって見かけのグリフ位置は上下に移動するが,
8327 仮想ボディの高さ$h$,深さ$d$については
8328 \begin{description}
8329 \catcode`\<=12\catcode`\>=12
8330  \item[$\texttt{yoffset}\geq 0$のとき]
8331 $h = \max(\texttt{height} + \texttt{yoffset}, 0)$,
8332 $d = \max(\texttt{depth} - \texttt{yoffset}, 0)$,
8333  \item[$\texttt{yoffset}<0$のとき]
8334 $h = \max(\texttt{height} + \texttt{yoffset}, 0)$, $d=\texttt{depth}$.
8335 \end{description}
8336 という仕様になっている.つまり,\texttt{yoffset} が負(グリフを下ける)の場合に深さは増加しな
8337 い(表\ref{tab:yoffset_and_im}参照).
8338
8339 \begin{table}[t]
8340 \caption{\texttt{yoffset} and imaginary body}
8341 \label{tab:yoffset_and_im}
8342 \centering\small
8343 \fboxsep0pt
8344 \def\T#1#2{\fcolorbox{blue}{white}{%
8345   \setbox0=\hbox{\LARGE #1%
8346     \directlua{
8347       local p = tex.nest[tex.nest.ptr].tail
8348       p.yoffset = #2 * 65536
8349     }%
8350   }%
8351   \copy0\kern-\wd0\smash{\color{red}\vrule width \wd0 height 0.2pt depth 0.2pt}%
8352 }}
8353 \begin{tabular}{>{\bfseries}lccccc}
8354 \toprule
8355 \texttt{yoffset}&10\,pt&5\,pt&0&$-5$\,pt&$-10$\,pt\\
8356 \midrule
8357 仮想ボディ&\T{y}{10}, \T{H}{10}&\T{y}{5}, \T{H}{5}&\T{y}{0}, \T{H}{0}%
8358 &\T{y}{-5}, \T{H}{-5}&\T{y}{-10}, \T{H}{-10}\\[10pt]
8359 \bottomrule
8360 \end{tabular}
8361 \end{table}
8362
8363 \subsection{\textbf{ALchar}の補正}
8364 上記の問題について,\textbf{ALchar}のベースライン補正では
8365 「正しい深さ」を持った罫線(rule)を補うという対応策をとった.
8366 この罫線による補正は,\textit{id}が\textit{id\_glyph}であるクラスタ単位,
8367 大雑把に言えば音節単位で行われる.
8368 文字列``Typeset''を
8369 \begin{itemize}
8370  \item フォントはLatin Modern Roman (\texttt{lmroman10-regular.otf}) 10\,pt
8371  \item \Param{yalbaselineshift}は5\,pt
8372 \end{itemize}
8373 という状況で組んだ場合を例にとって説明しよう.
8374
8375 \LuaTeX・\Pkg{luaotfload}によるカーニング・ハイフネーションが終わった段階では,……
8376
8377
8378
8379 %</ja>
8380
8381 %<en>\section{Patch for the \Pkg{listings} Package}
8382 %<ja>\section{\Pkg{listings} パッケージへの対応}
8383
8384 %<*en>
8385 It is well-known that the \Pkg{listings} package outputs weird results
8386 for Japanese input.
8387 The \Pkg{listings} package makes most of letters active and assigns
8388 output command for each letter~(\cite{listings}).
8389 But Japanese characters are not included in these activated letters.
8390 For \pTeX{} series, there is no method to make Japanese characters active;
8391 a patch \Pkg{jlisting.sty}~(\cite{jlisting}) resolves the problem forcibly.
8392 %</en>
8393 %<*ja>
8394 \Pkg{listings} パッケージが,そのままでは日本語をまともに出力できないこと
8395 はよく知られている.きちんと整形して出力するために,\Pkg{listings}パッケー
8396 ジは内部で「ほとんどの文字」をアクティブにし,各文字に対してその文字の出
8397 力命令を割り当てている(\cite{listings}).
8398 しかし,そこでアクティブにする文字の中に,和文文
8399 字がないためである.\pTeX 系列では,和文文字をアクティブにする手法がなく,
8400 \Pkg{jlisting.sty} というパッチ(\cite{jlisting})を用いることで無理やり解決していた.
8401 %</ja>
8402
8403 %<*en>
8404 In \LuaTeX-ja, the problem is resolved by using the \verb+process_input_buffer+ callback.
8405 The callback function inserts the output command (active character \texttt{U+FFFFF})
8406 before each letter above \texttt{U+0080}.
8407 This method can omits the process to make all Japanese characters active
8408 (most of the activated characters are not used in many cases).
8409 %</en>
8410 %<*ja>
8411 \LuaTeX-jaでは,\verb+process_input_buffer+ コールバックを利用することで,
8412 「各行に出現する\texttt{U+0080}以降の文字に対して,それらの出力命令を前置する」
8413 という方法をとっている.出力命令としては,アクティブ文字化した \texttt{U+FFFFF} を用いている.
8414 これにより,(入力には使用されていないかもしれない)和文文字をもすべてアクティブ化する手間もなく,
8415 見通しが良い実装になっている.
8416 %</ja>
8417
8418
8419 %<*en>
8420 If the \Pkg{listings} package  and \LuaTeX-ja were loaded,
8421 then the patch \Pkg{lltjp-listings} is loaded automatically at \verb+\begin{document}+.
8422 %</en>
8423 %<*ja>
8424 \LuaTeX-ja で利用される \Pkg{listings} パッケージへのパッチ \Pkg{lltjp-listings} は,
8425 \Pkg{listings} と\LuaTeX-jaを読み込んでおけば,
8426 \verb+\begin{document}+ の箇所において自動的に読み込まれるので,通常はあまり
8427 意識する必要はない.
8428 %</ja>
8429
8430 %<en>\subsection{Notes and additional keys}
8431 %<ja>\subsection{注意}
8432 %<*en>
8433 \paragraph{Escaping to \LaTeX}
8434 We used the \verb+process_input_buffer+ callback to output \textbf{JAchar}s.
8435 But it has a drawback; any commands whose name contains a \textbf{JAchar}
8436 cannot be used in any ``escape to \LaTeX''.
8437
8438 Consider the following input:
8439 %</en>
8440 %<*ja>
8441 \paragraph{\LaTeX へのエスケープ}
8442 日本語対応を行うために \verb+process_input_buffer+ を使用したことで,
8443 \texttt{texcl},~\texttt{escapeinside}といった\emph{「\LaTeX へのエスケープ」中では,
8444 \textbf{JAchar}を名称の一部に含む制御綴は使用不可能}である.
8445 例えば次のような入力を考えよう:
8446 %</ja>
8447 \begin{verbatim*}
8448 \begin{lstlisting}[escapechar=\#]
8449 #\ほげ xぴよ#
8450 \end{lstlisting}
8451 \end{verbatim*}
8452 %<en>The line~2 is transformed by the callback to
8453 %<ja>ここで,2行目は \verb+process_input_buffer+ の作用により,
8454 \begin{lstlisting}[showspaces, escapechar=\!]
8455 #\!\IVSA FFFFF!ほ!\IVSA FFFFF!げ x!\IVSA FFFFF!ぴ!\IVSA FFFFF!よ#
8456 \end{lstlisting}
8457 %<*en>
8458 before the line is actually processed.
8459 In the escape (between the character ``\verb+#+''),
8460 the category code of \texttt{U+FFFFF} is set to 9~(\emph{ignored}).
8461 Hence the control symbol ``\cs{}\IVSA FFFFF'' will be executed,
8462 instead of ``\verb+\ほげ+''.
8463 %</en>
8464 %<*ja>
8465 と変換されてから,実際の処理に回される.
8466 「\verb+#+」で挟まれた「\LaTeX へのエスケープ」中では\
8467 \texttt{U+FFFFF} のカテゴリーコードは9~(\textit{ignored})となるので,
8468 結局「\verb+\ほげ+」の代わりに
8469 「\cs{}\IVSA FFFFF」というcontrol symbolが実行されることになる.
8470 %</ja>
8471
8472 %<*en>
8473 \paragraph{Variation selectors}
8474 \Pkg{lltjp-listings} add two keys, namely \texttt{vsraw}~and~\texttt{vscmd},
8475 which specify how variation selectors are treated in
8476 \texttt{lstlisting} or other enviroments.
8477 Note that these additional keys are not usable in the preamble,
8478 since \Pkg{lltjp-listings} is loaded at \verb+\begin{document}+.
8479
8480 \texttt{vsraw} is a key which takes a boolean value, and its default value is
8481 false.
8482 \begin{itemize}
8483  \item If the \texttt{vsraw} key is true, then
8484 variation selectors are ``combined'' with the previous character.
8485 %</en>
8486 %<*ja>
8487 \paragraph{異体字セレクタの扱い}
8488 \texttt{lstlisting} 環境などの内部にある異体字セレクタを扱うため,
8489 \Pkg{lltjp-listings} では \texttt{vsraw} と \texttt{vscmd} という2つのキーを追加した.
8490 しかし,\Pkg{lltjp-listings} が実際に読み込まれるのは \verb+\begin{document}+\
8491 のところであるので,プリアンブル内ではこれらの追加キーは使用できない.
8492
8493 \texttt{vsraw}は,ブール値の値をとるキーであり,標準ではfalseである.
8494 \begin{itemize}
8495  \item trueの場合は,異体字セレクタは「直前の文字に続けて」出力される.
8496 もしもIVSサポート(\ref{ssec-ltjotf}節)が有効になっていた場合は,
8497 以下の例(左側は入力,右側はその出力)のようになる.
8498 %</ja>
8499 \begin{LTXexample}
8500 \begin{lstlisting}[vsraw=true]
8501 葛󠄀城市,葛󠄁飾区,葛西
8502 \end{lstlisting}
8503 \end{LTXexample}
8504 %<*en>
8505 \item If the \texttt{vsraw} key is false, then
8506 variation selectors are typeset by an appropriate command, which is specified by
8507       the \texttt{vscmd} key.
8508 The default setting of the \texttt{vscmd} key produces the following.
8509 %</en>
8510 %<*ja>
8511 \item falseの場合は,異体字セレクタは適当な命令によって「見える形で」出力される.
8512 どのような形で出力されるかを規定するのが \texttt{vscmd} キーであり,
8513 \Pkg{lltjp-listings} の標準設定では以下の例の右側のように出力される.
8514 %</ja>
8515 \begin{LTXexample}
8516 \begin{lstlisting}[vsraw=false,
8517    vscmd=\ltjlistingsvsstdcmd]
8518 葛󠄀城市,葛󠄁飾区,葛西
8519 \end{lstlisting}
8520 \end{LTXexample}
8521 %<ja> ちなみに,本ドキュメントでは次のようにしている:
8522 %<en> For example, the following code is the setting of the \texttt{vscmd} key in this document.
8523 \begin{lstlisting}[numbers=left]
8524 \def\IVSA#1#2#3#4#5{%
8525   \textcolor{blue}{\raisebox{3.5pt}{\tt%
8526     \fboxsep=0.5pt\fbox{\tiny \oalign{0#1#2\crcr#3#4#5\crcr}}}}%
8527 }
8528 {\catcode`\%=11
8529   \gdef\IVSB#1{\expandafter\IVSA\directlua{
8530     local cat_str = luatexbase.catcodetables['string']
8531     tex.sprint(cat_str, string.format('%X', 0xE00EF+#1))
8532 }}}
8533 \lstset{vscmd=\IVSB}
8534 \end{lstlisting}
8535 \end{itemize}
8536 %<*en>
8537 The default output command of variation selectors is stored in \verb+\ltjlistingsvsstdcmd+.
8538 %</en>
8539 %<*ja>
8540 既定の出力命令を復活させたい場合は\ \verb+vscmd=\ltjlistingsvsstdcmd+\
8541 とすれば良い.
8542 %</ja>
8543
8544 %<*en>
8545 \paragraph{The \texttt{doubleletterspace} key}
8546 Even the column format is \texttt{[c]fixed}, sometimes characters are not vertically aligned.
8547 The following example  is typeset with \texttt{basewidth=2em}, and
8548 you'll see the leftmost ``\texttt{H}'' are not vertically aligned.
8549 \begin{lstlisting}[basewidth=2em, basicstyle=\tt,numbers=left]
8550 :H:
8551 :HHHH:
8552 \end{lstlisting}
8553
8554 \Pkg{lltjp-listing} adds the \texttt{doubleletterspace} key (not activated by default, for
8555 compatibility) to
8556 improve the situation, namely doubles inter-character space in each output unit.
8557 With this key, the above input now produces better output.
8558 \begin{lstlisting}[basewidth=2em, basicstyle=\tt,numbers=left, doubleletterspace]
8559 :H:
8560 :HHHH:
8561 \end{lstlisting}
8562 %</en>
8563 %<*ja>
8564 \paragraph{\texttt{doubleletterspace}キー}
8565 \Pkg{listings}パッケージで列揃えが \texttt{[c]fixed} となっている場合でも,
8566 場合によっては文字が縦に揃わない場合もある.
8567 例を以下に示そう.これは強調するために \texttt{basewidth=2em} を設定している.
8568 \begin{lstlisting}[basewidth=2em, basicstyle=\tt,numbers=left]
8569 :H:
8570 :HHHH:
8571 \end{lstlisting}
8572 1行目と2行目の「\texttt{H}」の位置が揃っていないが,
8573 これは出力単位ごとに,先頭・末尾・各文字間に同じ量の空白を挿入することによる.
8574
8575 \Pkg{lltjp-listing}では,このような症状を改善させるために \texttt{doubleletterspace} キー
8576 を追加した(標準では互換性のために無効になっている).このキーを有効にすると,
8577 出力単位中の各文字間の空白を2倍にすることで文字を揃いやすくしている.
8578 上と同じものを \texttt{doubleletterspace} キーを有効にして組んだものが以下であり,
8579 きちんと「\texttt{H}」の位置が揃っていることが分かる.
8580 \begin{lstlisting}[basewidth=2em, basicstyle=\tt,numbers=left, doubleletterspace]
8581 :H:
8582 :HHHH:
8583 \end{lstlisting}
8584 %</ja>
8585
8586 %<en>\subsection{Class of Characters}
8587 %<ja>\subsection{文字種}
8588
8589 %<en>Roughly speaking, the \Pkg{listings} package processes input as follows:
8590 %<ja>\Pkg{listings} パッケージの内部では,大雑把に言うと
8591 \begin{enumerate}
8592 %<en>\item Collects \textit{letters} and \textit{digits}, which can be used for the name of identifiers.
8593 %<ja>\item 識別子として使える文字 (``letter'',~``digit'') たちを集める.
8594 %<en>\item When reading an \textit{other}, outputs the collected character string (with modification, if needed).
8595 %<ja>\item letterでもdigitでもない文字が現れた時に,収集した文字列を(必要なら修飾して)出力する.
8596 %<en>\item Collects \textit{others}.
8597 %<ja>\item 今度は逆に,letterでない文字たちをletterが現れるまで集める.
8598 %<en>\item When reading a \textit{letter} or a \textit{digit}, outputs the collected character string.
8599 %<ja>\item letterが出現したら集めた文字列を出力する.
8600 %<en>\item Turns back to 1.
8601 %<ja>\item 1.に戻る.
8602 \end{enumerate}
8603 %<*en>
8604 By the above process, line breaks inside of an identifier are blocked.
8605 A flag \verb+\lst@ifletter+ indicates whether the previous character can be used
8606 for the name of identifiers or not.
8607 %</en>
8608 %<*ja>
8609 という処理が行われている.これにより,識別子の途中では行分割が行われないようになっている.
8610 直前の文字が識別子として使えるか否かは \verb+\lst@ifletter+ というフラグに格納されている.
8611 %</ja>
8612
8613 %<*en>
8614 For Japanese characters, line breaks are permitted on both sides
8615 except for brackets, dashes, etc.
8616 Hence the patch \Pkg{lltjp-listings} introduces
8617 a new flag \verb+\lst@ifkanji+, which indicates
8618 whether the previous character is a Japanese character or not.
8619 For illustration, we introduce following classes of characters:
8620 %</en>
8621 %<*ja>
8622 さて,日本語の処理である.殆どの和文文字の前後では行分割が可能であるが,その一方で
8623 括弧類や音引きなどでは禁則処理が必要なことから,\Pkg{lltjp-listings} では,
8624 直前が和文文字であるかを示すフラグ \verb+\lst@ifkanji+ を新たに導入した.
8625 以降,説明のために以下のように文字を分類する:
8626 %</ja>
8627 \begin{center}
8628 \small
8629 \begin{tabular}{lccccc}
8630 \toprule
8631 &Letter&Other&Kanji&Open&Close\\\midrule
8632 \verb+\lst@ifletter+&T&F&T&F&T\\
8633 \verb+\lst@ifkanji+&F&F&T&T&F\\
8634 %<en>Meaning&char in an identifier&other alphabet&%
8635 %<en>most of Japanese char&opening brackets&closing brackets\\
8636 %<ja>意図&識別子中の文字&その他欧文文字&殆どの和文文字&開き括弧類&閉じ括弧類\\
8637 \bottomrule
8638 \end{tabular}
8639 \end{center}
8640 %<*en>
8641 Note that \textit{digits} in the \Pkg{listings} package can be Letter or
8642 Other according to circumstances.
8643 %</en>
8644 %<*ja>
8645 なお,本来の\Pkg{listings} パッケージでの分類``digit''は,
8646 出現状況によって,上の表のLetterとOtherのどちらにもなりうる.
8647 また,KanjiとCloseは \verb+\lst@ifletter+ と \verb+\lst@ifkanji+ の値が一致しているが,
8648 これは間違いではない.
8649 %</ja>
8650
8651 %<*en>
8652 For example, let us consider the case an Open comes after a Letter.
8653 Since an Open represents Japanese open brackets,
8654 it is preferred to be permitted to insert line break after the Letter.
8655 Therefore, the collected character string is output in this case.
8656 %</en>
8657 %<*ja>
8658 例えば,Letterの直後にOpenが来た場合を考える.
8659 文字種Openは和文開き括弧類を想定しているので,Letterの直後では行分割が可能であることが望ましい.
8660 そのため,この場合では,すでに収集されている文字列を出力することで行分割を許容するようにした.
8661 %</ja>
8662
8663 %<*en>
8664 The following table summarizes $5\times 5=25$ cases:
8665 %</en>
8666 %<*ja>
8667 同じように,$5\times 5=25$通り全てについて書くと,次のようになる:
8668 %</ja>
8669 \begin{center}
8670 \small
8671 \begin{tabular}{llccccc}
8672 \toprule
8673 %<*en>
8674 &&\multicolumn{4}{c}{Next}\\\cmidrule(lr){3-7}
8675 &&\hbox to 4em{\hss Letter\hss}&\hbox to 4em{\hss Other\hss}
8676 &\hbox to 4em{\hss Kanji\hss}&\hbox to 4em{\hss Open\hss}&Close\\\midrule
8677 &Letter&collects&\multicolumn{3}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
8678 &Other&outputs&collects&\multicolumn{2}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
8679 Prev&Kanji&\multicolumn{4}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
8680 &Open&\multicolumn{5}{c}{\hrulefill \ collects\ \hrulefill}\\
8681 &Close&\multicolumn{4}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
8682 %</en>
8683 %<*ja>
8684 &&\multicolumn{4}{c}{後ろ側の文字}\\\cmidrule(lr){3-7}
8685 &&\hbox to 4em{\hss Letter\hss}&\hbox to 4em{\hss Other\hss}
8686 &\hbox to 4em{\hss Kanji\hss}&\hbox to 4em{\hss Open\hss}&Close\\\midrule
8687 直&Letter&収集&\multicolumn{3}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
8688 前&Other&出力&収集&\multicolumn{2}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
8689 文&Kanji&\multicolumn{4}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
8690 字&Open&\multicolumn{5}{c}{\hrulefill \ 収集\ \hrulefill}\\
8691 種&Close&\multicolumn{4}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
8692 %</ja>
8693 \bottomrule
8694 \end{tabular}
8695 \end{center}
8696 %<en>In the above table,
8697 %<ja>上の表において,
8698 \begin{itemize}
8699 %<en>\item ``outputs'' means to output the collected character string (i.e., line breaking is permitted there).
8700 %<ja>\item 「出力」は,それまでに集めた文字列を出力(≒ここで行分割可能)を意味する.
8701
8702 %<en>\item ``collects'' means to append the next character to the collected character string (i.e., line breaking is prohibited there).
8703 %<ja>\item 「収集」は,後側の文字を,現在収集された文字列に追加(行分割不可)を意味する.
8704 \end{itemize}
8705
8706 %<*en>
8707 Characters above or equal to~\texttt{U+0080} \emph{except Variation Selectors}
8708 are classified into above 5~classes by the following rules:
8709 %</en>
8710 %<*ja>
8711 \texttt{U+0080}以降の\emph{異体字セレクタ以外の}各文字が
8712 Letter, Other, Kanji, Open, Closeのどれに属するかは次によって決まる:
8713 %</ja>
8714 \begin{itemize}
8715 %<en>\item \textbf{ALchar}s above or equal to~\texttt{U+0080} are classified as Letter.
8716 %<ja>\item (\texttt{U+0080}以降の)\textbf{ALchar}は,すべてLetter扱いである.
8717
8718 %<en>\item \textbf{JAchar}s are classified in the order as follows:
8719 %<ja>\item \textbf{JAchar}については,以下の順序に従って文字種を決める:
8720 \begin{enumerate}
8721 %<en>\item Characters whose \Param{prebreakpenalty} is greater than or equal to 0 are classified as Open.
8722 %<ja>\item \Param{prebreakpenalty}が0以上の文字はOpen扱いである.
8723
8724 %<en>\item Characters whose \Param{postbreakpenalty} is greater than or equal to 0 are classified as Close.
8725 %<ja>\item \Param{postbreakpenalty}が0以上の文字はClose扱いである.
8726
8727 %<en>\item Characters that don't satisfy the above two conditions are classified as Kanji.
8728 %<ja>\item 上の3条件のどちらにも当てはまらなかった文字は,Kanji扱いである.
8729 \end{enumerate}
8730 \end{itemize}
8731
8732 %<*en>
8733 The width of halfwidth kana (\texttt{U+FF61}--\texttt{U+FF9F})
8734 is same as the width of \textbf{ALchar};
8735 the width of the other \textbf{JAchar}s is double the width of \textbf{ALchar}.
8736 %</en>
8737 %<*ja>
8738 なお,半角カナ(U+FF61--U+FF9F)以外の\textbf{JAchar}は欧文文字2文字分の幅をとるものとみなされる.
8739 半角カナは欧文文字1文字分の幅となる.
8740 %</ja>
8741
8742 %<*en>
8743 This classification process is executed every time a character appears in
8744 the \texttt{lstlisting} environment or other environments/commands.
8745 %</en>
8746 %<*ja>
8747 これらの文字種決定は,実際に \texttt{lstlisting} 環境などの内部で文字が出てくるたびに行われる.
8748 %</ja>
8749
8750 %<*ja>
8751 \section{和文の行長補正方法}
8752 \label{sec-adjspec}
8753 \Pkg{luatexja-adjust} で提供される優先順位付きの行長調整の詳細を述
8754 べる.大まかに述べると,次のようになる.
8755 \begin{itemize}
8756 \item 通常の\TeX の行分割方法に従って,段落を行分割する.この段階では,行
8757       長に半端が出た場合,その半端分は\textbf{JAglue}(\Param{xkanjiskip},
8758       \Param{kanjiskip},JFMグルー)と
8759       それ以外のグルーの全てで(優先順位なく)負担される.
8760 \item その後,\texttt{post\_linebreak\_filter} callbackを使い,\emph{段
8761       落中の各行ごとに},行末文字の位置を調整したり,優先度付きの行長調整
8762       を実現するためにグルーの伸縮度を調整する.
8763       その処理においては,グルーの自然長と\textbf{JAglue}以外の
8764       グルーの伸び量・縮み量は変更せず,必要に応じて\textbf{JAglue}の伸び量・縮み量のみを
8765       変更する設計とした.
8766
8767 \Pkg{luatexja-adjust} の作用は,この処理を行うcallbackを追加するだけであり,
8768       この章の残りではcallbackでの処理について解説する.
8769 \end{itemize}
8770
8771 \paragraph{準備:合計伸縮量の計算}
8772 グルーの伸縮度(\texttt{plus} や \texttt{minus} で指定されている値)には,
8773 有限値の他に,\texttt{fi},\texttt{fil},\texttt{fill},\texttt{filll}と
8774 いう4つの無限大レベル(後ろの方ほど大きい)があり,行の調整に
8775 \texttt{fi} などの\emph{無限大レベルの伸縮度が用いられている場合は,そ
8776 の行に対しての処理を中止}する.
8777
8778 よって,以降,問題にしている行の行長調整は伸縮度が有限長のグルーを用いて
8779 行われているとして良い.さらに,簡単のため,この行はグルーが広げられている
8780 (自然長で組むと望ましい行長よりの短い)場合しか扱わない.
8781
8782 まず,段落中の行中のグルーを
8783 \begin{itemize}
8784 \item \textbf{JAglue}ではないグルー
8785 \item JFMグルー(優先度\footnote{%
8786   \ref{ssec-jfm-str}節にあるように,
8787   各JFMグルーには$-2$から2までの優先度がついている.}%
8788 別にまとめられる)
8789 \item 和欧文間空白(\Param{xkanjiskip})
8790 \item 和文間空白(\Param{kanjiskip})
8791 \end{itemize}
8792 の$1+1+5+1=8$つに類別し,それぞれの種別ごとに
8793 許容されている伸び量(\texttt{stretch}の値)の合計を計算する.
8794 また,行長と自然長との差を\textit{total}とおく.
8795
8796
8797 \subsection{行末文字の位置調整}
8798 行末が文字クラス$n$の\textbf{JAchar}であった場合,
8799 それを動かすことによって,\textit{total}のうち
8800 \textbf{JAglue}が負担する分を少なくしようとする.
8801 この行末文字の左右の移動可能量は,
8802 JFM中にある文字クラス$n$の定義の
8803 \texttt{end\_stretch},~\texttt{end\_shrink}フィールドに
8804 全角単位の値として記述されている.
8805
8806 例えば,行末文字が句点「。」であり,そこで用いられているJFM中に
8807 \begin{lstlisting}
8808   [2] = {
8809     chars = { '。', ... }, width = 0.5, ...,
8810     end_stretch = 0.5, end_shrink = 0.5,
8811   },
8812 \end{lstlisting}
8813 という指定があった場合,この行末の句点は
8814 \begin{itemize}
8815 \item 通常の\TeX の行分割処理で「半角以上の詰め」が行われていた場合,
8816 この行中の\textbf{JAglue}の負担を軽減するため,
8817 行末の句点を半角だけ右に移動する(ぶら下げ組を行う).
8818 \item 通常の\TeX の行分割処理で「半角以上の空き」が行われていた場合,
8819 逆に行末句点を半角左に移動させる(見た目的に全角取りとなる).
8820 \item 以上のどちらでもない場合,行末句点の位置調整は行わない.
8821 \end{itemize}
8822 となる.
8823
8824 行末文字を移動した場合,その分だけ\textit{total}の値を引いておく.
8825
8826 \subsection{グルーの調整}
8827 \textit{total}の分だけが,行中のグルーの伸び量に応じて負担されることになる.
8828 負担するグルーの優先度は以下の順であり,
8829 できるだけ\Param{kanjiskip}を自然長のままにすることを
8830 試みている.
8831 \begin{enumerate}\def\labelenumi{(\Alph{enumi})}
8832  \item \textbf{JAglue}以外のグルー
8833  \item 優先度2のJFMグルー
8834  \item 優先度1のJFMグルー
8835  \item 優先度0のJFMグルー
8836  \item 優先度$-1$のJFMグルー
8837  \item 優先度$-2$のJFMグルー
8838  \item \Param{xkanjiskip}
8839  \item \Param{kanjiskip}
8840 \end{enumerate}
8841 \begin{enumerate}
8842  \item 行末の\textbf{JAchar}を移動したことで$\textit{total}=0$となれば,
8843 調整の必要はなく,行が格納されているhboxの
8844 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算すればよい.
8845 以降,$\textit{total}\neq 0$と仮定する.
8846  \item \textit{total}が「\textbf{JAglue}以外のグルーの伸び量の合計」(以下,(A)の伸び量の
8847        合計,と称す)よりも小さければ,
8848 それらのグルーに\textit{total}を負担させ,\textbf{JAglue}達自身は自然長で組むことができる.
8849 よって,以下の処理を行う:
8850 \begin{enumerate}
8851 \item 各\textbf{JAglue}の伸び量を0とする.
8852 \item 行が格納されているhboxの
8853 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算する.
8854 これによって,\textit{total}は\textbf{JAglue}以外のグルーによって負担される.
8855 \end{enumerate}
8856 \item \textit{total}が「(A)の伸び量の合計」以上ならば,(A)--(H)のどこまで負担すれば
8857 \textit{total}以上になるかを計算する.
8858 例えば,
8859 \[\catcode`\<=12
8860  \textit{total} = (\text{(A)--(B)の伸び量の合計}) + p\cdot (\text{(C)の伸び量の合計}),
8861  \qquad 0\le p<1
8862 \]
8863 であった場合,各グルーは次のように組まれる:
8864 \begin{itemize}
8865  \item (A),~(B)に属するグルーは各グルーで許された伸び量まで伸ばす.
8866  \item (C)に属するグルーはそれぞれ$p\times (\text{伸び量})$だけ伸びる.
8867  \item (D)--(H)に属するグルーは自然長のまま.
8868 \end{itemize}
8869 実際には,前に述べた「設計」に従い,次のように処理している:
8870 \begin{enumerate}
8871 \item (C)に属するグルーの伸び量を$p$倍する.
8872 \item (D)--(H)に属するグルーの伸び量を0とする.
8873 \item 行が格納されているhboxの
8874 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算する.
8875 これによって,\textit{total}は\textbf{JAglue}以外のグルーによって負担される.
8876 \end{enumerate}
8877 \item \textit{total}が(A)--(H)の伸び量の合計よりも大きい場合,どうしようもないので
8878       \verb+^^;+何もしない.
8879 \end{enumerate}
8880
8881 %</ja>
8882
8883 %<*ja>
8884 \section{IVS対応}
8885 \verb+luatexja.otf.enable_ivs()+ を実行し,IVS対応を有効にした状態では,
8886 \verb+pre_linebreak_filter+ や \verb+hpack_filter+ コールバックには
8887 次の4つが順に実行される状態となっている:
8888 \begin{description}
8889 \item[\tt ltj.do\_ivs] \textit{glyph\_node}~$p$の直後に,異体字セレクタ(を表す\textit{glyph\_node})
8890 が連続した場合に,$p$のフォントに対応したが持つ「異体字情報」に従って出力するグリフを変える.
8891
8892 しかし,単に$p.\textit{char}$を変更するだけでは,後から
8893 font featureの適用(すぐ下)により置換される可能性がある.そのため,
8894 \cs{CID} や \cs{UTF} と同じように,\textit{glyph\_node}~$p$の代わりに
8895 \texttt{user\_id} が\textit{char\_by\_cid}であるようなuser-defined whatsitを用いている.
8896 \item[(\Pkg{luaotfload} によるfont featureの適用)]
8897 \item[\tt ltj.otf] \texttt{user\_id} が\textit{char\_by\_cid}であるようなuser-defined whatsitを
8898 きちんと\textit{glyph\_node}に変換する.この処理は,\cs{CID}, \cs{UTF}やIVSによる置換が,
8899 font featureの適用で上書きされてしまうのを防止するためである.
8900 \item[\tt ltj.main\_process] \textbf{JAglue}の挿入処理(\ref{sec-jfmglue}章)と,
8901 JFMの指定に従って各\textbf{JAchar}の「寸法を補正」することを行う.
8902 \end{description}
8903
8904 問題は各フォントの持っているIVS情報をどのように取得するか,である.
8905 \Pkg{luaotfload} はフォント番号<font\_number>の情報を\
8906 \texttt{fonts.hashes.identifiers[<font\_number>]} 以下に格納している.
8907 しかし,OpenTypeフォントのIVS情報は格納されていないようである%
8908 \footnote{TrueTypeフォントに関しては,
8909 \begin{center}
8910 \texttt{fonts.hashes.idenfiers[<font\_number>]%
8911   .resources.variants[<selector>][<base\_char>]}
8912 \end{center}
8913 に,<base\_char>番の文字の後に異体字セレクタ<selector>が続いた場合に
8914 出力すべきグリフが書かれてある.}.
8915 %例えば,小塚明朝Pr6N~Rでは,
8916
8917 一方,\LuaTeX 内部の \texttt{fontloader} の返すテーブルには
8918 OpenTypeフォントでもTrueTypeフォントでもIVS情報が格納されている.
8919 具体的には……
8920
8921 そのため,\LuaTeX-jaのIVS対応においては,\LuaTeX 内部の\
8922 \texttt{fontloader} を直接用いることで,フォントのIVS情報を取得している.
8923 20140114.0以降でキャッシュを用いるようにした要因はここにあり,
8924 \texttt{fontloader} の呼び出しでかなり時間を消費することから,
8925 %%% to_table を使わなくしたことで,メモリ使用量は減った
8926 IVS情報をキャッシュに保存することで2回目以降の実行時間を節約している.
8927 %</ja>
8928
8929
8930 %<*ja>
8931 \section{複数フォントの「合成」(未完)}
8932 \section{\LuaTeX-jaにおけるキャッシュ}
8933 \Pkg{luaotfload}パッケージが,各TrueType・OpenTypeフォントの情報を
8934 キャッシュとして保存しているのと同様の方法で,
8935 \LuaTeX-jaもいくつかのキャッシュファイルを作成するようになった.
8936 \begin{itemize}
8937  \item 通常,キャッシュは\texttt{\$TEXMFVAR/luatexja/}以下に保存され,
8938 そこから読み込みが行われる.
8939  \item 「通常の」テキスト形式のキャッシュ(拡張子は \texttt{.lua})以外にも,
8940 それをバイナリ形式(バイトコード)に変換したものもサポートしている.
8941 \begin{itemize}
8942  \item \LuaTeX とLuaJIT\TeX ではバイトコードの形式が異なるため,バイナリ形式の
8943 キャッシュは共有できない.\LuaTeX 用のバイナリキャッシュは \texttt{.luc},
8944 LuaJIT\TeX 用のは \texttt{.lub} と拡張子を変えることで対応している.
8945  \item キャッシュを読み込む時,同名のバイナリキャッシュがあれば,
8946 テキスト形式のものよりそちらを優先して読み込む.
8947  \item テキスト形式のキャッシュが更新/作成される際は,そのバイナリ版も
8948 同時に更新される.
8949 また,(バイナリ版が見つからず)テキスト形式のキャッシュ側が読み込まれたときは,
8950 \LuaTeX-jaはバイナリキャッシュを作成する.
8951 \end{itemize}
8952 \end{itemize}
8953 %</ja>
8954 %<*en>
8955 \section{Cache Management of \LuaTeX-ja}
8956 \LuaTeX-ja creates some cache files to reduce the loading time.
8957 in a similar way to the \Pkg{luaotfload} package:
8958 \begin{itemize}
8959  \item Cache files are usually stored in (and loaded from)
8960 \texttt{\$TEXMFVAR/luatexja/}.
8961  \item In addition to caches of the text form (the extension is ``\texttt{.lua}''),
8962 caches of the \emph{binary}, precompiled form are supported.
8963 \begin{itemize}
8964  \item We cannot share same binary cache for \LuaTeX\ and LuaJIT\TeX.
8965 Hence we distinguish them by their extension, ``\texttt{.luc}'' for \LuaTeX\
8966 and ``\texttt{.lub}'' for LuaJIT\TeX.
8967  \item In loading a cache, the binary cache precedes
8968 the text form.
8969  \item When \LuaTeX-ja updates a cache \texttt{hoge.lua},
8970 its binary version is also updated.
8971 \end{itemize}
8972 \end{itemize}
8973 %</en>
8974
8975 %<*ja>
8976 \subsection{キャッシュの使用箇所}
8977
8978 \LuaTeX-ja では以下の3種類のキャッシュを使用している:
8979 \begin{cslist}
8980 \item[ltj-cid-auto-adobe-japan1.lua]
8981 Ryumin-Lightのような非埋め込みフォントの情報を格納しており,
8982 (それらが\LuaTeX-jaの標準和文フォントなので)\LuaTeX-jaの読み込み時に自動で読まれる.
8983 生成には\texttt{UniJIS2004-UTF32-\{H, V\}}, \texttt{Adobe-Japan1-UCS2}という3つの
8984 CMapが必要である.
8985
8986 \pageref{para-cid}ページで述べたように,\texttt{cid}キーを使って
8987 非埋め込みの中国語・韓国語フォントを定義する場合,同様のキャッシュが生成される.
8988 キャッシュの名称,必要となるCMapについては表\ref{tab:cid-cache}を参照して欲しい.
8989
8990 \item[extra\_***.lua]
8991 フォント``\texttt{***}''における異体字セレクタの情報,縦組用字形への変換テーブル,そして
8992 縦組時における幅を格納している.構造は以下の通り:
8993 %</ja>
8994 %<*en>
8995 \subsection{Use of Cache}
8996
8997 \LuaTeX-ja uses the following cache:
8998 \begin{cslist}
8999 \item[ltj-cid-auto-adobe-japan1.lua]
9000 The font table of a CID-keyed non-embedded Japanese font.
9001 This is loaded in every run.
9002 It is created from three CMaps, \texttt{UniJIS2004-UTF32-\{H,V\}} and
9003              \texttt{Adobe-Japan1-UCS2},
9004 and this is why these two CMaps are needed in the first run of \LuaTeX-ja.
9005
9006 Similar caches are created as Table~\ref{tab:cid-cache},
9007 if you specified \texttt{cid} key in \cs{jfont}
9008 to use other CID-keyed non-embedded fonts for Chinese or Korean,
9009 as in Page~\pageref{para-cid}.
9010
9011 \item[extra\_***.lua]
9012 This file stores the table which stores the following.
9013 \begin{itemize}
9014  \item unicode variants in a font ``\texttt{***}''
9015  \item vertical width of glyphs, if it is not equal to the sum of
9016 the height of ascender and the depth of descender
9017  \item vertical variants
9018 \end{itemize}
9019 The following is the structure of the that table.
9020 %</en>
9021
9022 \begin{table}[!tb]
9023  \centering\small
9024 \caption{\texttt{cid} key and corresponding files}
9025 \label{tab:cid-cache}
9026 \vspace*{\medskipamount}
9027 \begin{tabular}{>{\tt}l>{\tt}l>{\tt}l>{\tt}l}
9028 \toprule
9029 \bf \texttt{cid} key&\bf name of the cache &
9030 \multicolumn{2}{c}{\bf used CMaps}\\
9031 \midrule
9032 Adobe-Japan1-*&ltj-cid-auto-adobe-japan1.lua&UniJIS2004-UTF32-*&Adobe-Japan1-UCS2\\
9033 Adobe-Korea1-*&ltj-cid-auto-adobe-korea1.lua&UniKS-UTF32-*&Adobe-Korea1-UCS2\\
9034 Adobe-GB1-*&ltj-cid-auto-adobe-gb1.lua&UniGB-UTF32-*&Adobe-GB1-UCS2\\
9035 Adobe-CNS1-*&ltj-cid-auto-adobe-cns1.lua&UniCNS-UTF32-*&Adobe-CNS1-UCS2\\
9036 \bottomrule
9037 \end{tabular}
9038 \end{table}
9039
9040 \begin{lstlisting}
9041 return {
9042  {
9043   [10955]={    -- U+2ACB "Subset Of Above Not Equal To"
9044    [65024]=983879, -- <2ACB FE00>
9045    ["vwidth"]=0.98, -- vertical width
9046   },
9047   [37001]={    -- U+9089 "邉"
9048    [0]=37001,  --   <9089 E0100>
9049    991049,     --   <9089 E0101>
9050    ...
9051    ["vert"]=995025, -- vertical variant
9052   },
9053   ...
9054  },
9055  ["chksum"]="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", -- checksum of the fontfile
9056  ["version"]=2, -- version of the cache
9057 }
9058 \end{lstlisting}
9059 %<*ja>
9060 \item[ltj-jisx0208.\{luc|lub\}]
9061 \LuaTeX-ja配布中の\texttt{ltj-jisx0208.lua}をバイナリ化したものである.
9062 これはJIS~X~0208とUnicodeとの変換テーブルであり,
9063 \pTeX との互換目的の文字コード変換命令で用いられる.
9064 %</ja>
9065 %<*en>
9066 \item[ltj-jisx0208.\{luc|lub\}]
9067 The binary version of \texttt{ltj-jisx0208.lua}.
9068 This is the conversion table between JIS~X~0208 and Unicode
9069 which is used in Kanji-code conversion commands for compatibility with \pTeX.
9070 %</en>
9071 \end{cslist}
9072
9073 %<*en>
9074 \subsection{Internal}
9075 Cache management system of \LuaTeX-ja is stored in \texttt{luatexja.base}
9076 (\texttt{ltj-base.lua}).
9077 There are three public functions for cache management in \texttt{luatexja.base},
9078 where <filename> stands for the file name \emph{without suffix}:
9079 \begin{cslist}
9080 \item[save\_cache(<filename>, <data>)]
9081 Save a non-nil table <data> into a cache <filename>.
9082 Both the text form <filename>\texttt{.lua} and its binary version
9083 are created or updated.
9084
9085 \item[save\_cache\_luc(<filename>, <data>{[, <serialized\_data>]})]
9086
9087 Same as \texttt{save\_cache}, except that only the binary cache is updated.
9088 The third argument <serialized\_data> is not usually given.
9089 But if this is given, it is treated as a string representation of <data>.
9090
9091 \item[load\_cache(<filename>, <outdate>)]
9092 Load the cache <filename>.
9093 <outdate> is a function which takes one argument (the contents of the cache),
9094 and its return value is whether the cache is outdated.
9095
9096 \texttt{load\_cache} first tries to
9097 read the binary cache <filename>\texttt{.\{luc|lub\}}.
9098 If its contents is up-to-date, \texttt{load\_cache} returns the contents.
9099 If the binary cache is not found or
9100 its contents is outdated, \texttt{load\_cache} tries to
9101 read the text form <filename>\texttt{.lua}.
9102 Hence, the return value of \texttt{load\_cache} is non-nil,
9103 if and only if the updated cache is found.
9104 \end{cslist}
9105 %</en>
9106 %<*ja>
9107 \subsection{内部命令}
9108 \LuaTeX-jaにおけるキャッシュ管理は,\texttt{luatexja.base}~(\texttt{ltj-base.lua})に
9109 実装しており,以下の3関数が公開されている.
9110 ここで,<filename>は保存するキャッシュのファイル名を\emph{拡張子なしで}指定する.
9111 \begin{cslist}
9112 \item[save\_cache(<filename>, <data>)]
9113 nilでない<data>をキャッシュ<filename>に保存する.
9114 テキスト形式の<filename>\texttt{.lua}のみならず,
9115 そのバイナリ版も作成/更新される.
9116
9117 \item[save\_cache\_luc(<filename>, <data>{[, <serialized\_data>]})]
9118
9119 \texttt{save\_cache}と同様だが,バイナリキャッシュのみが更新される.
9120 第3引数<serialized\_data>が与えられた場合,それを
9121 <data>の文字列化表現として使用する.
9122 そのため,<serialized\_data>は普通は指定しないことになるだろう.
9123
9124 \item[load\_cache(<filename>, <outdate>)]
9125 キャッシュ<filename>を読み込む.
9126 <outdate>は1引数(キャッシュの中身)をとる関数であり,
9127 その戻り値は「キャッシュの更新が必要」かどうかを示すブール値でないといけない.
9128
9129 \texttt{load\_cache}は,まずバイナリキャッシュ<filename>\texttt{.\{luc|lub\}}を
9130 読みこむ.もしその内容が「新しい」,つまり<outdate>の評価結果が \texttt{false} なら
9131 \texttt{load\_cache}はこのバイナリキャッシュの中身を返す.
9132 もしバイナリキャッシュが見つからなかったか,「古すぎる」ならばテキスト版
9133              <filename>\texttt{.lua}を読み込み,その値を返す.
9134
9135 以上より,\texttt{load\_cache}自体がnilでない値を返すのは,ちょうど「新しい」キャッシュが
9136 見つかった場合である.
9137 \end{cslist}
9138 %</ja>
9139
9140
9141 %<*ja>
9142 \section{縦組の実装}
9143 \label{sec-dir-imp}
9144 \ref{sec-direction}章の最初でも述べたように,
9145 \LuaTeX-jaは横組(\texttt{TLT})で組んだボックスを回転させる方式で
9146 縦組を実装している.
9147
9148 \LuaTeX-jaにおける縦組の実装は
9149 \pTeX における実装(\cite{ptexdoc,ptextug})をベースにしている.
9150
9151 \subsection{direction~whatsit}
9152 \textit{direction}~whatsitとは,\textit{direction}という特定の \verb+user_id+ を持つ
9153 whatsitのことであり,以下のタイミングで作られる.
9154 \begin{itemize}
9155  \item 組方向を \cs{tate} 等で変更したとき.
9156  \item \cs{hbox}, \cs{vbox}, \cs{vtop} による明示的なボックスの開始時.\\
9157 \verb+\hbox{}+, \verb+\vbox{}+ といった,
9158 \begin{itemize}
9159  \item \cs{tate} 等によりボックス内部の組方向を変更していない
9160  \item ボックスの中身のリストが空である
9161 \end{itemize}
9162 場合は,\LuaTeX の \verb+hpack_filter+, \verb+vpack_filter+ といった
9163 callbackに処理が回らない.そこで,\LuaTeX-ja では,\cs{everyhbox}, \cs{everyvbox} を利用す
9164        ることで各ボックスの先頭に確実に追加するようにしている\footnote{%
9165   問題は \cs{hbox to 25pt\{\}} という状況である.実際のこのボックスの中身は空でない(少な
9166        くともdirection whatsitがある)ため,何も対策をしなければhpack時にUnderfill警告が発
9167        生してしまうことになる.\LuaTeX-jaではそうならないように「\cs{hbadness},
9168        \cs{vbadness} を一時的に10000に変更し,hpack, vpack後に元の値に戻す」処理を行ってい
9169        る.
9170 }.
9171  \item \cs{vsplit}によってvboxを分割した時の「残り」の先頭.
9172  \item \LuaTeX-ja読み込み前に作成したボックスの寸法を \cs{ltjsetwd} 等によって変更した時.
9173  \item \cs{insert} によるinsertionでは,中身の先頭に\textit{direction}~whatsitは作られず,
9174 その代わりに中身の各ボックス・罫線の直前に作られる\footnote{%
9175  これは,ページ分割の過程でinsertionが分割される時,「現在のページで出力される部分」が空と
9176        なることがあることによる.先頭にwhatsitを置くと,最悪でも「現在のページにwhatsitが
9177        残る」ことになってしまう.}.
9178 \end{itemize}
9179 なお,\verb+\vtop{...}+ の場合は,先頭にdirection whatsitを置くと
9180 ボックスの高さが常に0\,ptになるという問題が発生する.そのため,この場合に限っては
9181 vpack時にdirection whatsitをリストの2番目に移動させている.
9182
9183 direction whatsitはあくまでも組方向処理のための補助的なノードであるので,
9184 \cs{unhbox}, \cs{unhcopy} によってボックスの中身が展開される時には展開直前に削除される.
9185 これは
9186 \begin{lstlisting}
9187  % yoko direction
9188 \setbox0=\hbox{\tate B}
9189 \noindent % 水平モードに入る.この時点でのリストの中身は空
9190 \unhbox0 A
9191 \end{lstlisting}
9192 といった場合に,段落が縦組で組まれたり,あるいは
9193 \begin{lstlisting}
9194 \setbox0=\hbox{}
9195 \leavevmode \hbox{A}\unhbox0
9196 \setbox1=\lastbox % \box1 はどうなる?
9197 \end{lstlisting}
9198 で \cs{box1} が \cs{hbox\{A\}} でなく空になってしまうことを防ぐためである.
9199
9200
9201 \subsection{\textit{dir\_box}}
9202 縦中横など異方向のボックスを配置する場合に,周囲の組方向と大きさを整合させるため,
9203 \LuaTeX-jaでは \verb+\ltj@dir+ が128以降の\textit{hlist\_node}, \textit{vlist\_node}を
9204 用いる.これらは\pTeX における\textit{dir\_node}の役割と同じ果たしており,
9205 この文章中では\textit{dir\_box}と呼称する.
9206
9207 \subsubsection{異方向のボックスの整合}
9208 \textit{dir\_box}の第一の使用目的は,異方向のボックスの大きさを整合させることである.
9209 例えば,
9210 \begin{lstlisting}
9211  % yoko direction
9212 平成\hbox{\tate 26}年
9213 \end{lstlisting}
9214 は段落中で
9215 \[
9216  \xymatrix{
9217    {}\Node{glyph}{`平'}\ar[r]&{}\Node{glyph}{`成'}\ar[r]&
9218    {}\HNode{hbox}{10.00003}{3.02779}{0.0}\ar[r]\ar[d]^{\text{中身}}&{}\Node{glyph}{`年'}\\
9219    &&{}\Node{whatsit}{\cs{tate}}\ar[r]&{}\Node{glyph}{`2'}\ar[r]&{}\Node{glyph}{`6'}
9220  }
9221 \]
9222 というリストを作る.その後,この段落が終了したときに,
9223 \LuaTeX-jaの\textbf{JAglue}挿入処理が行われ
9224 \[
9225  \xymatrix{
9226    {}\Node{glyph}{`平'}\ar[r]
9227   &{}\textcolor{blue}{\Node{glue}{\Param{xkanjiskip}}}\ar[r]
9228   &{}\Node{glyph}{`成'}\ar[r]
9229   &{}\textcolor{blue}{\Node{penalty}{0}}
9230     \ar`r[d] `[l] `[ddll] `[dl] [dl]
9231   \\
9232   &&{}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{yoko})}{3.02779}{10.00003}{0.0}}\ar[r]\ar[d]^{\text{中身}}
9233   &{}\textcolor{blue}{\Node{penalty}{0}}\ar[r]
9234   &{}\Node{glyph}{`年'}\\
9235   &&{}\HNode{hbox}{10.00003}{3.02779}{0.0}\ar[d]^{\text{中身}}\\
9236   &&{}\Node{whatsit}{\cs{tate}}\ar[r]&{}\Node{glyph}{`2'}\ar[r]&{}\Node{glyph}{`6'}
9237  }
9238 \]
9239 のようになる(青字は\textbf{JAglue},赤字が整合処理のための\textit{dir\_box}である).
9240 \TeX の \cs{showbox} 形式で書けば
9241
9242 \medskip{\narrowbaselines\ttfamily\obeylines\parindent0pt
9243 \catcode`\@=0 @catcode`@\=12
9244 .\tenmin 平
9245 @textcolor{blue}{.\glue 0.0 plus 0.4 minus 0.4}
9246 .\tenmin 成
9247 @textcolor{blue}{.\penalty 0}
9248 @textcolor{red}{.\hbox(10.00003+0.0)x3.02779, direction TLT}
9249 ..\hbox(3.02779+0.0)x10.00003, direction TLT
9250 ...\whatsit4=[]
9251 ...\tenrm 2
9252 ...\tenrm 6
9253 @textcolor{blue}{.\penalty 0}
9254 .\tenmin 年
9255 }\medskip
9256
9257 \noindent である.
9258
9259 なお,\cs{raise},~\cs{lower}, \cs{moveleft},~\cs{moveright} といったボックス移動命令では.
9260 移動を正しく表現するために段落やボックスの途中でも異方向のボックスは\textit{dir\_box}にカ
9261 プセル化している.
9262 例えば
9263 \begin{lstlisting}
9264  % yoko direction
9265 平成\raise1pt\hbox{\tate 26}年\showlists
9266 \end{lstlisting}
9267 は以下のような結果を得る.
9268
9269 \medskip{\narrowbaselines\ttfamily\obeylines\parindent0pt
9270 \catcode`\@=0 @catcode`@\=12
9271 (前略)
9272 \tenrm 平
9273 \tenrm 成
9274 @textcolor{red}{\hbox(10.00003+0.0)x3.02779, shifted -1.0, direction TLT}
9275 .\hbox(3.02779+0.0)x10.00003, direction TLT
9276 ..\whatsit4=[]
9277 ..\tenrm 2
9278 ..\tenrm 6
9279 \tenrm 年
9280 }\medskip
9281
9282 また,メインの垂直リストに異方向のボックスが追加される場合にも同様に即座に
9283 \textit{dir\_box}にカプセル化している.ページ分割のタイミングを正
9284 しく\TeX が判断するためである.
9285 \cs{lastbox} によるボックスの取得では,\textit{dir\_box}は削除される.
9286
9287 \subsubsection{異方向のボックス寸法の格納}
9288 第二の使用目的は,現在の組方向がボックス本来の組方向とは異なる状況で,
9289 \cs{ltjsetwd} によってボックス寸法を設定されたことを記録することである.
9290
9291 例えば
9292 \begin{lstlisting}[numbers=left]
9293 \setbox0=\hbox{\vrule width 10pt height 5pt depth 2pt}
9294 \setbox1=\hbox{\tate\ltjsetwd0=20pt}
9295 \wd0=9pt
9296 \setbox1=\hbox{\dtou\ltjsetwd0=20pt}
9297 \setbox0=\hbox{\dtou a\box0}
9298 \end{lstlisting}
9299 というコードを考える.1行目で \cs{box0} には横組の
9300 幅10\,pt,高さ5\,pt,深さ2\,ptのボックスが代入される.
9301 よって,
9302 \begin{itemize}
9303  \item 縦組下では \cs{box0} は幅7\,pt,高さ・深さ5\,ptのボックスとして扱われる.
9304  \item \cs{dtou} 下では \cs{box0} は幅7\,pt,高さ10\,pt,深さ0\,ptのボックスとして扱われる.
9305 \end{itemize}
9306 このとき,\cs{box0} の\emph{中身}は
9307 \[
9308  \xymatrix{
9309    {}\Node{whatsit}{\cs{yoko}}\ar[r]&{}\Node{rule}{}
9310  }
9311 \]
9312 である.
9313
9314 さて,2行目で縦組時の \cs{box0} の幅が20\,ptに設定される.この情報が
9315 direction~whatsit内部のノードリストに,\textit{dir\_box}として格納される:
9316 \[
9317  \xymatrix{
9318    {}\Node{whatsit}{\cs{yoko}}\ar[r]\ar[d]_{\text{中身}}&{}\Node{rule}{}\\
9319    {}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{tate})}{20.0}{5.0}{5.0}}
9320  }
9321 \]
9322
9323 次に,3行目では横組時の,つまり \cs{box0} 本来の組方向での深さが9\,ptに変更される.
9324 このとき,\cs{box0} は
9325 \begin{itemize}
9326  \item 縦組下では寸法代入が既に行われているので,2行目で作成された\textit{dir\_box}の通り
9327        に幅20\,pt,高さ・深さ5\,ptのボックスとして扱われる.
9328  \item \cs{dtou} 下ではまだ寸法代入が行われていないので,
9329 \cs{box0} の寸法変更に追従し,幅7\,pt,高さ9\,pt,深さ0\,ptのボックスとして扱われる.
9330 \end{itemize}
9331
9332 4行目では \cs{dtou} 下での\cs{box0} の幅が20\,ptに設定されるので,2行目と同じように
9333 \[
9334  \xymatrix{
9335    {}\Node{whatsit}{\cs{yoko}}\ar[r]\ar[d]_{\text{中身}}&{}\Node{rule}{}\\
9336    {}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{dtou})}{20.0}{9.0}{0.0}}\ar[r]&
9337    {}\HNode{\textit{dir\_box} (\cs{tate})}{20.0}{5.0}{5.0}
9338  }
9339 \]
9340 と\textit{dir\_box}が作成される.
9341
9342 このように寸法代入によってつくられた\textit{dir\_box}は,前節の整合過程のときに再利用され
9343 る.上記の例でいえば,5行目を実行した後の \cs{box0} の内容は
9344 \[
9345  \xymatrix{
9346    {}\Node{whatsit}{\cs{dtou}}\ar[r]&
9347    {}\Node{glyph}{`a'}\ar[r]&
9348    {}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{dtou})}{20.0}{9.0}{0.0}}\ar[d]_{\text{中身}}\\
9349    &&{}\HNode{hbox}{9.0}{5.0}{2.0}\ar[d]_{\text{中身}}\\
9350    &&{}\Node{whatsit}{\cs{yoko}}\ar[r]&{}\Node{rule}{}
9351  }
9352 \]
9353 のようになる.
9354 %</ja>
9355
9356 \newpage
9357 \begin{thebibliography}{99}
9358   \addcontentsline{toc}{section}{\refname}
9359 \bibitem{texbytopic}
9360 Victor Eijkhout. \newblock \textit{\TeX\ by Topic, A \TeX nician's Reference}, Addison-Wesley, 1992.
9361 \bibitem{listings} C.\ Heinz, B.\ Moses. \newblock The \textsf{Listings} Package.
9362 \bibitem{uptex} Takuji Tanaka. \newblock
9363 upTeX---Unicode version of pTeX with CJK extensions,
9364 TUG 2013, October 2013.
9365 %<ja>\newblock
9366 %<en>\\\null\hfill
9367 \url{http://tug.org/tug2013/slides/TUG2013_upTeX.pdf}
9368 \bibitem{jlisting} Thor Watanabe. \newblock Listings\ -\ MyTeXpert.
9369 %<en>\newblock
9370 %<ja>\\\null\hfill
9371 \url{http://mytexpert.osdn.jp/index.php?Listings}
9372 \bibitem{jlreq}  W3C Japanese Layout Task Force~(ed). \newblock
9373 Requirements for Japanese Text Layout (W3C Working Group Note), 2011, 2012. \newblock
9374 \url{http://www.w3.org/TR/jlreq/}%
9375 %<ja> \\日本語訳の書籍版:W3C日本語組版タスクフォース(編),『W3C技術ノート 日本語組版処理の要件』,東京電機大学出版局,2012.
9376 \bibitem{min10} 乙部厳己.min10フォントについて.\\\null\hfill
9377 \url{http://argent.shinshu-u.ac.jp/~otobe/tex/files/min10.pdf}
9378 \bibitem{x4051} 日本工業規格(Japanese Industrial Standard). JIS~X~4051,
9379 日本語文書の組版方法(Formatting rules for Japanese documents), 1993, 1995, 2004.
9380 \bibitem{ptexdoc} 濱野尚人,田村明史,倉沢良一.\TeX の出版への応用—縦組み機能の組み込み—.
9381 \\\null\hfill\texttt{.../texmf-dist/doc/ptex/base/ptexdoc.pdf}
9382 \bibitem{ptextug} Hisato Hamano. \newblock
9383 \textit{Vertical Typesetting with \TeX}, TUGBoat~\textbf{11}(3), 346--352, 1990.
9384 \bibitem{pdfstd} International Organization for Standardization. \newblock
9385 ISO 32000-1:2008, \textit{Document management -- Portable document format -- Part 1: PDF
9386       1.7}, 2008. \newblock
9387 \\\null\hfill
9388 \url{http://www.iso.org/iso/iso\_catalogue/catalogue_tc/catalogue\_detail.htm?csnumber=51502}
9389 \end{thebibliography}
9390
9391 \end{document}
9392 %</!showexpl>
9393 %<*showexpl>
9394 %%
9395 %% config file for showexpl.sty
9396 %%
9397 %% Copyright The LuaTeX-ja project team, 2012
9398 %%
9399 \ProvidesFile{showexpl.cfg}
9400   [2012/05/20 v0.01 Definitions for the showexpl package (luatexja)]
9401 \lstset{}
9402 \def\SX@Info{}
9403 \endinput
9404 %</*showexpl>