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 version~20150420.0, \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 20150420.0版からは,不安定ながらも\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 By default, \LuaTeX-ja uses Japanese fonts to typeset Greek and Cyrillic letters,
747       and some Unicode symbols such as \P~and~\S. To change this behavior, 
748       put \lstinline!\ltjsetparameter{jacharrange={-2,-3,-8}}! in the preamble.
749       For the detailed description, see Subsection~\ref{ssec-setrange}.
750 %</en>
751 %<*ja>
752 \item 
753 標準では,\LuaTeX-jaはギリシャ文字やキリル文字,それに\P や\S などの記号を和文フォントを使っ
754       て組む.ギリシャ語などを本格的に組むなどこの状況が望ましくない場合,
755       プリアンブルに \lstinline!\ltjsetparameter{jacharrange={-2,-3,-8}}! を入れると
756       上記種類の文字は欧文フォントを用いて組まれるようになる.
757       詳しい説明は\ref{ssec-setrange}節を参照してほしい.
758 %</ja>
759 %<*en>
760 \item \LuaTeX-ja is very slower than \pTeX.
761 Generally speaking, LuaJIT\TeX\ processes \LuaTeX-ja
762 about 30\% faster than \LuaTeX, but not always.
763 %</en>
764 %<*ja>
765 \item \LuaTeX-jaは動作が\pTeX に比べて非常に遅い.
766 コードを調整して徐々に速くしているが,まだ満足できる速度ではない.
767 LuaJIT\TeX を用いると\LuaTeX のだいたい1.3倍の速度で動くようであるが,
768 IPA mj明朝などの大きいフォントを用いた場合には\LuaTeX よりも遅くなることもある.
769 %</ja>
770
771 \item%
772 %<*en>
773 \textbf{(Outdated) note for MiK\TeX\ users}\quad
774 \LuaTeX-ja requires that several CMap files%
775 \footnote{\texttt{UniJIS2004-UTF32-\{H,V\}} and \texttt{Adobe-Japan1-UCS2}.}
776 must be found from \LuaTeX.
777 Strictly speaking, those CMaps are needed
778 only in the first run of \LuaTeX-ja after installing or updating.
779 But it seems that MiK\TeX\ does not satisfy this condition,
780 so you will encounter an error like the following:
781 %</en>
782 %<*ja>
783 \LuaTeX-jaが動作するためには,\emph{導入・更新後の初回起動時に}
784 \texttt{UniJIS2004-UTF32-\{H,V\}}, \texttt{Adobe-Japan1-UCS2}という3つのCMapが
785 \LuaTeX によって見つけられることが必要である.
786 しかし古いバージョンのMiK\TeX ではそのようになっていないので,次のエラーが発生するだろう:
787 %</ja>
788 \begin{lstlisting}
789 ! LuaTeX error ...iles (x86)/MiKTeX 2.9/tex/luatex/luatexja/ltj-rmlgbm.lua
790 bad argument #1 to 'open' (string expected, got nil)
791 \end{lstlisting}
792
793 %<*en>
794 If so, please execute a batch file which is written on
795 \href{https://osdn.jp/projects/luatex-ja/wiki/FrontPage%28en%29}{ the Project Wiki (English)}.
796 This batch file creates a temporary directory, copy CMaps in it,
797 run a test file which loads \LuaTeX-ja in this directory, 
798 and finally delete the temporary directory.
799 %</en>
800 %<*ja>
801 そのような場合には,
802 \href{https://osdn.jp/projects/luatex-ja/wiki/FrontPage%28en%29}{%
803   プロジェクトWiki英語版トップページ}中に書かれているバッチファイルを
804 実行して欲しい.このバッチファイルは,作業用ディレクトリにCMap達を
805 コピーし,その中で\LuaTeX-ja の初回起動を行い,作業用ディレクトリを消す作業をしている.
806 %</ja>
807
808 \end{itemize}
809
810 %<en>\subsection{Using in plain \TeX}
811 %<ja>\subsection{plain \TeX で使う}
812 \label{ssec-plain}
813
814 %<en>To use \LuaTeX-ja in plain \TeX, simply put the following at the beginning of the document:
815 %<ja>\LuaTeX-jaを plain \TeX で使うためには,単に次の行をソースファイルの冒頭に追加すればよい:
816 \begin{lstlisting}
817 \input luatexja.sty
818 \end{lstlisting}
819 %<en>This does minimal settings (like \texttt{ptex.tex}) for typesetting Japanese documents:
820 %<ja>これで(\texttt{ptex.tex}のように)日本語組版のための最低限の設定がなされる:
821
822 \begin{itemize}
823 %<*en>
824 \item The following 12~Japanese fonts are preloaded:
825 \begin{center}\small
826 \begin{tabular}{cccccc}
827 \toprule
828 \textbf{direction}&
829 \textbf{classification}&\textbf{font name}&\bf ``10\,pt''&\bf``7\,pt''&\bf``5\,pt''\\\midrule
830 \smash{\raisebox{-1ex}{\emph{yoko} (horizontal)}}&
831 \emph{mincho}&IPAex Mincho&\cs{tenmin}&\cs{sevenmin}&\cs{fivemin}\\
832 &\emph{gothic}&IPAex Gothic&\cs{tengt} &\cs{sevengt} &\cs{fivegt}\\
833 \midrule
834 \smash{\raisebox{-1ex}{\emph{tate} (vertical)}}&
835 \emph{mincho}&IPAex Mincho&\cs{tentmin}&\cs{seventmin}&\cs{fivetmin}\\
836 &\emph{gothic}&IPAex Gothic&\cs{tentgt} &\cs{seventgt} &\cs{fivetgt}\\
837 \bottomrule
838 \end{tabular}
839 \end{center}
840 %</en>
841 %<*ja>
842 \item 以下の12個の和文フォントが定義される:
843 \begin{center}\small
844 \begin{tabular}{cccccc}
845 \toprule
846 \emph{組方向}&\emph{字体}&\emph{フォント名}&\bf ``10\,pt''&\bf``7\,pt''&\bf``5\,pt''\\\midrule
847 \smash{\raisebox{-1ex}{横組}}&
848 明朝体&IPAex明朝&\cs{tenmin}&\cs{sevenmin}&\cs{fivemin}\\
849 &ゴシック体&IPAexゴシック&\cs{tengt} &\cs{sevengt} &\cs{fivegt}\\
850 \midrule
851 \smash{\raisebox{-1ex}{縦組}}&
852 明朝体&IPAex明朝&\cs{tentmin}&\cs{seventmin}&\cs{fivetmin}\\
853 &ゴシック体&IPAexゴシック&\cs{tentgt} &\cs{seventgt} &\cs{fivetgt}\\
854 \bottomrule
855 \end{tabular}
856 \end{center}
857 %</ja>
858 \begin{itemize}
859 %<*en>
860 \item With \texttt{luatexja.cfg}, one can use other fonts
861 as ``default'' Japanese fonts (Subsection~\ref{ssec-cfg}).
862 %</en>
863 %<*ja>
864 \item \texttt{luatexja.cfg} を用いることによって,標準和文フォントを
865 IPAexフォントから別のフォントに置き換えることができる.\ref{ssec-cfg}節を参照.
866 %</ja>
867
868 %<*en>
869 \item A character in an alphabetic font is generally smaller than a
870       Japanese font in the same size. So actual size specification of
871       these Japanese fonts is in fact smaller than that of alphabetic
872       fonts, namely scaled by 0.962216.
873 %</en>
874 %<*ja>
875 \item 欧文フォントの文字は和文フォントの文字よりも,同じ文字サイズでも
876       一般に小さくデザインされている.そこで,標準ではこれらの和文フォントの実際のサイズは指定された値よりも
877       小さくなるように設定されており,具体的には指定の0.962216倍にスケールされる.
878       この0.962216という数値も,\pTeX におけるスケーリングを踏襲した値である.
879 %</ja>
880 \end{itemize}
881
882 %<*en>
883 \item The amount of glue that are inserted between a \textbf{JAchar} and
884       an \textbf{ALchar} (the parameter \Param{xkanjiskip}) is set to
885 %</en>
886 %<*ja>
887 \item \textbf{JAchar}と\textbf{ALchar}の間に入るグルー(\Param{xkanjiskip})の
888       量は次のように設定されている:
889 %</ja>
890 \[
891  (0.25\cdot 0.962216\cdot 10\,\mathrm{pt})^{+1\,\text{pt}}_{-1\,\text{pt}}
892  = 2.40554\,\mathrm{pt}^{+1\,\text{pt}}_{-1\,\text{pt}}.
893 \]
894 \end{itemize}
895
896 %<en>\subsection{Using in \LaTeX}
897 %<ja>\subsection{\LaTeX で使う}
898 \label{ssec-ltx}
899
900 %<*en>
901 Using in \LaTeXe\ is basically same. To set up the minimal environment
902 for Japanese, you only have to load \texttt{luatexja.sty}:
903 %</en>
904 %<*ja>
905 \LaTeXe を用いる場合も基本的には同じである.日本語組版のための最低限の環境を
906 設定するためには,\texttt{luatexja.sty}を読み込むだけでよい:
907 %</ja>
908 \begin{lstlisting}
909 \usepackage{luatexja}
910 \end{lstlisting}
911 %<*en>
912 It also does minimal settings (counterparts in \pLaTeX\ are \texttt{%
913 plfonts.dtx} and \texttt{pldefs.ltx}):
914 %</en>
915 %<*ja>
916 これで\pLaTeX の\texttt{plfonts.dtx}と\texttt{pldefs.ltx}に相当する最低限の設定が
917 なされる:
918 %</ja>
919
920 \begin{itemize}
921 %<*en>
922 \item Font encodings for Japanese fonts is \texttt{JY3}~(for horizontal direction) and
923 \texttt{JT3}~(for vertical direction).
924 %</en>
925 %<*ja>
926 \item 和文フォントのエンコーディングとしては,横組用には \texttt{JY3},縦組用には\
927 \texttt{JT3}が用いられる.
928 %</ja>
929
930 %<*en>
931 \item Traditionally, Japanese documents use two typeface categories: \emph{mincho}~(明朝体) and
932  \emph{gothic}~(\textgt{ゴシック体}). \emph{mincho} is used in the main text, while \emph{gothic}
933       is used in the headings or for emphasis.
934 \begin{center}\small
935 \begin{tabular}{lllc}
936 \toprule
937 \textbf{classification}&&&\textbf{family name}\\\midrule
938 \emph{mincho} (明朝体)&\verb+\textmc{...}+&\verb+{\mcfamily ...}+&\cs{mcdefault}\\
939 \emph{gothic} (\textgt{ゴシック体})&\verb+\textgt{...}+&\verb+{\gtfamily ...}+&\cs{gtdefault}\\
940 \bottomrule
941 \end{tabular}
942 \end{center}
943 \item
944 By default, the following fonts are used for \emph{mincho} and \emph{gothic}:
945 \begin{center}\small
946 \begin{tabular}{ccccc}
947 \toprule
948 \textbf{classification}&\textbf{family}&\cs{mdseries}&\cs{bfseries}&\textbf{scale}\\\midrule
949 \emph{mincho} (明朝体)&\tt mc&IPAex Mincho&IPAex Gothic&0.962216\\
950 \emph{gothic} (\textgt{ゴシック体})&\tt gt&IPAex Gothic&IPAex Gothic&0.962216\\
951 \bottomrule
952 \end{tabular}
953 \end{center}
954 Note that the bold series in both family are same as the medium series of \emph{gothic}
955      family. There is no italic nor slanted shape for
956       these \texttt{mc}~and~\texttt{gt}.
957 %</en>
958 %<*ja>
959 \item \pLaTeX と同様に,標準では「明朝体」「ゴシック体」の2種類を用いる:
960 \begin{center}\small
961 \begin{tabular}{cllc}
962 \toprule
963 \emph{字体}&&&\emph{ファミリ名}\\\midrule
964 明朝体&\verb+\textmc{...}+&\verb+{\mcfamily ...}+&\cs{mcdefault}\\
965 \textgt{ゴシック体}&\verb+\textgt{...}+&\verb+{\gtfamily ...}+&\cs{gtdefault}\\
966 \bottomrule
967 \end{tabular}
968 \end{center}
969 \item 標準では,次のフォントファミリが用いられる:
970 \begin{center}\small
971 \begin{tabular}{ccccc}
972 \toprule
973 \emph{字体}&\emph{ファミリ}&\cs{mdseries}&\cs{bfseries}&\emph{スケール}\\\midrule
974 明朝体&\tt mc&IPAex明朝&IPAexゴシック&0.962216\\
975 ゴシック体&\tt gt&IPAexゴシック&IPAexゴシック&0.962216\\
976 \bottomrule
977 \end{tabular}
978 \end{center}
979 どちらのファミリにおいても,そのboldシリーズで使われるフォントは
980 ゴシック体のmediumシリーズで使われるフォントと同じであることに注意.
981 また,どちらのファミリでもイタリック体・スラント体は定義されない.
982 %</ja>
983
984 %<en>\item Japanese characters in math mode are typeset by the font family \texttt{mc}.
985 %<ja>\item 数式モード中の和文文字は明朝体(\texttt{mc})で出力される.
986
987 %<*en>
988 \item If you use the \Pkg{beamer} class with the default font theme (which uses sans serif
989       fonts) and with \LuaTeX-ja, you might want to change default Japanese fonts to
990       \emph{gothic} family. The following line  changes  the default Japanese font family
991       to \emph{gothic}:
992 %</en>
993 %<*ja>
994 \item \Pkg{beamer}クラスを既定のフォント設定で使う場合,既定欧文フォントがサンセリフなの
995       で,既定和文フォントもゴシック体にしたいと思うかもしれない.その場合はプリアンブルに
996 次を書けばよい:
997 %</ja>
998 \begin{lstlisting}
999  \renewcommand{\kanjifamilydefault}{\gtdefault}
1000 \end{lstlisting}
1001
1002
1003 \end{itemize}
1004
1005 %<*en>
1006 However, above settings are not sufficient for Japanese-based
1007 documents. To typeset Japanese-based documents, you are better to use
1008 class files other than \texttt{article.cls}, \texttt{book.cls}, and so on.  At
1009 the present, we have the counterparts of \Pkg{jclasses} (standard
1010 classes in \pLaTeX) and \Pkg{jsclasses} (classes by Haruhiko
1011 Okumura), namely, \Pkg{ltjclasses}\footnote{%
1012   \texttt{ltjarticle.cls},~\texttt{ltjbook.cls}, \texttt{ltjreport.cls},
1013   \texttt{ltjtarticle.cls}, \texttt{ltjtbook.cls}, \texttt{ltjtreport.cls}.
1014   The latter \texttt{ltjt*.cls} are for vertically writtened Japanese documents.
1015 } and \Pkg{ltjsclasses}\footnote{%
1016   \texttt{ltjsarticle.cls},~\texttt{ltjsbook.cls},~\texttt{ltjskiyou.cls}.}.
1017 %</en>
1018 %<*ja>
1019 しかしながら,上記の設定は日本語の文書にとって十分とは言えない.
1020 日本語文書を組版するためには,\texttt{article.cls}, \texttt{book.cls}といった
1021 欧文用のクラスファイルではなく,和文用のクラスファイルを用いた方がよい.
1022 現時点では,\Pkg{jclasses}(\pLaTeX の標準クラス)と\Pkg{jsclasses}
1023 (奥村晴彦氏による「\pLaTeXe 新ドキュメントクラス」)に対応するものとして,
1024 \Pkg{ltjclasses}\footnote{%
1025   横組用は \texttt{ltjarticle.cls},~\texttt{ltjbook.cls}, \texttt{ltjreport.cls} であり,
1026   縦組用は \texttt{ltjtarticle.cls}, \texttt{ltjtbook.cls}, \texttt{ltjtreport.cls} である.
1027 },
1028 \Pkg{ltjsclasses}\footnote{%
1029   \texttt{ltjsarticle.cls},~\texttt{ltjsbook.cls},~\texttt{ltjskiyou.cls}.}%
1030 がそれぞれ用意されている.
1031 %</ja>
1032
1033 %<*ja>
1034 \paragraph{脚注とボトムフロートの出力順序}
1035 オリジナルの\LaTeX では脚注がボトムフロートの上に来るようになっており,
1036 \pLaTeX では脚注がボトムフロートの下に来るように変更されている.
1037
1038 \LuaTeX-jaでは「欧文クラスの中にちょっとだけ日本語を入れる」という利用も考慮し,
1039 脚注とボトムフロートの順序は\LaTeX 通りとした.もし\pLaTeX の出力順序が好みならば,
1040 \Pkg{stfloats}パッケージを利用して
1041 \begin{lstlisting}
1042  \usepackage{stfloats}\fnbelowfloat
1043 \end{lstlisting}
1044 のようにすればよい.\Pkg{footmisc}パッケージを \texttt{bottom}\ オプションを指定して
1045 読み込むという方法もあるが,それだとボトムフロートと脚注の間が開いてしまう.
1046 %</ja>
1047 %%% ↑は英訳しない
1048
1049 %<*en>
1050 \paragraph{\Pkg{geometry} package and classes for vertical writing}
1051 It is well-known that the \Pkg{geometry} package produces the following error, when classes for
1052 vertical writing is used:
1053 %</en>
1054 %<*ja>
1055 \paragraph{縦組での\Pkg{geometry}パッケージ}
1056 \pLaTeX の縦組用標準クラスファイルでは\Pkg{geometry}パッケージを利用することは出来ず,
1057 %</ja>
1058 \begin{lstlisting}
1059 ! Incompatible direction list can't be unboxed.
1060 \@begindvi ->\unvbox \@begindvibox
1061                                    \global \let \@begindvi \@empty
1062 \end{lstlisting}
1063 %<*en>
1064 Now, \LuaTeX-ja automatically applies the patch \Pkg{lltjp-geometry} to the
1065 \Pkg{geometry} package, when the direction of the document is \emph{tate} (vertical
1066 writing).
1067 This patch \Pkg{lltjp-geometry} also can be used in \pLaTeX; for the detail, please refer
1068 \url{lltjp-geometry.pdf}~(Japanese).
1069 %</en>
1070 %<*ja>
1071 というようなエラーが発生することが知られている.
1072 \LuaTeX-jaでは, \texttt{ltjtarticle.cls} といった縦組クラスの下でも
1073 \Pkg{geometry}パッケージが利用できるようにパッチ\Pkg{lltjp-geometry}パッケージを自動的に当てている.
1074
1075 なお,\Pkg{lltjp-geometry}パッケージは\pTeX 系列でも明示的に読み込むことによって
1076 使用可能である.詳細や注意事項は \url{lltjp-geometry.pdf} を参照のこと.
1077 %</ja>
1078
1079
1080 %<en>\section{Changing Fonts}
1081 %<ja>\section{フォントの変更}
1082
1083 \subsection{plain \TeX~and~\LaTeXe}
1084 \label{ssec-chgfnt}
1085
1086 \paragraph{plain \TeX}
1087 %<*en>
1088 To change Japanese fonts in plain \TeX, you must use the command
1089 \cs{jfont}~and~\cs{tfont}. So please see Subsection~\ref{ssec-jfont}.
1090 %</en>
1091 %<*ja>
1092 plain \TeX で和文フォントを変更するためには,
1093 \pTeX のように \cs{jfont} 命令や \cs{tfont} 命令を直接用いる.
1094 \ref{ssec-jfont}節を参照.
1095 %</ja>
1096
1097 \paragraph{\LaTeXe\ (NFSS2)}
1098 %<*en>
1099 For \LaTeXe, \LuaTeX-ja adopted most of the font selection system of \pLaTeXe\ (in \texttt{plfonts.dtx}).
1100 %</en>
1101 %<*ja>
1102 \LaTeX で用いる際には,\pLaTeXe\ (\texttt{plfonts.dtx})用のフォント選択機構の大部分を流用している.
1103 %</ja>
1104 \begin{itemize}
1105 %<*en>
1106 \item Commands \cs{fontfamily}, \cs{fontseries},
1107       \cs{fontshape}, and \cs{selectfont} can be used to change
1108       attributes of Japanese fonts.
1109 %</en>
1110 %<*ja>
1111 \item 和文フォントの属性を変更するには,\cs{fontfamily}, \cs{fontseries}, \cs{fontshape},
1112       そしてそれらを反映させるために \cs{selectfont} を用いればよい.
1113 %</ja>
1114
1115 %<*en>
1116 \begin{center}\small
1117 \begin{tabular}{cccccc}
1118 \toprule
1119 &\textbf{encoding}&\textbf{family}&\textbf{series}&\textbf{shape}&\textbf{selection}\\\midrule
1120 alphabetic fonts
1121 &\cs{romanencoding}&\cs{romanfamily}&\cs{romanseries}&\cs{romanshape}
1122 &\cs{useroman}\\
1123 Japanese fonts
1124 &\cs{kanjiencoding}&\cs{kanjifamily}&\cs{kanjiseries}&\cs{kanjishape}
1125 &\cs{usekanji}\\
1126 both&---&--&\cs{fontseries}&\cs{fontshape}&---\\
1127 auto select&\cs{fontencoding}&\cs{fontfamily}&---&---&\cs{usefont}\\
1128 \bottomrule
1129 \end{tabular}
1130 \end{center}
1131 %</en>
1132 %<*ja>
1133 \begin{center}\small
1134 \begin{tabular}{cccccc}
1135 \toprule
1136 &\emph{エンコーディング}&\emph{ファミリ}&\emph{シリーズ}&\emph{シェープ}&\emph{選択}\\\midrule
1137 欧文
1138 &\cs{romanencoding}&\cs{romanfamily}&\cs{romanseries}&\cs{romanshape}
1139 &\cs{useroman}\\
1140 和文
1141 &\cs{kanjiencoding}&\cs{kanjifamily}&\cs{kanjiseries}&\cs{kanjishape}
1142 &\cs{usekanji}\\
1143 両方&---&--&\cs{fontseries}&\cs{fontshape}&---\\
1144 自動選択&\cs{fontencoding}&\cs{fontfamily}&---&---&\cs{usefont}\\
1145 \bottomrule
1146 \end{tabular}
1147 \end{center}
1148 %</ja>
1149
1150 %<*en>
1151       \verb+\fontencoding{+<encoding>\verb+}+ changes the encoding of alphabetic fonts
1152       or Japanese fonts depending on the argument. For example,
1153       \verb+\fontencoding{JY3}+ changes the encoding of Japanese fonts to
1154       \texttt{JY3}, and \verb+\fontencoding{T1}+ changes the encoding of
1155       alphabetic fonts to \texttt{T1}.
1156       \cs{fontfamily} also changes the current Japanese font family,
1157       the current alphabetic font family, \emph{or both}.
1158       For the detail, see Subsection~\ref{ssec-nfsspat}.
1159 %</en>
1160 %<*ja>
1161       ここで,\verb+\fontencoding{+<encoding>\verb+}+ は,引数により和文側か欧文
1162       側かのどちらかのエンコーディングを変更する.例えば,
1163       \verb+\fontencoding{JY3}+ は和文フォントのエンコーディングを
1164       \texttt{JY3}に変更し,\verb+\fontencoding{T1}+ は欧文フォント側を
1165       \texttt{T1}へと変更する.\cs{fontfamily} も引数により和文側,欧文
1166       側,\emph{あるいは両方}のフォントファミリを変更する.詳細は
1167       \ref{ssec-nfsspat}節を参照すること.
1168 %</ja>
1169
1170 %<*en>
1171 \item For defining a Japanese font family, use
1172       \cs{DeclareKanjiFamily} instead of
1173       \cs{DeclareFontFamily}. However, in the present implementation,
1174       using \cs{DeclareFontFamily} doesn't cause any problem.
1175 \item Defining a Japanese font shape can be done by usual \cs{DeclareFontShape}:
1176 %</en>
1177 %<*ja>
1178 \item 和文フォントファミリの定義には \cs{DeclareFontFamily} の
1179       代わりに \cs{DeclareKanjiFamily} を用いる.しかし,現在の
1180       実装では \cs{DeclareFontFamily} を用いても問題は生じない.
1181 \item 和文フォントのシェイプを定義するには,通常の \cs{DeclareFontShape} を使えば良い:
1182 %</ja>
1183 \begin{lstlisting}
1184 \DeclareFontShape{JY3}{mc}{bx}{n}{<-> s*KozMinPr6N-Bold:jfm=ujis;-kern}{}
1185     % Kozuka Mincho Pr6N Bold
1186 \end{lstlisting}
1187 %<*ja>
1188 仮名書体を使う場合など,複数の和文フォントを組み合わせて使いたい場合は
1189 \ref{ssec-altfont}節の \cs{ltjdeclarealtfont} と,その\LaTeX 版の\
1190 \cs{DeclareAlternateKanjiFont}(\ref{ssec-nfsspat}節)を参照せよ.
1191 %</ja>
1192
1193 \end{itemize}
1194
1195 %<*en>
1196 \paragraph{Remark: Japanese characters in math mode}
1197 Since \pTeX\ supports Japanese characters in math mode, there are
1198 sources like the following:
1199 %</en>
1200 %<*ja>
1201 \paragraph{注意:数式モード中の和文文字}
1202 \pTeX では,特に何もしないでも数式中に和文文字を記述することができた.そのため,
1203 以下のようなソースが見られた:
1204 %</ja>
1205
1206 \begin{LTXexample}
1207 $f_{高温}$~($f_{\text{high temperature}}$).
1208 \[ y=(x-1)^2+2\quad よって\quad y>0 \]
1209 $5\in 素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
1210 \end{LTXexample}
1211 %<*en>
1212 We (the project members of \LuaTeX-ja) think that using
1213 Japanese characters in math mode are allowed if and only if these are used as identifiers.
1214 In this point of view,
1215 %</en>
1216 %<*ja>
1217 \LuaTeX-jaプロジェクトでは,数式モード中での和文文字はそれらが識別子として用いられる
1218 ときのみ許されると考えている.
1219 この観点から,
1220 %</ja>
1221
1222 \begin{itemize}
1223 %<*en>
1224 \item The lines 1~and~2 above are not correct, since ``高温'' in above is used as a textual label, and
1225 ``よって'' is used as a conjunction.
1226 %</en>
1227 %<*ja>
1228 \item 上記数式のうち1, 2行目は正しくない.なぜならば「高温」が意味のあるラベルと
1229       して,「よって」が接続詞として用いられているからである.
1230 %</ja>
1231 %<en>\item However, the line~3 is correct, since ``素'' is used as an identifier.
1232 %<ja>\item しかしながら,3行目は「素」が単なる識別子として用いられているので正しい.
1233 \end{itemize}
1234 %<en>Hence, in our opinion, the above input should be corrected as:
1235 %<ja>したがって,\LuaTeX-jaプロジェクトの意見としては,上記の入力は次のように直されるべきである:
1236 \begin{LTXexample}
1237 $f_{\text{高温}}$~%
1238 ($f_{\text{high temperature}}$).
1239 \[ y=(x-1)^2+2\quad
1240   \mathrel{\text{よって}}\quad y>0 \]
1241 $5\in 素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
1242 \end{LTXexample}
1243 %<*en>
1244 We also believe that using Japanese characters as identifiers is rare,
1245 hence we don't describe how to change Japanese fonts in math mode in
1246 this chapter. For the method, please see Subsection~\ref{ssec-math}.
1247 %</en>
1248 %<*ja>
1249 また\LuaTeX-jaプロジェクトでは,和文文字が識別子として用いられることはほとんどない
1250 と考えており,したがってこの節では数式モード中の和文フォントを変更する方法については
1251 記述しない.この方法については\ref{ssec-math}節を参照のこと.
1252 %</ja>
1253
1254
1255 \subsection{fontspec}
1256 \label{ssec-fontspec}
1257 %<*en>
1258 To coexist with the \Pkg{fontspec} package, it is needed to load
1259 the \Pkg{luatexja-fontspec} package in the preamble, as follows:
1260 \begin{quote}
1261 \ttfamily \textbackslash usepackage[<options>]\{luatexja-fontspec\}
1262 \end{quote}
1263 This \Pkg{luatexja-fontspec} package
1264 automatically loads \Pkg{luatexja} and \Pkg{fontspec}
1265 packages, if needed.
1266 %</en>
1267 %<*ja>
1268 \Pkg{fontspec}パッケージと同様の機能を和文フォントに対しても用いる場合,
1269 \Pkg{luatexja-fontspec}パッケージを読み込めばよい.
1270 \begin{quote}
1271 \ttfamily \textbackslash usepackage[<options>]\{luatexja-fontspec\}
1272 \end{quote}
1273 このパッケージ
1274 は必要ならば自動で\Pkg{luatexja}パッケージと\Pkg{fontspec}パッケージを読み込む.
1275 %</ja>
1276
1277 %<*en>
1278 In the \Pkg{luatexja-fontspec} package, the following seven~commands are defined as
1279 counterparts of original commands in the \Pkg{fontspec} package:
1280 %</en>
1281 %<*ja>
1282 \Pkg{luatexja-fontspec}パッケージでは,以下の7つのコマンドを\Pkg{fontspec}
1283 パッケージの元のコマンドに対応するものとして定義している:
1284 %</ja>
1285 %<*en>
1286 \begin{center}\small
1287 \begin{tabular}{ccccc}
1288 \toprule
1289 Japanese fonts
1290 &\cs{jfontspec}&\cs{setmainjfont}&\cs{setsansjfont}&\cs{setmonojfont}$^*$\\
1291 alphabetic fonts
1292 &\cs{fontspec}&\cs{setmainfont}&\cs{setsansfont}&\cs{setmonofont}\\
1293 \midrule
1294 Japanese fonts
1295 &\cs{newjfontfamily}&\cs{newjfontface}
1296 &\cs{defaultjfontfeatures}&\cs{addjfontfeatures}\\
1297 alphabetic fonts
1298 &\cs{newfontfamily}&\cs{newfontface}
1299 &\cs{defaultfontfeatures}&\cs{addfontfeatures}\\
1300 \bottomrule
1301 \end{tabular}
1302 \end{center}
1303 %</en>
1304 %<*ja>
1305 \begin{center}\small
1306 \begin{tabular}{cccc}
1307 \toprule
1308 和文
1309 &\cs{jfontspec}&\cs{setmainjfont}&\cs{setsansjfont}\\
1310 欧文
1311 &\cs{fontspec}&\cs{setmainfont}&\cs{setsansfont}\\
1312 \midrule
1313 和文
1314 &\cs{newjfontfamily}&\cs{newjfontface}&\cs{defaultjfontfeatures}\\
1315 欧文
1316 &\cs{newfontfamily}&\cs{newfontface}&\cs{defaultfontfeatures}\\
1317 \midrule
1318 和文
1319 &\cs{addjfontfeatures}\\
1320 欧文
1321 &\cs{addfontfeatures}\\
1322 \bottomrule
1323 \end{tabular}
1324 \end{center}
1325 %</ja>
1326 %<*en>
1327 The package option of \Pkg{luatexja-fontspec} are the followings:
1328 \begin{cslist}
1329  \item[match]
1330 If this option is specified, usual family-changing commands such as
1331 \cs{rmfamily},~\cs{textrm}, \cs{sffamily},~\dots\ also change Japanese font family.
1332
1333 Note that \emph{\cs{setmonojfont} is defined
1334 if and only if this \texttt{\textup{match}} option is specified}.
1335
1336  \item[pass=<opts>]
1337 Specify options <opts> which will be passed to the \Pkg{fontspec} package.
1338 \end{cslist}
1339 The reason that \cs{setmonojfont} is not defined by default is that
1340 it is popular for Japanese fonts that nearly all Japanese glyphs have same
1341 widths.  Also note that kerning information in a font is not used
1342 (that is, \texttt{kern} feature is set off) by default in these seven (or~eight) commands.
1343 This is because of the compatibility with previous versions of \LuaTeX-ja
1344 (see \ref{para-kern}).
1345
1346 Below is an example of \cs{jfontspec}.
1347 %</en>
1348 %<*ja>
1349 \Pkg{luatexja-fontspec} パッケージのオプションは以下の通りである:
1350 \begin{cslist}
1351  \item[match]
1352 このオプションが指定されると,「\pLaTeXe 新ドキュメントクラス」のように\
1353 \cs{rmfamily}, \verb+\textrm{...}+, \cs{sffamily} 等が
1354 欧文フォントだけでなく和文フォントも変更するようになる.
1355
1356 \emph{なお,\cs{setmonojfont} はこの \texttt{match} オプションが
1357 指定された時のみ定義される.}この命令は標準の「タイプライタ体に対応する和文フォント」を指定する.
1358
1359  \item[pass=<opts>]
1360 \Pkg{fontspec} パッケージに渡すオプション <opts> を指定する.
1361 \end{cslist}
1362 標準で \cs{setmonojfont} コマンドが定義されないのは,
1363 和文フォントではほぼ全ての和文文字のグリフが等幅であるのが伝統的であったことによる.
1364 また,これらの和文用のコマンドではフォント内のペアカーニング情報は標準では使用されない,
1365 言い換えれば \texttt{kern} featureは標準では無効化となっている.
1366 これは以前のバージョンの\LuaTeX-jaとの互換性のためである(\ref{para-kern}節を参照).
1367
1368 以下に\cs{jfontspec}の使用例を示す.
1369 %</ja>
1370
1371 \begin{LTXexample}[width=0.4\textwidth]
1372 \jfontspec[CJKShape=NLC]{KozMinPr6N-Regular}
1373 JIS~X~0213:2004→辻\par
1374 \jfontspec[CJKShape=JIS1990]{KozMinPr6N-Regular}
1375 JIS~X~0208:1990→辻
1376 \end{LTXexample}
1377
1378 %<en>\subsection{Presets}
1379 %<ja>\subsection{プリセット設定}
1380 \label{ssec-preset}
1381
1382 %<*en>
1383 To use standard Japanese font settings easily, one can load the \Pkg{luatexja-preset}
1384 package with several options. This package provides functions in a part of
1385 \Pkg{japanese-otf} package and a part of \Pkg{PXchfon} package by Takayuki Yato.
1386 %</en>
1387 %<*ja>
1388 よく使われている和文フォント設定を一行で指定できるようにしたのが
1389 \Pkg{luatexja-preset}パッケージである.このパッケージは,
1390 \Pkg{otf}パッケージの一部機能と八登崇之氏による\Pkg{PXchfon}パッケージの一部機能とを
1391 合わせたような格好をしている.
1392 %</ja>
1393
1394 %<en>\paragraph{General options}
1395 %<ja>\paragraph{一般的なオプション}
1396 \begin{cslist}[before*=]
1397
1398 \item[fontspec]
1399 %<*en>
1400 With this option, Japanese fonts are selected using functionality of
1401 the \Pkg{luatexja-fontspec} package. This means that the \Pkg{fontspec} package is
1402              automatically loaded by this package.
1403 \emph{This option is enabled by default.}
1404
1405 If you need to pass some options to \Pkg{fontspec}, load \Pkg{fontspec} manually
1406 before \Pkg{luatexja-preset}:
1407 %</en>
1408 %<*ja>
1409 \Pkg{luatexja-fontspec}パッケージの機能を用いて和文フォントを選択する.
1410 これは,\Pkg{fontspec}パッケージが自動で読み込まれることを意味する.
1411 \emph{このオプションは標準で有効になっている.}
1412
1413 もし\Pkg{fontspec}パッケージに何らかのオプションを渡す必要がある
1414 \footnote{例えば,数式フォントまで置換されてしまい,\cs{mathit}によってギリシャ文字の
1415 斜体大文字が出なくなる,など.}場合は,
1416 次のように\Pkg{luatexja-preset}の前に\Pkg{fontspec}を手動で読みこめば良い:
1417 %</ja>
1418 \begin{lstlisting}
1419 \usepackage[no-math]{fontspec}
1420 \usepackage[...]{luatexja-preset}
1421 \end{lstlisting}
1422
1423 \item[nfssonly]
1424 %<*en>
1425 With this option,selecting Japanese fonts won't be performed using  the functionality of
1426              the \Pkg{fontspec} package, but only standard NFSS2.
1427
1428 This option will be disabled when \Pkg{luatexja-fontspec} package is loaded.
1429 Note that the \Pkg{fontspec} can coexist with the option as the following:
1430 \begin{lstlisting}
1431 \usepackage{fontspec}
1432 \usepackage[hiragino-pron,nfssonly]{luatexja-preset}
1433 \end{lstlisting}
1434 Note that the functionality of the \Pkg{luatexja-fontspec} package, such as
1435              \cs{setmainjfont}, cannot be used in the example above.
1436 %</en>
1437 %<*ja>
1438 \LaTeX 標準のフォント選択機構(NFSS2)を用いて
1439 \texttt{ltjpm}(明朝),\texttt{ltjpg}(ゴシック),それに後に述べる \texttt{deluxe} オプ
1440              ションが指定された場合には \texttt{ltjpmg}(丸ゴシック)という
1441 3つの和文フォントファミリを定義し,これらを用いる.
1442
1443 欧文フォントの指定で\Pkg{fontspec}パッケージを読み込んでいる場合でも
1444 \begin{lstlisting}
1445 \usepackage{fontspec}
1446 \usepackage[hiragino-pron,nfssonly]{luatexja-preset}
1447 \end{lstlisting}
1448 のようにこのオプションを指定することは可能である.一方,
1449 パッケージ読み込み時に既に\Pkg{luatexja-fontspec}パッケージが読み込まれて
1450              いる場合は \texttt{nfssonly} オプションは無視される.
1451 %</ja>
1452
1453 \item[nodeluxe]
1454 %<*en>
1455 Use one-weighted \textit{mincho} and \textit{gothic} font families.
1456 This means that \verb+\mcfamily\bfseries+, \verb+\gtfamily\bfseries+ and
1457 \verb+\gtfamily\mdseries+ use the same font.
1458 \emph{This option is enabled by default.}
1459 %</en>
1460 %<*ja>
1461 \LaTeXe 環境下の標準設定のように,明朝体・ゴシック体を各1ウェイトで使用する.
1462 より具体的に言うと,この設定の下では
1463 \ \verb+\mcfamily\bfseries+, \verb+\gtfamily\bfseries+,
1464 \verb+\gtfamily\mdseries+はみな同じフォントとなる.
1465 \emph{このオプションは標準で有効になっている.}
1466 %</ja>
1467 \item[deluxe]
1468 %<*en>
1469 Use \textit{mincho} with two weights (medium~and~bold),
1470 \textit{gothic} with three weights (medium, bold~and~heavy), and \textit{rounded gothic}%
1471 \footnote{Provided by \cs{mgfamily} and \cs{textmg},
1472 because \textit{rounded gothic} is called \textit{maru gothic} (丸ゴシック) in Japanese.}.
1473 The heavy weight of \textit{gothic} can be used by ``changing the family'' \cs{gtebfamily},
1474 or \verb+\textgteb{...}+.
1475 This is because the \Pkg{fontspec} package can handle only medium (\cs{mdseries}) and
1476 bold (\cs{bfseries}).
1477 %</en>
1478 %<*ja>
1479 明朝体2ウェイト・ゴシック体3ウェイトと,
1480 丸ゴシック体 (\cs{mgfamily}, \verb+\textmg{...}+) を使用可能とする.
1481 ゴシック体は中字・太字・極太の3ウェイトがあるが,
1482 極太ゴシック体を使う場合,
1483 \begin{itemize}
1484  \item \cs{gtebfamily}, \verb+\textgteb{...}+
1485  \item \cs{ebseries} (周囲がゴシック体のとき,\texttt{nfssonly} オプション指定時のみ)
1486 \end{itemize}
1487 のいずれかを用いる.標準で \cs{ebseries} が準備されていないのは,バージョンが古い
1488 \Pkg{fontspec}では中字(\cs{mdseries})と太字(\cs{bfseries})しか扱えなかった名残である.
1489 %</ja>
1490 \item[expert]
1491 %<*en>
1492 Use horizontal/vertical kana alternates, and define a command \cs{rubyfamily} to use kana
1493 characters designed for ruby.
1494 %</en>
1495 %<*ja>
1496 横組・縦組専用仮名を用いる.また,\cs{rubyfamily} でルビ用仮名が使用可能となる\footnote{%
1497   \cs{rubyfamily}とはいいつつ,実際にはフォントファミリを切り替えるのではない(通常では
1498   font featureの追加,\texttt{nfssonly} 指定時にはシェイプを \texttt{rb} に切り替え).
1499 }.
1500 %</ja>
1501 \item[bold]
1502 %<en>Substitute bold series of \textit{gothic} for  bold series of \textit{mincho}.
1503 %<ja>「明朝の太字」をゴシック体の太字によって代替する.
1504 \item[90jis]
1505 %<en>Use 90JIS glyph variants if possible.
1506 %<ja>出来る限り90JISの字形を使う.
1507 \item[jis2004]
1508 %<en>Use JIS2004 glyph variants if possible.
1509 %<ja>出来る限りJIS2004の字形を使う.
1510 \item[jis]
1511 %<*en>
1512 Use the JFM \texttt{jfm-jis.lua}, instead of \texttt{jfm-ujis.lua}, which is the default JFM of
1513 \LuaTeX-ja.
1514 %</en>
1515 %<*ja>
1516 用いるJFMを(JISフォントメトリック類似の)\texttt{jfm-jis.lua}にする.このオプションがない時は
1517 \LuaTeX-ja標準の\texttt{jfm-ujis.lua}が用いられる.
1518 %</ja>
1519 \end{cslist}
1520 %<*en>
1521 Note that \texttt{90jis} and \texttt{jis2004} only affect with \textit{mincho},
1522 \textit{gothic} (and possibly \textit{rounded gothic}) defined by this package.
1523 We didn't taken account of  when both \texttt{90jis} and \texttt{jis2004} are specified.
1524 %</en>
1525 %<*ja>
1526 \texttt{90jis}と\texttt{jis2004}については本パッケージで定義された
1527 明朝体・ゴシック体(・丸ゴシック体)にのみ有効である.両オプションが
1528 同時に指定された場合の動作については全く考慮していない.
1529 %</ja>
1530
1531 %<en>\paragraph{Presets for multi weight}
1532 %<ja>\paragraph{多ウェイト用プリセットの一覧}
1533 %<*en>
1534 Besides \texttt{morisawa-pro}~and~\texttt{morisawa-pr6n} presets,
1535 fonts are specified by font name, not by file name.
1536 In following tables, starred fonts (e.g.~KozGo\dots-Regular) are used for medium series of \textit{gothic},
1537 \emph{if and only if \texttt{deluxe} option is specified}.
1538 %</en>
1539 %<*ja>
1540 \texttt{morisawa-pro}, \texttt{morisawa-pr6n}以外はフォントの指定は
1541 (ファイル名でなく)フォント名で行われる.
1542 以下の表において,*\,つきのフォント(e,g,~KozGo\dots-Regular)は,\emph{\texttt{deluxe}オプション指定時に}
1543 ゴシック体中字として用いられるものを示している.
1544 %</ja>
1545 \begin{cslist}[style=standard]
1546  \item[kozuka-pro] Kozuka Pro (Adobe-Japan1-4) fonts.
1547 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
1548  \item[kozuka-pr6] Kozuka Pr6 (Adobe-Japan1-6)  fonts.
1549 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
1550  \item[kozuka-pr6n] Kozuka Pr6N (Adobe-Japan1-6, JIS04-savvy) fonts.
1551
1552 %<*en>
1553 Kozuka Pro/Pr6N fonts are bundled with Adobe's software, such as Adobe~InDesign.
1554 There is not rounded gothic family in Kozuka fonts.
1555 %</en>
1556 %<*ja>
1557 小塚Pro書体・Pr6N書体はAdobe InDesign等のAdobe製品にバンドルされている.
1558 「小塚丸ゴシック」は存在しないので,便宜的に小塚ゴシックHによって代用している.
1559 %</ja>
1560 \begin{center}\small
1561 \begin{tabular}{cllll}
1562 \toprule
1563 \bf family&\bf series&\tt kozuka-pro&\tt kozuka-pr6&\tt kozuka-pr6n\\
1564 \midrule
1565  &medium&KozMinPro-Regular&KozMinProVI-Regular&KozMinPr6N-Regular\\
1566 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
1567 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
1568  &bold&KozMinPro-Bold&KozMinProVI-Bold&KozMinPr6N-Bold\\
1569 \midrule
1570  &&KozGoPro-Regular*&KozGoProVI-Regular*&KozGoPr6N-Regular*\\
1571  &\smash{\raisebox{1.5ex}{medium}}
1572  &KozGoPro-Medium&KozGoProVI-Medium&KozGoPr6N-Medium\\
1573 \cmidrule(l){2-5}
1574 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
1575 %<ja>\smash{\raisebox{2ex}{\gt ゴシック}}%
1576  &bold&KozGoPro-Bold&KozGoProVI-Bold&KozGoPr6N-Bold\\
1577  &heavy&KozGoPro-Heavy&KozGoProVI-Heavy&KozGoPr6N-Heavy\\
1578 \midrule
1579 %<en>\textit{rounded gothic}
1580 %<ja>\gt 丸ゴシック
1581 &&KozGoPro-Heavy&KozGoProVI-Heavy&KozGoPr6N-Heavy\\
1582 \bottomrule
1583 \end{tabular}
1584 \end{center}
1585
1586 %<ja>\newpage
1587
1588  \item[hiragino-pro]  Hiragino Pro (Adobe-Japan1-5) fonts.
1589 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
1590  \item[hiragino-pron] Hiragino ProN (Adobe-Japan1-5, JIS04-savvy) fonts.
1591
1592 %<*en>
1593 Hiragino fonts are bundled with Mac OS~X 10.5 or later.
1594 Some editions of a Japanese word-processor ``一太郎2012'' includes Hiragino ProN fonts.
1595 Note that the heavy weight of \textit{gothic} family only supports
1596 Adobe-Japan1-3 character collection (Std/StdN).
1597 %</en>
1598 %<*ja>
1599 ヒラギノフォントは,Mac OS~X以外にも,一太郎2012の上位エディションにもバンドルされている.
1600 極太ゴシックとして用いるヒラギノ角ゴW8は,Adobe-Japan1-3の範囲しかカバーしていない
1601 Std/StdNフォントであり,その他はAdobe-Japan1-5対応である.
1602 %</ja>
1603 \begin{center}\small
1604 \begin{tabular}{clll}
1605 \toprule
1606 \bf family&\bf series&\tt hiragino-pro&\tt hiragino-pron\\
1607 \midrule
1608  &medium&Hiragino~Mincho~Pro~W3&Hiragino~Mincho~ProN~W3\\
1609 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
1610 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
1611  &bold&Hiragino~Mincho~Pro~W6&Hiragino~Mincho~ProN~W6\\
1612 \midrule
1613  &&Hiragino~Kaku~Gothic~Pro~W3*&Hiragino~Kaku~Gothic~ProN~W3*\\
1614  &\smash{\raisebox{1.5ex}{medium}}
1615  &Hiragino~Kaku~Gothic~Pro~W6&Hiragino~Kaku~Gothic~ProN~W6\\
1616 \cmidrule(l){2-4}
1617 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
1618 %<ja>\smash{\raisebox{2ex}{\gt ゴシック}}%
1619  &bold&Hiragino~Kaku~Gothic~Pro~W6&Hiragino~Kaku~Gothic~ProN~W6\\
1620  &heavy&Hiragino~Kaku~Gothic~Std~W8&Hiragino~Kaku~Gothic~StdN~W8\\
1621 \midrule
1622 %<en>\textit{rounded gothic}
1623 %<ja>\gt 丸ゴシック
1624 &&Hiragino~Maru~Gothic~Pro~W4&Hiragino~Maru~Gothic~ProN~W4\\
1625 \bottomrule
1626 \end{tabular}
1627 \end{center}
1628
1629 %<ja>\medskip
1630
1631  \item[morisawa-pro]  Morisawa Pro (Adobe-Japan1-4) fonts.
1632 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
1633  \item[morisawa-pr6n]  Morisawa Pr6N (Adobe-Japan1-6, JIS04-savvy) fonts.
1634
1635 \begin{center}\small
1636 \begin{tabular}{cl>{\tt}l>{\tt}l}
1637 \toprule
1638 \bf family&\bf series&morisawa-pro&morisawa-pr6n\\
1639 \midrule
1640  &medium&A-OTF-RyuminPro-Light.otf&A-OTF-RyuminPr6N-Light.otf\\
1641 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
1642 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
1643  &bold&A-OTF-FutoMinA101Pro-Bold.otf&A-OTF-FutoMinA101Pr6N-Bold.otf\\
1644 \midrule
1645  &medium
1646  &A-OTF-GothicBBBPro-Medium.otf&A-OTF-GothicBBBPr6N-Medium.otf\\
1647 %<en>\textit{gothic}%
1648 %<ja>\gt ゴシック
1649  &bold&A-OTF-FutoGoB101Pro-Bold.otf&A-OTF-FutoGoB101Pr6N-Bold.otf\\
1650  &heavy&A-OTF-MidashiGoPro-MB31.otf&A-OTF-MidashiGoPr6N-MB31.otf\\
1651 \midrule
1652 %<en>\textit{rounded gothic}
1653 %<ja>\gt 丸ゴシック
1654 &&A-OTF-Jun101Pro-Light.otf&A-OTF-ShinMGoPr6N-Light.otf\\
1655 \bottomrule
1656 \end{tabular}
1657 \end{center}
1658
1659  \item[yu-win]  Yu fonts bundled with Windows~8.1.
1660 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
1661  \item[yu-osx]  Yu fonts bundled with OSX~Mavericks.
1662
1663 \begin{center}\small
1664 \begin{tabular}{clll}
1665 \toprule
1666 \bf family&\bf series&\tt yu-win&\tt yu-osx\\
1667 \midrule
1668  &medium&YuMincho-Regular&YuMincho~Medium\\
1669 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
1670 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
1671  &bold&YuMincho-Demibold&YuMincho~Demibold\\
1672 \midrule
1673  &&YuGothic-Regular*&YuGothic~Medium*\\
1674  &\smash{\raisebox{1.5ex}{medium}}
1675  &YuGothic-Bold&YuGothic~Bold\\
1676 \cmidrule(l){2-4}
1677 %<en>\textit{gothic}%
1678 %<ja>\gt ゴシック
1679  &bold&YuGothic-Bold&YuGothic~Bold\\
1680  &heavy&YuGothic-Bold&YuGothic~Bold\\
1681 \midrule
1682 %<en>\textit{rounded gothic}
1683 %<ja>\gt 丸ゴシック
1684 &&YuGothic-Bold&YuGothic~Bold\\
1685 \bottomrule
1686 \end{tabular}
1687 \end{center}
1688
1689  \item[moga-mobo]  MogaMincho, MogaGothic, and MoboGothic.
1690 %<en>These fonts can be downloaded from\\\hfill \url{http://yozvox.web.fc2.com/}.
1691 %<ja>これらのフォントは \url{http://yozvox.web.fc2.com/} からダウンロードできる.
1692
1693 \begin{center}\small
1694 \begin{tabular}{clll}
1695 \toprule
1696 \bf family&\bf series&\bf default, \texttt{90jis}~option&\bf \texttt{jis2004} option\\
1697 \midrule
1698  &medium&Moga90Mincho&MogaMincho\\
1699 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
1700 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
1701  &bold&Moga90Mincho Bold&MogaMincho Bold\\
1702 \midrule
1703  &&Moga90Gothic&MogaGothic\\
1704  &\smash{\raisebox{1.5ex}{medium}}
1705  &Moga90Gothic&MogaGothic\\
1706 \cmidrule(l){2-4}
1707 %<en>\textit{gothic}%
1708 %<ja>\gt ゴシック
1709  &bold&Moga90Gothic Bold&MogaGothic Bold\\
1710  &heavy&Moga90Gothic Bold&MogaGothic Bold\\
1711 \midrule
1712 %<en>\textit{rounded gothic}
1713 %<ja>\gt 丸ゴシック
1714 &&Mobo90Gothic&MoboGothic\\
1715 \bottomrule
1716 \end{tabular}
1717 \end{center}
1718
1719
1720 \end{cslist}
1721 %<en>\paragraph{Presets for single weight}
1722 %<ja>\paragraph{単ウェイト用プリセット一覧}
1723 %<*en>
1724 Next, we describe settings for using only single weight.
1725 %</en>
1726 %<*ja>
1727 次に,単ウェイト用の設定を述べる.この4設定では
1728 明朝体太字・丸ゴシック体はゴシック体と同じフォントが用いられる.
1729 %</ja>
1730 \par\nobreak\medskip
1731 {\centering\small
1732 \begin{tabular}{lllll}
1733 \toprule
1734 &\tt noembed&\tt ipa&\tt ipaex&\tt ms\\
1735 \midrule
1736 %<*en>
1737 \it mincho&Ryumin-Light (non-embedded)
1738 &IPA Mincho&IPAex Mincho&MS Mincho\\
1739 \it gothic&GothicBBB-Medium (non-embedded)
1740 &IPA Gothic&IPAex Gothic&MS Gothic\\
1741 %</en>
1742 %<*ja>
1743 \gtfamily 明朝体&Ryumin-Light(非埋込)
1744 &IPA明朝&IPAex明朝&MS明朝\\
1745 \gtfamily ゴシック体&GothicBBB-Medium(非埋込)
1746 &IPAゴシック&IPAexゴシック&MSゴシック\\
1747 %</ja>
1748 \bottomrule
1749 \end{tabular}\par\medskip}
1750
1751 %<en>\paragraph{Using HG fonts}
1752 %<ja>\paragraph{HGフォントの利用}
1753 %<*en>
1754 We can use HG~fonts bundled with Microsoft~Office for realizing multiple weights.
1755 %</en>
1756 %<*ja>
1757 すぐ前に書いた単ウェイト用設定を,Microsoft Office等に付属するHGフォントを使って
1758 多ウェイト化した設定もある.
1759 %</ja>
1760 \par\nobreak\medskip
1761 {\centering\small
1762 \begin{tabular}{llll}
1763 \toprule
1764 &\tt ipa-hg&\tt ipaex-hg&\tt ms-hg\\
1765 \midrule
1766 %<*en>
1767 \bf mincho medium
1768 &IPA Mincho&IPAex Mincho&MS Mincho\\\midrule
1769 \bf mincho bold&
1770 \multicolumn{3}{c}{HG Mincho E}\\\midrule
1771 \bf Gothic medium\\
1772 ~~without \texttt{deluxe}
1773 &IPA Gothic&IPAex Gothic&MS Gothic\\
1774 ~~with {\tt jis2004}
1775 &IPA Gothic&IPAex Gothic&MS Gothic\\
1776 \cmidrule(lr){1-4}
1777 ~~otherwise&
1778 \multicolumn{3}{c}{HG Gothic M}\\\midrule
1779 \bf gothic bold&
1780 \multicolumn{3}{c}{HG Gothic E}\\\midrule
1781 \bf gothic heavy&
1782 \multicolumn{3}{c}{HG Soei Kaku Gothic UB}\\\midrule
1783 \bf rounded gothic&
1784 \multicolumn{3}{c}{HG Maru Gothic PRO}\\
1785 %</en>
1786 %<*ja>
1787 \gtfamily 明朝体中字
1788 &IPA明朝&IPAex明朝&MS明朝\\\midrule
1789 \gtfamily 明朝体太字&
1790 \multicolumn{3}{c}{HG明朝E}\\\midrule
1791 \gtfamily ゴシック体中字\\
1792  単ウェイト時
1793 &IPAゴシック&IPAexゴシック&MSゴシック\\
1794  {\tt jis2004}指定時
1795 &IPAゴシック&IPAexゴシック&MSゴシック\\
1796 \cmidrule(lr){1-4}
1797  それ以外の時&
1798 \multicolumn{3}{c}{HGゴシックM}\\\midrule
1799 \gtfamily ゴシック体太字&
1800 \multicolumn{3}{c}{HGゴシックE}\\\midrule
1801 \gtfamily ゴシック体極太&
1802 \multicolumn{3}{c}{HG創英角ゴシックUB}\\\midrule
1803 \gtfamily 丸ゴシック体&
1804 \multicolumn{3}{c}{HG丸ゴシック体PRO}\\
1805 %</ja>
1806 \bottomrule
1807 \end{tabular}\par\medskip}
1808
1809 %<*en>
1810 Note that HG~Mincho~E, HG~Gothic~E, HG Soei Kaku Gothic UB, and HG Maru Gothic PRO
1811 are internally specified by:
1812 \begin{description}
1813 \item[default] by font name (\texttt{HGMinchoE}, etc.).
1814 \item[{\tt 90jis}] by file name (\texttt{hgrme.ttc}, \texttt{hgrge.ttc}, \texttt{hgrsgu.ttc}, \texttt{hgrsmp.ttf}).
1815 \item[{\tt jis2004}] by file name (\texttt{hgrme04.ttc}, \texttt{hgrge04.ttc}, \texttt{hgrsgu04.ttc}, \texttt{hgrsmp04.ttf}).
1816 \end{description}
1817 %</en>
1818 %<*ja>
1819 なお,HG明朝E・HGゴシックE・HG創英角ゴシックUB・HG丸ゴシック体PROの4つについては,内部で
1820 \begin{description}
1821 \item[標準] フォント名(\texttt{HGMinchoE} など)
1822 \item[{\tt 90jis}指定時] ファイル名 (%
1823 \texttt{hgrme.ttc}, \texttt{hgrge.ttc}, \texttt{hgrsgu.ttc}, \texttt{hgrsmp.ttf})
1824 \item[{\tt jis2004}指定時] ファイル名 (%
1825 \texttt{hgrme04.ttc}, \texttt{hgrge04.ttc}, \texttt{hgrsgu04.ttc}, \texttt{hgrsmp04.ttf})
1826 \end{description}
1827 として指定を行っているので注意すること.
1828 %</ja>
1829
1830
1831 %<*en>
1832 \subsection{\cs{CID}, \cs{UTF}, and macros in \Pkg{japanese-otf} package}
1833 Under \pLaTeX, \Pkg{japanese-otf} package (developed by Shuzaburo Saito) is
1834 used for typesetting characters which is in Adobe-Japan1-6 CID but not
1835 in JIS~X~0208. Since this package is widely used, \LuaTeX-ja
1836 supports some of functions in the \Pkg{japanese-otf} package,
1837 as an external package \Pkg{luatexja-otf}.
1838 %</en>
1839 %<*ja>
1840 \subsection{\cs{CID}, \cs{UTF}と\Pkg{otf}パッケージのマクロ}
1841 \pLaTeX では,JIS~X~0208にないAdobe-Japan1-6の文字を出力するために,
1842 齋藤修三郎氏による\Pkg{otf}パッケージが用いられていた.このパッケージは
1843 広く用いられているため,\LuaTeX-jaにおいても\Pkg{otf}パッケージの機能の
1844 一部を(\Pkg{luatexja-otf}という別のパッケージとして)実装した.
1845 %</ja>
1846
1847 \begin{LTXexample}
1848 \jfontspec{KozMinPr6N-Regular.otf}
1849 森\UTF{9DD7}外と内田百\UTF{9592}とが\UTF{9AD9}島屋に行く。
1850
1851 \CID{7652}飾区の\CID{13706}野家,
1852 \CID{1481}城市,葛西駅,
1853 高崎と\CID{8705}\UTF{FA11}
1854
1855 \aj半角{はんかくカタカナ}
1856 \end{LTXexample}
1857
1858 %<*ja>
1859 \Pkg{otf}パッケージでは,それぞれ次のようなオプションが存在した:
1860 \begin{cslist}
1861 \item[deluxe] 明朝体・ゴシック体各3ウェイトと,丸ゴシック体を扱えるようになる.
1862 \item[expert] 仮名が横組・縦組専用のものに切り替わり,ルビ用仮名も
1863 \ \cs{rubyfamily}\ によって扱えるようになる.
1864 \item[bold] ゴシック体を標準で太いウェイトのものに設定する.
1865 \end{cslist}
1866 しかしこれらのオプションは\Pkg{luatexja-otf}パッケージには存在しない.
1867 \Pkg{otf}パッケージが文書中で使用する和文用TFMを自前の物に置き換えていたのに対し,
1868 \Pkg{luatexja-otf}パッケージでは,そのようなことは行わないからである.
1869
1870 これら3オプションについては,
1871 \Pkg{luatexja-preset} パッケージにプリセットを使う時に一緒に指定するか,
1872 あるいは対応する内容を\ref{ssec-chgfnt}節,\ref{ssec-nfsspat}節 (NFSS2) や
1873 \ref{ssec-fontspec}節 (\Pkg{fontspec}) の方法で手動で指定する必要がある.
1874 %</ja>
1875
1876 %<en>\subsection{Changing default Japanese fonts}
1877 %<ja>\subsection{標準和文フォントの変更}
1878 \label{ssec-cfg}
1879 %<*en>
1880 If \texttt{luatexja.cfg} can be seen from \LuaTeX, \LuaTeX-ja automatically reads it.
1881 The main use of \texttt{luatexja.cfg} is for changing default Japanese fonts,
1882 when IPAex fonts cannot be installed in \TeX~system.
1883 One should not overuse this \texttt{luatexja.cfg}; fonts which will be used in
1884 a document should be specified in its source.
1885
1886 For example,
1887 \begin{lstlisting}
1888 \def\ltj@stdmcfont{IPAMincho}
1889 \def\ltj@stdgtfont{IPAGothic}
1890 \end{lstlisting}
1891 makes that IPA~Mincho and IPA~Gothic will be used as default Japanese fonts, instead of
1892 IPAex~Mincho and IPAex~Gothic.
1893
1894 For another example, the following two lines makes that
1895 non-embedded fonts Ryumin-Light~and~GothicBBB-Medium as default Japanese fonts
1896 (as the earlier version of \LuaTeX-ja):
1897 \begin{lstlisting}
1898 \def\ltj@stdmcfont{psft:Ryumin-Light}
1899 \def\ltj@stdgtfont{psft:GothicBBB-Medium}
1900 \end{lstlisting}
1901 %</en>
1902 %<*ja>
1903 \LuaTeX から見える位置に \texttt{luatexja.cfg} があれば,\LuaTeX-jaはそれを読み込む.
1904 このファイルを用いるとplain~\TeX, \LaTeXe における標準和文フォントを
1905 IPAex明朝・IPAexゴシックから変更することができる.
1906 しかし,基本的には\emph{文章中で用いるフォントは(例えば \Pkg{luatexja-preset} などで)
1907 文書ソース内で指定するべき}であり,この \texttt{luatexja.cfg} は,
1908 「IPAexフォントがインストールできない」など,IPAexフォントが使用できない場合にのみ
1909 応急処置的に用いるべきである.
1910
1911 例えば
1912 \begin{lstlisting}
1913 \def\ltj@stdmcfont{IPAMincho}
1914 \def\ltj@stdgtfont{IPAGothic}
1915 \end{lstlisting}
1916 と記述しておけば,標準和文フォントがIPA明朝・IPAゴシックへと変
1917 更される.
1918
1919
1920 なお,20140906.0以前のバージョンのように,
1921 Ryumin-Light, GothicBBB-Mediumという名前の非埋込フォントを用いる場合は
1922 \begin{lstlisting}
1923 \def\ltj@stdmcfont{psft:Ryumin-Light}
1924 \def\ltj@stdgtfont{psft:GothicBBB-Medium}
1925 \end{lstlisting}
1926 と記述すればよい.
1927 %</ja>
1928
1929
1930 %<en>\section{Changing Internal Parameters}
1931 %<ja>\section{パラメータの変更}
1932
1933 %<*en>
1934 There are many internal parameters in \LuaTeX-ja. And due to the behavior of \LuaTeX,
1935 most of them are not stored as internal register of \TeX, but as an
1936 original storage system in \LuaTeX-ja. Hence, to assign or acquire those
1937 parameters, you have to use commands \cs{ltjsetparameter} and
1938 \cs{ltjgetparameter}.
1939 %</en>
1940 %<*ja>
1941 \LuaTeX-jaには多くのパラメータが存在する.そして\LuaTeX の仕様のために,
1942 その多くは\TeX のレジスタにではなく,\LuaTeX-ja独自の方法で保持されている.
1943 これらのパラメータを設定・取得するためには \cs{ltjsetparameter} と \cs{ltjgetparameter} を
1944 用いる.
1945 %</ja>
1946
1947 %<en>\subsection{Range of \textbf{JAchar}s}
1948 %<ja>\subsection{\textbf{JAchar}の範囲}
1949 \label{ssec-setrange}
1950
1951 %<*en>
1952 \LuaTeX-ja divides the Unicode codespace \texttt{U+0080}--\texttt{U+10FFFF}
1953 into \emph{character ranges},
1954 numbered 1 to 217. The grouping can be (globally) customized by \cs{ltjdefcharrange}.
1955 The next line adds whole characters in Supplementary Ideographic Plane
1956 and the character ``漢'' to the character range~100.
1957 %</en>
1958 %<*ja>
1959 \LuaTeX-jaは,Unicodeの \texttt{U+0080}--\texttt{U+10FFFF} の空間を
1960 1番から217番までの\emph{文字範囲}に分割している.
1961 区分けは \cs{ltjdefcharrange} を用いることで(グローバルに)変更することができ,
1962 例えば,次は追加漢字面(SIP)にある全ての文字と「漢」を「100番の文字範囲」に追加する.
1963 %</ja>
1964 \begin{lstlisting}
1965 \ltjdefcharrange{100}{"20000-"2FFFF,`漢}
1966 \end{lstlisting}
1967 %<*en>
1968 A character can belong to only one character range.
1969 For example, whole SIP belong to the range~4 in the default setting of \LuaTeX-ja,
1970 and if you execute the above line, then SIP will belong to the range~100 and be
1971 removed from the range~4.
1972 %</en>
1973 %<*ja>
1974 各文字はただ一つの文字範囲に所属することができる.
1975 例えば,SIPは全て\LuaTeX-jaのデフォルトでは4番の文字範囲に
1976 属しているが,上記の指定を行えばSIPは100番に属すようになり,4番からは除かれる.
1977 %</ja>
1978
1979 %<*en>
1980 The distinction between \textbf{ALchar} and \textbf{JAchar} is done for character ranges.
1981 This can be edited by setting the \textsf{jacharrange} parameter.
1982 For example, this is just the default setting of \LuaTeX-ja, and
1983 it sets
1984 \begin{itemize}
1985  \item a character which belongs character ranges 1,~4, and~5 is \textbf{ALchar},
1986  \item a character which belongs character ranges 2,~3, 6, 7, and~8 is \textbf{JAchar}.
1987 \end{itemize}
1988 %</en>
1989 %<*ja>
1990 \textbf{ALchar}と\textbf{JAchar}の区別は文字範囲ごとに行われる.
1991 これは\textsf{jacharrange}パラメータによって編集できる.
1992 例えば,以下は\LuaTeX-jaの初期設定であり,次の内容を設定している:
1993 \begin{itemize}
1994  \item 1番,4番,5番の文字範囲に属する文字は\textbf{ALchar}.
1995  \item 2番,3番,6番,7番,8番の文字範囲に属する文字は\textbf{JAchar}.
1996 \end{itemize}
1997 %</ja>
1998 \begin{lstlisting}
1999 \ltjsetparameter{jacharrange={-1, +2, +3, -4, -5, +6, +7, +8}}
2000 \end{lstlisting}
2001 %<*en>
2002 The argument to \textsf{jacharrange} parameter is a list of non-zero integer.
2003 Negative integer $-n$ in the list means that ``each character in the range~$n$ is an
2004 \textbf{ALchar}'',
2005 and positive integer $+n$ means that ``\dots\ is a \textbf{JAchar}''.
2006 %</en>
2007 %<*ja>
2008 \textsf{jacharrange}パラメータの引数は非零の整数のリストである.
2009 リスト中の負の整数$-n$は「文字範囲$n$に属する文字は\textbf{ALchar}として
2010 扱う」ことを意味し,正の整数$+n$は「\textbf{JAchar}として扱う」ことを意味する.
2011 %</ja>
2012
2013 %<*en>
2014 \paragraph{Default setting}
2015 \LuaTeX-ja predefines eight character ranges for convenience. They are
2016 determined from the following data:
2017 %</en>
2018 %<*ja>
2019 \paragraph{初期設定}
2020 \LuaTeX-jaでは8つの文字範囲を予め定義しており,
2021 これらは以下のデータに基づいて決定している.
2022 %</ja>
2023 \begin{itemize}
2024 %<en>\item Blocks in Unicode~6.0.
2025 %<ja>\item Unicode~6.0のブロック.
2026 %<en>\item The \texttt{Adobe-Japan1-UCS2} mapping between a CID Adobe-Japan1-6 and Unicode.
2027 %<ja>\item Adobe-Japan1-6のCIDとUnicodeの間の対応表\texttt{Adobe-Japan1-UCS2}.
2028 %<en>\item The \Pkg{PXbase} bundle for \upTeX\ by Takayuki Yato.
2029 %<ja>\item 八登崇之氏による\upTeX 用の\Pkg{PXbase}バンドル.
2030 \end{itemize}
2031
2032 %<*en>
2033 Now we describe these eight ranges. The superscript ``J'' or ``A'' after the
2034 number shows whether each character in the range is treated as
2035 \textbf{JAchar}s or not by default. These settings are similar to the
2036 \texttt{prefercjk} settings defined in \texttt{PXbase} bundle.
2037 Any characters above \texttt{U+0080} which does not belong to
2038 these eight ranges belongs to the character range~217.
2039 %</en>
2040 %<*ja>
2041 以下ではこれら8つの文字範囲について記述する.添字のアルファベット「J」「A」
2042 は,その文字範囲内の文字が\textbf{JAchar}か\textbf{ALchar}かを表している.これらの設定は
2043 \texttt{PXbase}バンドルで定義されている\texttt{prefercjk}と類似のものである.
2044 なお,\texttt{U+0080} 以降でこれら8つの文字範囲に属さない文字は,217番の文字範囲に属することになっている.
2045 %</ja>
2046 \begin{description}
2047 %<*en>
2048
2049 \item[Range~8${}^{\kern.1em\text{J}}$] The intersection of the upper half of ISO~8859-1
2050          (Latin-1 Supplement) and JIS~X~0208 (a basic character set for Japanese). This character range
2051          consists of the following characters:
2052 %</en>
2053 %<*ja>
2054 \item[範囲8${}^{\kern.1em\text{J}}$] ISO~8859-1の上位領域(ラテン1補助)と
2055                              JIS~X~0208の共通部分.この文字範囲は
2056                              以下の文字で構成される:
2057 %</ja>
2058 \begin{multicols}{2}
2059 \begin{itemize}
2060 \def\ch#1#2{\item \char"#1\ (\texttt{U+00#1}, #2)}%"
2061 \ch{A7}{Section Sign}
2062 \ch{A8}{Diaeresis}
2063 \ch{B0}{Degree sign}
2064 \ch{B1}{Plus-minus sign}
2065 \ch{B4}{Spacing acute}
2066 \ch{B6}{Paragraph sign}
2067 \ch{D7}{Multiplication sign}
2068 \ch{F7}{Division Sign}
2069 \end{itemize}
2070 \end{multicols}
2071
2072 %<*en>
2073 \item[Range~1${}^{\text{A}}$] Latin characters that some of them are included in Adobe-Japan1-6.
2074 This range consists of the following Unicode ranges, \emph{except characters in the range~8 above}:
2075 %</en>
2076 %<*ja>
2077 \item[範囲1${}^{\text{A}}$] ラテン文字のうち,Adobe-Japan1-6との共通部分があるもの.
2078                              この範囲は以下のUnicodeのブロックのうち
2079                              \emph{範囲8を除いた}部分で構成されている:
2080 %</ja>
2081 \begin{multicols}{2}
2082 \begin{itemize}
2083 \item \texttt{U+0080}--\texttt{U+00FF}: Latin-1 Supplement
2084 \item \texttt{U+0100}--\texttt{U+017F}: Latin Extended-A
2085 \item \texttt{U+0180}--\texttt{U+024F}: Latin Extended-B
2086 \item \texttt{U+0250}--\texttt{U+02AF}: IPA Extensions
2087 \item \texttt{U+02B0}--\texttt{U+02FF}: Spacing Modifier Letters
2088 \item \texttt{U+0300}--\texttt{U+036F}: \\\null\hfill Combining Diacritical Marks
2089 \item \texttt{U+1E00}--\texttt{U+1EFF}: \\\null\hfill Latin Extended Additional
2090 \par\
2091 \end{itemize}
2092 \end{multicols}
2093 %<*en>
2094 \item[Range~2${}^{\text{\kern.1emJ}}$] Greek and Cyrillic letters. JIS~X~0208 (hence most of Japanese
2095            fonts) has some of these characters.
2096 %</en>
2097 %<*ja>
2098 \item[範囲2${}^{\text{\kern.1emJ}}$] ギリシャ文字とキリル文字.JIS~X~0208(したがってほとんどの
2099                              和文フォント)はこれらの文字を持つ.
2100 %</ja>
2101 \begin{multicols}{2}
2102 \begin{itemize}
2103 \item \texttt{U+0370}--\texttt{U+03FF}: Greek and Coptic
2104 \item \texttt{U+0400}--\texttt{U+04FF}: Cyrillic
2105 \item \texttt{U+1F00}--\texttt{U+1FFF}: Greek Extended
2106 \\\
2107 \end{itemize}
2108 \end{multicols}
2109 %<*en>
2110 \item[Range~3${}^{\text{\kern.1emJ}}$] Punctuations and Miscellaneous symbols. The block list is
2111            indicated in Table~\ref{table-rng3}.
2112 %</en>
2113 %<*ja>
2114 \item[範囲3${}^{\text{\kern.1emJ}}$] 句読点と記号類.ブロックのリストは表\ref{table-rng3}%
2115                              に示してある.
2116 %</ja>
2117 \begin{table}[!tb]
2118 %<en>\caption{Unicode blocks in predefined character range~3.}\medskip
2119 %<ja>\caption{文字範囲3に指定されているUnicodeブロック.}
2120 \label{table-rng3}
2121 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
2122 \centering\small
2123 \begin{tabular}{llll}
2124 "2000--"206F&General Punctuation&
2125 "2070--"209F&Superscripts and Subscripts\\
2126 "20A0--"20CF&Currency Symbols&
2127 "20D0--"20FF&Comb.\ Diacritical Marks for Symbols\\
2128 "2100--"214F&Letterlike Symbols&
2129 "2150--"218F&Number Forms\\
2130 "2190--"21FF&Arrows&
2131 "2200--"22FF&Mathematical Operators\\
2132 "2300--"23FF&Miscellaneous Technical&
2133 "2400--"243F&Control Pictures\\
2134 "2500--"257F&Box Drawing&
2135 "2580--"259F&Block Elements\\
2136 "25A0--"25FF&Geometric Shapes&
2137 "2600--"26FF&Miscellaneous Symbols\\
2138 "2700--"27BF&Dingbats&
2139 "2900--"297F&Supplemental Arrows-B\\
2140 "2980--"29FF&Misc.\ Mathematical Symbols-B&
2141 "2B00--"2BFF&Miscellaneous Symbols and Arrows
2142 \end{tabular}
2143 \end{table}
2144 %<*en>
2145 \item[Range~4${}^{\text{A}}$] Characters usually not in Japanese fonts. This range consists
2146            of almost all Unicode blocks which are not in other
2147            predefined ranges. Hence, instead of showing the block list,
2148            we put the definition of this range itself:
2149 %</en>
2150 %<*ja>
2151 \item[範囲4${}^{\text{A}}$] 通常和文フォントには含まれていない文字.
2152                              この範囲は他の範囲にないほとんど全てのUnicodeブロック
2153                              で構成されている.したがって,ブロックのリストを示す
2154                              代わりに,範囲の定義そのものを示す:
2155 %</ja>
2156 \begin{lstlisting}
2157 \ltjdefcharrange{4}{%
2158    "500-"10FF, "1200-"1DFF, "2440-"245F, "27C0-"28FF, "2A00-"2AFF,
2159   "2C00-"2E7F, "4DC0-"4DFF, "A4D0-"A82F, "A840-"ABFF, "FB00-"FE0F,
2160   "FE20-"FE2F, "FE70-"FEFF, "10000-"1FFFF, "E000-"F8FF} % non-Japanese
2161 \end{lstlisting}
2162 %<en>\item[Range~5${}^{\text{A}}$] Surrogates and Supplementary Private Use Areas.
2163 %<ja>\item[範囲5${}^{\text{A}}$] 代用符号と補助私用領域.
2164 %<en>\item[Range~6${}^{\text{\kern.1emJ}}$] Characters used in Japanese. The block list is indicated in Table~\ref{table-rng6}.
2165 %<ja>\item[範囲6${}^{\text{\kern.1emJ}}$] 日本語で用いられる文字.ブロックのリストは表\ref{table-rng6}に示す.
2166 \begin{table}[!tb]
2167 %<en>\caption{Unicode blocks in predefined character range~6.}\medskip
2168 %<ja>\caption{文字範囲6に指定されているUnicodeブロック.}
2169 \label{table-rng6}
2170 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
2171 \centering\small
2172 \begin{tabular}{llll}
2173 "2460--"24FF&Enclosed Alphanumerics&
2174 "2E80--"2EFF&CJK Radicals Supplement\\
2175 "3000--"303F&CJK Symbols and Punctuation&
2176 "3040--"309F&Hiragana\\
2177 "30A0--"30FF&Katakana&
2178 "3190--"319F&Kanbun\\
2179 "31F0--"31FF&Katakana Phonetic Extensions&
2180 "3200--"32FF&Enclosed CJK Letters and Months\\
2181 "3300--"33FF&CJK Compatibility&
2182 "3400--"4DBF&CJK Unified Ideographs Extension A\\
2183 "4E00--"9FFF&CJK Unified Ideographs&
2184 "F900--"FAFF&CJK Compatibility Ideographs\\
2185 "FE10--"FE1F&Vertical Forms&
2186 "FE30--"FE4F&CJK Compatibility Forms\\
2187 "FE50--"FE6F&Small Form Variants&
2188 "{20}000--"{2F}FFF&(Supplementary Ideographic Plane)\\
2189 "{E0}100--"{E0}1EF&Variation Selectors Supplement
2190 \end{tabular}
2191 \end{table}
2192 %<*en>
2193 \item[Range~7${}^{\text{\kern.1emJ}}$] Characters used in CJK languages, but not included in  Adobe-Japan1-6.
2194 The block list is indicated in Table~\ref{table-rng7}.
2195 %</en>
2196 %<*ja>
2197 \item[範囲7${}^{\text{\kern.1emJ}}$] CJK言語で用いられる文字のうち,Adobe-Japan1-6に
2198                             含まれていないもの.
2199                             ブロックのリストは表\ref{table-rng7}に示す.
2200 %</ja>
2201 \begin{table}[!tb]
2202 %<en>\caption{Unicode blocks in predefined character range~7.}\medskip
2203 %<ja>\caption{文字範囲7に指定されているUnicodeブロック.}
2204 \label{table-rng7}
2205 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
2206 \centering\small
2207 \begin{tabular}{llll}
2208 "1100--"11FF&Hangul Jamo&
2209 "2F00--"2FDF&Kangxi Radicals\\
2210 "2FF0--"2FFF&Ideographic Description Characters&
2211 "3100--"312F&Bopomofo\\
2212 "3130--"318F&Hangul Compatibility Jamo&
2213 "31A0--"31BF&Bopomofo Extended\\
2214 "31C0--"31EF&CJK Strokes&
2215 "A000--"A48F&Yi Syllables\\
2216 "A490--"A4CF&Yi Radicals&
2217 "A830--"A83F&Common Indic Number Forms\\
2218 "AC00--"D7AF&Hangul Syllables&
2219 "D7B0--"D7FF&Hangul Jamo Extended-B
2220 \end{tabular}
2221 \end{table}
2222 \end{description}
2223
2224 %<en>\subsection{\Param{kanjiskip} and \Param{xkanjiskip}}
2225 %<ja>\subsection{\Param{kanjiskip}と\Param{xkanjiskip}}
2226 \label{subs-kskip}
2227
2228 %<en>\textbf{JAglue} is divided into the following three categories:
2229 %<ja>\textbf{JAglue}は以下の3つのカテゴリに分類される:
2230 \begin{itemize}
2231 %<*en>
2232 \item Glues/kerns specified in JFM. If \cs{inhibitglue} is issued
2233       around a \textbf{JAchar}, this glue will not be inserted at the
2234       place.
2235 %</en>
2236 %<*ja>
2237 \item JFMで指定されたグルー/カーン.もし \cs{inhibitglue} が\textbf{JAchar}の周りで
2238       発行されていれば,このグルーは挿入されない.
2239 %</ja>
2240 %<*en>
2241 \item The default glue which inserted between two \textbf{JAchar}s (\Param{%
2242       kanjiskip}).
2243 %</en>
2244 %<*ja>
2245 \item デフォルトで2つの\textbf{JAchar}の間に挿入されるグルー(\Param{kanjiskip}).
2246 %</ja>
2247 %<*en>
2248 \item The default glue which inserted between a \textbf{JAchar} and an
2249       \textbf{ALchar} (\Param{xkanjiskip}).
2250 %</en>
2251 %<*ja>
2252 \item デフォルトで\textbf{JAchar}と\textbf{ALchar}の間に挿入されるグルー(\Param{xkanjiskip}).
2253 %</ja>
2254 \end{itemize}
2255 %<*en>
2256 The value (a skip) of \Param{kanjiskip} or
2257 \Param{xkanjiskip} can be changed as the following.
2258 Note that only their values \emph{at the end of a paragraph or a hbox are
2259 adopted in the whole paragraph or the whole hbox.
2260 }
2261 %</en>
2262 %<*ja>
2263 \Param{kanjiskip}や\Param{xkanjiskip}の値
2264 は以下のようにして変更可能である.
2265 %</ja>
2266 \begin{lstlisting}
2267 \ltjsetparameter{kanjiskip={0pt plus 0.4pt minus 0.4pt},
2268                  xkanjiskip={0.25\zw plus 1pt minus 1pt}}
2269 \end{lstlisting}
2270 %<*en>
2271 Here \cs{zw} is a internal dimension
2272 which stores fullwidth of the current Japanese font.
2273 This \cs{zw} can be used as the unit \texttt{zw} in \pTeX.
2274
2275 The value of these parameter can be get by \cs{ltjgetparameter}.
2276 Note that the result by \cs{ltjgetparameter} is \emph{not} the internal quantities,
2277 but \emph{a string} (hence \cs{the} cannot be prefixed).
2278 %</en>
2279 %<*ja>
2280 ここで,\cs{zw} は現在の和文フォントの全角幅を表す長さであり,
2281 \pTeX における長さ単位 \texttt{zw} と同じように使用できる.
2282
2283 これらのパラメータの値は以下のように取得できる.
2284 戻り値は内部値ではなく\emph{文字列}である(\cs{the} は前置できない)ことに注意してほしい:
2285 %</ja>
2286 \begin{LTXexample}
2287 kanjiskip: \ltjgetparameter{kanjiskip},\\
2288 xkanjiskip: \ltjgetparameter{xkanjiskip}
2289 \end{LTXexample}
2290
2291 %<*en>
2292 It may occur that JFM contains the data of ``ideal width of
2293 \Param{kanjiskip}''
2294 and/or ``ideal width of \Param{xkanjiskip}''.
2295 To use these data from JFM, set the value of \Param{kanjiskip} or
2296 \Param{xkanjiskip} to \cs{maxdimen}
2297 (these ``ideal width'' cannot be retrived by \cs{ltjgetparameter}).
2298 %</en>
2299 %<*ja>
2300 JFMは「望ましい\Param{kanjiskip}の値」や
2301 「望ましい\Param{xkanjiskip}の値」を持っていることがある.
2302 これらのデータを使うためには,\Param{kanjiskip}や%
2303 \Param{xkanjiskip}の値を \cs{maxdimen} の値に設定すればよいが,
2304 \cs{ltjgetparameter} によって取得することはできないので注意が必要である.
2305 %</ja>
2306
2307 %<en>\subsection{Insertion Setting of \Param{xkanjiskip}}
2308 %<ja>\subsection{\Param{xkanjiskip} の挿入設定}
2309
2310 %<*en>
2311 It is not desirable that \Param{xkanjiskip} is inserted into every
2312 boundary between \textbf{JAchar}s and \textbf{ALchar}s. For example,
2313 \Param{xkanjiskip} should not be inserted after opening parenthesis
2314 (\textit{e.g.}, compare ``(あ'' and ``(\hskip\ltjgetparameter{xkanjiskip}あ'').
2315 \LuaTeX-ja can control whether \Param{xkanjiskip} can be inserted
2316 before/after a character, by changing \Param{jaxspmode} for \textbf{JAchar}s and
2317 \Param{alxspmode} parameters \textbf{ALchar}s respectively.
2318 %</en>
2319 %<*ja>
2320 \Param{xkanjiskip}がすべての\textbf{JAchar}と\textbf{ALchar}の境界に
2321 挿入されるのは望ましいことではない.例えば,\Param{xkanjiskip}は開き括弧の
2322 後には挿入されるべきではない(「(あ」と「(\hskip\ltjgetparameter{xkanjiskip}あ」を
2323 比べてみよ).
2324 \LuaTeX-jaでは\Param{xkanjiskip}をある文字の前/後に挿入するかどうかを,
2325 \textbf{JAchar}に対しては\Param{jaxspmode}を,\textbf{ALchar}に対しては
2326 \Param{alxspmode}をそれぞれ変えることで制御することができる.
2327 %</ja>
2328 \begin{LTXexample}
2329 \ltjsetparameter{jaxspmode={`あ,preonly}, alxspmode={`\!,postonly}}
2330 pあq い!う
2331 \end{LTXexample}
2332
2333 %<*en>
2334 The second argument \texttt{preonly} means that the insertion of
2335 \Param{xkanjiskip} is allowed before this character, but not after.
2336 the other possible values are \texttt{postonly}, \texttt{allow}, and \texttt{inhibit}.
2337 %</en>
2338 %<*ja>
2339 2つ目の引数の \texttt{preonly}は「\Param{xkanjiskip}の挿入はこの文字の
2340 前でのみ許され,後では許さない」ことを意味する.他に指定可能な値は
2341 \texttt{postonly}, \texttt{allow}, \texttt{inhibit}である.
2342 %</ja>
2343
2344 %<*en>
2345 \Param{jaxspmode} and \Param{alxspmode} use a same table to store the parameters
2346 on the current version. Therefore, line~1 in the code above can be rewritten
2347 as follows:
2348 %</en>
2349 %<*ja>
2350 なお,現行の
2351 仕様では,\Param{jaxspmode}, \Param{alxspmode}はテーブルを共有しており,
2352 上のコードの1行目を次のように変えても同じことになる:
2353 %</ja>
2354 \begin{lstlisting}
2355 \ltjsetparameter{alxspmode={`あ,preonly}, jaxspmode={`\!,postonly}}
2356 \end{lstlisting}
2357 %<*en>
2358 One can use also numbers to specify these two parameters (see Subsection~\ref{ssec-param}).
2359 %</en>
2360 %<*ja>
2361 また,これら2パラメータには数値で値を指定することもできる(\ref{ssec-param}節を参照).
2362 %</ja>
2363
2364 %<*en>
2365 If you want to enable/disable all insertions of \Param{kanjiskip} and
2366 \Param{xkanjiskip}, set \Param{autospacing} and \Param{autoxspacing}
2367 parameters to \texttt{true}/\texttt{false}, respectively.
2368 %</en>
2369 %<*ja>
2370 もし全ての\Param{kanjiskip}と\Param{xkanjiskip}の挿入を有効化/無効化
2371 したければ,それぞれ\Param{autospacing}と\Param{autoxspacing}を
2372 \texttt{true}/\texttt{false}に設定すればよい.
2373 %</ja>
2374
2375 %<en>\subsection{Shifting the baseline}
2376 %<ja>\subsection{ベースラインの移動}
2377 %<*en>
2378 To make a match between a Japanese font and an alphabetic font, sometimes
2379 shifting of the baseline of one of the pair is needed. In \pTeX, this is achieved
2380 by setting \cs{ybaselineshift} (or \cs{tbaselineshift}) to a non-zero length (the
2381 baseline of \textbf{ALchar} is shifted below). However, for documents
2382 whose main language is not Japanese, it is good to shift the baseline of
2383 Japanese fonts, but not that of alphabetic fonts.
2384 Because of this, \LuaTeX-ja can independently set the shifting amount
2385 of the baseline of alphabetic fonts and that of Japanese fonts.
2386 \begin{center}
2387  \small
2388 \begin{tabular}{>{\bfseries}lcc}
2389 \toprule
2390 &\bfseries Horizontal writing (\emph{yoko} direction) etc.
2391 &\bfseries Vertical writing(\emph{tate} direction)\\
2392 \midrule
2393 Alphabetic fonts&\Param{yalbaselineshift}
2394      parameter&\Param{talbaselineshift} parameter\\
2395 Japanese fonts&\Param{yjabaselineshift}
2396      parameter&\Param{tjabaselineshift} parameter\\
2397 \bottomrule
2398 \end{tabular}
2399 \end{center}
2400 %</en>
2401 %<*ja>
2402 和文フォントと欧文フォントを合わせるためには,時々どちらかのベースラインの移動が
2403 必要になる.\pTeX ではこれは \cs{ybaselineshift}(または\cs{tbaselineshift})を設定することで
2404 なされていた(\textbf{ALchar}のベースラインがその分だけ下がる).しかし,日本語が主ではない
2405 文書に対しては,欧文フォントではなく和文フォントのベースラインを移動した方がよい.
2406 このため,\LuaTeX-jaでは欧文フォントのベースラインのシフト量
2407 と和文フォントのベースラインのシフト量を独立に設定できるようになっている.
2408 \begin{center}
2409  \small
2410 \begin{tabular}{>{\bfseries}lcc}
2411 \toprule
2412 &\bfseries 横組など&\bfseries 縦組\\
2413 \midrule
2414 欧文フォントのシフト量&\Param{yalbaselineshift}
2415      parameter&\Param{talbaselineshift} parameter\\
2416 和文フォントのシフト量&\Param{yjabaselineshift}
2417      parameter&\Param{tjabaselineshift} parameter\\
2418 \bottomrule
2419 \end{tabular}
2420 \end{center}
2421 %</ja>
2422
2423 %<*en>
2424 Here the horizontal line in the below example is the baseline of a line.
2425 %</en>
2426 %<*ja>
2427 下の例において引かれている水平線がベースラインである.
2428 %</ja>
2429 \begin{LTXexample}
2430 \vrule width 150pt height 0.4pt depth 0pt \hskip-120pt
2431 \ltjsetparameter{yjabaselineshift=0pt, yalbaselineshift=0pt}abcあいう
2432 \ltjsetparameter{yjabaselineshift=5pt, yalbaselineshift=2pt}abcあいう
2433 \end{LTXexample}
2434
2435 %<*en>
2436 There is an interesting side-effect: characters in different size can be
2437 vertically aligned center in a line, by setting two parameters appropriately.
2438 The following is an example (beware the value is not well tuned):
2439 %</en>
2440 %<*ja>
2441 この機能には面白い使い方がある:2つのパラメータを適切に設定することで,サイズの
2442 異なる文字を中心線に揃えることができる.
2443 以下は一つの例である(値はあまり調整されていないことに注意):
2444 %</ja>
2445 \begin{LTXexample}
2446 xyz漢字
2447 {\scriptsize
2448   \ltjsetparameter{yjabaselineshift=-1pt,
2449     yalbaselineshift=-1pt}
2450   XYZひらがな
2451 }abcかな
2452 \end{LTXexample}
2453
2454 %<*en>
2455 Note that setting positive \Param{yalbaselineshift}~or~\Param{talbaselineshift}
2456 parameters does not increase the depth of one-letter \emph{syllable} $p$ of \textbf{Alchar}, if
2457 its left-protrusion~(\cs{lpcode}) and right-protrusion~(\cs{rpcode}) are both non-zero.
2458 This is because
2459 \begin{itemize}
2460 \item These two parameters are implemented by setting \texttt{yoffset} field of a
2461 glyph node, and this does not increase the depth of the glyph.
2462 \item To cope with the above situation, \LuaTeX-ja automatically supplies
2463 a rule in every syllable.
2464 \item However, we cannot use this ``supplying a rule'' method if a syllable comprises just
2465       one letter whose \cs{lpcode}~and~\cs{rpcode} are both non-zero.
2466 \end{itemize}
2467
2468 This problem does not apply for \Param{yjabaselineshift}~nor~\Param{tjabaselineshift},
2469 becuse a \emph{JAchar} is encapsulated by a horizontal box if needed.
2470 %</en>
2471 %<*ja>
2472 なお,以下の場合には1文字の\textbf{ALchar}からなる「音節」の深さは増加しないことに注意.
2473 \begin{itemize}
2474  \item \Param{yalbaselineshift},~\Param{talbaselineshift}パラメータが正になっている.
2475  \item 「音節」を構成する唯一の文字$p$の
2476 左余白への突出量(\cs{lpcode}),右余白への突出量(\cs{rpcode})がどちらも非零である.
2477 \end{itemize}
2478 \emph{JAchar}は必要に応じて1文字ずつボックスにカプセル化されるため,
2479 \Param{yjabaselineshift},~\Param{tjabaselineshift}パラメータについてはこのような問題は起こらない.
2480 %</ja>
2481
2482 %<*ja>
2483 \paragraph{数式における挙動:\pTeX との違い}
2484 \textbf{ALchar}のベースラインを補正する \Param{yalbaselineshift} パラメータは
2485 ほぼ\pTeX における \cs{ybaselineshift} に対応しているものであるが,
2486 数式中の挙動は異なっているので注意が必要である.
2487 例えば,表\ref{tab:math_bsa}のように,数式中に明示的に現れた \cs{hbox} は,
2488 \begin{itemize}
2489  \item \pTeX では,ボックス全体が \cs{ybaselineshift} だとシフトされるので,
2490  表\ref{tab:math_bsa}中の``い''のように,ボックス中の和文文字は
2491  \ \cs{ybaselineshift} だけシフトされ,一方,``for all''のように,
2492  ボックス内の欧文文字は2重にシフトされることになる.
2493  \item 一方,\LuaTeX-jaではそのようなことはおこらず,
2494  数式中に明示的に現れた \cs{hbox} はシフトしない.そのため,
2495  表\ref{tab:math_bsa}中の``い''も``for all''も,それぞれ本文中に
2496  書かれたときと同じ上下位置に組まれる.
2497 \end{itemize}
2498 \begin{table}
2499 \small\centering
2500 \caption{数式関係のベースライン補正($\Param{yalbaselineshift}=10\,\textrm{pt}$)}
2501 \label{tab:math_bsa}
2502 \newdimen\origbaselineskip
2503 \origbaselineskip=\baselineskip
2504 \begin{tabular}{lp{30\zw}}
2505 \toprule
2506 \emph{入力}&\vspace*{\dimexpr-\origbaselineskip-\smallskipamount}
2507 \begin{lstlisting}
2508 数式abc: $あa\hbox{い}$, $\int_0^x t\,dt=x^2\!/2$,
2509 $\Phi\vdash F(x)\ \hbox{for all}\ x\in A$
2510 \end{lstlisting}\\
2511 \noalign{\vskip-\origbaselineskip}
2512 \midrule
2513 \emph{\pTeX}&
2514 {\ltjsetparameter{yalbaselineshift=10pt}%
2515 数式abc: $あa\lower10pt\hbox{い}$, $\int_0^x t\,dt=x^2\!/2$,
2516 $\Phi\vdash F(x)\ \lower10pt\hbox{for all}\ x\in A$
2517 \par}\\
2518 \midrule
2519 \emph{\LuaTeX-ja}&
2520 {\ltjsetparameter{yalbaselineshift=10pt}%
2521 数式abc: $あa\hbox{い}$, $\int_0^x t\,dt=x^2\!/2$,
2522 $\Phi\vdash F(x)\ \hbox{for all}\ x\in A$
2523 \par}\\
2524 \noalign{\vskip-\origbaselineskip}
2525 \bottomrule
2526 \end{tabular}
2527 \end{table}
2528 %</ja>
2529
2530 %<*en>
2531 \subsection{\emph{kinsoku} parameters and OpenType features}
2532 Among parameters which related to Japanese word-wrapping process (\emph{kinsoku shori}),
2533 \begin{quote}
2534  \Param{jaxspmode},~\Param{alxspmode}, \Param{prebreakpenalty},
2535  \Param{postbreakpenalty}~and~\Param{kcatcode}
2536 \end{quote}
2537 are stored by each character codes. ...
2538
2539 For example, a fullwidth katakana ``ア'' on line~10 in the below input is replaced to
2540 its halfwidth variant ``ア'', by \verb+hwid+ feature.
2541 However, the penalty inserted after it is 10 which is the \Param{postbreakpenalty} of
2542 ``ア'', not 20.
2543 %</en>
2544 %<*ja>
2545 \subsection{禁則処理関連パラメータとfont feature}
2546 禁則処理や \Param{kanjiskip}, \Param{xkanjiskip} の挿入に関連したパラメータのうち
2547 \begin{quote}
2548  \Param{jaxspmode},~\Param{alxspmode}, \Param{prebreakpenalty},
2549  \Param{postbreakpenalty}, \Param{kcatcode}
2550 \end{quote}
2551 は,文字コードごとに設定する量である.
2552
2553 \Pkg{fontspec}パッケージを使う(\ref{ssec-fontspec}節)場合など,
2554 各種のOpenType featureを適用することもあると思うが,前段落に述べたパラメータ類は,
2555 \emph{OpenType featureの適用前の文字コードによって判定される.}
2556 例えば,以下の例において10行目の「ア」は,\verb+hwid+ featureの適用により半角カタカナの「ア」
2557 に置き換わる.しかし,その直後に挿入される \Param{postbreakpenalty}は,置換前の「ア」に対する値10である.
2558 %</ja>
2559
2560 \begin{LTXexample}[width=0.2\textwidth]
2561 \ltjsetparameter{postbreakpenalty={`ア, 10}}
2562 \ltjsetparameter{postbreakpenalty={`ア, 20}}
2563
2564 \newcommand\showpostpena[1]{%
2565   \leavevmode\setbox0=\hbox{#1\hbox{}}%
2566   \unhbox0\setbox0=\lastbox\the\lastpenalty}
2567
2568 \showpostpena{ア},
2569 \showpostpena{ア},
2570 {\addjfontfeatures{CharacterWidth=Half}\showpostpena{ア}}
2571 \end{LTXexample}
2572
2573 \clearpage
2574 %<en>\part{Reference}
2575 %<ja>\part{リファレンス}
2576 \label{part-ref}
2577 \suppressfloats[t]
2578 %<*ja>
2579 \section{\LuaTeX-jaにおける \cs{catcode}}
2580 \label{sec-catcode}
2581 \subsection{予備知識:\pTeX と\upTeX における \cs{kcatcode}}
2582 \pTeX,\upTeX においては,和文文字が制御綴内で利用できるかどうか
2583 は \cs{kcatcode} の値によって決定されるのであった.
2584 詳細は表\ref{table-kcat}を参照されたい.
2585 %</ja>
2586 %<*en>
2587 \section{\cs{catcode} in \LuaTeX-ja}
2588 \label{sec-catcode}
2589 \subsection{Preliminaries: \cs{kcatcode} in \pTeX\ and \upTeX}
2590 In \pTeX~and~\upTeX, the value of \cs{kcatcode} determines
2591 whether a Japanese character can be used in a control word.
2592 For the detail, see Table~\ref{table-kcat}.
2593 %</en>
2594
2595 \begin{table}[t]
2596 \small
2597 \caption{\cs{kcatcode} in \upTeX}
2598 \label{table-kcat}
2599 %<en>\medskip
2600
2601 \noindent\hfill
2602 \begin{tabular}{ccccc}
2603 \toprule
2604 \bfseries \cs{kcatcode}&
2605 %<*en>
2606 \bfseries meaning&
2607 \bfseries control word&
2608 \bfseries widow penalty\hbox{}$^*$&
2609 \bfseries linebreak\\
2610 %</en>
2611 %<*ja>
2612 \bfseries 意図&
2613 \bfseries 制御綴中に使用&
2614 \bfseries 文字ウィドウ処理\hbox{}$^*$&
2615 \bfseries 直後での改行\\
2616 %</ja>
2617 \midrule
2618 15&non-cjk&\multicolumn{3}{c}{(treated as usual \LaTeX)}\\
2619 16&kanji&Y&Y&ignored\\
2620 17&kana&Y&Y&ignored\\
2621 18&other&N&N&ignored\\
2622 19&hangul&Y&Y&space\\
2623 \bottomrule
2624 \end{tabular}\hfill\null
2625
2626 \medskip
2627
2628 %<*ja>
2629 文字ウィドウ処理\hbox{}$^*$: 「漢字が一文字だけ次の行に行くのを防ぐ」\
2630 \cs{jcharwidowpenalty} が,
2631 その文字の直前に挿入されうるか否か,を示す.
2632 %</ja>
2633 \end{table}
2634
2635 %<*en>
2636 \cs{kcatcode} can be set by a row of JIS~X~0208 in \pTeX,
2637 and generally by a Unicode block\footnote{%
2638   \upTeX\ divides \texttt{U+FF00}--\texttt{U+FFEF} (Halfwidth and Fullwidth Forms)
2639   into three subblocks, and \cs{kcatcode} can be set by a subblock.
2640 }
2641 in \upTeX. So characters which can be used in a control word
2642 slightly differ between \pTeX~and~\upTeX.
2643 %</en>
2644 %<*ja>
2645 \pTeX では \cs{kcatcode} はJIS~X~0208の区単位,
2646 \upTeX では概ねUnicodeブロック単位\footnote{%
2647   \texttt{U+FF00}--\texttt{U+FFEF} (Halfwidth and Fullwidth Forms)は
2648   「全角英数字」「半角カナ」「その他」と3つに分割されており,
2649   それぞれ別々に \cs{kcatcode} が指定できるようになっている.
2650 }で設定可能になっている.そのため,\pTeX と\upTeX の初期状態では
2651 制御綴内で使用可能な文字が微妙に異なっている.
2652 %</ja>
2653
2654 %<*en>
2655 \subsection{Case of \LuaTeX-ja}
2656 The role of \cs{kcatcode} in \pTeX~and~\upTeX\ can be
2657 divided into the following four kinds,
2658 and \LuaTeX-ja can control these four kinds separately:
2659 \begin{itemize}
2660  \item
2661 \emph{Distinction between \textbf{JAchar} or \textbf{ALchar}}
2662 is controlled by the character range, see Subsection~\ref{ssec-setrange}.
2663  \item
2664 \emph{Whether the character can be used in a control word}
2665 is controlled by setting \cs{catcode} to 11~(enabled) or 12~(disabled), as usual.
2666  \item
2667 \emph{Whether \Param{jcharwidowpenalty} can be inserted before the character}
2668 is controlled by the lowermost bit of the \Param{kcatcode} parameter.
2669  \item
2670 \emph{Linebreak after a \textbf{JAchar}} does not produce a space.
2671 \end{itemize}
2672 %</en>
2673 %<*ja>
2674 \subsection{\LuaTeX-jaの場合}
2675 \LuaTeX-jaでは,従来の\pTeX・\upTeX における \cs{kcatcode} の役割を
2676 分割している:
2677 \begin{description}
2678  \item[欧文/和文の区別 (\upTeX)]
2679 \cs{ltjdefcharrange} と\textsf{jacharrange}パラメータ(\ref{ssec-setrange}節)
2680  \item[制御綴中に使用可か]
2681 \LuaTeX 自身の \cs{catcode} でよい
2682  \item[\Param{jcharwidowpenalty}が挿入可か]
2683 \Param{kcatcode}パラメータの最下位ビット
2684  \item[直後の改行]
2685 日本語しか想定していないので,\textbf{JAchar}直後の改行で半角スペースが挿入されることはない.
2686 \end{description}
2687 %</ja>
2688
2689 %<*en>
2690 Default setting of \cs{catcode} of Unicode characters are located in
2691 \begin{description}
2692  \item[plain \LuaTeX] \texttt{luatex-unicode-letters.tex}, which is based on \texttt{unicode-letters.tex}
2693 (for \XeTeX).
2694  \item[\LuaLaTeX] now included in \LaTeX\ kernel  as~\texttt{unicode-letters.def}.
2695 \end{description}
2696 However, the default setting of \cs{catcode} differs
2697 between \XeTeX\ and \LuaTeX, by the following reasons:
2698 \begin{itemize}
2699  \item (plain format) \texttt{luatex-unicode-letters.tex} is based on old \texttt{unicode-letters.tex}.
2700  \item The latter half of \texttt{unicode-letters.tex}~and~\texttt{unicode-letters.def}
2701 sets\cs{catcode} of Kanji and kana characters to 11, via setting \cs{XeTeXcharclass}.
2702
2703 However, this latter half does not exist (plain case), or not executed (\LaTeX~case) in \LuaTeX, hence
2704 \cs{catcode} of Kanji and kana characters remains 12 in \LuaTeX.
2705 \end{itemize}
2706 In other words, Kanji nor kana characters cannot be used in
2707 a control word, in the default setting of \LuaTeX.
2708
2709 This would be inconvenient for \pTeX~users to shifting to \LuaTeX-ja,
2710 since several control words containing Kanji, such as \verb+\西暦+,
2711 are used in \pTeX.
2712 Hence, \LuaTeX-ja have a counterpart of \texttt{unicode-letters.tex}
2713 for \LuaTeX, \emph{to match the \cs{catcode} setting with that of \XeTeX.}
2714 %</en>
2715 %<*ja>
2716 ネイティブにUnicode全部の文字を扱える\XeTeX や\LuaTeX では,
2717 文字が制御綴内で使用できるかは通常の欧文文字と同じく \cs{catcode}
2718 で指定することとなる.plain \XeTeX における \cs{catcode} の初期設定は\
2719 \texttt{unicode-letters.tex} 中に記述されており,plain \LuaTeX ではそれを
2720 元にした \texttt{luatex-unicode-letters.tex} を用いている.
2721 \LaTeX では \cs{catcode} の設定はカーネルに \texttt{unicode-letters.def} として統合され.
2722 このファイルを\XeLaTeX, \LuaLaTeX の両方が用いている.
2723
2724
2725 だが,\XeTeX における \cs{catcode} の初期設定と
2726 \LuaTeX におけるそれは一致していない:
2727 \begin{itemize}
2728  \item \texttt{luatex-unicode-letters.tex} の元になった\
2729 \texttt{unicode-letters.tex} が古い
2730  \item \texttt{unicode-letters.tex} 後半部や \texttt{unicode-letters.def} 後半部では
2731 \cs{XeTeXcharclass} の設定を行なっており,
2732 それによって漢字や仮名の \cs{catcode} が11に設定されている.
2733
2734 しかし,\texttt{luatex-unicode-letters.tex} ではこの「後半部」が
2735 まるごと省略されており,また\LuaLaTeX でも \texttt{unicode-letters.def} 後半部は実行されな
2736        い.従って漢字や仮名の \cs{catcode} は12のままになっている.
2737 \end{itemize}
2738 言い換えると,\LuaTeX の初期状態では漢字や仮名を制御綴内に
2739 使用することはできない.
2740
2741 これでは \pTeX で使用できた \verb+\西暦+ などが使えないこととなり,
2742 \LuaTeX-jaへの移行で手間が生じる.そのため,\LuaTeX-jaでは
2743 \texttt{unicode-letters.tex} の後半部にあたる内容を自前でパッチし,
2744 結果として\textbf{\XeTeX における初期設定と同じになるようにしている.}
2745 %</ja>
2746
2747 \begin{table}
2748  \centering\small
2749 %<en>\caption{Difference of the set of non-kanji JIS~X~0208 characters which can be used in a control word}
2750 %<ja>\caption{制御綴中に使用出来るJIS~X~0208非漢字の違い}
2751 %<en>\medskip
2752 \label{table-kcat-diff}
2753 \def\D#1#2#3#4{%
2754   {\fboxsep0pt\fcolorbox{cyan}{white}%
2755   {\large\char"#1#2#3#4}}\ (\texttt{U+#1#2#3#4})} %"
2756 \leavevmode\hbox to 0pt{\hss\begin{tabular}{cccccc}
2757 \toprule
2758 %<en>&\bf row&\bf col.&\bf \pTeX&\bf \upTeX&\bf\LuaTeX-ja\\
2759 %<ja>&\bf 区&\bf 点&\bf \pTeX&\bf \upTeX&\fontseries{b}\selectfont\LuaTeX-ja\\
2760 \midrule
2761 %\D 3000&1&1&N&N&Y\\
2762 \D 30FB&1&6&N&Y&N\\
2763 \D 309B&1&11&N&Y&N\\
2764 \D 309C&1&12&N&Y&N\\
2765 \D FF40&1&14&N&N&Y\\
2766 \D FF3E&1&16&N&N&Y\\
2767 \D FFE3&1&17&N&N&Y\\
2768 \D FF3F&1&18&N&N&Y\\
2769 %\D 30FD&1&19&N&Y&Y\\
2770 %\D 30FE&1&20&N&Y&Y\\
2771 %\D 309D&1&21&N&Y&Y\\
2772 %\D 309E&1&22&N&Y&Y\\
2773 \D 3003&1&23&N&N&Y\\
2774 \D 4EDD&1&24&N&Y&Y\\
2775 \D 3005&1&25&N&N&Y\\
2776 \D 3006&1&26&N&N&Y\\
2777 \D 3007&1&27&N&N&Y\\
2778 \D 30FC&1&28&N&Y&Y\\
2779 \D FF0F&1&31&N&N&Y\\
2780 \D FF3C&1&32&N&N&Y\\
2781 \bottomrule
2782 \end{tabular}\qquad
2783 \begin{tabular}{cccccc}
2784 \toprule
2785 %<en>&\bf row&\bf col.&\bf \pTeX&\bf \upTeX&\bf\LuaTeX-ja\\
2786 %<ja>&\bf 区&\bf 点&\bf \pTeX&\bf \upTeX&\fontseries{b}\selectfont\LuaTeX-ja\\
2787 \midrule
2788 \D FF5C&1&35&N&N&Y\\
2789 \D FF0B&1&60&N&N&Y\\
2790 \D FF1D&1&65&N&N&Y\\
2791 \D FF1C&1&67&N&N&Y\\
2792 \D FF1E&1&68&N&N&Y\\
2793 \D FF03&1&84&N&N&Y\\
2794 \D FF06&1&85&N&N&Y\\
2795 \D FF0A&1&86&N&N&Y\\
2796 \D FF20&1&87&N&N&Y\\
2797 \D 3012&2&9&N&N&Y\\
2798 \D 3013&2&14&N&N&Y\\
2799 \D FFE2&2&44&N&N&Y\\
2800 \D 212B&2&82&N&N&Y\\
2801 %<en>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}Greek letters (row 6)}&Y&N&Y\\
2802 %<en>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}Cyrillic letters (row 7)}&N&N&Y\\
2803 %<ja>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}ギリシャ文字(6区)}&Y&N&Y\\
2804 %<ja>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}キリル文字(7区)}&N&N&Y\\
2805 \bottomrule
2806 \end{tabular}\hss}\par
2807 \end{table}
2808
2809 %<*en>
2810 \subsection{Non-kanji Characters in a Control Word}
2811 Because the engine differ, so non-kanji JIS~X~0208 characters
2812 which can be used in a control word differ in \pTeX, in \upTeX,~and~in \LuaTeX-ja.
2813 Table~\ref{table-kcat-diff} shows the difference.
2814 Except for four characters ``・'',~``゛'', ``゜'',~``゠'',
2815 \LuaTeX-ja admits more characters in a control word than \upTeX.
2816
2817 Difference becomes larger, if we consider
2818 non-kanji JIS~X~0213 characters.
2819 For the detail, see \url{https://github.com/h-kitagawa/kct}.
2820 %</en>
2821 %<*ja>
2822 \subsection{制御綴中に使用出来るJIS非漢字の違い}
2823
2824 エンジンが異なるので,\pTeX, \upTeX, \LuaTeX-ja
2825 において制御綴中に使用可能なJIS~X~0208の文字は異なる.
2826 異なっているところだけを載せると,表\ref{table-kcat-diff}のようになる.
2827 「・」「゛」「゜」「゠」を除けば,\LuaTeX-jaでは\upTeX より多くの文字が
2828 制御綴に使用可能になっている.
2829
2830 JIS~X~0213の範囲に広げると,差異はさらに大きくなる.
2831 詳細については例えば \url{https://github.com/h-kitagawa/kct} 中の\
2832 \texttt{kct-out.pdf} などを参照すること.
2833 %</ja>
2834
2835
2836 %<*en>
2837 \section{Directions}
2838 \LuaTeX\ supports four $\Omega$-style directions: \texttt{TLT},~\texttt{TRT}, \texttt{RTT}
2839 and \texttt{LTL}.
2840 However, neither directions are not well-suited for typesetting Japanese vertically, hence we
2841 implemented vertical writing by rotating \texttt{TLT}-box by 90~degrees.
2842 %</en>
2843 %<*ja>
2844 \section{縦組}
2845 \label{sec-direction}
2846 \LuaTeX 本体でも,$\Omega$・$\aleph$由来の機能として,複数の組方向をサポートしている.
2847 しかし,\LuaTeX がサポートするのは \texttt{TLT},~\texttt{TRT}, \texttt{RTT},~\texttt{LTL}\
2848 のみであり,日本語の縦組に使うのは望ましくない\footnote{%
2849 和文文字だけならば \texttt{RTT} を使えばなんとかなると思うが,
2850 欧文文字が入ってきた場合はうまくいかず,\texttt{RTR} という組方向が必要になる.
2851 }.そのため,\LuaTeX-jaでは横組(\texttt{TLT})で組んだボックスを回転させる方式で
2852 縦組を実装した.
2853 %</ja>
2854
2855 %<ja>\subsection{サポートする組方向}
2856 \begin{table}[t]
2857 %<ja>\caption{\LuaTeX-ja のサポートする組方向}
2858 %<en>\caption{Directions supported by \LuaTeX-ja}
2859 %<en>\medskip
2860 \label{tab-dir}
2861 \centering\small
2862 \def\obox#1{%
2863   \setbox0=\hbox{\yoko\hbox{#1%
2864   \large\ltjsetparameter{talbaselineshift=0pt}%
2865   \vrule height 25pt width 0.4pt depth 15pt\kern-.2pt%
2866   \raise25pt\hbox to 0pt{\hss\composite{*r^@{>>}}\hss}%
2867   \raise-15pt\hbox to 0pt{\hss\composite{*l^@{>|}}\hss}\kern.2pt%
2868   \vrule height.2pt depth.2pt width 60pt\hbox to 0pt{\hss\composite{*d^@{>}}\hss}\kern-60pt
2869   \hbox to 60pt{\,銀は、Ag\hss}}}%
2870   \raise\dimexpr 0.5\ltjgetdp0-0.5\ltjgetht0\box0%
2871 }
2872 %<*ja>
2873 \begin{tabular}{>{\bfseries}lcccc}
2874 \toprule
2875 &横組&縦組 &「dtou方向」&「utod方向」\\
2876 \midrule
2877 命令&\cs{yoko}&\cs{tate}&\cs{dtou}&\cs{utod}\\
2878 字送り方向&水平右向き(→)&垂直下向き(↓)&垂直上向き(↑)&垂直下向き(↓)\\
2879 行送り方向&垂直下向き(↓)&水平左向き(←)&水平右向き(→)&水平左向き(←)\\
2880 使用する和文フォント&横組用(\cs{jfont})&縦組用(\cs{tfont})&
2881 \multicolumn{2}{c}{%
2882   横組用(\cs{jfont})の$90^\circ$回転}\\[\smallskipamount]
2883 組版例\null $^*$ &\obox{\yoko}&\obox{\tate}&\obox{\dtou}&\obox{\utod}\\
2884 \noalign{\medskip}
2885 \bottomrule
2886 \end{tabular}
2887
2888 \medskip\raggedright
2889 \def\R#1{%
2890   \raise0.38\zw\hbox{%
2891     \vrule height.2pt  depth.2pt width2\zw%
2892     \hbox to 0pt{\hss\composite{*d^@{#1}}\hss}%
2893   }%
2894 }
2895 $^*$\ 幅(width),高さ(height),深さ(depth)の増加方向を,
2896 それぞれ「\R{>}」,「\R{>>}」,「\R{>|}」で表している.
2897 \raggedright
2898 %</ja>
2899
2900 %<*en>
2901 \begin{tabular}{>{\bfseries}lcccc}
2902 \toprule
2903 &horizontal (\emph{yoko}~direction)&vertical (\emph{tate}~direction)&%
2904   \emph{dtou} direction&\emph{utod} direction\\
2905 \midrule
2906 Commands&\cs{yoko}&\cs{tate}&\cs{dtou}&\cs{utod}\\
2907 Beginning of the page&Top&Right&Left&Right\\
2908 Beginning of the line&Left&Top&Bottom&Top\\
2909 Used Japanese font&horizontal (\cs{jfont})&vertical (\cs{tfont})&
2910 \multicolumn{2}{c}{%
2911   horizontal ($90^\circ$ rotated)}\\[\smallskipamount]
2912 Example&\obox{\yoko}&\obox{\tate}&\obox{\dtou}&\obox{\utod}\\
2913 \noalign{\medskip}
2914 (Notation used in $\Omega$)&TLT&RTR, RTT&LBL&RTR\\
2915 \bottomrule
2916 \end{tabular}
2917
2918 \medskip\raggedright
2919 \def\R#1{%
2920   \raise0.38\zw\hbox{%
2921     \vrule height.2pt  depth.2pt width2\zw%
2922     \hbox to 0pt{\hss\composite{*d^@{#1}}\hss}%
2923   }%
2924 }
2925 \raggedright
2926 %</en>
2927 \end{table}
2928
2929 %<*en>
2930 \LuaTeX-ja supports four directions, as shown in Table~\ref{tab-dir}.
2931 The second column (\emph{yoko} direction) is just horizontal writing,
2932 and the third column (\emph{tate} direction) is vertical writing.
2933 The fourth column (\emph{dtou} direction) is actually a hidden feature of \pTeX.
2934 We implemented this for debugging purpose.
2935 The fifth column (\emph{utod} direction) corresponds the ``\texttt{tate (math) direction}'' of \pTeX.
2936
2937 Directions can be changed by \cs{yoko},~\cs{tate}, \cs{dtou},~\cs{utod},
2938 only when the current list is null. Also, the direction of a math formula is changed to
2939 \emph{utod}, when the direction outside the math formula is \emph{tate} (vertical writing).
2940 %</en>
2941
2942 %<*ja>
2943 \LuaTeX-jaがサポートする組方向は表\ref{tab-dir}に示す4つである.
2944 4列目の \cs{dtou} は聞き慣れない命令だと思うが,
2945 実は\pTeX に同名の命令が(ドキュメントには書かれていないが)存在する.
2946 Down-TO-Upの意味なのだろう.\cs{dtou} を使用する機会はないだろうが,
2947 \LuaTeX-jaではデバッグ用に実装している.
2948 5列目の \cs{utod} は,\pTeX で言う「縦数式ディレクション」に相当するものである.
2949
2950 組方向は,\cs{yoko},~\cs{tate}, \cs{dtou},~\cs{utod} をそれぞれ使用することで,
2951 現在作成中のリストやボックスが空の時にのみ変更可能である.
2952 また,縦組中の数式内のボックスは\pTeX と同じように組方向が \cs{utod} となる.
2953 %</ja>
2954
2955 %<*en>
2956 \subsection{Boxes in different direction}
2957
2958 As in \pTeX, one can use boxes of different direction in one document.
2959 The below is an example.
2960 \begin{LTXexample}
2961 ここは横組%     yoko
2962 \hbox{\tate %   tate
2963   \hbox{縦組}%  tate
2964   の中に
2965   \hbox{\yoko 横組の内容}% yoko
2966   を挿入する
2967 }
2968 また横組に戻る% yoko
2969 \end{LTXexample}
2970
2971 Table~\ref{tab-diffdir} shows how a box is arranged when
2972 the direction  inside the box and that outside the box differ.
2973 %</en>
2974 %<*ja>
2975 \subsection{異方向のボックス}
2976
2977 縦組の中に「42」などの2桁以上の算用数字を横組で組むなど,
2978 異なる組方向を混在させることがしばしば行われる.
2979 組方向の混在も\pTeX と同じようにできる:
2980 \begin{LTXexample}
2981 ここは横組%     yoko
2982 \hbox{\tate %   tate
2983   \hbox{縦組}%  tate
2984   の中に
2985   \hbox{\yoko 横組の内容}% yoko
2986   を挿入する
2987 }
2988 また横組に戻る% yoko
2989 \end{LTXexample}
2990
2991 異なる組方向のボックスを配置した場合にどう組まれるかの仕様も,\pTeX を
2992 踏襲している.表\ref{tab-diffdir}に示す.
2993 %</ja>
2994
2995 \begin{table}[t]
2996 %<ja>\caption{異方向のボックスの配置}
2997 %<en>\caption{Boxes in different direction}
2998 %<en>\medskip
2999 \label{tab-diffdir}
3000  \centering\small\unitlength3mm
3001  \def\TATEeg{%
3002    \hbox{\smash{\begin{picture}(0,0)(-2,0)
3003      \thicklines
3004      \polyline(-2,0)(-2,-7)(5,-7)(5,0)
3005      \put(0,0){\circle*{0.3}}
3006      \put(2.5,-4){\makebox(0,0){\hbox{\tate\bfseries \emph{tate}/\emph{utod}}}}
3007      \put(0,0){\vector(1,0){5}} \put(2.5,-0.2){\makebox(0,0)[t]{$h_{\mathrm{T}}$}}
3008      \put(0,0){\vector(-1,0){2}}\put(-1,-0.2){\makebox(0,0)[t]{$d_{\mathrm{T}}$}}
3009      \put(0,0){\vector(0,-1){7}}\put(0.2,-3.5){\makebox(0,0)[l]{$w_{\mathrm{T}}$}}
3010    \end{picture}}}
3011  }
3012  \def\DTOUeg{%
3013    \hbox{\smash{\begin{picture}(0,0)(-5,0)
3014      \thicklines
3015      \polyline(-5,0)(-5,7)(2,7)(2,0)
3016      \put(0,0){\circle*{0.3}}
3017      \put(-2.5,4){\makebox(0,0){\hbox{\dtou\bfseries \emph{dtou}}}}
3018      \put(0,0){\vector(-1,0){5}} \put(-2.5,0.3){\makebox(0,0)[b]{$h_{\mathrm{D}}$}}
3019      \put(0,0){\vector(1,0){2}}\put(1,0.3){\makebox(0,0)[b]{$d_{\mathrm{D}}$}}
3020      \put(0,0){\vector(0,1){7}}\put(-0.2,3.5){\makebox(0,0)[r]{$w_{\mathrm{D}}$}}
3021    \end{picture}}}
3022  }
3023  \def\YOKOeg{%
3024    \hbox{\smash{\begin{picture}(0,0)
3025      \thicklines
3026      \polyline(0,5)(7,5)(7,-2)(0,-2)
3027      \put(4,2.5){\makebox(0,0){\hbox{\yoko\bfseries \emph{yoko}}}}
3028      \put(0,0){\circle*{0.3}}
3029      \put(0,0){\vector(0,1){5}} \put(0.3,2.5){\makebox(0,0)[l]{$h_{\mathrm{Y}}$}}
3030      \put(0,0){\vector(0,-1){2}}\put(0.3,-1){\makebox(0,0)[l]{$d_{\mathrm{Y}}$}}
3031      \put(0,0){\vector(1,0){7}}\put(3.5,0.2){\makebox(0,0)[b]{$w_{\mathrm{Y}}$}}
3032    \end{picture}}}
3033  }
3034 \begin{tabular}{ccc}
3035 \toprule
3036 %<ja>\emph{横組中に配置}&\emph{縦組中に配置}&%
3037 %<ja>\emph{組方向 \cs{dtou} 中に配置}\\
3038 %<en>\textbf{typeset in \emph{yoko} direction}
3039 %<en>&\textbf{typeset in \emph{tate} or \emph{utod} direction}
3040 %<en>&\textbf{typeset in \emph{dtou} direction}\\
3041 \midrule
3042  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3043    \put(0,0){\line(1,0){3.8}}
3044    \put(4,7){\TATEeg}
3045    \put(11.2,0){\line(1,0){3.8}}
3046 %
3047    \put(2,7){\line(1,0){1.8}}
3048    \put(3,3.5){\vector(0,1){3.5}\vector(0,-1){3.5}}
3049    \put(2.8,3.5){\makebox(0,0)[r]{$H_{\mathrm{Y}}$}}
3050    \put(3,-2){\vector(0,1){2}}
3051    \put(2.8,-1){\makebox(0,0)[r]{$D_{\mathrm{Y}}$}}
3052 %
3053    \put(4,7.2){\line(0,1){1.8}}
3054    \put(11,7.2){\line(0,1){1.8}}
3055    \put(6,8){\vector(-1,0){2}}
3056    \put(9,8){\vector(1,0){2}}
3057    \put(7.5,8){\makebox(0,0){$W_{\mathrm{Y}}$}}
3058 %
3059  \end{picture}\vspace{-\baselineskip}
3060    \begin{align*}
3061    W_{\mathrm{Y}} &= h_{\mathrm{T}}+d_{\mathrm{T}},\\
3062    H_{\mathrm{Y}} &= w_{\mathrm{T}},\\
3063    D_{\mathrm{Y}} &=0\,\mathrm{pt}
3064    \end{align*}%
3065  }&
3066  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3067    \put(7.5,-0.2){\line(0,-1){2.8}}
3068    \put(4,2){\YOKOeg}
3069    \put(7.5, 7.2){\line(0,1){3.8}}
3070 %
3071    \put(2,7){\line(1,0){1.8}}
3072    \put(2,0){\line(1,0){1.8}}
3073    \put(3,5){\vector(0,1){2}}
3074    \put(3,2){\vector(0,-1){2}}
3075    \put(3,3.5){\makebox(0,0){$W_{\mathrm{T}}$}}
3076 %
3077    \put(4,7.2){\line(0,1){1.8}}
3078    \put(11,7.2){\line(0,1){1.8}}
3079    \put(8,8){\vector(-1,0){0.5}\vector(1,0){3}}
3080    \put(7,8){\vector(-1,0){3}\vector(1,0){0.5}}
3081    \put(9.25,8.2){\makebox(0,0)[b]{$H_{\mathrm{T}}$}}
3082    \put(5.75,8.2){\makebox(0,0)[b]{$D_{\mathrm{T}}$}}
3083 %
3084  \end{picture}\vspace{-\baselineskip}
3085    \begin{align*}
3086    W_{\mathrm{T}} &= h_{\mathrm{Y}}+d_{\mathrm{Y}},\\
3087    H_{\mathrm{T}} &= w_{\mathrm{Y}}/2,\\
3088    D_{\mathrm{T}} &= w_{\mathrm{Y}}/2
3089    \end{align*}%
3090  }&
3091  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3092    \put(11,-0.2){\line(0,-1){2.8}}
3093    \put(4,2){\YOKOeg}
3094    \put(11, 7.2){\line(0,1){3.8}}
3095 %
3096    \put(2,7){\line(1,0){1.8}}
3097    \put(2,0){\line(1,0){1.8}}
3098    \put(3,5){\vector(0,1){2}}
3099    \put(3,2){\vector(0,-1){2}}
3100    \put(3,3.5){\makebox(0,0){$W_{\mathrm{D}}$}}
3101 %
3102    \put(4,7.2){\line(0,1){1.8}}
3103    \put(11,7.2){\line(0,1){1.8}}
3104    \put(7.5,8){\vector(-1,0){3.5}\vector(1,0){3.5}}
3105    \put(13,8){\vector(-1,0){2}}
3106    \put(7.5,8.2){\makebox(0,0)[b]{$H_{\mathrm{D}}$}}
3107    \put(12,8.2){\makebox(0,0)[b]{$D_{\mathrm{D}}$}}
3108 %
3109  \end{picture}\vspace{-\baselineskip}
3110    \begin{align*}
3111    W_{\mathrm{D}} &= h_{\mathrm{Y}}+d_{\mathrm{Y}},\\
3112    H_{\mathrm{D}} &= w_{\mathrm{Y}},\\
3113    D_{\mathrm{D}} &= 0\,\mathrm{pt}
3114    \end{align*}%
3115  }%
3116 \\\midrule
3117  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3118    \put(0,0){\line(1,0){3.8}}
3119    \put(4,0){\DTOUeg}
3120    \put(11.2,0){\line(1,0){3.8}}
3121 %
3122    \put(2,7){\line(1,0){1.8}}
3123    \put(3,3.5){\vector(0,1){3.5}\vector(0,-1){3.5}}
3124    \put(2.8,3.5){\makebox(0,0)[r]{$H_{\mathrm{Y}}$}}
3125    \put(3,-2){\vector(0,1){2}}
3126    \put(2.8,-1){\makebox(0,0)[r]{$D_{\mathrm{Y}}$}}
3127 %
3128    \put(4,7.2){\line(0,1){1.8}}
3129    \put(11,7.2){\line(0,1){1.8}}
3130    \put(6,8){\vector(-1,0){2}}
3131    \put(9,8){\vector(1,0){2}}
3132    \put(7.5,8){\makebox(0,0){$W_{\mathrm{Y}}$}}
3133 %
3134  \end{picture}\vspace{-\baselineskip}
3135    \begin{align*}
3136    W_{\mathrm{Y}} &= h_{\mathrm{D}}+d_{\mathrm{D}},\\
3137    H_{\mathrm{Y}} &= w_{\mathrm{D}},\\
3138    D_{\mathrm{Y}} &= 0\,pt
3139    \end{align*}%
3140  }&
3141  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3142    \put(9,-0.2){\line(0,-1){2.8}}
3143    \put(4,0){\DTOUeg}
3144    \put(9, 7.2){\line(0,1){3.8}}
3145 %
3146    \put(2,7){\line(1,0){1.8}}
3147    \put(2,0){\line(1,0){1.8}}
3148    \put(3,5){\vector(0,1){2}}
3149    \put(3,2){\vector(0,-1){2}}
3150    \put(3,3.5){\makebox(0,0){$W_{\mathrm{T}}$}}
3151 %
3152    \put(4,7.2){\line(0,1){1.8}}
3153    \put(11,7.2){\line(0,1){1.8}}
3154    \put(6.5,8){\vector(-1,0){2.5}\vector(1,0){2.5}}
3155    \put(10,8){\vector(-1,0){1}\vector(1,0){1}}
3156    \put(10,8.2){\makebox(0,0)[b]{$H_{\mathrm{T}}$}}
3157    \put(6.5,8.2){\makebox(0,0)[b]{$D_{\mathrm{T}}$}}
3158 %
3159  \end{picture}\vspace{-\baselineskip}
3160    \begin{align*}
3161    W_{\mathrm{T}} &= h_{\mathrm{D}}+d_{\mathrm{D}},\\
3162    H_{\mathrm{T}} &= d_{\mathrm{D}},\\
3163    D_{\mathrm{T}} &= h_{\mathrm{D}}
3164    \end{align*}%
3165  }&
3166  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
3167    \put(6,-0.2){\line(0,-1){2.8}}
3168    \put(4,7){\TATEeg}
3169    \put(6, 7.2){\line(0,1){3.8}}
3170 %
3171    \put(2,7){\line(1,0){1.8}}
3172    \put(2,0){\line(1,0){1.8}}
3173    \put(3,5){\vector(0,1){2}}
3174    \put(3,2){\vector(0,-1){2}}
3175    \put(3,3.5){\makebox(0,0){$W_{\mathrm{D}}$}}
3176 %
3177    \put(4,7.2){\line(0,1){1.8}}
3178    \put(11,7.2){\line(0,1){1.8}}
3179    \put(5,8){\vector(-1,0){1}\vector(1,0){1}}
3180    \put(8.5,8){\vector(-1,0){2.5}\vector(1,0){2.5}}
3181    \put(5,8.2){\makebox(0,0)[b]{$H_{\mathrm{D}}$}}
3182    \put(8.5,8.2){\makebox(0,0)[b]{$D_{\mathrm{D}}$}}
3183 %
3184  \end{picture}\vspace{-\baselineskip}
3185    \begin{align*}
3186    W_{\mathrm{D}} &= w_{\mathrm{T}},\\
3187    H_{\mathrm{D}} &= d_{\mathrm{T}},\\
3188    D_{\mathrm{D}} &= h_{\mathrm{T}}
3189    \end{align*}%
3190  }\\
3191 \bottomrule
3192 \end{tabular}
3193 \end{table}
3194
3195
3196
3197 %<*en>
3198 \paragraph{\cs{wd} and direction}
3199 In \pTeX, \cs{wd},~\cs{ht},~\cs{dp} means the dimensions of a box register
3200 \emph{with respact to the current direction}.
3201 This means that the value of \cs{wd0} etc.\ might differ when the current direction is
3202 different, even if \cs{box0} stores the same box.
3203 However, this no longer applies in \LuaTeX-ja.
3204
3205 \begin{LTXexample}
3206 % yoko direction
3207 \setbox0=\hbox to 20pt{foo}
3208 \the\wd0,~\hbox{\tate\vrule\the\wd0}
3209 \wd0=100pt
3210 \the\wd0,~\hbox{\tate \the\wd0}
3211 \end{LTXexample}
3212
3213 To access box dimensions \emph{with respect to current direction},
3214 one have to use the following commands instead of \cs{wd} wtc.
3215 \begin{cslist}
3216
3217  \item[\cs{ltjgetwd}<num>\textrm{, }\cs{ltjgetht}<num>\textrm{, }%
3218   \cs{ltjgetdp}<num>]
3219 These commands return \emph{an internal dimension} of \cs{box<num>} with respect to
3220 the current direction. One can use these in \cs{dimexpr} primitive, as the followings.
3221 \begin{lstlisting}
3222 \dimexpr 2\ltjgetwd42-3pt\relax, \the\ltjgetwd1701
3223 \end{lstlisting}
3224 The following is an example.
3225 \begin{LTXexample}[width=0.3\textwidth]
3226 \parindent0pt
3227 \setbox32767=\hbox{\yoko よこぐみ}
3228 \fboxsep=0mm\fbox{\copy32767}
3229 \vbox{\hsize=20mm
3230 \yoko YOKO \the\ltjgetwd32767, \\
3231   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3232 \vbox{\hsize=20mm\raggedleft
3233 \tate TATE \the\ltjgetwd32767, \\
3234   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3235 \vbox{\hsize=20mm\raggedleft
3236 \dtou DTOU \the\ltjgetwd32767, \\
3237   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3238 \end{LTXexample}
3239
3240  \item[\cs{ltjsetwd}<num>=<dimen>\textrm{, }\cs{ltjsetht}<num>=<dimen>\textrm{, }%
3241   \cs{ltjsetdp}<num>=<dimen>]
3242 These commands set the dimension of \cs{box<num>}. One does not need
3243         to group the argument <num>; four calls of \cs{ltjsetwd} below have the same meaning.
3244 \begin{lstlisting}
3245 \ltjsetwd42 20pt,  \ltjsetwd42=20pt,  \ltjsetwd=42 20pt,  \ltjsetwd=42=20pt
3246 \end{lstlisting}
3247
3248 \end{cslist}
3249 %</en>
3250 %<*ja>
3251 \paragraph{\cs{wd} 達と組方向}
3252 ボックスレジスタ \cs{box}<num> にセットされているボックスの幅・高さ・深さの取得や
3253 変更にはそれぞれ \cs{wd},~\cs{ht},~\cs{dp} プリミティブを用いるのであった.
3254 \pTeX ではこれらのプリミティブは,「現在の組方向におけるボックスの寸法」を指すもので,
3255 同じボックスに対しても現在の組方向によって返る値は異なるもであった.
3256
3257 \LuaTeX-jaにおいては状況が異なり,\cs{wd},~\cs{ht},~\cs{dp} が返す値は
3258 現在の組方向には依存しない.下の例のように,横組のボックスが格納されていれば
3259 \cs{wd}等は常に「横組におけるボックスの寸法」を意味する.
3260
3261 \begin{LTXexample}
3262 % yoko direction
3263 \setbox0=\hbox to 20pt{foo}
3264 \the\wd0,~\hbox{\tate\vrule\the\wd0}
3265 \wd0=100pt
3266 \the\wd0,~\hbox{\tate \the\wd0}
3267 \end{LTXexample}
3268
3269 \pTeX のように現在の組方向に応じたボックスの寸法の取得・設定を行うには,
3270 代わりに次の命令を使用する.
3271
3272 \begin{cslist}
3273
3274  \item[\cs{ltjgetwd}<num>\textrm{, }\cs{ltjgetht}<num>\textrm{, }%
3275   \cs{ltjgetdp}<num>]
3276 現在の組方向に応じたボックスの寸法の取得を行う.結果は内部長さであるため,
3277 \begin{lstlisting}
3278 \dimexpr 2\ltjgetwd42-3pt\relax, \the\ltjgetwd1701
3279 \end{lstlisting}
3280 のように \cs{wd}<num> の代わりとして扱うことができる.
3281 使用例は以下の通りである.
3282 \begin{LTXexample}[width=0.3\textwidth]
3283 \parindent0pt
3284 \setbox32767=\hbox{\yoko よこぐみ}
3285 \fboxsep=0mm\fbox{\copy32767}
3286 \vbox{\hsize=20mm
3287 \yoko YOKO \the\ltjgetwd32767, \\
3288   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3289 \vbox{\hsize=20mm\raggedleft
3290 \tate TATE \the\ltjgetwd32767, \\
3291   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3292 \vbox{\hsize=20mm\raggedleft
3293 \dtou DTOU \the\ltjgetwd32767, \\
3294   \the\ltjgetht32767, \\ \the\ltjgetdp32767.}
3295 \end{LTXexample}
3296
3297  \item[\cs{ltjsetwd}<num>=<dimen>\textrm{, }\cs{ltjsetht}<num>=<dimen>\textrm{, }%
3298   \cs{ltjsetdp}<num>=<dimen>]
3299 現在の組方向に応じたボックスの寸法の設定を行う.\cs{afterassignment} を2回利用して
3300 実装しているので,次の4通りは全て同じ意味である.
3301 \begin{lstlisting}
3302 \ltjsetwd42 20pt,  \ltjsetwd42=20pt,  \ltjsetwd=42 20pt,  \ltjsetwd=42=20pt
3303 \end{lstlisting}
3304
3305 設定値は「横組」「縦組及び \cs{utod} 方向」「\cs{dtou} 方向」
3306 の3種ごとに独立して記録される.参考として,Gitリポジトリ内の
3307               \verb+test/test55-boxdim_diffdir.{tex,pdf}+ を挙げておく.
3308
3309 \end{cslist}
3310 %</ja>
3311
3312 %<*en>
3313 \subsection{Getting current direction}
3314 The \Param{direction} parameter returns the current direction, and
3315 the \Param{boxdir} parameter (with the argument <num>)
3316 returns the direction of a box register \cs{box}<num>.
3317 The returned value of these parameters are a \emph{string}:
3318 \begin{center}
3319 \small
3320 \begin{tabular}{>{\bfseries}lccccc}
3321 \toprule
3322 Direction&\emph{yoko}&\emph{tate}&\emph{dtou}&\emph{utod}&(empty)\\
3323 \midrule
3324 Returned value&\texttt{4}&\texttt{3}&\texttt{1}&\texttt{11}&\texttt{0}\\
3325 \bottomrule
3326 \end{tabular}
3327 \end{center}
3328 \begin{LTXexample}[width=0.3\textwidth]
3329 \leavevmode\def\DIR{\ltjgetparameter{direction}}
3330 \hbox{\yoko \DIR}, \hbox{\tate\DIR},
3331 \hbox{\dtou\DIR}, \hbox{\utod\DIR},
3332 \hbox{\tate$\hbox{tate math: \DIR}$}
3333
3334 \setbox2=\hbox{\tate}\ltjgetparameter{boxdir}{2}
3335 \end{LTXexample}
3336 %</en>
3337 %<*ja>
3338 \subsection{組方向の取得}
3339 「現在の組方向」や「<num>番のボックスの組方向」は,
3340 \pTeX では \cs{ifydir} や \cs{ifybox}<num> といった条件判断文を使って
3341 判断することができた.
3342 しかし,\LuaTeX-jaはあくまでも\TeX マクロとLuaコードで
3343 記述されており,それでは新たな条件判断命令を作るのは難しい.
3344
3345 \LuaTeX-jaでは,\Param{direction}パラメータで現在の組方向を,
3346 \Param{boxdir}パラメータ(と追加の引数<num>)によって
3347 \cs{box}<num>の組方向をそれぞれ取得できるようにした.
3348 戻り値は文字列である:
3349 \begin{center}
3350 \small
3351 \begin{tabular}{>{\bfseries}lccccc}
3352 \toprule
3353 組方向&\emph{横組}&\emph{tate縦組}&\emph{dtou方向}&\emph{utod方向}&(未割り当て)\\
3354 \midrule
3355 戻り値&\texttt{4}&\texttt{3}&\texttt{1}&\texttt{11}&\texttt{0}\\
3356 \bottomrule
3357 \end{tabular}
3358 \end{center}
3359
3360 \begin{LTXexample}[width=0.3\textwidth]
3361 \leavevmode\def\DIR{\ltjgetparameter{direction}}
3362 \hbox{\yoko\DIR}, \hbox{\tate\DIR},
3363 \hbox{\dtou\DIR}, \hbox{\utod\DIR},
3364 \hbox{\tate$\hbox{tate math: \DIR}$}
3365
3366 \setbox2=\hbox{\tate}\ltjgetparameter{boxdir}{2}
3367 \end{LTXexample}
3368
3369 これらを用いれば,例えば
3370 \pTeX の \cs{ifydir},~\cs{ifybox200} と同等の条件判断を
3371 \begin{lstlisting}
3372 \ifnum\ltjgetparameter{direction}=4
3373 \ifnum\ltjgetparameter{boxdir}{200}=4
3374 \end{lstlisting}
3375 のように行うことができる.
3376 \cs{iftdir} は少々面倒であるが,8で割った余りが3であるか否かを判断すれば良いから
3377 \begin{lstlisting}
3378 \ifnum\numexpr
3379   \ltjgetparameter{direction}-(\ltjgetparameter{direction}/8)*8=3
3380 \end{lstlisting}
3381 とすればよい.
3382 %</ja>
3383
3384 %<*en>
3385 \subsection{Overridden box primitives}
3386 To cope with multiple directions, the following primitives are
3387 overridden by \LuaTeX-ja, using~\verb+\protected\def+.
3388 \begin{cslist}[style=standard]
3389  \item[\cs{unhbox}<num>\textrm{, }\cs{unvbox}<num>\textrm{, }\cs{unhcopy}<num>\textrm{, }\cs{unvcopy}<num>]
3390  \item[\cs{vadjust}\{<material>\}]
3391  \item[\cs{insert}<number>\{<material>\}]
3392  \item[\cs{lastbox}]
3393  \item[\cs{raise}<dimen><box>\textrm{, }\cs{lower}<dimen><box>\textrm{\ etc., }\cs{vcenter}]
3394  \item[\cs{vcenter}]
3395 \end{cslist}
3396 %</en>
3397 %<*ja>
3398 \subsection{プリミティブの再定義}
3399 異なる組方向に対応するために,以下に挙げるプリミティブは
3400 \LuaTeX-jaによる前処理もしくは後処理が行われるように
3401 \ \verb+\protected\def+ により再定義してある.
3402
3403 \begin{cslist}
3404  \item[\cs{unhbox}<num>\textrm{, }\cs{unvbox}<num>\textrm{, }\cs{unhcopy}<num>\textrm{, }\cs{unvcopy}<num>]
3405  ボックスの組方向が現在のリストと異なる場合は事前にエラーメッセージを出力する.
3406  \pTeX と異なり,エラーを無視して無理矢理 \cs{unhbox}, \cs{unvbox} を
3407  続行させることもできるが,その場合の組版結果は保証しない.
3408  \item[\cs{vadjust}\{<material>\}] 一旦プリミティブ本来の挙動を行う.その後,<material>の組方向が
3409  周囲の垂直リストの組方向と一致しない場合にエラーを出力し,
3410  該当の \cs{vadjust} を無効にする.
3411  \item[\cs{insert}<number>\{<material>\}]
3412  一旦プリミティブ本来の挙動を行い,その後<material>内の各ボックス・罫線の直前に組方向を示
3413               すdirection whatsitを挿入する.
3414  \item[\cs{lastbox}] ボックスの「中身」を現在の組方向に合わせるためのノード
3415               (\textit{dir\_box}という)を必要ならば除去し,
3416  正しく「中身」のボックスが返されるように前処理をする.
3417  \item[\cs{raise}<dimen><box>\textrm{, }\cs{lower}<dimen><box>\textrm{\ etc., }\cs{vcenter}]
3418  一方,こちらでは必要に応じて\textit{dir\_box}を作成する前処理を追加している.
3419 \end{cslist}
3420 %</ja>
3421
3422 %<en>\section{Font Metric and Japanese Font}
3423 %<ja>\section{フォントメトリックと和文フォント}
3424 %<en>\subsection{\cs{jfont}}
3425 %<ja>\subsection{\cs{jfont} 命令}
3426 \label{ssec-jfont}
3427
3428 %<*en>
3429 To load a font as a Japanese font (for horizontal direction), you must use the
3430 \cs{jfont} instead of~\cs{font}, while
3431 \cs{jfont} admits the same syntax used in~\cs{font}.
3432 \LuaTeX-ja automatically loads \Pkg{luaotfload} package,
3433 so TrueType/OpenType fonts with features can be used for Japanese fonts:
3434 %</en>
3435 %<*ja>
3436 フォントを(横組用)和文フォントとして読み込むためには,\cs{jfont} を
3437 \ \cs{font} プリミティブの代わりに用いる.
3438 \cs{jfont} の文法は \cs{font} と同じである.
3439 \LuaTeX-jaは\Pkg{luaotfload}パッケージを自動的に読み込むので,
3440 TrueType/OpenTypeフォントにfeatureを指定したものを和文フォントとして用いる
3441 ことができる:
3442 %</ja>
3443 \begin{LTXexample}[width=0.3\textwidth]
3444 \jfont\tradgt={file:KozMinPr6N-Regular.otf:script=latn;%
3445   +trad;-kern;jfm=ujis} at 14pt
3446 \tradgt 当/体/医/区
3447 \end{LTXexample}
3448
3449 %<*en>
3450 Note that the defined control sequence
3451 (\cs{tradgt} in the example above) using \cs{jfont} is not a
3452 \textit{font\_def} token,  but a macro.
3453 Hence the input like \verb+\fontname\tradgt+
3454 causes a error.  We denote control sequences which are defined in
3455 \cs{jfont} by <jfont\_cs>.
3456 %</en>
3457 %<*ja>
3458 なお,\cs{jfont} で定義された制御綴(上の例だと \cs{tradgt})
3459 は\textit{font\_def}トークンではなくマクロである.従って,\verb+\fontname\tradgt+ のような
3460 入力はエラーとなる.以下では \cs{jfont} で定義された
3461 制御綴を<jfont\_cs>で表す.
3462 %</ja>
3463
3464 \paragraph{JFM}
3465 %<*en>
3466 a JFM has measurements of characters and
3467 glues/kerns that are automatically inserted for Japanese
3468 typesetting. The structure of JFM will be described in the next
3469 subsection. At the calling of \cs{jfont}, you must specify
3470 which JFM will be used for this font by the following keys:
3471 %</en>
3472 %<*ja>
3473 JFMは文字と和文組版で自動的に挿入される
3474 グルー/カーンの寸法情報を持っている.JFMの構造は次の節で述べる.
3475 \cs{jfont} 命令の呼び出しの際には,どのJFMを用いるのかを以下のキーで
3476 指定する必要がある:
3477 %</ja>
3478
3479
3480 \begin{table}[t]
3481 %<en>\caption{Differences between horizontal JFMs shipped with \LuaTeX-ja}
3482 %<ja>\caption{\LuaTeX-ja に同梱されている横組用JFMの違い}
3483 %<en>\medskip
3484 \label{tab-difjfm}
3485 \ltjsetparameter{jacharrange={+3}}
3486 \centering\small
3487 \def\r#1#2{%
3488   \hbox{\Large\vrule
3489   \parbox[b]{7\zw}{%
3490     \addjfontfeatures{YokoFeatures={Opacity=0.5, Color=#2, JFM=#1}}\noindent
3491     ◆◆◆◆◆◆◆
3492     ある日モモちゃんがお使いで迷子になって泣きました.
3493   }\vrule}}
3494 \def\s#1#2{%
3495   \Large
3496   \parbox[b]{7\zw}{%
3497     \addjfontfeatures{YokoFeatures={Opacity=0.5, Color=#2, JFM=#1}}\noindent
3498     ちょっと!何
3499   }}
3500 \def\t#1#2#3{\hbox to 0pt{\hss%
3501   \setbox0=\hbox{\addjfontfeatures{YokoFeatures={JFM=#1}}\huge #3}%
3502   \textcolor{#2}{\transparent{0.5}\vrule width 0.4pt height\ht0 depth\dp0}\kern-.2pt\copy0
3503   \textcolor{#2}{\transparent{0.5}\kern-\wd0\vrule width\wd0height .2pt depth .2pt
3504   \kern-\wd0\raise\ht0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3505   \kern-\wd0\lower\dp0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3506   \kern-.2pt\vrule width 0.4pt height\ht0 depth \dp0}\hss}}
3507 {\Large\tabcolsep0pt
3508 \begin{tabular}{m{8\zw}m{8\zw}m{8\zw}}
3509 \leavevmode\hbox to 0pt{\r{ujis}{blue}\hss}\r{jis}{black}&
3510 \leavevmode\hbox to 0pt{\r{jis}{black}\hss}\r{min}{red}&
3511 \leavevmode\hbox to 0pt{\r{ujis}{blue}\hss}\r{min}{red}\\
3512 \leavevmode\hbox to 0pt{\s{ujis}{blue}\hss}\s{jis}{black}&
3513 \leavevmode\hbox to 0pt{\s{jis}{black}\hss}\s{min}{red}&
3514 \leavevmode\hbox to 0pt{\s{ujis}{blue}\hss}\s{min}{red}\\
3515 \leavevmode\qquad\t{ujis}{blue}{漢}\t{jis}{black}{漢}\qquad
3516            \t{ujis}{blue}{っ}\t{jis}{black}{っ}&
3517 \leavevmode\qquad\t{jis}{black}{漢}\t{min}{red}{漢}\qquad
3518            \t{jis}{black}{っ}\t{min}{red}{っ}&
3519 \leavevmode\qquad\t{ujis}{blue}{漢}\t{min}{red}{漢}\qquad
3520            \t{ujis}{blue}{っ}\t{min}{red}{っ}\\
3521 \end{tabular}\par}
3522
3523 (\textcolor{blue}{Blue: \texttt{jfm-ujis.lua}},
3524 \textcolor{black}{Black: \texttt{jfm-jis.lua}},
3525 \textcolor{red}{Red: \texttt{jfm-min.lua}})
3526 \ltjsetparameter{jacharrange={-3}}
3527 \end{table}
3528
3529 \begin{cslist}
3530 \item[jfm=<name>]
3531 %<*en>
3532 Specify the name of (horizontal) JFM.
3533 If specified JFM has not been loaded, \LuaTeX-ja search and load
3534 a file named \texttt{jfm-<name>.lua}.
3535
3536 The following JFMs are shipped with \LuaTeX-ja:
3537 %</en>
3538 %<*ja>
3539 用いる(横組用)JFMの名前を指定する.もし以前に指定されたJFMが読み込まれていなければ,
3540 \texttt{jfm-<name>.lua}を読み込む.以下の横組用JFMが\LuaTeX-jaには同梱されている:
3541 %</ja>
3542 \begin{description}
3543 %<*en>
3544 \item[\tt jfm-ujis.lua] A standard JFM in \LuaTeX-ja. This JFM is
3545   based on \verb+upnmlminr-h.tfm+, a metric for UTF/OTF package that
3546   is used in \upTeX. When you use the \Pkg{luatexja-otf} package, you should use this JFM.
3547 %</en>
3548 %<*ja>
3549 \item[\tt jfm-ujis.lua] \LuaTeX-jaの標準JFMである.このJFMは\upTeX で
3550   用いられるUTF/OTFパッケージ用の和文用TFMである \verb+upnmlminr-h.tfm+ を
3551   元にしている.\Pkg{luatexja-otf}パッケージを使うときはこのJFMを指定するべきである.
3552 %</ja>
3553 %<*en>
3554 \item[\tt jfm-jis.lua] A counterpart for \verb+jis.tfm+, ``JIS font
3555   metric'' which is widely used in \pTeX. A major difference between
3556   \texttt{jfm-ujis.lua} and this \texttt{jfm-jis.lua} is that
3557   most characters under \texttt{jfm-ujis.lua} are square-shaped,
3558   while that under \texttt{jfm-jis.lua} are horizontal
3559   rectangles.
3560 %</en>
3561 %<*ja>
3562 \item[\tt jfm-jis.lua] \pTeX で広く用いられている「JISフォントメトリック」
3563   \verb+jis.tfm+ に相当するJFMである.\texttt{jfm-ujis.lua} とこの
3564   \texttt{jfm-jis.lua} の主な違いは,\texttt{jfm-ujis.lua} ではほとんどの文字が
3565   正方形状であるのに対し,\texttt{jfm-jis.lua} では横長の長方形状であることと,
3566   \texttt{jfm-ujis.lua} では「?」「!」の直後に半角空白が挿入されることである.
3567 %</ja>
3568 %<*en>
3569 \item[\tt jfm-min.lua] A counterpart for \verb+min10.tfm+, which is one
3570   of the default Japanese font metric shipped with \pTeX.
3571 %</en>
3572 %<*ja>
3573 \item[\tt jfm-min.lua] \pTeX に同梱されているデフォルトの和文用TFM
3574 (\verb+min10.tfm+)に相当し,行末で文字が揃うようにするために「っ」など一部の文字幅が変わっ
3575            ている.\verb+min10.tfm+ については\cite{min10}が詳しい.
3576 %</ja>
3577 \end{description}
3578 %<*en>
3579 The difference among these three~JFMs is  shown in Table~\ref{tab-difjfm}.
3580 %</en>
3581 %<*ja>
3582 これら3つのJFMの違いは表\ref{tab-difjfm}に示した.表中の文例の一部には,
3583 \cite{min10}の図3,~4のものを用いた.
3584 %</ja>
3585
3586 \begin{figure}
3587 \begin{LTXexample}[width=0.3\textwidth]
3588 \ltjsetparameter{differentjfm=both}
3589 \jfont\F=file:KozMinPr6N-Regular.otf:jfm=ujis
3590 \jfont\G=file:KozGoPr6N-Medium.otf:jfm=ujis
3591 \jfont\H=file:KozGoPr6N-Medium.otf:jfm=ujis;jfmvar=hoge
3592 \F ){\G 【】}( % halfwidth space
3593    ){\H 『』}( % fullwidth space
3594
3595 ほげ,{\G 「ほげ」}(ほげ)\par
3596 ほげ,{\H 「ほげ」}(ほげ)% pTeX-like
3597
3598 \ltjsetparameter{differentjfm=paverage}
3599 \end{LTXexample}
3600 \caption{Example of \texttt{jfmvar} key}
3601 \label{fig:jfmvar}
3602 \end{figure}
3603
3604 %<*en>
3605 \item[jfmvar=<string>]
3606 Sometimes there is a need that \ldots.
3607 %</en>
3608 %<*ja>
3609 \item[jfmvar=<string>]
3610 標準では,JFMとサイズが同じで,
3611   実フォントだけが異なる2つの和文フォントは「区別されない」.例えば
3612 図\ref{fig:jfmvar}において,最初の「)」と「【」の実フォントは異なるが,
3613 JFMもサイズも同じなので,普通に「)【」と入力した時と同じように半角空きとなる.
3614
3615 しかし,JFMとサイズが同じであっても,\texttt{jfmvar} キーの異なる
3616 2つの和文フォント,例えば図\ref{fig:jfmvar}で言う \cs{F} と \cs{H},
3617 は「区別される」.異なる和文フォントに異なる \texttt{jfmvar} キーを割り当て,
3618 かつ\Param{differentjfm}パラメータを \texttt{both} に設定すれば,
3619 \pTeX と似た状況で組版されることになる.
3620 %</ja>
3621 \end{cslist}
3622
3623 \begin{figure}
3624 \begin{LTXexample}[pos=t]
3625 \newcommand\test{\vrule ダイナミックダイクマ\vrule\\}
3626 \jfont\KMFW = KozMinPr6N-Regular:jfm=prop;-kern at 17pt
3627 \jfont\KMFK = KozMinPr6N-Regular:jfm=prop at 17pt % kern is activated
3628 \jfont\KMPW = KozMinPr6N-Regular:jfm=prop;script=dflt;+pwid;-kern at 17pt
3629 \jfont\KMPK = KozMinPr6N-Regular:jfm=prop;script=dflt;+pwid;+kern at 17pt
3630 \begin{multicols}{2}
3631 \ltjsetparameter{kanjiskip=0pt}
3632 {\KMFW\test \KMFK\test \KMPW\test \KMPK\test}
3633
3634 \ltjsetparameter{kanjiskip=3pt}
3635 {\KMFW\test \KMFK\test \KMPW\test \KMPK\test}
3636 \end{multicols}
3637 \end{LTXexample}
3638 \caption{Kerning information and \Param{kanjiskip}}
3639 \label{fig:kern-jfm}
3640 \end{figure}
3641
3642 %<en>\paragraph{Using kerning information in a font}
3643 %<ja>\paragraph{ペアカーニング情報の使用}
3644 \label{para-kern}
3645 %<*en>
3646 Some fonts have information for inter-glyph spacing.
3647 This version of \LuaTeX-ja treats kerning spaces like an italic correction;
3648 any glue and/or kern from the JFM and a kerning space can coexist.
3649 See Figure~\ref{fig:kern-jfm} for detail.
3650
3651 Note that in \cs{setmainjfont} etc.\ which are provided by \Pkg{luatexja-fontspec}
3652 package, kerning option is set \emph{off} (\texttt{Kerning=Off}) by default,
3653 because of the compatibility with previous versions of \LuaTeX-ja.
3654 %</en>
3655 %<*ja>
3656 いくつかのフォントはグリフ間のスペースについての情報を持っている.
3657 このカーニング情報は以前の\LuaTeX-ja とはあまり相性が良くなかったが,
3658 本バージョンではカーニングによる空白はイタリック補正と同様に扱うことになっている.
3659 つまり,カーニング由来の空白とJFM由来のグルー・カーンは同時に入りうる.
3660 図\ref{fig:kern-jfm}を参照.
3661 \begin{itemize}
3662  \item \emph{\cs{jfont} や,
3663 NFSS2用の命令(\ref{ssec-chgfnt}節,\ref{ssec-nfsspat}節)における指定では
3664 カーニング情報は標準で使用する}ことになっているようである.
3665 言い換えれば,カーニング情報を使用しない設定にするには,面倒でも
3666 \begin{lstlisting}
3667 \jfont\hoge=KozMinPr6N-Regular:jfm=ujis;-kern at 3.5mm
3668 \DeclareFontShape{JY3}{fuga}{m}{n} {<-> s*KozMinPr6N-Regular:jfm=ujis;-kern}{}
3669 \end{lstlisting}
3670 のように,\texttt{-kern} という指定を自分で追加しなければいけない.
3671  \item
3672 一方,\emph{\Pkg{luatexja-fontspec} の提供する \cs{setmainjfont}\
3673 などの命令の標準設定ではカーニング情報は使用しない}(\texttt{Kerning=Off})
3674 ことになっている.これは以前のバージョンの\LuaTeX-jaとの互換性のためである.
3675 \end{itemize}
3676 %</ja>
3677
3678 %<*ja>
3679 \paragraph{\texttt{extend}と\texttt{slant}}
3680 OpenType font featureと見かけ上同じような形式で指定できるものに,
3681 \begin{description}
3682 \item[\texttt{extend=}<extend>] 横方向に<extend>倍拡大する.
3683 \item[\texttt{slant=}<slant>] <slant>に指定された割合だけ傾ける.
3684 \end{description}
3685 の2つがある.
3686 \texttt{extend}や\texttt{slant}を指定した場合は,それに応じたJFMを指定すべきである%
3687 \footnote{\LuaTeX-jaでは,これらに対するJFMを特に提供することはしない予定である.}.
3688 例えば,次の例では無理やり通常のJFMを使っているために,文字間隔やイタリック補正量が
3689 正しくない:
3690 %</ja>
3691 %<*en>
3692 \paragraph{\texttt{extend} and \texttt{slant}}
3693 The following setting can be specified as OpenType font features:
3694 \begin{cslist}[style=standard]
3695 \item[\cs{extend=}<extend>] expand the font horizontally by <extend>.
3696 \item[\cs{slant=}<slant>] slant the font.
3697 \end{cslist}
3698 Note that \LuaTeX-ja doesn't adjust JFMs by these \texttt{extend} and \texttt{slant}
3699 settings; you have to write new JFMs on purpose.
3700 For example, the following example uses the standard JFM \texttt{jfm-ujis.lua}, hence
3701 letter-spacing and the width of italic correction are not correct:
3702 %</en>
3703 \begin{LTXexample}[width=0.3\textwidth]
3704 \jfont\E=KozMinPr6N-Regular:extend=1.5;jfm=ujis;-kern
3705 \E あいうえお
3706
3707 \jfont\S=KozMinPr6N-Regular:slant=1;jfm=ujis;-kern
3708 \S あいう\/ABC
3709 \end{LTXexample}
3710
3711 %<en>\subsection{\cs{tfont}}
3712 %<ja>\subsection{\cs{tfont} 命令}
3713
3714
3715 \begin{table}[t]
3716 %<en>\caption{Differences between vertical JFMs shipped with \LuaTeX-ja}
3717 %<ja>\caption{\LuaTeX-ja に同梱されている縦組用 JFM の違い}
3718 %<en>\medskip
3719 \label{tab-difjfm-tate}
3720 \catcode`\<=12\catcode`\>=12
3721 \ltjsetparameter{jacharrange={+3}}
3722 \small
3723
3724 \def\r#1#2{%
3725   \hbox{\tate\Large\vrule
3726   \parbox{7\zw}{%
3727     \addjfontfeatures{TateFeatures={Opacity=0.5, Color=#2, JFM=#1}}\noindent
3728     ◆◆◆◆◆◆◆
3729     ある日モモちゃんがお使いで迷子になって泣きました.
3730   }\vrule}}
3731 \def\s#1#2{%
3732   \hbox{\tate\Large
3733   \parbox{7\zw}{%
3734     \addjfontfeatures{TateFeatures={Opacity=0.5, Color=#2, JFM=#1}}\noindent
3735     ちょっと!何
3736   }}}
3737 \def\t#1#2#3{\hbox to 0pt{\hss%
3738   \setbox0=\hbox{\addjfontfeatures{TateFeatures={JFM=#1}}\huge #3}%
3739   \textcolor{#2}{\transparent{0.5}\vrule width 0.4pt height\ht0 depth\dp0}\kern-.2pt\copy0
3740   \textcolor{#2}{\transparent{0.5}\kern-\wd0\vrule width\wd0height .2pt depth .2pt
3741   \kern-\wd0\raise\ht0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3742   \kern-\wd0\lower\dp0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3743   \kern-.2pt\vrule width 0.4pt height\ht0 depth \dp0}\hss}}
3744
3745 \begin{minipage}{.7\textwidth}
3746 \centering
3747 \leavevmode\hbox to 0pt{\r{ujisv}{blue}\hss}\r{tmin}{red}\quad
3748 \leavevmode\hbox to 0pt{\s{ujisv}{blue}\hss}\s{tmin}{red}\quad
3749 \raise4\zw\hbox{\tate\Large\t{ujisv}{black}{漢}\t{tmin}{red}{漢}\qquad
3750            \t{ujisv}{black}{っ}\t{tmin}{red}{っ}}
3751 \end{minipage}%
3752 \begin{minipage}{.3\textwidth}
3753 \textcolor{blue}{Blue: \texttt{jfm-ujisv.lua}}\\
3754 \textcolor{red}{Red: \texttt{jfm-tmin.lua}}
3755 \end{minipage}
3756 \ltjsetparameter{jacharrange={-3}}
3757 \end{table}
3758
3759 %<*en>
3760 ...
3761 %</en>
3762 %<*ja>
3763 \cs{tfont} はフォントを縦組用の和文フォントとして読み込む命令であり,
3764 \cs{tfont} の文法は \cs{jfont} と同じである.
3765 \cs{tfont} で定義された縦組用和文フォントは,
3766 以下の点が \cs{jfont} による横組用和文フォントとは異なる:
3767 \begin{itemize}
3768  \item 自動的に \texttt{vert}, \texttt{vrt2} の両OpenType featureが有効化される.
3769 但し,以下の例の3行目に示すように,明示的に \texttt{vert}, \texttt{vrt2}(のいずれか)の
3770 有効・無効を指定した場合は別である.
3771 \begin{lstlisting}
3772 \tfont\S=file:KozMinPr6N-Regular.otf:jfm=ujisv
3773     % vert and vrt2 are automatically activated
3774 \tfont\T=file:KozMinPr6N-Regular.otf:jfm=ujisv;-vert % vert and vrt2 are not activated
3775 \end{lstlisting}
3776  \item \ref{ssec-math}節で述べる,数式中の和文フォントには縦組用和文フォントは指定できない.
3777  \item \texttt{jfm=<name>}\ の部分には縦組用JFMを指定する.
3778 以下の縦組用JFMが\LuaTeX-jaには同梱されており,違いを表\ref{tab-difjfm-tate}に示した.
3779 \begin{description}
3780 \item[\tt jfm-ujisv.lua] \LuaTeX-jaの標準縦組用JFMである.このJFMは\upTeX で
3781   用いられるUTF/OTFパッケージ用の和文用TFMである \verb+upnmlminr-v.tfm+ を
3782   元にしている.
3783 \item[\tt jfm-tmin.lua] \pTeX に同梱されているデフォルトの和文用縦組TFM
3784   である \verb+tmin10.tfm+ に相当し,\texttt{min10.tfm} と同様に
3785   「っ」など一部の文字幅が狭められている.
3786 \end{description}
3787 \end{itemize}
3788
3789 なお,\pTeX では,\cs{font},~\cs{jfont},~\cs{tfont}のどれでも欧文フォント・横組用和文フォン
3790 ト・縦組用和文フォントの定義が可能であったが,\LuaTeX-jaではそうでないので注意.
3791 %</ja>
3792
3793 %<en>\subsection{Prefix \texttt{psft}}
3794 %<ja>\subsection{\texttt{psft}プリフィックス}
3795 \label{ssec-psft}
3796 %<*en>
3797 Besides ``\texttt{file:}''\ and ``\texttt{name:}''\ prefixes which
3798 are introduced in the \Pkg{luaotfload} package,
3799 \LuaTeX-ja adds ``\texttt{psft:}''\ prefix in \cs{jfont} (and~\cs{font}),
3800 to specify a ``name-only'' Japanese font which
3801 will not be embedded to PDF.
3802 Note that these non-embedded fonts under current \LuaTeX\ has Identity-H encoding,
3803 and this violates the standard ISO32000-1:2008~(\cite{pdfstd}).
3804
3805 \emph{OpenType font features, such as ``{\tt +jp90}'',
3806 have no meaning in name-only fonts using ``{\tt psft:}''\ prefix,
3807 because we can't expect what fonts are actually used by the PDF reader.}
3808 Note that \texttt{extend}~and~\texttt{slant} settings (see~above) are supported
3809 with \texttt{psft} prefix, because they are only simple linear transformations.
3810 %</en>
3811 %<*ja>
3812 \Pkg{luaotfload}で使用可能になった
3813 \texttt{file:}\ と \texttt{name:}\ のプリフィックスに加えて,
3814 \cs{jfont}(と \cs{font} プリミティブ)では
3815 \texttt{psft:}プリフィックスを用いることができる.
3816 このプリフィックスを用いることで,PDFには埋め込まれない「名前だけの」
3817 和文フォントを指定することができる.
3818 なお,現行の\LuaTeX で非埋め込みフォントを作成するとPDF内でのエンコーディングが
3819 Identity-Hとなり,PDFの標準規格ISO32000-1:2008~(\cite{pdfstd})に非準拠になってしまう
3820 ので注意してほしい.
3821
3822 \emph{\texttt{psft} プリフィックスの下では
3823 \texttt{+jp90} などのOpenType font featureの効力はない.
3824 非埋込フォントをPDFに使用すると,実際にどのようなフォントが
3825 表示に用いられるか予測できないからである.}\
3826 \texttt{extend} と \texttt{slant} 指定は単なる変形のため
3827 \texttt{psft} プリフィックスでも使用可能である.
3828 %</ja>
3829
3830 %<en>\paragraph{\texttt{cid} key}
3831 %<ja>\paragraph{\texttt{cid}キー}
3832 \label{para-cid}
3833
3834 %<*en>
3835 The default font defined by using \texttt{psft:} prefix is for Japanese typesetting;
3836 it is Adobe-Japan1-6 CID-keyed font.
3837 One can specify \texttt{cid} key to use other CID-keyed non-embedded fonts
3838 for Chinese or Korean typesetting.
3839 %</en>
3840 %<*ja>
3841 標準で\texttt{psft:}プリフィックスで定義されるフォントは日本語用のもので
3842 あり,Adobe-Japan1-6のCIDに対応したものとなる.しかし,\LuaTeX-jaは中国語
3843 の組版にも威力を発揮することが分かり,日本語フォントでない非埋込フォント
3844 の対応も必要となった.そのために追加されたのが\texttt{cid}キーである.
3845
3846 \texttt{cid}キーに値を指定すると,そのCIDを持った非埋込フォントを定義することができる:
3847 %</ja>
3848 \begin{lstlisting}[numbers=left]
3849 \jfont\testJ={psft:Ryumin-Light:cid=Adobe-Japan1-6;jfm=jis}     % Japanese
3850 \jfont\testD={psft:Ryumin-Light:jfm=jis}                        % default value is Adobe-Japan1-6
3851 \jfont\testC={psft:AdobeMingStd-Light:cid=Adobe-CNS1-6;jfm=jis} % Traditional Chinese
3852 \jfont\testG={psft:SimSun:cid=Adobe-GB1-5;jfm=jis}              % Simplified Chinese
3853 \jfont\testK={psft:Batang:cid=Adobe-Korea1-2;jfm=jis}           % Korean
3854 \end{lstlisting}
3855 %<*en>
3856 Note that the code above specifies \texttt{jfm-jis.lua}, which is for Japanese fonts,
3857 as JFM for Chinese and Korean fonts.
3858 %</en>
3859 %<*ja>
3860 上のコードでは中国語・韓国語用フォントに対してもJFMに
3861 日本語用の\texttt{jfm-jis.lua}を指定しているので注意されたい.
3862 %</ja>
3863
3864 %<*en>
3865 At present, \LuaTeX-ja supports only 4 values written in the sample code above.
3866 Specifying other values, e.g.,
3867 %</en>
3868 %<*ja>
3869 今のところ,\LuaTeX-jaは上のサンプルコード中に書いた4つの値しかサポートしていない.
3870 %</ja>
3871 \begin{lstlisting}
3872 \jfont\test={psft:Ryumin-Light:cid=Adobe-Japan2;jfm=jis}
3873 \end{lstlisting}
3874 %<*en>
3875 produces the following error:
3876 %</en>
3877 %<*ja>
3878 のようにそれら以外の値を指定すると,エラーが発生する:
3879 %</ja>
3880 \begin{lstlisting}[numbers=left]
3881 ! Package luatexja Error: bad cid key `Adobe-Japan2'.
3882
3883 See the luatexja package documentation for explanation.
3884 Type  H <return>  for immediate help.
3885 <to be read again>
3886                    \par
3887 l.78
3888
3889 ? h
3890 I couldn't find any non-embedded font information for the CID
3891 `Adobe-Japan2'. For now, I'll use `Adobe-Japan1-6'.
3892 Please contact the LuaTeX-ja project team.
3893 ?
3894 \end{lstlisting}
3895
3896 %<en>\subsection{Structure of a JFM File}
3897 %<ja>\subsection{JFMファイルの構造}
3898 \label{ssec-jfm-str}
3899 %<en>A JFM file is a Lua script which has only one function call:
3900 %<ja>JFMファイルはただ一つの関数呼び出しを含むLuaスクリプトである:
3901 \begin{lstlisting}
3902 luatexja.jfont.define_jfm { ... }
3903 \end{lstlisting}
3904 %<*en>
3905 Real data are stored in the table which indicated above by
3906 \verb+{ ... }+.  So, the rest of this subsection are devoted to describe the
3907 structure of this table.  Note that all lengths in a JFM file are
3908 floating-point numbers in design-size unit.
3909 %</en>
3910 %<*ja>
3911 実際のデータは上で \verb+{ ... }+ で示されたテーブルの中に格納されている.
3912 以下ではこのテーブルの構造について記す.
3913 なお,JFMファイル中の長さは全てdesign-sizeを単位とする浮動小数点数であることに
3914 注意する.
3915 %</ja>
3916
3917 \begin{cslist}[style=standard]
3918
3919 \item[dir=<direction>]
3920 %<en>(required)
3921 %<ja>(必須)
3922
3923 %<*en>
3924 The direction of JFM. \texttt{'yoko'}~(horizontal)
3925 or \texttt{'tate'}~(vertical) are supported.
3926 %</en>
3927 %<*ja>
3928 JFMの書字方向.\texttt{'yoko'}(横組)と \texttt{'tate'}(縦組)がサポートされる.
3929 %</ja>
3930
3931 \item[zw=<length>]
3932 %<en>(required)
3933 %<ja>(必須)
3934
3935 %<en>The amount of the length of the ``full-width''.
3936 %<*ja>
3937 「全角幅」の長さ.この量が \cs{zw} の長さとなる.\pTeX では
3938 「全角幅」\texttt{1zw} は「文字クラス0の文字」の幅と決められていたが,
3939 \LuaTeX-jaではここで指定する.
3940 %</ja>
3941
3942 \item[zh=<length>]
3943 %<en>(required)
3944 %<ja>(必須)
3945
3946 %<en>The amount of the ``full-height'' (height + depth).
3947 %<*ja>
3948 「全角高さ」(height + depth)の長さ.通常は全角幅と同じ長さになるだろう.
3949 \pTeX では 「全角高さ」\texttt{1zh} は「文字クラス0の文字」の高さと深さの和と決められていたが,
3950 \LuaTeX-jaではここで指定する.
3951 %</ja>
3952
3953 \item[kanjiskip=\{<natural>, <stretch>, <shrink>\}]
3954 %<en>(optional)
3955 %<ja>(任意)
3956
3957 %<*en>
3958 This field specifies the ``ideal'' amount of \Param{kanjiskip}. As noted
3959              in Subsection~\ref{subs-kskip}, if the parameter
3960              \Param{kanjiskip} is \cs{maxdimen}, the value specified
3961              in this field is actually used (if this field is not specified in
3962              JFM, it is regarded as 0\,pt). Note that <stretch> and <shrink>
3963              fields are in design-size unit too.
3964 %</en>
3965 %<*ja>
3966 理想的な\Param{kanjiskip}の量を指定する.\ref{subs-kskip}節で述べたように,
3967 もし\Param{kanjiskip}が \cs{maxdimen} の値ならば,このフィールドで指定された
3968 値が実際には用いられる(指定なしは0\,ptとして扱われる).<stretch>と<shrink>のフィールドもdesign-size
3969 が単位であることに注意せよ.
3970 %</ja>
3971
3972 \item[xkanjiskip=\{<natural>, <stretch>, <shrink>\}]
3973 %<en>(optional)
3974 %<ja>(任意)
3975
3976 %<*en>
3977 Like the \texttt{kanjiskip} field, this field specifies the ``ideal''
3978              amount of \Param{xkanjiskip}.
3979 %</en>
3980 %<*ja>
3981 \texttt{kanjiskip}フィールドと同様に,\Param{xkanjiskip}の理想的な量を
3982 指定する.
3983 %</ja>
3984 \end{cslist}
3985
3986 %<*en>
3987 \paragraph{Character classes}
3988 Besides from above fields, a JFM file have several sub-tables those
3989 indices are natural numbers.  The table indexed by~$i\in\omega$ stores
3990 information of \emph{character class}~$i$. At least, the character class~0 is
3991 always present, so each JFM file must have a sub-table whose index is
3992 \texttt{[0]}.  Each sub-table (its numerical index is denoted by $i$) has
3993 the following fields:
3994 %</en>
3995 %<*ja>
3996 \paragraph{文字クラス}
3997 上記のフィールドに加えて,JFMファイルはそのインデックスが自然数であるいくつかの
3998 サブテーブルを持つ.インデックスが$i\in\omega$であるテーブルは\emph{文字クラス}$i$の
3999 情報を格納する.少なくとも,文字クラス0は常に存在するので,JFMファイルはインデックス
4000 が\texttt{[0]}のサブテーブルを持たなければならない.それぞれのサブテーブル
4001 (そのインデックスを$i$で表わす)は以下のフィールドを持つ:
4002 %</ja>
4003
4004 \begin{cslist}[style=standard]
4005 \item[chars=\{<character>, ...\}]
4006 %<en>(required except character class~0)
4007 %<ja>(文字クラス0を除いて必須)
4008
4009 %<*en>
4010 This field is a list of characters which are in this character
4011              type~$i$. This field is optional if $i=0$, since all
4012              \textbf{JAchar} which do not belong  any character classes other
4013              than 0 are in the character class 0
4014              (hence, the character class~0 contains most of
4015              \textbf{JAchar}s). In the list, character(s) can be specified in the following form:
4016 \begin{itemize}
4017 \item a Unicode code point
4018 \item the character itself (as a Lua string, like \hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ'+})
4019 \item a string like \hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ*'+} (the character followed by an asterisk)
4020 \item several ``imaginary'' characters (We will describe these later.)
4021 \end{itemize}
4022 %</en>
4023 %<*ja>
4024 このフィールドは文字クラス$i$に属する文字のリストである.このフィールドは$i=0$の
4025 場合には任意である(文字クラス0には,0以外の文字クラスに属するものを
4026 除いた全ての\textbf{JAchar}が属するから).このリスト中で文字を指定するには,以下の方法がある:
4027 \begin{itemize}
4028 \item Unicode におけるコード番号
4029 \item 「\hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ'+}」のような,文字それ自体
4030 \item 「\hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ*'+}」のような,文字それ自体の後にアスタリスクをつけたもの
4031 \item いくつかの「仮想的な文字」(後に説明する)
4032 \end{itemize}
4033 %</ja>
4034
4035 \item[width=<length>, height=<length>, depth=<length>, italic=<length>]
4036 %<en>(required)
4037 %<ja>(必須)
4038
4039 %<*en>
4040 Specify the width of characters in character class~$i$, the height, the depth and
4041 the amount of italic correction. All characters in character class~$i$ are regarded that its width, height, and depth are
4042 as values of these fields.
4043
4044 But there is one exception: \texttt{width} field can be \texttt{'prop'}.
4045 This means that width of a character becomes that of its ``real'' glyph.
4046 %</en>
4047 %<*ja>
4048 文字クラス$i$に属する文字の幅,高さ,深さ,イタリック補正の量を指定する.
4049 文字クラス$i$に属する全ての文字は,その幅,高さ,深さがこのフィールドで指定した
4050 値であるものとして扱われる.
4051
4052 例外として,\emph{\texttt{width} フィールドには数値以外に \texttt{'prop'} が指定可能である}.
4053 この場合,文字の幅はその「実際の」グリフの幅となる.OpenTypeの \texttt{prop} featureと併用
4054              すれば,これによってプロポーショナル組を行うことができる.
4055 %</ja>
4056
4057 \item[left=<length>, down=<length>, align=<align>]\
4058
4059 %<*en>
4060 These fields are for adjusting the position of the ``real'' glyph. Legal
4061              values of \texttt{align} field are \texttt{'left'},
4062              \texttt{'middle'}, and \texttt{'right'}. If one of these
4063              3~fields are omitted, \texttt{left} and \texttt{down} are
4064              treated as~0, and \texttt{align} field is treated as
4065              \texttt{'left'}.
4066 The effects of these 3~fields are indicated in
4067 Figures \ref{fig-pos}~and~\ref{fig-pos-tate}.
4068 %</en>
4069 %<*ja>
4070 これらのフィールドは実際のグリフの位置を調整するためにある.
4071 \texttt{align} フィールドに指定できる値は \texttt{'left'}, \texttt{'middle'},
4072 \texttt{'right'} のいずれかである.もしこれら3つのフィールドのうちの1つが省かれた
4073 場合,\texttt{left} と \texttt{down} は0,\texttt{align} フィールドは
4074 \ \texttt{'left'} であるものとして扱われる.
4075 これら3つのフィールドの意味については図\ref{fig-pos}(横組用和文フォント),
4076 図\ref{fig-pos-tate}(縦組用和文フォント)で説明する.
4077 %</ja>
4078
4079 %<*en>
4080 In most cases, \texttt{left} and \texttt{down} fields are~0, while
4081 it is not uncommon that the \texttt{align} field is \texttt{'middle'} or \texttt{'right'}.
4082 For example, setting the \texttt{align} field to \texttt{'right'} is practically needed
4083 when the current character class is the class for opening delimiters'.
4084 %</en>
4085 %<*ja>
4086 多くの場合,\texttt{left}と\texttt{down}は0である一方,
4087 \texttt{align}フィールドが\texttt{'middle'}や\texttt{'right'}であることは
4088 珍しいことではない.
4089 例えば,\texttt{align}フィールドを\texttt{'right'}に指定することは,
4090 文字クラスが開き括弧類であるときに実際必要である.
4091 %</ja>
4092
4093 \begin{figure}[!tb]
4094 \begin{minipage}{0.4\textwidth}%
4095 \begin{center}\unitlength=10pt\small
4096 \begin{picture}(15,12)(-1,-4)
4097 \color{b_gray}% jfm
4098 \put(0,0){\vrule width 12\unitlength height 8\unitlength depth 3\unitlength}
4099
4100 \color{b_pink}% step1
4101 \put(-1,-1.5){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
4102
4103 \color{red}% real glyph
4104 \thicklines
4105 \put(-1,-1.5){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
4106 \put(5,-1.5){\line(0,1){7}\line(0,-1){2.5}}
4107 \put(-1,5.5){\line(1,0){6}}
4108 \put(-1,-4){\line(1,0){6}}
4109
4110 \color{b_green}% real glyph
4111 \put(3,0){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
4112
4113 \color{black}% jfm
4114 \thicklines
4115 \put(0,0){\vector(0,1){8}\line(0,-1){3}\vector(1,0){12}}
4116 \put(12,0){\line(0,1){8}\vector(0,-1){3}}
4117 \put(0,8){\line(1,0){12}}
4118 \put(0,-3){\line(1,0){12}}
4119 \put(0.2,4){\makebox(0,0)[l]{\texttt{height}}}
4120 \put(12.2,-1.5){\makebox(0,0)[l]{\texttt{depth}}}
4121 \put(6,0.2){\makebox(0,0)[b]{\texttt{width}}}
4122
4123 \color{green}% step1
4124 \thicklines
4125 \put(3,0){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
4126 \put(9,0){\line(0,1){7}\line(0,-1){2.5}}
4127 \put(3,7){\line(1,0){6}}
4128 \put(3,-2.5){\line(1,0){6}}
4129 \newsavebox{\eqdist}
4130 \savebox{\eqdist}(0,0)[b]{%
4131   \thinlines
4132   \put(-0.08,0.2){\line(0,-1){0.4}}%
4133   \put(0.08,0.2){\line(0,-1){0.4}}}
4134 \put(1.5,0){\usebox{\eqdist}}
4135 \put(10.5,0){\usebox{\eqdist}}
4136
4137 \color{blue}% shifted
4138 \thicklines
4139 \put(3,-1.5){\vector(-1,0){4}}
4140 \put(1,-1.7){\makebox(0,0)[t]{\texttt{left}}}
4141 \put(3,0){\vector(0,-1){1.5}}
4142 \put(3.2,-0.75){\makebox(0,0)[l]{\texttt{down}}}
4143 \end{picture}
4144 \end{center}
4145 \end{minipage}%
4146 \begin{minipage}{0.6\textwidth}%
4147 %<*en>
4148 Consider a  Japanese character node which belongs to
4149 a character class whose the \texttt{align}
4150 field is \texttt{'middle'}.
4151 %</en>
4152 %<*ja>
4153 \texttt{align}フィールドの値が \texttt{'middle'} であるような文字クラスに属する
4154 和文文字ノードを考えよう.
4155 %</ja>
4156 \begin{itemize}
4157 \item
4158 %<*en>
4159 The black rectangle is the imaginary body of the node.
4160 Its width, height, and depth are specified by JFM.
4161 %</en>
4162 %<*ja>
4163 黒色の長方形はノードの枠であり,
4164 その幅,高さ,深さはJFMによって指定されている.
4165 %</ja>
4166 \item
4167 %<*en>
4168 Since the \texttt{align} field is \texttt{'middle'},
4169 the ``real'' glyph is centered horizontally (the green rectangle) first.
4170 %</en>
4171 %<*ja>
4172 \texttt{align}フィールドは \texttt{'middle'} なので,
4173 実際のグリフの位置はまず水平方向に中央揃えしたものとなる(緑色の長方形).
4174 %</ja>
4175 \item
4176 %<*en>
4177 Furthermore, the glyph is shifted according to values of fields
4178       \texttt{left} and \texttt{down}. The ultimate position of the real
4179       glyph is indicated by the red rectangle.
4180 %</en>
4181 %<*ja>
4182 さらに,グリフは \texttt{left} と \texttt{down} の値に従ってシフトされる.
4183 最終的な実際のグリフの位置は赤色の長方形で示された位置になる.
4184 %</ja>
4185 \end{itemize}
4186 \end{minipage}
4187 \medskip
4188
4189 \caption{%
4190 %<en>The position of the real glyph (horizontal Japanese fonts)
4191 %<ja>横組和文フォントにおける「実際の」グリフの位置
4192 }
4193 \label{fig-pos}
4194 \end{figure}
4195 \begin{figure}[!tb]
4196 \begin{minipage}{0.4\textwidth}%
4197 \begin{center}\unitlength=10pt\small
4198 \begin{picture}(15,12)(-6,0)
4199 \color{b_gray}% jfm
4200 \put(-6,0){\vrule width 12\unitlength height 11\unitlength}
4201
4202 \color{b_pink}% real glyph
4203 \put(-6.5,5.5){\vrule width 8\unitlength height 6\unitlength depth 3\unitlength}
4204
4205 \color{red}% real glyph
4206 \thicklines
4207 \put(-6.5,5.5){\vector(0,1){6}\vector(0,-1){3}\vector(1,0){8}}
4208 \put( 1.5,5.5){\line(0,1){6}\line(0,-1){3}}
4209 \put(-6.5,11.5){\line(1,0){8}}
4210 \put(-6.5,2.5){\line(1,0){8}}
4211
4212 \color{b_green}% step1
4213 \put(-4,3){\vrule width 8\unitlength height 6\unitlength depth 3\unitlength}
4214
4215 \color{black}% jfm
4216 \thicklines
4217 \put(0,11){\vector(1,0){6}\vector(-1,0){6}\vector(0,-1){11}}
4218 \put(0,0){\line(1,0){6}\line(-1,0){6}}
4219 \put(-6,0){\line(0,1){11}}
4220 \put( 6,0){\line(0,1){11}}
4221 \put( 3,10.8){\makebox(0,0)[t]{\texttt{height}}}
4222 \put(-3,10.8){\makebox(0,0)[t]{\texttt{depth}}}
4223 \put(0.2,5.5){\makebox(0,0)[l]{\texttt{width}}}
4224
4225 \color{green}% step1
4226 \thicklines
4227 \put(-4,3){\vector(0,1){6}\vector(0,-1){3}\vector(1,0){8}}
4228 \put( 4,3){\line(0,1){6}\line(0,-1){3}}
4229 \put(-4,9){\line(1,0){8}}
4230 \put(-4,0){\line(1,0){8}}
4231 \savebox{\eqdist}(0,0)[b]{%
4232   \thinlines
4233   \put(-0.08,0.2){\line(0,-1){0.4}}%
4234   \put(0.08,0.2){\line(0,-1){0.4}}}
4235 \put(2,9){\usebox{\eqdist}}
4236 \put(-2,9){\usebox{\eqdist}}
4237
4238
4239 \color{blue}% shifted
4240 \thicklines
4241 \put(-4,3){\vector(0,1){2.5}}
4242 \put(-3.8,4.25){\makebox(0,0)[l]{\texttt{left}}}
4243 \put(-4,5.5){\vector(-1,0){2.5}}
4244 \put(-5.,5.7){\makebox(0,0)[b]{\texttt{down}}}
4245 \end{picture}
4246 \end{center}
4247 \end{minipage}%
4248 \begin{minipage}{0.6\textwidth}%
4249 %<*en>
4250 (\dots)
4251 %</en>
4252 %<*ja>
4253 \texttt{align}フィールドの値が \texttt{'right'} であるような文字クラスに属する
4254 和文文字を考えよう.
4255 \begin{itemize}
4256 \item
4257 実際のグリフの「垂直位置」は,まずベースラインが文字の物理的な左右方向の中央を通る
4258 位置となる.
4259 \item
4260 また,この場合 \texttt{align} フィールドは \texttt{'right'} なので,
4261 「水平位置」は字送り方向に「右寄せ」したものとなる(緑色の長方形).
4262 \item
4263 その後さらに \texttt{left} と \texttt{down} の値に従ってシフトされる
4264 のは横組用和文フォントと変わらない.
4265 \end{itemize}
4266 %</ja>
4267 \end{minipage}
4268 \medskip
4269
4270 \caption{%
4271 %<en>The position of the real glyph (vertical Japanese fonts)
4272 %<ja>縦組和文フォントにおける「実際の」グリフの位置
4273 }
4274 \label{fig-pos-tate}
4275 \end{figure}
4276
4277 \item[kern={\{[$j$]=<kern>, [$j'$]=\{<kern>, [<ratio>]\}, ...\}}]
4278
4279 \item[glue={\{[$j$]=\{<width>, <stretch>, <shrink>, [<priority>], [<ratio>]\}, ...\}}]\
4280 %<*ja>
4281
4282 文字クラス$i$の文字と$j$の文字の間に挿入されるkernやglueの量を指定する.
4283
4284              <priority>は \Pkg{luatexja-adjust} による優先順位付き
4285              行長調整(\ref{ssec-adj}節)が有効なときのみ意味を持つ.
4286 このフィールドは省略可能であり,行調整処理におけるこのglueの優先
4287              度を$-2$から$+2$の間の整数で指定する.大きい値ほど「伸びやすく,縮みやすい」
4288              ことを意味する.省略時の値
4289              は0であり,範囲外の値が指定されたときの動作は未定義である.
4290
4291 <ratio>も省略可能フィールドであり,$-1$から$+1$の実数値をとる.省略時の値は0である.
4292 \begin{itemize}
4293 \item $-1$はこのグルーが「前の文字」由来であることを示す.
4294 \item $+1$はこのグルーが「後の文字」由来であることを示す.
4295 \item それ以外の値は,「前の文字」由来のグルーと「後の文字」由来の
4296 グルーが混合されていることを示す.
4297 \end{itemize}
4298 なお,このフィールドの値は\Param{differentjfm}の値が
4299 \texttt{pleft},~\texttt{pright},~\texttt{paverage}の値のときのみ実際に用いられる.
4300
4301 例えば,\cite{x4051}では,句点と中点の間には,
4302 句点由来の二分空きと中点由来の四分空きが挿入されるが,この場合には
4303 \begin{itemize}
4304 \item <width>には$0.5+0.25=0.75$を指定する.
4305 \item <ratio>には次の値を指定する.
4306 \[
4307  -1\cdot \frac{0.5}{0.5+0.25} + 1 \cdot \frac{0.25}{0.5+0.25} = -\frac13
4308 \]
4309 \end{itemize}
4310 %</ja>
4311 %<*en>
4312 \
4313
4314 Specifies the width of kern or glue which will be inserted
4315 between characters in character class~$i$ and those in character class~$j$.
4316
4317 <priority> is an integer in $[-2,2]$ (treated as 0 if omitted), and this is
4318 used only in line adjustment with priority by \Pkg{luatexja-adjust}
4319 (see Subsection~\ref{ssec-adj}). Higher value means the glue is easy to shretch,
4320 and is also easy to shrink.
4321
4322 <ratio> is also an optional value between $-1$ and 1. For example,
4323 The width of a glue between an ideographic full stop ``。''
4324 and a fullwidth middle dot ``・'' is three-fourth of fullwidth,
4325 namely halfwidth from the ideographic full stop, and
4326 quarter-width from the fullwidth middle dot.  In this case,
4327 we specify <ratio> to
4328 \[
4329   -1\cdot \frac{0.5}{0.5+0.25} + 1 \cdot \frac{0.25}{0.5+0.25} = -\frac13.
4330 \]
4331 %</en>
4332
4333
4334 \item[end\_stretch=<kern>, end\_shrink=<kern>]
4335 %<*ja>
4336 (任意)
4337
4338 優先順位付き行長調整が有効であり,かつ現在の文字クラスの文字が行
4339              末に来た時に,行長を詰める調整・伸ばす調整のた
4340              めにこの文字と行末の間に挿入可能なカーンの大きさを指定する.
4341 %</ja>
4342
4343 \end{cslist}
4344
4345 %<*ja>
4346 \paragraph{文字クラスの決定}
4347 文字からその文字の属する文字クラスを算出する過程について,
4348 次の内容を含んだ \texttt{jfm-test.lua} を用いて説明する.
4349 %</ja>
4350 %<*en>
4351 \paragraph{Character to character classes}
4352 We explain how the character class of a character is determined,
4353 using  \texttt{jfm-test.lua} which contains the following:
4354 %</en>
4355 \begin{lstlisting}
4356    [0] = {
4357       chars = { '漢' },
4358       align = 'left', left = 0.0, down = 0.0,
4359       width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
4360    },
4361    [2000] = {
4362       chars = { '。', 'ヒ' },
4363       align = 'left', left = 0.0, down = 0.0,
4364       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
4365    },
4366 \end{lstlisting}
4367 %<ja>ここで,次のような入力とその実行結果を考える:
4368 %<en>Now consider the following input/output:
4369 \begin{LTXexample}[width=0.3\textwidth]
4370 \jfont\a=file:KozMinPr6N-Regular.otf:jfm=test;+hwid
4371 \setbox0\hbox{\a ヒ漢}
4372 \the\wd0
4373 \end{LTXexample}
4374 %<*en>
4375 Now we look why the above source outputs 15\,pt.
4376 \begin{enumerate}
4377 \item The character ``ヒ'' is converted to its half width  form ``ヒ'' by \verb+hwid+ feature.
4378 \item According to the JFM, the character class of ``ヒ'' is 2000, hence its width is halfwidth.
4379 \item The character class of ``漢'' is zero,  hence its width is fullwidth.
4380 \item Hence the width of \cs{hbox} equals to 15\,pt.
4381 \end{enumerate}
4382 This example shows that the character class of a character is generally determined \emph{after
4383 applying font features by \Pkg{luaotfload}}.
4384 %</en>
4385 %<*ja>
4386 上記の出力結果が,15\,ptとなっているのは理由によるものである:
4387 \begin{enumerate}
4388 \item \verb+hwid+ featureによって「ヒ」が半角幅のグリフ「ヒ」と置き換わる(\Pkg{luaotfload} による処理).
4389 \item JFMによれば,この「ヒ」のグリフの文字クラスは2000である.
4390 \item 以上により文字クラス2000とみなされるため,結果として「ヒ」の幅は半角だと認識される.
4391 \end{enumerate}
4392 この例は,\emph{文字クラスの決定はfont featureの適用によるグリフ置換の結果に基づく}ことを
4393 示している.
4394 %</ja>
4395
4396 %<*en>
4397 However, if the class determined by the glyph after application of features is zero,
4398 \LuaTeX-ja adopts the class determined by the glyph \emph{before} application of features.
4399 The following input is an example.
4400 %</en>
4401 %<*ja>
4402 但し,JFMによって決まる置換後のグリフの文字クラスが0である場合は,置換前の文字クラスを採用する.
4403 %</ja>
4404 \begin{LTXexample}[width=0.3\textwidth]
4405 \jfont\a=file:KozMinPr6N-Regular.otf:jfm=test;+vert
4406 \a 漢。\inhibitglue 漢
4407 \end{LTXexample}
4408 %<*en>
4409 Here, the character class of the ideographic full stop ``。''~(\texttt{U+3002}) is determined
4410 as follows:
4411 \begin{enumerate}
4412 \item As the case of ``ヒ'', the ideographic full stop ``。'' is converted to its vertical
4413       form ``\char"FE12''~(\texttt{U+FE12}) by \verb+vert+ feature.%"
4414 \item The character class of ``\char"FE12'', according to the JFM  is \emph{zero}.
4415 \item However, \LuaTeX-ja remembers that this ``\char"FE12'' is obtained from ``。'' by
4416       font features. The character class of ``。'' is \emph{non-zero value}, namely, 2000.
4417 \item Hence the ideographic full stop ``。'' in above belongs the character class~2000.
4418 \end{enumerate}
4419 %</en>
4420 %<*ja>
4421 ここで,句点「。」(\texttt{U+3002})の文字クラスは,以下のようにして決まる.
4422 \begin{enumerate}
4423 \item \Pkg{luaotfload} によって縦組用句点のグリフに置き換わる.
4424 \item 置換後のグリフは \texttt{U+FE12} であり,JFMに従えば文字クラスは\emph{0}と判定される.
4425 \item この場合,置換前の横組用句点のグリフによって文字クラスを判定する.
4426 \item 結果として,上の出力例中の句点の文字クラスは2000となる.
4427 \end{enumerate}
4428 %</ja>
4429
4430
4431 %<ja>\paragraph{仮想的な文字}
4432 %<en>\paragraph{Imaginary characters}
4433 %<*en>
4434 As described before, you can specify several \emph{imaginary characters} in
4435 \texttt{chars} field. The most of these characters are regarded as the
4436 characters of class 0 in \pTeX.
4437 As a result, \LuaTeX-ja can control typesetting finer than \pTeX.
4438 The following is the list of imaginary characters:
4439 %</en>
4440 %<*ja>
4441 上で説明した通り,\texttt{chars}フィールド中にはいくつかの「特殊文字」も
4442 指定可能である.これらは,大半が\pTeX のJFMグルーの挿入処理ではみな「文字
4443 クラス0の文字」として扱われていた文字であり,その結果として\pTeX より細か
4444 い組版調整ができるようになっている.以下でその一覧を述べる:
4445 %</ja>
4446
4447 \begin{cslist}
4448 %%\item['diffmet']
4449 %%<en>Used at a boundary between two \textbf{JAchar}s whose JFM or size is different.
4450 %%<ja>JFMやサイズが異なる2つの\textbf{JAchar}の間の境界として用いられる.
4451
4452 \item['boxbdd']
4453 %<en>The beginning/ending of a hbox, and the beginning of a noindented (i.e., began by \cs{noindent}) paragraph.
4454 %<ja>hboxの先頭と末尾,及びインデントされていない(\cs{noindent} で開始された)段落の先頭を表す.
4455
4456 \item['parbdd']
4457 %<en>The beginning of an (indented) paragraph.
4458 %<ja>通常の(\cs{noindent} で開始されていない)段落の先頭.
4459
4460 \item['jcharbdd']
4461 %<en>A boundary between \textbf{JAchar} and anything else (such as \textbf{ALchar}, kern, glue,\,\ldots).
4462 %<ja>\textbf{JAchar}と「その他のもの」(欧文文字,glue,kern等)との境界.
4463
4464 \item[$-1$]
4465 %<en>The left/right boundary of an inline math formula.
4466 %<ja>行中数式と地の文との境界.
4467 \end{cslist}
4468
4469 %<en>\paragraph{Porting JFM from \pTeX}
4470 %<ja>\paragraph{\pTeX 用和文用TFMの移植}
4471
4472 % ToDo: English version.
4473
4474 %<*en>
4475 See Japanese version of this manual.
4476 %</en>
4477
4478 %<*ja>
4479 以下に,\pTeX 用に作られた和文用TFMを\LuaTeX-ja用に移植する場合の注意点を挙げておく.
4480 \begin{itemize}
4481 \item 実際に出力される和文フォントのサイズがdesign sizeとなる.
4482 このため,例えば$1\,\textrm{zw}$がdesign sizeの0.962216倍であるJISフォン
4483       トメトリック等を移植する場合は,次のようにするべきである:
4484 \begin{itemize}
4485 \item JFM中の全ての数値を$1/0.962216$倍しておく.
4486 \item \TeX ソース中で使用するところで,サイズ指定を0.962216倍にする.
4487       \LaTeX でのフォント宣言なら,例えば次のように:
4488 \begin{lstlisting}
4489 \DeclareFontShape{JY3}{mc}{m}{n}{<-> s*[0.962216] psft:Ryumin-Light:jfm=jis}{}
4490 \end{lstlisting}
4491 \end{itemize}
4492 \item 上に述べた特殊文字は,\texttt{'boxbdd'}を除き文字クラスを全部0とする
4493       (JFM中に単に書かなければよい).
4494 \item \texttt{'boxbdd'}については,それのみで一つの文字クラスを形成し,その
4495       文字クラスに関してはグルー/カーンの設定はしない.
4496
4497 これは,\pTeX では,
4498       hboxの先頭・末尾とインデントされていない(\cs{noindent} で開始さ
4499       れた)段落の先頭にはJFMグルーは入らないという仕様を実現させるためである.
4500 \item \pTeX の組版を再現させようというのが目的であれば以上の注意を守れば十分である.
4501
4502 ところで,\pTeX では通常の段落の先頭にJFMグルーが残るという仕様があるので,
4503       段落先頭の開き括弧は全角二分下がりになる.全角下がりを実現させるに
4504       は,段落の最初に手動で \cs{inhibitglue} を追加するか,あるいは
4505       \ \cs{everypar} のハックを行い,それを自動化させるしかなかった.
4506
4507 一方,\LuaTeX-jaでは,\texttt{'parbdd'}によって,それがJFM側で調整できるよ
4508 うになった.例えば,\LuaTeX-ja同梱のJFMのように,\texttt{'boxbdd'}と同じ文字クラスに
4509 \texttt{'parbdd'}を入れれば全角下がりとなる.
4510
4511 \begin{LTXexample}[width=0.4\textwidth]
4512 \jfont\g=KozMinPr6N-Regular:jfm=test \g
4513 \parindent1\zw\noindent{}◆◆◆◆◆
4514 \par 「◆◆←二分下がり
4515 \par 【◆◆←全角下がり
4516 \par 〔◆◆←全角二分下がり
4517 \end{LTXexample}
4518 \end{itemize}
4519
4520 但し,\cs{everypar} を利用している場合にはこの仕組みは正しく動かない.
4521 そのような例としては箇条書き中の \cs{item} で始まる段落があり,\Pkg{ltjsclasses}では
4522 人工的に「\texttt{'parbdd'}の意味を持つ」whatsitノードを作ることによって対処している%
4523 \footnote{\texttt{ltjsclasses.dtx} を参照されたい.
4524 JFM側で一部の対処ができることにより,\Pkg{jsclasses}のようにif文の判定はしていない.}.
4525 %</ja>
4526
4527
4528 %<en>\subsection{Math Font Family}
4529 %<ja>\subsection{数式フォントファミリ}
4530 \label{ssec-math}
4531
4532 %<*en>
4533 \TeX\ handles fonts in math formulas by 16~font families\footnote{Omega,
4534 Aleph, \LuaTeX~and $\varepsilon$-\kern-.125em(u)\pTeX\ can handles 256~families, but
4535 an external package is needed to support this in plain \TeX\ and
4536 \LaTeX.}, and each family has three fonts:
4537 \cs{textfont}, \cs{scriptfont} and \cs{scriptscriptfont}.
4538 %</en>
4539 %<*ja>
4540 \TeX\ は数式フォントを16のファミリ\footnote{Omega, Aleph, \LuaTeX,そして
4541   $\varepsilon$-\kern-.125em(u)\pTeX\ では256の数式ファミリを扱うことができるが,
4542   これをサポートするためにplain \TeX と\LaTeX では外部パッケージを読み込む必要が
4543   ある.}で管理し,それぞれのファミリは3つのフォントを持っている:
4544 \cs{textfont}, \cs{scriptfont} そして \cs{scriptscriptfont} である.
4545 %</ja>
4546
4547 %<*en>
4548 \LuaTeX-ja's handling of Japanese fonts in math formulas is similar;
4549 Table~\ref{tab-math} shows counterparts to \TeX's primitives for math
4550 font families. There is no relation between the value of
4551 \cs{fam} and that of \cs{jfam}; with appropriate settings,
4552 you can set both \cs{fam} and \cs{jfam} to the same value.
4553 Here <jfont\_cs> in the argument of \Param{jatextfont} etc.\ is
4554 a control sequence which is defined by \cs{jfont}, i.e.,
4555 a \emph{horizontal} Japanese font.
4556 %</en>
4557 %<*ja>
4558 \LuaTeX-jaの数式中での和文フォントの扱いも同様である.
4559 表\ref{tab-math}は数式フォントファミリに対する \TeX のプリミティブと対応する
4560 ものを示している.\cs{fam} と \cs{jfam} の値の間には関係はなく,
4561 適切な設定の下では \cs{fam} と \cs{jfam} の両方に同じ値を設定することができる.
4562 \Param{jatextfont} 他の第2引数<jfont\_cs>は,\cs{jfont} で定義された
4563 \emph{横組用}和文フォントである.\cs{tfont} で定義された
4564 \emph{縦組用}和文フォントを指定することは想定していない.
4565 %</ja>
4566
4567 \begin{table}[!tb]
4568 %<en>\caption{Commands for Japanese math fonts}
4569 %<ja>\caption{和文数式フォントに対する命令}
4570 \label{tab-math}
4571 %<en>\medskip
4572 \centering
4573 \def\{{\char`\{}\def\}{\char`\}}\small
4574 \begin{tabular}{ll}
4575 \toprule
4576 %<en>\bf Japanese fonts&\bf alphabetic fonts\\
4577 %<ja>\bf 和文フォント&\bf 欧文フォント\\
4578 \midrule
4579 \cs{jfam}${}\in [0,256)$&\cs{fam}\\
4580 \tt\Param{jatextfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\cs{textfont}<fam>=<font\_cs>\\
4581 \tt\Param{jascriptfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\cs{scriptfont}<fam>=<font\_cs>\\
4582 \tt\Param{jascriptscriptfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\cs{scriptscriptfont}<fam>=<font\_cs>\\
4583 \bottomrule
4584 \end{tabular}
4585 \end{table}
4586
4587 %<en>\subsection{Callbacks}
4588 %<ja>\subsection{コールバック}
4589
4590 %<*en>
4591 \LuaTeX-ja also has several callbacks. These callbacks can
4592 be accessed via \verb+luatexbase.add_to_callback+ function and so on, as other callbacks.
4593 %</en>
4594 %<*ja>
4595 \LuaTeX 自体のものに加えて,\LuaTeX-jaもコールバックを持っている.
4596 これらのコールバックには,他のコールバックと同様に \verb+luatexbase.add_to_callback+
4597 関数などを用いることでアクセスすることができる.
4598 %</ja>
4599 \begin{description}[font=\bfseries, style=nextline]
4600 %<en>\item[\texttt{luatexja.load\_jfm} callback]
4601 %<ja>\item[\texttt{luatexja.load\_jfm}コールバック]
4602 %<*en>
4603 With this callback you can overwrite JFMs.
4604 This callback is called when a new JFM is loaded.
4605 %</en>
4606 %<*ja>
4607 このコールバックを用いることでJFMを上書きすることができる.
4608 このコールバックは新しいJFMが読み込まれるときに呼び出される.
4609 %</ja>
4610
4611 \begin{lstlisting}[numbers=left]
4612 function (<table> jfm_info, <string> jfm_name)
4613   return <table> new_jfm_info
4614 end
4615 \end{lstlisting}
4616
4617 %<*en>
4618 The argument \verb+jfm_info+ contains a table similar to the table in a JFM file, except
4619 this argument has \texttt{chars} field which contains character codes
4620              whose character class is not~0.
4621 %</en>
4622 %<*ja>
4623 引数 \verb+jfm_info+ はJFMファイルのテーブルと似たものが格納されるが,
4624 クラス0を除いた文字のコードを含んだ\texttt{chars}フィールドを持つ点が異なる.
4625 %</ja>
4626
4627 %<*en>
4628 An example of this callback is the \texttt{ltjarticle} class, with
4629              forcefully assigning character class~0 to \texttt{'parbdd'}
4630              in the JFM \texttt{jfm-min.lua}.
4631 %</en>
4632 %<*ja>
4633 このコールバックの使用例は\texttt{ltjarticle}クラスにあり,
4634 \texttt{jfm-min.lua}中の\texttt{'parbdd'}を強制的にクラス0に割り当てている.
4635 %</ja>
4636
4637 %<en>\item[\texttt{luatexja.define\_jfont} callback]
4638 %<ja>\item[\texttt{luatexja.define\_jfont}コールバック]
4639 %<*en>
4640 This callback and the next callback form a pair, and you can assign characters
4641  which do not have fixed code points in Unicode to non-zero character classes.
4642 This \texttt{luatexja.define\_font} callback is called just when new Japanese font is loaded.
4643 %</en>
4644 %<*ja>
4645 このコールバックと次のコールバックは組をなしており,Unicode中に固定された文字コード
4646 番号を持たない文字を非零の文字クラスに割り当てることができる.
4647 このコールバックは新しい和文フォントが読み込まれたときに呼び出される.
4648 %</ja>
4649
4650 \begin{lstlisting}[numbers=left]
4651 function (<table> jfont_info, <number> font_number)
4652   return <table> new_jfont_info
4653 end
4654 \end{lstlisting}
4655 %<*en>
4656 \verb+jfont_info+ has the following fields,
4657 \emph{which may not overwritten by a user}:
4658 \begin{description}
4659 \item[\texttt{size}]
4660 The font size specified at \cs{jfont} in scaled points ($1\,\mathrm{sp}=2^{-16}\,\mathrm{pt}$).
4661 \item[\texttt{zw}, \texttt{zh}, \texttt{kanjiskip}, \texttt{xkanjiskip}]
4662 These are scaled value of those specified by the JFM, by the font size.
4663 \item[\texttt{jfm}]
4664 The internal number of the JFM.
4665 \item[\texttt{var}]
4666 The value of \texttt{jfmvar}~key, which is specified at \cs{jfont}.
4667 The default value is the empty string.
4668 \item[\texttt{chars}]
4669 The mapping table from character codes to its character classes.\\
4670 The specification \texttt{[i].chars=\{<character>, ...\}} in the JFM will be  stored in this
4671            field as \texttt{chars=\{[<character>]=\,$i$, ...\}}.
4672 \item[\texttt{char\_type}]
4673 For $i\in\omega$, \texttt{char\_type[$i$]} is information of characters whose class is
4674            $i$, and has the following fields:
4675 \begin{itemize}
4676  \item \texttt{width},~\texttt{height}, \texttt{depth},
4677   \texttt{italic}, \texttt{down},~\texttt{left}\ are just
4678        scaled value of those specified by the JFM, by the font size.
4679  \item \texttt{align} is a number which is determined from \texttt{align}~field in the JFM:
4680 \[
4681  \begin{cases}
4682   0&\text{\texttt{'left'} (default)}\\0.5&\text{\tt 'middle'}\\1&\text{\tt 'right'}
4683  \end{cases}
4684 \]
4685 \item For $j\in \omega$, \texttt{[$j$]} stores a kern or a glue which will be inserted
4686 between character class~$i$ and class~$j$.
4687
4688 If a kern will be inserted, the value of this field is \texttt{[$j$]=\{false, <kern\_node>, <ratio>\}},
4689 where <kern\_node> is a node\footnote{%
4690  This version of \LuaTeX-ja uses ``direct access
4691       model'' for accessing nodes, if possible. }.
4692 If a glue will be inserted, we have \texttt{[$j$]=\{false, <spec\_node>, <ratio>, <icflag>\}},
4693 where <spec\_node> is also a node, and $\text{<icflag>}=\textit{from\_jfm}+\text{<priority>}$.
4694 \end{itemize}
4695 \end{description}
4696 %</en>
4697 %<*ja>
4698 \verb+jfont_info+ は最低限以下のフィールドを持つが,これらを書き換えてはならない:
4699 \begin{cslist}
4700 \item[size]
4701 実際に使われるフォントサイズ(sp単位).$1\,\mathrm{sp}=2^{-16}\,\mathrm{pt}$.
4702 \item[zw\textrm{, }zh\textrm{, }kanjiskip\textrm{, }xkanjiskip]
4703 JFMファイルで指定されているそれぞれの値をフォントサイズに合わせてスケーリングしたものを
4704 sp単位で格納している.
4705 \item[jfm]
4706 利用されているJFMを識別するための番号.
4707 \item[var]
4708 \cs{jfont},~\cs{tfont} で指定された \texttt{jfmvar} キーの値(未指定のときは空文字列).
4709 \item[chars]
4710 文字コードから文字クラスへの対応が記述されたテーブル.\\
4711 JFM内の \texttt{[i].chars=\{<character>, ...\}} という指定は\
4712 \texttt{chars=\{[<character>]=\,$i$, ...\}} という形式に変換されている.
4713 \item[char\_type]
4714 $i\in\omega$に対して,\texttt{char\_type[$i$]} は文字クラス$i$の文字の寸法を格納しており,
4715 以下のフィールドを持つ.
4716 \begin{itemize}
4717  \item \texttt{width},~\texttt{height}, \texttt{depth},
4718   \texttt{italic}, \texttt{down},~\texttt{left}\ は
4719 JFMで指定されているそれぞれの値をスケーリングしたものである.
4720  \item \texttt{align} はJFMで指定されている値によって,
4721 \[
4722  \begin{cases}
4723   0&\text{\texttt{'left'}や省略時}\\0.5&\text{\tt 'middle'}\\1&\text{\tt 'right'}
4724  \end{cases}
4725 \]
4726 のいずれかの値をとる.
4727 \item $j\in \omega$に対して,\texttt{[$j$]} は文字クラス$i$の文字と$j$の文字の間に挿入されるkern
4728       やglueを格納している.
4729 間に入るものがkernであれば,このフィールドの値は\
4730 \texttt{[$j$]=\{false, <kern\_node>, <ratio>\}} である.
4731 <kern\_node>はkernを表すノードそのものである\footnote{%
4732 本バージョンではノードのアクセス手法にdirect access
4733       modelを用いている.そのため,例えば\LuaTeX\ beta-0.78.2では,単なる自然数のようにし
4734       か見えないことに注意.
4735 }.
4736 glueであれば,\texttt{[$j$]=\{false, <spec\_node>, <ratio>, <icflag>\}} である.
4737 <spec\_node>はglueの長さを表すノードそのものであり,
4738       $\text{<icflag>}=\textit{from\_jfm}+\text{<priority>}$である.
4739 \end{itemize}
4740 \item[ascent\textrm{, }descent]
4741 ……
4742 \item[chars\_cbcache]
4743 ……
4744 \end{cslist}
4745 %</ja>
4746
4747 %<*en>
4748 The returned table \verb+new_jfont_info+ also should include these fields, but
4749 you are free to add more fields (to use them in the \texttt{luatexja.find\_char\_class} callback).
4750 The \verb+font_number+ is a font number.
4751 %</en>
4752 %<*ja>
4753 戻り値の \verb+new_jfont_info+ テーブルも上に述べたフィールドをそのまま含まなければならないが,
4754 それ以外にユーザが勝手にフィールドを付け加えることは自由である.
4755 \verb+font_number+ はフォント番号である.
4756 %</ja>
4757
4758 %<*en>
4759 A good example of this and the next callbacks is the \Pkg{luatexja-otf}
4760              package, supporting \verb+"AJ1-xxx"+ form for Adobe-Japan1
4761              CID characters in a JFM. This callback doesn't replace any
4762              code of \LuaTeX-ja.
4763 %</en>
4764 %<*ja>
4765 これと次のコールバックの良い使用例は\Pkg{luatexja-otf}パッケージであり,
4766 JFM中でAdobe-Japan1 CIDの文字を \verb+"AJ1-xxx"+ の形で指定するために
4767 用いられている.
4768 %</ja>
4769
4770 %<en>\item[\texttt{luatexja.find\_char\_class} callback]
4771 %<ja>\item[\texttt{luatexja.find\_char\_class}コールバック]
4772 %<*en>
4773 This callback is called just when \LuaTeX-ja is trying to determine which
4774              character class a character \verb+chr_code+ belongs.
4775 A function used in this callback should be in the following form:
4776 %</en>
4777 %<*ja>
4778 このコールバックは\LuaTeX-jaが \verb+chr_code+ の文字がどの文字クラスに
4779 属するかを決定しようとする際に呼び出される.
4780 このコールバックで呼び出される関数は次の形をしていなければならない:
4781 %</ja>
4782 \begin{lstlisting}[numbers=left]
4783 function (<number> char_class, <table> jfont_info, <number> chr_code)
4784   if char_class~=0 then return char_class
4785   else
4786     ....
4787     return (<number> new_char_class or 0)
4788   end
4789 end
4790 \end{lstlisting}
4791
4792 %<*en>
4793 The argument \verb+char_class+ is the result of \LuaTeX-ja's default
4794              routine or previous function calls in this callback, hence
4795              this argument may not be 0. Moreover, the returned
4796              \verb+new_char_class+ should be as same as \verb+char_class+ when \verb+char_class+
4797              is not~0, otherwise you will overwrite the \LuaTeX-ja's
4798              default routine.
4799 %</en>
4800 %<*ja>
4801 引数 \verb+char_class+ は\LuaTeX-jaのデフォルトルーチンか,このコールバックの
4802 直前の関数呼び出しの結果を含んでおり,したがってこの値は0ではないかもしれない.
4803 さらに,戻り値の \verb+new_char_class+ は \verb+char_class+ が非零のときには
4804 \verb+char_class+ の値と同じであるべきで,そうでないときは\LuaTeX-jaの
4805 デフォルトルーチンを書き換えることになる.
4806 %</ja>
4807
4808 %<en>\item[\texttt{luatexja.set\_width} callback]
4809 %<ja>\item[\texttt{luatexja.set\_width}コールバック]
4810 %<*en>
4811 This callback is called when \LuaTeX-ja is trying to encapsule a
4812              \textbf{JAchar} \textit{glyph\_node}, to adjust its
4813              dimension and position.
4814 %</en>
4815 %<*ja>
4816 このコールバックは\LuaTeX-jaが\textbf{JAchar}の寸法と位置を調節するために
4817 その\textit{glyph\_node}をカプセル化しようとする際に呼び出される.
4818 %</ja>
4819 \begin{lstlisting}[numbers=left]
4820 function (<table> shift_info, <table> jfont_info, <number> char_class)
4821   return <table> new_shift_info
4822 end
4823 \end{lstlisting}
4824
4825 %<*en>
4826 The argument \verb+shift_info+ and the returned \verb+new_shift_info+ have
4827 \texttt{down} and \texttt{left} fields, which are the amount of shifting
4828              down/left the character in a scaled point.
4829 %</en>
4830 %<*ja>
4831 引数 \verb+shift_info+ と戻り値の \verb+new_shift_info+ は
4832 \texttt{down}と\texttt{left}のフィールドを持ち,これらの値は
4833 文字の下/左へのシフト量(sp単位)である.
4834 %</ja>
4835
4836 %<*en>
4837 A good example is \Pkg{test/valign.lua}.
4838 After loading this file, the vertical position of glyphs is automatically
4839 adjusted; the ratio $(\hbox{height}:\hbox{depth})$ of glyphs is adjusted
4840 to be that of letters in the character class~0. For example, suppose that
4841 \begin{itemize}
4842 \item The setting of the JFM: $(\hbox{height})=88x$, $(\hbox{depth})=12x$
4843   (the standard values of Japanese OpenType fonts);
4844 \item The value of the real font: $(\hbox{height})=28y$, $(\hbox{depth})=5y$
4845   (the standard values of Japanese TrueType fonts).
4846 \end{itemize}
4847 Then, the position of glyphs is shifted up by
4848 %</en>
4849 %<*ja>
4850 良い例が\Pkg{test/valign.lua}である.このファイルが読み込まれた状態では,
4851              JFM内で規定された文字クラス0の文字における$(\hbox{高
4852              さ}):(\hbox{深さ})$の比になるように,実際のフォントの出力上
4853              下位置が自動調整される.例えば,
4854 \begin{itemize}
4855 \item JFM側の設定:$(\hbox{高さ})=88x$, $(\hbox{深さ})=12x$%
4856 (和文OpenTypeフォントの標準値)
4857 \item 実フォント側の数値:$(\hbox{高さ})=28y$, $(\hbox{深さ})=5y$(和文TrueTypeフォントの標準値)
4858 \end{itemize}
4859 となっていたとする.すると,実際の文字の出力位置は,以下の量だけ上にぜらされることとなる:
4860 %</ja>
4861 \[
4862  \frac{88x}{88x+12x} (28y+5y) - 28y = \frac{26}{25}y= 1.04y.
4863 \]
4864 \end{description}
4865
4866
4867
4868 %<en>\section{Parameters}
4869 %<ja>\section{パラメータ}
4870 \subsection{\cs{ltjsetparameter}}
4871 \label{ssec-param}
4872
4873 %<*en>
4874 As described before, \cs{ltjsetparameter} and \cs{ltjgetparameter} are
4875 commands for accessing most parameters of \LuaTeX-ja. One of the main
4876 reason that \LuaTeX-ja didn't adopted the syntax similar to that of \pTeX\
4877 (\textit{e.g.},~\verb+\prebreakpenalty`)=10000+)
4878 is the position of \verb+hpack_filter+ callback in the source
4879 of \LuaTeX, see Section~\ref{sec-para}.
4880 %</en>
4881 %<*ja>
4882 先に述べたように,\LuaTeX-jaの内部パラメータにアクセスするには
4883 \cs{ltjsetparameter}(または \cs{ltjglobalsetparameter})と \cs{ltjgetparameter} を用いる.
4884 \LuaTeX-jaが\pTeX のような文法(例えば,\verb+\prebreakpenalty`)=10000+)を
4885 採用しない理由の一つは,\LuaTeX のソースにおける \verb+hpack_filter+
4886 コールバックの位置にある.\ref{sec-para}章を参照.
4887 %</ja>
4888
4889 %<*en>
4890 \cs{ltjsetparameter} and \cs{ltjglobalsetparameter} are commands
4891 for assigning parameters. These take one argument which is a
4892 \texttt{<key>=<value>} list.
4893 The difference between these two commands is the
4894 scope of assignment;
4895 \cs{ltjsetparameter} does a local assignment and
4896 \cs{ltjglobalsetparameter} does a global one.
4897 They also obey the value of \cs{globaldefs}, like other assignments.
4898 %</en>
4899 %<*ja>
4900 \cs{ltjsetparameter} と \cs{ltjglobalsetparameter} はパラメータを
4901 指定するための命令で,\texttt{<key>=<value>}のリストを
4902 引数としてとる.両者の違いはスコープであり,
4903 \cs{ltjsetparameter} はローカルな設定を行うのに対し,
4904 \cs{ltjglobalsetparameter} はグローバルな設定を行う.
4905 また,他のパラメータ指定と同様に \cs{globaldefs} の値にも従う.
4906 %</ja>
4907
4908 %<*en>
4909 The following is the list of parameters which can be specified by the
4910 \cs{ltjsetparameter} command. [\cs{cs}] indicates the counterpart
4911 in \pTeX, and symbols beside each parameter has the following meaning:
4912 %</en>
4913 %<*ja>
4914 以下は \cs{ltjsetparameter} に指定することができるパラメータの一覧である.
4915 [\cs{cs}]は\pTeX における対応物を示す.
4916 また,それぞれのパラメータの右上の記号には次の意味がある:
4917 %</ja>
4918 \begin{itemize}
4919 %<*en>
4920 \item ``\ast'' : values at the end of a paragraph or a hbox are
4921 adopted in the whole paragraph or the whole hbox.
4922 %</en>
4923 %<*ja>
4924 \item ``\ast'':段落やhboxの終端での値がその段落/hbox全体で用いられる.
4925 %</ja>
4926 %<*en>
4927 \item ``\dagger'': assignments are always global.
4928 %</en>
4929 %<*ja>
4930 \item ``\dagger'':指定は常にグローバルになる.
4931 %</ja>
4932 \end{itemize}
4933
4934 \begin{cslist}[style=standard]
4935 \item[\DParam{jcharwidowpenalty}\,=<penalty>$^\ast$] [\cs{jcharwidowpenalty}]\
4936
4937 %<*en>
4938 Penalty value for suppressing orphans. This penalty is inserted just
4939              after the last \textbf{JAchar} which is not regarded as a
4940              (Japanese) punctuation mark.
4941 %</en>
4942 %<*ja>
4943 パラグラフの最後の字が孤立して改行されるのを防ぐためのペナルティの値.
4944 このペナルティは(日本語の)句読点として扱われない最後の\textbf{JAchar}の直後に
4945 挿入される.
4946 %</ja>
4947
4948 \item[\DParam{kcatcode}\,=\{<chr\_code>,<natural number>\}$^\ast$]\
4949
4950 %<*en>
4951 An additional attributes which each character whose character code is <chr\_code> has.
4952 At the present version, the lowermost bit of <natural number> indicates
4953              whether the character is considered as a punctuation mark
4954              (see the description of \Param{jcharwidowpenalty} above).
4955 %</en>
4956 %<*ja>
4957 文字コードが<chr\_code>の文字が持つ付加的な属性値.
4958 現在のバージョンでは,<natural number>の最下位ビットが,その文字が句読点と
4959 みなされるかどうかを表している(上の\Param{jcharwidowpenalty}の記述を参照).
4960 %</ja>
4961
4962 \item[\DParam{prebreakpenalty}\,=\{<chr\_code>,<penalty>\}$^\ast$] [\cs{prebreakpenalty}]\
4963
4964 %<*ja>
4965 文字コード<chr\_code>の\textbf{JAchar}が行頭にくることを抑止するために,
4966              この文字の前に挿入/追加されるペナルティの量を指定する.
4967
4968 例えば閉じ括弧「〗」は絶対に行頭にきてはならないので,
4969 \begin{lstlisting}
4970 \ltjsetparameter{prebreakpenalty={`〙,10000}}
4971 \end{lstlisting}
4972 と,最大値の10000が標準で指定されている.他にも,小書きのカナなど,絶対禁止とい
4973              うわけではないができれば行頭にはきて欲しくない場合に,0と
4974              10000の間の値を指定するのも有用であろう.
4975
4976 \pTeX では,\cs{prebreakpenalty}, \cs{postbreakpenalty}において,
4977 \begin{itemize}
4978 \item 一つの文字に対して,pre, postどちらか一つしか指定することができない%
4979   \footnote{後から指定した方で上書きされる.}
4980 \item pre, post合わせて256文字分の情報を格納することしかできない
4981 \end{itemize}
4982 という制限があったが,\LuaTeX-jaではこれらの制限は解消されている.
4983 %</ja>
4984 %<*en>
4985 Set a penalty which is inserted automatically before the character <chr\_code>,
4986 to prevent a line starts from this character. For example, a line cannot started
4987 with one of closing brackets ``〗'', so \LuaTeX-ja sets
4988 \begin{lstlisting}
4989 \ltjsetparameter{prebreakpenalty={`〙,10000}}
4990 \end{lstlisting}
4991 by default.
4992
4993 \pTeX\ has following restrictions on \cs{prebreakpenalty} and \cs{postbreakpenalty},
4994 but they don't exist in \LuaTeX-ja:
4995 \begin{itemize}
4996  \item Both \cs{prebreakpenalty} and \cs{postbreakpenalty} cannot be set
4997 for the same character.
4998  \item We can set \cs{prebreakpenalty} and \cs{postbreakpenalty} up to 256~characters.
4999 \end{itemize}
5000 %</en>
5001
5002 \item[\DParam{postbreakpenalty}\,=\{<chr\_code>,<penalty>\}$^\ast$]
5003            [\cs{postbreakpenalty}]\
5004
5005 %<*ja>
5006 文字コード<chr\_code>の\textbf{JAchar}が行末にくることを抑止するために,
5007              この文字の後に挿入/追加されるペナルティの量を指定する.
5008 %</ja>
5009 %<*en>
5010 Set a penalty which is inserted automatically after the character <chr\_code>,
5011 to prevent a line ends with this character.
5012 %</en>
5013
5014 \item[\DParam{jatextfont}\,=\{<jfam>,<jfont\_cs>\}$^\ast$]
5015 %<en>[\cs{textfont} in \TeX]
5016 %<ja>[\TeX の \cs{textfont}]
5017 \item[\DParam{jascriptfont}\,=\{<jfam>,<jfont\_cs>\}$^\ast$]
5018 %<en>[\cs{scriptfont} in \TeX]
5019 %<ja>[\TeX の \cs{scriptfont}]
5020 \item[\DParam{jascriptscriptfont}\,=\{<jfam>,<jfont\_cs>\}$^\ast$]
5021 %<en>[\cs{scriptscriptfont} in \TeX]
5022 %<ja>[\TeX の \cs{scriptscriptfont}]
5023 \item[\DParam{yjabaselineshift}\,=<dimen>]\
5024 \item[\DParam{yalbaselineshift}\,=<dimen>] [\cs{ybaselineshift}]
5025 \item[\DParam{tjabaselineshift}\,=<dimen>]\
5026 \item[\DParam{talbaselineshift}\,=<dimen>] [\cs{tbaselineshift}]
5027
5028 \item[\DParam{jaxspmode}\,=\{<chr\_code>,<mode>\}$^\ast$]\
5029
5030 %<*en>
5031 Set whether inserting \Param{xkanjiskip} is allowed before/after a \textbf{JAchar} whose character code is <chr\_code>.
5032 The followings are allowed for <mode>:
5033 %</en>
5034 %<*ja>
5035 文字コードが<chr\_code>の\textbf{JAchar}の前/後ろに\Param{xkanjiskip}の
5036 挿入を許すかどうかの設定.
5037 以下の<mode>が許される:
5038 %</ja>
5039 \begin{description}
5040 %<en>\item[0, \texttt{inhibit}] Insertion of \Param{xkanjiskip} is inhibited before the character, nor after the character.
5041 %<ja>\item[0, \texttt{inhibit}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも禁止される.
5042 %<en>\item[1, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed before the character, but not after.
5043 %<ja>\item[1, \texttt{preonly}] \Param{xkanjiskip}の挿入は文字の前では許されるが,後ろでは許されない.
5044 %<en>\item[2, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed after the character, but not before.
5045 %<ja>\item[2, \texttt{postonly}] \Param{xkanjiskip}の挿入は文字の後ろでは許されるが,前では許されない.
5046 %<en>\item[3, \texttt{allow}] Insertion of \Param{xkanjiskip} is allowed both before the character and after the character. This is the default value.
5047 %<ja>\item[3, \texttt{allow}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも許される.これがデフォルトの値である.
5048 \end{description}
5049 %<*en>
5050 This parameter is similar to the \cs{inhibitxspcode} primitive of \pTeX, but not compatible with \cs{inhibitxspcode}.
5051 %</en>
5052 %<*ja>
5053 このパラメータは\pTeX の \cs{inhibitxspcode} プリミティブと似ているが,
5054 互換性はない.
5055 %</ja>
5056 \item[\DParam{alxspmode}\,=\{<chr\_code>,<mode>\}$^\ast$] [\cs{xspcode}]\
5057
5058 %<*en>
5059 Set whether inserting \Param{xkanjiskip} is allowed before/after a
5060              \textbf{ALchar} whose character code is <chr\_code>.
5061              The followings are allowed for <mode>:
5062 %</en>
5063 %<*ja>
5064 文字コードが<chr\_code>の\textbf{ALchar}の前/後ろに\Param{xkanjiskip}の
5065 挿入を許すかどうかの設定.
5066 以下の<mode>が許される:
5067 %</ja>
5068 \begin{description}
5069 %<en>\item[0, \texttt{inhibit}] Insertion of \Param{xkanjiskip} is inhibited before the character, nor after the character.
5070 %<ja>\item[0, \texttt{inhibit}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも禁止される.
5071 %<en>\item[1, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed before the character, but not after.
5072 %<ja>\item[1, \texttt{preonly}] \Param{xkanjiskip}の挿入は文字の前では許されるが,後ろでは許されない.
5073 %<en>\item[2, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed after the character, but not before.
5074 %<ja>\item[2, \texttt{postonly}] \Param{xkanjiskip}の挿入は文字の後ろでは許されるが,前では許されない.
5075 %<en>\item[3, \texttt{allow}] Insertion of \Param{xkanjiskip} is allowed before the character and after the character. This is the default value.
5076 %<ja>\item[3, \texttt{allow}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも許される.これがデフォルトの値である.
5077 \end{description}
5078 %<*en>
5079 Note that parameters \Param{jaxspmode} and \Param{alxspmode} share a common table, hence these two parameters are synonyms of each other.
5080 %</en>
5081 %<*ja>
5082 \Param{jaxspmode}と\Param{alxspmode}は共通のテーブルを用いているため,
5083 これら2つのパラメータは互いの別名となっていることに注意する.
5084 %</ja>
5085
5086 \item[\DParam{autospacing}\,=<bool>] [\cs{autospacing}]
5087 \item[\DParam{autoxspacing}\,=<bool>] [\cs{autoxspacing}]
5088 \item[\DParam{kanjiskip}\,=<skip>$^\ast$] [\cs{kanjiskip}]\
5089
5090 %<*ja>
5091 デフォルトで2つの\textbf{JAchar}の間に挿入されるグルーである.
5092 通常では,\pTeX と同じようにフォントサイズに比例して変わることはない.
5093 しかし,自然長が \cs{maxdimen} の場合は,例外的に和文フォントのJFM側で指定されている
5094 値を採用(こちらはフォントサイズに比例)することになっている.
5095 %</ja>
5096 %<*en>
5097 The default glue which inserted between two \textbf{JAchar}s.
5098 Changing current Japanese font does not alter this parameter, as \pTeX.
5099
5100 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 \item[\DParam{xkanjiskip}\,=<skip>$^\ast$] [\cs{xkanjiskip}]\
5105
5106 %<*ja>
5107 デフォルトで\textbf{JAchar}と\textbf{ALchar}の間に挿入されるグルーである.
5108 \Param{kanjiskip}と同じように,通常ではフォントサイズに比例して変わることはないが,
5109 自然長が \cs{maxdimen} の場合が例外である.
5110 %</ja>
5111 %<*en>
5112 The default glue which inserted between a \textbf{JAchar} and an
5113       \textbf{ALchar}.
5114 Changing current font does not alter this parameter, as \pTeX.
5115
5116 As \Param{kanjiskip}, if the natural width of this parameter is \cs{maxdimen}, \LuaTeX-ja uses
5117 the value which is specified in the JFM for current Japanese font (See Subsection~\ref{ssec-jfm-str}).
5118 %</en>
5119
5120
5121 \item[\DParam{differentjfm}\,=<mode>$^\dagger$]\
5122
5123 %<*en>
5124 Specify how glues/kerns between two \textbf{JAchar}s whose JFM (or size) are different.
5125 The allowed arguments are the followings:
5126 %</en>
5127 %<*ja>
5128 JFM(もしくはサイズ)が異なる2つの\textbf{JAchar}の間にグルー/カーンをどのように
5129 入れるかを指定する.
5130 許される値は以下の通り:
5131 %</ja>
5132 \begin{quote}
5133 \texttt{average},
5134 \texttt{both},
5135 \texttt{large},
5136 \texttt{small},
5137 \texttt{pleft},
5138 \texttt{pright},
5139 \texttt{paverage}
5140 \end{quote}
5141 %<*en>
5142 The default value is \texttt{paverage}. \dots
5143 %</en>
5144 %<*ja>
5145 デフォルト値は \texttt{paverage} である.
5146 各々の値による差異の詳細は\ref{ssec-cluster-wa}節の「『右空白』の算出」を参照してほしい.
5147 %</ja>
5148
5149 \item[\DParam{jacharrange}\,=<ranges>]
5150 \item[\DParam{kansujichar}\,=\{<digit>, <chr\_code>\}$^\ast$] [\cs{kansujichar}]
5151
5152 \item[\DParam{direction}\,=<dir>\ \hbox{\rm (always local)}]\
5153
5154 %<*en>
5155 Assigning to this parameter has the same effect as
5156 \cs{yoko}~(if $\hbox{<dir>}=4$), \cs{tate}~(if $\hbox{<dir>}=3$),
5157 \cs{dtou}~(if $\hbox{<dir>}=1$) or \cs{utod}~(if $\hbox{<dir>}=11$).
5158 If the argument <dir> is not one of 4,~3, 1~nor~11,
5159 the behavior of this assignment is undefined.
5160 %</en>
5161 %<*ja>
5162 組方向を変更する \cs{yoko}~(if $\hbox{<dir>}=4$), \cs{tate}~(if $\hbox{<dir>}=3$),
5163 \cs{dtou}~(if $\hbox{<dir>}=1$), \cs{utod}~(if $\hbox{<dir>}=11$) と同じ役割を持つ.
5164 利用可能な状況もこれら4命令と同一である.引数<dir>が4,~3, 1,~11のいずれでも無いときの
5165 動作は未定義である.
5166 %</ja>
5167
5168 \end{cslist}
5169
5170
5171 \subsection{\cs{ltjgetparameter}}
5172 \label{ssec-getpar}
5173 %<*en>
5174 \cs{ltjgetparameter} is a control sequence for acquiring parameters. It
5175 always takes a parameter name as first argument.
5176 %</en>
5177 %<*ja>
5178 \cs{ltjgetparameter} はパラメータの値を取得するための命令であり,
5179 常にパラメータの名前を第一引数にとる.
5180 %</ja>
5181 \begin{LTXexample}
5182 \ltjgetparameter{differentjfm},
5183 \ltjgetparameter{autospacing},
5184 \ltjgetparameter{kanjiskip},
5185 \ltjgetparameter{prebreakpenalty}{`)}.
5186 \end{LTXexample}
5187
5188 %<*en>
5189 \emph{The return value of\/ \cs{ltjgetparameter} is
5190 always a string}, which is outputted by \texttt{tex.write()}.
5191 Hence any character other than space~``\texttt{\char32}''~(\texttt{U+0020}) has the category code
5192 12~(other), while the space has 10~(space).
5193 %</en>
5194 %<*ja>
5195 \emph{\cs{ltjgetparameter} の戻り値は常に文字列である.}
5196 これは\texttt{tex.write()}によって出力しているためで,空白「\texttt{\char32}」
5197 (\texttt{U+0020})を除いた文字のカテゴリーコードは全て12~(other)となる.
5198 一方,空白のカテゴリーコードは10~(space)である.
5199 %</ja>
5200
5201 \begin{itemize}
5202 \item
5203 %<*en>
5204 If first argument is one of the
5205 following, no  additional argument is needed.
5206 %</en>
5207 %<*ja>
5208 第1引数が次のいずれかの場合には,追加の引数は必要ない.
5209 %</ja>
5210 \begin{quote}
5211 \sffamily
5212 jcharwidowpenalty, yjabaselineshift, yalbaselineshift, autospacing, autoxspacing,\\
5213 kanjiskip, xkanjiskip, differentjfm, direction
5214 \end{quote}
5215 %<*en>
5216 Note that \verb+\ltjgetparameter{autospacing}+~and~\verb+\ltjgetparameter{autoxspacing}+
5217 returns 1 or 0, not
5218 \texttt{true}~nor~\texttt{false}.
5219 %</en>
5220 %<*ja>
5221 \verb+\ltjgetparameter{autospacing}+ と \verb+\ltjgetparameter{autoxspacing}+ は,
5222 \texttt{true}や\texttt{false}を返すの\emph{ではなく},
5223 1か0のいずれかを返すことに注意,
5224 %</ja>
5225
5226 \item
5227 %<*en>
5228 If first argument is one of the
5229 following, an additional argument---a character code, for example---is needed.
5230 %</en>
5231 %<*ja>
5232 第1引数が次のいずれかの場合には,さらに文字コードを第2引数としてとる.
5233 %</ja>
5234 \begin{quote}
5235 \sffamily
5236 kcatcode, prebreakpenalty, postbreakpenalty, jaxspmode, alxspmode
5237 \end{quote}
5238 %<*en>
5239 \verb+\ltjgetparameter{jaxspmode}{...}+~and~\verb+\ltjgetparameter{alxspmode}{...}+
5240 returns 0,~1, 2,~or~3, instead of \texttt{preonly} etc.
5241 %</en>
5242 %<*ja>
5243 \verb+\ltjgetparameter{jaxspmode}{...}+ や \verb+\ltjgetparameter{alxspmode}{...}+\
5244 は,\texttt{preonly} などといった文字列ではなく,0から3までの値を返す.
5245 %</ja>
5246
5247 \item
5248 %<*en>
5249 \verb+\ltjgetparameter{jacharrange}{+<range>\verb+}+ returns \texttt{0}
5250 if ``characters which belong to the character range~<range> are \textbf{JAchar}'',
5251 \texttt{1} if ``\dots~are \textbf{ALchar}''.
5252 Although there is no character range~$-1$, specifying $-1$ to <range> does not cause an
5253       error (returns 1).
5254 %</en>
5255 %<*ja>
5256 \verb+\ltjgetparameter{jacharrange}{+<range>\verb+}+ は,<range>が\textbf{JAchar}達の
5257 範囲ならば0を,そうでなければ1を返す.「$-1$番の文字範囲」は存在しないが,<range>に$-1$を
5258 指定してもエラーは発生しない(1を返す).
5259 %</ja>
5260
5261 \item
5262 %<*en>
5263 For an integer~<digit> between 0~and~9,
5264      \verb+\ltjgetparameter{kansujichar}{+<digit>\verb+}+ returns the character code
5265 of the result of \cs{kansuji}<digit>.
5266 %</en>
5267 %<*ja>
5268 0--9の数<digit>に対して,
5269 \verb+\ltjgetparameter{kansujichar}{+<digit>\verb+}+ は,\cs{kansuji}<digit>で出力され
5270      る文字の文字コードを返す.
5271 %</ja>
5272
5273 \item
5274 %<*en>
5275 \verb+\ltjgetparameter{adjustdir}+ returns a integer which represents
5276 the direction of the surrounding vertical list.
5277 As \Param{direction}, the return value 1 means \emph{down-to-up} direction,
5278 3 means \emph{tate} direction (vertical typesetting),
5279 and 4 means \emph{yoko} direction (horizontal typesetting).
5280 %</en>
5281 %<*ja>
5282 \verb+\ltjgetparameter{adjustdir}+ は,周囲のvboxの組方向(言い換えれば,
5283 \cs{vadjust} で用いられる組方向)を表す数値を返す.
5284 \Param{direction}と同様に,1は \cs{dtou} 方向を,
5285 3は縦組みを,4は横組みを表す.
5286 %</ja>
5287
5288 \item
5289 %<*en>
5290 For an integer~<reg\_num> between 0~and~65535,
5291 \verb+\ltjgetparameter{boxdim}{+<reg\_num>\verb+}+ returns the direction of
5292 \cs{box}<reg\_num>. If this box register is void, the returned value is zero.
5293 %</en>
5294 %<*ja>
5295 0--65535の数<reg\_num>に対して,
5296 \verb+\ltjgetparameter{boxdim}{+<reg\_num>\verb+}+ は,\cs{box}<reg\_num>に
5297 格納されているボックスの組方向を表す.もしこのレジスタが空の場合は,0が返される.
5298 %</ja>
5299
5300 \item
5301 %<*en>
5302 The following parameter names \emph{cannot be specified} in \cs{ltjgetparameter}.
5303 %</en>
5304 %<*ja>
5305 次のパラメータ名を \cs{ltjgetparameter} に指定することはできない.
5306 %</ja>
5307 \begin{quote}
5308 \sffamily
5309 jatextfont, jascriptfont, jascriptscriptfont, jacharrange
5310 \end{quote}
5311
5312 \item
5313 %<*en>
5314 \verb+\ltjgetparameter{chartorange}{+<chr\_code>\verb+}+ returns
5315 the range number which <chr\_code> belongs to
5316 (although there is no parameter named ``chartorange'').
5317
5318 If <chr\_code> is between 0 and 127, this <chr\_code> does not belong to
5319 any character range. In this case,
5320       \verb+\ltjgetparameter{chartorange}{+<chr\_code>\verb+}+
5321 returns $-1$.
5322
5323 Hence, one can know whether <chr\_code> is \textbf{JAchar} or not
5324 by the following:
5325 %</en>
5326 %<*ja>
5327 \verb+\ltjgetparameter{chartorange}{+<chr\_code>\verb+}+ によって
5328 <chr\_code>の属する文字範囲の番号を知ることができる.
5329
5330 <chr\_code>に0--127の値を指定した場合(このとき,<chr\_code>が属する
5331 文字範囲は存在しない)は$-1$が返る.
5332
5333 そのため,<chr\_code>が\textbf{JAchar}か\textbf{ALchar}かは
5334 次で知ることができる:
5335 %</ja>
5336 \begin{quote}
5337 \ttfamily \verb+\ltjgetparameter{jacharrange}{\ltjgetparameter{chartorange}{+%
5338   <chr\_code>\verb+}}+\\\null\hfill\verb+% 0 if JAchar, 1 if ALchar+
5339 \end{quote}
5340
5341 %<*en>
5342 \item Because the returned value is string, the following conditionals do not work
5343 if \Param{kanjiskip} (or~\Param{xkanjiskip}) has the stretch part or the shrink part.
5344 \begin{lstlisting}
5345 \ifdim\ltjgetparameter{kanjiskip}>\z@ ... \fi
5346 \ifdim\ltjgetparameter{xkanjiskip}>\z@ ... \fi
5347 \end{lstlisting}
5348 The correct way is using a temporary register.
5349 \begin{lstlisting}
5350 \@tempskipa=\ltjgetparameter{kanjiskip} \ifdim\@tempskipa>\z@ ... \fi
5351 \@tempskipa=\ltjgetparameter{xkanjiskip}\ifdim\@tempskipa>\z@ ... \fi
5352 \end{lstlisting}
5353 %</en>
5354 %<*ja>
5355 \item 返り値が文字列であることから,\Param{kanjiskip}や\Param{xkanjiskip}を直接
5356 \ \cs{ifdim} を使って比較することは望ましくない.伸び量や縮み量を持っている時には,
5357 次はエラーを発生させる:
5358 \begin{lstlisting}
5359 \ifdim\ltjgetparameter{kanjiskip}>\z@ ... \fi
5360 \ifdim\ltjgetparameter{xkanjiskip}>\z@ ... \fi
5361 \end{lstlisting}
5362 レジスタに一旦代入するのが良い:
5363 \begin{lstlisting}
5364 \@tempskipa=\ltjgetparameter{kanjiskip} \ifdim\@tempskipa>\z@ ... \fi
5365 \@tempskipa=\ltjgetparameter{xkanjiskip}\ifdim\@tempskipa>\z@ ... \fi
5366 \end{lstlisting}
5367 %</ja>
5368
5369 \end{itemize}
5370
5371 %<*ja>
5372 \subsection{\cs{ltjsetparameter} の代替}
5373 原則として各種内部パラメータの設定には \cs{ltjsetparameter} もしくは
5374 \ \cs{ltjglobalsetparameter}\ を用いることになるが,
5375 \cs{ltjsetparameter} の実行には時間がかかるという難点があり,
5376 \LuaTeX-ja の内部ではより高速に実行できる別の形式を用いている.
5377 \emph{本節は一般利用者むけの内容ではない.}
5378
5379 \paragraph{\Param{kanjiskip}, \Param{xkanjiskip} の設定}
5380 \pLaTeXe 新ドキュメントクラスでは,
5381 \begin{lstlisting}
5382 \def\@setfontsize#1#2#3{%
5383   ...
5384   \kanjiskip=0zw plus .1zw minus .01zw
5385   \ifdim\xkanjiskip>\z@
5386     \if@slide \xkanjiskip=0.1em \else
5387       \xkanjiskip=0.25em plus 0.15em minus 0.06em
5388     \fi
5389   \fi}
5390 \end{lstlisting}
5391 と,フォントサイズを変更するごとに \cs{kanjiskip}, \cs{xkanjiskip} を変更している.
5392 この \cs{@setfontsize} は文書の中で多数回実行されるので.
5393 \LuaTeX-ja 用に素直に書き換えた
5394 \begin{lstlisting}
5395   \ltjsetparameter{kanjiskip=0\zw plus .1\zw minus .01\zw}
5396   \@tempskipa=\ltjgetparameter{xkanjiskip}
5397   \ifdim\@tempskipa>\z@
5398     \if@slide
5399       \ltjsetparameter{xkanjiskip=0.1em}
5400     \else
5401       \ltjsetparameter{xkanjiskip=0.25em plus 0.15em minus 0.06em}
5402     \fi
5403   \fi
5404 \end{lstlisting}
5405 としたのではタイプセットが遅くなってしまう.
5406 そこで,\cs{ltjsetparameter} の中で
5407 \begin{itemize}
5408 \item \cs{globaldefs} の値を読み取る \cs{ltj@setpar@global}
5409 \item \Param{kanjiskip} の設定を行う \cs{ltjsetkanjiskip}
5410 \item \Param{xkanjiskip} の設定を行う \cs{ltjsetxkanjiskip}
5411 \end{itemize}
5412 を独立させ,\Pkg{ltjsclasses}では,
5413 \begin{lstlisting}
5414   \ltj@setpar@global
5415   \ltjsetkanjiskip{\z@ plus .1\zw minus .01\zw}
5416   \@tempskipa=\ltjgetparameter{xkanjiskip}
5417   \ifdim\@tempskipa>\z@
5418     \if@slide
5419       \ltjsetxkanjiskip.1em
5420     \else
5421       \ltjsetxkanjiskip.25em plus .15em minus .06em
5422     \fi
5423   \fi
5424 \end{lstlisting}
5425 としている.
5426 \cs{ltj@setpar@global}を直前に実行せず,単独で
5427 \cs{ltjsetkanjiskip}, \cs{ltjsetxkanjiskip}を実行することは想定されていないので注意.
5428
5429
5430
5431 \paragraph{ベースライン補正量の設定}
5432 \pLaTeX の\Pkg{ascmac}パッケージでは,縦組の欧文ベースライン補正量の一時待避・復帰処理に
5433 \ \cs{@saveybaselineshift}\ という寸法レジスタを用い
5434 \begin{lstlisting}
5435 \@savetbaselineshift\tbaselineshift\tbaselineshift\z@
5436 ...
5437 \tbaselineshift\@savetbaselineshift
5438 \end{lstlisting}
5439 という処理を行っている.
5440
5441 これを\LuaTeX-ja 用に \cs{ltjsetparameter} を使って書き直すと,
5442 \begin{lstlisting}
5443 \@savetbaselineshift\ltjgetparameter{talbaselineshift}
5444 \ltjsetparameter{talbaselineshift=\z@}
5445 ...
5446 \ltjsetparameter{talbaselineshift=\@savetbaselineshift}
5447 \end{lstlisting}
5448 となる.
5449
5450 さて,縦組の欧文ベースライン補正量\Param{talbaselineshift}は,
5451 実際には \cs{ltj@tablshift} という属性レジスタに格納されている
5452 (\ref{sec-para}\nobreak 節参照).属性レジスタは長さではなく整数値を格納する\footnote{%
5453   従って,\texttt{\textbackslash @savetbaselineshift=\textbackslash ltj@tablshift}\
5454   のように記述することはできない.属性レジスタを \cs{tbaselineshift} という名称にしなかっ
5455   たのはそのためである.
5456 }ものであり,\cs{ltj@tablshift} は補正量を sp 単位で保持することから,
5457 上記のコードと同じ内容をより速い以下のコードで実現することができる.
5458 \begin{lstlisting}
5459 \@savetbaselineshift\ltj@tablshift sp%
5460 \ltj@tablshift\z@
5461 ...
5462 \ltj@tablshift\@savetbaselineshift
5463 \end{lstlisting}
5464 この手法は \Pkg{ascmac} パッケージの\LuaTeX-ja対応パッチ \Pkg{lltjp-tascmac.sty} で
5465 実際に用いられている.\Pkg{lltjp-tascmac.sty} は自動的に読み込まれるので,
5466 ユーザは何も気にせず普通に \Pkg{ascmac} パッケージを \cs{usepackage} で読みこめば良い.
5467 %</ja>
5468
5469
5470 %<en>\section{Other Commands for plain \TeX\ and \LaTeXe}
5471 %<ja>\section{plainでも\LaTeX でも利用可能なその他の命令}
5472 %<en>\subsection{Commands for Compatibility with \pTeX}
5473 %<ja>\subsection{\pTeX 互換用命令}
5474
5475 %<*en>
5476 The following commands are implemented for compatibility with \pTeX.
5477 Note that the former five commands don't support JIS~X~0213, but only JIS~X~0208.
5478 The last \cs{kansuji} converts an integer into its Chinese numerals.
5479 %</en>
5480 %<*ja>
5481 以下の命令は\pTeX との互換性のために実装されている.そのため,JIS~X~0213には対応せず,
5482 \pTeX と同じようにJIS~X~0208の範囲しかサポートしていない.
5483 %</ja>
5484 \begin{center}
5485 \cs{kuten}, \cs{jis}, \cs{euc}, \cs{sjis}, \cs{jis}, \cs{kansuji}
5486 \end{center}
5487 %<*en>
5488 These six commands takes an internal integer, and returns a \emph{string}.
5489 %</en>
5490 %<*ja>
5491 これら6命令は内部整数を引数とするが,実行結果は\textbf{文字列}であることに注意.
5492 %</ja>
5493 \begin{LTXexample}
5494 \newcount\hoge
5495 \hoge="2423 %"
5496 \the\hoge, \kansuji\hoge\\
5497 \jis\hoge, \char\jis\hoge\\
5498 \kansuji1701
5499 \end{LTXexample}
5500
5501 %<*en>
5502 To change characters of Chinese numerals for each digit, set \Param{kansujichar} parameter:
5503 \begin{LTXexample}
5504 \ltjsetparameter{kansujichar={1,`壹}}
5505 \ltjsetparameter{kansujichar={7,`漆}}
5506 \ltjsetparameter{kansujichar={0,`零}}
5507 \kansuji1701
5508 \end{LTXexample}
5509 %</en>
5510
5511
5512 \subsection{\cs{inhibitglue}}
5513 %<*en>
5514 \cs{inhibitglue} suppresses the insertion of \textbf{JAglue}.
5515 The following is an example, using a special JFM that there will be a glue between
5516 the beginning of a box and ``あ'', and also between ``あ''~and~``ウ''.
5517 %</en>
5518 %<*ja>
5519 \cs{inhibitglue} は\textbf{JAglue}の挿入を抑制する.
5520 以下は,ボックスの始めと「あ」の間,「あ」「ウ」の間にグルーが入る特別なJFMを用いた例で
5521 ある.
5522 %</ja>
5523
5524 \begin{LTXexample}[width=0.4\textwidth]
5525 \jfont\g=file:KozMinPr6N-Regular.otf:jfm=test \g
5526 \fbox{\hbox{あウあ\inhibitglue ウ}}
5527 \inhibitglue\par\noindent あ1
5528 \par\inhibitglue\noindent あ2
5529 \par\noindent\inhibitglue あ3
5530 \par\hrule\noindent あoff\inhibitglue ice
5531 \end{LTXexample}
5532
5533 %<*en>
5534 With the help of this example, we remark the specification of \cs{inhibitglue}:
5535 %</en>
5536 %<*ja>
5537 この例を援用して,\cs{inhibitglue} の仕様について述べる.
5538 %</ja>
5539 \begin{itemize}
5540 %<*en>
5541 \item The call of \cs{inhibitglue} in the (internal) vertical mode is
5542       simply ignored.
5543 %</en>
5544 %<*ja>
5545 \item \emph{\cs{inhibitglue} の垂直モード中での呼び出しは意味を持たない}\footnote{%
5546   この点は\TeX~Live~2014での\pTeX における \cs{inhibitglue} の仕様変更と同じである.
5547 }.
5548 4行目の入力で有効にならないのは,\cs{inhibitglue} の時点では垂直モードであり,
5549 \cs{noindent} の時点で水平モードになるからである.
5550 %</ja>
5551
5552 %<*en>
5553 \item The call of \cs{inhibitglue} in the (restricted) horizontal
5554       mode is only effective on the spot; does not get over boundary of
5555       paragraphs. Moreover, \cs{inhibitglue} cancels ligatures and
5556       kernings, as shown in the last line of above example.
5557 %</en>
5558 %<*ja>
5559 \item \cs{inhibitglue} の(制限された)水平モード中での呼び出しはその場でのみ
5560   有効であり,段落の境界を乗り越えない.
5561   さらに,\cs{inhibitglue} は上の例の最終行のように(欧文における)リガチャとカーニングを
5562   打ち消す.これは,\cs{inhibitglue} が内部的には「現在のリスト中にwhatsitノードを
5563   追加する」ことを行なっているからである.
5564 %</ja>
5565
5566 %<*en>
5567 \item The call of \cs{inhibitglue} in math mode is just ignored.
5568 %</en>
5569 %<*ja>
5570 \item \cs{inhibitglue} を数式モード中で呼び出した場合はただ無視される.
5571 %</ja>
5572
5573 %<*ja>
5574 \item \LaTeX で\LuaTeX-ja を使用する場合は,
5575 \cs{inhibitglue} の代わりとして \verb+\<+ を使うことができる.
5576 既に \verb+\<+ が定義されていた場合は,\LuaTeX-ja の読み込みで強制的に上書きされるので
5577 注意すること.
5578 %</ja>
5579 \end{itemize}
5580
5581
5582 \subsection{\cs{ltjdeclarealtfont}}
5583 \label{ssec-altfont}
5584 %<*en>
5585 Using \cs{ltjdeclarealtfont}, one can ``compose'' more than one Japanese fonts.
5586 This \cs{ltjdeclarealtfont} uses in the following form:
5587 \begin{quote}
5588 \ttfamily \textbackslash ltjdeclarealtfont<base\_font\_cs><alt\_font\_cs>{<range>}
5589 \end{quote}
5590 where  <base\_font\_cs>~and~<alt\_font\_cs> are defined by \cs{jfont}.
5591 Its meaning is
5592 \begin{quote}
5593 If the current Japanese font is <base\_font\_cs>, characters which belong to <range>
5594 is typeset by another Japanese font <alt\_font\_cs>, instead of <base\_font\_cs>.
5595 \end{quote}
5596
5597 <range> is a comma-separated list of character codes, but also accepts negative integers:
5598 $-n$~($n≥1$) means that all characters of character classes~$n$, with respect to JFM used
5599 by <base\_font\_cs>. Note that characters which do not exist in <alt\_font\_cs> are
5600 ignored.
5601
5602 For example, if \cs{hoge} uses \texttt{jfm-ujis.lua}, the standard JFM of \LuaTeX-ja,
5603 then
5604 \begin{lstlisting}
5605 \ltjdeclarealtfont\hoge\piyo{"3000-"30FF, {-1}-{-1}}
5606 \end{lstlisting}
5607 does
5608 \begin{quote}
5609 If the current Japanese font is \cs{hoge}, \texttt{U+3000}--\texttt{U+30FF}
5610 and characters in class~1 (ideographic opening brackets)
5611 are typeset by \cs{piyo}.
5612 \end{quote}
5613 %</en>
5614 %<*ja>
5615 \cs{jfont} の書式を見ればわかるように,基本的には\LuaTeX-jaにおける1つの和文フォントに
5616 使用出来る「実際のフォント」は1つである.
5617 しかし,\cs{ltjdeclarealtfont} を用いると,この原則から外れることができる.
5618
5619 \cs{ltjdeclarealtfont} は以下の書式で使用する:
5620 \begin{quote}
5621 \ttfamily \textbackslash ltjdeclarealtfont<base\_font\_cs><alt\_font\_cs>{<range>}
5622 \end{quote}
5623 これは「現在の和文フォント」が<base\_font\_cs>であるとき,
5624 <range>に属する文字は<alt\_font\_cs>を用いて組版される,という意味である.
5625 \begin{itemize}
5626  \item <base\_font\_cs>, <alt\_font\_cs>は
5627 \cs{jfont} によって定義された和文フォントである.
5628  \item <range>は文字コードの範囲を表すコンマ区切りのリストであるが,
5629    例外として負数$-n$は「<base\_font\_cs>のJFMの文字クラス$n$に属する全ての文字」
5630    を意味する.
5631
5632 <range>中に<alt\_font\_cs>中に実際には存在しない文字が指定された場合は,
5633 その文字に対する設定は無視される.
5634 \end{itemize}
5635
5636 例えば,\cs{hoge} のJFMが\LuaTeX-ja標準の
5637 \ \texttt{jfm-ujis.lua} であった場合,
5638 \begin{lstlisting}
5639 \ltjdeclarealtfont\hoge\piyo{"3000-"30FF, {-1}-{-1}}
5640 \end{lstlisting}
5641 は「\cs{hoge} を利用しているとき,
5642 \texttt{U+3000}--\texttt{U+30FF}と
5643 文字クラス1(開き括弧類)中の文字だけは \cs{piyo} を用いる」
5644 ことを設定する.\verb+{-1}-{-1}+ という変わった指定の仕方をしているのは,
5645 普通に \texttt{-1} と指定したのでは正しく$-1$と読み取られないという
5646 マクロの都合による.
5647 %</ja>
5648
5649
5650
5651 %<en>\section{Commands for \LaTeXe}
5652 %<ja>\section{\LaTeXe 用の命令}
5653
5654 %<en>\subsection{Patch for NFSS2}
5655 %<ja>\subsection{NFSS2へのパッチ}
5656 \label{ssec-nfsspat}
5657
5658 %<*en>
5659 Japanese patch for NFSS2 in \LuaTeX-ja
5660 is based on \texttt{plfonts.dtx} which plays the same role in \pLaTeXe.
5661 We will describe
5662 commands which are not described in Subsection~\ref{ssec-chgfnt}.
5663 %</en>
5664 %<*ja>
5665 \LuaTeX-jaのNFSS2への日本語パッチは
5666 \pLaTeXe で同様の役割を果たす \texttt{plfonts.dtx} をベースに,
5667 和文エンコーディングの管理等をLuaで書きなおしたものである.
5668 ここでは\ref{ssec-chgfnt}節で述べていなかった命令について
5669 記述しておく.
5670 %</ja>
5671
5672 \begin{cslist}%
5673 \item[\normalfont\bfseries %
5674 %<ja>追加の長さ変数達
5675 %<en>additonal dimensions
5676 ]
5677 %<*en>
5678 Like \pLaTeXe, \LuaTeX-ja defines the following dimensions
5679 for information of current Japanese font:
5680 %</en>
5681 %<*ja>
5682 \pLaTeXe と同様に,\LuaTeX-jaは「現在の和文フォントの情報」を格納する長さ変数
5683 %</ja>
5684 \begin{quote}
5685  \cs{cht}~(height), \cs{cdp}~(depth), \cs{cHT}~(sum of former two),\\
5686  \cs{cwd}~(width), \cs{cvs}~(lineskip), \cs{chs}~(equals to \cs{cwd})
5687 \end{quote}
5688 %<en>and its \cs{normalsize} version:
5689 %<ja>と,その \cs{normalsize} 版である
5690 \begin{quote}
5691  \cs{Cht}~(height), \cs{Cdp}~(depth),
5692  \cs{Cwd}~(width), \\\cs{Cvs}~(equals to \cs{baselineskip}),
5693  \cs{Chs}~(equals to \cs{cwd})%
5694 %<en>.
5695 \end{quote}
5696 %<*ja>
5697 を定義している.なお,\cs{cwd} と \cs{zw},また
5698 \cs{cHT} と \cs{zh} は一致しない可能性がある.なぜなら,
5699 \cs{cwd},~\cs{cHT} は「あ」の寸法から決定されるのに対し,
5700 \cs{zw} と \cs{zh} はJFMに指定された値に過ぎないからである.
5701 %</ja>
5702 %<*en>
5703 Note that \cs{cwd}~and~\cs{cHT} may  differ from \cs{zw}~and~\cs{zh}
5704 respectively.
5705 On the one hand the former dimensions are determined from the character ``あ'',
5706 but on the other hand \cs{zw}~and~\cs{zh} are specified by JFM.
5707 %</en>
5708
5709
5710 \item[\cs{DeclareYokoKanjiEncoding}\{<encoding>\}\{<text-settings>\}\{<math-settings>\}]
5711 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
5712 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
5713 \item[\cs{DeclareTateKanjiEncoding}\{<encoding>\}\{<text-settings>\}\{<math-settings>\}]
5714
5715 %<*en>
5716 In NFSS2 under \LuaTeX-ja, distinction between alphabetic fonts
5717              and Japanese fonts are only made by their
5718              encodings. For example, encodings OT1 and T1 are encodings for
5719              alphabetic fonts, and Japanese fonts cannot
5720              have these encodings. These command define a new encoding
5721              scheme for Japanese font families.
5722 %</en>
5723 %<*ja>
5724 \LuaTeX-jaのNFSS2においては,欧文フォントと和文フォントは
5725 そのエンコーディングによってのみ区別される.
5726 例えば,OT1とT1のエンコーディングは欧文フォントのエンコーディングであり,
5727 和文フォントはこれらのエンコーディングを持つことはできない.
5728 これらコマンドは横組用・縦組用和文フォントのための新しいエンコーディングを
5729 それぞれ定義する.
5730 %</ja>
5731
5732 \item[\cs{DeclareKanjiEncodingDefaults}\{<text-settings>\}\{<math-settings>\}]
5733 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
5734 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
5735 \item[\cs{DeclareKanjiSubstitution}\{<encoding>\}\{<family>\}\{<series>\}\{<shape>\}]
5736 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
5737 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
5738 \item[\cs{DeclareErrorKanjiFont}\{<encoding>\}\{<family>\}\{<series>\}\{<shape>\}\{<size>\}]
5739
5740 %<*en>
5741 The above 3~commands are just the counterparts for \cs{DeclareFontEncodingDefaults} and~others.
5742 %</en>
5743 %<*ja>
5744 上記3つのコマンドはちょうどNFSS2 の \cs{DeclareFontEncodingDefaults} などに対応するものである.
5745 %</ja>
5746
5747 \item[\cs{reDeclareMathAlphabet}\{<unified-cmd>\}\{<al-cmd>\}\{<ja-cmd>\}]
5748
5749 % ToDo: en
5750 %<*ja>
5751 和文・欧文の数式用フォントファミリを一度に変更する命令を作成する.
5752 具体的には,欧文数式用フォントファミリ変更の命令<al-cmd>(\cs{mathrm} 等)と,和文数式用フォ
5753              ントファミリ変更の命令<ja-cmd>(\cs{mathmc} 等)の2つを同時に行う命令として
5754              <unified-cmd>を(再)定義する.実際の使用では<unified-cmd>と
5755              <al-cmd>に同じものを指定する,すなわち,<al-cmd>で和文側も変
5756              更させるようにするのが一般的と思われる.
5757
5758 本命令は
5759 \begin{center}\tt
5760 <unified-cmd>\{<arg>\}\quad$\longrightarrow$\quad
5761 (<al-cmd>の1段展開結果)\{<ja-cmd>の1段展開結果)\{<arg>\}\}
5762 \end{center}
5763 と定義を行うので,使用には注意が必要である:
5764 %<en>\vspace{-\medskipamount}
5765 \begin{itemize}
5766 \item <al-cmd>,~<ja-cmd>は既に定義されていなければならない.
5767       \cs{reDeclareMathAlphabet}\\の後に
5768 両命令の内容を再定義しても,<unified-cmd>の内容にそれは反映されない.
5769 \item <al-cmd>,~<ja-cmd>に\verb+\@mathrm+などと \texttt{@} をつけた命令を指定した時の動作は保証できない.
5770 \end{itemize}
5771 %</ja>
5772
5773 \item[\cs{DeclareRelationFont}\{<ja-encoding>\}\{<ja-family>\}\{<ja-series>\}\{<ja-shape>\}\\*
5774   \null\hfill\{<al-encoding>\}\{<al-family>\}\{<al-series>\}\{<al-shape>\}]
5775 %<*en>
5776 This command sets the ``accompanied'' alphabetic font (given by the latter 4~arguments)
5777 with respect to a Japanese font given by the former 4~arguments.
5778 %</en>
5779 %<*ja>
5780 いわゆる「従属欧文」を設定するための命令である.前半の4引数で表される和文フォントに対して,
5781 そのフォントに対応する「従属欧文」のフォントを後半の4引数により与える.
5782 %</ja>
5783 \item[\cs{SetRelationFont}]
5784 %<*en>
5785 This command is almost same as \cs{DeclareRelationFont}, except that this command does a local
5786 assignment, where \cs{DeclareRelationFont} does a global assignment.
5787 %</en>
5788 %<*ja>
5789 このコマンドは \cs{DeclareRelationFont} とローカルな指定であることを除いて
5790 ほとんど同じである(\cs{DeclareRelationFont} はグローバル).
5791 %</ja>
5792
5793 \item[\cs{userelfont}]
5794 %<*en>
5795 Change current alphabetic font encoding/family/\dots\ to the `accompanied' alphabetic
5796              font family with respect to current Japanese font family,
5797              which was set by
5798              \cs{DeclareRelationFont} or \cs{SetRelationFont}.
5799 Like \cs{fontfamily}, \cs{selectfont} is required to take an effect.
5800 %</en>
5801 %<*ja>
5802 現在の欧文フォントのエンコーディング/ファミリ/…… を,
5803 \cs{DeclareRelationFont} か \cs{SetRelationFont} で指定された
5804 現在の和文フォントに対応する「従属欧文」フォントに変更する.
5805 \cs{fontfamily} のように,有効にするためには \cs{selectfont} が必要である.
5806 %</ja>
5807
5808 \item[\cs{adjustbaseline}]
5809 %<*en>
5810 In \pLaTeXe, \cs{adjustbaseline} sets \cs{tbaselineshift}
5811 to match the vertical center of ``M'' and that of ``あ''  in vertical typesetting:
5812 \[
5813 \text{\cs{tbaselineshift}} \leftarrow
5814 \frac{(h_{\text{M}}+d_{\text{M}}) - (h_{\text{あ}}+d_{\text{あ}})}2
5815   + d_{\text{あ}} - d_{\text{M}},
5816 \]
5817 where $h_{a}$~and~$d_{a}$ denote the height of ``$a$'' and the depth, respectively.
5818 In \LuaTeX-ja, this \cs{adjustbaseline} does same task, namely setting the
5819              \Param{talbaselineshift} parameter.
5820 %</en>
5821 %<*ja>
5822 \pLaTeXe では,\cs{adjustbaseline} は縦組時に「M」と「あ」の中心線を一致させるために,
5823 \cs{tbaselineshift} を設定する役割を持っていた:
5824 \[
5825 \text{\cs{tbaselineshift}} \leftarrow
5826 \frac{(h_{\text{M}}+d_{\text{M}}) - (h_{\text{あ}}+d_{\text{あ}})}2
5827   + d_{\text{あ}} - d_{\text{M}},
5828 \]
5829 ここで,$h_{a}$,~$d_{a}$はそれぞれ「$a$」の高さ・深さを表す.
5830 \LuaTeX-jaにおいても\cs{adjustbaseline} は同様に\Param{talbaselineshift}パラメータの調整処
5831              理を行っている.
5832
5833 同時に,これも\pLaTeXe の \cs{adjustbaseline} で行われていたが,
5834 「漢」の寸法を元に,(本節の最初に述べた,小文字で始まる)\cs{cht}, \cs{cwd} といった長さ変数を設定する.
5835 %</ja>
5836
5837 \item[\cs{fontfamily}\{<family>\}]
5838 %<*en>
5839 As in \LaTeXe, this command changes current font family (alphabetic, Japanese,~\emph{or both})
5840 to <family>. Which family will be changed is determined as follows:
5841 %</en>
5842 %<*ja>
5843 元々の\LaTeXe におけるものと同様に,このコマンドは現在のフォントファミリ(欧文,
5844 和文,\emph{もしくは両方})を<family>に変更する.
5845 どのファミリが変更されるかは以下のようにして決定される:
5846 %</ja>
5847 \begin{itemize}
5848 %<*en>
5849 \item Let current encoding scheme for Japanese fonts be
5850       <ja-enc>. Current Japanese font family will be changed to
5851       <family>, if one of the following two conditions is met:
5852 %</en>
5853 %<*ja>
5854 \item 現在の和文フォントに対するエンコーディングが<ja-enc>であるとしよう.
5855   現在の和文フォントファミリは,以下の2つの条件のうちの1つが満たされているときに
5856   <family>に変更される:
5857 %</ja>
5858 \begin{itemize}
5859 %<*en>
5860 \item The family <family> under the encoding <ja-enc> has been already defined by
5861       \cs{DeclareKanijFamily}.
5862 %</en>
5863 %<*ja>
5864 \item エンコーディング<ja-enc>におけるファミリ<family>が
5865 既に \cs{DeclareKanjiFamily} によって定義されている.
5866 %</ja>
5867 %<*en>
5868 \item A font definition named \texttt{<ja-enc><family>.fd} (the file name is
5869       all lowercase) exists.
5870 %</en>
5871 %<*ja>
5872 \item フォント定義ファイル\texttt{<ja-enc><family>.fd}(ファイル名は全て小文字)が存在する.
5873 %</ja>
5874 \end{itemize}
5875 %<*en>
5876 \item Let current encoding scheme for alphabetic fonts be
5877       <al-enc>. For alphabetic font family, the criterion as above is used.
5878 %</en>
5879 %<*ja>
5880 \item 現在の欧文フォントに対するエンコーディングを<al-enc>とする.
5881   欧文フォントファミリに対しても,上記の基準が用いられる.
5882 %</ja>
5883 %<*en>
5884 \item There is a case which none of the above applies, that is, the font
5885       family named <family> doesn't seem to be defined neither under the
5886       encoding <ja-enc>, nor under <al-enc>.
5887 In this case, the default family for font substitution is used for
5888       alphabetic and Japanese fonts. Note that current encoding will not
5889       be set to <family>, unlike the original implementation in \LaTeX.
5890 %</en>
5891 %<*ja>
5892 \item 上記のいずれもが適用されない,つまり<family>が<ja-enc>と<al-enc>の
5893   どちらでも定義されないような場合がある.
5894   この場合,代替フォントに用いられるデフォルトのフォントファミリが欧文フォントと
5895   和文フォントに用いられる.\LaTeX のオリジナルの実装とは異なり,
5896   現在のエンコーディングは<family>には設定されないことに注意する.
5897 %</ja>
5898 \end{itemize}%
5899 %<en>\vspace{-\medskipamount}
5900
5901
5902 \begin{figure}[!tb]
5903 \begin{LTXexample}[pos=b]
5904 \DeclareKanjiFamily{JY3}{edm}{}
5905 \DeclareFontShape{JY3}{edm}{m}{n}    {<-> s*KozMinPr6N-Regular:jfm=ujis;}{}
5906 \DeclareFontShape{JY3}{edm}{m}{green}{<-> s*KozMinPr6N-Regular:jfm=ujis;color=007F00}{}
5907 \DeclareFontShape{JY3}{edm}{m}{blue} {<-> s*KozMinPr6N-Regular:jfm=ujis;color=0000FF}{}
5908 \DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{green}{"4E00-"67FF,{-2}-{-2}}
5909 \DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{blue}{ "6800-"9FFF}
5910 {\kanjifamily{edm}\selectfont
5911 日本国民は、正当に選挙された国会における代表者を通じて行動し、……}
5912 \end{LTXexample}
5913 %<ja>\caption{\cs{DeclareAlternateKanjiFont} の使用例}
5914 %<en>\caption{An example of \cs{DeclareAlternateKanjiFont}}
5915 \label{fig:altkanji}
5916 \end{figure}
5917
5918 \item[\cs{DeclareAlternateKanjiFont}\{<base-encoding>\}\{<base-family>\}\{<base-series>\}\{<base-shape>\}\\
5919   \null\hfill\{<alt-encoding>\}\{<alt-family>\}\{<alt-series>\}\{<alt-shape>\}\{<range>\}]
5920 %<*ja>
5921 \ref{ssec-altfont}節の\
5922 \cs{ltjdeclarealtfont} と同様に,前半の4引数の
5923 和文フォント(基底フォント)のうち<range>中の文字を
5924 第5から第8引数の和文フォントを使って組むように指示する.
5925 使用例を図\nobreak\ref{fig:altkanji}に載せた.
5926
5927 \begin{itemize}
5928  \item
5929 \cs{ltjdeclarealtfont} では基底フォント・置き換え先和文フォントはあらかじめ定義されてい
5930              ないといけない(その代わり即時発効)であったが,
5931 \cs{DeclareAlternateKanjiFont} の設定が
5932 実際に効力が発揮するのは,書体変更やサイズ変更を行った時,
5933 あるいは(これらを含むが)\cs{selectfont} が実行された時である.
5934  \item
5935 段落やhboxの最後での設定値が段落/hbox全体にわたって通用する点や,
5936 <range>に負数$-n$を指定した場合,それが「基底フォントの文字クラス$n$に属する文字全体」
5937 と解釈されるのは \cs{ltjdeclarealtfont} と同じである.
5938 \end{itemize}%
5939 %</ja>
5940 %<*en>
5941 As \cs{ltjdeclarealtfont}~(Subsection~\ref{ssec-altfont}),
5942 characters in <range> of the Japanese font (we say the \emph{base font})
5943 which specified by first 4 arguments are typeset
5944 by the Japanese font which specified by fifth to eighth arguments
5945 (we say the \emph{alternate font}).
5946 An example is shown in Figure~\ref{fig:altkanji}.
5947
5948 \begin{itemize}
5949  \item
5950 In \cs{ltjdeclarealtfont}, the base font and the alternate font must be already defined.
5951 But this \cs{DeclareAlternateKanjiFont} is not so.
5952 In other words, \cs{DeclareAlternateKanjiFont} is effective only after
5953 current Japanese font is changed, or only after \cs{selectfont} is executed.
5954  \item \dots
5955 \end{itemize}%
5956 \vspace{-\medskipamount}
5957 %</en>
5958 \end{cslist}
5959
5960 %<*en>
5961 As closing this subsection, we shall introduce an example of
5962 \cs{SetRelationFont} and \cs{userelfont}:
5963 %</en>
5964 %<*ja>
5965 この節の終わりに,\cs{SetRelationFont} と \cs{userelfont} の例を
5966 紹介しておこう.\cs{userelfont} の使用によって,「abc」の部分のフォントが
5967 Avant Garde (OT1/pag/m/n) に変わっていることがわかる.
5968 %</ja>
5969 \begin{LTXexample}[width=0.3\textwidth]
5970 \makeatletter
5971 \SetRelationFont{JY3}{\k@family}{m}{n}{OT1}{pag}{m}{n}
5972   % \k@family: current Japanese font family
5973 \userelfont\selectfont あいうabc
5974 \end{LTXexample}
5975
5976 %<*en>
5977 \section{Addons}
5978 \LuaTeX-ja has several addon packages.
5979 These addons are written as \LaTeX\ packages, but
5980 \Pkg{luatexja-otf} and~\Pkg{luatexja-adjust} can be loaded in plain \LuaTeX\
5981 by \cs{input}.
5982 %</en>
5983 %<*ja>
5984 \section{拡張}
5985 \LuaTeX-jaには(動作には必須ではないが)自由に読み込める拡張が付属している.
5986 これらは\LaTeX のパッケージとして制作しているが,
5987 \Pkg{luatexja-otf}と\Pkg{luatexja-adjust}についてはplain \LuaTeX でも\
5988 \cs{input} で読み込み可能である.
5989 %</ja>
5990 \subsection{\texttt{luatexja-fontspec.sty}}
5991 \label{ssec-fontspec2}
5992 %<*en>
5993 As described in Subsection~\ref{ssec-fontspec}, this optional package
5994 provides the counterparts for several commands defined in the
5995 \Pkg{fontspec} package (requires \Pkg{fontspec}~v2.4).
5996 In addition to OpenType font features in the original \Pkg{fontspec},
5997 the following ``font features'' specifications are allowed for
5998 the commands of Japanese version:
5999 %</en>
6000 %<*ja>
6001 \ref{ssec-fontspec}節で述べたように,この追加パッケージは\Pkg{fontspec}%
6002 パッケージで定義されているコマンドに対応する和文フォント用のコマンドを提供する.
6003
6004 \Pkg{fontspec}パッケージで指定可能な各種font featureに加えて,和文版のコマンドには
6005 以下の``font feature''を指定することができる:
6006 %</ja>
6007
6008
6009 \begin{cslist}
6010 \item[CID=<name>\textrm{, }JFM=<name>\textrm{, }JFM-var=<name>]
6011
6012 %<*en>
6013 These 3 keys correspond to \texttt{cid}, \texttt{jfm} and
6014 \texttt{jfmvar} keys for \cs{jfont}~and~\cs{tfont} respectively.
6015 See Subsections~\ref{ssec-jfont} and \ref{ssec-psft} for details
6016  of \texttt{cid}, \texttt{jfm} and
6017 \texttt{jfmvar} keys.
6018
6019 The \texttt{CID} key is effective only when with \texttt{NoEmbed}
6020 described below. The same JFM cannot be used in both horizontal Japanese fonts and
6021              vertical Japanese fonts, hence the \texttt{JFM} key
6022 will be actually used in \texttt{YokoFeatures}~and~\texttt{TateFeatures} keys.
6023 %</en>
6024 %<*ja>
6025 これら3つのキーはそれぞれ \cs{jfont},~\cs{tfont}に対する
6026 \texttt{cid}, \texttt{jfm}, \texttt{jfmvar}キーとそれぞれ対応する.
6027 \texttt{cid}, \texttt{jfm}, \texttt{jfmvar}キーの詳細は\ref{ssec-jfont}節
6028              と\ref{ssec-psft}節を参照.
6029
6030 \texttt{CID} キーは下の \texttt{NoEmbed} と合わせて用いられたときのみ有効である.
6031 また,横組用JFMと縦組用JFMは共用できないため,実際に \texttt{JFM} キーを用いる際は
6032 後に述べる\ \texttt{YokoFeatures} キーや \texttt{TateFeatures}\ の中で用いる
6033 ことになる.
6034 %</ja>
6035
6036 \item[NoEmbed]
6037 %<*en>
6038 By specifying this key, one can use ``name-only'' Japanese font which
6039 will not be embedded in the output PDF file. See Subsection~\ref{ssec-psft}.
6040 %</en>
6041 %<*ja>
6042 これを指定することで,PDFに埋め込まれない「名前だけ」のフォントを指定することが
6043 できる.\ref{ssec-psft}節を参照.
6044 %</ja>
6045
6046 \begin{figure}[!tb]
6047 \begin{LTXexample}[width=0.25\textwidth]
6048 \jfontspec[
6049   YokoFeatures={Color=007F00}, TateFeatures={Color=00007F},
6050   TateFont=KozGoPr6N-Regular
6051 ]{KozMinPr6N-Regular}
6052 \hbox{\yoko 横組のテスト}\hbox{\tate 縦組のテスト}
6053 \addjfontfeatures{Color=FF0000}
6054 \hbox{\yoko 横組}\hbox{\tate 縦組}
6055 \end{LTXexample}
6056 %<ja>\caption{\texttt{TateFeatures} 等の使用例}
6057 %<en>\caption{An example of \texttt{TateFeatures} etc.}
6058 \label{fig:yokotate-fontspec}
6059 \end{figure}
6060
6061
6062 \item[TateFeatures=\{<features>\}\textrm{, }TateFont=<font>]
6063 %<*en>
6064 The \texttt{TateFeatures} key specifies font features which are only turned~on in
6065 vertical writing, such as \texttt{Style=VerticalKana}~(\texttt{vkna} feature).
6066 Similarly, the \texttt{TateFont} key specifies the Japanese font which will be used only
6067              in vertical writing.
6068 A demonstrarion is shown in Figure~\ref{fig:yokotate-fontspec}.
6069 %</en>
6070 %<*ja>
6071 縦組において使用されるフォントや,縦組においてのみ適用されるfeature達を
6072 指定する.使用例は図\ref{fig:yokotate-fontspec}参照.
6073 %</ja>
6074
6075 \item[YokoFeatures=\{<features>\}]
6076 %<*en>
6077 The \texttt{YokoFeatures} key specifies font features which are only turned~on in
6078 horizontal writing,.
6079 A demonstrarion is shown in Figure~\ref{fig:yokotate-fontspec}.
6080 %</en>
6081 %<*ja>
6082 同様に,横組においてのみ適用されるfeature達を
6083 指定する.使用例は図\ref{fig:yokotate-fontspec}参照.
6084 %</ja>
6085
6086
6087 \begin{figure}[!tb]
6088 \begin{LTXexample}[pos=b]
6089 \jfontspec[
6090   AltFont={
6091     {Range="4E00-"67FF, Color=007F00},
6092     {Range="6800-"9EFF, Color=0000FF},
6093     {Range="3040-"306F, Font=KozGoPr6N-Regular},
6094   }
6095 ]{KozMinPr6N-Regular}
6096 日本国民は、正当に選挙された国会における代表者を通じて行動し、われらとわれらの子孫のために、
6097 諸国民との協和による成果と、わが国全土にわたつて自由のもたらす恵沢を確保し、……
6098 \end{LTXexample}
6099 %<ja>\caption{\texttt{AltFont} の使用例}
6100 %<en>\caption{An example of \texttt{AltFont}}
6101 \label{fig:altkanji-fontspec}
6102 \end{figure}
6103
6104 \item[AltFont]
6105
6106 %<*en>
6107 As \cs{ltjdeclarealtfont}~(Subsection~\ref{ssec-altfont}) and
6108 \cs{DeclareAlternateKanjiFont}~(Subsection~\ref{ssec-nfsspat}),
6109 with this key, one can typeset some Japanese characters
6110 by a different font and/or using different features.
6111 The \texttt{AltFont} feature takes a comma-separated list of comma-separated lists,
6112 as the following:
6113 %</en>
6114 %<*ja>
6115 \ref{ssec-altfont}節の \cs{ltjdeclarealtfont} や,
6116 \ref{ssec-nfsspat}節の \cs{DeclareAlternateKanjiFont} と同様に,
6117 このキーを用いると一部の文字を異なったフォントやfont featureを使って組むことができる.
6118 \texttt{AltFont} キーに指定する値は,次のように二重のコンマ区切りリストである:
6119 %</ja>
6120 \begin{lstlisting}[escapechar=\#]
6121 AltFont = {
6122   ...
6123   { Range=#\LARG range>#, #\LARG features>#},
6124   { Range=#\LARG range>#, Font=#\LARG font~name>#, #\LARG features># },
6125   { Range=#\LARG range>#, Font=#\LARG font~name># },
6126   ...
6127 }
6128 \end{lstlisting}
6129 %<*en>
6130 Each sublist should have the \texttt{Range} key
6131 (sublist which does not contain \texttt{Range} key is simply ignored).
6132 A demonstrarion is shown in Figure~\ref{fig:altkanji-fontspec}.
6133 %</en>
6134 %<*ja>
6135 各部分リストには \texttt{Range} キーが必須である(含まれない部分リストは
6136 単純に無視される).指定例は図\ref{fig:altkanji-fontspec}に示した.
6137 %</ja>
6138 \end{cslist}
6139
6140 %<*ja>
6141 なお,\Pkg{luatexja-fontspec} 読み込み時には和文フォント定義ファイル%
6142 \texttt{<ja-enc><family>.fd}は全く参照されなくなる.
6143 %</ja>
6144
6145
6146 %<*en>
6147 \paragraph{Remark on \texttt{AltFont}, \texttt{YokoFeatures}, \texttt{TateFeatures} keys}
6148 In \texttt{AltFont},~\texttt{YokoFeatures},~\texttt{TateFeatures} keys,
6149 one cannot specify per-shape settings such as \texttt{BoldFeatures}.
6150 For example,
6151 \begin{lstlisting}
6152 AltFont = {
6153   { Font=HogeraMin-Light, BoldFont=HogeraMin-Bold,
6154     Range="3000-"30FF, BoldFeatures={Color=007F00} }
6155 }
6156 \end{lstlisting}
6157 does \emph{not} work. Instead, one have to write
6158 \begin{lstlisting}
6159 UprightFeatures = {
6160   AltFont = { { Font=HogeraMin-Light, Range="3000-"30FF, } },
6161 },
6162 BoldFeatures = {
6163   AltFont =  { { Font=HogeraMin-Bold, Range="3000-"30FF, Color=007F00 } },
6164 }
6165 \end{lstlisting}
6166
6167 On the other hand, \texttt{YokoFeatures}, \texttt{TateFeatures} and  \texttt{TateFont}
6168 keys can be specified in each list in the \texttt{AltFont} key. Also,
6169 one can specify \texttt{AltFont} inside \texttt{YokoFeatures},~\texttt{TateFeatures}.
6170
6171 Note that features which are specified in \texttt{YokoFeatures}~and~\texttt{TateFeatures}
6172 are always interpreted \emph{after} other ``direction-independent'' features.
6173 This explains why \cs{addjfontfeatures} at~line~6 in~Figure~\ref{fig:yokotate-fontspec}
6174 has no effect, because a color specification is already done in
6175 \texttt{YokoFeatures}~and~\texttt{TateFeatures} keys.
6176 %</en>
6177 %<*ja>
6178 \paragraph{\texttt{AltFont}, \texttt{YokoFeatures}, \texttt{TateFeatures} 等の制限}
6179 \texttt{AltFont},~\texttt{YokoFeatures},~\texttt{TateFeatures}の各キーは
6180 シェイプ別に指定されるべきものであり,
6181 内部では \texttt{BoldFeatures} などのシェイプ別の指定は行うことが出来ない.
6182 例えば.
6183 \begin{lstlisting}
6184 AltFont = {
6185   { Font=HogeraMin-Light, BoldFont=HogeraMin-Bold,
6186     Range="3000-"30FF, BoldFeatures={Color=007F00} }
6187 }
6188 \end{lstlisting}
6189 のように指定することは出来ず,
6190 \begin{lstlisting}
6191 UprightFeatures = {
6192   AltFont = { { Font=HogeraMin-Light, Range="3000-"30FF, } },
6193 },
6194 BoldFeatures = {
6195   AltFont =  { { Font=HogeraMin-Bold, Range="3000-"30FF, Color=007F00 } },
6196 }
6197 \end{lstlisting}
6198 のように指定しなければならない.
6199
6200 一方,\texttt{AltFont} キー内の各リストでは
6201 \ \texttt{YokoFeatures},~\texttt{TateFeatures} 及び \texttt{TateFont} キーを
6202 指定することは可能であり.また\ \texttt{YokoFeatures},~\texttt{TateFeatures} キーの
6203 中身に \texttt{AltFont} を指定することができる.
6204
6205 また,図\ref{fig:yokotate-fontspec}後半部では6行目の色の指定が効かず,
6206 2行目で指定した\ \texttt{YokoFeatures},~\texttt{TateFeatures}\ による色の指定が有効になっ
6207 たままである.これは\emph{\ \texttt{YokoFeatures},~\texttt{TateFeatures}\ によるfeature指定は
6208 組方向に依存しないfeature指定より後に解釈される}からである.
6209
6210 %</ja>
6211
6212
6213 \subsection{\texttt{luatexja-otf.sty}}
6214 \label{ssec-ltjotf}
6215 %<*en>
6216 This optional package supports typesetting characters in
6217 Adobe-Japan1 character collection
6218 (or other CID character collection, if the font is supported).
6219 The package \Pkg{luatexja-otf} offers the following 2~low-level
6220 commands:
6221 %</en>
6222 %<*ja>
6223 この追加パッケージはAdobe-Japan1(フォント自身が持っていれば,
6224 別のCID文字セットでも可)の文字の出力をサポートする.
6225 \Pkg{luatexja-otf}は以下の2つの低レベルコマンドを提供する:
6226 %</ja>
6227 \begin{cslist}
6228 \item[\cs{CID}\{<number>\}]
6229 %<*en>
6230 Typeset a character whose CID number is <number>.
6231 %</en>
6232 %<*ja>
6233 CID番号が<number>の文字を出力する.
6234 %</ja>
6235
6236 \item[\cs{UTF}\{<hex\_number>\}]
6237 %<*en>
6238 Typeset a character whose character code is <hex\_number> (in hexadecimal).
6239 This command is similar to \verb+\char"+<hex\_number>,\ %"
6240 but please remind remarks below.
6241 %</en>
6242 %<*ja>
6243 文字コードが(16進で)<hex\_number>の文字を出力する.
6244 このコマンドは \verb+\char"+<hex\_number>と似ているが,下の注意を参照すること.%"
6245 %</ja>
6246 \end{cslist}
6247
6248 %<*ja>
6249 このパッケージは,マクロ集 \texttt{luatexja-ajmacros.sty}\footnote{\Pkg{otf}パッケージ付属の井上浩一氏によるマクロ集
6250 \texttt{ajmacros.sty} に対して
6251 漢字コードをUTF-8にしたり,plain \LuaTeX でも利用可能にするという
6252 修正を加えたものである.}\ も自動的に読み込む.
6253 \texttt{luatexja-ajmacros.sty} は,
6254 そのため,\Pkg{luatexja-otf} を読みこめば \texttt{ajmacros.sty} マクロ集にある \cs{aj半角} などのマクロもそのまま使うことができる.
6255 %</ja>
6256 %<*en>
6257 This package automatically loads \texttt{luatexja-ajmacros.sty}, which is slightly
6258 modified version of \texttt{ajmacros.sty}\footnote{Useful macros by iNOUE Koich!, for the
6259 \Pkg{japanese-otf} package.}.
6260 Hence one can use macros which sre defined in \texttt{ajmacros.sty}, such as~\cs{aj半角}.
6261 %</en>
6262
6263 %<en>\paragraph{Remarks}
6264 %<ja>\paragraph{注意}
6265 %<*en>
6266 Characters by \cs{CID} and \cs{UTF} commands are different from
6267 ordinary characters in the following points:
6268 %</en>
6269 %<*ja>
6270 \cs{CID} と \cs{UTF} コマンドによって出力される文字は
6271 以下の点で通常の文字と異なる:
6272 %</ja>
6273 \begin{itemize}
6274 %<*en>
6275 \item Always treated as \textbf{JAchar}s.
6276 %</en>
6277 %<*ja>
6278 \item 常に\textbf{JAchar}として扱われる.
6279 %</ja>
6280 %<*en>
6281 \item Processing codes for supporting OpenType features (\textit{e.g.},
6282       glyph replacement and kerning) by the \Pkg{luaotfload} package
6283       is not performed to these characters.
6284 %</en>
6285 %<*ja>
6286 \item OpenType feature(例えばグリフ置換やカーニング)をサポートするための
6287   \Pkg{luaotfload}パッケージのコードはこれらの文字には働かない.
6288 %</ja>
6289 \end{itemize}
6290
6291 %<en>\paragraph{Additional syntax of JFM}
6292 %<ja>\paragraph{JFMへの記法の追加}
6293
6294 %<*en>
6295 The package \Pkg{luatexja-otf} extends the syntax of JFM; the entries of \texttt{
6296 chars} table in JFM now allows a string in the form
6297 \verb+'AJ1-xxx'+, which stands for the character
6298 whose CID number in Adobe-Japan1 is \verb+xxx+.
6299
6300 This extended notation is used in the standard JFM \texttt{jfm-ujis.lua}
6301 to typeset halfwidth Hiragana glyphs (CID~516--598) in halfwidth.
6302 %</en>
6303 %<*ja>
6304 \Pkg{luatexja-otf}パッケージを読み込むと,
6305 JFMの\texttt{chars}テーブルのエントリとして \verb+'AJ1-xxx'+ の形の文字列が
6306 使えるようになる.これはAdobe-Japan1におけるCID番号が \verb+xxx+ の文字を表す.
6307
6308 この拡張記法は,標準JFM~\texttt{jfm-ujis.lua}で,半角ひらがなのグリフ(CID~516--598)を
6309 正しく半角幅で組むために利用されている.
6310 %</ja>
6311
6312 %<*en>
6313 \paragraph{IVS support}
6314 Recent fonts support Ideographic Variation Selector (IVS).
6315 It seems that \Pkg{luaotfload} and \Pkg{fontspec} packages do not support
6316 IVS, so we implemented IVS support in \Pkg{luatexja-otf}.
6317 \emph{IVS support is experimental; if you want to enable this, load
6318 \Pkg{luatexja-otf} and execute the following:}
6319 %</en>
6320 %<*ja>
6321 \paragraph{IVSサポート}
6322 最近のOpenTypeフォントやTrueTypeフォントには,
6323 \texttt{U+E0100}--\texttt{U+E01EF}の範囲の「文字」
6324 (漢字用異体字セレクタ)を後置することによって
6325 字形を指定する仕組み(IVS)が含まれている.
6326 執筆時点の2013年12月では,\Pkg{luaotfload}や\Pkg{fontspec}パッケージ類は
6327 IVSに対応してはいないようである.これらのパッケージで対応してくれるのが理想的だが,
6328 それまでのつなぎとして,\Pkg{luatexja-otf}パッケージ内にIVS対応を仕込んでおいた.
6329
6330 \medskip
6331
6332 \emph{IVS対応は試験的なものである.
6333 有効にするには,\Pkg{luatexja-otf}パッケージを読み込んだ上で以下の命令を実行する%
6334 \footnote{この命令を2回以上実行しても意味がない.}:}
6335 %</ja>
6336 \begin{lstlisting}
6337 \directlua{luatexja.otf.enable_ivs()}
6338 \end{lstlisting}
6339 %<ja> すると,上の命令を実行した箇所以降では,以下のようにIVSによる字形指定が有効となる.
6340 %<en> After executing the command above, you can use IVS like the following:
6341 \begin{LTXexample}
6342 \Large
6343 \jfontspec{KozMinPr6N-Regular}
6344 奈良県葛󠄀城市と,東京都葛󠄁飾区.\\
6345 こんにちは,渡
6346 邉󠄀邉󠄁邉󠄂邉󠄃邉󠄄
6347 邉󠄅邉󠄆邉󠄇邉󠄈邉󠄉
6348 邉󠄊邉󠄋邉󠄌邉󠄍邉󠄎
6349 さん.
6350 \end{LTXexample}
6351 %<*ja>
6352 左上側の入力においては,漢字用異体字セレクタを明示するため,
6353 例えばVariation~Selector~18 (\texttt{U+E0101})を\IVSB{18}のように表記している.
6354 %</ja>
6355 \medskip
6356
6357 %<*en>
6358 Specifying glyph variants by IVS precedes glyph replacement by font features.
6359 For example, only ``葛'' in ``葛西'' is changed by font features
6360 \texttt{jp78}~or~\texttt{jp90}, which does not followed by any variation selector.
6361 %</en>
6362 %<*ja>
6363 また,IVSによる字形指定は,font featureによるそれに優先されることとした.
6364 下の例において,\texttt{jp78}, \texttt{jp90} 指定で字形が変化した文字は
6365 異体字セレクタが続いていない「葛西」中の「葛」のみである.
6366 %</ja>
6367 \begin{LTXexample}
6368  \def\TEST#1{%
6369    {\jfontspec[#1]{KozMinPr6N-Regular}%
6370    葛󠄀城市,葛󠄁飾区,葛西}\\}
6371  指定なし:\TEST{}
6372  \texttt{jp78}:\TEST{CJKShape=JIS1978}
6373  \texttt{jp90}:\TEST{CJKShape=JIS1990}
6374 \end{LTXexample}
6375
6376 %<*ja>
6377 現状では,\TeX 側のインターフェースとなる \Pkg{luatexja-otf.sty} は一切変更していない
6378 ので,ZRさんによる\Pkg{PXipamjm}パッケージ%
6379 \footnote{\url{https://github.com/zr-tex8r/PXipamjm}. 説明は彼のブログ記事
6380 「pxipamjm パッケージの説明書のような何か(\url{http://d.hatena.ne.jp/zrbabbler/20131221})」
6381 にある.}
6382 にあるような気の利いた命令はまだない.
6383 異体字の一覧表示を行いたい場合は,gitリポジトリ内の \texttt{test/test19-ivs.tex} 中にある
6384 Lua・\TeX コードが参考になるだろう.
6385 %</ja>
6386
6387
6388 \subsection{\texttt{luatexja-adjust.sty}}
6389 \label{ssec-adj}
6390 \begin{figure}[t]
6391 \def\sq{%
6392   \hbox to 1\zw{\hss\fboxsep=-.5\fboxrule\fbox{%
6393    \hskip\dimexpr-.5\zw-.2pt\vrule width.4pt height.08\zw depth.12\zw%
6394   \hskip\dimexpr.5\zw-.2pt\relax}\hss}}
6395 \def\sb{\hbox to 1\zw{\hss\fboxsep=-.5\fboxrule\fbox{%
6396   ■\hskip\dimexpr-.5\zw-.2pt\vrule width.4pt height.08\zw depth.12\zw%
6397   \hskip\dimexpr.5\zw-.2pt\relax}\hss}}
6398 \newbox\gridbox
6399 \def\outbox#1{{\Large%
6400   \ltjsetparameter{kanjiskip=0pt plus .2\zw minus .2\zw}%
6401   \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}%
6402   \hbox{\textcolor{cyan}{\copy\gridbox}\hskip-20\zw%
6403   \vbox{\hsize=20\zw\noindent\leftskip0pt\rightskip0pt\parfillskip0pt#1}\vrule}%
6404 }}
6405
6406 {\centering
6407 \begin{tabular}{lc}
6408 \toprule
6409 no adjustment&\outbox{以上の原理は,「包除原理」とよく呼ばれるが\hskip-.5\zw\null}\\
6410 without priority&%
6411 \ltjdisableadjust
6412 \outbox{以上の原理は,「包除原理」とよく呼ばれるが}%
6413 \ltjenableadjust\\
6414 with priority&%
6415 \outbox{以上の原理は,「包除原理」とよく呼ばれるが}
6416 %<en>\ltjdisableadjust
6417 \\
6418 \bottomrule
6419 \end{tabular}\par}
6420 \smallskip
6421
6422 Note: the value of
6423 \Param{kanjiskip} is 0\,pt${}^{+1/5\,\mathrm{em}}_{-1/5\,\mathrm{em}}$ in this figure,
6424 for making the difference obvious.
6425 %<ja>\caption{行長調整}\label{fig-adj}
6426 %<en>\caption{Line adjustment}\label{fig-adj}
6427 \end{figure}
6428
6429
6430 %<*en>
6431 (see Japanese version of this manual)
6432 %</en>
6433 %<*ja>
6434 \pTeX では,行長調整において優先度の概念が存在しなかったため,図
6435 \ref{fig-adj}上段における半角分の半端は,図\ref{fig-adj}中段のように,鍵
6436 括弧周辺の空白と和文間空白(\Param{kanjiskip})の両方によって負担される.し
6437 かし,「日本語組版処理の要件」\cite{jlreq}やJIS~X~4051~\cite{x4051}におい
6438 ては,このような状況では半端は鍵括弧周辺の空白のみで負担し,その他の和文
6439 文字はベタ組で組まれる(図\ref{fig-adj}下段)ことになっている.この追加
6440 パッケージは\cite{jlreq}や\cite{x4051}における規定のような,優先順位付き
6441 の行長調整を提供する.詳細な仕様については\ref{sec-adjspec}章を参照してほしい.
6442 \begin{itemize}
6443  \item 優先度付き行長調整は,段落を行分割した後に個々の行について行われるものである.
6444 そのため,行分割の位置は変化することはない.
6445
6446 また,\verb+\hbox to ... {...}+ のような「幅が指定されたhbox」では無効である.
6447  \item 優先度付き行長調整を行うと,和文処理グルーの自然長は変化しないが,伸び量や縮み量は
6448 一般に変化する.そのため,既に組まれた段落を \cs{unhbox} などを利用して組み直す処理を
6449 行う場合には注意が必要である.
6450 \end{itemize}
6451
6452
6453 \Pkg{luatexja-adjust} は,以下の命令を提供する.これらはすべてグローバルに効力を発揮する.
6454
6455 \begin{cslist}
6456 \item[\cs{ltjdisableadjust}]
6457 優先順位付きの行長調整を無効化する.
6458
6459 \item[\cs{ltjenableadjust}]
6460 優先順位付きの行長調整を有効化する.
6461
6462 \item[\textsf{adjust}\,=<bool>] \cs{ltjsetparameter} で指定可能な追加パラメータであり,
6463 <bool>が\textit{true}なら \cs{ltjenableadjust} を,
6464 そうでなければ \cs{ltjdisableadjust} を実行する.
6465 \end{cslist}
6466 %</ja>
6467
6468 \subsection{\texttt{luatexja-ruby.sty}}
6469 %<*en>
6470 This addon package provides functionality of ``ruby'' (\emph{furigana}) annotations
6471 using callbacks of \LuaTeX-ja.
6472 There is no detailed manual of \Pkg{luatexja-ruby.sty} in English.
6473 (Japanese manual is another PDF file, \url{luatexja-ruby.pdf}.)
6474 %</en>
6475 %<*ja>
6476 この追加パッケージは,\LuaTeX-jaの機能を利用したルビ(振り仮名)の組版機能を提供する.
6477 前後の文字種に応じた前後への自動進入や,
6478 行頭形・行中形・行末形の自動的な使い分けが特徴である.
6479
6480 ルビ組版に設定可能な項目や注意事項が多いため,本追加パッケージの詳細な説明は
6481 使用例と共に \url{luatexja-ruby.pdf}\ という別ファイルに載せている.
6482 この節では簡単な使用方法のみ述べる.
6483 %</ja>
6484
6485 \begin{description}
6486 %<*en>
6487  \item[Group-ruby]
6488 By default, ruby characters (the second argument of \cs{ruby})
6489 are attached to base characters (the first argument), as one object.
6490 This type of ruby is called \emph{group-ruby}.
6491 %</en>
6492 %<*ja>
6493  \item[グループルビ] 標準ではグループルビの形で組まれる.第1引数に親文字,
6494 第2引数にルビを記述する.
6495 %</ja>
6496 \begin{LTXexample}[width=0.3\textwidth]
6497 東西線\ruby{妙典}{みようでん}駅は……\\
6498 東西線の\ruby{妙典}{みようでん}駅は……\\
6499 東西線の\ruby{妙典}{みようでん}という駅……\\
6500 東西線\ruby{葛西}{かさい}駅は……
6501 \end{LTXexample}
6502 %<*en>
6503 As the above example, ruby hangover is allowed on the Hiragana before/after
6504 its base characters.
6505 %</en>
6506 %<ja> この例のように,標準では前後の平仮名にルビ全角までかかるようになっている.
6507
6508 %<*en>
6509 \item[Mono-ruby]
6510 To attach ruby characters to each base characters (\emph{mono-ruby}),
6511 one should use \cs{ruby} multiple times:
6512 %</en>
6513 %<*ja>
6514  \item[モノルビ] 親文字を1文字にするとモノルビとなる.
6515 2文字以上の熟語をモノルビの形で組みたい場合は,面倒でも
6516 その数だけ \cs{ruby} を書く必要がある.
6517 %</ja>
6518 \begin{LTXexample}[width=0.3\textwidth]
6519 東西線の\ruby{妙}{みよう}\ruby{典}{でん}駅は……
6520 \end{LTXexample}
6521
6522 %<*en>
6523  \item[Jukugo-ruby]
6524 Vertical bar~\verb+|+ denotes a boundary of \emph{groups}.
6525 %</en>
6526 %<*ja>
6527  \item[熟語ルビ] 引数内の縦棒 \verb+|+ はグループの区切りを表し,
6528 複数グループのルビは熟語ルビとして組まれる.
6529 \cite{x4051}にあるように,
6530 どのグループでも「親文字」が対応するルビ以上の長さの場合は
6531 各グループごとに,そうでないときは全体をまとめて1つのグループルビとして組まれる.
6532 \cite{jlreq}で規定されている組み方とは異なるので注意.
6533 %</ja>
6534 \begin{LTXexample}
6535 \ruby{妙|典}{みよう|でん}\
6536 \ruby{葛|西}{か|さい}\
6537 \ruby{神楽|坂}{かぐら|ざか}
6538 \end{LTXexample}
6539 %<*en>
6540 If there are multiple groups in one \cs{ruby} call,
6541 A linebreak between two groups is allowed.
6542 %</en>
6543 %<ja> 複数ルビではグループとグループの間で改行が可能である.
6544 \begin{LTXexample}[width=0.3\textwidth]
6545 \vbox{\hsize=6\zw\noindent
6546   \hbox to 2.5\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
6547   \hbox to 2.5\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
6548   \hbox to   3\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
6549 }
6550 \end{LTXexample}
6551 \end{description}
6552
6553 %<*en>
6554 If the width of ruby characters are longer than that of base characters,
6555 \cs{ruby} automatically selects the appropriate form
6556 among the line-head form, the line-middle form, and the line-end form.
6557 %</en>
6558 %<*ja>
6559 また,ルビ文字のほうが親文字よりも長い場合は,自動的に
6560 行頭形・行中形・行末形のいずれか適切なものを選択する.
6561 %</ja>
6562 \begin{LTXexample}[width=0.3\textwidth]
6563 \vbox{\hsize=8\zw\noindent
6564 \null\kern3\zw ……を\ruby{承}{うけたまわ}る
6565      \kern1\zw ……を\ruby{承}{うけたまわ}る\\
6566 \null\kern5\zw ……を\ruby{承}{うけたまわ}る
6567 }
6568 \end{LTXexample}
6569
6570
6571 %<*ja>
6572 \subsection{\texttt{lltjext.sty}}
6573 \pLaTeX では縦組用の拡張として \Pkg{plext} パッケージが用意されていたが,
6574 それを\LuaTeX-ja用に書きなおしたものが本追加パッケージ \Pkg{lltjext} である.
6575
6576 従来の \Pkg{plext} パッケージとの違いは,
6577 {\catcode`\<=12
6578 \begin{itemize}
6579  \item 組方向オプション \texttt{<y>}(横組),\texttt{<t>}(縦組),
6580 \texttt{<z>}\ の他に\ \texttt{<d>}(dtou方向),\texttt{<u>}(utod方向)を追加した.
6581 \texttt{<z>} と \texttt{<u>} の違いは,\texttt{<z>} が(\Pkg{plext} パッケージと同様に)
6582 周囲の組方向が縦組のときにしか意味を持たない
6583        のに対し,\texttt{<u>} にはそのような制限がないことである.
6584
6585  \item \Pkg{plext} パッケージでは,表組(\texttt{tabular} 環境,\texttt{align} 環境等)や
6586 \texttt{minipage} 環境,\cs{parbox} 命令において,
6587 垂直位置指定 \texttt{[t]},~\texttt{[b]} の挙動が非読み込み時と微妙に変わることがあった.
6588
6589 \Pkg{lltjext} パッケージでは,垂直位置指定が\LaTeXe と同様の挙動(以下に示す)に
6590 なるように修正した.
6591 \begin{itemize}
6592  \item \texttt{[t]} オプション指定時は,ボックスのベースラインが中身の1行目のベースライン
6593        (1行目の上に罫線などが来た時は,ボックスの上端)に一致するように配置する.
6594  \item \texttt{[b]} オプション指定時は,ボックスのベースラインが中身の最終行のベースライン
6595        (中身の最後が罫線などの時は,ボックスの下端)に一致するように配置する.
6596  \item それ以外のときは,ボックスの中央が「数式の軸」に一致するように配置する.
6597 \end{itemize}
6598
6599  \item 連数字用命令 \cs{rensuji} における位置合わせオプション \texttt{[l]}, \texttt{[c]},
6600        \texttt{[r]} の挙動を若干変更した.
6601
6602 \end{itemize}
6603 }
6604 %</ja>
6605 %<*en>
6606 \subsection{\texttt{lltjext.sty}}
6607 \pLaTeX\ supplies additional macros for vertical writing in the \Pkg{plext} package.
6608 The \Pkg{lltjext} package which we want to describe here is the \LuaTeX-ja
6609 counterpart of the \Pkg{plext} package.
6610 %</en>
6611
6612 %<*ja>
6613 念の為,本 \Pkg{lltjext} パッケージで追加・変更している命令の一覧を載せておく.
6614 \begin{cslist}
6615 \item[tabular\textrm{, }array\textrm{, }minipage環境]
6616 これらの環境は,
6617 \begin{lstlisting}
6618 \begin{tabular}<dir>[pos]{table spec} ... \end{tabular}
6619 \begin{array}<dir>[pos]{table spec}   ... \end{array}
6620 \begin{minipage}<dir>[pos]{width}     ... \end{minipage}
6621 \end{lstlisting}
6622 のように,組方向オプション \texttt{\<dir\>} が拡張されている.
6623 既に述べたように,組方向オプションに指定できる値は以下の5つであり,
6624 それ以外を指定した時や無指定時は周囲の組方向と同じ組方向になる.
6625 \begin{description}
6626  \item[y] 横組(\cs{yoko})
6627  \item[t] 縦組(\cs{tate})
6628  \item[z] 周囲が縦組の時はutod方向,それ以外はそのまま
6629  \item[d] dtou方向
6630  \item[u] utod方向
6631 \end{description}
6632 \item[\cs{parbox}\<<dir>\>{[<pos>]}\{<width>\}\{<contents>\}]
6633 \cs{parbox} 命令も同様に,組方向の指定ができるように拡張されている.
6634
6635 \item[\cs{pbox}\<<dir>\>{[<width>][<pos>]}\{<contents>\}]
6636 組方向<dir>で<contents>の中身をLRモードで組む命令である.
6637 <width>が正の値であるときは,ボックス全体の幅がその値となる.
6638 その際,中身は<pos>の値に従い,左寄せ(\texttt{l}),右揃え(\texttt{r}),
6639 中央揃え(それ以外)される.
6640 \item[picture環境]
6641 図表作成に用いる \texttt{picture} 環境も,
6642 \begin{lstlisting}
6643 \begin{picture}<dir>(x_size, y_size)(x_offset,y_offset)
6644   ...
6645 \end{picture}
6646 \end{lstlisting}
6647 と組方向が指定できるように拡張されている.
6648 $x$成分の増加方向は字送り方向,$y$成分の増加方向は行送り方向の\emph{反対方向}となる.
6649 \Pkg{plext} パッケージと同様に
6650 内部ではベースライン補正(\Param{yalbaselineshift}パラメータなど)の影響を受けないように,
6651 \cs{put},~\cs{line}, \cs{vector}, \cs{dashbox}, \cs{oval},~\cs{circle}も
6652 ベースライン補正を受けないように再定義されている.
6653
6654 \item[\cs{rensuji}{[<pos>]}\{<contents>\}\textrm{, }\cs{rensujiskip}]
6655
6656 \item[\cs{Kanji}\{<counter\_name>\}]
6657
6658 \item[\cs{kasen}\{<contents>\}\textrm{, }\cs{bou}\{<contents>\}\textrm{,
6659                      }\cs{boutenchar}]
6660
6661 \item[参照番号]
6662 \end{cslist}
6663 %</ja>
6664 %<*en>
6665 \begin{cslist}
6666 \item[tabular\textrm{, }array\textrm{, }minipage\textrm{ environments}]
6667 These environments are extended by \texttt{\<dir\>}, which specifies the direction,
6668 as follows:
6669 \begin{lstlisting}
6670 \begin{tabular}<dir>[pos]{table spec} ... \end{tabular}
6671 \begin{array}<dir>[pos]{table spec}   ... \end{array}
6672 \begin{minipage}<dir>[pos]{width}     ... \end{minipage}
6673 \end{lstlisting}
6674 This option permits one of the following five values. If none of them is specified,
6675 the direction inside the environment is same as that outside the enviromnent.
6676 \begin{description}
6677  \item[y] \emph{yoko} direction (horizontal writing)
6678  \item[t] \emph{tate} direction (vertical writing)
6679  \item[z] \emph{utod} direction if direction outside the env.\ is \emph{tate}.
6680  \item[d] \emph{dtou} direction
6681  \item[u] \emph{utod} direction
6682 \end{description}
6683 \item[\cs{parbox}\<<dir>\>{[<pos>]}\{<width>\}\{<contents>\}]
6684 \cs{parbox} command is also extended by \texttt{\<dir\>}.
6685
6686 \item[\cs{pbox}\<<dir>\>{[<width>][<pos>]}\{<contents>\}]
6687 This commands typeset <contents> in LR-mode, in <dir> direction.
6688 If <width> is positive, the width of the box becomes this <width>.
6689 In this case, <contents> will be aligned \dots
6690
6691 \item[picture\textrm{\ environment}]
6692
6693 \item[\cs{rensuji}{[<pos>]}\{<contents>\}\textrm{, }\cs{rensujiskip}]
6694
6695 \item[\cs{Kanji}\{<counter\_name>\}]
6696
6697 \item[\cs{kasen}\{<contents>\}\textrm{, }\cs{bou}\{<contents>\}\textrm{,
6698                      }\cs{boutenchar}]
6699
6700 \item[参照番号]
6701 \end{cslist}
6702 %</en>
6703
6704
6705
6706 %<en>\part{Implementations}
6707 %<ja>\part{実装}
6708 \label{part-imp}
6709 %<en>\section{Storing Parameters}
6710 %<ja>\section{パラメータの保持}
6711 \label{sec-para}
6712 %<en>\subsection{Used Dimensions, Attributes and Whatsit Nodes}
6713 %<ja>\subsection{\LuaTeX-jaで用いられるレジスタとwhatsitノード}
6714
6715 %<*en>
6716 Here the following is the list of dimensions and attributes which are used in \LuaTeX-ja.
6717 %</en>
6718 %<*ja>
6719 以下は\LuaTeX-jaで用いられる寸法レジスタ(dimension),属性レジスタ(attribute)の
6720 リストである.
6721 %</ja>
6722 \begin{list}{}{%
6723 \def\makelabel{\ttfamily}\advance\leftmargin1\zw
6724 \def\dim#1{\item[\textbackslash #1\ \textrm{(dimension)}]}
6725 \def\cnt#1{\item[\textbackslash #1\ \textrm{(counter)}]}
6726 \def\attr#1{\item[\textbackslash #1\ \textrm{(attribute)}]}
6727 }
6728
6729 \dim{jQ}
6730 %<*en>
6731 \cs{jQ} is equal to
6732                         $1\,\textrm{Q}=0.25\,\textrm{mm}$, where ``Q''~(also called ``級'') is
6733                         a unit used in Japanese phototypesetting.
6734 So one should not change the value of this dimension.
6735 %</en>
6736 %<*ja>
6737 \cs{jQ} は写植で用いられた$1\,\textrm{Q}=0.25\,\textrm{mm}$%
6738 (「級」とも書かれる)に等しい.したがって,
6739 この寸法レジスタの値を変更してはならない.
6740 %</ja>
6741
6742 \dim{jH}
6743 %<*en>
6744 There is also a unit called ``歯'' which equals to $0.25\,\textrm{mm}$ and
6745                          used in Japanese phototypesetting.
6746 This \cs{jH} is the same \cs{dimen} register as \cs{jQ}.
6747 %</en>
6748 %<*ja>
6749 同じく写植で用いられていた単位として「歯」があり,これも$0.25\,\textrm{mm}$と
6750 等しい.この \cs{jH} は \cs{jQ} と同じ寸法レジスタを指す.
6751 %</ja>
6752
6753 \dim{ltj@zw}
6754 %<*en>
6755 A temporal register for the ``full-width'' of current Japanese font.
6756 The command \cs{zw} sets this register to the correct value, and
6757 ``return'' this register itself.
6758 %</en>
6759 %<*ja>
6760 現在の和文フォントの「全角幅」を保持する一時レジスタ.
6761 \cs{zw} 命令は,このレジスタを適切な値に設定した後,
6762 「このレジスタ自体を返す」.
6763 %</ja>
6764
6765 \dim{ltj@zh}
6766 %<*en>
6767 A temporal register for the ``full-height'' (usually the sum of height of imaginary body and its depth) of current Japanese font.
6768 The command \cs{zh} sets this register to the correct value, and
6769 ``return'' this register itself.
6770 %</en>
6771 %<*ja>
6772 現在の和文フォントの「全角高さ」(通常,高さと深さの和)を保持する一時レジスタ.
6773 \cs{zh} 命令は,このレジスタを適切な値に設定した後,
6774 「このレジスタ自体を返す」.
6775 %</ja>
6776
6777 \attr{jfam}
6778 %<*en>
6779 Current number of Japanese font family for math formulas.
6780 %</en>
6781 %<*ja>
6782 数式用の和文フォントファミリの現在の番号.
6783 %</ja>
6784
6785 \attr{ltj@curjfnt}
6786 %<*en>
6787 The font index of current Japanese font for horizontal direction.
6788 %</en>
6789 %<*ja>
6790 現在の横組用和文フォントのフォント番号.
6791 %</ja>
6792
6793 \attr{ltj@curtfnt}
6794 %<*en>
6795 The font index of current Japanese font for vertical direction.
6796 %</en>
6797 %<*ja>
6798 現在の縦組用和文フォントのフォント番号.
6799 %</ja>
6800
6801 \attr{ltj@charclass}
6802 %<*en>
6803 The character class of a \textbf{JAchar}. This attribute is only set on a
6804                          \textit{glyph\_node} which contains a \textbf{JAchar}.
6805 %</en>
6806 %<*ja>
6807 \textbf{JAchar}の文字クラス.\textbf{JAchar}が格納された\textit{glyph\_node}でのみ使われる.
6808 %</ja>
6809
6810 \attr{ltj@yablshift}
6811 %<*en>
6812 The amount of shifting the baseline of alphabetic fonts in scaled point ($2^{-16}\,\textrm{pt}$).
6813 %</en>
6814 %<*ja>
6815 スケールド・ポイント($2^{-16}\,\textrm{pt}$)を単位とした欧文フォントのベースラインの移動量.
6816 %</ja>
6817
6818 \attr{ltj@ykblshift}
6819 %<*en>
6820 The amount of shifting the baseline of Japanese fonts in scaled point ($2^{-16}\,\textrm{pt}$).
6821 %</en>
6822 %<*ja>
6823 スケールド・ポイント($2^{-16}\,\textrm{pt}$)を単位とした和文フォントのベースラインの移動量.
6824 %</ja>
6825
6826 \attr{ltj@tablshift}
6827 \attr{ltj@tkblshift}
6828
6829 \attr{ltj@autospc}
6830 %<*en>
6831 Whether the auto insertion of \Param{kanjiskip} is allowed at the node.
6832 %</en>
6833 %<*ja>
6834 そのノードで\Param{kanjiskip}の自動挿入が許されるかどうか.
6835 %</ja>
6836
6837 \attr{ltj@autoxspc}
6838 %<*en>
6839 Whether the auto insertion of \Param{xkanjiskip} is allowed at the node.
6840 %</en>
6841 %<*ja>
6842 そのノードで\Param{xkanjiskip}の自動挿入が許されるかどうか.
6843 %</ja>
6844
6845 \attr{ltj@icflag}
6846 %<*en>
6847 An attribute for distinguishing ``kinds'' of a node. One of the following value is
6848 assigned to this attribute:
6849 %</en>
6850 %<*ja>
6851 ノードの「種類」を区別するための属性.以下のうちのひとつが値として割り当てられる:
6852 %</ja>
6853 \begin{description}
6854 \item[\textit{italic} (1)]
6855 %<*en>
6856 Kerns from italic correction (\verb+\/+), or from kerning information of a Japanese font.
6857 These kerns are ``ignored'' in the insertion process of \textbf{JAglue},
6858 unlike explicit \cs{kern}.
6859 %</en>
6860 %<*ja>
6861 イタリック補正(\verb+\/+)によるカーン,
6862 または \Pkg{luaotfload} によって挿入されたフォントのカーニング情報由来のカーン.
6863 これらのカーンは通常の \cs{kern} とは異なり,
6864 \textbf{JAglue}の挿入処理においては透過する.
6865 %</ja>
6866
6867 \item[\textit{packed} (2)]
6868
6869 \item[\textit{kinsoku} (3)]
6870 %<*en>
6871 Penalties inserted for the word-wrapping process (\emph{kinsoku shori}) of Japanese characters.
6872 %</en>
6873 %<ja>禁則処理のために挿入されたペナルティ.
6874 \item[\mathversion{bold}$(\textit{from\_jfm}-2)$--$(\textit{from\_jfm}+2)$~(4--8)]
6875 %<en>Glues/kerns from JFM.
6876 %<ja>JFM由来のグルー/カーン.
6877 \item[\textit{kanji\_skip}~(9), \textit{kanji\_skip\_jfm}~(10)]
6878 %<en>Glues from \Param{kanjiskip}.
6879 %<ja>和文間空白\Param{kanjiskip}を表すグルー.
6880 \item[\textit{xkanji\_skip}~(11), \textit{xkanji\_skip\_jfm}~(12)]
6881 %<en>Glues from \Param{xkanjiskip}.
6882 %<ja>和欧文間空白\Param{xkanjiskip}を表すグルー.
6883 \item[\textit{processed} (13)]
6884 %<en>Nodes which is already processed by \ldots.
6885 %<ja>\LuaTeX-ja の内部処理によって既に処理されたノード.
6886 \item[\textit{ic\_processed} (14)]
6887 %<*en>
6888 Glues from an italic correction, but already processed in the insertion process of \textbf{JAglue}s.
6889 %</en>
6890 %<ja>イタリック補正に由来するグルーであって,既に \textbf{JAglue} 挿入処理にかかったもの.
6891 \item[\textit{boxbdd} (15)]
6892 %<en>Glues/kerns that inserted just the beginning or the ending of an hbox or a paragraph.
6893 %<ja>hboxか段落の最初か最後に挿入されたグルー/カーン.
6894 \end{description}
6895
6896 %<*ja>
6897 また,挿入処理の結果であるリストの最初のノードでは,\verb+\ltj@icflag+ の値に
6898 \textit{processed\_begin\_flag}~(128)が追加される.これによって,\cs{unhbox} が
6899 連続した場合でも「ボックスの境界」が識別できるようになっている.
6900 %</ja>
6901
6902 \attr{ltj@kcat\,$i$}
6903 %<*en>
6904 Where $i$~is a natural number which is less than~7.
6905 These 7~attributes store bit~vectors indicating which character block is regarded as a block of \textbf{JAchar}s.
6906 %</en>
6907 %<*ja>
6908 $i$は7より小さい自然数.
6909 これら7つの属性レジスタは,どの文字ブロックが\textbf{JAchar}のブロックとして
6910 扱われるかを示すビットベクトルを格納する.
6911 %</ja>
6912
6913 \attr{ltj@dir}
6914 %<*ja>
6915 \textit{direction}~whatsit(後述)において組方向を示すために,あるいは\textit{dir\_box}の
6916                          組方向を用いる.\textit{direction}~whatsitにおいては値は
6917 \begin{quote}
6918  \textit{dir\_dtou} (1), \textit{dir\_tate} (3),
6919  \textit{dir\_yoko} (4), \textit{dir\_utod} (11)
6920 \end{quote}
6921 のいずれかであり,\textit{dir\_box}ではこれらに次を加えた値をとる(\ref{sec-dir-imp}章参照).
6922 %</ja>
6923 \begin{description}
6924 \item[\textit{dir\_node\_auto} (128)]
6925 %<ja> 異なる組方向に配置するために自動的に作られたボックス.
6926 \item[\textit{dir\_node\_manual} (256)]
6927 %<ja> \cs{ltjsetwd} によって「ボックスの本来の組方向とは異なる組方向での寸法」を
6928 %<ja> 設定したときに,それを記録するためのボックス.
6929 \end{description}
6930 %<ja> \TeX 側から見える値,つまり \verb+\the\ltj@dir+ の値は常に0である.
6931
6932 \end{list}
6933
6934 %<*en>
6935 Furthermore, \LuaTeX-ja uses several user-defined whatsit nodes for
6936 internal processing. All those nodes except \emph{direction} whatsits
6937 store a natural number (hence its \texttt{type} is 100).
6938 \emph{direction} whatsits store a node list, hence its \texttt{type} is 110.
6939 Their \texttt{user\_id} (used for distinguish user-defined whatsits)
6940 are allocated by \texttt{luatexbase.newuserwhatsitid}.
6941 %</en>
6942 %<*ja>
6943 さらに,\LuaTeX-jaはいくつかのuser-defined whatsit nodeを内部処理に用いる.
6944 \textit{direction} whatsitはノードリストを格納するが,
6945 それ以外のwhatsitノードの \texttt{type} は100であり,ノードは自然数を格納している.
6946 user-defined whatsitを識別するための \texttt{user\_id} は\
6947 \texttt{luatexbase.newuserwhatsitid} により確保されており,
6948 下の見出しは単なる識別用でしかない.
6949 %</ja>
6950 \begin{description}
6951 \item[\textit{inhibitglue}]
6952 %<*en>
6953 Nodes for indicating that \cs{inhibitglue} is
6954            specified. The \texttt{value} field of these nodes doesn't matter.
6955 %</en>
6956 %<*ja>
6957 \cs{inhibitglue} が指定されたことを示すノード.これらのノードの\
6958 \texttt{value} フィールドは意味を持たない.
6959 %</ja>
6960
6961 \item[\textit{stack\_marker}]
6962 %<*en>
6963 Nodes for \LuaTeX-ja's stack system (see the next
6964            subsection). The \texttt{value} field of these nodes is
6965            current group level.
6966 %</en>
6967 %<*ja>
6968 \LuaTeX-jaのスタックシステム(次の節を参照)のためのノード.
6969 これらのノードの \texttt{value} フィールドは現在のグループネストレベルを表す.
6970 %</ja>
6971
6972 \item[\textit{char\_by\_cid}]
6973 %<*en>
6974 Nodes for \textbf{JAchar} which the callback process of
6975            \Pkg{luaotfload} won't be applied, and the character code is
6976            stored in the \texttt{value} field. Each node of this type are
6977            converted to a \textit{glyph\_node} \emph{after}
6978            the callback process of luaotfload.
6979 Nodes of this type is used in \cs{CID}, \cs{UTF} and IVS support.
6980 %</en>
6981 %<*ja>
6982 \Pkg{luaotfload}のコールバックによる処理が適用されない\textbf{JAchar}のためのノードで,
6983 \texttt{value} フィールドに文字コードが格納されている.
6984 この種類のノードはそれぞれが\Pkg{luaotfload}のコールバックの処理の
6985 \emph{後で}\textit{glyph\_node}に変換される.
6986 \cs{CID}, \cs{UTF}やIVS対応処理でこの種類のノードが利用されている.
6987 %</ja>
6988
6989 \item[\textit{replace\_vs}]
6990 %<*en>
6991 Similar to \textit{char\_by\_cid} whatsits above.
6992 These nodes are for \textbf{ALchar} which the callback process of
6993            \Pkg{luaotfload} won't be applied.
6994 %</en>
6995 %<*ja>
6996 上の\textit{char\_by\_cid}と同様に,
6997 これらのノードは\Pkg{luaotfload}のコールバックによる処理が適用されない\textbf{ALchar}のた
6998            めものである.
6999 %</ja>
7000
7001 \item[\textit{begin\_par}]
7002 %<*en>
7003 Nodes for indicating beginning of a paragraph.
7004 A paragraph which is started by \cs{item} in list-like environments has a horizontal box
7005 for its label before the actual contents. So \dots
7006 %</en>
7007 %<*ja>
7008 「段落の開始」を意味するノード.
7009 list環境,itemize環境などにおいて,\cs{item} で始まる各項目は……
7010 %</ja>
7011
7012 \item[\textit{direction}]
7013
7014 \end{description}
7015
7016 %<*en>
7017 These whatsits will be removed during the process of inserting \textbf{JAglue}s.
7018 %</en>
7019 %<*ja>
7020 これらのwhatsitノードは\textbf{JAglue}の挿入処理の間に取り除かれる.
7021 %</ja>
7022
7023 %<en>\subsection{Stack System of \LuaTeX-ja}
7024 %<ja>\subsection{\LuaTeX-jaのスタックシステム}
7025 \label{ssec-stack}
7026
7027 %<en>\paragraph{Background}
7028 %<ja>\paragraph{背景}
7029 %<*en>
7030 \LuaTeX-ja has its own stack system, and most parameters of \LuaTeX-ja
7031 are stored in it. To clarify the reason, imagine the parameter
7032 \Param{kanjiskip} is stored by a skip, and consider the following
7033 source:
7034 %</en>
7035 %<*ja>
7036 \LuaTeX-jaは独自のスタックシステムを持ち,\LuaTeX-jaのほとんどのパラメータは
7037 これを用いて保持されている.その理由を明らかにするために,
7038 \Param{kanjiskip}パラメータがスキップレジスタで保持されているとし,
7039 以下のコードを考えてみよう:
7040 %</ja>
7041 \begin{LTXexample}
7042 \ltjsetparameter{kanjiskip=0pt}ふがふが.%
7043 \setbox0=\hbox{%
7044   \ltjsetparameter{kanjiskip=5pt}ほげほげ}
7045 \box0.ぴよぴよ\par
7046 \end{LTXexample}
7047
7048 %<*en>
7049 As described in Subsection~\ref{ssec-param}, the only effective value of
7050 \Param{kanjiskip} in an hbox is the latest value, so the value of
7051 \Param{kanjiskip} which applied in the entire hbox should be 5\,pt.
7052 However, by the implementation method of \LuaTeX, this ``5\,pt'' cannot be
7053 known from any callbacks.  In the \texttt{tex/packaging.w}, which is a
7054 file in the source of \LuaTeX, there are the following codes:
7055 %</en>
7056 %<*ja>
7057 \ref{ssec-param}節で述べたように,あるhboxの中で効力を持つ
7058 \Param{kanjiskip}の値は最後に現れた値のみであり,したがってボックス全体に適用される
7059 \Param{kanjiskip}は5\,ptであるべきである.しかし,\LuaTeX の実
7060 装を観察すると,この5\,ptという長さはどのコールバックからも知ることはできないことがわかる.
7061 \LuaTeX のソースファイルの1つ \texttt{tex/packaging.w} の中に,
7062 以下のコードがある:
7063 %</ja>
7064 \begin{lstlisting}[numbers=left,firstnumber=1226]
7065 void package(int c)
7066 {
7067     scaled h;                   /* height of box */
7068     halfword p;                 /* first node in a box */
7069     scaled d;                   /* max depth */
7070     int grp;
7071     grp = cur_group;
7072     d = box_max_depth;
7073     unsave();
7074     save_ptr -= 4;
7075     if (cur_list.mode_field == -hmode) {
7076         cur_box = filtered_hpack(cur_list.head_field,
7077                                  cur_list.tail_field, saved_value(1),
7078                                  saved_level(1), grp, saved_level(2));
7079         subtype(cur_box) = HLIST_SUBTYPE_HBOX;
7080 \end{lstlisting}
7081 %<*en>
7082 Notice that \texttt{unsave()} is executed \emph{before}
7083 \texttt{filtered\_hpack()}, where \texttt{hpack\_filter} callback is
7084 executed) here. So ``5\,pt'' in the above source is orphaned at
7085 \texttt{unsave()}, and hence it can't be accessed from \texttt{hpack\_filter}
7086 callback.
7087 %</en>
7088 %<*ja>
7089 \texttt{unsave()} が \texttt{filtered\_hpack()}(これは \texttt{hpack\_filter} コールバックが
7090 実行されるところである)の\emph{前に}実行されていることに注意する.
7091 したがって,上記ソース中で5\,ptは \texttt{unsave()} のところで捨てられ,
7092 \texttt{hpack\_filter} コールバックからはアクセスすることができない.
7093 %</ja>
7094
7095 %<en>\paragraph{Implementation}
7096 %<ja>\paragraph{解決法}
7097
7098 %<*en>
7099 The code of stack system is based on that in a post of Dev-luatex mailing list\footnote{%
7100 \texttt{[Dev-luatex] tex.currentgrouplevel}, a post at 2008/8/19 by Jonathan Sauer.}.
7101 %</en>
7102 %<*ja>
7103 スタックシステムのコードはDev-luatexメーリングリストのある投稿\footnote{%
7104 \texttt{[Dev-luatex] tex.currentgrouplevel}: Jonathan Sauerによる2008/8/19の投稿.}を
7105 ベースにしている.
7106 %</ja>
7107
7108 %<*en>
7109 These are two \TeX\ count registers for maintaining information:
7110 \verb+\ltj@@stack+ for the stack level, and \verb+\ltj@@group@level+ for
7111 the \TeX's group level when the last assignment was done.  Parameters
7112 are stored in one big table named \texttt{charprop\_stack\_table}, where
7113 \texttt{charprop\_stack\_table[$i$]} stores data of stack level~$i$. If
7114 a new stack level is created by \cs{ltjsetparameter}, all data of the
7115 previous level is copied.
7116 %</en>
7117 %<*ja>
7118 情報を保持するために,2つの\TeX の整数レジスタを用いている:
7119 \verb+\ltj@@stack+ にスタックレベル,\verb+\ltj@@group@level+ に最後の代入が
7120 なされた時点での\TeX のグループレベルを保持している.
7121 パラメータは\texttt{charprop\_stack\_table}という名前のひとつの大きなテーブルに
7122 格納される.ここで,\texttt{charprop\_stack\_table[$i$]}はスタックレベル$i$の
7123 データを格納している.もし新しいスタックレベルが \cs{ltjsetparameter} によって
7124 生成されたら,前のレベルの全てのデータがコピーされる.
7125 %</ja>
7126
7127 %<*en>
7128 To resolve the problem mentioned in above paragraph ``Background'', \LuaTeX-ja uses
7129 another trick. When the stack level is about to be increased, a whatsit
7130 node whose type, subtype and value are 44~(\textit{user\_defined}),
7131 \textit{stack\_marker} and the current group level respectively is appended to the current
7132 list (we refer this node by \textit{stack\_flag}). This enables us to
7133 know whether assignment is done just inside a hbox. Suppose that the
7134 stack level is~$s$ and the \TeX's group level is~$t$ just after the hbox
7135 group, then:
7136 %</en>
7137 %<*ja>
7138 上の「背景」で述べた問題を解決するために,\LuaTeX-jaでは次の手法を用いる:
7139 スタックレベルが増加するするとき,type, subtype, valueがそれぞれ
7140 44~(\textit{user\_defined}), \textit{stack\_marker},そして現在のグループレベルであるwhatsitノード
7141 を現在のリストに付け加える(このノードを\textit{stack\_flag}とする).
7142 これにより,あるhboxの中で代入がなされたかどうかを知ることが可能
7143 となる.スタックレベルを$s$,そのhbox groupの直後の\TeX のグループレベルを
7144 $t$とすると:
7145 %</ja>
7146 \begin{itemize}
7147 %<*en>
7148 \item If there is no \textit{stack\_flag} node in the list of the contents of the hbox, then
7149       no assignment was occurred inside the hbox. Hence values of
7150       parameters at the end of the hbox are stored in the stack
7151       level~$s$.
7152 %</en>
7153 %<*ja>
7154 \item もしそのhboxの中身を表すリストの中に\textit{stack\_flag}ノードがなければ,
7155   hboxの中では代入は起こらなかったということになる.
7156   したがって,そのhboxの終わりにおけるパラメータの値はスタックレベル$s$に
7157   格納されている.
7158 %</ja>
7159
7160 %<*en>
7161 \item If there is a \textit{stack\_flag} node whose value is~$t+1$, then
7162       an assignment was occurred just inside the hbox group. Hence
7163       values of parameters at the end of the hbox are stored in the
7164       stack level~$s+1$.
7165 %</en>
7166 %<*ja>
7167 \item もし値が$t+1$の\textit{stack\_flag}ノードがあれば,その
7168   hboxの中で代入が起こったことになる.
7169   したがって,hboxの終わりにおけるパラメータの値はスタックレベル$s+1$に
7170   格納されている.
7171 %</ja>
7172
7173 %<*en>
7174 \item If there are \textit{stack\_flag} nodes but all of their values
7175       are more than~$t+1$, then an assignment was occurred in the box,
7176       but it is done in more internal group. Hence values of
7177       parameters at the end of the hbox are stored in the stack
7178       level~$s$.
7179 %</en>
7180 %<*ja>
7181 \item もし\textit{stack\_flag}ノードがあるがそれらの値が全て$t+1$より大きい
7182   場合,そのボックスの中で代入が起こったが,それは「より内部の」グループで
7183   起こったということになる.したがって,hboxの終わりでのパラメータの
7184   値はスタックレベル$s$に格納されている.
7185 %</ja>
7186 \end{itemize}
7187
7188 %<*en>
7189 Note that to work this trick correctly, assignments to
7190 \verb+\ltj@@stack+ and \verb+\ltj@@group@level+ have to be local always,
7191 regardless the value of \cs{globaldefs}.
7192 To solve this problem, we use another trick: the assignment
7193 \hbox{\verb+\directlua{tex.globaldefs=0}+} is always local.
7194 %</en>
7195 %<*ja>
7196 このトリックを正しく働かせるためには,\verb+\ltj@@stack+ と \verb+\ltj@@group@level+ への
7197 代入は \cs{globaldefs} の値によらず常にローカルでなければならないことに注意する.
7198 この問題は \hbox{\verb+\directlua{tex.globaldefs=0}+}(この代入は常にローカル)を
7199 用いることで解決している.
7200 %</ja>
7201
7202 %<*en>
7203 \subsection{Lua Functions of the Stack System}
7204 In this subsection, we will see how a user use \LuaTeX-ja's stack system to
7205 store some data which obeys the grouping of \TeX.
7206 %</en>
7207 %<*ja>
7208 \subsection{スタックシステムで使用される関数}
7209 本節では,ユーザが\LuaTeX-jaのスタックシステムを使用して,
7210 \TeX のグルーピングに従うような
7211 独自のデータを取り扱う方法を述べる.
7212 %</ja>
7213
7214 %<*en>
7215 The following function can be used to store data into a stack:
7216 \begin{lstlisting}
7217 luatexja.stack.set_stack_table(index, <any> data)
7218 \end{lstlisting}
7219 Any values which except \texttt{nil}~and~NaN are usable as \textit{index}.
7220 However, a user should use only negative integers or strings as \textit{index},
7221 since natural numbers are used by \LuaTeX-ja itself.
7222 Also, whether \textit{data} is stored locally or globally
7223 is determined by \texttt{luatexja.isglobal}
7224 (stored globally if and only if \texttt{luatexja.isglobal == 'global'}).
7225 %</en>
7226 %<*ja>
7227 スタックに値を設定するには,以下のLua関数を呼び出せば良い:
7228 \begin{lstlisting}
7229 luatexja.stack.set_stack_table(<any> index, <any> data)
7230 \end{lstlisting}
7231 直感的には,スタックテーブル中のインデックス\textit{index}の値を\textit{data}にする,という意味である.
7232 \textit{index}の値としては \texttt{nil} とNaN以外の任意の値を使えるが,
7233 自然数は\LuaTeX-jaが使用する(将来の拡張用も含む)ので,
7234 ユーザが使用する場合は負の整数値か文字列の値にすることが望ましい.
7235 また,ローカルに設定されるかグローバルに設定されるかは,\texttt{luatexja.isglobal} の値に依存する
7236 (グローバルに設定されるのは,\texttt{luatexja.isglobal == 'global'} であるちょうどその時).
7237 %</ja>
7238
7239 %<*en>
7240 Stored data can be obtained as the return value of
7241 \begin{lstlisting}
7242 luatexja.stack.get_stack_table(index, <any> default, <number> level)
7243 \end{lstlisting}
7244 where \textit{level} is the stack level, which is usually the value of \verb+\ltj@@stack+,
7245 and \textit{default} is the default value which will be returned if no values are stored
7246 in the stack table whose level is \textit{level}.
7247 %</en>
7248 %<*ja>
7249 スタックの値は,
7250 \begin{lstlisting}
7251 luatexja.stack.get_stack_table(<any> index, <any> default, <number> level)
7252 \end{lstlisting}
7253 の戻り値で取得できる.\textit{level}はスタックレベルであり,
7254 通常は \verb+\ltj@@stack+ の値を指定することになるだろう.
7255 \textit{default}はレベル\textit{level}のスタックに値が設定されていなかった場合に
7256 返すデフォルト値である.
7257 %</ja>
7258
7259 \begin{figure}[tb]
7260 \begin{lstlisting}[numbers=left, firstnumber=380]
7261 \protected\def\ltj@setpar@global{%
7262   \relax\ifnum\globaldefs>0\directlua{luatexja.isglobal='global'}%
7263     \else\directlua{luatexja.isglobal=''}\fi
7264 }
7265 \protected\def\ltjsetparameter#1{%
7266   \ltj@setpar@global\setkeys[ltj]{japaram}{#1}\ignorespaces}
7267 \protected\def\ltjglobalsetparameter#1{%
7268   \relax\ifnum\globaldefs<0\directlua{luatexja.isglobal=''}%
7269     \else\directlua{luatexja.isglobal='global'}\fi%
7270   \setkeys[ltj]{japaram}{#1}\ignorespaces}
7271 \end{lstlisting}
7272 %<ja>\caption{パラメータ設定命令の定義}
7273 %<en>\caption{Definiton of parameter setting commands}
7274 \label{fig:setpar-def}
7275 \end{figure}
7276
7277 %<*en>
7278 \subsection{Extending Parameters}
7279 Keys for \cs{ltjsetparameter}~and~\cs{ltjgetparameter} can be extended,
7280 as in \Pkg{luatexja-adjust}.
7281 %</en>
7282 %<*ja>
7283 \subsection{パラメータの拡張}
7284 ここでは,\Pkg{luatexja-adjust}で行なっているように,
7285 \cs{ltjsetparameter},~\cs{ltjgetparameter}に指定可能なキーを追加する方法
7286 を述べる.
7287 %</ja>
7288
7289 %<*en>
7290 \paragraph{Setting parameters}
7291 Figure~\ref{fig:setpar-def} shows the \emph{most outer} definition of
7292 two commands,
7293 \cs{ltjsetparameter} and \cs{ltjglobalsetparameter}.
7294 Most important part is the last \cs{setkeys},
7295 which is offered by the \Pkg{xkeyval} package.
7296
7297 Hence, to add a key in \cs{ltjsetparameter}, one only have to add a key
7298 whose prefix is \texttt{ltj} and whose family is \texttt{japaram}, as the following.
7299 \begin{lstlisting}
7300 \define@key[ltj]{japaram}{...}{...}
7301 \end{lstlisting}
7302
7303 \cs{ltjsetparameter}~and~\cs{ltjglobalsetparameter} automatically sets
7304 \texttt{luatexja.isglobal}. Its meaning is the following.
7305 \begin{align}
7306  \texttt{luatexja.isglobal} =
7307 \begin{cases}
7308  \texttt{'global'}&\text{global}\\
7309  \texttt{''}&\text{local}
7310 \end{cases}
7311 \end{align}
7312 This is determined not only by command name
7313 (\cs{ltjsetparameter}~or~\cs{ltjglobalsetparameter}),
7314 but also by the value of \cs{globaldefs}.
7315 %</en>
7316 %<*ja>
7317 \paragraph{パラメータの設定}
7318 \cs{ltjsetparameter} と,\cs{ltjglobalsetparameter} の定義は図\ref{fig:setpar-def}の
7319 のようになっている.
7320 本質的なのは最後の \cs{setkeys} で,これは\Pkg{xkeyval}パッケージの提供する命令である.
7321
7322 このため,\cs{ltjsetparameter} に指定可能なパラメータを追加するには,
7323 <prefix>を \texttt{ltj},<family>を \texttt{japaram} としたキーを
7324 \begin{lstlisting}
7325 \define@key[ltj]{japaram}{...}{...}
7326 \end{lstlisting}
7327 のように定義すれば良いだけである.
7328 なお,パラメータ指定がグローバルかローカルかどうかを示す \texttt{luatexja.isglobal} が,
7329 \begin{align}
7330  \texttt{luatexja.isglobal} =
7331 \begin{cases}
7332  \texttt{'global'}&\text{パラメータ設定はグローバル}\\
7333  \texttt{''}&\text{パラメータ設定はローカル}
7334 \end{cases}
7335 \end{align}
7336 として自動的にセットされる\footnote{命令が \cs{ltjglobalsetparameter} かどうかだけでは
7337 なく,実行時の \cs{globaldefs} の値にも依存して定まる.}.
7338 %</ja>
7339
7340 %<*en>
7341 \paragraph{Getting parameters}
7342 \cs{ltjgetparameter} is implemented by a Lua script.
7343
7344 For parameters that do not need additional arguments, one only have to
7345 define a function in the table \verb+luatexja.unary_pars+.
7346 For example, with the following function,
7347 \verb+\ltjgetparameter{hoge}+ returns a \emph{string} \texttt{42}.
7348 \begin{lstlisting}[numbers=left]
7349 function luatexja.unary_pars.hoge (t)
7350   return 42
7351 end
7352 \end{lstlisting}
7353 Here the argument of \verb+luatexja.unary_pars.hoge+ is
7354 the stack level of \LuaTeX-ja's stack system (see Subsection~\ref{ssec-stack}).
7355
7356 On the other hand, for parameters that need an additional argument
7357 (this must be an integer), one have to define a function in
7358 \verb+luatexja.binary_pars+ first. For example,
7359 \begin{lstlisting}[numbers=left]
7360 function luatexja.binary_pars.fuga (c, t)
7361   return tostring(c) .. ', ' .. tostring(42)
7362 end
7363 \end{lstlisting}
7364 Here the first argument $t$ is the stack level, as before.
7365 The second argument $c$ is just the second argument of \cs{ltjgetparameter}.
7366
7367 For parameters that need an additional argument, one also have to
7368 execute the \TeX\ code like
7369 \begin{lstlisting}
7370 \ltj@@decl@array@param{fuga}
7371 \end{lstlisting}
7372 to indicate that ``the parameter \texttt{fuga} needs an additional argument''.
7373 %</en>
7374 %<*ja>
7375 \paragraph{パラメータの取得}
7376 一方,\cs{ltjgetparameter} はLuaスクリプトによって実装されている.
7377 値を取得するのに追加引数の要らないパラメータについては,\verb+luatexja.unary_pars+\
7378 内に処理内容を記述した関数を定義すれば良い.例えば,Luaスクリプトで
7379 \begin{lstlisting}[numbers=left]
7380 function luatexja.unary_pars.hoge (t)
7381   return 42
7382 end
7383 \end{lstlisting}
7384 を実行すると,\verb+\ltjgetparameter{hoge}+ は \texttt{42} という\emph{文字列}を返す.
7385 関数 \verb+luatexja.unary_pars.hoge+ の引数$t$は,\ref{ssec-stack}節で述べた
7386 \LuaTeX-jaのスタックシステムにおけるスタックレベルである.
7387 戻り値はいかなる値であっても,最終的には文字列として出力されることに注意.
7388
7389 一方,追加引数(\emph{数値しか許容しない})が必要なパラメータについては,
7390 まずLuaスクリプトで処理内容の本体を記述しておく:
7391 \begin{lstlisting}[numbers=left]
7392 function luatexja.binary_pars.fuga (c, t)
7393   return tostring(c) .. ', ' .. tostring(42)
7394 end
7395 \end{lstlisting}
7396 引数$t$は,先に述べた通りのスタックレベルである.一方,引数$c$は\
7397 \cs{ltjgetparameter} の第2引数を表す数値である.
7398 しかしこれだけでは駄目で,
7399 \begin{lstlisting}
7400 \ltj@@decl@array@param{fuga}
7401 \end{lstlisting}
7402 を実行し,\TeX インターフェース側に
7403 「\verb+\ltjgetparameter{fuga}+ は追加引数が必要」ということを通知する必要がある.
7404 %</ja>
7405
7406 %<en>\section{Linebreak after a Japanese Character}
7407 %<ja>\section{和文文字直後の改行}
7408 \label{sec-lbreak}
7409 %<en>\subsection{Reference: Behavior in \pTeX}
7410 %<ja>\subsection{参考:\pTeX の動作}
7411 %<*en>
7412 In~\pTeX, a line break after a Japanese character doesn't emit a space,
7413 since words are not separated by spaces in Japanese writings. However,
7414 this feature isn't fully implemented in \LuaTeX-ja due to the
7415 specification of callbacks in~\LuaTeX. To clarify the difference between
7416 \pTeX~and~\LuaTeX, We briefly describe the handling of a line break in~\pTeX, in
7417 this subsection.
7418
7419 \pTeX's input processor can be described in terms of a finite state
7420 automaton, as that of~\TeX\ in~Section~2.5 of~\cite{texbytopic}. The
7421 internal states are as follows:
7422 \begin{itemize}
7423 \item State~$N$: new line
7424 \item State~$S$: skipping spaces
7425 \item State~$M$: middle of line
7426 \item State~$K$: after a Japanese character
7427 \end{itemize}
7428 The first three states---$N$,~$S$, and~$M$---are as same as \TeX's input
7429 processor.  State~$K$ is similar to state~$M$, and is entered after
7430 Japanese characters.  The diagram of state transitions are indicated in
7431 Figure~\ref{fig-ptexipro}.  Note that \pTeX\ doesn't leave state~$K$
7432 after ``beginning/ending of a group'' characters.
7433 %</en>
7434
7435 %<*ja>
7436 欧文では文章の改行は単語間でしか行わない.そのため,\TeX では,(文字の直後の)改行は
7437 空白文字と同じ扱いとして扱われる.一方,和文ではほとんどどこでも改行が可能なため,
7438 \pTeX では和文文字の直後の改行は単純に無視されるようになっている.
7439
7440 このような動作は,\pTeX が\TeX からエンジンとして拡張されたことによって可能になったことである.
7441 \pTeX の入力処理部は,\TeX におけるそれと同じように,有限オートマトンとして記述することができ,
7442 以下に述べるような4状態を持っている.
7443
7444 \begin{itemize}
7445 \item State~$N$: 行の開始.
7446 \item State~$S$: 空白読み飛ばし.
7447 \item State~$M$: 行中.
7448 \item State~$K$: 行中(和文文字の後).
7449 \end{itemize}
7450 また,状態遷移は,図\ref{fig-ptexipro}のようになっており,図中の数字は
7451 カテゴリーコードを表している.最初の3状態は\TeX の入力処理部と同じであり,
7452 図中から状態$K$と「$j$」と書かれた矢印を取り除けば,\TeX の入力処理部と同
7453 じものになる.
7454
7455 この図から分かることは,
7456 \begin{quote}
7457 行が和文文字(とグループ境界文字)で終わっていれば,改行は無視される
7458 \end{quote}
7459 ということである.
7460 %</ja>
7461
7462 \begin{figure}[!tb]
7463 \let\sp\textvisiblespace\small
7464 \begin{minipage}{.6\textwidth}%
7465 \begin{center}
7466 \unitlength=6.5mm\sf\mathversion{bold}
7467 \begin{tikzpicture}[
7468   ->, auto, shorten >=1pt
7469 ]
7470 \node [shape=rectangle, font=\scriptsize] (init) at (2,7) {start};
7471 \node [shape=circle,draw, fill=b_cyan] (newline) at (4,7) {$N$};
7472 \node [shape=circle,draw, fill=b_cyan] (midline) at (4,4) {$M$};
7473 \node [shape=circle,draw, fill=b_cyan] (skipspc) at (8,7) {$S$};
7474 \node [shape=circle,draw, fill=b_pink]  (kanji) at (8,4) {$K$};
7475 \node [shape=rectangle,draw, fill=b_green] (scanacs) at (6,8) {scan a c.s.};
7476 \node (endk) at (8,2.5) {} ;
7477 \node (endm) at (4,2.5) {} ;
7478 \node (ends) at (8,8.5) {} ;
7479 \node (endn) at (4,8.5) {} ;
7480 \begin{scope}[font=\scriptsize]
7481 \path (newline) edge [bend right]    node [left]{G, O} (midline)
7482       (init)    edge                 node {} (newline)
7483       (midline) edge [bend right=10] node {10} (skipspc)
7484       (skipspc) edge [bend right]    node [left,right=10,above=7]{G, O} (midline)
7485       (skipspc) edge [loop right]    node {10} (skipspc)
7486       (newline) edge [loop right]    node {10} (newline)
7487       (scanacs) edge [bend left]     node [left=3,below]{$(*)$} (skipspc)
7488       (scanacs) edge [bend right]    node [right=30,above=20]{$(*)$} (midline)
7489       (midline) edge                 node {5\ [\sp]} (endm)
7490       (midline) edge [loop left]     node {G, O} (midline)
7491       (skipspc) edge                 node [right] {5} (ends)
7492       (newline) edge                 node {5 [\cs{par}]} (endn);
7493 \begin{scope}[red]
7494 \path (newline) edge [bend right]    node [right=25,below=3]{J} (kanji)
7495       (midline) edge                 node [below]{J} (kanji)
7496       (kanji)   edge [bend left]     node {O} (midline)
7497       (kanji)   edge                 node {10} (skipspc)
7498       (kanji)   edge [loop right]    node {G, J} (kanji)
7499       (skipspc) edge [bend left]     node {J} (kanji)
7500       (kanji)   edge                 node {5} (endk)
7501 ;
7502 \end{scope}
7503 \end{scope}
7504 \end{tikzpicture}
7505 \end{center}
7506 \end{minipage}%
7507 \begin{minipage}{.4\textwidth}
7508 \begin{description}
7509 \item[\textsf{G}] Beginning of group (usually \verb+{+)\\
7510  and ending of group (usually \verb+}+).
7511 \item[\textsf{J}] Japanese characters.
7512 \item[\textsf{5}] \textit{end-of-line} (usually \verb+^+\verb+^J+).
7513 \item[\textsf{10}] space (usually \sp).
7514 \item[\textsf{O}] other characters, whose category code is in $\{3,4,6,7,8,11,12,13\}$.
7515 \item[\textsf{[\sp]}, \textsf{[\cs{par}]}]
7516 emits a space, or~\cs{par}.
7517 \end{description}
7518 \end{minipage}
7519 \begin{itemize}
7520 \item We omitted about category codes
7521 9~(\textit{ignored}), 14~(\textit{comment}), and~15~(\textit{invalid})
7522 from the above diagram. We also ignored the input like ``\verb+^+\verb+^A+'' or ``\verb+^+\verb+^df+''.
7523 \item When a character whose category code is 0 (\textit{escape character}) is seen by \TeX,
7524 the input processor scans a control sequence (\textsf{scan a c.s.}).
7525 These paths are not shown in the above diagram.
7526
7527 After that, the state is changed to State~$S$ (skipping blanks) in most cases, but
7528 to State~$M$ (middle of line) sometimes.
7529 \end{itemize}
7530 %<en>\caption{State transitions of \pTeX's input processor}
7531 %<ja>\caption{\pTeX の入力処理部の状態遷移}
7532 \label{fig-ptexipro}
7533 \end{figure}
7534
7535
7536 %<en>\subsection{Behavior in \LuaTeX-ja}
7537 %<ja>\subsection{\LuaTeX-jaの動作}
7538 %<*en>
7539 States in the input processor of \LuaTeX\ is the same as that of \TeX,
7540 and they can't be customized by any callbacks. Hence, we can only use
7541 \verb+process_input_buffer+ and \verb+token_filter+ callbacks for to
7542 suppress a space by a line break which is after Japanese characters.
7543
7544 However, \verb+token_filter+ callback cannot be used either, since a
7545 character in category code 5~(\textit{end-of-line}) is converted into an space
7546 token \emph{in the input processor}.  So we can use only the
7547 \verb+process_input_buffer+ callback.  This means that suppressing a
7548 space must be done \emph{just before} an input line is read.
7549
7550 Considering these situations, handling of an end-of-line in \LuaTeX-ja are as follows:
7551 \begin{quote}
7552 A character \texttt{U+FFFFF} (its category code is set to 14~(\textit{comment}) by
7553 \LuaTeX-ja) is appended to an input line, \emph{before \LuaTeX\ actually
7554 process it}, if and only if the following three conditions are satisfied:
7555 \begin{enumerate}
7556 \item The category code of \cs{endlinechar}%
7557 \footnote{Usually, it is $\langle$\textit{return}$\rangle$
7558       (whose character code is 13).} is 5~(\textit{end-of-line}).
7559 \item The category code of \texttt{U+FFFFF} itself is 14~(\textit{comment}).
7560 \item The input line matches the following ``regular expression'':
7561 \[
7562   (\text{any char})^*(\textbf{JAchar})
7563   \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
7564 \]
7565 \end{enumerate}
7566 \end{quote}
7567
7568 \paragraph{Remark}
7569 The following example shows the major difference from the behavior of \pTeX.
7570 \begin{LTXexample}
7571 \fontspec[Ligatures=TeX]{Linux Libertine O}
7572 \ltjsetparameter{autoxspacing=false}
7573 \ltjsetparameter{jacharrange={-6}}xあ
7574 y\ltjsetparameter{jacharrange={+6}}zい
7575 u
7576 \end{LTXexample}
7577 It is not strange that ``あ'' does not printed in the above output.
7578 This is because \TeX\ Gyre\ Termes does not contain ``あ'', and because
7579 ``あ'' in line~3 is considered as an \textbf{ALchar}.
7580
7581 Note that there is no space before ``y'' in the output, but
7582 there is a space before ``u''. This follows from following reasons:
7583 \begin{itemize}
7584 \item When line~3 is processed by \texttt{process\_input\_buffer} callback,
7585 ``あ'' is considered as an \textbf{JAchar}.
7586 Since  line~3 ends with an \textbf{JAchar},
7587 the comment character \texttt{U+FFFFF} is appended to this line,
7588 and hence the linebreak immediately after this line is ignored.
7589 \item When line~4 is processed by \texttt{process\_input\_buffer} callback,
7590 ``い'' is considered as an \textbf{ALchar}.
7591 Since  line~4 ends with an \textbf{ALchar}, the linebreak immediately after this line
7592 emits a space.
7593 \end{itemize}
7594 %</en>
7595
7596 %<*ja>
7597 \LuaTeX の入力処理部は\TeX のそれと全く同じであり,コールバックによりユーザが
7598 カスタマイズすることはできない.このため,改行抑制の目的でユーザが利用で
7599 きそうなコールバックとしては,\verb+process_input_buffer+や
7600 \verb+token_filter+に限られてしまう.しかし,\TeX の入力処理部をよく見る
7601 と,後者も役には経たないことが分かる:改行文字は,入力処理部によってトー
7602 クン化される時に,カテゴリーコード10の32番文字へと置き換えられてしまうた
7603 め,\verb+token_filter+で非標準なトークン読み出しを行おうとしても,空白文
7604 字由来のトークンと,改行文字由来のトークンは区別できないのだ.
7605
7606 すると,我々のとれる道は,\verb+process_input_buffer+を用いて
7607 \LuaTeX の入力処理部に引き渡される前に入力文字列を編集するというものしかない.
7608 以上を踏まえ,\LuaTeX-jaにおける「和文文字直後の改行抑制」の処理は,次のようになっている:
7609
7610 \begin{quote}
7611 各入力行に対し,\emph{その入力行が読まれる前の内部状態で}
7612 以下の3条件が満たされている場合,\LuaTeX-jaは\texttt{U+FFFFF}の文字
7613 \footnote{この文字はコメント文字として扱われるように\LuaTeX-ja内部で設定をしている.}
7614 を末尾に追加する.よって,その場合に改行は空白とは見做されないこととなる.
7615 \begin{enumerate}
7616 \item \cs{endlinechar}の文字\footnote{普通は,改行文字(文字コード13番)である.}
7617 のカテゴリーコードが5~(\textit{end-of-line})である.
7618 \item \texttt{U+FFFFF}のカテゴリーコードが14~(\textit{comment})である.
7619 \item 入力行は次の「正規表現」にマッチしている:
7620 \[
7621   (\text{any char})^*(\textbf{JAchar})
7622   \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
7623 \]
7624 \end{enumerate}
7625 \end{quote}
7626
7627 この仕様は,前節で述べた\pTeX の仕様にできるだけ近づけたものとなっている.条件1.は,
7628 \texttt{lstlisting}系環境などの日本語対応マクロを書かなくてすませるためのものである.
7629
7630 しかしながら,\pTeX と完全に同じ挙動が実現できたわけではない.
7631 次のように,\textbf{JAchar}の範囲を変更したちょうどその行においては挙動が異なる:
7632 \begin{LTXexample}
7633 \fontspec[Ligatures=TeX]{TeX Gyre Termes}
7634 \ltjsetparameter{autoxspacing=false}
7635 \ltjsetparameter{jacharrange={-6}}xあ
7636 y\ltjsetparameter{jacharrange={+6}}zい
7637 u
7638 \end{LTXexample}
7639 上ソース中の「あ」は\textbf{ALchar}(欧文扱い)であり.
7640 ここで使用している欧文フォント\TeX\ Gyre Termesは「あ」を含まない.
7641 よって,出力に「あ」は現れないことは不思議ではない.
7642 それでも,\pTeX とまったく同じ挙動を示すならば,出力は
7643 「\hbox{\ltjsetparameter{autoxspacing=false}x yzいu}」となるはずである.しかし,実際には
7644 上のように異なる挙動となっているが,それは以下の理由による:
7645 \begin{itemize}
7646 \item 3行目を \texttt{process\_input\_buffer} で処理する時点では,
7647       「あ」は\textbf{JAchar}(和文扱い)である.よって3行目は\textbf{JAchar}で終わることになり,
7648       コメント文字 \texttt{U+FFFFF} が追加される.
7649       よって,直後の改行文字は無視されることになり,空白は入らない.
7650 \item 4行目を \texttt{process\_input\_buffer} で処理する時点では,
7651       「い」は\textbf{ALchar}である.よって4行目は\textbf{ALchar}で終わることになり,
7652       直後の改行文字は空白に置き換わる.
7653 \end{itemize}
7654 このため,トラブルを避けるために,\textbf{JAchar}の範囲を\cs{ltjsetparameter}で編集した場合,
7655 その行はそこで改行するようにした方がいいだろう.
7656 %</ja>
7657
7658 %<*ja>
7659
7660 %<en>\section{Insertion of JFM glues, \Param{kanjiskip} and \Param{xkanjiskip}}
7661 %<ja>\section{JFMグルーの挿入,\Param{kanjiskip}と\Param{xkanjiskip}}
7662 \label{sec-jfmglue}
7663 %<en>\subsection{Overview}
7664 %<ja>\subsection{概要}
7665
7666 \LuaTeX-jaにおける \textbf{JAglue} の挿入方法は,\pTeX のそれとは全く異なる.
7667 \pTeX では次のような仕様であった:
7668 \begin{itemize}
7669 \item JFMグルーの挿入は,和文文字を表すトークンを元に水平リストに(文字を表す)<char\_node>を
7670 追加する過程で行われる.
7671 \item \Param{xkanjiskip}の挿入は,hboxへのパッケージングや行分割前に行われる.
7672 \item \Param{kanjiskip}はノードとしては挿入されない.パッケージングや行分割の計算時に
7673 「和文文字を表す2つの<char\_node>の間には\Param{kanjiskip}がある」ものとみなされる.
7674 \end{itemize}
7675 しかし,\LuaTeX-jaでは,hboxへのパッケージングや行分割前に全ての
7676 \textbf{JAglue},即ちJFMグルー・\Param{xkanjiskip}・\Param{kanjiskip}の
7677 3種類を一度に挿入することになっている.これは,\LuaTeX において欧文の合字・
7678 カーニング処理がノードベースになったことに対応する変更である.
7679
7680 \LuaTeX-jaにおける\textbf{JAglue}挿入処理では,次節で定義する
7681 「クラスタ」を単位にして行われる.大雑把にいうと,「クラスタ」は文字とそれに付随す
7682 るノード達(アクセント位置補正用のカーンや,イタリック補正)をまとめたもの
7683 であり,2つのクラスタの間には,ペナルティ,\cs{vadjust},whatsitなど,行組版
7684 には関係しないものがある.
7685
7686
7687 %<en>\subsection{Definition of a Cluster}
7688 %<ja>\subsection{「クラスタ」の定義}
7689
7690 \def\OA{$\text{\sf O}_{\text{\sf A}}$}
7691 \def\OB{$\text{\sf O}_{\text{\sf B}}$}
7692 \begin{defn}
7693 %<*en>
7694 A \emph{cluster} is consecutive nodes in one of the following forms,
7695 with the \textit{id} of it:
7696 %</en>
7697 %<*ja>
7698 \emph{クラスタ}は以下の形のうちのどれかひとつをとるノードのリストである:
7699 %</ja>
7700 \begin{enumerate}
7701 %<*en>
7702 \item Nodes whose value of\ \verb+\ltj@icflag+ is in $[3,15)$.  These
7703       nodes come from a hbox which is already packaged, by unpackaging
7704       (\cs{unhbox}).
7705       The \textit{id} of the cluster is \textit{id\_pbox}.
7706 %</en>
7707 %<*ja>
7708 \item その \verb+\ltj@icflag+ の値が$[3,15)$に入るノードのリスト.
7709   これらのノードはある既にパッケージングされたhboxから \cs{unhbox} で
7710   アンパックされたものである.
7711   この場合,クラスタの\textit{id}は\textit{id\_pbox}である.
7712 %</ja>
7713
7714 %<*en>
7715 \item A inline math formula, including two \textit{math\_node}s at the boundary of it.
7716       The \textit{id} of the cluster is \textit{id\_math}.
7717 %</en>
7718 %<*ja>
7719 \item インライン数式でその境界に2つの\textit{math\_node}を含むもの.
7720   この場合,クラスタの\textit{id}は\textit{id\_math}である.
7721 %</ja>
7722
7723 %<*en>
7724 \item A \textit{glyph\_node}~$p$, which represents a \textbf{JAchar}, with nodes which relate with it:
7725 %</en>
7726 %<*ja>
7727 \item \textbf{JAchar}を表す\textit{glyph\_node}~$p$とそれに関係するノード:
7728 %</ja>
7729 \begin{enumerate}
7730 %<*en>
7731 \item[(a)] A kern for the italic correction of~$p$.
7732 %</en>
7733 %<*ja>
7734 \item[(a)] $p$のイタリック補正のためのカーン.
7735 %</ja>
7736
7737 %<*en>
7738 \item[(b)] An accent attached to $p$ by \cs{accent}.
7739 %</en>
7740 %<*ja>
7741 \item[(b)] \cs{accent} による$p$に付随したアクセント.
7742 %</ja>
7743 \end{enumerate}
7744 \[
7745 \overbrace{%
7746  \Node{kern}{$\mathit{subtype}=2$}\longrightarrow
7747 \left\{\begin{array}{c}
7748 \Node{glyph}{accent}\\\noalign{\medskip}
7749 \Node{hbox}{accent (shifted vert.)}
7750 \end{array}\right\}\longrightarrow
7751 \Node{kern}{$\mathit{subtype}=2$}}^{\text{(a)}}
7752 \longrightarrow
7753 \Node{glyph}{$p$}\longrightarrow
7754 \overbrace{%
7755 \Node{kern}{italic corr.}}^{\text{(b)}}
7756 \]
7757
7758 %<*en>
7759 In this case, the \textit{id} is \textit{id\_jglyph}.
7760 %</en>
7761 %<*ja>
7762 この場合の\textit{id}は\textit{id\_jglyph}である.
7763 %</ja>
7764
7765 %<*en>
7766 \item A list which begins from a \textit{glyph\_node} which represents a \textbf{ALchar},
7767       and consists of \textbf{ALchar} \textit{glyph\_node}s,
7768       kerns for adjusting accents~(its subtype is 2), kerns for italic corrections and
7769       kerns which are automatically inserted by \LuaTeX~or~luaotfload.
7770       In this case, the \textit{id} is \textit{id\_glyph}.
7771 %</en>
7772 %<*ja>
7773 \item \textbf{ALchar}を表す\textit{glyph\_node},\cs{accent} によるアクセント位置補正用の
7774       カーン(subtypeが2),そしてイタリック補正・カーニングによって挿入されたカーン達が連続
7775       したもの.この場合の\textit{id}は\textit{id\_glyph}である.
7776 %</ja>
7777
7778 %<*en>
7779 \item An box-like node, that is, an hbox, a vbox, a rule (\cs{vrule}) and an \textit{unset\_node}.
7780 The \textit{id} of the cluster is \textit{id\_hlist} if the node is an
7781       hbox which is not shifted vertically, or \textit{id\_box\_like}
7782       otherwise.
7783 %</en>
7784 %<*ja>
7785 \item 水平ボックス(hbox),垂直ボックス,罫線 (\cs{vrule}),
7786   そして\textit{unset\_node}.
7787   クラスタの\textit{id}は垂直に移動していないhboxならば\textit{id\_hlist},
7788   そうでなければ\textit{id\_box\_like}となる.
7789 %</ja>
7790
7791 %<*en>
7792 \item A glue, a kern whose subtype is not 2~(\textit{accent}), and a discretionary break.
7793 The \textit{id} of the cluster is \textit{id\_glue}, \textit{id\_kern}
7794       and \textit{id\_disc}, respectively.
7795 %</en>
7796 %<*ja>
7797 \item グルー,subtypeが 2~(\textit{accent})ではないカーン,そしてdiscretionary break.
7798   その\textit{id} of the clusterはそれぞれ\textit{id\_glue}, \textit{id\_kern},そして
7799   \textit{id\_disc}である.
7800 %</ja>
7801 \end{enumerate}
7802 %<*en>
7803 We use \textit{Np}, \textit{Nq} and \textit{Nr} to denote a cluster.
7804 %</en>
7805 %<*ja>
7806 以下では\textit{Np}, \textit{Nq}, \textit{Nr}でクラスタを表す.
7807 %</ja>
7808 \end{defn}
7809
7810 \paragraph{\textit{id}の意味}
7811 $\mathit{Np}.\mathit{id}$の意味を述べるとともに,
7812 「先頭の文字」を表す\textit{glyph\_node}~$\mathit{Np}.\mathit{head}$と,
7813 「最後の文字」を表す\textit{glyph\_node}~$\mathit{Np}.\mathit{tail}$を次のように定義する.
7814 直感的に言うと,\textit{Np}は$\mathit{Np}.\mathit{head}$で始まり$\mathit{Np}.\mathit{tail}$で終わるような単語,
7815 と見做すことができる.これら$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は
7816 説明用に準備した概念であって,実際のLuaコード中にそのように書かれているわけではないことに注意.
7817
7818 \begin{description}
7819 \item[\textit{id\_jglyph}] \textbf{JAchar}(和文文字).\\
7820 $\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は,その\textbf{JAchar}を表している
7821 \textit{glyph\_node}そのものである.
7822 \item[\textit{id\_glyph}] \textbf{JAchar}(和文文字)以外のものを表す\textit{glyph\_node}~$p$.\\
7823 多くの場合,$p$は\textbf{ALchar}(欧文文字)を格納しているが,「ffi」などの合字によって作られた
7824 \textit{glyph\_node}である可能性もある.
7825 前者の場合,$\mathit{Np}.\mathit{head}$,~$\mathit{Np}.\mathit{tail} = p$である.
7826 一方,後者の場合,
7827 \begin{itemize}
7828 \item $\mathit{Np}.\mathit{head}$は,
7829 合字の構成要素の先頭→(その\textit{glyph\_node}における)合字の構成要素の先頭→……
7830 と再帰的に検索していってたどり着いた\textit{glyph\_node}である.
7831 \item $\mathit{Np}.\mathit{last}$は,同様に末尾→末尾→と検索してたどり着いた\textit{glyph\_node}である.
7832 \end{itemize}
7833 \item[\textit{id\_math}] インライン数式.\\
7834 便宜的に,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$ともに
7835 「文字コード$-1$の欧文文字」とおく.
7836 \item[\textit{id\_hlist}] 縦方向にシフトされていないhbox.\\
7837 この場合,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$はそれぞれ$p$の内容を表すリストの,
7838 先頭・末尾のノードである.
7839 \medskip
7840 \begin{itemize}
7841 \item 状況によっては,\TeX ソースで言うと
7842 \begin{lstlisting}
7843 \hbox{\hbox{abc}...\hbox{\lower1pt\hbox{xyz}}}
7844 \end{lstlisting}
7845 のように,$p$の内容が別のhboxで開始・終了している可能性も十分あり得る.そのような場合,
7846 $\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$の算出は,
7847 \emph{垂直方向にシフトされていない}hboxの
7848 場合だけ内部を再帰的に探索する.例えば上の例では,$\mathit{Np}.\mathit{head}$は文字「a」を表すノードであり,
7849 一方$\mathit{Np}.\mathit{tail}$は垂直方向にシフトされたhbox,
7850 \verb+\lower1pt\hbox{xyz}+ に対応するノードである.
7851 \item また,先頭にアクセント付きの文字がきたり,末尾にイタリック補正用のカーンが
7852 来ることもあり得る.この場合は,クラスタの定義のところにもあったように,それらは無視して算出を行う.
7853 \item 最初・最後のノードが合字によって作られた\textit{glyph\_node}のときは,それぞれに対して\textit{id\_glyph}%
7854 と同様に再帰的に構成要素をたどっていく.
7855 \end{itemize}
7856 \item[\textit{id\_pbox}] 「既に処理された」ノードのリストであり,これらのノードが二度処理を受けないために
7857 まとめて1つのクラスタとして取り扱うだけである.
7858 \textit{id\_hlist}と同じ方法で$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$を算出する,
7859 \item[\textit{id\_disc}] discretionary break (\verb+\discretionary{pre}{post}{nobreak}+).\\
7860 \textit{id\_hlist}と同じ方法で$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$を算出するが,
7861 第3引数の \texttt{nobreak}(行分割が行われない時の内容)を使う.言い換えれば,ここで行分割が発生した時の状況は
7862 全く考慮に入れない.
7863 \item[\textit{id\_box\_like}] \textit{id\_hlist}とならないboxや,rule.\\
7864 この場合は,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$のデータは利用されないので,2つの算出は無意味である.
7865 敢えて明示するならば,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は共にnil値である.
7866 \item[他] 以上にない\textit{id}に対しても,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$の算出は無意味.
7867 \end{description}
7868
7869 \paragraph{クラスタの別の分類}
7870 さらに,JFMグルー挿入処理の実際の説明により便利なように,\textit{id}とは別のクラスタの分類を行っておく.
7871 挿入処理では2つの隣り合ったクラスタの間に
7872 空白等の実際の挿入を行うことは前に書いたが,ここでの説明では,問題にしているクラスタ\textit{Np}は「後ろ側」のクラスタである
7873 とする.「前側」のクラスタについては,以下の説明で\textit{head}が\textit{last}に置き換わることに注意すること.
7874 \begin{description}
7875 \item[和文A] リスト中に直接出現している\textbf{JAchar}.
7876 \textit{id}が\textit{id\_jglyph}であるか,\\
7877 \textit{id}が\textit{id\_pbox}であって$\mathit{Np}.\mathit{head}$が\textbf{JAchar}であるとき.
7878
7879 \item[和文B] リスト中のhboxの中身の先頭として出現した\textbf{JAchar}.和文Aとの違いは,これの前に
7880 JFMグルーの挿入が行われない(\Param{xkanjiskip},~\Param{kanjiskip}は入り得る)ことである.\\
7881 \textit{id}が\textit{id\_hlist}か\textit{id\_disc}であって$\mathit{Np}.\mathit{head}$が\textbf{JAchar}であるとき.
7882
7883 \item[欧文] リスト中に直接/hboxの中身として出現している「\textbf{JAchar}以外の文字」.次の3つの場合が該当:
7884 \begin{itemize}
7885 \item \textit{id}が\textit{id\_glyph}である.
7886 \item \textit{id}が\textit{id\_math}である.
7887 \item \textit{id}が\textit{id\_pbox}か\textit{id\_hlist}か\textit{id\_disc}であって,$\mathit{Np}.\mathit{head}$が\textbf{ALchar}.
7888 \end{itemize}
7889 \item[箱] box,またはそれに類似するもの.次の2つが該当:
7890 \begin{itemize}
7891 \item \textit{id}が\textit{id\_pbox}か\textit{id\_hlist}か\textit{id\_disc}であって,$\mathit{Np}.\mathit{head}$が\textit{glyph\_node}でない.
7892 \item \textit{id}が\textit{id\_box\_like}である.
7893 \end{itemize}
7894
7895 \end{description}
7896
7897 \subsection{段落/hboxの先頭や末尾}
7898 \paragraph{先頭部の処理}
7899 まず,段落/hboxの一番最初にあるクラスタ\textit{Np}を探索する.
7900 hboxの場合は何の問題もないが,段落の場合では以下のノード達を事前に読み飛ばしておく:
7901 \begin{itemize}
7902 \item \cs{parindent} 由来のhbox($\mathit{subtype}=3$)
7903 \item \textit{subtype}が44~(\textit{user\_defined})でないようなwhatsit
7904 \end{itemize}
7905 これは,\cs{parindent}由来のhboxがクラスタを構成しないようにするためである.
7906
7907 次に,\textit{Np}の直前に空白$g$を必要なら挿入する:
7908 \begin{enumerate}
7909 \item この処理が働くような\textit{Np}は\textsf{和文A}である.
7910 \item 問題のリストが字下げありの段落(\cs{parindent} 由来のhboxあり)の場合は,
7911 この空白$g$は「文字コード \texttt{'parbdd'} の文字」と\textit{Np}の間に入るグルー/カーンである.
7912 \item そうでないとき(\verb+noindent+ で開始された段落やhbox)は,
7913 $g$は「文字コード \texttt{'boxbdd'} の文字」と\textit{Np}の間に入るグルー/カーンである.
7914 \end{enumerate}
7915 ただし,もし$g$がglueであった場合,この挿入によって\textit{Np}による行分割が新たに可能になるべきではない.
7916 そこで,以下の場合には,$g$の直前に \cs{penalty10000} を挿入する:
7917 \begin{itemize}
7918 \item 問題にしているリストが段落であり,かつ
7919 \item \textit{Np}の前には予めペナルティがなく,$g$はglue.
7920 \end{itemize}
7921
7922 \paragraph{末尾の処理}
7923 末尾の処理は,問題のリストが段落のものかhboxのものかによって異なる.
7924 後者の場合は容易い:最後のクラスタを\textit{Nq}とおくと,\textit{Nq}と「文字コード\
7925 \texttt{'boxbdd'} の文字」の間に入るグルー/カーンを,
7926 \textit{Nq}の直後に挿入するのみである.
7927
7928 一方.前者(段落)の場合は,リストの末尾は常に \cs{penalty10000} と,
7929 \cs{parfillskip} 由来のグルーが存在する.%よって,最後のクラスタ\textit{Np}は
7930 %この \cs{parfillskip} 由来のグルーとなり,実質的な中身の最後はその1つ前のクラスタ\textit{Nq}となる.
7931 段落の最後の「通常の\textbf{JAchar}${}+{}$句点」が独立した行となるのを防ぐために,
7932 \Param{jcharwidowpenalty}の値の分だけ適切な場所のペナルティを増やす.
7933
7934 ペナルティ量を増やす場所は,\textit{head}が\textbf{JAchar}であり,
7935 かつその文字の\Param{kcatcode}が偶数であるような
7936 最後のクラスタの直前にあるものたちである%
7937 \footnote{大雑把に言えば,\Param{kcatcode}が奇数であるような\textbf{JAchar}%
7938 を約物として考えていることになる.
7939 \Param{kcatcode}の最下位ビットはこの\Param{jcharwidowpenalty}用にのみ利用される.}.
7940
7941 \subsection{概観と典型例:2つの「和文A」の場合}
7942 \label{ssec-cluster-wa}
7943 先に述べたように,2つの隣り合ったクラスタ,\textit{Nq}と\textit{Np}の間には,
7944 ペナルティ,\cs{vadjust},whatsitなど,行組版には関係しないものがある.模式的に表すと,
7945 \[
7946  \Node{cluster}{\textit{Nq}}\longrightarrow
7947 \overbrace{
7948 \Node{penalty}{$p$}\longrightarrow \cdots\longrightarrow \Node{whatsit}{}}^{\textrm{(a)}}
7949 \longrightarrow \Node{cluster}{\textit{Np}}
7950 \]
7951 のようになっている.間の(a)に相当する部分には,何のノードもない場合ももちろんあり得る.
7952 そうして,JFMグルー挿入後には,この2クラスタ間は次のようになる:
7953 \[
7954  \Node{cluster}{\textit{Nq}}\longrightarrow%\Node{kern}{左空白}\longrightarrow
7955 \overbrace{
7956 \Node{penalty}{$p+x$}\longrightarrow \cdots\longrightarrow
7957 \Node{whatsit}{}}^{\textrm{(a)}}\longrightarrow
7958 \Node{glue or kern}{\raisebox{-.2\zw}{右空白}}\longrightarrow
7959 \Node{cluster}{\textit{Np}}
7960 \]
7961
7962 以後,\emph{典型的な例として,クラスタ\textit{Nq}と\textit{Np}が共に\textsf{\textmd{和文A}}である場合を見ていこう,}
7963 この場合が全ての場合の基本となる.
7964
7965 \paragraph{「右空白」の算出}
7966 まず,「右空白」にあたる量を算出する.通常はこれが,隣り合った2つの\textbf{JAchar}間に入る空白量となる.
7967 \begin{description}
7968 \item[JFM由来{[M]}] JFMの文字クラス指定によって入る空白を以下によって求める.この段階で空白量が未定義(未指定)だった場合,
7969       デフォルト値\Param{kanjiskip}を採用することとなるので,次へ.
7970 \begin{enumerate}
7971 \item もし両クラスタの間で \cs{inhibitglue} が実行されていた場合(証としてwhatsitノードが自動挿入される),
7972       代わりに\Param{kanjiskip}が挿入されることとなる.次へ.
7973 \item \textit{Nq}と\textit{Np}が同じJFM・同じ\texttt{jfmvar}キー・同じサイズの和文フォントであったならば,
7974       共通に使っているJFM内で挿入される空白(グルーかカーン)が決まっているか調べ,決まっていればそれを採用.
7975 \item 1.でも2.でもない場合は,JFM・\texttt{jfmvar}・サイズの3つ組は\textit{Nq}と\textit{Np}で異なる.
7976 この場合,まず
7977 \[
7978 \vcenter{\halign{\hfil$#:={}$&\inhibitglue#\inhibitglue\cr
7979 gb&(\textit{Nq}と「使用フォントが\textit{Nq}のそれと同じで,\hfil\cr
7980 \omit&\quad 文字コードが\textit{Np}のそれの文字」との間に入るグルー/カーン)\hfil\cr
7981 ga&(\inhibitglue 「使用フォントが\textit{Np}のそれと同じで,\hfil\cr
7982 \omit&\quad 文字コードが\textit{Nq}のそれの文字」と\textit{Np}との間に入るグルー/カーン)\hfil\cr
7983 }}
7984 \]
7985 として,前側の文字のJFMを使った時の空白(グルー/カーン)と,後側の文字のJFMを使った時のそれを求める.
7986
7987 $\mathit{gb}$,~$\mathit{ga}$それぞれに対する<ratio>の値を$d_b$,~$d_a$とする.
7988 \begin{itemize}
7989 \item
7990 $\mathit{ga}$と$\mathit{gb}$の両方が未定義であるならば,JFM由来のグルーは挿入されず,
7991 \Param{kanjiskip}を採用することとなる.
7992 どちらか片方のみが未定義であるならば,次のステップでその未定義の方は長さ0のkernで,<ratio>の値は0であるかのように扱われる.
7993 \item
7994 \Param{diffrentjfm}の値が \texttt{pleft}, \texttt{pright},
7995       \texttt{paverage} のとき,
7996 <ratio>の指定に従って比例配分を行う.
7997 JFM由来のグルー/カーンは以下の値となる:
7998 \[
7999  f\left(\frac{1-d_b}2\textit{gb} + \frac{1+d_b}2\textit{ga},
8000 \frac{1-d_a}2\textit{gb} + \frac{1+d_a}2\textit{ga}\right)
8001 \]
8002 ここで.$f(x,y)$は
8003 \[
8004  f(x,y)=\begin{cases}
8005 x&\text{if\ }\Param{diffrentjfm}=\texttt{pleft};\\
8006 y&\text{if\ }\Param{diffrentjfm}=\texttt{pright};\\
8007 (x+y)/2&\text{if\ }\Param{diffrentjfm}=\texttt{paverage};
8008 \end{cases}.
8009 \]
8010 \item
8011 \Param{differentjfm}がそれ以外の値の時は,<ratio>の値は無視され,JFM由来のグルー/カーンは以下の値となる:
8012 \[
8013  f(\textit{gb},\textit{ga})
8014 \]
8015 ここで.$f(x,y)$は
8016 \[
8017  f(x,y)=\begin{cases}
8018 \min(x,y)&\text{if\ }\Param{diffrentjfm}=\texttt{small};\\
8019 \max(x,y)&\text{if\ }\Param{diffrentjfm}=\texttt{large};\\
8020 (x+y)/2&\text{if\ }\Param{diffrentjfm}=\texttt{average};\\
8021 x+y&\text{if\ }\Param{diffrentjfm}=\texttt{both};
8022 \end{cases}.
8023 \]
8024 \end{itemize}
8025 \end{enumerate}
8026
8027 例えば,
8028 \begin{lstlisting}
8029 \jfont\foo=psft:Ryumin-Light:jfm=ujis;-kern
8030 \jfont\bar=psft:GothicBBB-Medium:jfm=ujis;-kern
8031 \jfont\baz=psft:GothicBBB-Medium:jfm=ujis;jfmvar=piyo;-kern
8032 \end{lstlisting}
8033 という3フォントを考え,
8034 \[
8035  \overbrace{\Node{glyph}{\cs{ foo}, `あ'}}^{p}
8036 \longrightarrow \overbrace{\Node{glyph}{\cs{bar}, `い'}}^{q}
8037 \longrightarrow \overbrace{\Node{glyph}{\cs{baz}, `う'}}^{r}
8038 \]
8039 という3ノードを考える(それぞれ単独でクラスタをなす).
8040 この場合,$p$と$q$の間は,実フォントが異なるにもかかわらず2.の状況となる一方で,
8041 $q$と$r$の間は(実フォントが同じなのに)\texttt{jfmvar} キーの内容が異なるので3.の状況となる.
8042 \item[\Param{kanjiskip}~{[K]}] 上の[M]において空白が定まらなかった場合,
8043 以下で定めた量「右空白」として採用する.
8044 この段階においては,\cs{inhibitglue} は効力を持たないため,
8045 結果として,2つの\textbf{JAchar}間には常に何らかのグルー/カーンが挿入されることとなる.
8046 \begin{enumerate}
8047 \item 両クラスタ(厳密には$\mathit{Nq}.\mathit{tail}$,$\mathit{Np}.\mathit{head}$)の中身の文字コードに対する
8048 \Param{autospacing}パラメタが両方ともfalseだった場合は,長さ0のglueとする.
8049 \item ユーザ側から見た\Param{kanjiskip}パラメタの自然長が$\cs{maxdimen}=(2^{30}-1)\,{\rm sp}$で
8050 なければ,\Param{kanjiskip}パラメタの値を持つglueを採用する.
8051 \item 2.でない場合は,\textit{Nq}, \textit{Np}で使われているJFMに指定されている\Param{kanjiskip}の値を用いる.
8052 どちらか片方のクラスタだけが\textbf{JAchar}(\textsf{和文A}・\textsf{和文B})のときは,そちらのクラスタで使われている
8053 JFM由来の値だけを用いる.もし両者で使われているJFMが異なった場合は,上の[M]~3.と同様の方法を用いて調整する.
8054 \end{enumerate}
8055 \end{description}
8056 %\paragraph{「左空白」の算出とそれに伴う補正}
8057 %「左空白」は過去のバージョンでは定義していたが,このバージョンでは
8058 %挿入は一切行われない(機能自体削除している).
8059 %しかし,仕様は流動的であり,将来復活する可能性もあるため,マニュアル中の記述は今のところ極力変更しない.
8060 \paragraph{禁則用ペナルティの挿入}
8061 まず,
8062 \[
8063  a:=(\text{\textit{Nq}{\footnotemark}の文字に対する\Param{postbreakpenalty}の値})
8064 +(\text{\textit{Np}{\footnotemark}の文字に対する\Param{prebreakpenalty}の値})
8065 \]
8066 とおく\footnotetext{厳密にはそれぞれ$\mathit{Nq}.\mathit{tail}$,$\mathit{Np}.\mathit{head}$.}.
8067 ペナルティは通常$[-10000,10000]$の整数値をとり,また$\pm 10000$は正負の無限大を意味することになっているが,この$a$の
8068 算出では単純な整数の加減算を行う.
8069
8070 $a$は禁則処理用に\textit{Nq}と\textit{Np}の間に加えられるべきペナルティ量である.
8071 \begin{description}
8072 \item[P-normal~{[PN]}]
8073 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティ(\textit{penalty\_node})があれば処理は簡単である:
8074 それらの各ノードにおいて,ペナルティ値を($\pm 10000$を無限大として扱いつつ)$a$だけ増加させればよい.
8075 また,$10000 + (-10000) = 0$としている.
8076
8077 少々困るのは,(a)部分にペナルティが存在していない場合である.
8078 直感的に,補正すべき量$a$が0でないとき,その値をもつ\textit{penalty\_node}を作って
8079 「右空白」の(もし未定義なら\textit{Np}の)直前に挿入……
8080 ということになるが,実際には僅かにこれより複雑である.
8081 \begin{itemize}
8082 \item 「右空白」がカーンであるとき,
8083 それは「\textit{Nq}と\textit{Np}の間で改行は許されない」ことを意図している.そのため,
8084 この場合は$a\neq 0$であってもペナルティの挿入はしない.
8085 \item そうでないないときは,$a\neq 0$ならば\textit{penalty\_node}を作って挿入する.
8086 %\item 「左空白」がカーンとしてきっちり定義されている時(このとき,「右空白」はカーンでない),
8087 %この「左空白」の直後での行分割を許容しないといけないので,$a=0$であっても
8088 %\textit{penalty\_node}を作って挿入する.
8089 %\item 以上のどれでもないときは,$a\neq 0$ならば\textit{penalty\_node}を作って挿入する.
8090 \end{itemize}
8091 \end{description}
8092
8093 \def\gkf#1#2#3{\sf$\displaystyle\vphantom{\Bigg(}%
8094   \frac{\hbox to 4\zw{\hss#2\hss}}{\hbox{#3}}$}
8095 \begin{table}[t]
8096 %<en>\caption{Summary of JFM glues}
8097 %<ja>\caption{JFM グルーの概要}
8098 \label{tab-jfmglue}
8099 %<en>\medskip
8100 \begin{center}
8101 \small
8102 \begin{tabular}{c|cccccc}
8103 \toprule
8104 {\bf\textit{Np}}↓&\sf 和文A&\sf 和文B&\sf 欧文&\sf 箱&\sf glue&\sf kern\\\midrule
8105 \sf 和文A&
8106 \gkf{E}{M→K}{PN}&
8107 \gkf{---}{\OA →K}{PN}&
8108 \gkf{---}{\OA →X}{PN}&
8109 \gkf{---}{\OA}{PA}&
8110 \gkf{---}{\OA}{PN}&
8111 \gkf{---}{\OA}{PS}\\
8112 \sf 和文B&
8113 \gkf{E}{\OB→K}{PA}&
8114 \gkf{---}{K}{PS}&
8115 \gkf{---}{X}{PS}\\
8116 \sf 欧文&
8117 \gkf{E}{\OB →X}{PA}&
8118 \gkf{---}{X}{PS}\cr
8119 \sf 箱&\gkf{E}{\OB}{PA}\\
8120 \sf glue&\gkf{E}{\OB}{PN}\\
8121 \sf kern&\gkf{E}{\OB}{PS}\\
8122 \bottomrule
8123 \end{tabular}
8124 \end{center}
8125 \begin{quote}
8126 %<*en>
8127 In the table above, {\small\gkf{E}{M→K}{PN}} means that
8128 %</en>
8129 %<*ja>
8130 上の表において,{\small\gkf{E}{M→K}{PN}}は次の意味である:
8131 %</ja>
8132 \begin{enumerate}
8133 %<*en>
8134 \item To determine the ``right-space'', \LuaTeX-ja first attempts by the method ``\textsf{JFM-origin~[M]}''.
8135 If this attempt fails, \LuaTeX-ja use the method ``\textsf{\Param{kanjiskip}~[K]}''.
8136 %</en>
8137 %<*ja>
8138 \item 「右空白」を決めるために,\LuaTeX-ja はまず「JFM由来{[M]}」の方法を試みる.
8139   これが失敗したら,\LuaTeX-ja は「\Param{kanjiskip}~{[K]}」の方法を試みる.
8140 %</ja>
8141
8142 % %<*en>
8143 % \item The ``left space'' between \textit{Nq}~and~\textit{Np} is
8144 %   determined by the method ``\textsf{line-end~[E]}''.
8145 % %</en>
8146 % %<*ja>
8147 % \item \textit{Nq} と \textit{Np} の間の「左空白」は「\textsf{line-end~[E]}」の
8148 %   方法で決定される.
8149 % %</ja>
8150
8151 %<*en>
8152 \item \LuaTeX-ja adopts the method ``\textsf{P-normal~[PN]}'' to adjust the penalty
8153   between two clusters for \emph{kinsoku shori}.
8154 %</en>
8155 %<*ja>
8156 \item \LuaTeX-jaは2つのクラスタの間の禁則処理用のペナルティを設定するために「\textsf{P-normal~[PN]}」の方法を採用する.
8157 %</ja>
8158 \end{enumerate}
8159 \end{quote}
8160 \end{table}
8161
8162 \subsection{その他の場合}
8163 本節の内容は表\ref{tab-jfmglue}にまとめてある.
8164
8165 \paragraph{和文Aと欧文の間}
8166 \textit{Nq}が\textsf{和文A}で,\textit{Np}が\textsf{欧文}の場合,JFMグルー挿入処理は次のようにして行われる.
8167 \begin{itemize}
8168 \item 「右空白」については,まず以下に述べる\textsf{Boundary-B~[\OB]}により空白を決定しようと試みる.
8169 それが失敗した場合は,\textsf{\Param{xkanjiskip}~[X]}によって定める.
8170 %\item 「左空白」については,既に述べた\textsf{line-end~[E]}をそのまま採用する.それに伴う「右空白」の補正も%同じ.
8171 \item 禁則用ペナルティも,以前述べた\textsf{P-normal~[PN]}と同じである.
8172 \end{itemize}
8173 \begin{description}
8174 \item[Boundary-B~{[\OB]}] \textbf{JAchar}と「\textbf{JAchar}でないもの」との間に入る空白を以下によって求め,
8175 未定義でなければそれを「右空白」として採用する.
8176 \textsf{JFM-origin~[M]}の変種と考えて良い.
8177 これによって定まる空白の典型例は,和文の閉じ括弧と欧文文字の間に入る半角アキである.
8178 \begin{enumerate}
8179 \item もし両クラスタの間で \cs{inhibitglue} が実行されていた場合%
8180 (証としてwhatsitノードが自動挿入される),「右空白」は未定義.
8181 \item そうでなければ,
8182 \textit{Nq}と「文字コードが {\tt'jcharbdd'} の文字」との間に入るグルー/カーンとして定まる.
8183 \end{enumerate}
8184 \item[\Param{xkanjiskip}~{[X]}]
8185 この段階では,\textsf{\Param{kanjiskip}~[K]}のときと同じように,
8186 以下で定めた量を「右空白」として採用する.
8187 \cs{inhibitglue} は効力を持たない.
8188 \begin{enumerate}
8189 \item 以下のいずれかの場合は,\Param{xkanjiskip}の挿入は抑止される.しかし,実際には行分割を許容するために,長さ0のglueを採用する:
8190 \begin{itemize}
8191 \item 両クラスタにおいて,それらの中身の文字コードに対する\Param{autoxspacing}パラメタが共にfalseである.
8192 \item \textit{Nq}の中身の文字コードについて,「直後への\Param{xkanjiskip}の挿入」が禁止されている
8193 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメタが2以上).
8194 \item \textit{Np}の中身の文字コードについて,「直前への\Param{xkanjiskip}の挿入」が禁止されている
8195 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメタが偶数).
8196 \end{itemize}
8197 \item ユーザ側から見た\Param{xkanjiskip}パラメタの自然長が$\cs{maxdimen}=(2^{30}-1)\,{\rm sp}$で
8198 なければ,\Param{xkanjiskip}パラメタの値を持つglueを採用する.
8199 \item 2.でない場合は,\textit{Nq}, \textit{Np}(\textsf{和文A}/\textsf{和文B}なのは片方だけ)
8200 で使われているJFMに指定されている\Param{xkanjiskip}の値を用いる.
8201 \end{enumerate}
8202 \end{description}
8203
8204 \paragraph{欧文と和文Aの間}
8205 \textit{Nq}が\textsf{欧文}で,\textit{Np}が\textsf{和文A}の場合,JFMグルー挿入処理は上の場合とほぼ同じである.
8206 \textsf{和文A}のクラスタが逆になるので,\textsf{Boundary-A~[\OA]}の部分が変わるだけ.
8207 \begin{itemize}
8208 \item 「右空白」については,まず以下に述べる\textsf{Boundary-A~[\OA]}により空白を決定しようと試みる.
8209 それが失敗した場合は,\textsf{\Param{xkanjiskip}~[X]}によって定める.
8210 %\item \textit{Nq}が和文でないので,「左空白」は算出されない.
8211 \item 禁則用ペナルティは,以前述べた\textsf{P-normal~[PN]}と同じである.
8212 \end{itemize}
8213 \begin{description}
8214 \item[Boundary-A~{[\OA]}] 「\textbf{JAchar}でないもの」と\textbf{JAchar}との間に入る空白を以下によって求め,
8215 未定義でなければそれを「右空白」として採用する.
8216 \textsf{JFM-origin~[M]}の変種と考えて良い.
8217 これによって定まる空白の典型例は,欧文文字と和文の開き括弧との間に入る半角アキである.
8218 \begin{enumerate}
8219 \item もし両クラスタの間で \cs{inhibitglue} が実行されていた場合(証としてwhatsitノードが自動挿入される),次へ.
8220 \item そうでなければ,
8221 「文字コードが {\tt'jcharbdd'} の文字」と\textit{Np}との間に入るグルー/カーンとして定まる.
8222 \end{enumerate}
8223 \end{description}
8224
8225 \paragraph{和文Aと箱・グルー・カーンの間}
8226 \textit{Nq}が\textsf{和文A}で,\textit{Np}が\textsf{箱}・グルー・カーンのいずれかであった場合,
8227 両者の間に挿入されるJFMグルーについては同じ処理である.しかし,そこでの行分割に対する仕様が異なるので,
8228 ペナルティの挿入処理は若干異なったものとなっている.
8229
8230 \begin{itemize}
8231 \item 「右空白」については,既に述べた\textsf{Boundary-B~[\OB]}により空白を決定しようと試みる.
8232 それが失敗した場合は,「右空白」は挿入されない.
8233 %\item 「左空白」については,既に述べた\textsf{line-end~[E]}の算出方法をそのまま採用する.それに伴う「右空白」の補正も同じ.
8234 \item 禁則用ペナルティの処理は,後ろのクラスタ\textit{Np}の種類によって異なる.
8235 なお,$\mathit{Np}.\mathit{head}$は無意味であるから,
8236 「$\mathit{Np}.\mathit{head}$に対する\Param{prebreakpenalty}の値」は0とみなされる.言い換えれば,
8237 \[
8238  a:=(\text{\textit{Nq}の文字に対する\Param{postbreakpenalty}の値}).
8239 \]
8240 \begin{description}
8241 \item[箱] \textit{Np}が\textsf{箱}であった場合は,両クラスタの間での行分割は
8242 (明示的に両クラスタの間に \cs{penalty10000} があった場合を除き)いつも許容される.そのため,
8243 ペナルティ処理は,後に述べる\textsf{P-allow~[PA]}が\textsf{P-normal~[PN]}の代わりに用いられる.
8244 \item[グルー] \textit{Np}がグルーの場合,ペナルティ処理は\textsf{P-normal~[PN]}を用いる.
8245 \item[カーン] \textit{Np}がカーンであった場合は,両クラスタの間での行分割は
8246 (明示的に両クラスタの間にペナルティがあった場合を除き)許容されない.
8247 ペナルティ処理は,後に述べる\textsf{P-suppress~[PS]}を使う.
8248 \end{description}
8249 これらの\textsf{P-normal~[PN]},\textsf{P-allow~[PA]},\textsf{P-suppress~[PS]}の違いは,
8250 \textit{Nq}と\textit{Np}の間(以前の図だと(a)の部分)にペナルティが存在しない場合にのみ存在する.
8251 \end{itemize}
8252
8253 \begin{description}
8254 \item[P-allow~{[PA]}]
8255 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティがあれば,\textsf{P-normal~[PN]}と同様に,
8256 それらの各ノードにおいてペナルティ値を$a$だけ増加させる.
8257
8258 (a)部分にペナルティが存在していない場合,
8259 \LuaTeX-ja は\textit{Nq}と\textit{Np}の間の行分割を可能にしようとする.
8260 そのために,以下のいずれかの場合に$a$をもつ\textit{penalty\_node}を作って
8261 「右空白」の(もし未定義なら\textit{Np}の)直前に挿入する:
8262 \begin{itemize}
8263 \item 「右空白」がグルーでない(カーンか未定義)であるとき.
8264 \item $a\neq 0$のときは,「右空白」がグルーであっても\textit{penalty\_node}を作る.
8265 \end{itemize}
8266
8267 \item[P-suppress~{[PS]}]
8268 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティがあれば,\textsf{P-normal~[PN]}と同様に,
8269 それらの各ノードにおいてペナルティ値を$a$だけ増加させる.
8270
8271 (a)部分にペナルティが存在していない場合,
8272 \textit{Nq}と\textit{Np}の間の行分割は元々不可能のはずだったのであるが,
8273 \LuaTeX-ja はそれをわざわざ行分割可能にはしない.
8274 そのため,「右空白」がglueであれば,その直前に \cs{penalty10000} を挿入する.
8275 \end{description}
8276
8277 \paragraph{箱・グルー・カーンと和文Aの間}
8278 \textit{Np}が\textsf{箱}・グルー・カーンのいずれかで,\textit{Np}が\textsf{和文A}であった場合は,
8279 すぐ上の(\textit{Nq}と\textit{Np}の順序が逆になっている)場合と同じである.
8280 %が,「左空白」がなくなることにのみ注意.
8281 \begin{itemize}
8282 \item 「右空白」については,既に述べた\textsf{Boundary-A~[\OA]}により空白を決定しようと試みる.
8283 それが失敗した場合は,「右空白」は挿入されない.
8284 %\item \textit{Nq}が和文でないので,「左空白」は算出されない.
8285 \item 禁則用ペナルティの処理は,\textit{Nq}の種類によって異なる.
8286 $\mathit{Nq}.\mathit{tail}$は無意味なので,
8287 \[
8288  a:=(\text{\textit{Np}の文字に対する\Param{prebreakpenalty}の値}).
8289 \]
8290 \begin{description}
8291 \item[箱] \textit{Nq}が\textsf{箱}の場合は,\textsf{P-allow~[PA]}を用いる.
8292 \item[グルー] \textit{Nq}がグルーの場合は,\textsf{P-normal~[PN]}を用いる.
8293 \item[カーン] \textit{Nq}がカーンの場合は,\textsf{P-suppress~[PS]}を用いる.
8294 \end{description}
8295 \end{itemize}
8296
8297 \paragraph{和文Aと和文Bの違い}
8298 先に述べたように,\textsf{和文B}はhboxの中身の先頭(or 末尾)として出現している
8299 \textbf{JAchar}である.リスト内に直接ノードとして現れている\textbf{JAchar}(\textsf{和文A})との違いは,
8300 \begin{itemize}
8301 \item \textsf{和文B}に対しては,JFMの文字クラス指定から定まる空白
8302 \textsf{JFM-origin~[M]},\textsf{Boundary-A~[\OA]},\textsf{Boundary-B~[\OB]})の挿入は行われない.
8303 %「左空白」の算出も行われない.
8304 例えば,
8305 \begin{itemize}
8306 \item 片方が\textsf{和文A},もう片方が\textsf{和文B}のクラスタの場合,
8307 \textsf{Boundary-A~[\OA]}または\textsf{Boundary-B~[\OB]}の挿入を試み,それがダメなら
8308 \Param{kanjiskip}~\textsf{[K]}の挿入を行う.
8309 \item \textsf{和文B}の2つのクラスタの間には,\Param{kanjiskip}~\textsf{[K]}が自動的に入る.
8310 \end{itemize}
8311 \item \textsf{和文B}と箱・グルー・カーンが隣接したとき(どちらが前かは関係ない),間にJFMグルー・ペナルティの挿入は一切しない.
8312 \item \textsf{和文B}と\textsf{和文B},また\textsf{和文B}と\textsf{欧文}とが隣接した時は,禁則用ペナルティ挿入処理は
8313 \textsf{P-suppress~[PS]}が用いられる.
8314 \item \textsf{和文B}の文字に対する\Param{prebreakpenalty},~\Param{postbreakpenalty}の値は使われず,0として計算される.
8315 \end{itemize}
8316
8317
8318 次が具体例である:
8319 \begin{LTXexample}
8320 あ.\inhibitglue A\\
8321 \hbox{あ.}A\\
8322 あ.A
8323 \end{LTXexample}
8324 \begin{itemize}
8325 \item 1行目の\cs{inhibitglue}は\textsf{Boundary-B~[\OB]}の処理のみを抑止するので,ピリオドと「A」の間には
8326 \Param{xkanjiskip}(四分アキ)が入ることに注意.
8327 \item 2行目のピリオドと「A」の間においては,前者が\textsf{和文B}となる(hboxの中身の末尾として登場しているから)ので,
8328 そもそも\textsf{Boundary-B~[\OB]}の処理は行われない.よって,\Param{xkanjiskip}が入ることとなる.
8329 \item 3行目では,ピリオドの属するクラスタは\textsf{和文A}である.これによって,
8330 ピリオドと「A」の間には\textsf{Boundary-B~[\OB]}由来の半角アキが入ることになる.
8331 \end{itemize}
8332 %</ja>
8333
8334 %<*ja>
8335 \section{ベースライン補正の方法}
8336 \subsection{\texttt{yoffset} フィールド}
8337 \Param{yalbaselineshift}等のベースライン補正は,基本的には対象となっている
8338 \textit{glyph\_node}の \texttt{yoffset} フィールドの値を増減することによって
8339 実装されている.なお,\texttt{yoffset} の値は上方向への移動量であるのに対し,
8340 \Param{yalbaselineshift}などは下方向への移動量である.
8341
8342 さて,\texttt{yoffset} の増減によって見かけのグリフ位置は上下に移動するが,
8343 仮想ボディの高さ$h$,深さ$d$については
8344 \begin{description}
8345 \catcode`\<=12\catcode`\>=12
8346  \item[$\texttt{yoffset}\geq 0$のとき]
8347 $h = \max(\texttt{height} + \texttt{yoffset}, 0)$,
8348 $d = \max(\texttt{depth} - \texttt{yoffset}, 0)$,
8349  \item[$\texttt{yoffset}<0$のとき]
8350 $h = \max(\texttt{height} + \texttt{yoffset}, 0)$, $d=\texttt{depth}$.
8351 \end{description}
8352 という仕様になっている.つまり,\texttt{yoffset} が負(グリフを下ける)の場合に深さは増加しな
8353 い(表\ref{tab:yoffset_and_im}参照).
8354
8355 \begin{table}[t]
8356 \caption{\texttt{yoffset} and imaginary body}
8357 \label{tab:yoffset_and_im}
8358 \centering\small
8359 \fboxsep0pt
8360 \def\T#1#2{\fcolorbox{blue}{white}{%
8361   \setbox0=\hbox{\LARGE #1%
8362     \directlua{
8363       local p = tex.nest[tex.nest.ptr].tail
8364       p.yoffset = #2 * 65536
8365     }%
8366   }%
8367   \copy0\kern-\wd0\smash{\color{red}\vrule width \wd0 height 0.2pt depth 0.2pt}%
8368 }}
8369 \begin{tabular}{>{\bfseries}lccccc}
8370 \toprule
8371 \texttt{yoffset}&10\,pt&5\,pt&0&$-5$\,pt&$-10$\,pt\\
8372 \midrule
8373 仮想ボディ&\T{y}{10}, \T{H}{10}&\T{y}{5}, \T{H}{5}&\T{y}{0}, \T{H}{0}%
8374 &\T{y}{-5}, \T{H}{-5}&\T{y}{-10}, \T{H}{-10}\\[10pt]
8375 \bottomrule
8376 \end{tabular}
8377 \end{table}
8378
8379 \subsection{\textbf{ALchar}の補正}
8380 上記の問題について,\textbf{ALchar}のベースライン補正では
8381 「正しい深さ」を持った罫線(rule)を補うという対応策をとった.
8382 この罫線による補正は,\textit{id}が\textit{id\_glyph}であるクラスタ単位,
8383 大雑把に言えば音節単位で行われる.
8384 文字列``Typeset''を
8385 \begin{itemize}
8386  \item フォントはLatin Modern Roman (\texttt{lmroman10-regular.otf}) 10\,pt
8387  \item \Param{yalbaselineshift}は5\,pt
8388 \end{itemize}
8389 という状況で組んだ場合を例にとって説明しよう.
8390
8391 \LuaTeX・\Pkg{luaotfload}によるカーニング・ハイフネーションが終わった段階では,……
8392
8393
8394
8395 %</ja>
8396
8397 %<en>\section{Patch for the \Pkg{listings} Package}
8398 %<ja>\section{\Pkg{listings} パッケージへの対応}
8399
8400 %<*en>
8401 It is well-known that the \Pkg{listings} package outputs weird results
8402 for Japanese input.
8403 The \Pkg{listings} package makes most of letters active and assigns
8404 output command for each letter~(\cite{listings}).
8405 But Japanese characters are not included in these activated letters.
8406 For \pTeX{} series, there is no method to make Japanese characters active;
8407 a patch \Pkg{jlisting.sty}~(\cite{jlisting}) resolves the problem forcibly.
8408 %</en>
8409 %<*ja>
8410 \Pkg{listings} パッケージが,そのままでは日本語をまともに出力できないこと
8411 はよく知られている.きちんと整形して出力するために,\Pkg{listings}パッケー
8412 ジは内部で「ほとんどの文字」をアクティブにし,各文字に対してその文字の出
8413 力命令を割り当てている(\cite{listings}).
8414 しかし,そこでアクティブにする文字の中に,和文文
8415 字がないためである.\pTeX 系列では,和文文字をアクティブにする手法がなく,
8416 \Pkg{jlisting.sty} というパッチ(\cite{jlisting})を用いることで無理やり解決していた.
8417 %</ja>
8418
8419 %<*en>
8420 In \LuaTeX-ja, the problem is resolved by using the \verb+process_input_buffer+ callback.
8421 The callback function inserts the output command (active character \texttt{U+FFFFF})
8422 before each letter above \texttt{U+0080}.
8423 This method can omits the process to make all Japanese characters active
8424 (most of the activated characters are not used in many cases).
8425 %</en>
8426 %<*ja>
8427 \LuaTeX-jaでは,\verb+process_input_buffer+ コールバックを利用することで,
8428 「各行に出現する\texttt{U+0080}以降の文字に対して,それらの出力命令を前置する」
8429 という方法をとっている.出力命令としては,アクティブ文字化した \texttt{U+FFFFF} を用いている.
8430 これにより,(入力には使用されていないかもしれない)和文文字をもすべてアクティブ化する手間もなく,
8431 見通しが良い実装になっている.
8432 %</ja>
8433
8434
8435 %<*en>
8436 If the \Pkg{listings} package  and \LuaTeX-ja were loaded,
8437 then the patch \Pkg{lltjp-listings} is loaded automatically at \verb+\begin{document}+.
8438 %</en>
8439 %<*ja>
8440 \LuaTeX-ja で利用される \Pkg{listings} パッケージへのパッチ \Pkg{lltjp-listings} は,
8441 \Pkg{listings} と\LuaTeX-jaを読み込んでおけば,
8442 \verb+\begin{document}+ の箇所において自動的に読み込まれるので,通常はあまり
8443 意識する必要はない.
8444 %</ja>
8445
8446 %<en>\subsection{Notes and additional keys}
8447 %<ja>\subsection{注意}
8448 %<*en>
8449 \paragraph{Escaping to \LaTeX}
8450 We used the \verb+process_input_buffer+ callback to output \textbf{JAchar}s.
8451 But it has a drawback; any commands whose name contains a \textbf{JAchar}
8452 cannot be used in any ``escape to \LaTeX''.
8453
8454 Consider the following input:
8455 %</en>
8456 %<*ja>
8457 \paragraph{\LaTeX へのエスケープ}
8458 日本語対応を行うために \verb+process_input_buffer+ を使用したことで,
8459 \texttt{texcl},~\texttt{escapeinside}といった\emph{「\LaTeX へのエスケープ」中では,
8460 \textbf{JAchar}を名称の一部に含む制御綴は使用不可能}である.
8461 例えば次のような入力を考えよう:
8462 %</ja>
8463 \begin{verbatim*}
8464 \begin{lstlisting}[escapechar=\#]
8465 #\ほげ xぴよ#
8466 \end{lstlisting}
8467 \end{verbatim*}
8468 %<en>The line~2 is transformed by the callback to
8469 %<ja>ここで,2行目は \verb+process_input_buffer+ の作用により,
8470 \begin{lstlisting}[showspaces, escapechar=\!]
8471 #\!\IVSA FFFFF!ほ!\IVSA FFFFF!げ x!\IVSA FFFFF!ぴ!\IVSA FFFFF!よ#
8472 \end{lstlisting}
8473 %<*en>
8474 before the line is actually processed.
8475 In the escape (between the character ``\verb+#+''),
8476 the category code of \texttt{U+FFFFF} is set to 9~(\emph{ignored}).
8477 Hence the control symbol ``\cs{}\IVSA FFFFF'' will be executed,
8478 instead of ``\verb+\ほげ+''.
8479 %</en>
8480 %<*ja>
8481 と変換されてから,実際の処理に回される.
8482 「\verb+#+」で挟まれた「\LaTeX へのエスケープ」中では\
8483 \texttt{U+FFFFF} のカテゴリーコードは9~(\textit{ignored})となるので,
8484 結局「\verb+\ほげ+」の代わりに
8485 「\cs{}\IVSA FFFFF」というcontrol symbolが実行されることになる.
8486 %</ja>
8487
8488 %<*en>
8489 \paragraph{Variation selectors}
8490 \Pkg{lltjp-listings} add two keys, namely \texttt{vsraw}~and~\texttt{vscmd},
8491 which specify how variation selectors are treated in
8492 \texttt{lstlisting} or other enviroments.
8493 Note that these additional keys are not usable in the preamble,
8494 since \Pkg{lltjp-listings} is loaded at \verb+\begin{document}+.
8495
8496 \texttt{vsraw} is a key which takes a boolean value, and its default value is
8497 false.
8498 \begin{itemize}
8499  \item If the \texttt{vsraw} key is true, then
8500 variation selectors are ``combined'' with the previous character.
8501 %</en>
8502 %<*ja>
8503 \paragraph{異体字セレクタの扱い}
8504 \texttt{lstlisting} 環境などの内部にある異体字セレクタを扱うため,
8505 \Pkg{lltjp-listings} では \texttt{vsraw} と \texttt{vscmd} という2つのキーを追加した.
8506 しかし,\Pkg{lltjp-listings} が実際に読み込まれるのは \verb+\begin{document}+\
8507 のところであるので,プリアンブル内ではこれらの追加キーは使用できない.
8508
8509 \texttt{vsraw}は,ブール値の値をとるキーであり,標準ではfalseである.
8510 \begin{itemize}
8511  \item trueの場合は,異体字セレクタは「直前の文字に続けて」出力される.
8512 もしもIVSサポート(\ref{ssec-ltjotf}節)が有効になっていた場合は,
8513 以下の例(左側は入力,右側はその出力)のようになる.
8514 %</ja>
8515 \begin{LTXexample}
8516 \begin{lstlisting}[vsraw=true]
8517 葛󠄀城市,葛󠄁飾区,葛西
8518 \end{lstlisting}
8519 \end{LTXexample}
8520 %<*en>
8521 \item If the \texttt{vsraw} key is false, then
8522 variation selectors are typeset by an appropriate command, which is specified by
8523       the \texttt{vscmd} key.
8524 The default setting of the \texttt{vscmd} key produces the following.
8525 %</en>
8526 %<*ja>
8527 \item falseの場合は,異体字セレクタは適当な命令によって「見える形で」出力される.
8528 どのような形で出力されるかを規定するのが \texttt{vscmd} キーであり,
8529 \Pkg{lltjp-listings} の標準設定では以下の例の右側のように出力される.
8530 %</ja>
8531 \begin{LTXexample}
8532 \begin{lstlisting}[vsraw=false,
8533    vscmd=\ltjlistingsvsstdcmd]
8534 葛󠄀城市,葛󠄁飾区,葛西
8535 \end{lstlisting}
8536 \end{LTXexample}
8537 %<ja> ちなみに,本ドキュメントでは次のようにしている:
8538 %<en> For example, the following code is the setting of the \texttt{vscmd} key in this document.
8539 \begin{lstlisting}[numbers=left]
8540 \def\IVSA#1#2#3#4#5{%
8541   \textcolor{blue}{\raisebox{3.5pt}{\tt%
8542     \fboxsep=0.5pt\fbox{\tiny \oalign{0#1#2\crcr#3#4#5\crcr}}}}%
8543 }
8544 {\catcode`\%=11
8545   \gdef\IVSB#1{\expandafter\IVSA\directlua{
8546     local cat_str = luatexbase.catcodetables['string']
8547     tex.sprint(cat_str, string.format('%X', 0xE00EF+#1))
8548 }}}
8549 \lstset{vscmd=\IVSB}
8550 \end{lstlisting}
8551 \end{itemize}
8552 %<*en>
8553 The default output command of variation selectors is stored in \verb+\ltjlistingsvsstdcmd+.
8554 %</en>
8555 %<*ja>
8556 既定の出力命令を復活させたい場合は\ \verb+vscmd=\ltjlistingsvsstdcmd+\
8557 とすれば良い.
8558 %</ja>
8559
8560 %<*en>
8561 \paragraph{The \texttt{doubleletterspace} key}
8562 Even the column format is \texttt{[c]fixed}, sometimes characters are not vertically aligned.
8563 The following example  is typeset with \texttt{basewidth=2em}, and
8564 you'll see the leftmost ``\texttt{H}'' are not vertically aligned.
8565 \begin{lstlisting}[basewidth=2em, basicstyle=\tt,numbers=left]
8566 :H:
8567 :HHHH:
8568 \end{lstlisting}
8569
8570 \Pkg{lltjp-listing} adds the \texttt{doubleletterspace} key (not activated by default, for
8571 compatibility) to
8572 improve the situation, namely doubles inter-character space in each output unit.
8573 With this key, the above input now produces better output.
8574 \begin{lstlisting}[basewidth=2em, basicstyle=\tt,numbers=left, doubleletterspace]
8575 :H:
8576 :HHHH:
8577 \end{lstlisting}
8578 %</en>
8579 %<*ja>
8580 \paragraph{\texttt{doubleletterspace}キー}
8581 \Pkg{listings}パッケージで列揃えが \texttt{[c]fixed} となっている場合でも,
8582 場合によっては文字が縦に揃わない場合もある.
8583 例を以下に示そう.これは強調するために \texttt{basewidth=2em} を設定している.
8584 \begin{lstlisting}[basewidth=2em, basicstyle=\tt,numbers=left]
8585 :H:
8586 :HHHH:
8587 \end{lstlisting}
8588 1行目と2行目の「\texttt{H}」の位置が揃っていないが,
8589 これは出力単位ごとに,先頭・末尾・各文字間に同じ量の空白を挿入することによる.
8590
8591 \Pkg{lltjp-listing}では,このような症状を改善させるために \texttt{doubleletterspace} キー
8592 を追加した(標準では互換性のために無効になっている).このキーを有効にすると,
8593 出力単位中の各文字間の空白を2倍にすることで文字を揃いやすくしている.
8594 上と同じものを \texttt{doubleletterspace} キーを有効にして組んだものが以下であり,
8595 きちんと「\texttt{H}」の位置が揃っていることが分かる.
8596 \begin{lstlisting}[basewidth=2em, basicstyle=\tt,numbers=left, doubleletterspace]
8597 :H:
8598 :HHHH:
8599 \end{lstlisting}
8600 %</ja>
8601
8602 %<en>\subsection{Class of Characters}
8603 %<ja>\subsection{文字種}
8604
8605 %<en>Roughly speaking, the \Pkg{listings} package processes input as follows:
8606 %<ja>\Pkg{listings} パッケージの内部では,大雑把に言うと
8607 \begin{enumerate}
8608 %<en>\item Collects \textit{letters} and \textit{digits}, which can be used for the name of identifiers.
8609 %<ja>\item 識別子として使える文字 (``letter'',~``digit'') たちを集める.
8610 %<en>\item When reading an \textit{other}, outputs the collected character string (with modification, if needed).
8611 %<ja>\item letterでもdigitでもない文字が現れた時に,収集した文字列を(必要なら修飾して)出力する.
8612 %<en>\item Collects \textit{others}.
8613 %<ja>\item 今度は逆に,letterでない文字たちをletterが現れるまで集める.
8614 %<en>\item When reading a \textit{letter} or a \textit{digit}, outputs the collected character string.
8615 %<ja>\item letterが出現したら集めた文字列を出力する.
8616 %<en>\item Turns back to 1.
8617 %<ja>\item 1.に戻る.
8618 \end{enumerate}
8619 %<*en>
8620 By the above process, line breaks inside of an identifier are blocked.
8621 A flag \verb+\lst@ifletter+ indicates whether the previous character can be used
8622 for the name of identifiers or not.
8623 %</en>
8624 %<*ja>
8625 という処理が行われている.これにより,識別子の途中では行分割が行われないようになっている.
8626 直前の文字が識別子として使えるか否かは \verb+\lst@ifletter+ というフラグに格納されている.
8627 %</ja>
8628
8629 %<*en>
8630 For Japanese characters, line breaks are permitted on both sides
8631 except for brackets, dashes, etc.
8632 Hence the patch \Pkg{lltjp-listings} introduces
8633 a new flag \verb+\lst@ifkanji+, which indicates
8634 whether the previous character is a Japanese character or not.
8635 For illustration, we introduce following classes of characters:
8636 %</en>
8637 %<*ja>
8638 さて,日本語の処理である.殆どの和文文字の前後では行分割が可能であるが,その一方で
8639 括弧類や音引きなどでは禁則処理が必要なことから,\Pkg{lltjp-listings} では,
8640 直前が和文文字であるかを示すフラグ \verb+\lst@ifkanji+ を新たに導入した.
8641 以降,説明のために以下のように文字を分類する:
8642 %</ja>
8643 \begin{center}
8644 \small
8645 \begin{tabular}{lccccc}
8646 \toprule
8647 &Letter&Other&Kanji&Open&Close\\\midrule
8648 \verb+\lst@ifletter+&T&F&T&F&T\\
8649 \verb+\lst@ifkanji+&F&F&T&T&F\\
8650 %<en>Meaning&char in an identifier&other alphabet&%
8651 %<en>most of Japanese char&opening brackets&closing brackets\\
8652 %<ja>意図&識別子中の文字&その他欧文文字&殆どの和文文字&開き括弧類&閉じ括弧類\\
8653 \bottomrule
8654 \end{tabular}
8655 \end{center}
8656 %<*en>
8657 Note that \textit{digits} in the \Pkg{listings} package can be Letter or
8658 Other according to circumstances.
8659 %</en>
8660 %<*ja>
8661 なお,本来の\Pkg{listings} パッケージでの分類``digit''は,
8662 出現状況によって,上の表のLetterとOtherのどちらにもなりうる.
8663 また,KanjiとCloseは \verb+\lst@ifletter+ と \verb+\lst@ifkanji+ の値が一致しているが,
8664 これは間違いではない.
8665 %</ja>
8666
8667 %<*en>
8668 For example, let us consider the case an Open comes after a Letter.
8669 Since an Open represents Japanese open brackets,
8670 it is preferred to be permitted to insert line break after the Letter.
8671 Therefore, the collected character string is output in this case.
8672 %</en>
8673 %<*ja>
8674 例えば,Letterの直後にOpenが来た場合を考える.
8675 文字種Openは和文開き括弧類を想定しているので,Letterの直後では行分割が可能であることが望ましい.
8676 そのため,この場合では,すでに収集されている文字列を出力することで行分割を許容するようにした.
8677 %</ja>
8678
8679 %<*en>
8680 The following table summarizes $5\times 5=25$ cases:
8681 %</en>
8682 %<*ja>
8683 同じように,$5\times 5=25$通り全てについて書くと,次のようになる:
8684 %</ja>
8685 \begin{center}
8686 \small
8687 \begin{tabular}{llccccc}
8688 \toprule
8689 %<*en>
8690 &&\multicolumn{4}{c}{Next}\\\cmidrule(lr){3-7}
8691 &&\hbox to 4em{\hss Letter\hss}&\hbox to 4em{\hss Other\hss}
8692 &\hbox to 4em{\hss Kanji\hss}&\hbox to 4em{\hss Open\hss}&Close\\\midrule
8693 &Letter&collects&\multicolumn{3}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
8694 &Other&outputs&collects&\multicolumn{2}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
8695 Prev&Kanji&\multicolumn{4}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
8696 &Open&\multicolumn{5}{c}{\hrulefill \ collects\ \hrulefill}\\
8697 &Close&\multicolumn{4}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
8698 %</en>
8699 %<*ja>
8700 &&\multicolumn{4}{c}{後ろ側の文字}\\\cmidrule(lr){3-7}
8701 &&\hbox to 4em{\hss Letter\hss}&\hbox to 4em{\hss Other\hss}
8702 &\hbox to 4em{\hss Kanji\hss}&\hbox to 4em{\hss Open\hss}&Close\\\midrule
8703 直&Letter&収集&\multicolumn{3}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
8704 前&Other&出力&収集&\multicolumn{2}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
8705 文&Kanji&\multicolumn{4}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
8706 字&Open&\multicolumn{5}{c}{\hrulefill \ 収集\ \hrulefill}\\
8707 種&Close&\multicolumn{4}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
8708 %</ja>
8709 \bottomrule
8710 \end{tabular}
8711 \end{center}
8712 %<en>In the above table,
8713 %<ja>上の表において,
8714 \begin{itemize}
8715 %<en>\item ``outputs'' means to output the collected character string (i.e., line breaking is permitted there).
8716 %<ja>\item 「出力」は,それまでに集めた文字列を出力(≒ここで行分割可能)を意味する.
8717
8718 %<en>\item ``collects'' means to append the next character to the collected character string (i.e., line breaking is prohibited there).
8719 %<ja>\item 「収集」は,後側の文字を,現在収集された文字列に追加(行分割不可)を意味する.
8720 \end{itemize}
8721
8722 %<*en>
8723 Characters above or equal to~\texttt{U+0080} \emph{except Variation Selectors}
8724 are classified into above 5~classes by the following rules:
8725 %</en>
8726 %<*ja>
8727 \texttt{U+0080}以降の\emph{異体字セレクタ以外の}各文字が
8728 Letter, Other, Kanji, Open, Closeのどれに属するかは次によって決まる:
8729 %</ja>
8730 \begin{itemize}
8731 %<en>\item \textbf{ALchar}s above or equal to~\texttt{U+0080} are classified as Letter.
8732 %<ja>\item (\texttt{U+0080}以降の)\textbf{ALchar}は,すべてLetter扱いである.
8733
8734 %<en>\item \textbf{JAchar}s are classified in the order as follows:
8735 %<ja>\item \textbf{JAchar}については,以下の順序に従って文字種を決める:
8736 \begin{enumerate}
8737 %<en>\item Characters whose \Param{prebreakpenalty} is greater than or equal to 0 are classified as Open.
8738 %<ja>\item \Param{prebreakpenalty}が0以上の文字はOpen扱いである.
8739
8740 %<en>\item Characters whose \Param{postbreakpenalty} is greater than or equal to 0 are classified as Close.
8741 %<ja>\item \Param{postbreakpenalty}が0以上の文字はClose扱いである.
8742
8743 %<en>\item Characters that don't satisfy the above two conditions are classified as Kanji.
8744 %<ja>\item 上の3条件のどちらにも当てはまらなかった文字は,Kanji扱いである.
8745 \end{enumerate}
8746 \end{itemize}
8747
8748 %<*en>
8749 The width of halfwidth kana (\texttt{U+FF61}--\texttt{U+FF9F})
8750 is same as the width of \textbf{ALchar};
8751 the width of the other \textbf{JAchar}s is double the width of \textbf{ALchar}.
8752 %</en>
8753 %<*ja>
8754 なお,半角カナ(U+FF61--U+FF9F)以外の\textbf{JAchar}は欧文文字2文字分の幅をとるものとみなされる.
8755 半角カナは欧文文字1文字分の幅となる.
8756 %</ja>
8757
8758 %<*en>
8759 This classification process is executed every time a character appears in
8760 the \texttt{lstlisting} environment or other environments/commands.
8761 %</en>
8762 %<*ja>
8763 これらの文字種決定は,実際に \texttt{lstlisting} 環境などの内部で文字が出てくるたびに行われる.
8764 %</ja>
8765
8766 %<*ja>
8767 \section{和文の行長補正方法}
8768 \label{sec-adjspec}
8769 \Pkg{luatexja-adjust} で提供される優先順位付きの行長調整の詳細を述
8770 べる.大まかに述べると,次のようになる.
8771 \begin{itemize}
8772 \item 通常の\TeX の行分割方法に従って,段落を行分割する.この段階では,行
8773       長に半端が出た場合,その半端分は\textbf{JAglue}(\Param{xkanjiskip},
8774       \Param{kanjiskip},JFMグルー)と
8775       それ以外のグルーの全てで(優先順位なく)負担される.
8776 \item その後,\texttt{post\_linebreak\_filter} callbackを使い,\emph{段
8777       落中の各行ごとに},行末文字の位置を調整したり,優先度付きの行長調整
8778       を実現するためにグルーの伸縮度を調整する.
8779       その処理においては,グルーの自然長と\textbf{JAglue}以外の
8780       グルーの伸び量・縮み量は変更せず,必要に応じて\textbf{JAglue}の伸び量・縮み量のみを
8781       変更する設計とした.
8782
8783 \Pkg{luatexja-adjust} の作用は,この処理を行うcallbackを追加するだけであり,
8784       この章の残りではcallbackでの処理について解説する.
8785 \end{itemize}
8786
8787 \paragraph{準備:合計伸縮量の計算}
8788 グルーの伸縮度(\texttt{plus} や \texttt{minus} で指定されている値)には,
8789 有限値の他に,\texttt{fi},\texttt{fil},\texttt{fill},\texttt{filll}と
8790 いう4つの無限大レベル(後ろの方ほど大きい)があり,行の調整に
8791 \texttt{fi} などの\emph{無限大レベルの伸縮度が用いられている場合は,そ
8792 の行に対しての処理を中止}する.
8793
8794 よって,以降,問題にしている行の行長調整は伸縮度が有限長のグルーを用いて
8795 行われているとして良い.さらに,簡単のため,この行はグルーが広げられている
8796 (自然長で組むと望ましい行長よりの短い)場合しか扱わない.
8797
8798 まず,段落中の行中のグルーを
8799 \begin{itemize}
8800 \item \textbf{JAglue}ではないグルー
8801 \item JFMグルー(優先度\footnote{%
8802   \ref{ssec-jfm-str}節にあるように,
8803   各JFMグルーには$-2$から2までの優先度がついている.}%
8804 別にまとめられる)
8805 \item 和欧文間空白(\Param{xkanjiskip})
8806 \item 和文間空白(\Param{kanjiskip})
8807 \end{itemize}
8808 の$1+1+5+1=8$つに類別し,それぞれの種別ごとに
8809 許容されている伸び量(\texttt{stretch}の値)の合計を計算する.
8810 また,行長と自然長との差を\textit{total}とおく.
8811
8812
8813 \subsection{行末文字の位置調整}
8814 行末が文字クラス$n$の\textbf{JAchar}であった場合,
8815 それを動かすことによって,\textit{total}のうち
8816 \textbf{JAglue}が負担する分を少なくしようとする.
8817 この行末文字の左右の移動可能量は,
8818 JFM中にある文字クラス$n$の定義の
8819 \texttt{end\_stretch},~\texttt{end\_shrink}フィールドに
8820 全角単位の値として記述されている.
8821
8822 例えば,行末文字が句点「。」であり,そこで用いられているJFM中に
8823 \begin{lstlisting}
8824   [2] = {
8825     chars = { '。', ... }, width = 0.5, ...,
8826     end_stretch = 0.5, end_shrink = 0.5,
8827   },
8828 \end{lstlisting}
8829 という指定があった場合,この行末の句点は
8830 \begin{itemize}
8831 \item 通常の\TeX の行分割処理で「半角以上の詰め」が行われていた場合,
8832 この行中の\textbf{JAglue}の負担を軽減するため,
8833 行末の句点を半角だけ右に移動する(ぶら下げ組を行う).
8834 \item 通常の\TeX の行分割処理で「半角以上の空き」が行われていた場合,
8835 逆に行末句点を半角左に移動させる(見た目的に全角取りとなる).
8836 \item 以上のどちらでもない場合,行末句点の位置調整は行わない.
8837 \end{itemize}
8838 となる.
8839
8840 行末文字を移動した場合,その分だけ\textit{total}の値を引いておく.
8841
8842 \subsection{グルーの調整}
8843 \textit{total}の分だけが,行中のグルーの伸び量に応じて負担されることになる.
8844 負担するグルーの優先度は以下の順であり,
8845 できるだけ\Param{kanjiskip}を自然長のままにすることを
8846 試みている.
8847 \begin{enumerate}\def\labelenumi{(\Alph{enumi})}
8848  \item \textbf{JAglue}以外のグルー
8849  \item 優先度2のJFMグルー
8850  \item 優先度1のJFMグルー
8851  \item 優先度0のJFMグルー
8852  \item 優先度$-1$のJFMグルー
8853  \item 優先度$-2$のJFMグルー
8854  \item \Param{xkanjiskip}
8855  \item \Param{kanjiskip}
8856 \end{enumerate}
8857 \begin{enumerate}
8858  \item 行末の\textbf{JAchar}を移動したことで$\textit{total}=0$となれば,
8859 調整の必要はなく,行が格納されているhboxの
8860 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算すればよい.
8861 以降,$\textit{total}\neq 0$と仮定する.
8862  \item \textit{total}が「\textbf{JAglue}以外のグルーの伸び量の合計」(以下,(A)の伸び量の
8863        合計,と称す)よりも小さければ,
8864 それらのグルーに\textit{total}を負担させ,\textbf{JAglue}達自身は自然長で組むことができる.
8865 よって,以下の処理を行う:
8866 \begin{enumerate}
8867 \item 各\textbf{JAglue}の伸び量を0とする.
8868 \item 行が格納されているhboxの
8869 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算する.
8870 これによって,\textit{total}は\textbf{JAglue}以外のグルーによって負担される.
8871 \end{enumerate}
8872 \item \textit{total}が「(A)の伸び量の合計」以上ならば,(A)--(H)のどこまで負担すれば
8873 \textit{total}以上になるかを計算する.
8874 例えば,
8875 \[\catcode`\<=12
8876  \textit{total} = (\text{(A)--(B)の伸び量の合計}) + p\cdot (\text{(C)の伸び量の合計}),
8877  \qquad 0\le p<1
8878 \]
8879 であった場合,各グルーは次のように組まれる:
8880 \begin{itemize}
8881  \item (A),~(B)に属するグルーは各グルーで許された伸び量まで伸ばす.
8882  \item (C)に属するグルーはそれぞれ$p\times (\text{伸び量})$だけ伸びる.
8883  \item (D)--(H)に属するグルーは自然長のまま.
8884 \end{itemize}
8885 実際には,前に述べた「設計」に従い,次のように処理している:
8886 \begin{enumerate}
8887 \item (C)に属するグルーの伸び量を$p$倍する.
8888 \item (D)--(H)に属するグルーの伸び量を0とする.
8889 \item 行が格納されているhboxの
8890 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算する.
8891 これによって,\textit{total}は\textbf{JAglue}以外のグルーによって負担される.
8892 \end{enumerate}
8893 \item \textit{total}が(A)--(H)の伸び量の合計よりも大きい場合,どうしようもないので
8894       \verb+^^;+何もしない.
8895 \end{enumerate}
8896
8897 %</ja>
8898
8899 %<*ja>
8900 \section{IVS対応}
8901 \verb+luatexja.otf.enable_ivs()+ を実行し,IVS対応を有効にした状態では,
8902 \verb+pre_linebreak_filter+ や \verb+hpack_filter+ コールバックには
8903 次の4つが順に実行される状態となっている:
8904 \begin{description}
8905 \item[\tt ltj.do\_ivs] \textit{glyph\_node}~$p$の直後に,異体字セレクタ(を表す\textit{glyph\_node})
8906 が連続した場合に,$p$のフォントに対応したが持つ「異体字情報」に従って出力するグリフを変える.
8907
8908 しかし,単に$p.\textit{char}$を変更するだけでは,後から
8909 font featureの適用(すぐ下)により置換される可能性がある.そのため,
8910 \cs{CID} や \cs{UTF} と同じように,\textit{glyph\_node}~$p$の代わりに
8911 \texttt{user\_id} が\textit{char\_by\_cid}であるようなuser-defined whatsitを用いている.
8912 \item[(\Pkg{luaotfload} によるfont featureの適用)]
8913 \item[\tt ltj.otf] \texttt{user\_id} が\textit{char\_by\_cid}であるようなuser-defined whatsitを
8914 きちんと\textit{glyph\_node}に変換する.この処理は,\cs{CID}, \cs{UTF}やIVSによる置換が,
8915 font featureの適用で上書きされてしまうのを防止するためである.
8916 \item[\tt ltj.main\_process] \textbf{JAglue}の挿入処理(\ref{sec-jfmglue}章)と,
8917 JFMの指定に従って各\textbf{JAchar}の「寸法を補正」することを行う.
8918 \end{description}
8919
8920 問題は各フォントの持っているIVS情報をどのように取得するか,である.
8921 \Pkg{luaotfload} はフォント番号<font\_number>の情報を\
8922 \texttt{fonts.hashes.identifiers[<font\_number>]} 以下に格納している.
8923 しかし,OpenTypeフォントのIVS情報は格納されていないようである%
8924 \footnote{TrueTypeフォントに関しては,
8925 \begin{center}
8926 \texttt{fonts.hashes.idenfiers[<font\_number>]%
8927   .resources.variants[<selector>][<base\_char>]}
8928 \end{center}
8929 に,<base\_char>番の文字の後に異体字セレクタ<selector>が続いた場合に
8930 出力すべきグリフが書かれてある.}.
8931 %例えば,小塚明朝Pr6N~Rでは,
8932
8933 一方,\LuaTeX 内部の \texttt{fontloader} の返すテーブルには
8934 OpenTypeフォントでもTrueTypeフォントでもIVS情報が格納されている.
8935 具体的には……
8936
8937 そのため,\LuaTeX-jaのIVS対応においては,\LuaTeX 内部の\
8938 \texttt{fontloader} を直接用いることで,フォントのIVS情報を取得している.
8939 20140114.0以降でキャッシュを用いるようにした要因はここにあり,
8940 \texttt{fontloader} の呼び出しでかなり時間を消費することから,
8941 %%% to_table を使わなくしたことで,メモリ使用量は減った
8942 IVS情報をキャッシュに保存することで2回目以降の実行時間を節約している.
8943 %</ja>
8944
8945
8946 %<*ja>
8947 \section{複数フォントの「合成」(未完)}
8948 \section{\LuaTeX-jaにおけるキャッシュ}
8949 \Pkg{luaotfload}パッケージが,各TrueType・OpenTypeフォントの情報を
8950 キャッシュとして保存しているのと同様の方法で,
8951 \LuaTeX-jaもいくつかのキャッシュファイルを作成するようになった.
8952 \begin{itemize}
8953  \item 通常,キャッシュは\texttt{\$TEXMFVAR/luatexja/}以下に保存され,
8954 そこから読み込みが行われる.
8955  \item 「通常の」テキスト形式のキャッシュ(拡張子は \texttt{.lua})以外にも,
8956 それをバイナリ形式(バイトコード)に変換したものもサポートしている.
8957 \begin{itemize}
8958  \item \LuaTeX とLuaJIT\TeX ではバイトコードの形式が異なるため,バイナリ形式の
8959 キャッシュは共有できない.\LuaTeX 用のバイナリキャッシュは \texttt{.luc},
8960 LuaJIT\TeX 用のは \texttt{.lub} と拡張子を変えることで対応している.
8961  \item キャッシュを読み込む時,同名のバイナリキャッシュがあれば,
8962 テキスト形式のものよりそちらを優先して読み込む.
8963  \item テキスト形式のキャッシュが更新/作成される際は,そのバイナリ版も
8964 同時に更新される.
8965 また,(バイナリ版が見つからず)テキスト形式のキャッシュ側が読み込まれたときは,
8966 \LuaTeX-jaはバイナリキャッシュを作成する.
8967 \end{itemize}
8968 \end{itemize}
8969 %</ja>
8970 %<*en>
8971 \section{Cache Management of \LuaTeX-ja}
8972 \LuaTeX-ja creates some cache files to reduce the loading time.
8973 in a similar way to the \Pkg{luaotfload} package:
8974 \begin{itemize}
8975  \item Cache files are usually stored in (and loaded from)
8976 \texttt{\$TEXMFVAR/luatexja/}.
8977  \item In addition to caches of the text form (the extension is ``\texttt{.lua}''),
8978 caches of the \emph{binary}, precompiled form are supported.
8979 \begin{itemize}
8980  \item We cannot share same binary cache for \LuaTeX\ and LuaJIT\TeX.
8981 Hence we distinguish them by their extension, ``\texttt{.luc}'' for \LuaTeX\
8982 and ``\texttt{.lub}'' for LuaJIT\TeX.
8983  \item In loading a cache, the binary cache precedes
8984 the text form.
8985  \item When \LuaTeX-ja updates a cache \texttt{hoge.lua},
8986 its binary version is also updated.
8987 \end{itemize}
8988 \end{itemize}
8989 %</en>
8990
8991 %<*ja>
8992 \subsection{キャッシュの使用箇所}
8993
8994 \LuaTeX-ja では以下の3種類のキャッシュを使用している:
8995 \begin{cslist}
8996 \item[ltj-cid-auto-adobe-japan1.lua]
8997 Ryumin-Lightのような非埋め込みフォントの情報を格納しており,
8998 (それらが\LuaTeX-jaの標準和文フォントなので)\LuaTeX-jaの読み込み時に自動で読まれる.
8999 生成には\texttt{UniJIS2004-UTF32-\{H, V\}}, \texttt{Adobe-Japan1-UCS2}という3つの
9000 CMapが必要である.
9001
9002 \pageref{para-cid}ページで述べたように,\texttt{cid}キーを使って
9003 非埋め込みの中国語・韓国語フォントを定義する場合,同様のキャッシュが生成される.
9004 キャッシュの名称,必要となるCMapについては表\ref{tab:cid-cache}を参照して欲しい.
9005
9006 \item[extra\_***.lua]
9007 フォント``\texttt{***}''における異体字セレクタの情報,縦組用字形への変換テーブル,そして
9008 縦組時における幅を格納している.構造は以下の通り:
9009 %</ja>
9010 %<*en>
9011 \subsection{Use of Cache}
9012
9013 \LuaTeX-ja uses the following cache:
9014 \begin{cslist}
9015 \item[ltj-cid-auto-adobe-japan1.lua]
9016 The font table of a CID-keyed non-embedded Japanese font.
9017 This is loaded in every run.
9018 It is created from three CMaps, \texttt{UniJIS2004-UTF32-\{H,V\}} and
9019              \texttt{Adobe-Japan1-UCS2},
9020 and this is why these two CMaps are needed in the first run of \LuaTeX-ja.
9021
9022 Similar caches are created as Table~\ref{tab:cid-cache},
9023 if you specified \texttt{cid} key in \cs{jfont}
9024 to use other CID-keyed non-embedded fonts for Chinese or Korean,
9025 as in Page~\pageref{para-cid}.
9026
9027 \item[extra\_***.lua]
9028 This file stores the table which stores the following.
9029 \begin{itemize}
9030  \item unicode variants in a font ``\texttt{***}''
9031  \item vertical width of glyphs, if it is not equal to the sum of
9032 the height of ascender and the depth of descender
9033  \item vertical variants
9034 \end{itemize}
9035 The following is the structure of the that table.
9036 %</en>
9037
9038 \begin{table}[!tb]
9039  \centering\small
9040 \caption{\texttt{cid} key and corresponding files}
9041 \label{tab:cid-cache}
9042 \vspace*{\medskipamount}
9043 \begin{tabular}{>{\tt}l>{\tt}l>{\tt}l>{\tt}l}
9044 \toprule
9045 \bf \texttt{cid} key&\bf name of the cache &
9046 \multicolumn{2}{c}{\bf used CMaps}\\
9047 \midrule
9048 Adobe-Japan1-*&ltj-cid-auto-adobe-japan1.lua&UniJIS2004-UTF32-*&Adobe-Japan1-UCS2\\
9049 Adobe-Korea1-*&ltj-cid-auto-adobe-korea1.lua&UniKS-UTF32-*&Adobe-Korea1-UCS2\\
9050 Adobe-GB1-*&ltj-cid-auto-adobe-gb1.lua&UniGB-UTF32-*&Adobe-GB1-UCS2\\
9051 Adobe-CNS1-*&ltj-cid-auto-adobe-cns1.lua&UniCNS-UTF32-*&Adobe-CNS1-UCS2\\
9052 \bottomrule
9053 \end{tabular}
9054 \end{table}
9055
9056 \begin{lstlisting}
9057 return {
9058  {
9059   [10955]={    -- U+2ACB "Subset Of Above Not Equal To"
9060    [65024]=983879, -- <2ACB FE00>
9061    ["vwidth"]=0.98, -- vertical width
9062   },
9063   [37001]={    -- U+9089 "邉"
9064    [0]=37001,  --   <9089 E0100>
9065    991049,     --   <9089 E0101>
9066    ...
9067    ["vert"]=995025, -- vertical variant
9068   },
9069   ...
9070  },
9071  ["chksum"]="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", -- checksum of the fontfile
9072  ["version"]=2, -- version of the cache
9073 }
9074 \end{lstlisting}
9075 %<*ja>
9076 \item[ltj-jisx0208.\{luc|lub\}]
9077 \LuaTeX-ja配布中の\texttt{ltj-jisx0208.lua}をバイナリ化したものである.
9078 これはJIS~X~0208とUnicodeとの変換テーブルであり,
9079 \pTeX との互換目的の文字コード変換命令で用いられる.
9080 %</ja>
9081 %<*en>
9082 \item[ltj-jisx0208.\{luc|lub\}]
9083 The binary version of \texttt{ltj-jisx0208.lua}.
9084 This is the conversion table between JIS~X~0208 and Unicode
9085 which is used in Kanji-code conversion commands for compatibility with \pTeX.
9086 %</en>
9087 \end{cslist}
9088
9089 %<*en>
9090 \subsection{Internal}
9091 Cache management system of \LuaTeX-ja is stored in \texttt{luatexja.base}
9092 (\texttt{ltj-base.lua}).
9093 There are three public functions for cache management in \texttt{luatexja.base},
9094 where <filename> stands for the file name \emph{without suffix}:
9095 \begin{cslist}
9096 \item[save\_cache(<filename>, <data>)]
9097 Save a non-nil table <data> into a cache <filename>.
9098 Both the text form <filename>\texttt{.lua} and its binary version
9099 are created or updated.
9100
9101 \item[save\_cache\_luc(<filename>, <data>{[, <serialized\_data>]})]
9102
9103 Same as \texttt{save\_cache}, except that only the binary cache is updated.
9104 The third argument <serialized\_data> is not usually given.
9105 But if this is given, it is treated as a string representation of <data>.
9106
9107 \item[load\_cache(<filename>, <outdate>)]
9108 Load the cache <filename>.
9109 <outdate> is a function which takes one argument (the contents of the cache),
9110 and its return value is whether the cache is outdated.
9111
9112 \texttt{load\_cache} first tries to
9113 read the binary cache <filename>\texttt{.\{luc|lub\}}.
9114 If its contents is up-to-date, \texttt{load\_cache} returns the contents.
9115 If the binary cache is not found or
9116 its contents is outdated, \texttt{load\_cache} tries to
9117 read the text form <filename>\texttt{.lua}.
9118 Hence, the return value of \texttt{load\_cache} is non-nil,
9119 if and only if the updated cache is found.
9120 \end{cslist}
9121 %</en>
9122 %<*ja>
9123 \subsection{内部命令}
9124 \LuaTeX-jaにおけるキャッシュ管理は,\texttt{luatexja.base}~(\texttt{ltj-base.lua})に
9125 実装しており,以下の3関数が公開されている.
9126 ここで,<filename>は保存するキャッシュのファイル名を\emph{拡張子なしで}指定する.
9127 \begin{cslist}
9128 \item[save\_cache(<filename>, <data>)]
9129 nilでない<data>をキャッシュ<filename>に保存する.
9130 テキスト形式の<filename>\texttt{.lua}のみならず,
9131 そのバイナリ版も作成/更新される.
9132
9133 \item[save\_cache\_luc(<filename>, <data>{[, <serialized\_data>]})]
9134
9135 \texttt{save\_cache}と同様だが,バイナリキャッシュのみが更新される.
9136 第3引数<serialized\_data>が与えられた場合,それを
9137 <data>の文字列化表現として使用する.
9138 そのため,<serialized\_data>は普通は指定しないことになるだろう.
9139
9140 \item[load\_cache(<filename>, <outdate>)]
9141 キャッシュ<filename>を読み込む.
9142 <outdate>は1引数(キャッシュの中身)をとる関数であり,
9143 その戻り値は「キャッシュの更新が必要」かどうかを示すブール値でないといけない.
9144
9145 \texttt{load\_cache}は,まずバイナリキャッシュ<filename>\texttt{.\{luc|lub\}}を
9146 読みこむ.もしその内容が「新しい」,つまり<outdate>の評価結果が \texttt{false} なら
9147 \texttt{load\_cache}はこのバイナリキャッシュの中身を返す.
9148 もしバイナリキャッシュが見つからなかったか,「古すぎる」ならばテキスト版
9149              <filename>\texttt{.lua}を読み込み,その値を返す.
9150
9151 以上より,\texttt{load\_cache}自体がnilでない値を返すのは,ちょうど「新しい」キャッシュが
9152 見つかった場合である.
9153 \end{cslist}
9154 %</ja>
9155
9156
9157 %<*ja>
9158 \section{縦組の実装}
9159 \label{sec-dir-imp}
9160 \ref{sec-direction}章の最初でも述べたように,
9161 \LuaTeX-jaは横組(\texttt{TLT})で組んだボックスを回転させる方式で
9162 縦組を実装している.
9163
9164 \LuaTeX-jaにおける縦組の実装は
9165 \pTeX における実装(\cite{ptexdoc,ptextug})をベースにしている.
9166
9167 \subsection{direction~whatsit}
9168 \textit{direction}~whatsitとは,\textit{direction}という特定の \verb+user_id+ を持つ
9169 whatsitのことであり,以下のタイミングで作られる.
9170 \begin{itemize}
9171  \item 組方向を \cs{tate} 等で変更したとき.
9172  \item \cs{hbox}, \cs{vbox}, \cs{vtop} による明示的なボックスの開始時.\\
9173 \verb+\hbox{}+, \verb+\vbox{}+ といった,
9174 \begin{itemize}
9175  \item \cs{tate} 等によりボックス内部の組方向を変更していない
9176  \item ボックスの中身のリストが空である
9177 \end{itemize}
9178 場合は,\LuaTeX の \verb+hpack_filter+, \verb+vpack_filter+ といった
9179 callbackに処理が回らない.そこで,\LuaTeX-ja では,\cs{everyhbox}, \cs{everyvbox} を利用す
9180        ることで各ボックスの先頭に確実に追加するようにしている\footnote{%
9181   問題は \cs{hbox to 25pt\{\}} という状況である.実際のこのボックスの中身は空でない(少な
9182        くともdirection whatsitがある)ため,何も対策をしなければhpack時にUnderfill警告が発
9183        生してしまうことになる.\LuaTeX-jaではそうならないように「\cs{hbadness},
9184        \cs{vbadness} を一時的に10000に変更し,hpack, vpack後に元の値に戻す」処理を行ってい
9185        る.
9186 }.
9187  \item \cs{vsplit}によってvboxを分割した時の「残り」の先頭.
9188  \item \LuaTeX-ja読み込み前に作成したボックスの寸法を \cs{ltjsetwd} 等によって変更した時.
9189  \item \cs{insert} によるinsertionでは,中身の先頭に\textit{direction}~whatsitは作られず,
9190 その代わりに中身の各ボックス・罫線の直前に作られる\footnote{%
9191  これは,ページ分割の過程でinsertionが分割される時,「現在のページで出力される部分」が空と
9192        なることがあることによる.先頭にwhatsitを置くと,最悪でも「現在のページにwhatsitが
9193        残る」ことになってしまう.}.
9194 \end{itemize}
9195 なお,\verb+\vtop{...}+ の場合は,先頭にdirection whatsitを置くと
9196 ボックスの高さが常に0\,ptになるという問題が発生する.そのため,この場合に限っては
9197 vpack時にdirection whatsitをリストの2番目に移動させている.
9198
9199 direction whatsitはあくまでも組方向処理のための補助的なノードであるので,
9200 \cs{unhbox}, \cs{unhcopy} によってボックスの中身が展開される時には展開直前に削除される.
9201 これは
9202 \begin{lstlisting}
9203  % yoko direction
9204 \setbox0=\hbox{\tate B}
9205 \noindent % 水平モードに入る.この時点でのリストの中身は空
9206 \unhbox0 A
9207 \end{lstlisting}
9208 といった場合に,段落が縦組で組まれたり,あるいは
9209 \begin{lstlisting}
9210 \setbox0=\hbox{}
9211 \leavevmode \hbox{A}\unhbox0
9212 \setbox1=\lastbox % \box1 はどうなる?
9213 \end{lstlisting}
9214 で \cs{box1} が \cs{hbox\{A\}} でなく空になってしまうことを防ぐためである.
9215
9216
9217 \subsection{\textit{dir\_box}}
9218 縦中横など異方向のボックスを配置する場合に,周囲の組方向と大きさを整合させるため,
9219 \LuaTeX-jaでは \verb+\ltj@dir+ が128以降の\textit{hlist\_node}, \textit{vlist\_node}を
9220 用いる.これらは\pTeX における\textit{dir\_node}の役割と同じ果たしており,
9221 この文章中では\textit{dir\_box}と呼称する.
9222
9223 \subsubsection{異方向のボックスの整合}
9224 \textit{dir\_box}の第一の使用目的は,異方向のボックスの大きさを整合させることである.
9225 例えば,
9226 \begin{lstlisting}
9227  % yoko direction
9228 平成\hbox{\tate 26}年
9229 \end{lstlisting}
9230 は段落中で
9231 \[
9232  \xymatrix{
9233    {}\Node{glyph}{`平'}\ar[r]&{}\Node{glyph}{`成'}\ar[r]&
9234    {}\HNode{hbox}{10.00003}{3.02779}{0.0}\ar[r]\ar[d]^{\text{中身}}&{}\Node{glyph}{`年'}\\
9235    &&{}\Node{whatsit}{\cs{tate}}\ar[r]&{}\Node{glyph}{`2'}\ar[r]&{}\Node{glyph}{`6'}
9236  }
9237 \]
9238 というリストを作る.その後,この段落が終了したときに,
9239 \LuaTeX-jaの\textbf{JAglue}挿入処理が行われ
9240 \[
9241  \xymatrix{
9242    {}\Node{glyph}{`平'}\ar[r]
9243   &{}\textcolor{blue}{\Node{glue}{\Param{xkanjiskip}}}\ar[r]
9244   &{}\Node{glyph}{`成'}\ar[r]
9245   &{}\textcolor{blue}{\Node{penalty}{0}}
9246     \ar`r[d] `[l] `[ddll] `[dl] [dl]
9247   \\
9248   &&{}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{yoko})}{3.02779}{10.00003}{0.0}}\ar[r]\ar[d]^{\text{中身}}
9249   &{}\textcolor{blue}{\Node{penalty}{0}}\ar[r]
9250   &{}\Node{glyph}{`年'}\\
9251   &&{}\HNode{hbox}{10.00003}{3.02779}{0.0}\ar[d]^{\text{中身}}\\
9252   &&{}\Node{whatsit}{\cs{tate}}\ar[r]&{}\Node{glyph}{`2'}\ar[r]&{}\Node{glyph}{`6'}
9253  }
9254 \]
9255 のようになる(青字は\textbf{JAglue},赤字が整合処理のための\textit{dir\_box}である).
9256 \TeX の \cs{showbox} 形式で書けば
9257
9258 \medskip{\narrowbaselines\ttfamily\obeylines\parindent0pt
9259 \catcode`\@=0 @catcode`@\=12
9260 .\tenmin 平
9261 @textcolor{blue}{.\glue 0.0 plus 0.4 minus 0.4}
9262 .\tenmin 成
9263 @textcolor{blue}{.\penalty 0}
9264 @textcolor{red}{.\hbox(10.00003+0.0)x3.02779, direction TLT}
9265 ..\hbox(3.02779+0.0)x10.00003, direction TLT
9266 ...\whatsit4=[]
9267 ...\tenrm 2
9268 ...\tenrm 6
9269 @textcolor{blue}{.\penalty 0}
9270 .\tenmin 年
9271 }\medskip
9272
9273 \noindent である.
9274
9275 なお,\cs{raise},~\cs{lower}, \cs{moveleft},~\cs{moveright} といったボックス移動命令では.
9276 移動を正しく表現するために段落やボックスの途中でも異方向のボックスは\textit{dir\_box}にカ
9277 プセル化している.
9278 例えば
9279 \begin{lstlisting}
9280  % yoko direction
9281 平成\raise1pt\hbox{\tate 26}年\showlists
9282 \end{lstlisting}
9283 は以下のような結果を得る.
9284
9285 \medskip{\narrowbaselines\ttfamily\obeylines\parindent0pt
9286 \catcode`\@=0 @catcode`@\=12
9287 (前略)
9288 \tenrm 平
9289 \tenrm 成
9290 @textcolor{red}{\hbox(10.00003+0.0)x3.02779, shifted -1.0, direction TLT}
9291 .\hbox(3.02779+0.0)x10.00003, direction TLT
9292 ..\whatsit4=[]
9293 ..\tenrm 2
9294 ..\tenrm 6
9295 \tenrm 年
9296 }\medskip
9297
9298 また,メインの垂直リストに異方向のボックスが追加される場合にも同様に即座に
9299 \textit{dir\_box}にカプセル化している.ページ分割のタイミングを正
9300 しく\TeX が判断するためである.
9301 \cs{lastbox} によるボックスの取得では,\textit{dir\_box}は削除される.
9302
9303 \subsubsection{異方向のボックス寸法の格納}
9304 第二の使用目的は,現在の組方向がボックス本来の組方向とは異なる状況で,
9305 \cs{ltjsetwd} によってボックス寸法を設定されたことを記録することである.
9306
9307 例えば
9308 \begin{lstlisting}[numbers=left]
9309 \setbox0=\hbox{\vrule width 10pt height 5pt depth 2pt}
9310 \setbox1=\hbox{\tate\ltjsetwd0=20pt}
9311 \wd0=9pt
9312 \setbox1=\hbox{\dtou\ltjsetwd0=20pt}
9313 \setbox0=\hbox{\dtou a\box0}
9314 \end{lstlisting}
9315 というコードを考える.1行目で \cs{box0} には横組の
9316 幅10\,pt,高さ5\,pt,深さ2\,ptのボックスが代入される.
9317 よって,
9318 \begin{itemize}
9319  \item 縦組下では \cs{box0} は幅7\,pt,高さ・深さ5\,ptのボックスとして扱われる.
9320  \item \cs{dtou} 下では \cs{box0} は幅7\,pt,高さ10\,pt,深さ0\,ptのボックスとして扱われる.
9321 \end{itemize}
9322 このとき,\cs{box0} の\emph{中身}は
9323 \[
9324  \xymatrix{
9325    {}\Node{whatsit}{\cs{yoko}}\ar[r]&{}\Node{rule}{}
9326  }
9327 \]
9328 である.
9329
9330 さて,2行目で縦組時の \cs{box0} の幅が20\,ptに設定される.この情報が
9331 direction~whatsit内部のノードリストに,\textit{dir\_box}として格納される:
9332 \[
9333  \xymatrix{
9334    {}\Node{whatsit}{\cs{yoko}}\ar[r]\ar[d]_{\text{中身}}&{}\Node{rule}{}\\
9335    {}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{tate})}{20.0}{5.0}{5.0}}
9336  }
9337 \]
9338
9339 次に,3行目では横組時の,つまり \cs{box0} 本来の組方向での深さが9\,ptに変更される.
9340 このとき,\cs{box0} は
9341 \begin{itemize}
9342  \item 縦組下では寸法代入が既に行われているので,2行目で作成された\textit{dir\_box}の通り
9343        に幅20\,pt,高さ・深さ5\,ptのボックスとして扱われる.
9344  \item \cs{dtou} 下ではまだ寸法代入が行われていないので,
9345 \cs{box0} の寸法変更に追従し,幅7\,pt,高さ9\,pt,深さ0\,ptのボックスとして扱われる.
9346 \end{itemize}
9347
9348 4行目では \cs{dtou} 下での\cs{box0} の幅が20\,ptに設定されるので,2行目と同じように
9349 \[
9350  \xymatrix{
9351    {}\Node{whatsit}{\cs{yoko}}\ar[r]\ar[d]_{\text{中身}}&{}\Node{rule}{}\\
9352    {}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{dtou})}{20.0}{9.0}{0.0}}\ar[r]&
9353    {}\HNode{\textit{dir\_box} (\cs{tate})}{20.0}{5.0}{5.0}
9354  }
9355 \]
9356 と\textit{dir\_box}が作成される.
9357
9358 このように寸法代入によってつくられた\textit{dir\_box}は,前節の整合過程のときに再利用され
9359 る.上記の例でいえば,5行目を実行した後の \cs{box0} の内容は
9360 \[
9361  \xymatrix{
9362    {}\Node{whatsit}{\cs{dtou}}\ar[r]&
9363    {}\Node{glyph}{`a'}\ar[r]&
9364    {}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{dtou})}{20.0}{9.0}{0.0}}\ar[d]_{\text{中身}}\\
9365    &&{}\HNode{hbox}{9.0}{5.0}{2.0}\ar[d]_{\text{中身}}\\
9366    &&{}\Node{whatsit}{\cs{yoko}}\ar[r]&{}\Node{rule}{}
9367  }
9368 \]
9369 のようになる.
9370 %</ja>
9371
9372 \newpage
9373 \begin{thebibliography}{99}
9374   \addcontentsline{toc}{section}{\refname}
9375 \bibitem{texbytopic}
9376 Victor Eijkhout. \newblock \textit{\TeX\ by Topic, A \TeX nician's Reference}, Addison-Wesley, 1992.
9377 \bibitem{listings} C.\ Heinz, B.\ Moses. \newblock The \textsf{Listings} Package.
9378 \bibitem{uptex} Takuji Tanaka. \newblock
9379 upTeX---Unicode version of pTeX with CJK extensions,
9380 TUG 2013, October 2013.
9381 %<ja>\newblock
9382 %<en>\\\null\hfill
9383 \url{http://tug.org/tug2013/slides/TUG2013_upTeX.pdf}
9384 \bibitem{jlisting} Thor Watanabe. \newblock Listings\ -\ MyTeXpert.
9385 %<en>\newblock
9386 %<ja>\\\null\hfill
9387 \url{http://mytexpert.osdn.jp/index.php?Listings}
9388 \bibitem{jlreq}  W3C Japanese Layout Task Force~(ed). \newblock
9389 Requirements for Japanese Text Layout (W3C Working Group Note), 2011, 2012. \newblock
9390 \url{http://www.w3.org/TR/jlreq/}%
9391 %<ja> \\日本語訳の書籍版:W3C日本語組版タスクフォース(編),『W3C技術ノート 日本語組版処理の要件』,東京電機大学出版局,2012.
9392 \bibitem{min10} 乙部厳己.min10フォントについて.\\\null\hfill
9393 \url{http://argent.shinshu-u.ac.jp/~otobe/tex/files/min10.pdf}
9394 \bibitem{x4051} 日本工業規格(Japanese Industrial Standard). JIS~X~4051,
9395 日本語文書の組版方法(Formatting rules for Japanese documents), 1993, 1995, 2004.
9396 \bibitem{ptexdoc} 濱野尚人,田村明史,倉沢良一.\TeX の出版への応用—縦組み機能の組み込み—.
9397 \\\null\hfill\texttt{.../texmf-dist/doc/ptex/base/ptexdoc.pdf}
9398 \bibitem{ptextug} Hisato Hamano. \newblock
9399 \textit{Vertical Typesetting with \TeX}, TUGBoat~\textbf{11}(3), 346--352, 1990.
9400 \bibitem{pdfstd} International Organization for Standardization. \newblock
9401 ISO 32000-1:2008, \textit{Document management -- Portable document format -- Part 1: PDF
9402       1.7}, 2008. \newblock
9403 \\\null\hfill
9404 \url{http://www.iso.org/iso/iso\_catalogue/catalogue_tc/catalogue\_detail.htm?csnumber=51502}
9405 \end{thebibliography}
9406
9407 \end{document}
9408 %</!showexpl>
9409 %<*showexpl>
9410 %%
9411 %% config file for showexpl.sty
9412 %%
9413 %% Copyright The LuaTeX-ja project team, 2012
9414 %%
9415 \ProvidesFile{showexpl.cfg}
9416   [2012/05/20 v0.01 Definitions for the showexpl package (luatexja)]
9417 \lstset{}
9418 \def\SX@Info{}
9419 \endinput
9420 %</*showexpl>