OSDN Git Service

ltjclasses: everyshi package in tate classes.
[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 %<*en>
20 \usepackage[margin=25mm,lmargin=30mm,rmargin=30mm,footskip=6mm]{geometry}
21 \usepackage{luatexja-adjust}\ltjdisableadjust
22 \parskip=\smallskipamount
23 \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
24     {3.25ex \@plus1ex \@minus.2ex}%
25     {-1em}%
26     {\normalfont\normalsize\bfseries\raisebox{.2ex}{$\mdlgblksquare\mkern1mu$}}}
27 %</en>
28 %<*ja>
29 \usepackage[textwidth=45\zw, lines=45, footskip=6mm]{geometry}
30 \usepackage{luatexja-adjust}%\ltjdisableadjust
31 \advance\leftmargini-1\zw\advance\leftmarginii-1\zw
32 %</ja>
33
34 \usepackage{amsmath,array,tikz,pict2e,multienum,float}
35 \usepackage{booktabs,multicol,luatexja-ruby}
36 \usepackage[all]{xy}
37 \usepackage{lltjext,alltt}
38
39 %%%%%%%% listings
40
41 %%%%%%%% IVS
42
43 \def\IVS#1{\char\numexpr "E0100+#1\relax}%"
44 \def\IVSA#1#2#3#4#5{%
45   \textcolor{blue}{\raisebox{3.5pt}{\tt%
46     \fboxsep=0.5pt\fbox{\tiny \oalign{0#1#2\crcr#3#4#5\crcr}}}}%
47 }
48 {\catcode`\%=11
49   \gdef\IVSB#1{\expandafter\IVSA\directlua{
50     local cat_str = luatexbase.catcodetables['string']
51     tex.sprint(cat_str, string.format('%X', 0xE00EF+#1))
52 }}}
53
54 \usepackage{listings,showexpl,enumitem}
55 \lstset{
56   basicstyle=\ttfamily\small, pos=r, breaklines=true,
57   numbers=none, rframe={}, basewidth=0.5em, numberstyle=\tiny, numbersep=0.5em,
58   explpreset={numberstyle=\tiny, numbers=left, numbersep=1em, columns=fixed}
59 }
60 % Suppress output from showexpl to stdout.
61 \let\SX@Info\relax
62
63 %%%%%%%% colors
64 %% modified from http://jfly.iam.u-tokyo.ac.jp/colorset/
65 \usepackage{transparent}
66 \definecolor{red}{rgb}{1, 0.16, 0}
67 \definecolor{blue}{rgb}{0, 0.25, 1}
68 \definecolor{gray}{rgb}{.50, .53, .56}
69 \definecolor{green}{rgb}{.21, .63, .42}
70 \definecolor{cyan}{rgb}{0.40, .80, 1}
71 \definecolor{b_gray}{rgb}{0.78, 0.78, 0.80}
72 \definecolor{b_pink}{rgb}{1, 0.82, 0.82}
73 \definecolor{b_green}{rgb}{.53, .91, .69}
74 \definecolor{b_cyan}{rgb}{0.70, .92, 98}
75
76 %%%%%%%% hyperref
77 \usepackage{hyperref,bookmark}
78 %<*en>
79 \title{The \LuaTeX-ja package}
80 \author{The \LuaTeX-ja project team}
81 %</en>
82 %<*ja>
83 \title{\LuaTeX-jaパッケージ}
84 \author{\LuaTeX-jaプロジェクトチーム}
85 %</ja>
86 \hypersetup{%
87         unicode,
88         colorlinks,
89         allbordercolors=1 1 1,
90         allcolors=blue,
91 %<*en>
92         pdfauthor={The LuaTeX-ja project team},
93         pdftitle={The LuaTeX-ja package}
94 %</en>
95 %<*ja>
96         pdfauthor={LuaTeX-jaプロジェクトチーム},
97         pdftitle={LuaTeX-jaパッケージ}
98 %</ja>
99 }
100
101 %%%%%%%% definition env.
102 \usepackage{amsthm}
103 \theoremstyle{definition}
104 %<en>\newtheorem{defn}{Definition}
105 %<ja>\newtheorem{defn}{定義}
106
107 %%%%%%%% fonts
108 \usepackage{luatexja-otf}
109 %<ja>\usepackage{lmodern}
110 \directlua{luatexja.otf.enable_ivs()}
111 \usepackage[match]{luatexja-fontspec}
112 \usepackage[kozuka-pr6n]{luatexja-preset}
113 \setmonojfont{KozGoPr6N-Regular.otf}
114 %<*ja>
115 \def\emph#1{\textbf{\textgt{#1}}}
116 \def\headfont{\normalfont\bfseries\gtfamily}
117 \usepackage{amssymb}
118 %</ja>
119 %<*en>
120 \usepackage{unicode-math}
121 \setmainfont[Ligatures=TeX]{TeX Gyre Termes}
122 \setsansfont[Scale=0.95,Ligatures=TeX]{TeX Gyre Heros}
123 \setmathfont{xits-math.otf}
124 \frenchspacing
125 %</en>
126
127 %%%%%%%% logo
128 \usepackage{metalogo}
129 \DeclareRobustCommand\eTeX{\ensuremath{\varepsilon}-\kern-.125em\TeX}
130 \DeclareRobustCommand\LuaTeX{Lua\TeX}
131 \DeclareRobustCommand\pdfTeX{pdf\TeX}
132 \DeclareRobustCommand\pTeX{p\kern-.15em\TeX}
133 \DeclareRobustCommand\upTeX{up\kern-.15em\TeX}
134 \DeclareRobustCommand\pLaTeX{p\kern-.05em\LaTeX}
135 \DeclareRobustCommand\pLaTeXe{p\kern-.05em\LaTeXe}
136 \DeclareRobustCommand\epTeX{\ensuremath{\varepsilon}-\kern-.125em\pTeX}
137
138 %%%%%%%% other macros
139 \newlist{cslist}{description}{1}
140 \setlist[cslist]{%
141     style=nextline,font=\mdseries\ttfamily,
142     before*=\def\<{\char`\<}\def\>{\char`\>}\def\{{\char`\{}\def\}{\char`\}},
143 %<ja> leftmargin=2\zw,
144 %<en> leftmargin=2em,
145 }
146
147 \def\labelenumii{(\arabic{enumii})}
148 \long\def\@makecaption#1#2{%
149   \vskip\abovecaptionskip
150   \sbox\@tempboxa{{\small #1. #2}}%
151   \ifdim \wd\@tempboxa >\hsize
152     {\small #1. #2}\par
153   \else
154     \global \@minipagefalse
155     \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
156   \fi
157   \vskip\belowcaptionskip}
158
159 \def\_{\leavevmode \kern .06em\vbox {\hrule \@width .333em}}
160 \def\cs#1{\texttt{\upshape\textbackslash #1}}
161
162 %%%%%%%%
163 \makeatother
164 %%%%%%%%
165
166 \def\Node#1#2{\,\vcenter{\hbox{\fboxsep=1pt\fbox{\vbox{\small\halign{\hfil##\hfil\cr
167   #1\mathstrut\cr\noalign{\vskip1pt\hrule height.4pt\vskip1pt}\strut#2\cr}}}}}\,}
168 \def\HNode#1#2#3#4{\,\vcenter{\hbox{\fboxsep=1pt\fbox{\vbox{\small\halign{\hfil##\hfil\cr
169   #1\mathstrut\cr\noalign{\vskip1pt\hrule height.4pt\vskip1pt}%
170   width:\hfill\ #2\cr height:\hfill\ #3\cr depth:\hfill\ #4\cr
171   }}}}}\,}
172
173 \protected\def\Param#1{\hyperlink{fld:#1}{\textsf{#1}}} % parameter name
174 \protected\def\DParam#1{\hypertarget{fld:#1}{\textsf{#1}}} % parameter name (definition)
175 \protected\def\Pkg#1{\underline{\smash{\texttt{#1}}}} % packages/classes
176
177
178 \begin{document}
179 \lstset{
180   vscmd=\IVSB
181 }
182
183 \catcode`\<=13
184 \def<#1>{{\normalfont\rm\itshape$\langle$#1\/$\rangle$}}
185 \let\LARG=<
186 \maketitle
187
188 \tableofcontents
189 \bigskip
190
191 %<*en>
192 \textbf{This documentation is far from complete. It may have many
193 grammatical (and contextual) errors.} Also, several parts
194 are written in Japanese only.
195 %</en>
196 %<*ja>
197 \emph{\large 本ドキュメントはまだまだ未完成です.}
198 %</ja>
199
200 \clearpage
201 %<en>\part{User's manual}
202 %<ja>\part{ユーザーズマニュアル}
203
204 %<en>\section{Introduction}
205 %<ja>\section{はじめに}
206
207
208 %<*en>
209 The \LuaTeX-ja package is a macro package for typesetting high-quality
210 Japanese documents when using \LuaTeX.
211 %</en>
212 %<*ja>
213 \LuaTeX-jaパッケージは,次世代標準\TeX である\LuaTeX の上で,\pTeX と同等
214 /それ以上の品質の日本語組版を実現させようとするマクロパッケージである.
215 %</ja>
216 %<en>\subsection{Backgrounds}
217 %<ja>\subsection{背景}
218
219 %<*en>
220 Traditionally, ASCII \pTeX, an extension of \TeX, and its derivatives
221 are used to typeset Japanese documents in \TeX. \pTeX\ is an engine
222 extension of \TeX: so it can produce high-quality Japanese documents
223 without using very complicated macros. But this point is a mixed
224 blessing: \pTeX\ is left behind from other extensions of \TeX,
225 especially \eTeX\ and \pdfTeX, and from changes about
226 Japanese processing in computers (\textit{e.g.}, the UTF-8 encoding).
227 %</en>
228 %<*ja>
229 従来,「\TeX を用いて日本語組版を行う」といったとき,エンジンとしては
230 ASCII \pTeX やそれの拡張物が用いられることが一般的であった.\pTeX は\TeX
231 のエンジン拡張であり,(少々仕様上不便な点はあるものの)商業印刷の分野に
232 も用いられるほどの高品質な日本語組版を可能としている.だが,それは弱点に
233 もなってしまった.\pTeX という(組版的に)満足なものがあったため,海外で
234 行われている数々の\TeX の拡張――例えば\eTeX や\pdfTeX ――や,TrueType,
235 OpenType, Unicodeといった計算機で日本語を扱う際の状況の変化に追従すること
236 を怠ってしまったのだ.
237 %</ja>
238
239 %<*en>
240 Recently extensions of \pTeX, namely \upTeX\ (Unicode-implementation
241 of \pTeX) and \epTeX\ (merging of \pTeX\ and
242 \eTeX\ extension), have developed to fill those gaps to some
243 extent, but gaps still exist.
244 %</en>
245 %<*ja>
246 ここ数年,若干状況は改善されてきた.現在手に入る大半の\pTeX バイナリでは
247 外部UTF-8入力が利用可能となり,さらにUnicode化を推進し,\pTeX の内部処理
248 までUnicode化した\upTeX も開発されている.また,\pTeX に\eTeX 拡張をマー
249 ジした\epTeX も登場し,\TeX\ Live\ 2011では\pLaTeX が\epTeX の上で動作す
250 るようになった.だが,\pdfTeX 拡張(PDF直接出力やmicro-typesetting)を
251 \pTeX に対応させようという動きはなく,海外とのgapは未だにあるのが現状であ
252 る.
253 %</ja>
254
255 %<*en>
256 However, the appearance of \LuaTeX\ changed the whole situation. With
257 using Lua ``callbacks'', users can customize the internal processing of
258 \LuaTeX. So there is no need to modify sources of engines to
259 support Japanese typesetting: to do this, we only have to write Lua
260 scripts for appropriate callbacks.
261 %</en>
262 %<*ja>
263 しかし,\LuaTeX の登場で,状況は大きく変わることになった.Luaコードで
264 ``callback''を書くことにより,\LuaTeX の内部処理に割り込みをかけることが可
265 能となった.これは,エンジン拡張という真似をしなくても,Luaコードとそれに
266 関する\TeX マクロを書けば,エンジン拡張とほぼ同程度のことができるようになっ
267 たということを意味する.\LuaTeX-jaは,このアプローチによってLuaコード・
268 \TeX マクロによって日本語組版を\LuaTeX の上で実現させようという目的で開発
269 が始まったパッケージである.
270 %</ja>
271
272 %<en>\subsection{Major Changes from \pTeX}
273 %<ja>\subsection{\pTeX からの主な変更点}
274 \label{ssec:chgptex}
275
276 %<*en>
277 The \LuaTeX-ja package is under much influence of \pTeX\ engine. The initial
278 target of development was to implement features of \pTeX. However,
279 \emph{\LuaTeX-ja is not a just porting of \pTeX; unnatural
280 specifications/behaviors of \pTeX\ were not adopted}.
281 %</en>
282 %<*ja>
283 \LuaTeX-jaは,\pTeX に多大な影響を受けている.初期の開発目標は,\pTeX の機
284 能をLuaコードにより実装することであった.しかし,開発が進むにつれ,\pTeX
285 の完全な移植は不可能であり,また\pTeX における実装がいささか不可解になっ
286 ているような状況も発見された.そのため,\emph{\LuaTeX-jaは,もはや
287 \pTeX の完全な移植は目標とはしない.\pTeX における不自然な仕様・挙動があ
288 れば,そこは積極的に改める.}
289 %</ja>
290
291 %<*en>
292 The followings are major changes from \pTeX:
293 %</en>
294 %<*ja>
295 以下は \pTeX からの主な変更点である.
296 %</ja>
297
298 \begin{itemize}
299 %<*en>
300 \item \emph{\LuaTeX-ja does all process only with Lua and \TeX\ macros},
301 while \pTeX\  is an engine extension of \TeX82.
302 This means that several features of \pTeX\ are not completely implemented
303 in \LuaTeX-ja.
304 %</en>
305 %<*ja>
306 \item \pTeX はエンジン拡張であったのに対し,
307 \emph{\LuaTeX-jaはLuaコードと\TeX マクロを用いて全てを実装している}.
308 そのため,\pTeX のいくつかの機能は\LuaTeX-ja に(そのままの形では)実装していない.
309 %</ja>
310 \begin{itemize}
311 %<*en>
312  \item \pTeX\ addes several primitives, such as \cs{kanjiskip}, 
313 \cs{prebreakpenalty},~and,~\cs{ifydir}. They can be used as follows:
314 %</en>
315 %<*ja>
316  \item 例えば\pTeX で追加された次のようなプリミティブ
317 %</ja>
318 \begin{verbatim}
319 \kanjiskip=10pt  \dimen0=kanjiskip
320 \prebreakpenalty`ぁ=100
321 \ifydir ... \fi
322 \end{verbatim}
323 %<en> However, we cannot use them under \LuaTeX-ja. 
324 %<en> Instead of them, we have to write as the following.
325 %<ja> は\LuaTeX-jaには存在しない.\LuaTeX-jaでは以下のように記述することになる.
326 \begin{verbatim}
327 \ltjsetparameter{kanjiskip}  \dimen0=\ltjgetparameter{kanjiskip}
328 \ltjsetparameter{prebreakpenalty={`ぁ,100}}
329 \ifnum\ltjgetparemeter{direction}=4 ... \fi
330 \end{verbatim}
331
332 %<*en>
333 \item In \pTeX, a line break after Japanese character is ignored (and
334       doesn't yield a space), since line breaks (in source files) are
335       permitted almost everywhere in Japanese texts. However, \LuaTeX-ja
336       doesn't have this feature completely, because of a specification
337       of \LuaTeX. For the detail, see Section~\ref{sec-lbreak}.
338 %</en>
339 %<*ja>
340 \item 日本語の文書中では改行はほとんどどこでも許されるので,\pTeX では和文文字
341       直後の改行は無視される(スペースが入らない)ようになっていた.しかし,
342       \LuaTeX-ja では \LuaTeX の仕様のためにこの機能は完全には実装されていない.
343       詳しくは\ref{sec-lbreak}章を参照.
344 %</ja>
345
346 \end{itemize}
347
348
349
350 %<*en>
351 \item The insertion process of glues/kerns between two Japanese
352       characters and between a Japanese character and other characters
353       (we refer glues/kerns of both kinds as \textbf{JAglue}) is rewritten from
354       scratch.
355 %</en>
356 %<*ja>
357 \item 2つの和文文字の間や,和文文字と欧文文字の間に入るグルー/カーン
358       (両者をあわせて\textbf{JAglue}と呼ぶ)の挿入処理が0から書き直されている.
359 %</ja>
360
361 \begin{itemize}
362 %<*en>
363 \item As \LuaTeX's internal ligature handling is ``node-based''
364       (\textit{e.g.}, \verb+of{}fice+ doesn't prevent ligatures), the
365       insertion process of \textbf{JAglue} is now ``node-based''.
366 %</en>
367 %<*ja>
368 \item \LuaTeX の内部での合字の扱いは「ノード」を単位として行われるようになっている(例えば,
369       \verb+of{}fice+ で合字は抑制されない).それに合わせ,\textbf{JAglue}の挿入処理も
370       ノード単位で実行される.
371 %</ja>
372
373 %<*en>
374 \item Furthermore, nodes between two characters which have no effects in
375       line break (\textit{e.g.}, \cs{special} node) and kerns from
376       italic correction are ignored in the insertion process.
377 %</en>
378 %<*ja>
379 \item さらに,2つの文字の間にある行末では効果を持たないノード(例えば \cs{special} ノード)や,
380   イタリック補正に伴い挿入されるカーンは挿入処理中では無視される.
381 %</ja>
382
383 %<*en>
384 \item \emph{Caution: due to above two points, many methods which did for the
385       dividing the process of the insertion of \textbf{JAglue} in \pTeX\ are not
386       effective anymore.} In concrete terms, the following two methods are not effective anymore:
387 %</en>
388 %<*ja>
389 \item \emph{注意:上の2つの変更により,従来\textbf{JAglue}の挿入処理を分断するのに
390       使われていたいくつかの方法は用いることができない.具体的には,次の方法はもはや無効である:}
391 %</ja>
392 \begin{lstlisting}
393 ちょ{}っと    ちょ\/っと
394 \end{lstlisting}
395 %<*en>
396       If you want to do so, please put an empty horizontal box (hbox) between it instead:
397 %</en>
398 %<*ja>
399       もし同じことをやりたければ,空の水平ボックス(hbox)を間に挟めばよい:
400 %</ja>
401 \begin{lstlisting}
402 ちょ\hbox{}っと
403 \end{lstlisting}
404
405
406 %<*en>
407 \item In the process, two Japanese fonts which only differ in their ``real''
408       fonts are identified.
409 %</en>
410 %<*ja>
411 \item 処理中では,2つの和文フォントは,実フォントが異なるだけの場合には同一視
412       される.
413 %</ja>
414 \end{itemize}
415
416 %<*ja>
417 \item ****版からは,不安定ながらも\LuaTeX-ja における縦組みをサポートしている.
418 \LuaTeX のコールバックの制限などにより,特に異なった組方向のボックスを扱う場合には
419 仕様が異なるので注意.
420 %</ja>
421
422 %<*en>
423 \item Japanese characters in discretionary break (\cs{discretionary}) is not supported.
424 %</en>
425 %<*ja>
426 \item \cs{discretionary} 内に直接和文文字を記述することはサポートされない.和文文字をどう
427       しても使いたい場合は \cs{hbox} で括ること.
428 %</ja>
429 \end{itemize}
430
431 %<*en>
432 For detailed information, see Part~\ref{part-imp}.
433 %</en>
434 %<*ja>
435 詳細については第\ref{part-imp}部を参照.
436 %</ja>
437
438 %<en>\subsection{Notations}
439 %<ja>\subsection{用語と記法}
440
441 %<*en>
442 In this document, the following terms and notations are used:
443 %</en>
444 %<*ja>
445 本ドキュメントでは,以下の用語と記法を用いる:
446 %</ja>
447 \begin{itemize}
448 %<*en>
449 \item Characters are classified into following two types.
450       Note that the classification can be customized by a user
451       (see Subsection~\ref{ssec-setrange}).
452 %</en>
453 %<*ja>
454 \item 文字は次の2種類に分けられる.この類別はユーザが後から変更可能である
455       (\ref{ssec-setrange}節を参照).
456 %</ja>
457 \begin{itemize}
458 %<*en>
459 \item \textbf{JAchar}: standing for characters which used in Japanese typesetting,
460       such as Hiragana,~Katakana, Kanji, and~other Japanese punctuation marks.
461 %</en>
462 %<*ja>
463 \item \textbf{JAchar}: ひらがな,カタカナ,漢字,和文用の約物といった
464       日本語組版に使われる文字のことを指す.
465 %</ja>
466
467 %<en>\item \textbf{ALchar}: standing for all other characters like latin alphabets.
468 %<ja>\item \textbf{ALchar}: ラテンアルファベットを始めとする,その他全ての文字を指す.
469 \end{itemize}
470
471 %<*en>
472 We say \emph{alphabetic fonts} for fonts used in \textbf{ALchar},
473 and \emph{Japanese fonts} for fonts used in \textbf{JAchar}.
474 %</en>
475 %<*ja>
476 そして,\textbf{ALchar}の出力に用いられるフォントを\emph{欧文フォント}と呼び,
477 \textbf{JAchar}の出力に用いられるフォントを\emph{和文フォント}と呼ぶ.
478 %</ja>
479 %<*en>
480 \item A word in a sans-serif font (like \Param{prebreakpenalty})
481       means an internal parameter for Japanese typesetting, and it
482       is used as a key in \cs{ltjsetparameter} command.
483 %</en>
484 %<*ja>
485 \item サンセリフ体で書かれた語(例:\Param{prebreakpenalty})は日本語組版用の
486       パラメータを表し,これらは \cs{ltjsetparameter} 命令のキーとして
487       用いられる.
488 %</ja>
489 %<*en>
490 \item A word in typewriter font with underline (like \Pkg{fontspec})
491       means a package or a class of \LaTeX.
492 %</en>
493 %<*ja>
494 \item 下線付きタイプライタ体の語(例:\Pkg{fontspec})は\LaTeX の
495       パッケージやクラスを表す.
496 %</ja>
497 %<*en>
498 \item In this document, natural numbers start from~zero.
499   $\omega$ denotes the set of all natural numbers.
500 %</en>
501 %<*ja>
502 \item 本ドキュメントでは,自然数は0から始まる.自然数全体の集合は$\omega$と表記する.
503 %</ja>
504 \end{itemize}
505
506 %<en>\subsection{About the Project}
507 %<ja>\subsection{プロジェクトについて}
508
509 %<en>\paragraph{Project Wiki} Project Wiki is under construction.
510 %<ja>\paragraph{プロジェクトWiki} プロジェクトWikiは構築中である.
511 %<*en>
512 \begin{itemize}
513 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28en%29} (English)
514 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage} (Japanese)
515 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28zh%29} (Chinese)
516 \end{itemize}
517 %</en>
518 %<*ja>
519 \begin{itemize}
520 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage}(日本語)
521 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28en%29}(英語)
522 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28zh%29}(中国語)
523 \end{itemize}
524 %</ja>
525
526 %<en>This project is hosted by SourceForge.JP.
527 %<ja>本プロジェクトはSourceForge.JPのサービスを用いて運営されている.
528
529 %<en>\paragraph{Members}\
530 %<ja>\paragraph{開発メンバー}\
531
532 %<*en>
533 \begin{multienumerate}
534 \def\labelenumi{$\bullet$}
535 \mitemxxx{Hironori KITAGAWA}{Kazuki MAEDA}{Takayuki YATO}
536 \mitemxxx{Yusuke KUROKI}{Noriyuki ABE}{Munehiro YAMAMOTO}
537 \mitemxxx{Tomoaki HONDA}{Shuzaburo SAITO}{MA Qiyuan}
538 \end{multienumerate}
539 %</en>
540 %<*ja>
541 \begin{multienumerate}
542 \def\labelenumi{$\bullet$}
543 \mitemxxx{北川 弘典}{前田 一貴}{八登 崇之}
544 \mitemxxx{黒木 裕介}{阿部 紀行}{山本 宗宏}
545 \mitemxxx{本田 知亮}{齋藤 修三郎}{馬 起園}
546 \end{multienumerate}
547 %</ja>
548
549 % \paragraph{Acknowledgments} -- 挿入するならここ
550
551 \clearpage
552 %<en>\section{Getting Started}
553 %<ja>\section{使い方}
554 %<en>\subsection{Installation}
555 %<ja>\subsection{インストール}
556
557 %<en>The following packages are needed for the \LuaTeX-ja\ package.
558 %<ja>\LuaTeX-jaパッケージには,次のパッケージ類が必要である.
559 \begin{itemize}
560 \item \LuaTeX\ snapshot rev~5024 (or later)
561 \item \Pkg{luaotfload} v2.5 (or later)
562 \item \Pkg{adobemapping} (Adobe cmap and pdfmapping files)
563 \item \Pkg{everysel} (if you want to use \LuaTeX-ja with \LaTeXe)
564 %<en>\item \emph{IPAex fonts(\url{http://ipafont.ipa.go.jp/})}
565 %<ja>\item \emph{IPAexフォント(\url{http://ipafont.ipa.go.jp/})}
566 \end{itemize}
567
568 %<*en>
569 \emph{This version of \LuaTeX-ja no longer supports \TeX~Live~2013 (or older version).
570 If you want to use this version with \TeX~Live~2014, you have to build a development
571 version of \LuaTeX\ from its source.}
572
573 \medskip
574
575 Now \LuaTeX-ja is available from
576 CTAN (in the \texttt{macros/luatex/generic/luatexja} directory), and
577 the following distributions:
578   \begin{itemize}
579   \item MiK\TeX\ (in \texttt{luatexja.tar.lzma}); see the next subsection
580   \item \TeX\ Live (in \texttt{texmf-dist/tex/luatex/luatexja})
581   \item W32\TeX\ (in \texttt{luatexja.tar.xz})
582   \end{itemize}
583 IPAex fonts are also available in these distributions.
584 %</en>
585 %<*ja>
586 \emph{本バージョンの\LuaTeX-jaは\TeX~Live~2013以前では動作しない.\TeX~Live~2014で
587 用いたい場合は,自力で\LuaTeX 開発版をソースからビルドする必要がある.}
588
589 \medskip
590
591 現在,\LuaTeX-jaはCTAN (\texttt{macros/luatex/generic/luatexja})に収録されている他,
592 以下のディストリビューションにも収録されている:
593   \begin{itemize}
594   \item MiK\TeX\ (\texttt{luatexja.tar.lzma})
595   \item \TeX\ Live (\texttt{texmf-dist/tex/luatex/luatexja})
596   \item W32\TeX\ (\texttt{luatexja.tar.xz})
597   \end{itemize}
598 これらのディストリビューションはIPAexフォントも収録している.
599 W32\TeX においてはIPAexフォントは \texttt{luatexja.tar.xz} 内にある.
600 %</ja>
601
602 % %<*ja>
603 % 例えば\TeX~Live~2015を利用しているなら,\LuaTeX-jaは\TeX~Live manager (\texttt{tlmgr})を
604 % 使ってインストールすることができる.
605 % \begin{lstlisting}
606 % $ tlmgr install luatexja
607 % \end{lstlisting}
608 % %</ja>
609 % %<*en>
610 % If you are using \TeX~Live~2015, you can install \LuaTeX-ja
611 % from \TeX~Live manager (\texttt{tlmgr}):
612 % \begin{lstlisting}
613 % $ tlmgr install luatexja
614 % \end{lstlisting}
615 % %</en>
616
617 %<en>\paragraph{Manual installation}
618 %<ja>\paragraph{手動インストール方法}
619
620 \begin{enumerate}
621 %<*en>
622 \item Download the source, by one of the following method.
623       At the present, \LuaTeX-ja has no \emph{stable} release.
624
625 \begin{itemize}
626 \item Clone the Git repository:
627 \begin{lstlisting}
628 $ git clone git://git.sourceforge.jp/gitroot/luatex-ja/luatexja.git
629 \end{lstlisting}
630 \item Download the \texttt{tar.gz} archive of HEAD in the \texttt{master} branch from
631 \begin{flushleft}
632 \url{http://git.sourceforge.jp/view?p=luatex-ja/luatexja.git;a=snapshot;h=HEAD;sf=tgz}.
633 \end{flushleft}
634 \end{itemize}
635
636 Note that the \texttt{master} branch, and hence the archive in CTAN, are not updated frequently;
637 the forefront of development is not the \texttt{master} branch.
638 %</en>
639 %<*ja>
640 \item ソースを以下のいずれかの方法で取得する.現在公開されているのはあくまでも
641       開発版であって,安定版でないことに注意.
642
643 \begin{itemize}
644 \item Gitリポジトリをクローンする:
645 \begin{lstlisting}
646 $ git clone git://git.sourceforge.jp/gitroot/luatex-ja/luatexja.git
647 \end{lstlisting}
648 \item \texttt{master}ブランチのスナップショット(\texttt{tar.gz}形式)をダウンロードする.
649 \begin{flushleft}
650 \url{http://git.sourceforge.jp/view?p=luatex-ja/luatexja.git;a=snapshot;h=HEAD;sf=tgz}.
651 \end{flushleft}
652 \end{itemize}
653 \texttt{master}ブランチ(従って,CTAN内のアーカイブも)はたまにしか更新されないことに注意.
654 主な開発は\texttt{master}の外で行われ,比較的まとまってきたらそれを\texttt{master}に
655 反映させることにしている.
656 %</ja>
657
658 %<*en>
659 \item Extract the archive. You will see \texttt{src/} and several other sub-directories.
660 But only the contents in \texttt{src/} are needed to work \LuaTeX-ja.
661 %</en>
662 %<*ja>
663 \item 「Gitリポジトリをクローン」以外の方法でアーカイブを取得したならば,それを展開する.
664       \texttt{src/}をはじめとしたいくつかのディレクトリができるが,
665       動作には\texttt{src/}以下の内容だけで十分.
666 %</ja>
667
668 %<*en>
669 \item If you downloaded this package from CTAN, you have to run following commands
670     to generate classes
671     and \texttt{ltj-kinsoku.lua} (the file which stores default ``\textit{kinsoku}'' parameters):
672 %</en>
673 %<*ja>
674 \item もしCTANから本パッケージを取得したのであれば,日本語用クラスファイルや
675 標準の禁則処理用パラメータを
676 格納した \texttt{ltj-kinsoku.lua} を生成するために,
677 以下を実行する必要がある:
678 %</ja>
679 \begin{lstlisting}
680 $ cd src
681 $ lualatex ltjclasses.ins
682 $ lualatex ltjsclasses.ins
683 $ lualatex ltjltxdoc.ins
684 $ luatex   ltj-kinsoku_make.tex
685 \end{lstlisting}
686 %<*en>
687 Note that \texttt{*.\{dtx,ins\}} and \texttt{ltj-kinsoku\_make.tex} are not needed in regular use.
688 %</en>
689 %<*ja>
690 ここで使用した \texttt{*.\{dtx,ins\}} と \texttt{ltj-kinsoku\_make.tex} は
691 通常の使用にあたっては必要ない.
692 %</ja>
693
694
695
696 %<*en>
697 \item Copy all the contents of \texttt{src/} into one of your \texttt{TEXMF} tree.
698       \texttt{TEXMF/tex/luatex/luatexja/} is an example location.
699       If you cloned entire Git repository, making a symbolic link of \texttt{src/}
700       instead copying is also good.
701 %</en>
702 %<*ja>
703 \item \texttt{src}の中身を自分の\texttt{TEXMF}ツリーにコピーする.
704       場所の例としては,例えば
705 \begin{quote}
706  \texttt{TEXMF/tex/luatex/luatexja/}
707 \end{quote}
708       がある.
709       シンボリックリンクが利用できる環境で,かつリポジトリを直接取得したのであれば,
710       (更新を容易にするために)コピーではなくリンクを貼ることを勧める.
711 %</ja>
712 %<*en>
713 \item If \texttt{mktexlsr} is needed to update the file name database, make it so.
714 %</en>
715 %<*ja>
716 \item 必要があれば,\texttt{mktexlsr}を実行する.
717 %</ja>
718 \end{enumerate}
719
720 %<en>\subsection{Cautions}
721 %<ja>\subsection{注意点}
722
723 \begin{itemize}
724 %<*en>
725 \item The encoding of your source file must be UTF-8. No other
726       encodings, such as EUC-JP or Shift-JIS, are not supported.
727 %</en>
728 %<*ja>
729 \item 原稿のソースファイルの文字コードはUTF-8固定である.
730       従来日本語の文字コードとして用いられてきたEUC-JPやShift-JISは使用できない.
731 %</ja>
732 %<*en>
733 \item \LuaTeX-ja is very slower than \pTeX.
734 Generally speaking, LuaJIT\TeX\ processes \LuaTeX-ja
735 about 30\% faster than \LuaTeX, but not always.
736 %</en>
737 %<*ja>
738 \item \LuaTeX-jaは動作が\pTeX に比べて非常に遅い.
739 コードを調整して徐々に速くしているが,まだ満足できる速度ではない.
740 LuaJIT\TeX を用いると\LuaTeX のだいたい1.3倍の速度で動くようであるが,
741 IPA mj明朝などの大きいフォントを用いた場合には\LuaTeX よりも遅くなることもある.
742 %</ja>
743 \item%
744 %<*en>
745 \textbf{Note for MiK\TeX\ users}\quad
746 \LuaTeX-ja requires that several CMap files%
747 \footnote{\texttt{UniJIS2004-UTF32-\{H,V\}} and \texttt{Adobe-Japan1-UCS2}.}
748 must be found from \LuaTeX.
749 Strictly speaking, those CMaps are needed
750 only in the first run of \LuaTeX-ja after installing or updating.
751 But it seems that MiK\TeX\ does not satisfy this condition,
752 so you will encounter an error like the following:
753 %</en>
754 %<*ja>
755 \LuaTeX-jaが動作するためには,\emph{導入・更新後の初回起動時に}
756 \texttt{UniJIS2004-UTF32-\{H,V\}}, \texttt{Adobe-Japan1-UCS2}という3つのCMapが
757 \LuaTeX によって見つけられることが必要である.
758 しかしMiK\TeX ではそのようになっていないので,次のエラーが発生するだろう:
759 %</ja>
760 \begin{lstlisting}
761 ! LuaTeX error ...iles (x86)/MiKTeX 2.9/tex/luatex/luatexja/ltj-rmlgbm.lua
762 bad argument #1 to 'open' (string expected, got nil)
763 \end{lstlisting}
764
765 %<*en>
766 If so, please execute a batch file which is written on
767 \href{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28en%29}{ the Project Wiki (English)}.
768 This batch file creates a temporary directory, copy CMaps in it,
769 run \LuaTeX-ja in this directory, and finally delete the temporary directory.
770 %</en>
771 %<*ja>
772 そのような場合には,
773 \href{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28en%29}{%
774   プロジェクトWiki英語版トップページ}中に書かれているバッチファイルを
775 実行して欲しい.このバッチファイルは,作業用ディレクトリにCMap達を
776 コピーし,その中で\LuaTeX-ja の初回起動を行い,作業用ディレクトリを消す作業をしている.
777 %</ja>
778
779 \end{itemize}
780
781 %<en>\subsection{Using in plain \TeX}
782 %<ja>\subsection{plain \TeX で使う}
783 \label{ssec-plain}
784
785 %<en>To use \LuaTeX-ja in plain \TeX, simply put the following at the beginning of the document:
786 %<ja>\LuaTeX-jaを plain \TeX で使うためには,単に次の行をソースファイルの冒頭に追加すればよい:
787 \begin{lstlisting}
788 \input luatexja.sty
789 \end{lstlisting}
790 %<en>This does minimal settings (like \texttt{ptex.tex}) for typesetting Japanese documents:
791 %<ja>これで(\texttt{ptex.tex}のように)日本語組版のための最低限の設定がなされる:
792
793 \begin{itemize}
794 %<*en>
795 \item The following 12~Japanese fonts are preloaded:
796 \begin{center}\small
797 \begin{tabular}{cccccc}
798 \toprule
799 \textbf{direction}&
800 \textbf{classification}&\textbf{font name}&\bf `10\,pt'&\bf`7\,pt'&\bf`5\,pt'\\\midrule
801 \smash{\raisebox{-1ex}{\emph{yoko} (horizontal)}}&
802 \emph{mincho}&IPAex Mincho&\cs{tenmin}&\cs{sevenmin}&\cs{fivemin}\\
803 &\emph{gothic}&IPAex Gothic&\cs{tengt} &\cs{sevengt} &\cs{fivegt}\\
804 \midrule
805 \smash{\raisebox{-1ex}{\emph{tate} (vertical)}}&
806 \emph{mincho}&IPAex Mincho&\cs{tentmin}&\cs{seventmin}&\cs{fivetmin}\\
807 &\emph{gothic}&IPAex Gothic&\cs{tentgt} &\cs{seventgt} &\cs{fivetgt}\\
808 \bottomrule
809 \end{tabular}
810 \end{center}
811 %</en>
812 %<*ja>
813 \item 以下の12個の和文フォントが定義される:
814 \begin{center}\small
815 \begin{tabular}{cccccc}
816 \toprule
817 \emph{組方向}&\emph{字体}&\emph{フォント名}&\bf `10\,pt'&\bf`7\,pt'&\bf`5\,pt'\\\midrule
818 \smash{\raisebox{-1ex}{横組}}&
819 明朝体&IPAex明朝&\cs{tenmin}&\cs{sevenmin}&\cs{fivemin}\\
820 &ゴシック体&IPAexゴシック&\cs{tengt} &\cs{sevengt} &\cs{fivegt}\\
821 \midrule
822 \smash{\raisebox{-1ex}{縦組}}&
823 明朝体&IPAex明朝&\cs{tentmin}&\cs{seventmin}&\cs{fivetmin}\\
824 &ゴシック体&IPAexゴシック&\cs{tentgt} &\cs{seventgt} &\cs{fivetgt}\\
825 \bottomrule
826 \end{tabular}
827 \end{center}
828 %</ja>
829 \begin{itemize}
830 %<*en>
831 \item With \texttt{luatexja.cfg}, one can use other fonts
832 as ``default'' Japanese fonts (Subsection~\ref{ssec-cfg}).
833 %</en>
834 %<*ja>
835 \item \texttt{luatexja.cfg} を用いることによって,標準和文フォントを
836 IPAexフォントから別のフォントに置き換えることができる.\ref{ssec-cfg}節を参照.
837 %</ja>
838
839 %<*en>
840 \item A character in an alphabetic font is generally smaller than a
841       Japanese font in the same size. So actual size specification of
842       these Japanese fonts is in fact smaller than that of alphabetic
843       fonts, namely scaled by 0.962216.
844 %</en>
845 %<*ja>
846 \item 欧文フォントの文字は和文フォントの文字よりも,同じ文字サイズでも
847       一般に小さくデザインされている.そこで,標準ではこれらの和文フォントの実際のサイズは指定された値よりも
848       小さくなるように設定されており,具体的には指定の0.962216倍にスケールされる.
849       この0.962216という数値も,\pTeX におけるスケーリングを踏襲した値である.
850 %</ja>
851 \end{itemize}
852
853 %<*en>
854 \item The amount of glue that are inserted between a \textbf{JAchar} and
855       an \textbf{ALchar} (the parameter \Param{xkanjiskip}) is set to
856 %</en>
857 %<*ja>
858 \item \textbf{JAchar}と\textbf{ALchar}の間に入るグルー(\Param{xkanjiskip})の
859       量は次のように設定されている:
860 %</ja>
861 \[
862  (0.25\cdot 0.962216\cdot 10\,\mathrm{pt})^{+1\,\text{pt}}_{-1\,\text{pt}}
863  = 2.40554\,\mathrm{pt}^{+1\,\text{pt}}_{-1\,\text{pt}}.
864 \]
865 \end{itemize}
866
867 %<en>\subsection{Using in \LaTeX}
868 %<ja>\subsection{\LaTeX で使う}
869 \label{ssec-ltx}
870
871 %<*en>
872 Using in \LaTeXe\ is basically same. To set up the minimal environment
873 for Japanese, you only have to load \texttt{luatexja.sty}:
874 %</en>
875 %<*ja>
876 \LaTeXe を用いる場合も基本的には同じである.日本語組版のための最低限の環境を
877 設定するためには,\texttt{luatexja.sty}を読み込むだけでよい:
878 %</ja>
879 \begin{lstlisting}
880 \usepackage{luatexja}
881 \end{lstlisting}
882 %<*en>
883 It also does minimal settings (counterparts in \pLaTeX\ are \texttt{%
884 plfonts.dtx} and \texttt{pldefs.ltx}):
885 %</en>
886 %<*ja>
887 これで\pLaTeX の\texttt{plfonts.dtx}と\texttt{pldefs.ltx}に相当する最低限の設定が
888 なされる:
889 %</ja>
890
891 \begin{itemize}
892 %<*en>
893 \item Font encodings for Japanese fonts is \texttt{JY3}~(for horizontal direction) and
894 \texttt{JT3}~(for vertical direction).
895 %</en>
896 %<*ja>
897 \item 和文フォントのエンコーディングとしては,横組用には \texttt{JY3},縦組用には\
898 \texttt{JT3}が用いられる.
899 %</ja>
900
901 %<*en>
902 \item Traditionally, Japanese documents use two typeface categories: \emph{mincho}~(明朝体) and
903  \emph{gothic}~(\textgt{ゴシック体}). \emph{mincho} is used in the main text, while \emph{gothic}
904       is used in the headings or for emphasis.
905 \begin{center}\small
906 \begin{tabular}{lllc}
907 \toprule
908 \textbf{classification}&&&\textbf{family name}\\\midrule
909 \emph{mincho} (明朝体)&\verb+\textmc{...}+&\verb+{\mcfamily ...}+&\cs{mcdefault}\\
910 \emph{gothic} (\textgt{ゴシック体})&\verb+\textgt{...}+&\verb+{\gtfamily ...}+&\cs{gtdefault}\\
911 \bottomrule
912 \end{tabular}
913 \end{center}
914 \item
915 By default, the following fonts are used for \emph{mincho} and \emph{gothic}:
916 \begin{center}\small
917 \begin{tabular}{ccccc}
918 \toprule
919 \textbf{classification}&\textbf{family}&\cs{mdseries}&\cs{bfseries}&\textbf{scale}\\\midrule
920 \emph{mincho} (明朝体)&\tt mc&IPAex Mincho&IPAex Gothic&0.962216\\
921 \emph{gothic} (\textgt{ゴシック体})&\tt gt&IPAex Gothic&IPAex Gothic&0.962216\\
922 \bottomrule
923 \end{tabular}
924 \end{center}
925 Note that the bold series in both family are same as the medium series of \emph{gothic}
926      family. There is no italic nor slanted shape for
927       these \texttt{mc}~and~\texttt{gt}.
928 %</en>
929 %<*ja>
930 \item \pLaTeX と同様に,標準では「明朝体」「ゴシック体」の2種類を用いる:
931 \begin{center}\small
932 \begin{tabular}{cllc}
933 \toprule
934 \emph{字体}&&&\emph{ファミリ名}\\\midrule
935 明朝体&\verb+\textmc{...}+&\verb+{\mcfamily ...}+&\cs{mcdefault}\\
936 \textgt{ゴシック体}&\verb+\textgt{...}+&\verb+{\gtfamily ...}+&\cs{gtdefault}\\
937 \bottomrule
938 \end{tabular}
939 \end{center}
940 \item 標準では,次のフォントファミリが用いられる:
941 \begin{center}\small
942 \begin{tabular}{ccccc}
943 \toprule
944 \emph{字体}&\emph{ファミリ}&\cs{mdseries}&\cs{bfseries}&\emph{スケール}\\\midrule
945 明朝体&\tt mc&IPAex明朝&IPAexゴシック&0.962216\\
946 ゴシック体&\tt gt&IPAexゴシック&IPAexゴシック&0.962216\\
947 \bottomrule
948 \end{tabular}
949 \end{center}
950 どちらのファミリにおいても,そのboldシリーズで使われるフォントは
951 ゴシック体のmediumシリーズで使われるフォントと同じであることに注意.
952 また,どちらのファミリでもイタリック体・スラント体は定義されない.
953 %</ja>
954
955
956 %<en>\item Japanese characters in math mode are typeset by the font family \texttt{mc}.
957 %<ja>\item 数式モード中の和文文字は明朝体(\texttt{mc})で出力される.
958 \end{itemize}
959
960 %<*en>
961 However, above settings are not sufficient for Japanese-based
962 documents. To typeset Japanese-based documents, you are better to use
963 class files other than \texttt{article.cls}, \texttt{book.cls}, and so on.  At
964 the present, we have the counterparts of \Pkg{jclasses} (standard
965 classes in \pLaTeX) and \Pkg{jsclasses} (classes by Haruhiko
966 Okumura), namely, \Pkg{ltjclasses}\footnote{%
967   \texttt{ltjarticle.cls},~\texttt{ltjbook.cls}, \texttt{ltjreport.cls},
968   \texttt{ltjtarticle.cls}, \texttt{ltjtbook.cls}, \texttt{ltjtreport.cls}.
969   The latter \texttt{ltjt*.cls} are for vertically writtened Japanese documents.
970 } and \Pkg{ltjsclasses}\footnote{%
971   \texttt{ltjsarticle.cls},~\texttt{ltjsbook.cls},~\texttt{ltjskiyou.cls}.}.
972 %</en>
973 %<*ja>
974 しかしながら,上記の設定は日本語の文書にとって十分とは言えない.
975 日本語文書を組版するためには,\texttt{article.cls}, \texttt{book.cls}といった
976 欧文用のクラスファイルではなく,和文用のクラスファイルを用いた方がよい.
977 現時点では,\Pkg{jclasses}(\pLaTeX の標準クラス)と\Pkg{jsclasses}
978 (奥村晴彦氏による「\pLaTeXe 新ドキュメントクラス」)に対応するものとして,
979 \Pkg{ltjclasses}\footnote{%
980   横組用は \texttt{ltjarticle.cls},~\texttt{ltjbook.cls}, \texttt{ltjreport.cls} であり,
981   縦組用は \texttt{ltjtarticle.cls}, \texttt{ltjtbook.cls}, \texttt{ltjtreport.cls} である.
982 },
983 \Pkg{ltjsclasses}\footnote{%
984   \texttt{ltjsarticle.cls},~\texttt{ltjsbook.cls},~\texttt{ltjskiyou.cls}.}%
985 がそれぞれ用意されている.
986 %</ja>
987
988 %<*ja>
989 \paragraph{脚注とボトムフロートの出力順序}
990 オリジナルの\LaTeX では脚注がボトムフロートの上に来るようになっており,
991 \pLaTeX では脚注がボトムフロートの下に来るように変更されている.
992
993 \LuaTeX-jaでは「欧文クラスの中にちょっとだけ日本語を入れる」という利用も考慮し,
994 脚注とボトムフロートの順序は\LaTeX 通りとした.もし\pLaTeX の出力順序が好みならば,
995 \Pkg{stfloats}パッケージを利用して
996 \begin{lstlisting}
997  \usepackage{stfloats} \fnbelowfloat
998 \end{lstlisting}
999 のようにすればよい.\Pkg{footmisc}パッケージを \texttt{bottom}\ オプションを指定して
1000 読み込むという方法もあるが,それだとボトムフロートと脚注の間が開いてしまう.
1001 %</ja>
1002
1003 %<en>\section{Changing Fonts}
1004 %<ja>\section{フォントの変更}
1005
1006 \subsection{plain \TeX~and~\LaTeXe}
1007 \label{ssec-chgfnt}
1008
1009 \paragraph{plain \TeX}
1010 %<*en>
1011 To change Japanese fonts in plain \TeX, you must use the command
1012 \cs{jfont}~and~\cs{tfont}. So please see Subsection~\ref{ssec-jfont}.
1013 %</en>
1014 %<*ja>
1015 plain \TeX で和文フォントを変更するためには,
1016 \pTeX のように \cs{jfont} 命令や \cs{tfont} 命令を直接用いる.
1017 \ref{ssec-jfont}節を参照.
1018 %</ja>
1019
1020 \paragraph{\LaTeXe\ (NFSS2)}
1021 %<*en>
1022 For \LaTeXe, \LuaTeX-ja adopted most of the font selection system of \pLaTeXe\ (in \texttt{plfonts.dtx}).
1023 %</en>
1024 %<*ja>
1025 \LaTeXe については,\LuaTeX-jaではフォント選択システムを\pLaTeXe\ (\texttt{plfonts.dtx})
1026 の大部分をそのまま採用している.
1027 %</ja>
1028 \begin{itemize}
1029 %<*en>
1030 \item Commands \cs{fontfamily}, \cs{fontseries},
1031       \cs{fontshape}, and \cs{selectfont} can be used to change
1032       attributes of Japanese fonts.
1033 %</en>
1034 %<*ja>
1035 \item \cs{fontfamily}, \cs{fontseries}, \cs{fontshape}, そして
1036       \cs{selectfont} が和文フォントの属性を変更するために使用できる.
1037 %</ja>
1038
1039 %<*en>
1040 \begin{center}\small
1041 \begin{tabular}{cccccc}
1042 \toprule
1043 &\textbf{encoding}&\textbf{family}&\textbf{series}&\textbf{shape}&\textbf{selection}\\\midrule
1044 alphabetic fonts
1045 &\cs{romanencoding}&\cs{romanfamily}&\cs{romanseries}&\cs{romanshape}
1046 &\cs{useroman}\\
1047 Japanese fonts
1048 &\cs{kanjiencoding}&\cs{kanjifamily}&\cs{kanjiseries}&\cs{kanjishape}
1049 &\cs{usekanji}\\
1050 both&---&--&\cs{fontseries}&\cs{fontshape}&---\\
1051 auto select&\cs{fontencoding}&\cs{fontfamily}&---&---&\cs{usefont}\\
1052 \bottomrule
1053 \end{tabular}
1054 \end{center}
1055 %</en>
1056 %<*ja>
1057 \begin{center}\small
1058 \begin{tabular}{cccccc}
1059 \toprule
1060 &\emph{エンコーディング}&\emph{ファミリ}&\emph{シリーズ}&\emph{シェープ}&\emph{選択}\\\midrule
1061 欧文
1062 &\cs{romanencoding}&\cs{romanfamily}&\cs{romanseries}&\cs{romanshape}
1063 &\cs{useroman}\\
1064 和文
1065 &\cs{kanjiencoding}&\cs{kanjifamily}&\cs{kanjiseries}&\cs{kanjishape}
1066 &\cs{usekanji}\\
1067 両方&---&--&\cs{fontseries}&\cs{fontshape}&---\\
1068 自動選択&\cs{fontencoding}&\cs{fontfamily}&---&---&\cs{usefont}\\
1069 \bottomrule
1070 \end{tabular}
1071 \end{center}
1072 %</ja>
1073
1074 %<*en>
1075       \verb+\fontencoding{+<encoding>\verb+}+ changes the encoding of alphabetic fonts
1076       or Japanese fonts depending on the argument. For example,
1077       \verb+\fontencoding{JY3}+ changes the encoding of Japanese fonts to
1078       \texttt{JY3},and \verb+\fontencoding{T1}+ changes the encoding of
1079       alphabetic fonts to \texttt{T1}.
1080       \cs{fontfamily} also changes the current Japanese font family,
1081       the current alphabetic font family, \emph{or both}.
1082       For the detail, see Subsection~\ref{ssec-nfsspat}.
1083 %</en>
1084 %<*ja>
1085       ここで,\verb+\fontencoding{+<encoding>\verb+}+ は,引数により和文側か欧文
1086       側かのどちらかのエンコーディングを変更する.例えば,
1087       \verb+\fontencoding{JY3}+ は和文フォントのエンコーディングを
1088       \texttt{JY3}に変更し,\verb+\fontencoding{T1}+ は欧文フォント側を
1089       \texttt{T1}へと変更する.\cs{fontfamily} も引数により和文側,欧文
1090       側,\emph{あるいは両方}のフォントファミリを変更する.詳細は
1091       \ref{ssec-nfsspat}節を参照すること.
1092 %</ja>
1093
1094 %<*en>
1095 \item For defining a Japanese font family, use
1096       \cs{DeclareKanjiFamily} instead of
1097       \cs{DeclareFontFamily}. However, in the present implementation,
1098       using \cs{DeclareFontFamily} doesn't cause any problem.
1099 \item Defining a Japanese font shape can be done by usual \cs{DeclareFontShape}:
1100 %</en>
1101 %<*ja>
1102 \item 和文フォントファミリの定義には \cs{DeclareFontFamily} の
1103       代わりに \cs{DeclareKanjiFamily} を用いる.しかし,現在の
1104       実装では \cs{DeclareFontFamily} を用いても問題は生じない.
1105 \item 和文フォントのシェイプを定義するには,通常の \cs{DeclareFontShape} を使えば良い:
1106 %</ja>
1107 \begin{lstlisting}
1108 \DeclareFontShape{JY3}{mc}{bx}{n}{<-> s*KozMinPr6N-Bold:jfm=ujis;-kern}{}
1109     % Kozuka Mincho Pr6N Bold
1110 \end{lstlisting}
1111 %<*ja>
1112 仮名書体を使う場合など,複数の和文フォントを組み合わせて使いたい場合は
1113 \ref{ssec-altfont}節の \cs{ltjdeclarealtfont} と,その\LaTeX 版の\
1114 \cs{DeclareAlternateKanjiFont}(\ref{ssec-nfsspat}節)を参照せよ.
1115 %</ja>
1116 \end{itemize}
1117
1118 %<*en>
1119 \paragraph{Remark: Japanese characters in math mode}
1120 Since \pTeX\ supports Japanese characters in math mode, there are
1121 sources like the following:
1122 %</en>
1123 %<*ja>
1124 \paragraph{注意:数式モード中の和文文字}
1125 \pTeX では,特に何もしないでも数式中に和文文字を記述することができた.そのため,
1126 以下のようなソースが見られた:
1127 %</ja>
1128
1129 \begin{LTXexample}
1130 $f_{高温}$~($f_{\text{high temperature}}$).
1131 \[ y=(x-1)^2+2\quad よって\quad y>0 \]
1132 $5\in 素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
1133 \end{LTXexample}
1134 %<*en>
1135 We (the project members of \LuaTeX-ja) think that using
1136 Japanese characters in math mode are allowed if and only if these are used as identifiers.
1137 In this point of view,
1138 %</en>
1139 %<*ja>
1140 \LuaTeX-jaプロジェクトでは,数式モード中での和文文字はそれらが識別子として用いられる
1141 ときのみ許されると考えている.
1142 この観点から,
1143 %</ja>
1144
1145 \begin{itemize}
1146 %<*en>
1147 \item The lines 1~and~2 above are not correct, since ``高温'' in above is used as a textual label, and
1148 ``よって'' is used as a conjunction.
1149 %</en>
1150 %<*ja>
1151 \item 上記数式のうち1, 2行目は正しくない.なぜならば「高温」が意味のあるラベルと
1152       して,「よって」が接続詞として用いられているからである.
1153 %</ja>
1154 %<en>\item However, the line~3 is correct, since ``素'' is used as an identifier.
1155 %<ja>\item しかしながら,3行目は「素」が単なる識別子として用いられているので正しい.
1156 \end{itemize}
1157 %<en>Hence, in our opinion, the above input should be corrected as:
1158 %<ja>したがって,\LuaTeX-jaプロジェクトの意見としては,上記の入力は次のように直されるべきである:
1159 \begin{LTXexample}
1160 $f_{\text{高温}}$~%
1161 ($f_{\text{high temperature}}$).
1162 \[ y=(x-1)^2+2\quad
1163   \mathrel{\text{よって}}\quad y>0 \]
1164 $5\in 素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
1165 \end{LTXexample}
1166 %<*en>
1167 We also believe that using Japanese characters as identifiers is rare,
1168 hence we don't describe how to change Japanese fonts in math mode in
1169 this chapter. For the method, please see Subsection~\ref{ssec-math}.
1170 %</en>
1171 %<*ja>
1172 また\LuaTeX-jaプロジェクトでは,和文文字が識別子として用いられることはほとんどない
1173 と考えており,したがってこの節では数式モード中の和文フォントを変更する方法については
1174 記述しない.この方法については\ref{ssec-math}節を参照のこと.
1175 %</ja>
1176
1177
1178 \subsection{fontspec}
1179 \label{ssec-fontspec}
1180 %<*en>
1181 To coexist with the \Pkg{fontspec} package, it is needed to load
1182 \Pkg{luatexja-fontspec} package in the preamble, as follows:
1183 \begin{quote}
1184 \ttfamily \textbackslash usepackage[<options>]\{luatexja-fontspec\}
1185 \end{quote}
1186 This \Pkg{luatexja-fontspec} package
1187 automatically loads \Pkg{luatexja} and \Pkg{fontspec}
1188 package, if needed.
1189 %</en>
1190 %<*ja>
1191 \Pkg{fontspec}パッケージと同様の機能を和文フォントに対しても用いる場合,
1192 \Pkg{luatexja-fontspec}パッケージを読み込む:
1193 \begin{quote}
1194 \ttfamily \textbackslash usepackage[<options>]\{luatexja-fontspec\}
1195 \end{quote}
1196 このパッケージ
1197 は必要ならば自動で\Pkg{luatexja}パッケージと\Pkg{fontspec}パッケージを読み込む.
1198 %</ja>
1199
1200 %<*en>
1201 In \Pkg{luatexja-fontspec} package, the following seven~commands are defined as
1202 counterparts of original commands in the \Pkg{fontspec} package:
1203 %</en>
1204 %<*ja>
1205 \Pkg{luatexja-fontspec}パッケージでは,以下の7つのコマンドを\Pkg{fontspec}
1206 パッケージの元のコマンドに対応するものとして定義している:
1207 %</ja>
1208 %<*en>
1209 \begin{center}\small
1210 \begin{tabular}{ccccc}
1211 \toprule
1212 Japanese fonts
1213 &\cs{jfontspec}&\cs{setmainjfont}&\cs{setsansjfont}&\cs{setmonojfont}$^*$\\
1214 alphabetic fonts
1215 &\cs{fontspec}&\cs{setmainfont}&\cs{setsansfont}&\cs{setmonofont}\\
1216 \midrule
1217 Japanese fonts
1218 &\cs{newjfontfamily}&\cs{newjfontface}
1219 &\cs{defaultjfontfeatures}&\cs{addjfontfeatures}\\
1220 alphabetic fonts
1221 &\cs{newfontfamily}&\cs{newfontface}
1222 &\cs{defaultfontfeatures}&\cs{addfontfeatures}\\
1223 \bottomrule
1224 \end{tabular}
1225 \end{center}
1226 %</en>
1227 %<*ja>
1228 \begin{center}\small
1229 \begin{tabular}{cccc}
1230 \toprule
1231 和文
1232 &\cs{jfontspec}&\cs{setmainjfont}&\cs{setsansjfont}\\
1233 欧文
1234 &\cs{fontspec}&\cs{setmainfont}&\cs{setsansfont}\\
1235 \midrule
1236 和文
1237 &\cs{newjfontfamily}&\cs{newjfontface}&\cs{defaultjfontfeatures}\\
1238 欧文
1239 &\cs{newfontfamily}&\cs{newfontface}&\cs{defaultfontfeatures}\\
1240 \midrule
1241 和文
1242 &\cs{addjfontfeatures}\\
1243 欧文
1244 &\cs{addfontfeatures}\\
1245 \bottomrule
1246 \end{tabular}
1247 \end{center}
1248 %</ja>
1249 %<*en>
1250 The package option of \Pkg{luatexja-fontspec} are the followings:
1251 \begin{cslist}
1252  \item[match]
1253 If this option is specified, usual family-changing commands such as
1254 \cs{rmfamily},~\cs{textrm}, \cs{sffamily},~\dots\ also change Japanese font family.
1255
1256 Note that \emph{\cs{setmonojfont} is defined
1257 if and only if this \texttt{\textup{match}} option is specified}.
1258
1259  \item[pass=<opts>]
1260 Specify options <opts> which will be passed to the \Pkg{fontspec} package.
1261 \end{cslist}
1262 The reason that \cs{setmonojfont} is not defined by default is that
1263 it is popular for Japanese fonts that nearly all Japanese glyphs have same
1264 widths.  Also note that kerning information in a font is not used
1265 (that is, \texttt{kern} feature is set off) by default in these seven (or~eight) commands.
1266 This is because of the compatibility with previous versions of \LuaTeX-ja
1267 (see \ref{para-kern}).
1268 %</en>
1269 %<*ja>
1270 \Pkg{luatexja-fontspec} パッケージのオプションは以下の通りである:
1271 \begin{cslist}
1272  \item[match]
1273 このオプションが指定されると,「\pLaTeXe 新ドキュメントクラス」のように\
1274 \cs{rmfamily}, \verb+\textrm{...}+, \cs{sffamily} 等が
1275 欧文フォントだけでなく和文フォントも変更するようになる.
1276
1277 \emph{なお,\cs{setmonojfont} はこの \texttt{match} オプションが
1278 指定された時のみ定義される.}この命令は標準の「タイプライタ体に対応する和文フォント」を指定する.
1279
1280  \item[pass=<opts>]
1281 \Pkg{fontspec} パッケージに渡すオプション <opts> を指定する.
1282 \end{cslist}
1283 標準で \cs{setmonojfont} コマンドが定義されないのは,
1284 和文フォントではほぼ全ての和文文字のグリフが等幅であるのが伝統的であったことによる.
1285 また,これらの和文用のコマンドではフォント内のペアカーニング情報は標準では使用されない,
1286 言い換えれば \texttt{kern} featureは標準では無効化となっている.
1287 これは以前のバージョンの\LuaTeX-jaとの互換性のためである(\ref{para-kern}節を参照).
1288 %</ja>
1289
1290 \begin{LTXexample}[width=0.4\textwidth]
1291 \fontspec[Numbers=OldStyle]{LMSans10-Regular}
1292 \jfontspec[CJKShape=NLC]{KozMinPr6N-Regular}
1293 JIS~X~0213:2004→辻
1294
1295 \jfontspec[CJKShape=JIS1990]{KozMinPr6N-Regular}
1296 JIS~X~0208:1990→辻
1297 \end{LTXexample}
1298
1299 %<en>\subsection{Presets}
1300 %<ja>\subsection{プリセット設定}
1301 \label{ssec-preset}
1302
1303 %<*en>
1304 To use standard Japanese font settings easily, one can load \Pkg{luatexja-preset}
1305 package with several options. This package provides functions in a part of
1306 \Pkg{japanese-otf} package and a part of \Pkg{PXchfon} package by Takayuki Yato,
1307 and loads \Pkg{luatexja-fontspec}, hence \Pkg{fontspec} internally.
1308
1309 If you need to pass some options to \Pkg{fontspec}, load \Pkg{fontspec} manually
1310 before \Pkg{luatexja-preset}:
1311 %</en>
1312 %<*ja>
1313 よく使われている和文フォント設定を一行で指定できるようにしたのが
1314 \Pkg{luatexja-preset}パッケージである.このパッケージは,
1315 \Pkg{otf}パッケージの一部機能と八登崇之氏による\Pkg{PXchfon}パッケージの一部機能とを
1316 合わせたような格好をしており,内部で\Pkg{luatexja-fontspec},従って
1317 \Pkg{fontspec}を読み込んでいる.
1318
1319 もし\Pkg{fontspec}パッケージに何らかのオプションを渡す必要がある
1320 \footnote{例えば,数式フォントまで置換されてしまい,\cs{mathit}によってギリシャ文字の
1321 斜体大文字が出なくなる,など.}場合は,
1322 次のように\Pkg{luatexja-preset}の前に\Pkg{fontspec}を手動で読みこめば良い:
1323 %</ja>
1324 \begin{lstlisting}
1325 \usepackage[no-math]{fontspec}
1326 \usepackage[...]{luatexja-preset}
1327 \end{lstlisting}
1328
1329 %<en>\paragraph{General options}
1330 %<ja>\paragraph{一般的なオプション}
1331 \begin{cslist}[before*=]
1332
1333 \item[nodeluxe]
1334 %<*en>
1335 Use one-weighted \textit{mincho} and \textit{gothic} font families.
1336 This means that \verb+\mcfamily\bfseries+, \verb+\gtfamily\bfseries+ and
1337 \verb+\gtfamily\mdseries+ use the same font.
1338 \emph{This option is enabled by default.}
1339 %</en>
1340 %<*ja>
1341 \LaTeXe 環境下での標準設定のように,明朝体・ゴシック体を各1ウェイトで使用する.
1342 より具体的に言うと,この設定の下では
1343 \ \verb+\mcfamily\bfseries+, \verb+\gtfamily\bfseries+,
1344 \verb+\gtfamily\mdseries+はみな同じフォントとなる.
1345 \emph{このオプションは標準で有効になっている.}
1346 %</ja>
1347 \item[deluxe]
1348 %<*en>
1349 Use \textit{mincho} with two weights (medium~and~bold),
1350 \textit{gothic} with three weights (medium, bold~and~heavy), and \textit{rounded gothic}%
1351 \footnote{Provided by \cs{mgfamily} and \cs{textmg},
1352 because \textit{rounded gothic} is called \textit{maru gothic} (丸ゴシック) in Japanese.}.
1353 The heavy weight of \textit{gothic} can be used by ``changing the family'' \cs{gtebfamily},
1354 or \verb+\textgteb{...}+.
1355 This is because \Pkg{fontspec} package can handle only medium (\cs{mdseries}) and
1356 bold (\cs{bfseries}).
1357 %</en>
1358 %<*ja>
1359 明朝体2ウェイト・ゴシック体3ウェイトと,
1360 丸ゴシック体 (\cs{mgfamily}, \verb+\textmg{...}+) を使用可能とする.
1361 ゴシック体は細字・太字・極太の3ウェイトがあるが,
1362 極太ゴシック体はファミリの切り替え (\cs{gtebfamily}, \verb+\textgteb{...}+) %
1363 で実現している.\Pkg{fontspec}では通常 (\cs{mdseries}) と太字 (\cs{bfseries}) しか扱えないために
1364 このような中途半端な実装になっている.
1365 %</ja>
1366 \item[expert]
1367 %<*en>
1368 Use horizontal/vertical kana alternates, and define a command \cs{rubyfamily} to use kana
1369 characters designed for ruby.
1370 %</en>
1371 %<ja>横組・縦組専用仮名を用いる.また,\cs{rubyfamily} でルビ用仮名が使用可能となる.
1372 \item[bold]
1373 %<en>Substitute bold series of \textit{gothic} for  bold series of \textit{mincho}.
1374 %<ja>「明朝の太字」をゴシック体の太字によって代替する.
1375 \item[90jis]
1376 %<en>Use 90JIS glyph variants if possible.
1377 %<ja>出来る限り90JISの字形を使う.
1378 \item[jis2004]
1379 %<en>Use JIS2004 glyph variants if possible.
1380 %<ja>出来る限りJIS2004の字形を使う.
1381 \item[jis]
1382 %<*en>
1383 Use the JFM \texttt{jfm-jis.lua}, instead of \texttt{jfm-ujis.lua}, which is the default JFM of
1384 \LuaTeX-ja.
1385 %</en>
1386 %<*ja>
1387 用いるJFMを(JISフォントメトリック類似の)\texttt{jfm-jis.lua}にする.このオプションがない時は
1388 \LuaTeX-ja標準の\texttt{jfm-ujis.lua}が用いられる.
1389 %</ja>
1390 \end{cslist}
1391 %<*en>
1392 Note that \texttt{90jis} and \texttt{jis2004} only affect with \textit{mincho},
1393 \textit{gothic} (and possibly \textit{rounded gothic}) defined by this package.
1394 We didn't taken account of  when both \texttt{90jis} and \texttt{jis2004} are specified.
1395 %</en>
1396 %<*ja>
1397 \texttt{90jis}と\texttt{jis2004}については本パッケージで定義された
1398 明朝体・ゴシック体(・丸ゴシック体)にのみ有効である.両オプションが
1399 同時に指定された場合の動作については全く考慮していない.
1400 %</ja>
1401
1402 %<en>\paragraph{Presets for multi weight}
1403 %<ja>\paragraph{多ウェイト用プリセットの一覧}
1404 %<*en>
1405 Besides \texttt{morisawa-pro}~and~\texttt{morisawa-pr6n} presets,
1406 fonts are specified by font name, not by file name.
1407 %</en>
1408 %<*ja>
1409 \texttt{morisawa-pro}, \texttt{morisawa-pr6n}以外はフォントの指定は
1410 (ファイル名でなく)フォント名で行われる.
1411 %</ja>
1412 \begin{cslist}[style=standard]
1413  \item[kozuka-pro] Kozuka Pro (Adobe-Japan1-4) fonts.
1414 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
1415  \item[kozuka-pr6] Kozuka Pr6 (Adobe-Japan1-6)  fonts.
1416 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
1417  \item[kozuka-pr6n] Kozuka Pr6N (Adobe-Japan1-6, JIS04-savvy) fonts.
1418
1419 %<*en>
1420 Kozuka Pro/Pr6N fonts are bundled with Adobe's software, such as Adobe~InDesign.
1421 There is not rounded gothic family in Kozuka fonts.
1422 %</en>
1423 %<*ja>
1424 小塚Pro書体・Pr6N書体はAdobe InDesign等のAdobe製品にバンドルされている.
1425 「小塚丸ゴシック」は存在しないので,便宜的に小塚ゴシックHによって代用している.
1426 %</ja>
1427 \begin{center}\small
1428 \begin{tabular}{cllll}
1429 \toprule
1430 \bf family&\bf series&\tt kozuka-pro&\tt kozuka-pr6&\tt kozuka-pr6n\\
1431 \midrule
1432  &medium&KozMinPro-Regular&KozMinProVI-Regular&KozMinPr6N-Regular\\
1433 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
1434 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
1435  &bold&KozMinPro-Bold&KozMinProVI-Bold&KozMinPr6N-Bold\\
1436 \midrule
1437  &&KozGoPro-Regular*&KozGoProVI-Regular*&KozGoPr6N-Regular*\\
1438  &\smash{\raisebox{1.5ex}{medium}}
1439  &KozGoPro-Medium&KozGoProVI-Medium&KozGoPr6N-Medium\\
1440 \cmidrule(l){2-5}
1441 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
1442 %<ja>\smash{\raisebox{2ex}{\gt ゴシック}}%
1443  &bold&KozGoPro-Bold&KozGoProVI-Bold&KozGoPr6N-Bold\\
1444  &heavy&KozGoPro-Heavy&KozGoProVI-Heavy&KozGoPr6N-Heavy\\
1445 \midrule
1446 %<en>\textit{rounded gothic}
1447 %<ja>\gt 丸ゴシック
1448 &&KozGoPro-Heavy&KozGoProVI-Heavy&KozGoPr6N-Heavy\\
1449 \bottomrule
1450 \end{tabular}
1451 \end{center}
1452
1453 %<*en>
1454 In above table, starred fonts (KozGo\dots-Regular) are used for medium series of \textit{gothic},
1455 \emph{if and only if \texttt{deluxe} option is specified}.
1456 %</en>
1457 %<*ja>
1458 上の表において,*つきのフォント(KozGo\dots-Regular)は,\emph{\texttt{deluxe}オプション非指定時に}
1459 ゴシック体細字として用いられる.
1460 %</ja>
1461
1462 %<ja>\medskip
1463
1464  \item[hiragino-pro]  Hiragino Pro (Adobe-Japan1-5) fonts.
1465 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
1466  \item[hiragino-pron] Hiragino ProN (Adobe-Japan1-5, JIS04-savvy) fonts.
1467
1468 %<*en>
1469 Hiragino fonts are bundled with Mac OS~X 10.5 or later.
1470 Some editions of a Japanese word-processor ``一太郎2012'' includes Hiragino ProN fonts.
1471 Note that the heavy weight of \textit{gothic} family only supports
1472 Adobe-Japan1-3 character collection (Std/StdN).
1473 %</en>
1474 %<*ja>
1475 ヒラギノフォントは,Mac OS~X以外にも,一太郎2012の上位エディションにもバンドルされている.
1476 極太ゴシックとして用いるヒラギノ角ゴW8は,Adobe-Japan1-3の範囲しかカバーしていない
1477 Std/StdNフォントであり,その他はAdobe-Japan1-5対応である.
1478 %</ja>
1479 \begin{center}\small
1480 \begin{tabular}{clll}
1481 \toprule
1482 \bf family&\bf series&\tt hiragino-pro&\tt hiragino-pron\\
1483 \midrule
1484  &medium&Hiragino~Mincho~Pro~W3&Hiragino~Mincho~ProN~W3\\
1485 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
1486 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
1487  &bold&Hiragino~Mincho~Pro~W6&Hiragino~Mincho~ProN~W6\\
1488 \midrule
1489  &&Hiragino~Kaku~Gothic~Pro~W3*&Hiragino~Kaku~Gothic~ProN~W3*\\
1490  &\smash{\raisebox{1.5ex}{medium}}
1491  &Hiragino~Kaku~Gothic~Pro~W6&Hiragino~Kaku~Gothic~ProN~W6\\
1492 \cmidrule(l){2-4}
1493 %<en>\smash{\raisebox{2ex}{\textit{gothic}}}%
1494 %<ja>\smash{\raisebox{2ex}{\gt ゴシック}}%
1495  &bold&Hiragino~Kaku~Gothic~Pro~W6&Hiragino~Kaku~Gothic~ProN~W6\\
1496  &heavy&Hiragino~Kaku~Gothic~Std~W8&Hiragino~Kaku~Gothic~StdN~W8\\
1497 \midrule
1498 %<en>\textit{rounded gothic}
1499 %<ja>\gt 丸ゴシック
1500 &&Hiragino~Maru~Gothic~ProN~W4&Hiragino~Maru~Gothic~ProN~W4\\
1501 \bottomrule
1502 \end{tabular}
1503 \end{center}
1504
1505 %<ja>\newpage
1506
1507  \item[morisawa-pro]  Morisawa Pro (Adobe-Japan1-4) fonts.
1508 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
1509  \item[morisawa-pr6n]  Morisawa Pr6N (Adobe-Japan1-6, JIS04-savvy) fonts.
1510
1511 \begin{center}\small
1512 \begin{tabular}{cl>{\tt}l>{\tt}l}
1513 \toprule
1514 \bf family&\bf series&morisawa-pro&morisawa-pr6n\\
1515 \midrule
1516  &medium&A-OTF-RyuminPro-Light.otf&A-OTF-RyuminPr6N-Light.otf\\
1517 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
1518 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
1519  &bold&A-OTF-FutoMinA101Pro-Bold.otf&A-OTF-FutoMinA101Pr6N-Bold.otf\\
1520 \midrule
1521  &medium
1522  &A-OTF-GothicBBBPro-Medium.otf&A-OTF-GothicBBBPr6N-Medium.otf\\
1523 %<en>\textit{gothic}%
1524 %<ja>\gt ゴシック
1525  &bold&A-OTF-FutoGoB101Pro-Bold.otf&A-OTF-FutoGoB101Pr6N-Bold.otf\\
1526  &heavy&A-OTF-MidashiGoPro-MB31.otf&A-OTF-MidashiGoPr6N-MB31.otf\\
1527 \midrule
1528 %<en>\textit{rounded gothic}
1529 %<ja>\gt 丸ゴシック
1530 &&A-OTF-Jun101Pro-Light.otf&A-OTF-ShinMGoPr6N-Light.otf\\
1531 \bottomrule
1532 \end{tabular}
1533 \end{center}
1534
1535  \item[yu-win]  Yu fonts bundled with Windows~8.1.
1536 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
1537  \item[yu-osx]  Yu fonts bundled with OSX~Mavericks.
1538
1539 \begin{center}\small
1540 \begin{tabular}{clll}
1541 \toprule
1542 \bf family&\bf series&\tt yu-win&\tt yu-osx\\
1543 \midrule
1544  &medium&YuMincho-Regular&YuMincho~Medium\\
1545 %<en>\smash{\raisebox{1.5ex}{\textit{mincho}}}%
1546 %<ja>\smash{\raisebox{1.5ex}{\gt 明朝}}%
1547  &bold&YuMincho-Demibold&YuMincho~Demibold\\
1548 \midrule
1549  &&YuGothic-Regular*&YuGothic~Medium*\\
1550  &\smash{\raisebox{1.5ex}{medium}}
1551  &YuGothic-Bold&YuGothic~Bold\\
1552 \cmidrule(l){2-4}
1553 %<en>\textit{gothic}%
1554 %<ja>\gt ゴシック
1555  &bold&YuGothic-Bold&YuGothic~Bold\\
1556  &heavy&YuGothic-Bold&YuGothic~Bold\\
1557 \midrule
1558 %<en>\textit{rounded gothic}
1559 %<ja>\gt 丸ゴシック
1560 &&YuGothic-Bold&YuGothic~Bold\\
1561 \bottomrule
1562 \end{tabular}
1563 \end{center}
1564
1565 \end{cslist}
1566 %<en>\paragraph{Presets for single weight}
1567 %<ja>\paragraph{単ウェイト用プリセット一覧}
1568 %<*en>
1569 Next, we describe settings for using only single weight.
1570 In four settings below, we use same fonts for medium and bold (and heavy) weights.
1571 (Hence \verb+\mcfamily\bfseries+ and \verb+\mcfamily\mdseries+ yields same Japanese fonts,
1572 even if \texttt{deluxe} option is also specified).
1573 %</en>
1574 %<*ja>
1575 次に,単ウェイト用の設定を述べる.この4設定では「細字」「太字」の区別はない.
1576 また,丸ゴシック体はゴシック体と同じフォントを用いる.
1577 %</ja>
1578 \par\nobreak\medskip
1579 {\centering\small
1580 \begin{tabular}{lllll}
1581 \toprule
1582 &\tt noembed&\tt ipa&\tt ipaex&\tt ms\\
1583 \midrule
1584 %<*en>
1585 \it mincho&Ryumin-Light (non-embedded)
1586 &IPA Mincho&IPAex Mincho&MS Mincho\\
1587 \it gothic&GothicBBB-Medium (non-embedded)
1588 &IPA Gothic&IPAex Gothic&MS Gothic\\
1589 %</en>
1590 %<*ja>
1591 \gtfamily 明朝体&Ryumin-Light(非埋込)
1592 &IPA明朝&IPAex明朝&MS明朝\\
1593 \gtfamily ゴシック体&GothicBBB-Medium(非埋込)
1594 &IPAゴシック&IPAexゴシック&MSゴシック\\
1595 %</ja>
1596 \bottomrule
1597 \end{tabular}\par\medskip}
1598
1599 %<en>\paragraph{Using HG fonts}
1600 %<ja>\paragraph{HGフォントの利用}
1601 %<*en>
1602 We can use HG~fonts bundled with Microsoft~Office for realizing multiple weights.
1603 %</en>
1604 %<*ja>
1605 すぐ前に書いた単ウェイト用設定を,Microsoft Office等に付属するHGフォントを使って
1606 多ウェイト化した設定もある.
1607 %</ja>
1608 \par\nobreak\medskip
1609 {\centering\small
1610 \begin{tabular}{llll}
1611 \toprule
1612 &\tt ipa-hg&\tt ipaex-hg&\tt ms-hg\\
1613 \midrule
1614 %<*en>
1615 \bf mincho medium
1616 &IPA Mincho&IPAex Mincho&MS Mincho\\\midrule
1617 \bf mincho bold&
1618 \multicolumn{3}{c}{HG Mincho E}\\\midrule
1619 \bf Gothic medium\\
1620 ~~without \texttt{deluxe}
1621 &IPA Gothic&IPAex Gothic&MS Gothic\\
1622 ~~with {\tt jis2004}
1623 &IPA Gothic&IPAex Gothic&MS Gothic\\
1624 \cmidrule(lr){1-4}
1625 ~~otherwise&
1626 \multicolumn{3}{c}{HG Gothic M}\\\midrule
1627 \bf gothic bold&
1628 \multicolumn{3}{c}{HG Gothic E}\\\midrule
1629 \bf gothic heavy&
1630 \multicolumn{3}{c}{HG Soei Kaku Gothic UB}\\\midrule
1631 \bf rounded gothic&
1632 \multicolumn{3}{c}{HG Maru Gothic PRO}\\
1633 %</en>
1634 %<*ja>
1635 \gtfamily 明朝体細字
1636 &IPA明朝&IPAex明朝&MS明朝\\\midrule
1637 \gtfamily 明朝体太字&
1638 \multicolumn{3}{c}{HG明朝E}\\\midrule
1639 \gtfamily ゴシック体細字\\
1640  単ウェイト時
1641 &IPAゴシック&IPAexゴシック&MSゴシック\\
1642  {\tt jis2004}指定時
1643 &IPAゴシック&IPAexゴシック&MSゴシック\\
1644 \cmidrule(lr){1-4}
1645  それ以外の時&
1646 \multicolumn{3}{c}{HGゴシックM}\\\midrule
1647 \gtfamily ゴシック体太字&
1648 \multicolumn{3}{c}{HGゴシックE}\\\midrule
1649 \gtfamily ゴシック体極太&
1650 \multicolumn{3}{c}{HG創英角ゴシックUB}\\\midrule
1651 \gtfamily 丸ゴシック体&
1652 \multicolumn{3}{c}{HG丸ゴシック体PRO}\\
1653 %</ja>
1654 \bottomrule
1655 \end{tabular}\par\medskip}
1656
1657 %<*en>
1658 Note that HG~Mincho~E, HG~Gothic~E, HG Soei Kaku Gothic UB, and HG Maru Gothic PRO
1659 are internally specified by:
1660 \begin{description}
1661 \item[default] by font name (\texttt{HGMinchoE}, etc.).
1662 \item[{\tt 90jis}] by file name (\texttt{hgrme.ttc}, \texttt{hgrge.ttc}, \texttt{hgrsgu.ttc}, \texttt{hgrsmp.ttf}).
1663 \item[{\tt jis2004}] by file name (\texttt{hgrme04.ttc}, \texttt{hgrge04.ttc}, \texttt{hgrsgu04.ttc}, \texttt{hgrsmp04.ttf}).
1664 \end{description}
1665 %</en>
1666 %<*ja>
1667 \newpage
1668 なお,HG明朝E・HGゴシックE・HG創英角ゴシックUB・HG丸ゴシック体PROの4つについては,内部で
1669 \begin{description}
1670 \item[標準] フォント名(\texttt{HGMinchoE} など)
1671 \item[{\tt 90jis}指定時] ファイル名 (%
1672 \texttt{hgrme.ttc}, \texttt{hgrge.ttc}, \texttt{hgrsgu.ttc}, \texttt{hgrsmp.ttf})
1673 \item[{\tt jis2004}指定時] ファイル名 (%
1674 \texttt{hgrme04.ttc}, \texttt{hgrge04.ttc}, \texttt{hgrsgu04.ttc}, \texttt{hgrsmp04.ttf})
1675 \end{description}
1676 として指定を行っているので注意すること.
1677 %</ja>
1678
1679
1680 %<*en>
1681 \subsection{\cs{CID}, \cs{UTF}, and macros in \Pkg{japanese-otf} package}
1682 Under \pLaTeX, \Pkg{japanese-otf} package (developed by Shuzaburo Saito) is
1683 used for typesetting characters which is in Adobe-Japan1-6 CID but not
1684 in JIS~X~0208. Since this package is widely used, \LuaTeX-ja
1685 supports some of functions in \Pkg{japanese-otf} package.
1686 If you want to use these functions, load \Pkg{luatexja-otf} package.
1687 %</en>
1688 %<*ja>
1689 \subsection{\cs{CID}, \cs{UTF}と\Pkg{otf}パッケージのマクロ}
1690 \pLaTeX では,JIS~X~0208にないAdobe-Japan1-6の文字を出力するために,
1691 齋藤修三郎氏による\Pkg{otf}パッケージが用いられていた.このパッケージは
1692 広く用いられているため,\LuaTeX-jaにおいても\Pkg{otf}パッケージの機能の
1693 一部をサポートしている.これらの機能を用いるためには\Pkg{luatexja-otf}パッケージ
1694 を読み込めばよい.
1695 %</ja>
1696
1697 \begin{LTXexample}
1698 \jfontspec{KozMinPr6N-Regular.otf}
1699 森\UTF{9DD7}外と内田百\UTF{9592}とが\UTF{9AD9}島屋に行く。
1700
1701 \CID{7652}飾区の\CID{13706}野家,
1702 \CID{1481}城市,葛西駅,
1703 高崎と\CID{8705}\UTF{FA11}
1704
1705 \aj半角{はんかくカタカナ}
1706 \end{LTXexample}
1707
1708 %<*ja>
1709 \Pkg{otf}パッケージでは,それぞれ次のようなオプションが存在した:
1710 \begin{cslist}
1711 \item[deluxe] 明朝体・ゴシック体各2ウェイトと,丸ゴシック体を扱えるようになる.
1712 \item[expert] 仮名が横組・縦組専用のものに切り替わり,ルビ用仮名も
1713 \ \cs{rubyfamily}\ によって扱えるようになる.
1714 \item[bold] ゴシック体を標準で太いウェイトのものに設定する.
1715 \end{cslist}
1716 しかしこれらのオプションは\Pkg{luatexja-otf}パッケージには存在しない.
1717 \Pkg{otf}パッケージが文書中で使用する和文用TFMを自前の物に置き換えていたのに対し,
1718 \Pkg{luatexja-otf}パッケージでは,そのようなことは行わないからである.
1719
1720 これら3オプションについては,
1721 \Pkg{luatexja-preset} パッケージにプリセットを使う時に一緒に指定するか,
1722 あるいは対応する内容を\ref{ssec-chgfnt}節,\ref{ssec-nfsspat}節 (NFSS2) や
1723 \ref{ssec-fontspec}節 (\Pkg{fontspec}) の方法で手動で指定する必要がある.
1724 %</ja>
1725
1726 %<en>\subsection{Changing default Japanese fonts}
1727 %<ja>\subsection{標準和文フォントの変更}
1728 \label{ssec-cfg}
1729 %<*en>
1730 If \texttt{luatexja.cfg} can be seen from \LuaTeX, \LuaTeX-ja automatically reads it.
1731 The main use of \texttt{luatexja.cfg} is for changing default Japanese fonts,
1732 when IPAex fonts cannot be installed in \TeX~system.
1733 One should not overuse this \texttt{luatexja.cfg}; fonts which will be used in
1734 a document should be specified in its source.
1735
1736 For example,
1737 \begin{lstlisting}
1738 \def\ltj@stdmcfont{IPAMincho}
1739 \def\ltj@stdgtfont{IPAGothic}
1740 \end{lstlisting}
1741 makes that IPA~Mincho and IPA~Gothic will be used as default Japanese fonts, instead of
1742 IPAex~Mincho and IPAex~Gothic.
1743
1744 For another example, the following two lines makes that
1745 non-embedded fonts Ryumin-Light~and~GothicBBB-Medium as default Japanese fonts
1746 (as the earlier version of \LuaTeX-ja):
1747 \begin{lstlisting}
1748 \def\ltj@stdmcfont{psft:Ryumin-Light}
1749 \def\ltj@stdgtfont{psft:GothicBBB-Medium}
1750 \end{lstlisting}
1751 %</en>
1752 %<*ja>
1753 \LuaTeX から見える位置に \texttt{luatexja.cfg} があれば,\LuaTeX-jaはそれを読み込む.
1754 このファイルを用いるとplain~\TeX, \LaTeXe における標準和文フォントを
1755 IPAex明朝・IPAexゴシックから変更することができる.
1756 しかし,基本的には\emph{文章中で用いるフォントは(例えば \Pkg{luatexja-preset} などで)
1757 文書ソース内で指定するべき}であり,この \texttt{luatexja.cfg} は,
1758 「IPAexフォントがインストールできない」など,IPAexフォントが使用できない場合にのみ
1759 応急処置的に用いるべきである.
1760
1761 例えば
1762 \begin{lstlisting}
1763 \def\ltj@stdmcfont{IPAMincho}
1764 \def\ltj@stdgtfont{IPAGothic}
1765 \end{lstlisting}
1766 と記述しておけば,標準和文フォントがIPA明朝・IPAゴシックへと変
1767 更される.
1768
1769
1770 なお,20140906.0以前のバージョンのように,
1771 Ryumin-Light, GothicBBB-Mediumという名前の非埋込フォントを用いる場合は
1772 \begin{lstlisting}
1773 \def\ltj@stdmcfont{psft:Ryumin-Light}
1774 \def\ltj@stdgtfont{psft:GothicBBB-Medium}
1775 \end{lstlisting}
1776 と記述すればよい.
1777 %</ja>
1778
1779
1780 %<en>\section{Changing Parameters}
1781 %<ja>\section{パラメータの変更}
1782
1783 %<*en>
1784 There are many parameters in \LuaTeX-ja. And due to the behavior of \LuaTeX,
1785 most of them are not stored as internal register of \TeX, but as an
1786 original storage system in \LuaTeX-ja. Hence, to assign or acquire those
1787 parameters, you have to use commands \cs{ltjsetparameter} and
1788 \cs{ltjgetparameter}.
1789 %</en>
1790 %<*ja>
1791 \LuaTeX-jaには多くのパラメータが存在する.そして\LuaTeX の仕様のために,
1792 その多くは\TeX のレジスタにではなく,\LuaTeX-ja独自の方法で保持されている.
1793 これらのパラメータを設定・取得するためには \cs{ltjsetparameter} と \cs{ltjgetparameter} を
1794 用いる.
1795 %</ja>
1796
1797 %<en>\subsection{Editing the Range of \textbf{JAchar}s}
1798 %<ja>\subsection{\textbf{JAchar}の範囲の設定}
1799 \label{ssec-setrange}
1800
1801 %<*en>
1802 \LuaTeX-ja divides the Unicode codespace \texttt{U+0080}--\texttt{U+10FFFF}
1803 into \emph{character ranges},
1804 numbered 1 to 217. The grouping can be (globally) customized by \cs{ltjdefcharrange}.
1805 The next line adds whole characters in Supplementary Ideographic Plane
1806 and the character ``漢'' to the character range~100.
1807 %</en>
1808 %<*ja>
1809 \LuaTeX-jaは,Unicodeの \texttt{U+0080}--\texttt{U+10FFFF} の空間を
1810 1番から217番までの\emph{文字範囲}に分割している.
1811 区分けは \cs{ltjdefcharrange} を用いることで(グローバルに)変更することができ,
1812 例えば,次は追加漢字面(SIP)にある全ての文字と「漢」を「100番の文字範囲」に追加する.
1813 %</ja>
1814 \begin{lstlisting}
1815 \ltjdefcharrange{100}{"20000-"2FFFF,`漢}
1816 \end{lstlisting}
1817 %<*en>
1818 A character can belong to only one character range.
1819 For example, whole SIP belong to the range~4 in the default setting of \LuaTeX-ja,
1820 and if you execute the above line, then SIP will belong to the range~100 and be
1821 removed from the range~4.
1822 %</en>
1823 %<*ja>
1824 各文字はただ一つの文字範囲に所属することができる.
1825 例えば,SIPは全て\LuaTeX-jaのデフォルトでは4番の文字範囲に
1826 属しているが,上記の指定を行えばSIPは100番に属すようになり,4番からは除かれる.
1827 %</ja>
1828
1829 %<*en>
1830 The distinction between \textbf{ALchar} and \textbf{JAchar} is done for character ranges.
1831 This can be edited by setting the \textsf{jacharrange} parameter.
1832 For example, this is just the default setting of \LuaTeX-ja, and
1833 it sets
1834 \begin{itemize}
1835  \item a character which belongs character ranges 1,~4, and~5 is \textbf{ALchar},
1836  \item a character which belongs character ranges 2,~3, 6, 7, and~8 is \textbf{JAchar}.
1837 \end{itemize}
1838 %</en>
1839 %<*ja>
1840 \textbf{ALchar}と\textbf{JAchar}の区別は文字範囲ごとに行われる.
1841 これは\textsf{jacharrange}パラメータによって編集できる.
1842 例えば,以下は\LuaTeX-jaの初期設定であり,次の内容を設定している:
1843 \begin{itemize}
1844  \item 1番,4番,5番の文字範囲に属する文字は\textbf{ALchar}.
1845  \item 2番,3番,6番,7番,8番の文字範囲に属する文字は\textbf{JAchar}.
1846 \end{itemize}
1847 %</ja>
1848 \begin{lstlisting}
1849 \ltjsetparameter{jacharrange={-1, +2, +3, -4, -5, +6, +7, +8}}
1850 \end{lstlisting}
1851 %<*en>
1852 The argument to \textsf{jacharrange} parameter is a list of non-zero integer.
1853 Negative integer $-n$ in the list means that ``each character in the range~$n$ is an
1854 \textbf{ALchar}'',
1855 and positive integer $+n$ means that ``\dots\ is a \textbf{JAchar}''.
1856 %</en>
1857 %<*ja>
1858 \textsf{jacharrange}パラメータの引数は非零の整数のリストである.
1859 リスト中の負の整数$-n$は「文字範囲$n$に属する文字は\textbf{ALchar}として
1860 扱う」ことを意味し,正の整数$+n$は「\textbf{JAchar}として扱う」ことを意味する.
1861 %</ja>
1862
1863 %<*en>
1864 \paragraph{Default setting}
1865 \LuaTeX-ja predefines eight character ranges for convenience. They are
1866 determined from the following data:
1867 %</en>
1868 %<*ja>
1869 \paragraph{初期設定}
1870 \LuaTeX-jaでは8つの文字範囲を予め定義しており,
1871 これらは以下のデータに基づいて決定している.
1872 %</ja>
1873 \begin{itemize}
1874 %<en>\item Blocks in Unicode~6.0.
1875 %<ja>\item Unicode~6.0のブロック.
1876 %<en>\item The \texttt{Adobe-Japan1-UCS2} mapping between a CID Adobe-Japan1-6 and Unicode.
1877 %<ja>\item Adobe-Japan1-6のCIDとUnicodeの間の対応表\texttt{Adobe-Japan1-UCS2}.
1878 %<en>\item The \Pkg{PXbase} bundle for \upTeX\ by Takayuki Yato.
1879 %<ja>\item 八登崇之氏による\upTeX 用の\Pkg{PXbase}バンドル.
1880 \end{itemize}
1881
1882 %<*en>
1883 Now we describe these eight ranges. The superscript ``J'' or ``A'' after the
1884 number shows whether each character in the range is treated as
1885 \textbf{JAchar}s or not by default. These settings are similar to the
1886 \texttt{prefercjk} settings defined in \texttt{PXbase} bundle.
1887 Any characters above \texttt{U+0080} which does not belong to
1888 these eight ranges belongs to the character range~217.
1889 %</en>
1890 %<*ja>
1891 以下ではこれら8つの文字範囲について記述する.添字のアルファベット「J」「A」
1892 は,その文字範囲内の文字が\textbf{JAchar}か\textbf{ALchar}かを表している.これらの設定は
1893 \texttt{PXbase}バンドルで定義されている\texttt{prefercjk}と類似のものである.
1894 なお,\texttt{U+0080} 以降でこれら8つの文字範囲に属さない文字は,217番の文字範囲に属することになっている.
1895 %</ja>
1896 \begin{description}
1897 %<*en>
1898
1899 \item[Range~8${}^{\text{J}}$] The intersection of the upper half of ISO~8859-1
1900          (Latin-1 Supplement) and JIS~X~0208 (a basic character set for Japanese). This character range
1901          consists of the following characters:
1902 %</en>
1903 %<*ja>
1904 \item[範囲8${}^{\text{J}}$] ISO~8859-1の上位領域(ラテン1補助)と
1905                              JIS~X~0208の共通部分.この文字範囲は
1906                              以下の文字で構成される:
1907 %</ja>
1908 \begin{multicols}{2}
1909 \begin{itemize}
1910 \def\ch#1#2{\item \char"#1\ (\texttt{U+00#1}, #2)}%"
1911 \ch{A7}{Section Sign}
1912 \ch{A8}{Diaeresis}
1913 \ch{B0}{Degree sign}
1914 \ch{B1}{Plus-minus sign}
1915 \ch{B4}{Spacing acute}
1916 \ch{B6}{Paragraph sign}
1917 \ch{D7}{Multiplication sign}
1918 \ch{F7}{Division Sign}
1919 \end{itemize}
1920 \end{multicols}
1921
1922 %<*en>
1923 \item[Range~1${}^{\text{A}}$] Latin characters that some of them are included in Adobe-Japan1-6.
1924 This range consists of the following Unicode ranges, \emph{except characters in the range~8 above}:
1925 %</en>
1926 %<*ja>
1927 \item[範囲1${}^{\text{A}}$] ラテン文字のうち,Adobe-Japan1-6との共通部分があるもの.
1928                              この範囲は以下のUnicodeのブロックのうち
1929                              \emph{範囲8を除いた}部分で構成されている:
1930 %</ja>
1931 \begin{multicols}{2}
1932 \begin{itemize}
1933 \item \texttt{U+0080}--\texttt{U+00FF}: Latin-1 Supplement
1934 \item \texttt{U+0100}--\texttt{U+017F}: Latin Extended-A
1935 \item \texttt{U+0180}--\texttt{U+024F}: Latin Extended-B
1936 \item \texttt{U+0250}--\texttt{U+02AF}: IPA Extensions
1937 \item \texttt{U+02B0}--\texttt{U+02FF}: Spacing Modifier Letters
1938 \item \texttt{U+0300}--\texttt{U+036F}: \\\null\hfill Combining Diacritical Marks
1939 \item \texttt{U+1E00}--\texttt{U+1EFF}: \\\null\hfill Latin Extended Additional
1940 \par\
1941 \end{itemize}
1942 \end{multicols}
1943 %<*en>
1944 \item[Range~2${}^{\text{J}}$] Greek and Cyrillic letters. JIS~X~0208 (hence most of Japanese
1945            fonts) has some of these characters.
1946 %</en>
1947 %<*ja>
1948 \item[範囲2${}^{\text{J}}$] ギリシャ文字とキリル文字.JIS~X~0208(したがってほとんどの
1949                              和文フォント)はこれらの文字を持つ.
1950 %</ja>
1951 \begin{multicols}{2}
1952 \begin{itemize}
1953 \item \texttt{U+0370}--\texttt{U+03FF}: Greek and Coptic
1954 \item \texttt{U+0400}--\texttt{U+04FF}: Cyrillic
1955 \item \texttt{U+1F00}--\texttt{U+1FFF}: Greek Extended
1956 \\\
1957 \end{itemize}
1958 \end{multicols}
1959 %<*en>
1960 \item[Range~3${}^{\text{J}}$] Punctuations and Miscellaneous symbols. The block list is
1961            indicated in Table~\ref{table-rng3}.
1962 %</en>
1963 %<*ja>
1964 \item[範囲3${}^{\text{J}}$] 句読点と記号類.ブロックのリストは表\ref{table-rng3}%
1965                              に示してある.
1966 %</ja>
1967 \begin{table}[!tb]
1968 %<en>\caption{Unicode blocks in predefined character range~3.}\medskip
1969 %<ja>\caption{文字範囲3に指定されているUnicodeブロック.}
1970 \label{table-rng3}
1971 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
1972 \centering\small
1973 \begin{tabular}{llll}
1974 "2000--"206F&General Punctuation&
1975 "2070--"209F&Superscripts and Subscripts\\
1976 "20A0--"20CF&Currency Symbols&
1977 "20D0--"20FF&Comb.\ Diacritical Marks for Symbols\\
1978 "2100--"214F&Letterlike Symbols&
1979 "2150--"218F&Number Forms\\
1980 "2190--"21FF&Arrows&
1981 "2200--"22FF&Mathematical Operators\\
1982 "2300--"23FF&Miscellaneous Technical&
1983 "2400--"243F&Control Pictures\\
1984 "2500--"257F&Box Drawing&
1985 "2580--"259F&Block Elements\\
1986 "25A0--"25FF&Geometric Shapes&
1987 "2600--"26FF&Miscellaneous Symbols\\
1988 "2700--"27BF&Dingbats&
1989 "2900--"297F&Supplemental Arrows-B\\
1990 "2980--"29FF&Misc.\ Mathematical Symbols-B&
1991 "2B00--"2BFF&Miscellaneous Symbols and Arrows
1992 \end{tabular}
1993 \end{table}
1994 %<*en>
1995 \item[Range~4${}^{\text{A}}$] Characters usually not in Japanese fonts. This range consists
1996            of almost all Unicode blocks which are not in other
1997            predefined ranges. Hence, instead of showing the block list,
1998            we put the definition of this range itself:
1999 %</en>
2000 %<*ja>
2001 \item[範囲4${}^{\text{A}}$] 通常和文フォントには含まれていない文字.
2002                              この範囲は他の範囲にないほとんど全てのUnicodeブロック
2003                              で構成されている.したがって,ブロックのリストを示す
2004                              代わりに,範囲の定義そのものを示す:
2005 %</ja>
2006 \begin{lstlisting}
2007 \ltjdefcharrange{4}{%
2008    "500-"10FF, "1200-"1DFF, "2440-"245F, "27C0-"28FF, "2A00-"2AFF,
2009   "2C00-"2E7F, "4DC0-"4DFF, "A4D0-"A82F, "A840-"ABFF, "FB00-"FE0F,
2010   "FE20-"FE2F, "FE70-"FEFF, "10000-"1FFFF, "E000-"F8FF} % non-Japanese
2011 \end{lstlisting}
2012 %<en>\item[Range~5${}^{\text{A}}$] Surrogates and Supplementary Private Use Areas.
2013 %<ja>\item[範囲5${}^{\text{A}}$] 代用符号と補助私用領域.
2014 %<en>\item[Range~6${}^{\text{J}}$] Characters used in Japanese. The block list is indicated in Table~\ref{table-rng6}.
2015 %<ja>\item[範囲6${}^{\text{J}}$] 日本語で用いられる文字.ブロックのリストは表\ref{table-rng6}に示す.
2016 \begin{table}[!tb]
2017 %<en>\caption{Unicode blocks in predefined character range~6.}\medskip
2018 %<ja>\caption{文字範囲6に指定されているUnicodeブロック.}
2019 \label{table-rng6}
2020 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
2021 \centering\small
2022 \begin{tabular}{llll}
2023 "2460--"24FF&Enclosed Alphanumerics&
2024 "2E80--"2EFF&CJK Radicals Supplement\\
2025 "3000--"303F&CJK Symbols and Punctuation&
2026 "3040--"309F&Hiragana\\
2027 "30A0--"30FF&Katakana&
2028 "3190--"319F&Kanbun\\
2029 "31F0--"31FF&Katakana Phonetic Extensions&
2030 "3200--"32FF&Enclosed CJK Letters and Months\\
2031 "3300--"33FF&CJK Compatibility&
2032 "3400--"4DBF&CJK Unified Ideographs Extension A\\
2033 "4E00--"9FFF&CJK Unified Ideographs&
2034 "F900--"FAFF&CJK Compatibility Ideographs\\
2035 "FE10--"FE1F&Vertical Forms&
2036 "FE30--"FE4F&CJK Compatibility Forms\\
2037 "FE50--"FE6F&Small Form Variants&
2038 "{20}000--"{2F}FFF&(Supplementary Ideographic Plane)\\
2039 "{E0}100--"{E0}1EF&Variation Selectors Supplement
2040 \end{tabular}
2041 \end{table}
2042 %<*en>
2043 \item[Range~7${}^{\text{J}}$] Characters used in CJK languages, but not included in  Adobe-Japan1-6.
2044 The block list is indicated in Table~\ref{table-rng7}.
2045 %</en>
2046 %<*ja>
2047 \item[範囲7${}^{\text{J}}$] CJK言語で用いられる文字のうち,Adobe-Japan1-6に
2048                             含まれていないもの.
2049                             ブロックのリストは表\ref{table-rng7}に示す.
2050 %</ja>
2051 \begin{table}[!tb]
2052 %<en>\caption{Unicode blocks in predefined character range~7.}\medskip
2053 %<ja>\caption{文字範囲7に指定されているUnicodeブロック.}
2054 \label{table-rng7}
2055 \catcode`\"=13\def"#1#2#3#4{\texttt{U+#1#2#3#4}}%"
2056 \centering\small
2057 \begin{tabular}{llll}
2058 "1100--"11FF&Hangul Jamo&
2059 "2F00--"2FDF&Kangxi Radicals\\
2060 "2FF0--"2FFF&Ideographic Description Characters&
2061 "3100--"312F&Bopomofo\\
2062 "3130--"318F&Hangul Compatibility Jamo&
2063 "31A0--"31BF&Bopomofo Extended\\
2064 "31C0--"31EF&CJK Strokes&
2065 "A000--"A48F&Yi Syllables\\
2066 "A490--"A4CF&Yi Radicals&
2067 "A830--"A83F&Common Indic Number Forms\\
2068 "AC00--"D7AF&Hangul Syllables&
2069 "D7B0--"D7FF&Hangul Jamo Extended-B
2070 \end{tabular}
2071 \end{table}
2072 \end{description}
2073
2074 %<en>\subsection{\Param{kanjiskip} and \Param{xkanjiskip}}
2075 %<ja>\subsection{\Param{kanjiskip}と\Param{xkanjiskip}}
2076 \label{subs-kskip}
2077
2078 %<en>\textbf{JAglue} is divided into the following three categories:
2079 %<ja>\textbf{JAglue}は以下の3つのカテゴリに分類される:
2080 \begin{itemize}
2081 %<*en>
2082 \item Glues/kerns specified in JFM. If \cs{inhibitglue} is issued
2083       around a Japanese character, this glue will not be inserted at the
2084       place.
2085 %</en>
2086 %<*ja>
2087 \item JFMで指定されたグルー/カーン.もし \cs{inhibitglue} が和文文字の周りで
2088       発行されていれば,このグルーは挿入されない.
2089 %</ja>
2090 %<*en>
2091 \item The default glue which inserted between two \textbf{JAchar}s (\Param{%
2092       kanjiskip}).
2093 %</en>
2094 %<*ja>
2095 \item デフォルトで2つの\textbf{JAchar}の間に挿入されるグルー(\Param{kanjiskip}).
2096 %</ja>
2097 %<*en>
2098 \item The default glue which inserted between a \textbf{JAchar} and an
2099       \textbf{ALchar} (\Param{xkanjiskip}).
2100 %</en>
2101 %<*ja>
2102 \item デフォルトで\textbf{JAchar}と\textbf{ALchar}の間に挿入されるグルー(\Param{xkanjiskip}).
2103 %</ja>
2104 \end{itemize}
2105 %<*en>
2106 The value (a skip) of \Param{kanjiskip} or
2107 \Param{xkanjiskip} can be changed as the following.
2108 Note that only their values \emph{at the end of a paragraph or a hbox are
2109 adopted in the whole paragraph or the whole hbox.
2110 }
2111 %</en>
2112 %<*ja>
2113 \Param{kanjiskip}や\Param{xkanjiskip}の値
2114 は以下のようにして変更可能である.
2115 %</ja>
2116 \begin{lstlisting}
2117 \ltjsetparameter{kanjiskip={0pt plus 0.4pt minus 0.4pt},
2118                  xkanjiskip={0.25\zw plus 1pt minus 1pt}}
2119 \end{lstlisting}
2120 %<*en>
2121 Here \cs{zw} is a internal dimension
2122 which stores fullwidth of the current Japanese font.
2123 This \cs{zw} can be used as the unit \texttt{zw} in \pTeX.
2124
2125 The value of these parameter can be get by \cs{ltjgetparameter}.
2126 Note that the result by \cs{ltjgetparameter} is \emph{not} the internal quantities,
2127 but \emph{a string} (hence \cs{the} cannot be prefixed).
2128 %</en>
2129 %<*ja>
2130 ここで,\cs{zw} は現在の和文フォントの全角幅を表す長さであり,
2131 \pTeX における長さ単位 \texttt{zw} と同じように使用できる.
2132
2133 これらのパラメータの値は以下のように取得できる.
2134 戻り値は内部値ではなく\emph{文字列}である(\cs{the} は前置できない)ことに注意してほしい:
2135 %</ja>
2136 \begin{LTXexample}
2137 kanjiskip: \ltjgetparameter{kanjiskip},\\
2138 xkanjiskip: \ltjgetparameter{xkanjiskip}
2139 \end{LTXexample}
2140
2141 %<*en>
2142 It may occur that JFM contains the data of ``ideal width of
2143 \Param{kanjiskip}''
2144 and/or ``ideal width of \Param{xkanjiskip}''.
2145 To use these data from JFM, set the value of \Param{kanjiskip} or
2146 \Param{xkanjiskip} to \cs{maxdimen}
2147 (these ``ideal width'' cannot be retrived by \cs{ltjgetparameter}).
2148 %</en>
2149 %<*ja>
2150 JFMは「望ましい\Param{kanjiskip}の値」や
2151 「望ましい\Param{xkanjiskip}の値」を持っていることがある.
2152 これらのデータを使うためには,\Param{kanjiskip}や%
2153 \Param{xkanjiskip}の値を \cs{maxdimen} の値に設定すればよいが,
2154 \cs{ltjgetparameter} によって取得することはできないので注意が必要である.
2155 %</ja>
2156
2157 %<en>\subsection{Insertion Setting of \Param{xkanjiskip}}
2158 %<ja>\subsection{\Param{xkanjiskip} の挿入設定}
2159
2160 %<*en>
2161 It is not desirable that \Param{xkanjiskip} is inserted into every
2162 boundary between \textbf{JAchar}s and \textbf{ALchar}s. For example,
2163 \Param{xkanjiskip} should not be inserted after opening parenthesis
2164 (\textit{e.g.}, compare ``(あ'' and ``(\hskip\ltjgetparameter{xkanjiskip}あ'').
2165 \LuaTeX-ja can control whether \Param{xkanjiskip} can be inserted
2166 before/after a character, by changing \Param{jaxspmode} for \textbf{JAchar}s and
2167 \Param{alxspmode} parameters \textbf{ALchar}s respectively.
2168 %</en>
2169 %<*ja>
2170 \Param{xkanjiskip}がすべての\textbf{JAchar}と\textbf{ALchar}の境界に
2171 挿入されるのは望ましいことではない.例えば,\Param{xkanjiskip}は開き括弧の
2172 後には挿入されるべきではない(「(あ」と「(\hskip\ltjgetparameter{xkanjiskip}あ」を
2173 比べてみよ).
2174 \LuaTeX-jaでは\Param{xkanjiskip}をある文字の前/後に挿入するかどうかを,
2175 \textbf{JAchar}に対しては\Param{jaxspmode}を,\textbf{ALchar}に対しては
2176 \Param{alxspmode}をそれぞれ変えることで制御することができる.
2177 %</ja>
2178 \begin{LTXexample}
2179 \ltjsetparameter{jaxspmode={`あ,preonly}, alxspmode={`\!,postonly}}
2180 pあq い!う
2181 \end{LTXexample}
2182
2183 %<*en>
2184 The second argument \texttt{preonly} means that the insertion of
2185 \Param{xkanjiskip} is allowed before this character, but not after.
2186 the other possible values are \texttt{postonly}, \texttt{allow}, and \texttt{inhibit}.
2187 %</en>
2188 %<*ja>
2189 2つ目の引数の \texttt{preonly}は「\Param{xkanjiskip}の挿入はこの文字の
2190 前でのみ許され,後では許さない」ことを意味する.他に指定可能な値は
2191 \texttt{postonly}, \texttt{allow}, \texttt{inhibit}である.
2192 %</ja>
2193
2194 %<*en>
2195 \Param{jaxspmode} and \Param{alxspmode} use a same table to store the parameters
2196 on the current version. Therefore, line~1 in the code above can be rewritten
2197 as follows:
2198 %</en>
2199 %<*ja>
2200 なお,現行の
2201 仕様では,\Param{jaxspmode}, \Param{alxspmode}はテーブルを共有しており,
2202 上のコードの1行目を次のように変えても同じことになる:
2203 %</ja>
2204 \begin{lstlisting}
2205 \ltjsetparameter{alxspmode={`あ,preonly}, jaxspmode={`\!,postonly}}
2206 \end{lstlisting}
2207 %<*en>
2208 One can use also numbers to specify these two parameters (see Subsection~\ref{ssec-param}).
2209 %</en>
2210 %<*ja>
2211 また,これら2パラメータには数値で値を指定することもできる(\ref{ssec-param}節を参照).
2212 %</ja>
2213
2214 %<*en>
2215 If you want to enable/disable all insertions of \Param{kanjiskip} and
2216 \Param{xkanjiskip}, set \Param{autospacing} and \Param{autoxspacing}
2217 parameters to \texttt{true}/\texttt{false}, respectively.
2218 %</en>
2219 %<*ja>
2220 もし全ての\Param{kanjiskip}と\Param{xkanjiskip}の挿入を有効化/無効化
2221 したければ,それぞれ\Param{autospacing}と\Param{autoxspacing}を
2222 \texttt{true}/\texttt{false}に設定すればよい.
2223 %</ja>
2224
2225 %<en>\subsection{Shifting the baseline}
2226 %<ja>\subsection{ベースラインの移動}
2227 %<*en>
2228 To make a match between a Japanese font and an alphabetic font, sometimes
2229 shifting of the baseline of one of the pair is needed. In \pTeX, this is achieved
2230 by setting \cs{ybaselineshift} (or \cs{tbaselineshift}) to a non-zero length (the
2231 baseline of \textbf{ALchar} is shifted below). However, for documents
2232 whose main language is not Japanese, it is good to shift the baseline of
2233 Japanese fonts, but not that of alphabetic fonts.
2234 Because of this, \LuaTeX-ja can independently set the shifting amount
2235 of the baseline of alphabetic fonts and that of Japanese fonts.
2236 \begin{center}
2237  \small
2238 \begin{tabular}{>{\bfseries}lcc}
2239 \toprule
2240 &\bfseries Horizontal writing (\emph{yoko} direction) etc.
2241 &\bfseries Vertical writing(\emph{tate} direction)\\
2242 \midrule
2243 Alphabetic fonts&\Param{yalbaselineshift}
2244      parameter&\Param{talbaselineshift} parameter\\
2245 Japanese fonts&\Param{yjabaselineshift}
2246      parameter&\Param{tjabaselineshift} parameter\\
2247 \bottomrule
2248 \end{tabular}
2249 \end{center}
2250 %</en>
2251 %<*ja>
2252 和文フォントと欧文フォントを合わせるためには,時々どちらかのベースラインの移動が
2253 必要になる.\pTeX ではこれは \cs{ybaselineshift} を設定することで
2254 なされていた(\textbf{ALchar}のベースラインがその分だけ下がる).しかし,日本語が主ではない
2255 文書に対しては,欧文フォントではなく和文フォントのベースラインを移動した方がよい.
2256 このため,\LuaTeX-jaでは欧文フォントのベースラインのシフト量
2257 と和文フォントのベースラインのシフト量を独立に設定できるようになっている.
2258 \begin{center}
2259  \small
2260 \begin{tabular}{>{\bfseries}lcc}
2261 \toprule
2262 &\bfseries 横組など&\bfseries 縦組\\
2263 \midrule
2264 欧文フォントのシフト量&\Param{yalbaselineshift}
2265      parameter&\Param{talbaselineshift} parameter\\
2266 和文フォントのシフト量&\Param{yjabaselineshift}
2267      parameter&\Param{tjabaselineshift} parameter\\
2268 \bottomrule
2269 \end{tabular}
2270 \end{center}
2271 %</ja>
2272
2273 %<*en>
2274 Here the horizontal line in the below example is the baseline of a line.
2275 %</en>
2276 %<*ja>
2277 下の例において引かれている水平線がベースラインである.
2278 %</ja>
2279 \begin{LTXexample}
2280 \vrule width 150pt height 0.4pt depth 0pt \hskip-120pt
2281 \ltjsetparameter{yjabaselineshift=0pt, yalbaselineshift=0pt}abcあいう
2282 \ltjsetparameter{yjabaselineshift=5pt, yalbaselineshift=2pt}abcあいう
2283 \end{LTXexample}
2284
2285 %<*en>
2286 There is an interesting side-effect: characters in different size can be
2287 vertically aligned center in a line, by setting two parameters appropriately.
2288 The following is an example (beware the value is not well tuned):
2289 %</en>
2290 %<*ja>
2291 この機能には面白い使い方がある:2つのパラメータを適切に設定することで,サイズの
2292 異なる文字を中心線に揃えることができる.
2293 以下は一つの例である(値はあまり調整されていないことに注意):
2294 %</ja>
2295 \begin{LTXexample}
2296 xyz漢字
2297 {\scriptsize
2298   \ltjsetparameter{yjabaselineshift=-1pt,
2299     yalbaselineshift=-1pt}
2300   XYZひらがな
2301 }abcかな
2302 \end{LTXexample}
2303
2304 %<*en>
2305 Note that setting positive \Param{yalbaselineshift}~or~\Param{talbaselineshift}
2306 parameters does not increase the depth of one-letter ``syllable'' $p$ of \textbf{Alchar}, if
2307 its left-protrusion~(\cs{lpcode}) and right-protrusion~(\cs{rpcode}) are both non-zero.
2308 This is because
2309 \begin{itemize}
2310 \item These two parameters are implemented by setting yoffset field of a
2311 glyph node, and this does not increase the depth of the glyph.
2312 \item To cope with the above situation, \LuaTeX-ja automatically supplies
2313 a rule in every ``syllable''.
2314 \item However, we cannot use this ``supplying a rule'' method if \dots
2315 \end{itemize}
2316
2317 This problem does not apply for \Param{yjabaselineshift}~nor~\Param{tjabaselineshift}.
2318 %</en>
2319 %<*ja>
2320 なお,以下の場合には1文字の\textbf{ALchar}からなる「音節」の深さは増加しないことに注意.
2321 \begin{itemize}
2322  \item \Param{yalbaselineshift},~\Param{talbaselineshift}パラメータが正になっている.
2323  \item 「音節」を構成する唯一の文字$p$の
2324 左余白への突出量(\cs{lpcode}),右余白への突出量(\cs{rpcode})がどちらも非零である.
2325 \end{itemize}
2326 \Param{yjabaselineshift},~\Param{tjabaselineshift}パラメータについてはこのような問題は起こらない.
2327 %</ja>
2328
2329 %<*ja>
2330 \paragraph{数式における挙動:\pTeX との違い}
2331 \textbf{ALchar}のベースラインを補正する \Param{yalbaselineshift} パラメータは
2332 ほぼ\pTeX における \cs{ybaselineshift} に対応しているものであるが,
2333 数式中の挙動は異なっているので注意が必要である.
2334 例えば,表\ref{tab:math_bsa}のように,数式中に明示的に現れた \cs{hbox} は,
2335 \begin{itemize}
2336  \item \pTeX では,ボックス全体が \cs{ybaselineshift} だとシフトされるので,
2337  表\ref{tab:math_bsa}中の``い''のように,ボックス中の和文文字は
2338  \ \cs{ybaselineshift} だけシフトされ,一方,``for all''のように,
2339  ボックス内の欧文文字は2重にシフトされることになる.
2340  \item 一方,\LuaTeX-jaではそのようなことはおこらず,
2341  数式中に明示的に現れた \cs{hbox} はシフトしない.そのため,
2342  表\ref{tab:math_bsa}中の``い''も``for all''も,それぞれ本文中に
2343  書かれたときと同じ上下位置に組まれる.
2344 \end{itemize}
2345 \begin{table}
2346 \small\centering
2347 \caption{数式関係のベースライン補正($\Param{yalbaselineshift}=10\,\textrm{pt}$)}
2348 \label{tab:math_bsa}
2349 \newdimen\origbaselineskip
2350 \origbaselineskip=\baselineskip
2351 \begin{tabular}{lp{30\zw}}
2352 \toprule
2353 \emph{入力}&\vspace*{\dimexpr-\origbaselineskip-\smallskipamount}
2354 \begin{lstlisting}
2355 数式abc: $あa\hbox{い}$, $\int_0^x t\,dt=x^2\!/2$,
2356 $\Phi\vdash F(x)\ \hbox{for all}\ x\in A$
2357 \end{lstlisting}\\
2358 \noalign{\vskip-\origbaselineskip}
2359 \midrule
2360 \emph{\pTeX}&
2361 {\ltjsetparameter{yalbaselineshift=10pt}%
2362 数式abc: $あa\lower10pt\hbox{い}$, $\int_0^x t\,dt=x^2\!/2$,
2363 $\Phi\vdash F(x)\ \lower10pt\hbox{for all}\ x\in A$
2364 \par}\\
2365 \midrule
2366 \emph{\LuaTeX-ja}&
2367 {\ltjsetparameter{yalbaselineshift=10pt}%
2368 数式abc: $あa\hbox{い}$, $\int_0^x t\,dt=x^2\!/2$,
2369 $\Phi\vdash F(x)\ \hbox{for all}\ x\in A$
2370 \par}\\
2371 \noalign{\vskip-\origbaselineskip}
2372 \bottomrule
2373 \end{tabular}
2374 \end{table}
2375 %</ja>
2376
2377 \clearpage
2378 %<en>\part{Reference}
2379 %<ja>\part{リファレンス}
2380 \label{part-ref}
2381 \suppressfloats[t]
2382 %<*ja>
2383 \section{\LuaTeX-jaにおける \cs{catcode}}
2384 \label{sec-catcode}
2385 \subsection{予備知識:\pTeX と\upTeX における \cs{kcatcode}}
2386 \pTeX,\upTeX においては,和文文字が制御綴内で利用できるかどうか
2387 は \cs{kcatcode} の値によって決定されるのであった.
2388 詳細は表\ref{table-kcat}を参照されたい.
2389 %</ja>
2390 %<*en>
2391 \section{\cs{catcode} in \LuaTeX-ja}
2392 \label{sec-catcode}
2393 \subsection{Preliminaries: \cs{kcatcode} in \pTeX\ and \upTeX}
2394 In \pTeX~and~\upTeX, the value of \cs{kcatcode} determines
2395 whether a Japanese character can be used in a control word.
2396 For the detail, see Table~\ref{table-kcat}.
2397 %</en>
2398
2399 \begin{table}[t]
2400 \small
2401 \caption{\cs{kcatcode} in \upTeX}
2402 \label{table-kcat}
2403 %<en>\medskip
2404
2405 \noindent\hfill
2406 \begin{tabular}{ccccc}
2407 \toprule
2408 \bfseries \cs{kcatcode}&
2409 %<*en>
2410 \bfseries meaning&
2411 \bfseries control word&
2412 \bfseries widow penalty\hbox{}$^*$&
2413 \bfseries linebreak\\
2414 %</en>
2415 %<*ja>
2416 \bfseries 意図&
2417 \bfseries 制御綴中に使用&
2418 \bfseries 文字ウィドウ処理\hbox{}$^*$&
2419 \bfseries 直後での改行\\
2420 %</ja>
2421 \midrule
2422 15&non-cjk&\multicolumn{3}{c}{(treated as usual \LaTeX)}\\
2423 16&kanji&Y&Y&ignored\\
2424 17&kana&Y&Y&ignored\\
2425 18&other&N&N&ignored\\
2426 19&hangul&Y&Y&space\\
2427 \bottomrule
2428 \end{tabular}\hfill\null
2429
2430 \medskip
2431
2432 %<*ja>
2433 文字ウィドウ処理\hbox{}$^*$: 「漢字が一文字だけ次の行に行くのを防ぐ」\
2434 \cs{jcharwidowpenalty} が,
2435 その文字の直前に挿入されうるか否か,を示す.
2436 %</ja>
2437 \end{table}
2438
2439 %<*en>
2440 \cs{kcatcode} can be set by a row of JIS~X~0208 in \pTeX,
2441 and generally by a Unicode block\footnote{%
2442   \upTeX\ divides \texttt{U+FF00}--\texttt{U+FFEF} (Halfwidth and Fullwidth Forms)
2443   into three subblocks, and \cs{kcatcode} can be set by a subblock.
2444 }
2445 in \upTeX. So characters which can be used in a control word
2446 slightly differ between \pTeX~and~\upTeX.
2447 %</en>
2448 %<*ja>
2449 \pTeX では \cs{kcatcode} はJIS~X~0208の区単位,
2450 \upTeX では概ねUnicodeブロック単位\footnote{%
2451   \texttt{U+FF00}--\texttt{U+FFEF} (Halfwidth and Fullwidth Forms)は
2452   「全角英数字」「半角カナ」「その他」と3つに分割されており,
2453   それぞれ別々に \cs{kcatcode} が指定できるようになっている.
2454 }で設定可能になっている.そのため,\pTeX と\upTeX の初期状態では
2455 制御綴内で使用可能な文字が微妙に異なっている.
2456 %</ja>
2457
2458 %<*en>
2459 \subsection{Case of \LuaTeX-ja}
2460 The role of \cs{kcatcode} in \pTeX~and~\upTeX\ can be
2461 divided into the following four kinds,
2462 and \LuaTeX-ja can control these four kinds separately:
2463 \begin{itemize}
2464  \item
2465 \emph{Distinction between \textbf{JAchar} or \textbf{ALchar}}
2466 is controlled by using the character range, see Subsection~\ref{ssec-setrange}.
2467  \item
2468 \emph{Whether the character can be used in a control word}
2469 is controlled by setting \cs{catcode} to 11~(enabled) or 12~(disabled), as usual.
2470  \item
2471 \emph{Whether \Param{jcharwidowpenalty} can be inserted before the character}
2472 is controlled by the lowermost bit of the \Param{kcatcode} parameter.
2473  \item
2474 \emph{Ignoring linebreak after a \textbf{JAchar}} is always ignored.
2475 \end{itemize}
2476 %</en>
2477 %<*ja>
2478 \subsection{\LuaTeX-jaの場合}
2479 \LuaTeX-jaでは,従来の\pTeX・\upTeX における \cs{kcatcode} の役割を
2480 分割している:
2481 \begin{description}
2482  \item[欧文/和文の区別 (\upTeX)]
2483 \cs{ltjdefcharrange} と\textsf{jacharrange}パラメータ(\ref{ssec-setrange}節)
2484  \item[制御綴中に使用可か]
2485 \LuaTeX 自身の \cs{catcode} でよい
2486  \item[\Param{jcharwidowpenalty}が挿入可か]
2487 \Param{kcatcode}パラメータの最下位ビット
2488  \item[直後の改行の無視]
2489 日本語しか想定していないので\textbf{JAchar}については一律有効
2490 \end{description}
2491 %</ja>
2492
2493 %<*en>
2494 Default setting of \cs{catcode} of \LuaTeX\ can be found
2495 in \texttt{luatex-unicode-letters.tex},
2496 which is based on \texttt{unicode-letters.tex} (for \XeTeX).
2497 However, the default setting of \cs{catcode} differs
2498 between \XeTeX\ and \LuaTeX, by the following reasons:
2499 \begin{itemize}
2500  \item \texttt{luatex-unicode-letters.tex} is based on old \texttt{unicode-letters.tex}.
2501  \item The latter half of \texttt{unicode-letters.tex} sets
2502 \cs{catcode} of Kanji and kana characters to 11,
2503 via setting \cs{XeTeXcharclass}.
2504
2505 However, this latter half is simply omitted in
2506 \texttt{luatex-unicode-letters.tex}, hence
2507 \cs{catcode} of Kanji and kana characters remains 12 in \LuaTeX.
2508 \end{itemize}
2509 In other words, Kanji nor kana characters cannot be used in
2510 a control word, in the default setting of \LuaTeX.
2511
2512 This would be inconvenient for \pTeX~users to shifting to \LuaTeX-ja,
2513 since several control words containing Kanji, such as \verb+\西暦+,
2514 are used in \pTeX.
2515 Hence, \LuaTeX-ja have a counterpart of \texttt{unicode-letters.tex}
2516 for \LuaTeX, \emph{to match the \cs{catcode} setting with that of \XeTeX.}
2517 %</en>
2518 %<*ja>
2519 ネイティブにUnicode全部の文字を扱える\XeTeX や\LuaTeX では,
2520 文字が制御綴内で使用できるかは通常の欧文文字と同じく \cs{catcode}
2521 で指定することとなる.\XeTeX における \cs{catcode} の初期設定は\
2522 \texttt{unicode-letters.tex} 中に記述されており,\LuaTeX ではそれを
2523 元にした \texttt{luatex-unicode-letters.tex} を用いている.
2524
2525 だが,\XeTeX における \cs{catcode} の初期設定と
2526 \LuaTeX におけるそれは一致していない:
2527 \begin{itemize}
2528  \item \texttt{luatex-unicode-letters.tex} の元になった\
2529 \texttt{unicode-letters.tex} が古い
2530  \item \texttt{unicode-letters.tex} の後半部では
2531 \cs{XeTeXcharclass} の設定を行なっており,
2532 それによって漢字や仮名の \cs{catcode} が11に設定されている.
2533
2534 しかし,\texttt{luatex-unicode-letters.tex} ではこの「後半部」が
2535 まるごと省略されており,漢字や仮名の \cs{catcode} は12のまま.
2536 \end{itemize}
2537 言い換えると,\LuaTeX の初期状態では漢字や仮名を制御綴内に
2538 使用することはできない.
2539
2540 これでは \pTeX で使用できた \verb+\西暦+ などが使えないこととなり,
2541 \LuaTeX-jaへの移行で手間が生じる.そのため,\LuaTeX-jaでは
2542 \texttt{unicode-letters.tex} の後半部にあたる内容を自前でパッチし,
2543 結果として\textbf{\XeTeX における初期設定と同じになるようにしている.}
2544 %</ja>
2545
2546 \begin{table}
2547  \centering\small
2548 %<en>\caption{Difference of the set of non-kanji JIS~X~0208 characters which can be used in a control word}
2549 %<ja>\caption{制御綴中に使用出来るJIS~X~0208非漢字の違い}
2550 %<en>\medskip
2551 \label{table-kcat-diff}
2552 \def\D#1#2#3#4{%
2553   {\fboxsep0pt\fcolorbox{cyan}{white}%
2554   {\large\char"#1#2#3#4}}\ (\texttt{U+#1#2#3#4})} %"
2555 \leavevmode\hbox to 0pt{\hss\begin{tabular}{cccccc}
2556 \toprule
2557 %<en>&\bf row&\bf col.&\bf \pTeX&\bf \upTeX&\bf\LuaTeX-ja\\
2558 %<ja>&\bf 区&\bf 点&\bf \pTeX&\bf \upTeX&\fontseries{b}\selectfont\LuaTeX-ja\\
2559 \midrule
2560 \D 3000&1&1&N&N&Y\\
2561 \D 30FB&1&6&N&Y&N\\
2562 \D 309B&1&11&N&Y&N\\
2563 \D 309C&1&12&N&Y&N\\
2564 \D FF40&1&14&N&N&Y\\
2565 \D FF3E&1&16&N&N&Y\\
2566 \D FFE3&1&17&N&N&Y\\
2567 \D FF3F&1&18&N&N&Y\\
2568 \D 30FD&1&19&N&Y&Y\\
2569 \D 30FE&1&20&N&Y&Y\\
2570 \D 309D&1&21&N&Y&Y\\
2571 \D 309E&1&22&N&Y&Y\\
2572 \D 3003&1&23&N&N&Y\\
2573 \D 4EDD&1&24&N&Y&Y\\
2574 \D 3005&1&25&N&N&Y\\
2575 \D 3006&1&26&N&N&Y\\
2576 \D 3007&1&27&N&N&Y\\
2577 \D 30FC&1&28&N&Y&Y\\
2578 \bottomrule
2579 \end{tabular}\qquad
2580 \begin{tabular}{cccccc}
2581 \toprule
2582 %<en>&\bf row&\bf col.&\bf \pTeX&\bf \upTeX&\bf\LuaTeX-ja\\
2583 %<ja>&\bf 区&\bf 点&\bf \pTeX&\bf \upTeX&\fontseries{b}\selectfont\LuaTeX-ja\\
2584 \midrule
2585 \D FF0F&1&31&N&N&Y\\
2586 \D FF3C&1&32&N&N&Y\\
2587 \D FF5C&1&35&N&N&Y\\
2588 \D FF0B&1&60&N&N&Y\\
2589 \D FF1D&1&65&N&N&Y\\
2590 \D FF1C&1&67&N&N&Y\\
2591 \D FF1E&1&68&N&N&Y\\
2592 \D FF03&1&84&N&N&Y\\
2593 \D FF06&1&85&N&N&Y\\
2594 \D FF0A&1&86&N&N&Y\\
2595 \D FF20&1&87&N&N&Y\\
2596 \D 3012&2&9&N&N&Y\\
2597 \D 3013&2&14&N&N&Y\\
2598 \D FFE2&2&44&N&N&Y\\
2599 \D 212B&2&82&N&N&Y\\
2600 %<en>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}Greek letters (row 6)}&Y&N&Y\\
2601 %<en>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}Cyrillic letters (row 7)}&N&N&Y\\
2602 %<ja>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}ギリシャ文字(6区)}&Y&N&Y\\
2603 %<ja>\multicolumn{3}{c}{$\vphantom{\D 3000}$\hbox{}キリル文字(7区)}&N&N&Y\\
2604 $\vphantom{\D 3000}$\\
2605 \bottomrule
2606 \end{tabular}\hss}\par
2607 \end{table}
2608
2609 %<*en>
2610 \subsection{Non-kanji Characters in a Control Word}
2611 Because the engine differ, so non-kanji JIS~X~0208 characters
2612 which can be used in a control word differ in \pTeX, in \upTeX,~and~in \LuaTeX-ja.
2613 Table~\ref{table-kcat-diff} shows the difference.
2614 Except for four characters ``・'',~``゛'', ``゜'',~``゠'',
2615 \LuaTeX-ja admits more characters in a control word than \upTeX.
2616 \emph{Note that the ideographic space~\texttt{U+3000} can be used
2617 in a control word in \LuaTeX-ja.}
2618
2619 Difference becomes larger, if we consider
2620 non-kanji JIS~X~0213 characters.
2621 For the detail, see \url{https://github.com/h-kitagawa/kct}.
2622 %</en>
2623 %<*ja>
2624 \subsection{制御綴中に使用出来るJIS非漢字の違い}
2625
2626 エンジンが異なるので,\pTeX, \upTeX, \LuaTeX-ja
2627 において制御綴中に使用可能なJIS~X~0208の文字は異なる.
2628 異なっているところだけを載せると,表\ref{table-kcat-diff}のようになる.
2629 「・」「゛」「゜」「゠」を除けば,\LuaTeX-jaでは\upTeX より多くの文字が
2630 制御綴に使用可能になっている.
2631 \textbf{特に重要なのは,全角空白(\texttt{U+3000})が
2632 \LuaTeX-jaでは制御綴中に使用可能であることである.}
2633
2634 JIS~X~0213の範囲に広げると,差異はさらに大きくなる.
2635 詳細については例えば \url{https://github.com/h-kitagawa/kct} 中の\
2636 \texttt{kct-uni-out.pdf} などを参照すること.
2637 %</ja>
2638
2639
2640 %<*en>
2641 \section{Directions}
2642 \LuaTeX\ supports four $\Omega$-style directions: \texttt{TLT},~\texttt{TRT}, \texttt{RTT}
2643 and \texttt{LTL}.
2644 However, neither directions are not well-suited for typesetting Japanese vertically, hence we
2645 implemented vertical writing by rotating \texttt{TLT}-box by 90~degrees.
2646 %</en>
2647 %<*ja>
2648 \section{縦組}
2649 \label{sec-direction}
2650 \LuaTeX 本体でも,$\Omega$・$\aleph$由来の機能として,複数の組方向をサポートしている.
2651 しかし,\LuaTeX がサポートするのは \texttt{TLT},~\texttt{TRT}, \texttt{RTT},~\texttt{LTL}\
2652 のみであり,日本語の縦組に使うのは望ましくない\footnote{%
2653 和文文字だけならば \texttt{RTT} を使えばなんとかなると思うが,
2654 欧文文字が入ってきた場合はうまくいかず,\texttt{RTR} という組方向が必要になる.
2655 }.そのため,\LuaTeX-jaでは横組(\texttt{TLT})で組んだボックスを回転させる方式で
2656 縦組を実装した.
2657 %</ja>
2658
2659 %<ja>\subsection{サポートする組方向}
2660 \begin{table}[t]
2661 %<ja>\caption{\LuaTeX-ja のサポートする組方向}
2662 %<en>\caption{Directions supported by \LuaTeX-ja}
2663 %<en>\medskip
2664 \label{tab-dir}
2665 \centering\small
2666 \def\obox#1{%
2667   \setbox0=\hbox{\yoko\hbox{#1%
2668   \large\ltjsetparameter{talbaselineshift=0pt}%
2669   \vrule height 25pt width 0.4pt depth 15pt\kern-.2pt%
2670   \raise25pt\hbox to 0pt{\hss\composite{*r^@{>>}}\hss}%
2671   \raise-15pt\hbox to 0pt{\hss\composite{*l^@{>|}}\hss}\kern.2pt%
2672   \vrule height.2pt depth.2pt width 60pt\hbox to 0pt{\hss\composite{*d^@{>}}\hss}\kern-60pt
2673   \hbox to 60pt{\,銀は、Ag\hss}}}%
2674   \raise\dimexpr 0.5\ltjgetdp0-0.5\ltjgetht0\box0%
2675 }
2676 %<*ja>
2677 \begin{tabular}{>{\bfseries}lcccc}
2678 \toprule
2679 &横組&縦組 &\cs{dtou}「dtou方向」&「utod方向」\\
2680 \midrule
2681 命令&\cs{yoko}&\cs{tate}&\cs{dtou}&\cs{utod}\\
2682 字送り方向&水平右向き(→)&垂直下向き(↓)&垂直上向き(↑)&垂直下向き(↓)\\
2683 行送り方向&垂直下向き(↓)&水平左向き(←)&水平右向き(→)&水平左向き(←)\\
2684 使用する和文フォント&横組用(\cs{jfont})&縦組用(\cs{tfont})&
2685 \multicolumn{2}{c}{%
2686   横組用(\cs{jfont})の$90^\circ$回転}\\[\smallskipamount]
2687 組版例\null $^*$ &\obox{\yoko}&\obox{\tate}&\obox{\dtou}&\obox{\utod}\\
2688 \noalign{\medskip}
2689 \bottomrule
2690 \end{tabular}
2691
2692 \medskip\raggedright
2693 \def\R#1{%
2694   \raise0.38\zw\hbox{%
2695     \vrule height.2pt  depth.2pt width2\zw%
2696     \hbox to 0pt{\hss\composite{*d^@{#1}}\hss}%
2697   }%
2698 }
2699 $^*$\ 幅(width),高さ(height),深さ(depth)の増加方向を,
2700 それぞれ「\R{>}」,「\R{>>}」,「\R{>|}」で表している.
2701 \raggedright
2702 %</ja>
2703
2704 %<*en>
2705 \begin{tabular}{>{\bfseries}lcccc}
2706 \toprule
2707 &horizontal (\emph{yoko}~direction)&vertical (\emph{tate}~direction)&%
2708   \emph{dtou} direction&\emph{utod} direction\\
2709 \midrule
2710 Commands&\cs{yoko}&\cs{tate}&\cs{dtou}&\cs{utod}\\
2711 Beginning of the page&Top&Right&Left&Right\\
2712 Beginning of the line&Left&Top&Bottom&Top\\
2713 Used Japanese font&horizontal (\cs{jfont})&vertical (\cs{tfont})&
2714 \multicolumn{2}{c}{%
2715   horizontal ($90^\circ$ rotated)}\\[\smallskipamount]
2716 Example&\obox{\yoko}&\obox{\tate}&\obox{\dtou}&\obox{\utod}\\
2717 \noalign{\medskip}
2718 (Notation used in $\Omega$)&TLT&RTR, RTT&LBL&RTR\\
2719 \bottomrule
2720 \end{tabular}
2721
2722 \medskip\raggedright
2723 \def\R#1{%
2724   \raise0.38\zw\hbox{%
2725     \vrule height.2pt  depth.2pt width2\zw%
2726     \hbox to 0pt{\hss\composite{*d^@{#1}}\hss}%
2727   }%
2728 }
2729 \raggedright
2730 %</en>
2731 \end{table}
2732
2733 %<*en>
2734 \LuaTeX-ja supports four directions, as shown in Table~\ref{tab-dir}.
2735 The second column (\emph{yoko} direction) is just horizontal writing,
2736 and the third column (\emph{tate} direction) is vertical writing.
2737 The fourth column (\emph{dtou} direction) is actually a hidden feature of \pTeX.
2738 We implemented this for debugging purpose.
2739 The fifth column (\emph{utod} direction) corresponds the ``\texttt{tate (math) direction}'' of \pTeX.
2740
2741 Directions can be changed by \cs{yoko},~\cs{tate}, \cs{dtou},~\cs{utod},
2742 only when the current list is null. Also, the direction of a math formula is changed to
2743 \emph{utod}, when the direction outside the math formula is \emph{tate} (vertical writing).
2744 %</en>
2745
2746 %<*ja>
2747 \LuaTeX-jaがサポートする組方向は表\ref{tab-dir}に示す4つである.
2748 4列目の \cs{dtou} は聞き慣れない命令だと思うが,
2749 実は\pTeX に同名の命令が(ドキュメントには書かれていないが)存在する.
2750 Down-TO-Upの意味なのだろう.\cs{dtou} を使用する機会はないだろうが,
2751 \LuaTeX-jaではデバッグ用に実装している.
2752 5列目の \cs{utod} は,\pTeX で言う「縦数式ディレクション」に相当するものである.
2753
2754 組方向は,\cs{yoko},~\cs{tate}, \cs{dtou},~\cs{utod} をそれぞれ使用することで,
2755 現在作成中のリストやボックスが空の時にのみ変更可能である.
2756 また,縦組中の数式内のボックスは\pTeX と同じように組方向が \cs{utod} となる.
2757 %</ja>
2758
2759 %<*en>
2760 \subsection{Boxes in different direction}
2761
2762 As in \pTeX, one can use boxes of different direction in one document.
2763 The below is an example.
2764 \begin{LTXexample}
2765 ここは横組%     yoko
2766 \hbox{\tate %   tate
2767   \hbox{縦組}%  tate
2768   の中に
2769   \hbox{\yoko 横組の内容}% yoko
2770   を挿入する
2771 }
2772 また横組に戻る% yoko
2773 \end{LTXexample}
2774
2775 Table~\ref{tab-diffdir} shows how a box is arranged when
2776 the direction  inside the box and that outside the box differ.
2777 %</en>
2778 %<*ja>
2779 \subsection{異方向のボックス}
2780
2781 縦組の中に「42」などの2桁以上の算用数字を横組で組むなど,
2782 異なる組方向を混在させることがしばしば行われる.
2783 組方向の混在も\pTeX と同じようにできる:
2784 \begin{LTXexample}
2785 ここは横組%     yoko
2786 \hbox{\tate %   tate
2787   \hbox{縦組}%  tate
2788   の中に
2789   \hbox{\yoko 横組の内容}% yoko
2790   を挿入する
2791 }
2792 また横組に戻る% yoko
2793 \end{LTXexample}
2794
2795 異なる組方向のボックスを配置した場合にどう組まれるかの仕様も,\pTeX を
2796 踏襲している.表\ref{tab-diffdir}に示す.
2797 %</ja>
2798
2799 \begin{table}[t]
2800 %<ja>\caption{異方向のボックスの配置}
2801 %<en>\caption{Boxes in different direction}
2802 %<en>\medskip
2803 \label{tab-diffdir}
2804  \centering\small\unitlength3mm
2805  \def\TATEeg{%
2806    \hbox{\smash{\begin{picture}(0,0)(-2,0)
2807      \thicklines
2808      \polyline(-2,0)(-2,-7)(5,-7)(5,0)
2809      \put(0,0){\circle*{0.3}}
2810      \put(2.5,-4){\makebox(0,0){\hbox{\tate\bfseries \emph{tate}/\emph{utod}}}}
2811      \put(0,0){\vector(1,0){5}} \put(2.5,-0.2){\makebox(0,0)[t]{$h_{\mathrm{T}}$}}
2812      \put(0,0){\vector(-1,0){2}}\put(-1,-0.2){\makebox(0,0)[t]{$d_{\mathrm{T}}$}}
2813      \put(0,0){\vector(0,-1){7}}\put(0.2,-3.5){\makebox(0,0)[l]{$w_{\mathrm{T}}$}}
2814    \end{picture}}}
2815  }
2816  \def\DTOUeg{%
2817    \hbox{\smash{\begin{picture}(0,0)(-5,0)
2818      \thicklines
2819      \polyline(-5,0)(-5,7)(2,7)(2,0)
2820      \put(0,0){\circle*{0.3}}
2821      \put(-2.5,4){\makebox(0,0){\hbox{\dtou\bfseries \emph{dtou}}}}
2822      \put(0,0){\vector(-1,0){5}} \put(-2.5,0.3){\makebox(0,0)[b]{$h_{\mathrm{D}}$}}
2823      \put(0,0){\vector(1,0){2}}\put(1,0.3){\makebox(0,0)[b]{$d_{\mathrm{D}}$}}
2824      \put(0,0){\vector(0,1){7}}\put(-0.2,3.5){\makebox(0,0)[r]{$w_{\mathrm{D}}$}}
2825    \end{picture}}}
2826  }
2827  \def\YOKOeg{%
2828    \hbox{\smash{\begin{picture}(0,0)
2829      \thicklines
2830      \polyline(0,5)(7,5)(7,-2)(0,-2)
2831      \put(4,2.5){\makebox(0,0){\hbox{\yoko\bfseries \emph{yoko}}}}
2832      \put(0,0){\circle*{0.3}}
2833      \put(0,0){\vector(0,1){5}} \put(0.3,2.5){\makebox(0,0)[l]{$h_{\mathrm{Y}}$}}
2834      \put(0,0){\vector(0,-1){2}}\put(0.3,-1){\makebox(0,0)[l]{$d_{\mathrm{Y}}$}}
2835      \put(0,0){\vector(1,0){7}}\put(3.5,0.2){\makebox(0,0)[b]{$w_{\mathrm{Y}}$}}
2836    \end{picture}}}
2837  }
2838 \begin{tabular}{ccc}
2839 \toprule
2840 %<ja>\emph{横組中に配置}&\emph{縦組中に配置}&%
2841 %<ja>\emph{組方向 \cs{dtou} 中に配置}\\
2842 %<en>\textbf{typeset in \emph{yoko} direction}
2843 %<en>&\textbf{typeset in \emph{tate} or \emph{utod} direction}
2844 %<en>&\textbf{typeset in \emph{dtou} direction}\\
2845 \midrule
2846  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
2847    \put(0,0){\line(1,0){3.8}}
2848    \put(4,7){\TATEeg}
2849    \put(11.2,0){\line(1,0){3.8}}
2850 %
2851    \put(2,7){\line(1,0){1.8}}
2852    \put(3,3.5){\vector(0,1){3.5}\vector(0,-1){3.5}}
2853    \put(2.8,3.5){\makebox(0,0)[r]{$H_{\mathrm{Y}}$}}
2854    \put(3,-2){\vector(0,1){2}}
2855    \put(2.8,-1){\makebox(0,0)[r]{$D_{\mathrm{Y}}$}}
2856 %
2857    \put(4,7.2){\line(0,1){1.8}}
2858    \put(11,7.2){\line(0,1){1.8}}
2859    \put(6,8){\vector(-1,0){2}}
2860    \put(9,8){\vector(1,0){2}}
2861    \put(7.5,8){\makebox(0,0){$W_{\mathrm{Y}}$}}
2862 %
2863  \end{picture}\vspace{-\baselineskip}
2864    \begin{align*}
2865    W_{\mathrm{Y}} &= h_{\mathrm{T}}+d_{\mathrm{T}},\\
2866    H_{\mathrm{Y}} &= w_{\mathrm{T}},\\
2867    D_{\mathrm{Y}} &=0\,\mathrm{pt}
2868    \end{align*}%
2869  }&
2870  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
2871    \put(7.5,-0.2){\line(0,-1){2.8}}
2872    \put(4,2){\YOKOeg}
2873    \put(7.5, 7.2){\line(0,1){3.8}}
2874 %
2875    \put(2,7){\line(1,0){1.8}}
2876    \put(2,0){\line(1,0){1.8}}
2877    \put(3,5){\vector(0,1){2}}
2878    \put(3,2){\vector(0,-1){2}}
2879    \put(3,3.5){\makebox(0,0){$W_{\mathrm{T}}$}}
2880 %
2881    \put(4,7.2){\line(0,1){1.8}}
2882    \put(11,7.2){\line(0,1){1.8}}
2883    \put(8,8){\vector(-1,0){0.5}\vector(1,0){3}}
2884    \put(7,8){\vector(-1,0){3}\vector(1,0){0.5}}
2885    \put(9.25,8.2){\makebox(0,0)[b]{$H_{\mathrm{T}}$}}
2886    \put(5.75,8.2){\makebox(0,0)[b]{$D_{\mathrm{T}}$}}
2887 %
2888  \end{picture}\vspace{-\baselineskip}
2889    \begin{align*}
2890    W_{\mathrm{T}} &= h_{\mathrm{Y}}+d_{\mathrm{Y}},\\
2891    H_{\mathrm{T}} &= w_{\mathrm{Y}}/2,\\
2892    D_{\mathrm{T}} &= w_{\mathrm{Y}}/2
2893    \end{align*}%
2894  }&
2895  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
2896    \put(11,-0.2){\line(0,-1){2.8}}
2897    \put(4,2){\YOKOeg}
2898    \put(11, 7.2){\line(0,1){3.8}}
2899 %
2900    \put(2,7){\line(1,0){1.8}}
2901    \put(2,0){\line(1,0){1.8}}
2902    \put(3,5){\vector(0,1){2}}
2903    \put(3,2){\vector(0,-1){2}}
2904    \put(3,3.5){\makebox(0,0){$W_{\mathrm{D}}$}}
2905 %
2906    \put(4,7.2){\line(0,1){1.8}}
2907    \put(11,7.2){\line(0,1){1.8}}
2908    \put(7.5,8){\vector(-1,0){3.5}\vector(1,0){3.5}}
2909    \put(13,8){\vector(-1,0){2}}
2910    \put(7.5,8.2){\makebox(0,0)[b]{$H_{\mathrm{D}}$}}
2911    \put(12,8.2){\makebox(0,0)[b]{$D_{\mathrm{D}}$}}
2912 %
2913  \end{picture}\vspace{-\baselineskip}
2914    \begin{align*}
2915    W_{\mathrm{D}} &= h_{\mathrm{Y}}+d_{\mathrm{Y}},\\
2916    H_{\mathrm{D}} &= w_{\mathrm{Y}},\\
2917    D_{\mathrm{D}} &= 0\,\mathrm{pt}
2918    \end{align*}%
2919  }%
2920 \\\midrule
2921  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
2922    \put(0,0){\line(1,0){3.8}}
2923    \put(4,0){\DTOUeg}
2924    \put(11.2,0){\line(1,0){3.8}}
2925 %
2926    \put(2,7){\line(1,0){1.8}}
2927    \put(3,3.5){\vector(0,1){3.5}\vector(0,-1){3.5}}
2928    \put(2.8,3.5){\makebox(0,0)[r]{$H_{\mathrm{Y}}$}}
2929    \put(3,-2){\vector(0,1){2}}
2930    \put(2.8,-1){\makebox(0,0)[r]{$D_{\mathrm{Y}}$}}
2931 %
2932    \put(4,7.2){\line(0,1){1.8}}
2933    \put(11,7.2){\line(0,1){1.8}}
2934    \put(6,8){\vector(-1,0){2}}
2935    \put(9,8){\vector(1,0){2}}
2936    \put(7.5,8){\makebox(0,0){$W_{\mathrm{Y}}$}}
2937 %
2938  \end{picture}\vspace{-\baselineskip}
2939    \begin{align*}
2940    W_{\mathrm{Y}} &= h_{\mathrm{D}}+d_{\mathrm{D}},\\
2941    H_{\mathrm{Y}} &= w_{\mathrm{D}},\\
2942    D_{\mathrm{Y}} &= 0\,pt
2943    \end{align*}%
2944  }&
2945  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
2946    \put(9,-0.2){\line(0,-1){2.8}}
2947    \put(4,0){\DTOUeg}
2948    \put(9, 7.2){\line(0,1){3.8}}
2949 %
2950    \put(2,7){\line(1,0){1.8}}
2951    \put(2,0){\line(1,0){1.8}}
2952    \put(3,5){\vector(0,1){2}}
2953    \put(3,2){\vector(0,-1){2}}
2954    \put(3,3.5){\makebox(0,0){$W_{\mathrm{T}}$}}
2955 %
2956    \put(4,7.2){\line(0,1){1.8}}
2957    \put(11,7.2){\line(0,1){1.8}}
2958    \put(6.5,8){\vector(-1,0){2.5}\vector(1,0){2.5}}
2959    \put(10,8){\vector(-1,0){1}\vector(1,0){1}}
2960    \put(10,8.2){\makebox(0,0)[b]{$H_{\mathrm{T}}$}}
2961    \put(6.5,8.2){\makebox(0,0)[b]{$D_{\mathrm{T}}$}}
2962 %
2963  \end{picture}\vspace{-\baselineskip}
2964    \begin{align*}
2965    W_{\mathrm{T}} &= h_{\mathrm{D}}+d_{\mathrm{D}},\\
2966    H_{\mathrm{T}} &= d_{\mathrm{D}},\\
2967    D_{\mathrm{T}} &= h_{\mathrm{D}}
2968    \end{align*}%
2969  }&
2970  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
2971    \put(6,-0.2){\line(0,-1){2.8}}
2972    \put(4,7){\TATEeg}
2973    \put(6, 7.2){\line(0,1){3.8}}
2974 %
2975    \put(2,7){\line(1,0){1.8}}
2976    \put(2,0){\line(1,0){1.8}}
2977    \put(3,5){\vector(0,1){2}}
2978    \put(3,2){\vector(0,-1){2}}
2979    \put(3,3.5){\makebox(0,0){$W_{\mathrm{D}}$}}
2980 %
2981    \put(4,7.2){\line(0,1){1.8}}
2982    \put(11,7.2){\line(0,1){1.8}}
2983    \put(5,8){\vector(-1,0){1}\vector(1,0){1}}
2984    \put(8.5,8){\vector(-1,0){2.5}\vector(1,0){2.5}}
2985    \put(5,8.2){\makebox(0,0)[b]{$H_{\mathrm{D}}$}}
2986    \put(8.5,8.2){\makebox(0,0)[b]{$D_{\mathrm{D}}$}}
2987 %
2988  \end{picture}\vspace{-\baselineskip}
2989    \begin{align*}
2990    W_{\mathrm{D}} &= w_{\mathrm{T}},\\
2991    H_{\mathrm{D}} &= d_{\mathrm{T}},\\
2992    D_{\mathrm{D}} &= h_{\mathrm{T}}
2993    \end{align*}%
2994  }\\
2995 \bottomrule
2996 \end{tabular}
2997 \end{table}
2998
2999
3000
3001 %<*en>
3002 \paragraph{\cs{wd} and direction}
3003 In \pTeX, \cs{wd},~\cs{ht},~\cs{dp} means the dimensions of a box register
3004 \emph{with respact to the current direction}.
3005 This means that the value of \cs{wd0} etc.\ might differ when the current direction is
3006 different, even if \cs{box0} stores the same box.
3007 However, this no longer applies in \LuaTeX-ja.
3008
3009 \begin{LTXexample}
3010 % yoko direction
3011 \setbox0=\hbox to 20pt{foo}
3012 \the\wd0,~\hbox{\tate\vrule\the\wd0}
3013 \wd0=100pt
3014 \the\wd0,~\hbox{\tate \the\wd0}
3015 \end{LTXexample}
3016
3017 To access box dimensions \emph{with respect to current direction},
3018 one have to use the following commands instead of \cs{wd} wtc.
3019 \begin{cslist}
3020
3021  \item[\cs{ltjgetwd}\{<num>\}\textrm{, }\cs{ltjgetht}\{<num>\}\textrm{, }%
3022   \cs{ltjgetdp}\{<num>\}]
3023 These commands return \emph{an internal dimension} of \cs{box<num>} with respect to
3024 the current direction. One can use these in \cs{dimexpr} primitive, as the followings.
3025 \begin{lstlisting}
3026 \dimexpr 2\ltjgetwd{42}-3pt\relax, \the\ltjgetwd{1701}
3027 \end{lstlisting}
3028 By its implementaion,  the argument must be grouped as \verb+\ltjgetwd{42}+,
3029 if the argument consists of more than one token.
3030 \begin{LTXexample}[width=0.3\textwidth]
3031 \parindent0pt
3032 \setbox32767=\hbox{\yoko よこぐみ}
3033 \fboxsep=0mm\fbox{\copy32767}
3034 \vbox{\hsize=20mm
3035 \yoko YOKO \the\ltjgetwd{32767}, \\
3036   \the\ltjgetht{32767}, \\ \the\ltjgetdp{32767}.}
3037 \vbox{\hsize=20mm\raggedleft
3038 \tate TATE \the\ltjgetwd{32767}, \\
3039   \the\ltjgetht{32767}, \\ \the\ltjgetdp{32767}.}
3040 \vbox{\hsize=20mm\raggedleft
3041 \dtou DTOU \the\ltjgetwd{32767}, \\
3042   \the\ltjgetht{32767}, \\ \the\ltjgetdp{32767}.}
3043 \end{LTXexample}
3044
3045  \item[\cs{ltjsetwd}<num>=<dimen>\textrm{, }\cs{ltjsetht}<num>=<dimen>\textrm{, }%
3046   \cs{ltjsetdp}<num>=<dimen>]
3047 These commands set the dimension of \cs{box<num>}. Unlike \cs{ltjgetwd}, one does not need
3048         to group the argument <num>; four calls of \cs{ltjsetwd} below have the same meaning.
3049 \begin{lstlisting}
3050 \ltjsetwd42 20pt,  \ltjsetwd42=20pt,  \ltjsetwd=42 20pt,  \ltjsetwd=42=20pt
3051 \end{lstlisting}
3052
3053 \end{cslist}
3054 %</en>
3055 %<*ja>
3056 \paragraph{\cs{wd} 達と組方向}
3057 ボックスレジスタ \cs{box}<num> にセットされているボックスの幅・高さ・深さの取得や
3058 変更にはそれぞれ \cs{wd},~\cs{ht},~\cs{dp} プリミティブを用いるのであった.
3059 \pTeX ではこれらのプリミティブは,「現在の組方向におけるボックスの寸法」を指すもので,
3060 同じボックスに対しても現在の組方向によって返る値は異なるもであった.
3061
3062 \LuaTeX-jaにおいては状況が異なり,\cs{wd},~\cs{ht},~\cs{dp} が返す値は
3063 現在の組方向には依存しない.下の例のように,横組のボックスが格納されていれば
3064 \cs{wd}等は常に「横組におけるボックスの寸法」を意味する.
3065
3066 \begin{LTXexample}
3067 % yoko direction
3068 \setbox0=\hbox to 20pt{foo}
3069 \the\wd0,~\hbox{\tate\vrule\the\wd0}
3070 \wd0=100pt
3071 \the\wd0,~\hbox{\tate \the\wd0}
3072 \end{LTXexample}
3073
3074 \pTeX のように現在の組方向に応じたボックスの寸法の取得・設定を行うには,
3075 代わりに次の命令を使用する.
3076
3077 \begin{cslist}
3078
3079  \item[\cs{ltjgetwd}\{<num>\}\textrm{, }\cs{ltjgetht}\{<num>\}\textrm{, }%
3080   \cs{ltjgetdp}\{<num>\}]
3081 現在の組方向に応じたボックスの寸法の取得を行う.結果は内部長さであるため,
3082 \begin{lstlisting}
3083 \dimexpr 2\ltjgetwd{42}-3pt\relax, \the\ltjgetwd{1701}
3084 \end{lstlisting}
3085 のように \cs{wd}<num> の代わりとして扱うことができる.引数が1桁の場合は,
3086 \cs{ltjgetwd3} のように引数をグループで括らなくても良いが,そうでない場合は
3087 (通常の命令への引数のように)\verb+\ltjgetwd{42}+ とグループに括る必要がある%
3088 \footnote{\cs{afterassignment} を利用して実装すればグループに括る必要がなくなるのでは,と思
3089               うかもしれないが,それでは本文中に書いた例のように \cs{dimexpr} 中で使用でき
3090               なくなってしまう.}.
3091 使用例は以下の通りである.
3092 \begin{LTXexample}[width=0.3\textwidth]
3093 \parindent0pt
3094 \setbox32767=\hbox{\yoko よこぐみ}
3095 \fboxsep=0mm\fbox{\copy32767}
3096 \vbox{\hsize=20mm
3097 \yoko YOKO \the\ltjgetwd{32767}, \\
3098   \the\ltjgetht{32767}, \\ \the\ltjgetdp{32767}.}
3099 \vbox{\hsize=20mm\raggedleft
3100 \tate TATE \the\ltjgetwd{32767}, \\
3101   \the\ltjgetht{32767}, \\ \the\ltjgetdp{32767}.}
3102 \vbox{\hsize=20mm\raggedleft
3103 \dtou DTOU \the\ltjgetwd{32767}, \\
3104   \the\ltjgetht{32767}, \\ \the\ltjgetdp{32767}.}
3105 \end{LTXexample}
3106
3107  \item[\cs{ltjsetwd}<num>=<dimen>\textrm{, }\cs{ltjsetht}<num>=<dimen>\textrm{, }%
3108   \cs{ltjsetdp}<num>=<dimen>]
3109 現在の組方向に応じたボックスの寸法の設定を行う.\cs{afterassignment} を2回利用して
3110 実装しているので,次の4通りは全て同じ意味である.
3111 \begin{lstlisting}
3112 \ltjsetwd42 20pt,  \ltjsetwd42=20pt,  \ltjsetwd=42 20pt,  \ltjsetwd=42=20pt
3113 \end{lstlisting}
3114
3115 設定値は「横組」「縦組及び \cs{utod} 方向」「\cs{dtou} 方向」
3116 の3種ごとに独立して記録される.参考として,Gitリポジトリ内の
3117               \verb+test/test55-boxdim_diffdir.{tex,pdf}+ を挙げておく.
3118
3119 \end{cslist}
3120 %</ja>
3121
3122 %<*en>
3123 \subsection{Getting current direction}
3124 The \Param{direction} parameter returns the current direction, and
3125 the \Param{boxdir} parameter (with the argumant <num>)
3126 returns the direction of a box register \cs{box}<num>.
3127 The returned value of these parameters are a \emph{string}:
3128 \begin{center}
3129 \small
3130 \begin{tabular}{>{\bfseries}lccccc}
3131 \toprule
3132 Direction&\emph{yoko}&\emph{tate}&\emph{dtou}&\emph{utod}&(empty)\\
3133 \midrule
3134 Returned value&\texttt{4}&\texttt{3}&\texttt{1}&\texttt{11}&\texttt{0}\\
3135 \bottomrule
3136 \end{tabular}
3137 \end{center}
3138 \begin{LTXexample}[width=0.3\textwidth]
3139 \leavevmode\def\DIR{\ltjgetparameter{direction}}
3140 \hbox{\yoko \DIR}, \hbox{\tate\DIR},
3141 \hbox{\dtou\DIR}, \hbox{\utod\DIR},
3142 \hbox{\tate$\hbox{tate math: \DIR}$}
3143
3144 \setbox2=\hbox{\tate}\ltjgetparameter{boxdir}{2}
3145 \end{LTXexample}
3146 %</en>
3147 %<*ja>
3148 \subsection{組方向の取得}
3149 「現在の組方向」や「<num>番のボックスの組方向」は,
3150 \pTeX では \cs{ifydir} や \cs{ifybox}<num> といった条件判断文を使って
3151 判断することができた.
3152 しかし,\LuaTeX-jaはあくまでも\TeX マクロとLuaコードで
3153 記述されており,それでは新たな条件判断命令を作るのは難しい.
3154
3155 \LuaTeX-jaでは,\Param{direction}パラメータで現在の組方向を,
3156 \Param{boxdir}パラメータ(と追加の引数<num>)によって
3157 \cs{box}<num>の組方向をそれぞれ取得できるようにした.
3158 戻り値は文字列である:
3159 \begin{center}
3160 \small
3161 \begin{tabular}{>{\bfseries}lccccc}
3162 \toprule
3163 組方向&\emph{横組}&\emph{tate縦組}&\emph{dtou方向}&\emph{utod方向}&(未割り当て)\\
3164 \midrule
3165 戻り値&\texttt{4}&\texttt{3}&\texttt{1}&\texttt{11}&\texttt{0}\\
3166 \bottomrule
3167 \end{tabular}
3168 \end{center}
3169
3170 \begin{LTXexample}[width=0.3\textwidth]
3171 \leavevmode\def\DIR{\ltjgetparameter{ direction}}
3172 \hbox{\yoko\DIR}, \hbox{\tate\DIR},
3173 \hbox{\dtou\DIR}, \hbox{\utod\DIR},
3174 \hbox{\tate$\hbox{tate math: \DIR}$}
3175
3176 \setbox2=\hbox{\tate}\ltjgetparameter{boxdir}{2}
3177 \end{LTXexample}
3178
3179 これらを用いれば,例えば
3180 \pTeX の \cs{ifydir},~\cs{ifybox200} と同等の条件判断を
3181 \begin{lstlisting}
3182 \ifnum\ltjgetparameter{direction}=4
3183 \ifnum\ltjgetparameter{boxdir}{200}=4
3184 \end{lstlisting}
3185 のように行うことができる.
3186 \cs{iftdir} は少々面倒であるが
3187 \begin{lstlisting}
3188 \ifnum\numexpr
3189   \ltjgetparameter{direction}-(\ltjgetparameter{direction}/8)*8=3
3190 \end{lstlisting}
3191 とすればよい.
3192 %</ja>
3193
3194 %<*en>
3195 \subsection{Overridden box primitives}
3196 To cope with multiple directions, the following primitives are
3197 overridden by \LuaTeX-ja, using~\verb+\protected\def+.
3198 \begin{cslist}[style=standard]
3199  \item[\cs{unhbox}<num>\textrm{, }\cs{unvbox}<num>\textrm{, }\cs{unhcopy}<num>\textrm{, }\cs{unvcopy}<num>]
3200  \item[\cs{vadjust}\{<material>\}]
3201  \item[\cs{insert}<number>\{<material>\}]
3202  \item[\cs{lastbox}]
3203  \item[\cs{raise}<dimen><box>\textrm{, }\cs{lower}<dimen><box>\textrm{\ etc., }\cs{vcenter}]
3204  \item[\cs{vcenter}]
3205 \end{cslist}
3206 %</en>
3207 %<*ja>
3208 \subsection{プリミティブの再定義}
3209 異なる組方向に対応するために,以下に挙げるプリミティブは
3210 \LuaTeX-jaによる前処理もしくは後処理が行われるように
3211 \ \verb+\protected\def+ により再定義してある.
3212
3213 \begin{cslist}
3214  \item[\cs{unhbox}<num>\textrm{, }\cs{unvbox}<num>\textrm{, }\cs{unhcopy}<num>\textrm{, }\cs{unvcopy}<num>]
3215  ボックスの組方向が現在のリストと異なる場合は事前にエラーメッセージを出力する.
3216  \pTeX と異なり,エラーを無視して無理矢理 \cs{unhbox}, \cs{unvbox} を
3217  続行させることもできるが,その場合の組版結果は保証しない.
3218  \item[\cs{vadjust}\{<material>\}] 一旦プリミティブ本来の挙動を行う.その後,<material>の組方向が
3219  周囲の垂直リストの組方向と一致しない場合にエラーを出力し,
3220  該当の \cs{vadjust} を無効にする.
3221  \item[\cs{insert}<number>\{<material>\}]
3222  一旦プリミティブ本来の挙動を行い,その後<material>内の各ボックス・罫線の直前に組方向を示
3223               すdirection whatsitを挿入する.
3224  \item[\cs{lastbox}] ボックスの「中身」を現在の組方向に合わせるためのノード
3225               (\textit{dir\_box}という)を必要ならば除去し,
3226  正しく「中身」のボックスが返されるように前処理をする.
3227  \item[\cs{raise}<dimen><box>\textrm{, }\cs{lower}<dimen><box>\textrm{\ etc., }\cs{vcenter}]
3228  一方,こちらでは必要に応じて\textit{dir\_box}を作成する前処理を追加している.
3229 \end{cslist}
3230 %</ja>
3231
3232 %<en>\section{Font Metric and Japanese Font}
3233 %<ja>\section{フォントメトリックと和文フォント}
3234 %<en>\subsection{\cs{jfont}}
3235 %<ja>\subsection{\cs{jfont} 命令}
3236 \label{ssec-jfont}
3237
3238 %<*en>
3239 To load a font as a Japanese font (for horizontal direction), you must use the
3240 \cs{jfont} instead of~\cs{font}, while
3241 \cs{jfont} admits the same syntax used in~\cs{font}.
3242 \LuaTeX-ja automatically loads \Pkg{luaotfload} package,
3243 so TrueType/OpenType fonts with features can be used for Japanese fonts:
3244 %</en>
3245 %<*ja>
3246 フォントを(横組用)和文フォントとして読み込むためには,\cs{jfont} を
3247 \ \cs{font} プリミティブの代わりに用いる.
3248 \cs{jfont} の文法は \cs{font} と同じである.
3249 \LuaTeX-jaは\Pkg{luaotfload}パッケージを自動的に読み込むので,
3250 TrueType/OpenTypeフォントにfeatureを指定したものを和文フォントとして用いる
3251 ことができる:
3252 %</ja>
3253 \begin{LTXexample}[width=0.3\textwidth]
3254 \jfont\tradgt={file:KozMinPr6N-Regular.otf:script=latn;%
3255   +trad;-kern;jfm=ujis} at 14pt
3256 \tradgt 当/体/医/区
3257 \end{LTXexample}
3258
3259 %<*en>
3260 Note that the defined control sequence
3261 (\cs{tradgt} in the example above) using \cs{jfont} is not a
3262 \textit{font\_def} token,  but a macro.
3263 Hence the input like \verb+\fontname\tradgt+
3264 causes a error.  We denote control sequences which are defined in
3265 \cs{jfont} by <jfont\_cs>.
3266 %</en>
3267 %<*ja>
3268 なお,\cs{jfont} で定義された制御綴(上の例だと \cs{tradgt})
3269 は\textit{font\_def}トークンではなくマクロである.従って,\verb+\fontname\tradgt+ のような
3270 入力はエラーとなる.以下では \cs{jfont} で定義された
3271 制御綴を<jfont\_cs>で表す.
3272 %</ja>
3273
3274 \paragraph{JFM}
3275 %<*en>
3276 a JFM has measurements of characters and
3277 glues/kerns that are automatically inserted for Japanese
3278 typesetting. The structure of JFM will be described in the next
3279 subsection. At the calling of \cs{jfont}, you must specify
3280 which JFM will be used for this font by the following keys:
3281 %</en>
3282 %<*ja>
3283 JFMは文字と和文組版で自動的に挿入される
3284 グルー/カーンの寸法情報を持っている.JFMの構造は次の節で述べる.
3285 \cs{jfont} 命令の呼び出しの際には,どのJFMを用いるのかを以下のキーで
3286 指定する必要がある:
3287 %</ja>
3288
3289
3290 \begin{table}[t]
3291 %<en>\caption{Differences between horizontal JFMs shipped with \LuaTeX-ja}
3292 %<ja>\caption{\LuaTeX-ja に同梱されている横組用JFMの違い}
3293 %<en>\medskip
3294 \label{tab-difjfm}
3295 \ltjsetparameter{jacharrange={+3}}
3296 \centering\small
3297 \def\r#1#2{%
3298   \hbox{\Large\vrule
3299   \parbox[b]{7\zw}{%
3300     \addjfontfeatures{YokoFeatures={Opacity=0.5, Color=#2, JFM=#1}}\noindent
3301     ◆◆◆◆◆◆◆
3302     ある日モモちゃんがお使いで迷子になって泣きました.
3303   }\vrule}}
3304 \def\s#1#2{%
3305   \Large
3306   \parbox[b]{7\zw}{%
3307     \addjfontfeatures{YokoFeatures={Opacity=0.5, Color=#2, JFM=#1}}\noindent
3308     ちょっと!何
3309   }}
3310 \def\t#1#2#3{\hbox to 0pt{\hss%
3311   \setbox0=\hbox{\addjfontfeatures{YokoFeatures={JFM=#1}}\huge #3}%
3312   \textcolor{#2}{\transparent{0.5}\vrule width 0.4pt height\ht0 depth\dp0}\kern-.2pt\copy0
3313   \textcolor{#2}{\transparent{0.5}\kern-\wd0\vrule width\wd0height .2pt depth .2pt
3314   \kern-\wd0\raise\ht0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3315   \kern-\wd0\lower\dp0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3316   \kern-.2pt\vrule width 0.4pt height\ht0 depth \dp0}\hss}}
3317 {\Large\tabcolsep0pt
3318 \begin{tabular}{m{8\zw}m{8\zw}m{8\zw}}
3319 \leavevmode\hbox to 0pt{\r{ujis}{blue}\hss}\r{jis}{black}&
3320 \leavevmode\hbox to 0pt{\r{jis}{black}\hss}\r{min}{red}&
3321 \leavevmode\hbox to 0pt{\r{ujis}{blue}\hss}\r{min}{red}\\
3322 \leavevmode\hbox to 0pt{\s{ujis}{blue}\hss}\s{jis}{black}&
3323 \leavevmode\hbox to 0pt{\s{jis}{black}\hss}\s{min}{red}&
3324 \leavevmode\hbox to 0pt{\s{ujis}{blue}\hss}\s{min}{red}\\
3325 \leavevmode\qquad\t{ujis}{blue}{漢}\t{jis}{black}{漢}\qquad
3326            \t{ujis}{blue}{っ}\t{jis}{black}{っ}&
3327 \leavevmode\qquad\t{jis}{black}{漢}\t{min}{red}{漢}\qquad
3328            \t{jis}{black}{っ}\t{min}{red}{っ}&
3329 \leavevmode\qquad\t{ujis}{blue}{漢}\t{min}{red}{漢}\qquad
3330            \t{ujis}{blue}{っ}\t{min}{red}{っ}\\
3331 \end{tabular}\par}
3332
3333 (\textcolor{blue}{Blue: \texttt{jfm-ujis.lua}},
3334 \textcolor{black}{Black: \texttt{jfm-jis.lua}},
3335 \textcolor{red}{Red: \texttt{jfm-min.lua}})
3336 \ltjsetparameter{jacharrange={-3}}
3337 \end{table}
3338
3339 \begin{cslist}
3340 \item[jfm=<name>]
3341 %<*en>
3342 Specify the name of (horizontal) JFM.
3343 If specified JFM has not been loaded, \LuaTeX-ja search and load
3344 a file named \texttt{jfm-<name>.lua}.
3345
3346 The following JFMs are shipped with \LuaTeX-ja:
3347 %</en>
3348 %<*ja>
3349 用いる(横組用)JFMの名前を指定する.もし以前に指定されたJFMが読み込まれていなければ,
3350 \texttt{jfm-<name>.lua}を読み込む.以下の横組用JFMが\LuaTeX-jaには同梱されている:
3351 %</ja>
3352 \begin{description}
3353 %<*en>
3354 \item[\tt jfm-ujis.lua] A standard JFM in \LuaTeX-ja. This JFM is
3355   based on \verb+upnmlminr-h.tfm+, a metric for UTF/OTF package that
3356   is used in \upTeX. When you use the \Pkg{luatexja-otf} package, you should use this JFM.
3357 %</en>
3358 %<*ja>
3359 \item[\tt jfm-ujis.lua] \LuaTeX-jaの標準JFMである.このJFMは\upTeX で
3360   用いられるUTF/OTFパッケージ用の和文用TFMである \verb+upnmlminr-h.tfm+ を
3361   元にしている.\Pkg{luatexja-otf}パッケージを使うときはこのJFMを指定するべきである.
3362 %</ja>
3363 %<*en>
3364 \item[\tt jfm-jis.lua] A counterpart for \verb+jis.tfm+, ``JIS font
3365   metric'' which is widely used in \pTeX. A major difference between
3366   \texttt{jfm-ujis.lua} and this \texttt{jfm-jis.lua} is that
3367   most characters under \texttt{jfm-ujis.lua} are square-shaped,
3368   while that under \texttt{jfm-jis.lua} are horizontal
3369   rectangles.
3370 %</en>
3371 %<*ja>
3372 \item[\tt jfm-jis.lua] \pTeX で広く用いられている「JISフォントメトリック」
3373   \verb+jis.tfm+ に相当するJFMである.\texttt{jfm-ujis.lua} とこの
3374   \texttt{jfm-jis.lua} の主な違いは,\texttt{jfm-ujis.lua} ではほとんどの文字が
3375   正方形状であるのに対し,\texttt{jfm-jis.lua} では横長の長方形状であることと,
3376   \texttt{jfm-ujis.lua} では「?」「!」の直後に半角空白が挿入されることである.
3377 %</ja>
3378 %<*en>
3379 \item[\tt jfm-min.lua] A counterpart for \verb+min10.tfm+, which is one
3380   of the default Japanese font metric shipped with \pTeX.
3381 %</en>
3382 %<*ja>
3383 \item[\tt jfm-min.lua] \pTeX に同梱されているデフォルトの和文用TFM
3384 (\verb+min10.tfm+)に相当し,行末で文字が揃うようにするために「っ」など一部の文字幅が変わっ
3385            ている.\verb+min10.tfm+ については\cite{min10}が詳しい.
3386 %</ja>
3387 \end{description}
3388 %<*en>
3389 The difference among these three~JFMs is  shown in Table~\ref{tab-difjfm}.
3390 %</en>
3391 %<*ja>
3392 これら3つのJFMの違いは表\ref{tab-difjfm}に示した.表中の文例の一部には,
3393 \cite{min10}の図3,~4のものを用いた.
3394 %</ja>
3395
3396 \begin{figure}
3397 \begin{LTXexample}[width=0.3\textwidth]
3398 \ltjsetparameter{differentjfm=both}
3399 \jfont\F=file:KozMinPr6N-Regular.otf:jfm=ujis
3400 \jfont\G=file:KozGoPr6N-Medium.otf:jfm=ujis
3401 \jfont\H=file:KozGoPr6N-Medium.otf:jfm=ujis;jfmvar=hoge
3402 \F ){\G 【】}( % halfwidth space
3403    ){\H 『』}( % fullwidth space
3404
3405 ほげ,{\G 「ほげ」}(ほげ)\par
3406 ほげ,{\H 「ほげ」}(ほげ)% pTeX-like
3407
3408 \ltjsetparameter{differentjfm=paverage}
3409 \end{LTXexample}
3410 \caption{Example of \texttt{jfmvar} key}
3411 \label{fig:jfmvar}
3412 \end{figure}
3413
3414 %<*en>
3415 \item[jfmvar=<string>]
3416 Sometimes there is a need that \ldots.
3417 %</en>
3418 %<*ja>
3419 \item[jfmvar=<string>]
3420 標準では,JFMとサイズが同じで,
3421   実フォントだけが異なる2つの和文フォントは「区別されない」.例えば
3422 図\ref{fig:jfmvar}において,最初の「)」と「【」の実フォントは異なるが,
3423 JFMもサイズも同じなので,普通に「)【」と入力した時と同じように半角空きとなる.
3424
3425 しかし,JFMとサイズが同じであっても,\texttt{jfmvar} キーの異なる
3426 2つの和文フォント,例えば図\ref{fig:jfmvar}で言う \cs{F} と \cs{H},
3427 は「区別される」.異なる和文フォントに異なる \texttt{jfmvar} キーを割り当て,
3428 かつ\Param{differentjfm}パラメータを \texttt{both} に設定すれば,
3429 \pTeX と似た状況で組版されることになる.
3430 %</ja>
3431 \end{cslist}
3432
3433 \begin{figure}
3434 \begin{LTXexample}[pos=t]
3435 \newcommand\test{\vrule ダイナミックダイクマ\vrule\\}
3436 \jfont\KMFW = KozMinPr6N-Regular:jfm=prop;-kern at 17pt
3437 \jfont\KMFK = KozMinPr6N-Regular:jfm=prop at 17pt % kern is activated
3438 \jfont\KMPW = KozMinPr6N-Regular:jfm=prop;script=dflt;+pwid;-kern at 17pt
3439 \jfont\KMPK = KozMinPr6N-Regular:jfm=prop;script=dflt;+pwid;+kern at 17pt
3440 \begin{multicols}{2}
3441 \ltjsetparameter{kanjiskip=0pt}
3442 {\KMFW\test \KMFK\test \KMPW\test \KMPK\test}
3443
3444 \ltjsetparameter{kanjiskip=3pt}
3445 {\KMFW\test \KMFK\test \KMPW\test \KMPK\test}
3446 \end{multicols}
3447 \end{LTXexample}
3448 \caption{Kerning information and \Param{kanjiskip}}
3449 \label{fig:kern-jfm}
3450 \end{figure}
3451
3452 %<en>\paragraph{Using kerning information in a font}
3453 %<ja>\paragraph{ペアカーニング情報の使用}
3454 \label{para-kern}
3455 %<*en>
3456 Some fonts have information for inter-glyph spacing.
3457 This version of \LuaTeX-ja treats kerning spaces like an italic correction;
3458 any glue and/or kern from the JFM and a kerning space can coexist.
3459 See Figure~\ref{fig:kern-jfm} for detail.
3460
3461 Note that in \cs{setmainjfont} etc.\ which are provided by \Pkg{luatexja-fontspec}
3462 package, kerning option is set \emph{off} (\texttt{Kerning=Off}) by default,
3463 because of the compatibility with previous versions of \LuaTeX-ja.
3464 %</en>
3465 %<*ja>
3466 いくつかのフォントはグリフ間のスペースについての情報を持っている.
3467 このカーニング情報は以前の\LuaTeX-ja とはあまり相性が良くなかったが,
3468 本バージョンではカーニングによる空白はイタリック補正と同様に扱うことになっている.
3469 つまり,カーニング由来の空白とJFM由来のグルー・カーンは同時に入りうる.
3470 図\ref{fig:kern-jfm}を参照.
3471 \begin{itemize}
3472  \item \emph{\cs{jfont} や,
3473 NFSS2用の命令(\ref{ssec-chgfnt}節,\ref{ssec-nfsspat}節)における指定では
3474 カーニング情報は標準で使用する}ことになっているようである.
3475 言い換えれば,カーニング情報を使用しない設定にするには,面倒でも
3476 \begin{lstlisting}
3477 \jfont\hoge=KozMinPr6N-Regular:jfm=ujis;-kern at 3.5mm
3478 \DeclareFontShape{JY3}{fuga}{m}{n} {<-> s*KozMinPr6N-Regular:jfm=ujis;-kern}{}
3479 \end{lstlisting}
3480 のように,\texttt{-kern} という指定を自分で追加しなければいけない.
3481  \item
3482 一方,\emph{\Pkg{luatexja-fontspec} の提供する \cs{setmainjfont}\
3483 などの命令の標準設定ではカーニング情報は使用しない}(\texttt{Kerning=Off})
3484 ことになっている.これは以前のバージョンの\LuaTeX-jaとの互換性のためである.
3485 \end{itemize}
3486 %</ja>
3487
3488 %<*ja>
3489 \paragraph{\texttt{extend}と\texttt{slant}}
3490 OpenType font featureと見かけ上同じような形式で指定できるものに,
3491 \begin{description}
3492 \item[\texttt{extend=}<extend>] 横方向に<extend>倍拡大する.
3493 \item[\texttt{slant=}<slant>] <slant>に指定された割合だけ傾ける.
3494 \end{description}
3495 の2つがある.
3496 \texttt{extend}や\texttt{slant}を指定した場合は,それに応じたJFMを指定すべきである%
3497 \footnote{\LuaTeX-jaでは,これらに対するJFMを特に提供することはしない予定である.}.
3498 例えば,次の例では無理やり通常のJFMを使っているために,文字間隔やイタリック補正量が
3499 正しくない:
3500 %</ja>
3501 %<*en>
3502 \paragraph{\texttt{extend} and \texttt{slant}}
3503 The following setting can be specified as OpenType font features:
3504 \begin{cslist}[style=standard]
3505 \item[\cs{extend=}<extend>] expand the font horizontally by <extend>.
3506 \item[\cs{slant=}<slant>] slant the font.
3507 \end{cslist}
3508 Note that \LuaTeX-ja doesn't adjust JFMs by these \texttt{extend} and \texttt{slant}
3509 settings; you have to write new JFMs on purpose.
3510 For example, the following example uses the standard JFM \texttt{jfm-ujis.lua}, hence
3511 letter-spacing and the width of italic correction are not correct:
3512 %</en>
3513 \begin{LTXexample}[width=0.3\textwidth]
3514 \jfont\E=KozMinPr6N-Regular:extend=1.5;jfm=ujis;-kern
3515 \E あいうえお
3516
3517 \jfont\S=KozMinPr6N-Regular:slant=1;jfm=ujis;-kern
3518 \S あいう\/ABC
3519 \end{LTXexample}
3520
3521 %<en>\subsection{\cs{tfont}}
3522 %<ja>\subsection{\cs{tfont} 命令}
3523
3524
3525 \begin{table}[t]
3526 %<en>\caption{Differences between vertical JFMs shipped with \LuaTeX-ja}
3527 %<ja>\caption{\LuaTeX-ja に同梱されている縦組用 JFM の違い}
3528 %<en>\medskip
3529 \label{tab-difjfm-tate}
3530 \catcode`\<=12\catcode`\>=12
3531 \ltjsetparameter{jacharrange={+3}}
3532 \small
3533
3534 \def\r#1#2{%
3535   \hbox{\tate\Large\vrule
3536   \parbox{7\zw}{%
3537     \addjfontfeatures{TateFeatures={Opacity=0.5, Color=#2, JFM=#1}}\noindent
3538     ◆◆◆◆◆◆◆
3539     ある日モモちゃんがお使いで迷子になって泣きました.
3540   }\vrule}}
3541 \def\s#1#2{%
3542   \hbox{\tate\Large
3543   \parbox{7\zw}{%
3544     \addjfontfeatures{TateFeatures={Opacity=0.5, Color=#2, JFM=#1}}\noindent
3545     ちょっと!何
3546   }}}
3547 \def\t#1#2#3{\hbox to 0pt{\hss%
3548   \setbox0=\hbox{\addjfontfeatures{TateFeatures={JFM=#1}}\huge #3}%
3549   \textcolor{#2}{\transparent{0.5}\vrule width 0.4pt height\ht0 depth\dp0}\kern-.2pt\copy0
3550   \textcolor{#2}{\transparent{0.5}\kern-\wd0\vrule width\wd0height .2pt depth .2pt
3551   \kern-\wd0\raise\ht0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3552   \kern-\wd0\lower\dp0\hbox{\vrule width\wd0height .2pt depth .2pt}%
3553   \kern-.2pt\vrule width 0.4pt height\ht0 depth \dp0}\hss}}
3554
3555 \begin{minipage}{.7\textwidth}
3556 \centering
3557 \leavevmode\hbox to 0pt{\r{ujisv}{blue}\hss}\r{tmin}{red}\quad
3558 \leavevmode\hbox to 0pt{\s{ujisv}{blue}\hss}\s{tmin}{red}\quad
3559 \raise4\zw\hbox{\tate\Large\t{ujisv}{black}{漢}\t{tmin}{red}{漢}\qquad
3560            \t{ujisv}{black}{っ}\t{tmin}{red}{っ}}
3561 \end{minipage}%
3562 \begin{minipage}{.3\textwidth}
3563 \textcolor{blue}{Blue: \texttt{jfm-ujisv.lua}}\\
3564 \textcolor{red}{Red: \texttt{jfm-tmin.lua}}
3565 \end{minipage}
3566 \ltjsetparameter{jacharrange={-3}}
3567 \end{table}
3568
3569 %<*en>
3570 ...
3571 %</en>
3572 %<*ja>
3573 \cs{tfont} はフォントを縦組用の和文フォントとして読み込む命令であり,
3574 \cs{tfont} の文法は \cs{jfont} と同じである.
3575 \cs{tfont} で定義された縦組用和文フォントは,
3576 以下の点が \cs{jfont} による横組用和文フォントとは異なる:
3577 \begin{itemize}
3578  \item 自動的に \texttt{vert}, \texttt{vrt2} の両OpenType featureが有効化される.
3579 但し,以下の例の3行目に示すように,明示的に \texttt{vert}, \texttt{vrt2}(のいずれか)の
3580 有効・無効を指定した場合は別である.
3581 \begin{lstlisting}
3582 \tfont\S=file:KozMinPr6N-Regular.otf:jfm=ujisv 
3583     % vert and vrt2 are automatically activated
3584 \tfont\T=file:KozMinPr6N-Regular.otf:jfm=ujisv;-vert % vert and vrt2 are not activated
3585 \end{lstlisting}
3586  \item \ref{ssec-math}節で述べる,数式中の和文フォントには縦組用和文フォントは指定できない.
3587  \item \texttt{jfm=<name>}\ の部分には縦組用JFMを指定する.
3588 以下の縦組用JFMが\LuaTeX-jaには同梱されており,違いを表\ref{tab-difjfm-tate}に示した.
3589 \begin{description}
3590 \item[\tt jfm-ujisv.lua] \LuaTeX-jaの標準縦組用JFMである.このJFMは\upTeX で
3591   用いられるUTF/OTFパッケージ用の和文用TFMである \verb+upnmlminr-v.tfm+ を
3592   元にしている.
3593 \item[\tt jfm-tmin.lua] \pTeX に同梱されているデフォルトの和文用縦組TFM
3594   である \verb+tmin10.tfm+ に相当し,\texttt{min10.tfm} と同様に
3595   「っ」など一部の文字幅が狭められている.
3596 \end{description}
3597 \end{itemize}
3598
3599 なお,\pTeX では,\cs{font},~\cs{jfont},~\cs{tfont}のどれでも欧文フォント・横組用和文フォン
3600 ト・縦組用和文フォントの定義が可能であったが,\LuaTeX-jaではそうでないので注意.
3601 %</ja>
3602
3603 %<en>\subsection{Prefix \texttt{psft}}
3604 %<ja>\subsection{\texttt{psft}プリフィックス}
3605 \label{ssec-psft}
3606 %<*en>
3607 Besides ``\texttt{file:}''\ and ``\texttt{name:}''\ prefixes which
3608 are introduced in the \Pkg{luaotfload} package,
3609 \LuaTeX-ja adds ``\texttt{psft:}''\ prefix in \cs{jfont} (and~\cs{font}),
3610 to specify a ``name-only'' Japanese font which
3611 will not be embedded to PDF.
3612 Note that these non-embedded fonts under current \LuaTeX\ has Identity-H encoding,
3613 and this violates the standard ISO32000-1:2008~(\cite{pdfstd}).
3614
3615 \emph{OpenType font features, such as ``{\tt +jp90}'',
3616 have no meaning in name-only fonts using ``{\tt psft:}''\ prefix,
3617 because we can't expect what fonts are actually used by the PDF reader.}
3618 Note that \texttt{extend}~and~\texttt{slant} settings (see~above) are supported
3619 with \texttt{psft} prefix, because they are only simple linear transformations.
3620 %</en>
3621 %<*ja>
3622 \Pkg{luaotfload}で使用可能になった
3623 \texttt{file:}\ と \texttt{name:}\ のプリフィックスに加えて,
3624 \cs{jfont}(と \cs{font} プリミティブ)では
3625 \texttt{psft:}プリフィックスを用いることができる.
3626 このプリフィックスを用いることで,PDFには埋め込まれない「名前だけの」
3627 和文フォントを指定することができる.
3628 なお,現行の\LuaTeX で非埋め込みフォントを作成するとPDF内でのエンコーディングが
3629 Identity-Hとなり,PDFの標準規格ISO32000-1:2008~(\cite{pdfstd})に非準拠になってしまう
3630 ので注意してほしい.
3631
3632 \emph{\texttt{psft} プリフィックスの下では
3633 \texttt{+jp90} などのOpenType font featureの効力はない.
3634 非埋込フォントをPDFに使用すると,実際にどのようなフォントが
3635 表示に用いられるか予測できないからである.}\
3636 \texttt{extend} と \texttt{slant} 指定は単なる変形のため
3637 \texttt{psft} プリフィックスでも使用可能である.
3638 %</ja>
3639
3640 %<en>\paragraph{\texttt{cid} key}
3641 %<ja>\paragraph{\texttt{cid}キー}
3642 \label{para-cid}
3643
3644 %<*en>
3645 The default font defined by using \texttt{psft:} prefix is for Japanese typesetting;
3646 it is Adobe-Japan1-6 CID-keyed font.
3647 One can specify \texttt{cid} key to use other CID-keyed non-embedded fonts
3648 for Chinese or Korean typesetting.
3649 %</en>
3650 %<*ja>
3651 標準で\texttt{psft:}プリフィックスで定義されるフォントは日本語用のもので
3652 あり,Adobe-Japan1-6のCIDに対応したものとなる.しかし,\LuaTeX-jaは中国語
3653 の組版にも威力を発揮することが分かり,日本語フォントでない非埋込フォント
3654 の対応も必要となった.そのために追加されたのが\texttt{cid}キーである.
3655
3656 \texttt{cid}キーに値を指定すると,そのCIDを持った非埋込フォントを定義することができる:
3657 %</ja>
3658 \begin{lstlisting}[numbers=left]
3659 \jfont\testJ={psft:Ryumin-Light:cid=Adobe-Japan1-6;jfm=jis}     % Japanese
3660 \jfont\testD={psft:Ryumin-Light:jfm=jis}                        % default value is Adobe-Japan1-6
3661 \jfont\testC={psft:AdobeMingStd-Light:cid=Adobe-CNS1-6;jfm=jis} % Traditional Chinese
3662 \jfont\testG={psft:SimSun:cid=Adobe-GB1-5;jfm=jis}              % Simplified Chinese
3663 \jfont\testK={psft:Batang:cid=Adobe-Korea1-2;jfm=jis}           % Korean
3664 \end{lstlisting}
3665 %<*en>
3666 Note that the code above specifies \texttt{jfm-jis.lua}, which is for Japanese fonts,
3667 as JFM for Chinese and Korean fonts.
3668 %</en>
3669 %<*ja>
3670 上のコードでは中国語・韓国語用フォントに対してもJFMに
3671 日本語用の\texttt{jfm-jis.lua}を指定しているので注意されたい.
3672 %</ja>
3673
3674 %<*en>
3675 At present, \LuaTeX-ja supports only 4 values written in the sample code above.
3676 Specifying other values, e.g.,
3677 %</en>
3678 %<*ja>
3679 今のところ,\LuaTeX-jaは上のサンプルコード中に書いた4つの値しかサポートしていない.
3680 %</ja>
3681 \begin{lstlisting}
3682 \jfont\test={psft:Ryumin-Light:cid=Adobe-Japan2;jfm=jis}
3683 \end{lstlisting}
3684 %<*en>
3685 produces the following error:
3686 %</en>
3687 %<*ja>
3688 のようにそれら以外の値を指定すると,エラーが発生する:
3689 %</ja>
3690 \begin{lstlisting}[numbers=left]
3691 ! Package luatexja Error: bad cid key `Adobe-Japan2'.
3692
3693 See the luatexja package documentation for explanation.
3694 Type  H <return>  for immediate help.
3695 <to be read again>
3696                    \par
3697 l.78
3698
3699 ? h
3700 I couldn't find any non-embedded font information for the CID
3701 `Adobe-Japan2'. For now, I'll use `Adobe-Japan1-6'.
3702 Please contact the LuaTeX-ja project team.
3703 ?
3704 \end{lstlisting}
3705
3706 %<en>\subsection{Structure of a JFM File}
3707 %<ja>\subsection{JFMファイルの構造}
3708 \label{ssec-jfm-str}
3709 %<en>A JFM file is a Lua script which has only one function call:
3710 %<ja>JFMファイルはただ一つの関数呼び出しを含むLuaスクリプトである:
3711 \begin{lstlisting}
3712 luatexja.jfont.define_jfm { ... }
3713 \end{lstlisting}
3714 %<*en>
3715 Real data are stored in the table which indicated above by
3716 \verb+{ ... }+.  So, the rest of this subsection are devoted to describe the
3717 structure of this table.  Note that all lengths in a JFM file are
3718 floating-point numbers in design-size unit.
3719 %</en>
3720 %<*ja>
3721 実際のデータは上で \verb+{ ... }+ で示されたテーブルの中に格納されている.
3722 以下ではこのテーブルの構造について記す.
3723 なお,JFMファイル中の長さは全てdesign-sizeを単位とする浮動小数点数であることに
3724 注意する.
3725 %</ja>
3726
3727 \begin{cslist}[style=standard]
3728
3729 \item[dir=<direction>]
3730 %<en>(required)
3731 %<ja>(必須)
3732
3733 %<*en>
3734 The direction of JFM. \texttt{'yoko'}~(horizontal)
3735 or \texttt{'tate'}~(vertical) are supported.
3736 %</en>
3737 %<*ja>
3738 JFMの書字方向.\texttt{'yoko'}(横組)と \texttt{'tate'}(縦組)がサポートされる.
3739 %</ja>
3740
3741 \item[zw=<length>]
3742 %<en>(required)
3743 %<ja>(必須)
3744
3745 %<en>The amount of the length of the ``full-width''.
3746 %<*ja>
3747 「全角幅」の長さ.この量が \cs{zw} の長さとなる.\pTeX では
3748 「全角幅」\texttt{1zw} は「文字クラス0の文字」の幅と決められていたが,
3749 \LuaTeX-jaではここで指定する.
3750 %</ja>
3751
3752 \item[zh=<length>]
3753 %<en>(required)
3754 %<ja>(必須)
3755
3756 %<en>The amount of the ``full-height'' (height + depth).
3757 %<*ja>
3758 「全角高さ」(height + depth)の長さ.通常は全角幅と同じ長さになるだろう.
3759 \pTeX では 「全角高さ」\texttt{1zh} は「文字クラス0の文字」の高さと深さの和と決められていたが,
3760 \LuaTeX-jaではここで指定する.
3761 %</ja>
3762
3763 \item[kanjiskip=\{<natural>, <stretch>, <shrink>\}]
3764 %<en>(optional)
3765 %<ja>(任意)
3766
3767 %<*en>
3768 This field specifies the ``ideal'' amount of \Param{kanjiskip}. As noted
3769              in Subsection~\ref{subs-kskip}, if the parameter
3770              \Param{kanjiskip} is \cs{maxdimen}, the value specified
3771              in this field is actually used (if this field is not specified in
3772              JFM, it is regarded as 0\,pt). Note that <stretch> and <shrink>
3773              fields are in design-size unit too.
3774 %</en>
3775 %<*ja>
3776 理想的な\Param{kanjiskip}の量を指定する.\ref{subs-kskip}節で述べたように,
3777 もし\Param{kanjiskip}が \cs{maxdimen} の値ならば,このフィールドで指定された
3778 値が実際には用いられる(指定なしは0\,ptとして扱われる).<stretch>と<shrink>のフィールドもdesign-size
3779 が単位であることに注意せよ.
3780 %</ja>
3781
3782 \item[xkanjiskip=\{<natural>, <stretch>, <shrink>\}]
3783 %<en>(optional)
3784 %<ja>(任意)
3785
3786 %<*en>
3787 Like the \texttt{kanjiskip} field, this field specifies the ``ideal''
3788              amount of \Param{xkanjiskip}.
3789 %</en>
3790 %<*ja>
3791 \texttt{kanjiskip}フィールドと同様に,\Param{xkanjiskip}の理想的な量を
3792 指定する.
3793 %</ja>
3794 \end{cslist}
3795
3796 %<*en>
3797 \paragraph{Character classes}
3798 Besides from above fields, a JFM file have several sub-tables those
3799 indices are natural numbers.  The table indexed by~$i\in\omega$ stores
3800 information of \emph{character class}~$i$. At least, the character class~0 is
3801 always present, so each JFM file must have a sub-table whose index is
3802 \texttt{[0]}.  Each sub-table (its numerical index is denoted by $i$) has
3803 the following fields:
3804 %</en>
3805 %<*ja>
3806 \paragraph{文字クラス}
3807 上記のフィールドに加えて,JFMファイルはそのインデックスが自然数であるいくつかの
3808 サブテーブルを持つ.インデックスが$i\in\omega$であるテーブルは\emph{文字クラス}$i$の
3809 情報を格納する.少なくとも,文字クラス0は常に存在するので,JFMファイルはインデックス
3810 が\texttt{[0]}のサブテーブルを持たなければならない.それぞれのサブテーブル
3811 (そのインデックスを$i$で表わす)は以下のフィールドを持つ:
3812 %</ja>
3813
3814 \begin{cslist}[style=standard]
3815 \item[chars=\{<character>, ...\}]
3816 %<en>(required except character class~0)
3817 %<ja>(文字クラス0を除いて必須)
3818
3819 %<*en>
3820 This field is a list of characters which are in this character
3821              type~$i$. This field is optional if $i=0$, since all
3822              \textbf{JAchar} which do not belong  any character classes other
3823              than 0 are in the character class 0
3824              (hence, the character class~0 contains most of
3825              \textbf{JAchar}s). In the list, character(s) can be specified in the following form:
3826 \begin{itemize}
3827 \item a Unicode code point
3828 \item the character itself (as a Lua string, like \hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ'+})
3829 \item a string like \hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ*'+} (the character followed by an asterisk)
3830 \item several ``imaginary'' characters (We will describe these later.)
3831 \end{itemize}
3832 %</en>
3833 %<*ja>
3834 このフィールドは文字クラス$i$に属する文字のリストである.このフィールドは$i=0$の
3835 場合には任意である(文字クラス0には,0以外の文字クラスに属するものを
3836 除いた全ての\textbf{JAchar}が属するから).このリスト中で文字を指定するには,以下の方法がある:
3837 \begin{itemize}
3838 \item Unicode におけるコード番号
3839 \item 「\hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ'+}」のような,文字それ自体
3840 \item 「\hbox{\ltjsetparameter{autoxspacing=false}\verb+'あ*'+}」のような,文字それ自体の後にアスタリスクをつけたもの
3841 \item いくつかの「仮想的な文字」(後に説明する)
3842 \end{itemize}
3843 %</ja>
3844
3845 \item[width=<length>, height=<length>, depth=<length>, italic=<length>]
3846 %<en>(required)
3847 %<ja>(必須)
3848
3849 %<*en>
3850 Specify the width of characters in character class~$i$, the height, the depth and
3851 the amount of italic correction. All characters in character class~$i$ are regarded that its width, height, and depth are
3852 as values of these fields.
3853
3854 But there is one exception: \texttt{width} field can be \texttt{'prop'}.
3855 This means that width of a character becomes that of its ``real'' glyph.
3856 %</en>
3857 %<*ja>
3858 文字クラス$i$に属する文字の幅,高さ,深さ,イタリック補正の量を指定する.
3859 文字クラス$i$に属する全ての文字は,その幅,高さ,深さがこのフィールドで指定した
3860 値であるものとして扱われる.
3861
3862 例外として,\emph{\texttt{width} フィールドには数値以外に \texttt{'prop'} が指定可能である}.
3863 この場合,文字の幅はその「実際の」グリフの幅となる.OpenTypeの \texttt{prop} featureと併用
3864              すれば,これによってプロポーショナル組を行うことができる.
3865 %</ja>
3866
3867 \item[left=<length>, down=<length>, align=<align>]\
3868
3869 %<*en>
3870 These fields are for adjusting the position of the ``real'' glyph. Legal
3871              values of \texttt{align} field are \texttt{'left'},
3872              \texttt{'middle'}, and \texttt{'right'}. If one of these
3873              3~fields are omitted, \texttt{left} and \texttt{down} are
3874              treated as~0, and \texttt{align} field is treated as
3875              \texttt{'left'}.
3876 The effects of these 3~fields are indicated in
3877 Figures \ref{fig-pos}~and~\ref{fig-pos-tate}.
3878 %</en>
3879 %<*ja>
3880 これらのフィールドは実際のグリフの位置を調整するためにある.
3881 \texttt{align} フィールドに指定できる値は \texttt{'left'}, \texttt{'middle'},
3882 \texttt{'right'} のいずれかである.もしこれら3つのフィールドのうちの1つが省かれた
3883 場合,\texttt{left} と \texttt{down} は0,\texttt{align} フィールドは
3884 \ \texttt{'left'} であるものとして扱われる.
3885 これら3つのフィールドの意味については図\ref{fig-pos}(横組用和文フォント),
3886 図\ref{fig-pos-tate}(縦組用和文フォント)で説明する.
3887 %</ja>
3888
3889 %<*en>
3890 In most cases, \texttt{left} and \texttt{down} fields are~0, while
3891 it is not uncommon that the \texttt{align} field is \texttt{'middle'} or \texttt{'right'}.
3892 For example, setting the \texttt{align} field to \texttt{'right'} is practically needed
3893 when the current character class is the class for opening delimiters'.
3894 %</en>
3895 %<*ja>
3896 多くの場合,\texttt{left}と\texttt{down}は0である一方,
3897 \texttt{align}フィールドが\texttt{'middle'}や\texttt{'right'}であることは
3898 珍しいことではない.
3899 例えば,\texttt{align}フィールドを\texttt{'right'}に指定することは,
3900 文字クラスが開き括弧類であるときに実際必要である.
3901 %</ja>
3902
3903 \begin{figure}[!tb]
3904 \begin{minipage}{0.4\textwidth}%
3905 \begin{center}\unitlength=10pt\small
3906 \begin{picture}(15,12)(-1,-4)
3907 \color{b_gray}% jfm
3908 \put(0,0){\vrule width 12\unitlength height 8\unitlength depth 3\unitlength}
3909
3910 \color{b_pink}% step1
3911 \put(-1,-1.5){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
3912
3913 \color{red}% real glyph
3914 \thicklines
3915 \put(-1,-1.5){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
3916 \put(5,-1.5){\line(0,1){7}\line(0,-1){2.5}}
3917 \put(-1,5.5){\line(1,0){6}}
3918 \put(-1,-4){\line(1,0){6}}
3919
3920 \color{b_green}% real glyph
3921 \put(3,0){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
3922
3923 \color{black}% jfm
3924 \thicklines
3925 \put(0,0){\vector(0,1){8}\line(0,-1){3}\vector(1,0){12}}
3926 \put(12,0){\line(0,1){8}\vector(0,-1){3}}
3927 \put(0,8){\line(1,0){12}}
3928 \put(0,-3){\line(1,0){12}}
3929 \put(0.2,4){\makebox(0,0)[l]{\texttt{height}}}
3930 \put(12.2,-1.5){\makebox(0,0)[l]{\texttt{depth}}}
3931 \put(6,0.2){\makebox(0,0)[b]{\texttt{width}}}
3932
3933 \color{green}% step1
3934 \thicklines
3935 \put(3,0){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
3936 \put(9,0){\line(0,1){7}\line(0,-1){2.5}}
3937 \put(3,7){\line(1,0){6}}
3938 \put(3,-2.5){\line(1,0){6}}
3939 \newsavebox{\eqdist}
3940 \savebox{\eqdist}(0,0)[b]{%
3941   \thinlines
3942   \put(-0.08,0.2){\line(0,-1){0.4}}%
3943   \put(0.08,0.2){\line(0,-1){0.4}}}
3944 \put(1.5,0){\usebox{\eqdist}}
3945 \put(10.5,0){\usebox{\eqdist}}
3946
3947 \color{blue}% shifted
3948 \thicklines
3949 \put(3,-1.5){\vector(-1,0){4}}
3950 \put(1,-1.7){\makebox(0,0)[t]{\texttt{left}}}
3951 \put(3,0){\vector(0,-1){1.5}}
3952 \put(3.2,-0.75){\makebox(0,0)[l]{\texttt{down}}}
3953 \end{picture}
3954 \end{center}
3955 \end{minipage}%
3956 \begin{minipage}{0.6\textwidth}%
3957 %<*en>
3958 Consider a  Japanese character node which belongs to
3959 a character class whose the \texttt{align}
3960 field is \texttt{'middle'}.
3961 %</en>
3962 %<*ja>
3963 \texttt{align}フィールドの値が \texttt{'middle'} であるような文字クラスに属する
3964 和文文字ノードを考えよう.
3965 %</ja>
3966 \begin{itemize}
3967 \item
3968 %<*en>
3969 The black rectangle is the imaginary body of the node.
3970 Its width, height, and depth are specified by JFM.
3971 %</en>
3972 %<*ja>
3973 黒色の長方形はノードの枠であり,
3974 その幅,高さ,深さはJFMによって指定されている.
3975 %</ja>
3976 \item
3977 %<*en>
3978 Since the \texttt{align} field is \texttt{'middle'},
3979 the ``real'' glyph is centered horizontally (the green rectangle) first.
3980 %</en>
3981 %<*ja>
3982 \texttt{align}フィールドは \texttt{'middle'} なので,
3983 実際のグリフの位置はまず水平方向に中央揃えしたものとなる(緑色の長方形).
3984 %</ja>
3985 \item
3986 %<*en>
3987 Furthermore, the glyph is shifted according to values of fields
3988       \texttt{left} and \texttt{down}. The ultimate position of the real
3989       glyph is indicated by the red rectangle.
3990 %</en>
3991 %<*ja>
3992 さらに,グリフは \texttt{left} と \texttt{down} の値に従ってシフトされる.
3993 最終的な実際のグリフの位置は赤色の長方形で示された位置になる.
3994 %</ja>
3995 \end{itemize}
3996 \end{minipage}
3997 \medskip
3998
3999 \caption{%
4000 %<en>The position of the real glyph (horizontal Japanese fonts)
4001 %<ja>横組和文フォントにおける「実際の」グリフの位置
4002 }
4003 \label{fig-pos}
4004 \end{figure}
4005 \begin{figure}[!tb]
4006 \begin{minipage}{0.4\textwidth}%
4007 \begin{center}\unitlength=10pt\small
4008 \begin{picture}(15,12)(-6,0)
4009 \color{b_gray}% jfm
4010 \put(-6,0){\vrule width 12\unitlength height 11\unitlength}
4011
4012 \color{b_pink}% real glyph
4013 \put(-6.5,5.5){\vrule width 8\unitlength height 6\unitlength depth 3\unitlength}
4014
4015 \color{red}% real glyph
4016 \thicklines
4017 \put(-6.5,5.5){\vector(0,1){6}\vector(0,-1){3}\vector(1,0){8}}
4018 \put( 1.5,5.5){\line(0,1){6}\line(0,-1){3}}
4019 \put(-6.5,11.5){\line(1,0){8}}
4020 \put(-6.5,2.5){\line(1,0){8}}
4021
4022 \color{b_green}% step1
4023 \put(-4,3){\vrule width 8\unitlength height 6\unitlength depth 3\unitlength}
4024
4025 \color{black}% jfm
4026 \thicklines
4027 \put(0,11){\vector(1,0){6}\vector(-1,0){6}\vector(0,-1){11}}
4028 \put(0,0){\line(1,0){6}\line(-1,0){6}}
4029 \put(-6,0){\line(0,1){11}}
4030 \put( 6,0){\line(0,1){11}}
4031 \put( 3,10.8){\makebox(0,0)[t]{\texttt{height}}}
4032 \put(-3,10.8){\makebox(0,0)[t]{\texttt{depth}}}
4033 \put(0.2,5.5){\makebox(0,0)[l]{\texttt{width}}}
4034
4035 \color{green}% step1
4036 \thicklines
4037 \put(-4,3){\vector(0,1){6}\vector(0,-1){3}\vector(1,0){8}}
4038 \put( 4,3){\line(0,1){6}\line(0,-1){3}}
4039 \put(-4,9){\line(1,0){8}}
4040 \put(-4,0){\line(1,0){8}}
4041 \savebox{\eqdist}(0,0)[b]{%
4042   \thinlines
4043   \put(-0.08,0.2){\line(0,-1){0.4}}%
4044   \put(0.08,0.2){\line(0,-1){0.4}}}
4045 \put(2,9){\usebox{\eqdist}}
4046 \put(-2,9){\usebox{\eqdist}}
4047
4048
4049 \color{blue}% shifted
4050 \thicklines
4051 \put(-4,3){\vector(0,1){2.5}}
4052 \put(-3.8,4.25){\makebox(0,0)[l]{\texttt{left}}}
4053 \put(-4,5.5){\vector(-1,0){2.5}}
4054 \put(-5.,5.7){\makebox(0,0)[b]{\texttt{down}}}
4055 \end{picture}
4056 \end{center}
4057 \end{minipage}%
4058 \begin{minipage}{0.6\textwidth}%
4059 %<*en>
4060 (\dots)
4061 %</en>
4062 %<*ja>
4063 \texttt{align}フィールドの値が \texttt{'right'} であるような文字クラスに属する
4064 和文文字を考えよう.
4065 \begin{itemize}
4066 \item
4067 実際のグリフの「垂直位置」は,まずベースラインが文字の物理的な左右方向の中央を通る
4068 位置となる.
4069 \item
4070 また,この場合 \texttt{align} フィールドは \texttt{'right'} なので,
4071 「水平位置」は字送り方向に「右寄せ」したものとなる(緑色の長方形).
4072 \item
4073 その後さらに \texttt{left} と \texttt{down} の値に従ってシフトされる
4074 のは横組用和文フォントと変わらない.
4075 \end{itemize}
4076 %</ja>
4077 \end{minipage}
4078 \medskip
4079
4080 \caption{%
4081 %<en>The position of the real glyph (vertical Japanese fonts)
4082 %<ja>縦組和文フォントにおける「実際の」グリフの位置
4083 }
4084 \label{fig-pos-tate}
4085 \end{figure}
4086
4087 \item[kern={\{[$j$]=<kern>, [$j'$]=\{<kern>, [<ratio>]\}, ...\}}]
4088
4089 \item[glue={\{[$j$]=\{<width>, <stretch>, <shrink>, [<priority>], [<ratio>]\}, ...\}}]\
4090 %<*ja>
4091
4092 文字クラス$i$の文字と$j$の文字の間に挿入されるkernやglueの量を指定する.
4093
4094              <priority>は \Pkg{luatexja-adjust} による優先順位付き
4095              行長調整(\ref{ssec-adj}節)が有効なときのみ意味を持つ.
4096 このフィールドは省略可能であり,行調整処理におけるこのglueの優先
4097              度を$-2$から$+2$の間の整数で指定する.大きい値ほど「伸びやすく,縮みやすい」
4098              ことを意味する.省略時の値
4099              は0であり,範囲外の値が指定されたときの動作は未定義である.
4100
4101 <ratio>も省略可能フィールドであり,$-1$から$+1$の実数値をとる.省略時の値は0である.
4102 \begin{itemize}
4103 \item $-1$はこのグルーが「前の文字」由来であることを示す.
4104 \item $+1$はこのグルーが「後の文字」由来であることを示す.
4105 \item それ以外の値は,「前の文字」由来のグルーと「後の文字」由来の
4106 グルーが混合されていることを示す.
4107 \end{itemize}
4108 なお,このフィールドの値は\Param{differentjfm}の値が
4109 \texttt{pleft},~\texttt{pright},~\texttt{paverage}の値のときのみ実際に用いられる.
4110
4111 例えば,\cite{x4051}では,句点と中点の間には,
4112 句点由来の二分空きと中点由来の四分空きが挿入されるが,この場合には
4113 \begin{itemize}
4114 \item <width>には$0.5+0.25=0.75$を指定する.
4115 \item <ratio>には次の値を指定する.
4116 \[
4117  -1\cdot \frac{0.5}{0.5+0.25} + 1 \cdot \frac{0.25}{0.5+0.25} = -\frac13
4118 \]
4119 \end{itemize}
4120 %</ja>
4121 %<*en>
4122 \
4123
4124 Specifies the width of kern or glue which will be inserted
4125 between characters in character class~$i$ and those in character class~$j$.
4126
4127 <priority> is an integer in $[-2,2]$ (treated as 0 if omitted), and this is
4128 used only in line adjustment with priority by \Pkg{luatexja-adjust}
4129 (see Subsection~\ref{ssec-adj}). Higher value means the glue is easy to shretch,
4130 and is also easy to shrink.
4131
4132 <ratio> is also an optional value between $-1$ and 1. For example,
4133 The width of a glue between an ideographic full stop ``。''
4134 and a fullwidth middle dot ``・'' is three-fourth of fullwidth,
4135 namely halfwidth from the ideographic full stop, and
4136 quarter-width from the fullwidth middle dot.  In this case,
4137 we specify <ratio> to
4138 \[
4139   -1\cdot \frac{0.5}{0.5+0.25} + 1 \cdot \frac{0.25}{0.5+0.25} = -\frac13.
4140 \]
4141 %</en>
4142
4143
4144 \item[end\_stretch=<kern>, end\_shrink=<kern>]
4145 %<*ja>
4146 (任意)
4147
4148 優先順位付き行長調整が有効であり,かつ現在の文字クラスの文字が行
4149              末に来た時に,行長を詰める調整・伸ばす調整のた
4150              めにこの文字と行末の間に挿入可能なカーンの大きさを指定する.
4151 %</ja>
4152
4153 \end{cslist}
4154
4155 %<*ja>
4156 \paragraph{文字クラスの決定}
4157 文字からその文字の属する文字クラスを算出する過程は少々複雑である.
4158 次の内容を一部に含んだ \texttt{jfm-test.lua} を用いて説明する.
4159 %</ja>
4160 %<*en>
4161 \paragraph{Character to character classes}
4162 We explain how the character class of a character is determined,
4163 using  \texttt{jfm-test.lua} which contains the following:
4164 %</en>
4165 \begin{lstlisting}
4166    [0] = {
4167       chars = { '漢' },
4168       align = 'left', left = 0.0, down = 0.0,
4169       width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
4170    },
4171    [2000] = {
4172       chars = { '。', 'ヒ' },
4173       align = 'left', left = 0.0, down = 0.0,
4174       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
4175    },
4176 \end{lstlisting}
4177 %<ja>ここで,次のような入力とその実行結果を考える:
4178 %<en>Now consider the following input/output:
4179 \begin{LTXexample}[width=0.3\textwidth]
4180 \jfont\a=file:KozMinPr6N-Regular.otf:jfm=test;+hwid
4181 \setbox0\hbox{\a ヒ漢}
4182 \the\wd0
4183 \end{LTXexample}
4184 %<*en>
4185 Now we look why the above source outputs 15\,pt.
4186 \begin{enumerate}
4187 \item The character ``ヒ'' is converted to its half width  form ``ヒ'' by \verb+hwid+ feature.
4188 \item According to the JFM, the character class of ``ヒ'' is 2000, hence its width is halfwidth.
4189 \item The character class of ``漢'' is zero,  hence its width is fullwidth.
4190 \item Hence the width of \cs{hbox} equals to 15\,pt.
4191 \end{enumerate}
4192 This example shows that the character class of a character is generally determined \emph{after
4193 applying font features by \Pkg{luaotfload}}.
4194 %</en>
4195 %<*ja>
4196 上記の出力結果が,15\,ptとなっているのは理由によるものである:
4197 \begin{enumerate}
4198 \item \verb+hwid+ featureによって「ヒ」が半角幅のグリフ「ヒ」と置き換わる(\Pkg{luaotfload} による処理).
4199 \item JFMによれば,この「ヒ」のグリフの文字クラスは2000である.
4200 \item 以上により文字クラス2000とみなされるため,結果として「ヒ」の幅は半角だと認識される.
4201 \end{enumerate}
4202 この例は,\emph{文字クラスの決定はfont featureの適用によるグリフ置換の後に行われる}ことを
4203 示している.
4204 %</ja>
4205
4206 %<*en>
4207 However, ...
4208 Consider the following input:
4209 %</en>
4210 %<*ja>
4211 但し,JFMによって決まる置換後のグリフの文字クラスが0である場合は,
4212 状況は異なる.
4213 %</ja>
4214 \begin{LTXexample}[width=0.3\textwidth]
4215 \jfont\a=file:KozMinPr6N-Regular.otf:jfm=test;+vert
4216 \a 漢。\inhibitglue 漢
4217 \end{LTXexample}
4218 %<*en>
4219 Here, the character class of the ideographic full stop ``。''~(\texttt{U+3002}) is determined
4220 as following:
4221 \begin{enumerate}
4222 \item As the case of ``ヒ'', the ideographic full stop ``。'' is converted to its vertical
4223       form ``\char"FE12''~(\texttt{U+FE12}).%"
4224 \item The character class of ``\char"FE12'' is \emph{zero}.
4225 \item However, \LuaTeX-ja remembers that this ``\char"FE12'' is obtained from ``。'' by
4226       font features. The character class of ``。'' is \emph{non-zero value}, namely, 2000.
4227 \item Hence the ideographic full stop ``。'' in above belongs the character class~2000.
4228 \end{enumerate}
4229 %</en>
4230 %<*ja>
4231 ここで,句点「。」(\texttt{U+3002})の文字クラスは,以下のようにして決まる.
4232 \begin{enumerate}
4233 \item \Pkg{luaotfload} によって縦組用句点のグリフに置き換わる.
4234 \item 置換後のグリフは \texttt{U+FE12} であり,JFMに従えば文字クラスは\emph{0}と判定される.
4235 \item この場合,置換前の横組用句点のグリフによって文字クラスを判定する.
4236 \item 結果として,上の出力例中の句点の文字クラスは2000となる.
4237 \end{enumerate}
4238 %</ja>
4239
4240
4241 %<ja>\paragraph{仮想的な文字}
4242 %<en>\paragraph{Imaginary characters}
4243 %<*en>
4244 As described before, you can specify several \emph{imaginary characters} in
4245 \texttt{chars} field. The most of these characters are regarded as the
4246 characters of class 0 in \pTeX.
4247 As a result, \LuaTeX-ja can control typesetting finer than \pTeX.
4248 The following is the list of imaginary characters:
4249 %</en>
4250 %<*ja>
4251 上で説明した通り,\texttt{chars}フィールド中にはいくつかの「特殊文字」も
4252 指定可能である.これらは,大半が\pTeX のJFMグルーの挿入処理ではみな「文字
4253 クラス0の文字」として扱われていた文字であり,その結果として\pTeX より細か
4254 い組版調整ができるようになっている.以下でその一覧を述べる:
4255 %</ja>
4256
4257 \begin{cslist}
4258 %%\item['diffmet']
4259 %%<en>Used at a boundary between two \textbf{JAchar}s whose JFM or size is different.
4260 %%<ja>JFMやサイズが異なる2つの\textbf{JAchar}の間の境界として用いられる.
4261
4262 \item['boxbdd']
4263 %<en>The beginning/ending of a hbox, and the beginning of a noindented (i.e., began by \cs{noindent}) paragraph.
4264 %<ja>hboxの先頭と末尾,及びインデントされていない(\cs{noindent} で開始された)段落の先頭を表す.
4265
4266 \item['parbdd']
4267 %<en>The beginning of an (indented) paragraph.
4268 %<ja>通常の(\cs{noindent} で開始されていない)段落の先頭.
4269
4270 \item['jcharbdd']
4271 %<en>A boundary between \textbf{JAchar} and anything else (such as \textbf{ALchar}, kern, glue,\,\ldots).
4272 %<ja>和文文字と「その他のもの」(欧文文字,glue,kern等)との境界.
4273
4274 \item[$-1$]
4275 %<en>The left/right boundary of an inline math formula.
4276 %<ja>行中数式と地の文との境界.
4277 \end{cslist}
4278
4279 %<en>\paragraph{Porting JFM from \pTeX}
4280 %<ja>\paragraph{\pTeX 用和文用TFMの移植}
4281
4282 % ToDo: English version.
4283
4284 %<*en>
4285 See Japanese version of this manual.
4286 %</en>
4287
4288 %<*ja>
4289 以下に,\pTeX 用に作られた和文用TFMを\LuaTeX-ja用に移植する場合の注意点を挙げておく.
4290 \begin{itemize}
4291 \item 実際に出力される和文フォントのサイズがdesign sizeとなる.
4292 このため,例えば$1\,\textrm{zw}$がdesign sizeの0.962216倍であるJISフォン
4293       トメトリック等を移植する場合は,次のようにするべきである:
4294 \begin{itemize}
4295 \item JFM中の全ての数値を$1/0.962216$倍しておく.
4296 \item \TeX ソース中で使用するところで,サイズ指定を0.962216倍にする.
4297       \LaTeX でのフォント宣言なら,例えば次のように:
4298 \begin{lstlisting}
4299 \DeclareFontShape{JY3}{mc}{m}{n}{<-> s*[0.962216] psft:Ryumin-Light:jfm=jis}{}
4300 \end{lstlisting}
4301 \end{itemize}
4302 \item 上に述べた特殊文字は,\texttt{'boxbdd'}を除き文字クラスを全部0とする
4303       (JFM中に単に書かなければよい).
4304 \item \texttt{'boxbdd'}については,それのみで一つの文字クラスを形成し,その
4305       文字クラスに関してはグルー/カーンの設定はしない.
4306
4307 これは,\pTeX では,
4308       hboxの先頭・末尾とインデントされていない(\cs{noindent} で開始さ
4309       れた)段落の先頭にはJFMグルーは入らないという仕様を実現させるためである.
4310 \item \pTeX の組版を再現させようというのが目的であれば以上の注意を守れば十分である.
4311
4312 ところで,\pTeX では通常の段落の先頭にJFMグルーが残るという仕様があるので,
4313       段落先頭の開き括弧は全角二分下がりになる.全角下がりを実現させるに
4314       は,段落の最初に手動で \cs{inhibitglue} を追加するか,あるいは
4315       \ \cs{everypar} のハックを行い,それを自動化させるしかなかった.
4316
4317 一方,\LuaTeX-jaでは,\texttt{'parbdd'}によって,それがJFM側で調整できるよ
4318 うになった.例えば,\LuaTeX-ja同梱のJFMのように,\texttt{'boxbdd'}と同じ文字クラスに
4319 \texttt{'parbdd'}を入れれば全角下がりとなる.
4320
4321 \begin{LTXexample}[width=0.4\textwidth]
4322 \jfont\g=KozMinPr6N-Regular:jfm=test \g
4323 \parindent1\zw\noindent{}◆◆◆◆◆
4324 \par 「◆◆←二分下がり
4325 \par 【◆◆←全角下がり
4326 \par 〔◆◆←全角二分下がり
4327 \end{LTXexample}
4328 \end{itemize}
4329
4330 但し,\cs{everypar} を利用している場合にはこの仕組みは正しく動かない.
4331 そのような例としては箇条書き中の \cs{item} で始まる段落があり,\Pkg{ltjsclasses}では
4332 人工的に「\texttt{'parbdd'}の意味を持つ」whatsitノードを作ることによって対処している%
4333 \footnote{\texttt{ltjsclasses.dtx} を参照されたい.
4334 JFM側で一部の対処ができることにより,\Pkg{jsclasses}のようにif文の判定はしていない.}.
4335 %</ja>
4336
4337
4338 %<en>\subsection{Math Font Family}
4339 %<ja>\subsection{数式フォントファミリ}
4340 \label{ssec-math}
4341
4342 %<*en>
4343 \TeX\ handles fonts in math formulas by 16~font families\footnote{Omega,
4344 Aleph, \LuaTeX~and $\varepsilon$-\kern-.125em(u)\pTeX\ can handles 256~families, but
4345 an external package is needed to support this in plain \TeX\ and
4346 \LaTeX.}, and each family has three fonts:
4347 \cs{textfont}, \cs{scriptfont} and \cs{scriptscriptfont}.
4348 %</en>
4349 %<*ja>
4350 \TeX\ は数式フォントを16のファミリ\footnote{Omega, Aleph, \LuaTeX,そして
4351   $\varepsilon$-\kern-.125em(u)\pTeX\ では256の数式ファミリを扱うことができるが,
4352   これをサポートするためにplain \TeX と\LaTeX では外部パッケージを読み込む必要が
4353   ある.}で管理し,それぞれのファミリは3つのフォントを持っている:
4354 \cs{textfont}, \cs{scriptfont} そして \cs{scriptscriptfont} である.
4355 %</ja>
4356
4357 %<*en>
4358 \LuaTeX-ja's handling of Japanese fonts in math formulas is similar;
4359 Table~\ref{tab-math} shows counterparts to \TeX's primitives for math
4360 font families. There is no relation between the value of
4361 \cs{fam} and that of \cs{jfam}; with appropriate settings,
4362 you can set both \cs{fam} and \cs{jfam} to the same value.
4363 Here <jfont\_cs> in the argument of \Param{jatextfont} etc.\ is
4364 a control sequence which is defined by \cs{jfont}, i.e.,
4365 a \emph{horizontal} Japanese font.
4366 %</en>
4367 %<*ja>
4368 \LuaTeX-jaの数式中での和文フォントの扱いも同様である.
4369 表\ref{tab-math}は数式フォントファミリに対する \TeX のプリミティブと対応する
4370 ものを示している.\cs{fam} と \cs{jfam} の値の間には関係はなく,
4371 適切な設定の下では \cs{fam} と \cs{jfam} の両方に同じ値を設定することができる.
4372 \Param{jatextfont} 他の第2引数<jfont\_cs>は,\cs{jfont} で定義された
4373 \emph{横組用}和文フォントである.\cs{tfont} で定義された
4374 \emph{縦組用}和文フォントを指定することは想定していない.
4375 %</ja>
4376
4377 \begin{table}[!tb]
4378 %<en>\caption{Commands for Japanese math fonts}
4379 %<ja>\caption{和文数式フォントに対する命令}
4380 \label{tab-math}
4381 %<en>\medskip
4382 \centering
4383 \def\{{\char`\{}\def\}{\char`\}}\small
4384 \begin{tabular}{ll}
4385 \toprule
4386 %<en>\bf Japanese fonts&\bf alphabetic fonts\\
4387 %<ja>\bf 和文フォント&\bf 欧文フォント\\
4388 \midrule
4389 \cs{jfam}${}\in [0,256)$&\cs{fam}\\
4390 \tt\Param{jatextfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\cs{textfont}<fam>=<font\_cs>\\
4391 \tt\Param{jascriptfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\cs{scriptfont}<fam>=<font\_cs>\\
4392 \tt\Param{jascriptscriptfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\cs{scriptscriptfont}<fam>=<font\_cs>\\
4393 \bottomrule
4394 \end{tabular}
4395 \end{table}
4396
4397 %<en>\subsection{Callbacks}
4398 %<ja>\subsection{コールバック}
4399
4400 %<*en>
4401 \LuaTeX-ja also has several callbacks. These callbacks can
4402 be accessed via \verb+luatexbase.add_to_callback+ function and so on, as other callbacks.
4403 %</en>
4404 %<*ja>
4405 \LuaTeX 自体のものに加えて,\LuaTeX-jaもコールバックを持っている.
4406 これらのコールバックには,他のコールバックと同様に \verb+luatexbase.add_to_callback+
4407 関数などを用いることでアクセスすることができる.
4408 %</ja>
4409 \begin{description}[font=\bfseries, style=nextline]
4410 %<en>\item[\texttt{luatexja.load\_jfm} callback]
4411 %<ja>\item[\texttt{luatexja.load\_jfm}コールバック]
4412 %<*en>
4413 With this callback you can overwrite JFMs.
4414 This callback is called when a new JFM is loaded.
4415 %</en>
4416 %<*ja>
4417 このコールバックを用いることでJFMを上書きすることができる.
4418 このコールバックは新しいJFMが読み込まれるときに呼び出される.
4419 %</ja>
4420
4421 \begin{lstlisting}[numbers=left]
4422 function (<table> jfm_info, <string> jfm_name)
4423   return <table> new_jfm_info
4424 end
4425 \end{lstlisting}
4426
4427 %<*en>
4428 The argument \verb+jfm_info+ contains a table similar to the table in a JFM file, except
4429 this argument has \texttt{chars} field which contains character codes
4430              whose character class is not~0.
4431 %</en>
4432 %<*ja>
4433 引数 \verb+jfm_info+ はJFMファイルのテーブルと似たものが格納されるが,
4434 クラス0を除いた文字のコードを含んだ\texttt{chars}フィールドを持つ点が異なる.
4435 %</ja>
4436
4437 %<*en>
4438 An example of this callback is the \texttt{ltjarticle} class, with
4439              forcefully assigning character class~0 to \texttt{'parbdd'}
4440              in the JFM \texttt{jfm-min.lua}.
4441 %</en>
4442 %<*ja>
4443 このコールバックの使用例は\texttt{ltjarticle}クラスにあり,
4444 \texttt{jfm-min.lua}中の\texttt{'parbdd'}を強制的にクラス0に割り当てている.
4445 %</ja>
4446
4447 %<en>\item[\texttt{luatexja.define\_jfont} callback]
4448 %<ja>\item[\texttt{luatexja.define\_jfont}コールバック]
4449 %<*en>
4450 This callback and the next callback form a pair, and you can assign characters
4451  which do not have fixed code points in Unicode to non-zero character classes.
4452 This \texttt{luatexja.define\_font} callback is called just when new Japanese font is loaded.
4453 %</en>
4454 %<*ja>
4455 このコールバックと次のコールバックは組をなしており,Unicode中に固定された文字コード
4456 番号を持たない文字を非零の文字クラスに割り当てることができる.
4457 このコールバックは新しい和文フォントが読み込まれたときに呼び出される.
4458 %</ja>
4459
4460 \begin{lstlisting}[numbers=left]
4461 function (<table> jfont_info, <number> font_number)
4462   return <table> new_jfont_info
4463 end
4464 \end{lstlisting}
4465 %<*en>
4466 \verb+jfont_info+ has the following fields,
4467 \emph{which may not overwritten by a user}:
4468 \begin{description}
4469 \item[\texttt{size}]
4470 The font size specified at \cs{jfont} in scaled points ($1\,\mathrm{sp}=2^{-16}\,\mathrm{pt}$).
4471 \item[\texttt{zw}, \texttt{zh}, \texttt{kanjiskip}, \texttt{xkanjiskip}]
4472 These are scaled value of those specified by the JFM, by the font size.
4473 \item[\texttt{jfm}]
4474 The internal number of the JFM.
4475 \item[\texttt{var}]
4476 The value of \texttt{jfmvar}~key, which is specified at \cs{jfont}.
4477 The default value is the empty string.
4478 \item[\texttt{chars}]
4479 The mapping table from character codes to its character classes.\\
4480 The specification \texttt{[i].chars=\{<character>, ...\}} in the JFM will be  stored in this
4481            field as \texttt{chars=\{[<character>]=\,$i$, ...\}}.
4482 \item[\texttt{char\_type}]
4483 For $i\in\omega$, \texttt{char\_type[$i$]} is information of characters whose class is
4484            $i$, and has the following fields:
4485 \begin{itemize}
4486  \item \texttt{width},~\texttt{height}, \texttt{depth},
4487   \texttt{italic}, \texttt{down},~\texttt{left}\ are just
4488        scaled value of those specified by the JFM, by the font size.
4489  \item \texttt{align} is a number which is determined from \texttt{align}~field in the JFM:
4490 \[
4491  \begin{cases}
4492   0&\text{\texttt{'left'} and the default value}\\0.5&\text{\tt 'middle'}\\1&\text{\tt 'right'}
4493  \end{cases}
4494 \]
4495 \item For $j\in \omega$, \texttt{[$j$]} stores a kern or a glue which will be inserted
4496 between character class~$i$ and class~$j$.
4497
4498 If a kern will be inserted, the value of this field is \texttt{[$j$]=\{false, <kern\_node>, <ratio>\}},
4499 where <kern\_node> is a node\footnote{%
4500  This version of \LuaTeX-ja uses ``direct access
4501       model'' for accessing nodes, if possible. }.
4502 If a glue will be inserted, we have \texttt{[$j$]=\{false, <spec\_node>, <ratio>, <icflag>\}},
4503 where <spec\_node> is also a node, and $\text{<icflag>}=\textit{from\_jfm}+\text{<priority>}$.
4504 \end{itemize}
4505 \end{description}
4506 %</en>
4507 %<*ja>
4508 \verb+jfont_info+ は最低限以下のフィールドを持つが,これらを書き換えてはならない:
4509 \begin{cslist}
4510 \item[size]
4511 実際に使われるフォントサイズ(sp単位).$1\,\mathrm{sp}=2^{-16}\,\mathrm{pt}$.
4512 \item[zw\textrm{, }zh\textrm{, }kanjiskip\textrm{, }xkanjiskip]
4513 JFMファイルで指定されているそれぞれの値をフォントサイズに合わせてスケーリングしたものを
4514 sp単位で格納している.
4515 \item[jfm]
4516 利用されているJFMを識別するための番号.
4517 \item[var]
4518 \cs{jfont},~\cs{tfont} で指定された \texttt{jfmvar} キーの値(未指定のときは空文字列).
4519 \item[chars]
4520 文字コードから文字クラスへの対応が記述されたテーブル.\\
4521 JFM内の \texttt{[i].chars=\{<character>, ...\}} という指定は\
4522 \texttt{chars=\{[<character>]=\,$i$, ...\}} という形式に変換されている.
4523 \item[char\_type]
4524 $i\in\omega$に対して,\texttt{char\_type[$i$]} は文字クラス$i$の文字の寸法を格納しており,
4525 以下のフィールドを持つ.
4526 \begin{itemize}
4527  \item \texttt{width},~\texttt{height}, \texttt{depth},
4528   \texttt{italic}, \texttt{down},~\texttt{left}\ は
4529 JFMで指定されているそれぞれの値をスケーリングしたものである.
4530  \item \texttt{align} はJFMで指定されている値によって,
4531 \[
4532  \begin{cases}
4533   0&\text{\texttt{'left'}や省略時}\\0.5&\text{\tt 'middle'}\\1&\text{\tt 'right'}
4534  \end{cases}
4535 \]
4536 のいずれかの値をとる.
4537 \item $j\in \omega$に対して,\texttt{[$j$]} は文字クラス$i$の文字と$j$の文字の間に挿入されるkern
4538       やglueを格納している.
4539 間に入るものがkernであれば,このフィールドの値は\
4540 \texttt{[$j$]=\{false, <kern\_node>, <ratio>\}} である.
4541 <kern\_node>はkernを表すノードそのものである\footnote{%
4542 本バージョンではノードのアクセス手法にdirect access
4543       modelを用いている.そのため,例えば\LuaTeX\ beta-0.78.2では,単なる自然数のようにし
4544       か見えないことに注意.
4545 }.
4546 glueであれば,\texttt{[$j$]=\{false, <spec\_node>, <ratio>, <icflag>\}} である.
4547 <spec\_node>はglueの長さを表すノードそのものであり,
4548       $\text{<icflag>}=\textit{from\_jfm}+\text{<priority>}$である.
4549 \end{itemize}
4550 \item[ascent\textrm{, }descent]
4551 ……
4552 \item[chars\_cbcache] 
4553 ……
4554 \end{cslist}
4555 %</ja>
4556
4557 %<*en>
4558 The returned table \verb+new_jfont_info+ also should include these fields, but
4559 you are free to add more fields (to use them in the \texttt{luatexja.find\_char\_class} callback).
4560 The \verb+font_number+ is a font number.
4561 %</en>
4562 %<*ja>
4563 戻り値の \verb+new_jfont_info+ テーブルも上に述べたフィールドをそのまま含まなければならないが,
4564 それ以外にユーザが勝手にフィールドを付け加えることは自由である.
4565 \verb+font_number+ はフォント番号である.
4566 %</ja>
4567
4568 %<*en>
4569 A good example of this and the next callbacks is the \Pkg{luatexja-otf}
4570              package, supporting \verb+"AJ1-xxx"+ form for Adobe-Japan1
4571              CID characters in a JFM. This callback doesn't replace any
4572              code of \LuaTeX-ja.
4573 %</en>
4574 %<*ja>
4575 これと次のコールバックの良い使用例は\Pkg{luatexja-otf}パッケージであり,
4576 JFM中でAdobe-Japan1 CIDの文字を \verb+"AJ1-xxx"+ の形で指定するために
4577 用いられている.
4578 %</ja>
4579
4580 %<en>\item[\texttt{luatexja.find\_char\_class} callback]
4581 %<ja>\item[\texttt{luatexja.find\_char\_class}コールバック]
4582 %<*en>
4583 This callback is called just when \LuaTeX-ja is trying to determine which
4584              character class a character \verb+chr_code+ belongs.
4585 A function used in this callback should be in the following form:
4586 %</en>
4587 %<*ja>
4588 このコールバックは\LuaTeX-jaが \verb+chr_code+ の文字がどの文字クラスに
4589 属するかを決定しようとする際に呼び出される.
4590 このコールバックで呼び出される関数は次の形をしていなければならない:
4591 %</ja>
4592 \begin{lstlisting}[numbers=left]
4593 function (<number> char_class, <table> jfont_info, <number> chr_code)
4594   if char_class~=0 then return char_class
4595   else
4596     ....
4597     return (<number> new_char_class or 0)
4598   end
4599 end
4600 \end{lstlisting}
4601
4602 %<*en>
4603 The argument \verb+char_class+ is the result of \LuaTeX-ja's default
4604              routine or previous function calls in this callback, hence
4605              this argument may not be 0. Moreover, the returned
4606              \verb+new_char_class+ should be as same as \verb+char_class+ when \verb+char_class+
4607              is not~0, otherwise you will overwrite the \LuaTeX-ja's
4608              default routine.
4609 %</en>
4610 %<*ja>
4611 引数 \verb+char_class+ は\LuaTeX-jaのデフォルトルーチンか,このコールバックの
4612 直前の関数呼び出しの結果を含んでおり,したがってこの値は0ではないかもしれない.
4613 さらに,戻り値の \verb+new_char_class+ は \verb+char_class+ が非零のときには
4614 \verb+char_class+ の値と同じであるべきで,そうでないときは\LuaTeX-jaの
4615 デフォルトルーチンを書き換えることになる.
4616 %</ja>
4617
4618 %<en>\item[\texttt{luatexja.set\_width} callback]
4619 %<ja>\item[\texttt{luatexja.set\_width}コールバック]
4620 %<*en>
4621 This callback is called when \LuaTeX-ja is trying to encapsule a
4622              \textbf{JAchar} \textit{glyph\_node}, to adjust its
4623              dimension and position.
4624 %</en>
4625 %<*ja>
4626 このコールバックは\LuaTeX-jaが\textbf{JAchar}の寸法と位置を調節するために
4627 その\textit{glyph\_node}をカプセル化しようとする際に呼び出される.
4628 %</ja>
4629 \begin{lstlisting}[numbers=left]
4630 function (<table> shift_info, <table> jfont_info, <number> char_class)
4631   return <table> new_shift_info
4632 end
4633 \end{lstlisting}
4634
4635 %<*en>
4636 The argument \verb+shift_info+ and the returned \verb+new_shift_info+ have
4637 \texttt{down} and \texttt{left} fields, which are the amount of shifting
4638              down/left the character in a scaled point.
4639 %</en>
4640 %<*ja>
4641 引数 \verb+shift_info+ と戻り値の \verb+new_shift_info+ は
4642 \texttt{down}と\texttt{left}のフィールドを持ち,これらの値は
4643 文字の下/左へのシフト量(sp単位)である.
4644 %</ja>
4645
4646 %<*en>
4647 A good example is \Pkg{test/valign.lua}.
4648 After loading this file, the vertical position of glyphs is automatically
4649 adjusted; the ratio $(\hbox{height}:\hbox{depth})$ of glyphs is adjusted
4650 to be that of letters in the character class~0. For example, suppose that
4651 \begin{itemize}
4652 \item The setting of the JFM: $(\hbox{height})=88x$, $(\hbox{depth})=12x$
4653   (the standard values of Japanese OpenType fonts);
4654 \item The value of the real font: $(\hbox{height})=28y$, $(\hbox{depth})=5y$
4655   (the standard values of Japanese TrueType fonts).
4656 \end{itemize}
4657 Then, the position of glyphs is shifted up by
4658 %</en>
4659 %<*ja>
4660 良い例が\Pkg{test/valign.lua}である.このファイルが読み込まれた状態では,
4661              JFM内で規定された文字クラス0の文字における$(\hbox{高
4662              さ}):(\hbox{深さ})$の比になるように,実際のフォントの出力上
4663              下位置が自動調整される.例えば,
4664 \begin{itemize}
4665 \item JFM側の設定:$(\hbox{高さ})=88x$, $(\hbox{深さ})=12x$%
4666 (和文OpenTypeフォントの標準値)
4667 \item 実フォント側の数値:$(\hbox{高さ})=28y$, $(\hbox{深さ})=5y$(和文TrueTypeフォントの標準値)
4668 \end{itemize}
4669 となっていたとする.すると,実際の文字の出力位置は,以下の量だけ上にぜらされることとなる:
4670 %</ja>
4671 \[
4672  \frac{88x}{88x+12x} (28y+5y) - 28y = \frac{26}{25}y= 1.04y.
4673 \]
4674 \end{description}
4675
4676
4677
4678 %<en>\section{Parameters}
4679 %<ja>\section{パラメータ}
4680 \subsection{\cs{ltjsetparameter}}
4681 \label{ssec-param}
4682
4683 %<*en>
4684 As described before, \cs{ltjsetparameter} and \cs{ltjgetparameter} are
4685 commands for accessing most parameters of \LuaTeX-ja. One of the main
4686 reason that \LuaTeX-ja didn't adopted the syntax similar to that of \pTeX\
4687 (\textit{e.g.},~\verb+\prebreakpenalty`)=10000+)
4688 is the position of \verb+hpack_filter+ callback in the source
4689 of \LuaTeX, see Section~\ref{sec-para}.
4690 %</en>
4691 %<*ja>
4692 先に述べたように,\LuaTeX-jaのほとんどの内部パラメータにアクセスするには
4693 \cs{ltjsetparameter} と \cs{ltjgetparameter} を用いる.
4694 \LuaTeX-jaが\pTeX のような文法(例えば,\verb+\prebreakpenalty`)=10000+)を
4695 採用しない理由の一つは,\LuaTeX のソースにおける \verb+hpack_filter+
4696 コールバックの位置にある.\ref{sec-para}章を参照.
4697 %</ja>
4698
4699 %<*en>
4700 \cs{ltjsetparameter} and \cs{ltjglobalsetparameter} are commands
4701 for assigning parameters. These take one argument which is a
4702 \texttt{<key>=<value>} list.
4703 The list of allowed keys are described in the next subsection.
4704 The difference between
4705 \cs{ltjsetparameter} and \cs{ltjglobalsetparameter} is only the
4706 scope of assignment;
4707 \cs{ltjsetparameter} does a local assignment and
4708 \cs{ltjglobalsetparameter} does a global one.
4709 They also obey the value of \cs{globaldefs},
4710 like other assignment.
4711 %</en>
4712 %<*ja>
4713 \cs{ltjsetparameter} と \cs{ltjglobalsetparameter} はパラメータを
4714 指定するための命令である.これらは\texttt{<key>=<value>}のリストを
4715 引数としてとる.許されるキーの一覧は次の節にある.
4716 \cs{ltjsetparameter} と \cs{ltjglobalsetparameter} の違いはスコープの
4717 違いのみで,
4718 \cs{ltjsetparameter} はローカルな指定,\cs{ltjglobalsetparameter} は
4719 グローバルな指定を行う.
4720 これらは他のパラメータ指定と同様に \cs{globaldefs} の値に従う.
4721 %</ja>
4722
4723 %<*en>
4724 The following is the list of parameters which can be specified by the
4725 \cs{ltjsetparameter} command. [\cs{cs}] indicates the counterpart
4726 in \pTeX, and symbols beside each parameter has the following meaning:
4727 %</en>
4728 %<*ja>
4729 以下は \cs{ltjsetparameter} に指定することができるパラメータの一覧である.
4730 [\cs{cs}]は\pTeX における対応物を示す.
4731 また,それぞれのパラメータの右上にある記号には次の意味がある:
4732 %</ja>
4733 \begin{itemize}
4734 %<*en>
4735 \item ``\ast'' : values at the end of a paragraph or a hbox are
4736 adopted in the whole paragraph or the whole hbox.
4737 %</en>
4738 %<*ja>
4739 \item ``\ast'':段落やhboxの終端での値がその段落/hbox全体で用いられる.
4740 %</ja>
4741 %<*en>
4742 \item ``\dagger'': assignments are always global.
4743 %</en>
4744 %<*ja>
4745 \item ``\dagger'':指定は常にグローバルになる.
4746 %</ja>
4747 \end{itemize}
4748
4749 \begin{cslist}[style=standard]
4750 \item[\DParam{jcharwidowpenalty}\,=<penalty>$^\ast$] [\cs{jcharwidowpenalty}]\
4751
4752 %<*en>
4753 Penalty value for suppressing orphans. This penalty is inserted just
4754              after the last \textbf{JAchar} which is not regarded as a
4755              (Japanese) punctuation mark.
4756 %</en>
4757 %<*ja>
4758 パラグラフの最後の字が孤立して改行されるのを防ぐためのペナルティの値.
4759 このペナルティは(日本語の)句読点として扱われない最後の\textbf{JAchar}の直後に
4760 挿入される.
4761 %</ja>
4762
4763 \item[\DParam{kcatcode}\,=\{<chr\_code>,<natural number>\}$^\ast$]\
4764
4765 %<*en>
4766 An additional attributes which each character whose character code is <chr\_code> has.
4767 At the present version, the lowermost bit of <natural number> indicates
4768              whether the character is considered as a punctuation mark
4769              (see the description of \Param{jcharwidowpenalty} above).
4770 %</en>
4771 %<*ja>
4772 文字コードが<chr\_code>の文字が持つ付加的な属性値(attribute).
4773 現在のバージョンでは,<natural number>の最下位ビットが,その文字が句読点と
4774 みなされるかどうかを表している(上の\Param{jcharwidowpenalty}の記述を参照).
4775 %</ja>
4776
4777 \item[\DParam{prebreakpenalty}\,=\{<chr\_code>,<penalty>\}$^\ast$] [\cs{prebreakpenalty}]\
4778
4779 %<*ja>
4780 文字コード<chr\_code>の\textbf{JAchar}が行頭にくることを抑止するために,
4781              この文字の前に挿入/追加されるペナルティの量を指定する.
4782
4783 例えば閉じ括弧「〗」は絶対に行頭にきてはならないので,
4784 \begin{lstlisting}
4785 \ltjsetparameter{prebreakpenalty={`〙,10000}}
4786 \end{lstlisting}
4787 と,最大値の10000が標準で指定されている.他にも,小書きのカナなど,絶対禁止とい
4788              うわけではないができれば行頭にはきて欲しくない場合に,0と
4789              10000の間の値を指定するのも有用であろう.
4790 %</ja>
4791 %<*en>
4792 Set a penalty which is inserted automatically before the character <chr\_code>,
4793 to prevent a line starts from this character. For example, a line cannot started
4794 with one of closing brackets ``〗'', so \LuaTeX-ja sets
4795 \begin{lstlisting}
4796 \ltjsetparameter{prebreakpenalty={`〙,10000}}
4797 \end{lstlisting}
4798 by default.
4799 %</en>
4800
4801
4802 \item[\DParam{postbreakpenalty}\,=\{<chr\_code>,<penalty>\}$^\ast$]
4803            [\cs{postbreakpenalty}]\
4804
4805 %<*ja>
4806 文字コード<chr\_code>の\textbf{JAchar}が行末にくることを抑止するために,
4807              この文字の後に挿入/追加されるペナルティの量を指定する.
4808
4809 \pTeX では,\cs{prebreakpenalty}, \cs{postbreakpenalty}において,
4810 \begin{itemize}
4811 \item 一つの文字に対して,pre, postどちらか一つしか指定することができなかっ
4812       た(後から指定した方で上書きされる).
4813 \item pre, post合わせて256文字分の情報を格納することしかできなかった.
4814 \end{itemize}
4815 という制限があったが,\LuaTeX-jaではこれらの制限は解消されている.
4816 %</ja>
4817 %<*en>
4818 Set a penalty which is inserted automatically after the character <chr\_code>,
4819 to prevent a line ends with this character.
4820 \pTeX\ has following restrictions on \cs{prebreakpenalty} and \cs{postbreakpenalty},
4821 but they don't exist in \LuaTeX-ja:
4822 \begin{itemize}
4823  \item Both \cs{prebreakpenalty} and \cs{postbreakpenalty} cannot be set
4824 for the same character.
4825  \item We can set \cs{prebreakpenalty} and \cs{postbreakpenalty}  up to 256~characters.
4826 \end{itemize}
4827 %</en>
4828
4829 \item[\DParam{jatextfont}\,=\{<jfam>,<jfont\_cs>\}$^\ast$]
4830 %<en>[\cs{textfont} in \TeX]
4831 %<ja>[\TeX の \cs{textfont}]
4832 \item[\DParam{jascriptfont}\,=\{<jfam>,<jfont\_cs>\}$^\ast$]
4833 %<en>[\cs{scriptfont} in \TeX]
4834 %<ja>[\TeX の \cs{scriptfont}]
4835 \item[\DParam{jascriptscriptfont}\,=\{<jfam>,<jfont\_cs>\}$^\ast$]
4836 %<en>[\cs{scriptscriptfont} in \TeX]
4837 %<ja>[\TeX の \cs{scriptscriptfont}]
4838 \item[\DParam{yjabaselineshift}\,=<dimen>]\
4839 \item[\DParam{yalbaselineshift}\,=<dimen>] [\cs{ybaselineshift}]
4840 \item[\DParam{tjabaselineshift}\,=<dimen>]\
4841 \item[\DParam{talbaselineshift}\,=<dimen>] [\cs{tbaselineshift}]
4842
4843 \item[\DParam{jaxspmode}\,=\{<chr\_code>,<mode>\}$^\ast$]\
4844
4845 %<*en>
4846 Setting whether inserting \Param{xkanjiskip} is allowed before/after a \textbf{JAchar} whose character code is <chr\_code>.
4847 The followings are allowed for <mode>:
4848 %</en>
4849 %<*ja>
4850 文字コードが<chr\_code>の\textbf{JAchar}の前/後ろに\Param{xkanjiskip}の
4851 挿入を許すかどうかの設定.
4852 以下の<mode>が許される:
4853 %</ja>
4854 \begin{description}
4855 %<en>\item[0, \texttt{inhibit}] Insertion of \Param{xkanjiskip} is inhibited before the character, nor after the character.
4856 %<ja>\item[0, \texttt{inhibit}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも禁止される.
4857 %<en>\item[1, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed before the character, but not after.
4858 %<ja>\item[1, \texttt{preonly}] \Param{xkanjiskip}の挿入は文字の前では許されるが,後ろでは許されない.
4859 %<en>\item[2, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed after the character, but not before.
4860 %<ja>\item[2, \texttt{postonly}] \Param{xkanjiskip}の挿入は文字の後ろでは許されるが,前では許されない.
4861 %<en>\item[3, \texttt{allow}] Insertion of \Param{xkanjiskip} is allowed both before the character and after the character. This is the default value.
4862 %<ja>\item[3, \texttt{allow}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも許される.これがデフォルトの値である.
4863 \end{description}
4864 %<*en>
4865 This parameter is similar to the \cs{inhibitxspcode} primitive of \pTeX, but not compatible with \cs{inhibitxspcode}.
4866 %</en>
4867 %<*ja>
4868 このパラメータは\pTeX の \cs{inhibitxspcode} プリミティブと似ているが,
4869 互換性はない.
4870 %</ja>
4871 \item[\DParam{alxspmode}\,=\{<chr\_code>,<mode>\}$^\ast$] [\cs{xspcode}]\
4872
4873 %<*en>
4874 Setting whether inserting \Param{xkanjiskip} is allowed before/after a
4875              \textbf{ALchar} whose character code is <chr\_code>.
4876              The followings are allowed for <mode>:
4877 %</en>
4878 %<*ja>
4879 文字コードが<chr\_code>の\textbf{ALchar}の前/後ろに\Param{xkanjiskip}の
4880 挿入を許すかどうかの設定.
4881 以下の<mode>が許される:
4882 %</ja>
4883 \begin{description}
4884 %<en>\item[0, \texttt{inhibit}] Insertion of \Param{xkanjiskip} is inhibited before the character, nor after the character.
4885 %<ja>\item[0, \texttt{inhibit}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも禁止される.
4886 %<en>\item[1, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed before the character, but not after.
4887 %<ja>\item[1, \texttt{preonly}] \Param{xkanjiskip}の挿入は文字の前では許されるが,後ろでは許されない.
4888 %<en>\item[2, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed after the character, but not before.
4889 %<ja>\item[2, \texttt{postonly}] \Param{xkanjiskip}の挿入は文字の後ろでは許されるが,前では許されない.
4890 %<en>\item[3, \texttt{allow}] Insertion of \Param{xkanjiskip} is allowed before the character and after the character. This is the default value.
4891 %<ja>\item[3, \texttt{allow}] \Param{xkanjiskip}の挿入は文字の前/後ろのいずれでも許される.これがデフォルトの値である.
4892 \end{description}
4893 %<*en>
4894 Note that parameters \Param{jaxspmode} and \Param{alxspmode} share a common table, hence these two parameters are synonyms of each other.
4895 %</en>
4896 %<*ja>
4897 \Param{jaxspmode}と\Param{alxspmode}は共通のテーブルを用いているため,
4898 これら2つのパラメータは互いの別名となっていることに注意する.
4899 %</ja>
4900
4901 \item[\DParam{autospacing}\,=<bool>] [\cs{autospacing}]
4902 \item[\DParam{autoxspacing}\,=<bool>] [\cs{autoxspacing}]
4903 \item[\DParam{kanjiskip}\,=<skip>$^\ast$] [\cs{kanjiskip}]\
4904
4905 %<*ja>
4906 デフォルトで2つの\textbf{JAchar}の間に挿入されるグルーである.
4907 通常では,\pTeX と同じようにフォントサイズに比例して変わることはない.
4908 しかし,自然長が \cs{maxdimen} の場合は,例外的に和文フォントのJFM側で指定されている
4909 値を採用(こちらはフォントサイズに比例)することになっている.
4910 %</ja>
4911
4912 \item[\DParam{xkanjiskip}\,=<skip>$^\ast$] [\cs{xkanjiskip}]\
4913
4914 %<*ja>
4915 デフォルトで\textbf{JAchar}と\textbf{ALchar}の間に挿入されるグルーである.
4916 \Param{kanjiskip}と同じように,通常ではフォントサイズに比例して変わることはないが,
4917 自然長が \cs{maxdimen} の場合が例外である.
4918 %</ja>
4919
4920
4921 \item[\DParam{differentjfm}\,=<mode>$^\dagger$]\
4922
4923 %<*en>
4924 Specify how glues/kerns between two \textbf{JAchar}s whose JFM (or size) are different.
4925 The allowed arguments are the followings:
4926 %</en>
4927 %<*ja>
4928 JFM(もしくはサイズ)が異なる2つの\textbf{JAchar}の間にグルー/カーンをどのように
4929 入れるかを指定する.
4930 許される値は以下の通り:
4931 %</ja>
4932 \begin{quote}
4933 \texttt{average},
4934 \texttt{both},
4935 \texttt{large},
4936 \texttt{small},
4937 \texttt{pleft},
4938 \texttt{pright},
4939 \texttt{paverage}
4940 \end{quote}
4941 %<*en>
4942 The default value is \texttt{paverage}. \dots
4943 %</en>
4944 %<*ja>
4945 デフォルト値は \texttt{paverage} である.
4946 各々の値による差異の詳細は\ref{ssec-cluster-wa}節の「『右空白』の算出」を参照してほしい.
4947 %</ja>
4948
4949 \item[\DParam{jacharrange}\,=<ranges>]
4950 \item[\DParam{kansujichar}\,=\{<digit>, <chr\_code>\}$^\ast$] [\cs{kansujichar}]
4951
4952 \item[\DParam{direction}\,=<dir>\ \hbox{\rm (always local)}]\
4953
4954 %<*en>
4955 Assigning to this parameter has the same effect as
4956 \cs{yoko}~(if $\hbox{<dir>}=4$), \cs{tate}~(if $\hbox{<dir>}=3$),
4957 \cs{dtou}~(if $\hbox{<dir>}=1$) or \cs{utod}~(if $\hbox{<dir>}=11$).
4958 If the argument <dir> is not one of 4,~3, 1~nor~11,
4959 the behavior of this assignment is undefined.
4960 %</en>
4961 %<*ja>
4962 組方向を変更する \cs{yoko}~(if $\hbox{<dir>}=4$), \cs{tate}~(if $\hbox{<dir>}=3$),
4963 \cs{dtou}~(if $\hbox{<dir>}=1$), \cs{utod}~(if $\hbox{<dir>}=11$) と同じ役割を持つ.
4964 利用可能な状況もこれら4命令と同一である.引数<dir>が4,~3, 1,~11のいずれでも無いときの
4965 動作は未定義である.
4966 %</ja>
4967
4968 \end{cslist}
4969
4970 \subsection{\cs{ltjgetparameter}}
4971 \label{ssec-getpar}
4972 %<*en>
4973 \cs{ltjgetparameter} is a control sequence for acquiring parameters. It
4974 always takes a parameter name as first argument.
4975 %</en>
4976 %<*ja>
4977 \cs{ltjgetparameter} はパラメータの値を取得するための命令であり,
4978 常にパラメータの名前を第一引数にとる.
4979 %</ja>
4980 \begin{LTXexample}
4981 \ltjgetparameter{differentjfm},
4982 \ltjgetparameter{autospacing},
4983 \ltjgetparameter{kanjiskip},
4984 \ltjgetparameter{prebreakpenalty}{`)}.
4985 \end{LTXexample}
4986
4987 %<*en>
4988 \emph{The return value of\/ \cs{ltjgetparameter} is
4989 always a string}. This is outputted by \texttt{tex.write()}, so any
4990 character other than space~``\texttt{\char32}''~(\texttt{U+0020}) has the category code
4991 12~(other), while the space has 10~(space).
4992 %</en>
4993 %<*ja>
4994 \emph{\cs{ltjgetparameter} の戻り値は常に文字列である.}
4995 これは\texttt{tex.write()}によって出力しているためで,空白「\texttt{\char32}」
4996 (\texttt{U+0020})を除いた文字のカテゴリーコードは全て12~(other)となる.
4997 一方,空白のカテゴリーコードは10~(space)である.
4998 %</ja>
4999
5000 \begin{itemize}
5001 \item
5002 %<*en>
5003 If first argument is one of the
5004 following, no  additional argument is needed.
5005 %</en>
5006 %<*ja>
5007 第1引数が次のいずれかの場合には,追加の引数は必要ない.
5008 %</ja>
5009 \begin{quote}
5010 \sffamily
5011 jcharwidowpenalty, yjabaselineshift, yalbaselineshift, autospacing, autoxspacing,\\
5012 kanjiskip, xkanjiskip, differentjfm, direction
5013 \end{quote}
5014 %<*en>
5015 Note that \verb+\ltjgetparameter{autospacing}+~and~\verb+\ltjgetparameter{autoxspacing}+
5016 returns 1 or 0, not
5017 \texttt{true}~nor~\texttt{false}.
5018 %</en>
5019 %<*ja>
5020 \verb+\ltjgetparameter{autospacing}+ と \verb+\ltjgetparameter{autoxspacing}+ は,
5021 \texttt{true}や\texttt{false}を返すの\emph{ではなく},
5022 1と0のいずれかを返すことに注意,
5023 %</ja>
5024
5025 \item
5026 %<*en>
5027 If first argument is one of the
5028 following, an additional argument---a character code, for example---is needed.
5029 %</en>
5030 %<*ja>
5031 第1引数が次のいずれかの場合には,さらに文字コードを第二引数としてとる.
5032 %</ja>
5033 \begin{quote}
5034 \sffamily
5035 kcatcode, prebreakpenalty, postbreakpenalty, jaxspmode, alxspmode
5036 \end{quote}
5037 %<*en>
5038 \verb+\ltjgetparameter{jaxspmode}{...}+~and~\verb+\ltjgetparameter{alxspmode}{...}+
5039 returns 0,~1, 2,~or~3, instead of \texttt{preonly} etc.
5040 %</en>
5041 %<*ja>
5042 \verb+\ltjgetparameter{jaxspmode}{...}+ や \verb+\ltjgetparameter{alxspmode}{...}+\
5043 は,\texttt{preonly} などといった文字列ではなく,0から3までの値を返す.
5044 %</ja>
5045
5046 \item
5047 %<*en>
5048 \verb+\ltjgetparameter{jacharrange}{+<range>\verb+}+ returns \texttt{0}
5049 if ``characters which belong to the character range~<range> are \textbf{JAchar}'',
5050 \texttt{1} if ``\dots~are \textbf{ALchar}''.
5051 Although there is no character range~$-1$, specifying $-1$ to <range> does not cause an
5052       error (returns 1).
5053 %</en>
5054 %<*ja>
5055 \verb+\ltjgetparameter{jacharrange}{+<range>\verb+}+ は,<range>が\textbf{JAchar}達の
5056 範囲ならば0を,そうでなければ1を返す.「$-1$番の文字範囲」は存在しないが,<range>に$-1$を
5057 指定してもエラーは発生しない(1を返す).
5058 %</ja>
5059
5060 \item
5061 %<*en>
5062 For an integer~<digit> between 0~and~9,
5063      \verb+\ltjgetparameter{kansujichar}{+<digit>\verb+}+ returns the character code
5064 of the result of \cs{kansuji}<digit>.
5065 %</en>
5066 %<*ja>
5067 0--9の数<digit>に対して,
5068 \verb+\ltjgetparameter{kansujichar}{+<digit>\verb+}+ は,\cs{kansuji}<digit>で出力され
5069      る文字の文字コードを返す.
5070 %</ja>
5071
5072 \item
5073 %<*en>
5074 \verb+\ltjgetparameter{adjustdir}+ returns a integer which represents
5075 the direction of the surrounding vertical list.
5076 As \Param{direction}, the return value 1 means \emph{down-to-up} direction,
5077 3 means \emph{tate} direction (vertical typesetting),
5078 and 4 means \emph{yoko} direction (horizontal typesetting).
5079 %</en>
5080 %<*ja>
5081 \verb+\ltjgetparameter{adjustdir}+ は,周囲のvboxの組方向(言い換えれば,
5082 \cs{vadjust} で用いられる組方向)を表す数値を返す.
5083 \Param{direction}と同様に,1は \cs{dtou} 方向を,
5084 3は縦組みを,4は横組みを表す.
5085 %</ja>
5086
5087 \item
5088 %<*en>
5089 For an integer~<reg\_num> between 0~and~65535,
5090 \verb+\ltjgetparameter{boxdim}{+<reg\_num>\verb+}+ returns the direction of
5091 \cs{box}<reg\_num>. If this box register is void, the returned value is zero.
5092 %</en>
5093 %<*ja>
5094 0--65535の数<reg\_num>に対して,
5095 \verb+\ltjgetparameter{boxdim}{+<reg\_num>\verb+}+ は,\cs{box}<reg\_num>に
5096 格納されているボックスの組方向を表す.もしこのレジスタが空の場合は,0が返される.
5097 %</ja>
5098
5099 \item
5100 %<*en>
5101 The following parameter names \emph{cannot be specified} in \cs{ltjgetparameter}.
5102 %</en>
5103 %<*ja>
5104 次のパラメータ名を \cs{ltjgetparameter} に指定することはできない.
5105 %</ja>
5106 \begin{quote}
5107 \sffamily
5108 jatextfont, jascriptfont, jascriptscriptfont, jacharrange
5109 \end{quote}
5110
5111 \item
5112 %<*en>
5113 \verb+\ltjgetparameter{chartorange}{+<chr\_code>\verb+}+ returns
5114 the range number which <chr\_code> belongs to
5115 (although there is no parameter named ``chartorange'').
5116
5117 If <chr\_code> is between 0 and 127, this <chr\_code> does not belong to
5118 any character range. In this case,
5119       \verb+\ltjgetparameter{chartorange}{+<chr\_code>\verb+}+
5120 returns $-1$.
5121
5122 Hence, one can know whether <chr\_code> is \textbf{JAchar} or not
5123 by the following:
5124 %</en>
5125 %<*ja>
5126 \verb+\ltjgetparameter{chartorange}{+<chr\_code>\verb+}+ によって
5127 <chr\_code>の属する文字範囲の番号を知ることができる.
5128
5129 <chr\_code>に0--127の値を指定した場合(このとき,<chr\_code>が属する
5130 文字範囲は存在しない)は$-1$が返る.
5131
5132 そのため,<chr\_code>が\textbf{JAchar}か\textbf{ALchar}かは
5133 次で知ることができる:
5134 %</ja>
5135 \begin{quote}
5136 \ttfamily \verb+\ltjgetparameter{jacharrange}{\ltjgetparameter{chartorange}{+%
5137   <chr\_code>\verb+}}+\\\null\hfill\verb+% 0 if JAchar, 1 if ALchar+
5138 \end{quote}
5139
5140 \end{itemize}
5141
5142
5143
5144
5145 %<en>\section{Other Commands for plain \TeX\ and \LaTeXe}
5146 %<ja>\section{plainでも\LaTeX でも利用可能なその他の命令}
5147 %<en>\subsection{Commands for Compatibility with \pTeX}
5148 %<ja>\subsection{\pTeX 互換用命令}
5149
5150 %<*en>
5151 The following commands are implemented for compatibility with \pTeX.
5152 Note that the former five commands don't support JIS~X~0213, but only JIS~X~0208.
5153 The last \cs{kansuji} converts an integer into its Chinese numerals.
5154 %</en>
5155 %<*ja>
5156 以下の命令は\pTeX との互換性のために実装されている.そのため,JIS~X~0213には対応せず,
5157 \pTeX と同じようにJIS~X~0208の範囲しかサポートしていない.
5158 %</ja>
5159 \begin{center}
5160 \cs{kuten}, \cs{jis}, \cs{euc}, \cs{sjis}, \cs{jis}, \cs{kansuji}
5161 \end{center}
5162 %<*en>
5163 These six commands takes an internal integer, and returns a \emph{string}.
5164 %</en>
5165 %<*ja>
5166 これら6命令は内部整数を引数とするが,実行結果は\textbf{文字列}であることに注意.
5167 %</ja>
5168 \begin{LTXexample}
5169 \newcount\hoge
5170 \hoge="2423 %"
5171 \the\hoge, \kansuji\hoge\\
5172 \jis\hoge, \char\jis\hoge\\
5173 \kansuji1701
5174 \end{LTXexample}
5175
5176 %<*en>
5177 To change characters of Chinese numerals for each digit, set \Param{kansujichar} parameter:
5178 \begin{LTXexample}
5179 \ltjsetparameter{kansujichar={1,`壹}}
5180 \ltjsetparameter{kansujichar={7,`漆}}
5181 \ltjsetparameter{kansujichar={0,`零}}
5182 \kansuji1701
5183 \end{LTXexample}
5184 %</en>
5185
5186
5187 \subsection{\cs{inhibitglue}}
5188 %<*en>
5189 \cs{inhibitglue} suppresses the insertion of \textbf{JAglue}.
5190 The following is an example, using a special JFM that there will be a glue between
5191 the beginning of a box and ``あ'', and also between ``あ''~and~``ウ''.
5192 %</en>
5193 %<*ja>
5194 \cs{inhibitglue} は\textbf{JAglue}の挿入を抑制する.
5195 以下は,ボックスの始めと「あ」の間,「あ」「ウ」の間にグルーが入る特別なJFMを用いた例で
5196 ある.
5197 %</ja>
5198
5199 \begin{LTXexample}[width=0.4\textwidth]
5200 \jfont\g=file:KozMinPr6N-Regular.otf:jfm=test \g
5201 \fbox{\hbox{あウあ\inhibitglue ウ}}
5202 \inhibitglue\par\noindent あ1
5203 \par\inhibitglue\noindent あ2
5204 \par\noindent\inhibitglue あ3
5205 \par\hrule\noindent あoff\inhibitglue ice
5206 \end{LTXexample}
5207
5208 %<*en>
5209 With the help of this example, we remark the specification of \cs{inhibitglue}:
5210 %</en>
5211 %<*ja>
5212 この例を援用して,\cs{inhibitglue} の仕様について述べる.
5213 %</ja>
5214 \begin{itemize}
5215 %<*en>
5216 \item The call of \cs{inhibitglue} in the (internal) vertical mode is
5217       simply ignored.
5218 %</en>
5219 %<*ja>
5220 \item \emph{\cs{inhibitglue} の垂直モード中での呼び出しは意味を持たない}\footnote{%
5221   この点は\TeX~Live~2014での\pTeX における \cs{inhibitglue} の仕様変更と同じである.
5222 }.
5223 4行目の入力で有効にならないのは,\cs{inhibitglue} の時点では垂直モードであり,
5224 \cs{noindent} の時点で水平モードになるからである.
5225 %</ja>
5226
5227 %<*en>
5228 \item The call of \cs{inhibitglue} in the (restricted) horizontal
5229       mode is only effective on the spot; does not get over boundary of
5230       paragraphs. Moreover, \cs{inhibitglue} cancels ligatures and
5231       kernings, as shown in the last line of above example.
5232 %</en>
5233 %<*ja>
5234 \item \cs{inhibitglue} の(制限された)水平モード中での呼び出しはその場でのみ
5235   有効であり,段落の境界を乗り越えない.
5236   さらに,\cs{inhibitglue} は上の例の最終行のように(欧文における)リガチャとカーニングを
5237   打ち消す.これは,\cs{inhibitglue} が内部的には「現在のリスト中にwhatsitノードを
5238   追加する」ことを行なっているからである.
5239 %</ja>
5240
5241 %<*en>
5242 \item The call of \cs{inhibitglue} in math mode is just ignored.
5243 %</en>
5244 %<*ja>
5245 \item \cs{inhibitglue} を数式モード中で呼び出した場合はただ無視される.
5246 %</ja>
5247
5248 %<*ja>
5249 \item \LaTeX で\LuaTeX-ja を使用する場合は,
5250 \cs{inhibitglue} の代わりとして \verb+\<+ を使うことができる.
5251 既に \verb+\<+ が定義されていた場合は,\LuaTeX-ja の読み込みで強制的に上書きされるので
5252 注意すること.
5253 %</ja>
5254 \end{itemize}
5255
5256
5257 \subsection{\cs{ltjdeclarealtfont}}
5258 \label{ssec-altfont}
5259 %<*en>
5260 Using \cs{ltjdeclarealtfont}, one can ``compose'' more than one Japanese fonts.
5261 This \cs{ltjdeclarealtfont} uses in the following form:
5262 \begin{quote}
5263 \ttfamily \textbackslash ltjdeclarealtfont<base\_font\_cs><alt\_font\_cs>{<range>}
5264 \end{quote}
5265 where  <base\_font\_cs>~and~<alt\_font\_cs> are defined by \cs{jfont}.
5266 Its meaning is
5267 \begin{quote}
5268 If the current Japanese font is <base\_font\_cs>, characters which belong to <range>
5269 is typeset by another Japanese font <alt\_font\_cs>, instead of <base\_font\_cs>.
5270 \end{quote}
5271
5272 <range> is a comma-separated list of character codes, but also accepts negative integers:
5273 $-n$~($n≥1$) means that all characters of character classes~$n$, with respect to JFM used
5274 by <base\_font\_cs>. Note that characters which do not exist in <alt\_font\_cs> are
5275 ignored.
5276
5277 For example, if \cs{hoge} uses \texttt{jfm-ujis.lua}, the standard JFM of \LuaTeX-ja,
5278 then
5279 \begin{lstlisting}
5280 \ltjdeclarealtfont\hoge\piyo{"3000-"30FF, {-1}-{-1}}
5281 \end{lstlisting}
5282 does
5283 \begin{quote}
5284 If the current Japanese font is \cs{hoge}, \texttt{U+3000}--\texttt{U+30FF}
5285 and characters in class~1 (ideographic opening brackets)
5286 are typeset by \cs{piyo}.
5287 \end{quote}
5288 %</en>
5289 %<*ja>
5290 \cs{jfont} の書式を見ればわかるように,基本的には\LuaTeX-jaにおける1つの和文フォントに
5291 使用出来る「実際のフォント」は1つである.
5292 しかし,\cs{ltjdeclarealtfont} を用いると,この原則から外れることができる.
5293
5294 \cs{ltjdeclarealtfont} は以下の書式で使用する:
5295 \begin{quote}
5296 \ttfamily \textbackslash ltjdeclarealtfont<base\_font\_cs><alt\_font\_cs>{<range>}
5297 \end{quote}
5298 これは「現在の和文フォント」が<base\_font\_cs>であるとき,
5299 <range>に属する文字は<alt\_font\_cs>を用いて組版される,という意味である.
5300 \begin{itemize}
5301  \item <base\_font\_cs>, <alt\_font\_cs>は
5302 \cs{jfont} によって定義された和文フォントである.
5303  \item <range>は文字コードの範囲を表すコンマ区切りのリストであるが,
5304    例外として負数$-n$は「<base\_font\_cs>のJFMの文字クラス$n$に属する全ての文字」
5305    を意味する.
5306
5307 <range>中に<alt\_font\_cs>中に実際には存在しない文字が指定された場合は,
5308 その文字に対する設定は無視される.
5309 \end{itemize}
5310
5311 例えば,\cs{hoge} のJFMが\LuaTeX-ja標準の
5312 \ \texttt{jfm-ujis.lua} であった場合,
5313 \begin{lstlisting}
5314 \ltjdeclarealtfont\hoge\piyo{"3000-"30FF, {-1}-{-1}}
5315 \end{lstlisting}
5316 は「\cs{hoge} を利用しているとき,
5317 \texttt{U+3000}--\texttt{U+30FF}と
5318 文字クラス1(開き括弧類)中の文字だけは \cs{piyo} を用いる」
5319 ことを設定する.\verb+{-1}-{-1}+ という変わった指定の仕方をしているのは,
5320 普通に \texttt{-1} と指定したのでは正しく$-1$と読み取られないという
5321 マクロの都合による.
5322 %</ja>
5323
5324
5325
5326 %<en>\section{Commands for \LaTeXe}
5327 %<ja>\section{\LaTeXe 用の命令}
5328
5329 %<en>\subsection{Patch for NFSS2}
5330 %<ja>\subsection{NFSS2へのパッチ}
5331 \label{ssec-nfsspat}
5332
5333 %<*en>
5334 Japanese patch for NFSS2 in \LuaTeX-ja
5335 is based on \texttt{plfonts.dtx} which plays the same role in \pLaTeXe.
5336 We will describe
5337 commands which are not described in Subsection~\ref{ssec-chgfnt}.
5338 %</en>
5339 %<*ja>
5340 \LuaTeX-jaのNFSS2への日本語パッチは
5341 \pLaTeXe で同様の役割を果たす \texttt{plfonts.dtx} をベースに,
5342 和文エンコーディングの管理等をLuaで書きなおしたものである.
5343 ここでは\ref{ssec-chgfnt}節で述べていなかった命令について
5344 記述しておく.
5345 %</ja>
5346
5347 \begin{cslist}%
5348 \item[\normalfont\bfseries %
5349 %<ja>追加の長さ変数達
5350 %<en>additonal dimensions
5351 ]
5352 %<*en>
5353 Like \pLaTeXe, \LuaTeX-ja defines the following dimensions
5354 for information of current Japanese font:
5355 %</en>
5356 %<*ja>
5357 \pLaTeXe と同様に,\LuaTeX-jaは「現在の和文フォントの情報」を格納する長さ変数
5358 %</ja>
5359 \begin{quote}
5360  \cs{cht}~(height), \cs{cdp}~(depth), \cs{cHT}~(sum of former two),\\
5361  \cs{cwd}~(width), \cs{cvs}~(lineskip), \cs{chs}~(equals to \cs{cwd})
5362 \end{quote}
5363 %<en>and its \cs{normalsize} version:
5364 %<ja>と,その \cs{normalsize} 版である
5365 \begin{quote}
5366  \cs{Cht}~(height), \cs{Cdp}~(depth),
5367  \cs{Cwd}~(width), \\\cs{Cvs}~(equals to \cs{baselineskip}),
5368  \cs{Chs}~(equals to \cs{cwd})%
5369 %<en>.
5370 \end{quote}
5371 %<*ja>
5372 を定義している.なお,\cs{cwd} と \cs{zw},また
5373 \cs{cHT} と \cs{zh} は一致しない可能性がある.なぜなら,
5374 \cs{cwd},~\cs{cHT} は「あ」の寸法から決定されるのに対し,
5375 \cs{zw} と \cs{zh} はJFMに指定された値に過ぎないからである.
5376 %</ja>
5377 %<*en>
5378 Note that \cs{cwd}~and~\cs{cHT} may  differ from \cs{zw}~and~\cs{zh}
5379 respectively.
5380 On the one hand the former dimensions are determined from the character ``あ'',
5381 but on the other hand \cs{zw}~and~\cs{zh} are specified by JFM.
5382 %</en>
5383
5384
5385 \item[\cs{DeclareYokoKanjiEncoding}\{<encoding>\}\{<text-settings>\}\{<math-settings>\}]
5386 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
5387 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
5388 \item[\cs{DeclareTateKanjiEncoding}\{<encoding>\}\{<text-settings>\}\{<math-settings>\}]
5389
5390 %<*en>
5391 In NFSS2 under \LuaTeX-ja, distinction between alphabetic font families
5392              and Japanese font families are only made by their
5393              encodings. For example, encodings OT1 and T1 are for
5394              alphabetic font families, and a Japanese font family cannot
5395              have these encodings. These command define a new encoding
5396              scheme for Japanese font families.
5397 %</en>
5398 %<*ja>
5399 \LuaTeX-jaのNFSS2においては,欧文フォントファミリと和文フォントファミリは
5400 そのエンコーディングによってのみ区別される.
5401 例えば,OT1とT1のエンコーディングは欧文フォントファミリに対するものであり,
5402 和文フォントファミリはこれらのエンコーディングを持つことはできない.
5403 これらコマンドは横組用・縦組用和文フォントのための新しいエンコーディングを
5404 それぞれ定義する.
5405 %</ja>
5406
5407 \item[\cs{DeclareKanjiEncodingDefaults}\{<text-settings>\}\{<math-settings>\}]
5408 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
5409 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
5410 \item[\cs{DeclareKanjiSubstitution}\{<encoding>\}\{<family>\}\{<series>\}\{<shape>\}]
5411 %<en>\ \\[\dimexpr-\medskipamount-2\baselineskip\relax]
5412 %<ja>\ \\[\dimexpr-2\baselineskip\relax]
5413 \item[\cs{DeclareErrorKanjiFont}\{<encoding>\}\{<family>\}\{<series>\}\{<shape>\}\{<size>\}]
5414
5415 %<*en>
5416 The above 3~commands are just the counterparts for \cs{DeclareFontEncodingDefaults} and~others.
5417 %</en>
5418 %<*ja>
5419 上記3つのコマンドはちょうど \cs{DeclareFontEncodingDefaults} などに対応するものである.
5420 %</ja>
5421
5422 \item[\cs{reDeclareMathAlphabet}\{<unified-cmd>\}\{<al-cmd>\}\{<ja-cmd>\}]
5423
5424 % ToDo: en
5425 %<*ja>
5426 和文・欧文の数式用フォントファミリを一度に変更する命令を作成する.
5427 具体的には,欧文数式用フォントファミリ変更の命令<al-cmd>(\cs{mathrm} 等)と,和文数式用フォ
5428              ントファミリ変更の命令<ja-cmd>(\cs{mathmc} 等)の2つを同時に行う命令として
5429              <unified-cmd>を(再)定義する.実際の使用では<unified-cmd>と
5430              <al-cmd>に同じものを指定する,すなわち,<al-cmd>で和文側も変
5431              更させるようにするのが一般的と思われる.
5432
5433 本命令は
5434 \begin{center}\tt
5435 <unified-cmd>\{<arg>\}\quad$\longrightarrow$\quad
5436 (<al-cmd>の1段展開結果)\{<ja-cmd>の1段展開結果)\{<arg>\}\}
5437 \end{center}
5438 と定義を行うので,使用には注意が必要である:
5439 %<en>\vspace{-\medskipamount}
5440 \begin{itemize}
5441 \item <al-cmd>,~<ja-cmd>は既に定義されていなければならない.
5442       \cs{reDeclareMathAlphabet}\\の後に
5443 両命令の内容を再定義しても,<unified-cmd>の内容にそれは反映されない.
5444 \item <al-cmd>,~<ja-cmd>に\verb+\@mathrm+などと \texttt{@} をつけた命令を指定した時の動作は保証できない.
5445 \end{itemize}
5446 %</ja>
5447
5448 \item[\cs{DeclareRelationFont}\{<ja-encoding>\}\{<ja-family>\}\{<ja-series>\}\{<ja-shape>\}\\*
5449   \null\hfill\{<al-encoding>\}\{<al-family>\}\{<al-series>\}\{<al-shape>\}]
5450 %<*en>
5451 This command sets the ``accompanied'' alphabetic font family (given by the latter 4~arguments)
5452 with respect to a Japanese font family given by the former 4~arguments.
5453 %</en>
5454 %<*ja>
5455 いわゆる「従属欧文」を設定するための命令である.前半の4引数で表される和文フォントファミリに対して,
5456 そのフォントに対応する「従属欧文」のフォントファミリを後半の4引数により与える.
5457 %</ja>
5458 \item[\cs{SetRelationFont}]
5459 %<*en>
5460 This command is almost same as \cs{DeclareRelationFont}, except that this command does a local
5461 assignment, where \cs{DeclareRelationFont} does a global assignment.
5462 %</en>
5463 %<*ja>
5464 このコマンドは \cs{DeclareRelationFont} とローカルな指定であることを除いて
5465 ほとんど同じである(\cs{DeclareRelationFont} はグローバル).
5466 %</ja>
5467
5468 \item[\cs{userelfont}]
5469 %<*en>
5470 Change current alphabetic font encoding/family/\dots\ to the `accompanied' alphabetic
5471              font family with respect to current Japanese font family,
5472              which was set by
5473              \cs{DeclareRelationFont} or \cs{SetRelationFont}.
5474 Like \cs{fontfamily}, \cs{selectfont} is required to take an effect.
5475 %</en>
5476 %<*ja>
5477 現在の欧文フォントのエンコーディング/ファミリ/…… を,
5478 \cs{DeclareRelationFont} か \cs{SetRelationFont} で指定された
5479 現在の和文フォントファミリに対応する「従属欧文」フォントファミリに変更する.
5480 \cs{fontfamily} のように,有効にするためには \cs{selectfont} が必要である.
5481 %</ja>
5482
5483 \item[\cs{adjustbaseline}]
5484 %<*en>
5485 In \pLaTeXe, \cs{adjustbaseline} sets \cs{tbaselineshift}
5486 to match the vertical center of ``M'' and that of ``あ''  in vertical typesetting:
5487 \[
5488 \text{\cs{tbaselineshift}} \leftarrow
5489 \frac{(h_{\text{M}}+d_{\text{M}}) - (h_{\text{あ}}+d_{\text{あ}})}2
5490   + d_{\text{あ}} - d_{\text{M}},
5491 \]
5492 where $h_{a}$~and~$d_{a}$ denote the height of ``$a$'' and the depth, respectively.
5493 In \LuaTeX-ja, this \cs{adjustbaseline} does same task.
5494 %</en>
5495 %<*ja>
5496 \pLaTeXe では,\cs{adjustbaseline} は縦組時に「M」と「あ」の中心線を一致させるために,
5497 \cs{tbaselineshift} を設定する役割を持っていた:
5498 \[
5499 \text{\cs{tbaselineshift}} \leftarrow
5500 \frac{(h_{\text{M}}+d_{\text{M}}) - (h_{\text{あ}}+d_{\text{あ}})}2
5501   + d_{\text{あ}} - d_{\text{M}},
5502 \]
5503 ここで,$h_{a}$,~$d_{a}$はそれぞれ「$a$」の高さ・深さを表す.
5504 \LuaTeX-jaにおいても\cs{adjustbaseline} は同様の処理を行っている.
5505 %</ja>
5506
5507 \item[\cs{fontfamily}\{<family>\}]
5508 %<*en>
5509 As in \LaTeXe, this command changes current font family (alphabetic, Japanese,~\emph{or both})
5510 to <family>. Which family will be changed is determined as follows:
5511 %</en>
5512 %<*ja>
5513 元々の\LaTeXe におけるものと同様に,このコマンドは現在のフォントファミリ(欧文,
5514 和文,\emph{もしくは両方})を<family>に変更する.
5515 どのファミリが変更されるかは以下のようにして決定される:
5516 %</ja>
5517 \begin{itemize}
5518 %<*en>
5519 \item Let current encoding scheme for Japanese fonts be
5520       <ja-enc>. Current Japanese font family will be changed to
5521       <family>, if one of the following two conditions is met:
5522 %</en>
5523 %<*ja>
5524 \item 現在の和文フォントに対するエンコーディングが<ja-enc>であるとしよう.
5525   現在の和文フォントファミリは,以下の2つの条件のうちの1つが満たされているときに
5526   <family>に変更される:
5527 %</ja>
5528 \begin{itemize}
5529 %<*en>
5530 \item The family <family> under the encoding <ja-enc> has been already defined by
5531       \cs{DeclareKanijFamily}.
5532 %</en>
5533 %<*ja>
5534 \item エンコーディング<ja-enc>におけるファミリ<family>が
5535 既に \cs{DeclareKanjiFamily} によって定義されている.
5536 %</ja>
5537 %<*en>
5538 \item A font definition named \texttt{<ja-enc><family>.fd} (the file name is
5539       all lowercase) exists.
5540 %</en>
5541 %<*ja>
5542 \item フォント定義ファイル\texttt{<ja-enc><family>.fd}(ファイル名は全て小文字)が存在する.
5543 %</ja>
5544 \end{itemize}
5545 %<*en>
5546 \item Let current encoding scheme for alphabetic fonts be
5547       <al-enc>. For alphabetic font family, the criterion as above is used.
5548 %</en>
5549 %<*ja>
5550 \item 現在の欧文フォントに対するエンコーディングを<al-enc>とする.
5551   欧文フォントファミリに対しても,上記の基準が用いられる.
5552 %</ja>
5553 %<*en>
5554 \item There is a case which none of the above applies, that is, the font
5555       family named <family> doesn't seem to be defined neither under the
5556       encoding <ja-enc>, nor under <al-enc>.
5557 In this case, the default family for font substitution is used for
5558       alphabetic and Japanese fonts. Note that current encoding will not
5559       be set to <family>, unlike the original implementation in \LaTeX.
5560 %</en>
5561 %<*ja>
5562 \item 上記のいずれもが適用されない,つまり<family>が<ja-enc>と<al-enc>の
5563   どちらでも定義されないような場合がある.
5564   この場合,代替フォントに用いられるデフォルトのフォントファミリが欧文フォントと
5565   和文フォントに用いられる.\LaTeX のオリジナルの実装とは異なり,
5566   現在のエンコーディングは<family>には設定されないことに注意する.
5567 %</ja>
5568 \end{itemize}%
5569 %<en>\vspace{-\medskipamount}
5570
5571
5572 \begin{figure}[!tb]
5573 \begin{LTXexample}[pos=b]
5574 \DeclareKanjiFamily{JY3}{edm}{}
5575 \DeclareFontShape{JY3}{edm}{m}{n}    {<-> s*KozMinPr6N-Regular:jfm=ujis;}{}
5576 \DeclareFontShape{JY3}{edm}{m}{green}{<-> s*KozMinPr6N-Regular:jfm=ujis;color=007F00}{}
5577 \DeclareFontShape{JY3}{edm}{m}{blue} {<-> s*KozMinPr6N-Regular:jfm=ujis;color=0000FF}{}
5578 \DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{green}{"4E00-"67FF,{-2}-{-2}}
5579 \DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{blue}{ "6800-"9FFF}
5580 {\kanjifamily{edm}\selectfont
5581 日本国民は、正当に選挙された国会における代表者を通じて行動し、……}
5582 \end{LTXexample}
5583 %<ja>\caption{\cs{DeclareAlternateKanjiFont} の使用例}
5584 %<en>\caption{An example of \cs{DeclareAlternateKanjiFont}}
5585 \label{fig:altkanji}
5586 \end{figure}
5587
5588 \item[\cs{DeclareAlternateKanjiFont}\{<base-encoding>\}\{<base-family>\}\{<base-series>\}\{<base-shape>\}\\
5589   \null\hfill\{<alt-encoding>\}\{<alt-family>\}\{<alt-series>\}\{<alt-shape>\}\{<range>\}]
5590 %<*ja>
5591 \ref{ssec-altfont}節の\
5592 \cs{ltjdeclarealtfont} と同様に,前半の4引数の
5593 和文フォント(基底フォント)のうち<range>中の文字を
5594 第5から第8引数の和文フォントを使って組むように指示する.
5595 使用例を図\nobreak\ref{fig:altkanji}に載せた.
5596
5597 \begin{itemize}
5598  \item
5599 \cs{ltjdeclarealtfont} では基底フォント・置き換え先和文フォントはあらかじめ定義されてい
5600              ないといけない(その代わり即時発効)であったが,
5601 \cs{DeclareAlternateKanjiFont} の設定が
5602 実際に効力が発揮するのは,書体変更やサイズ変更を行った時,
5603 あるいは(これらを含むが)\cs{selectfont} が実行された時である.
5604  \item
5605 段落やhboxの最後での設定値が段落/hbox全体にわたって通用する点や,
5606 <range>に負数$-n$を指定した場合,それが「基底フォントの文字クラス$n$に属する文字全体」
5607 と解釈されるのは \cs{ltjdeclarealtfont} と同じである.
5608 \end{itemize}%
5609 %</ja>
5610 %<*en>
5611 As \cs{ltjdeclarealtfont}~(Subsection~\ref{ssec-altfont}),
5612 characters in <range> of the Japanese font (we say the \emph{base font})
5613 which specified by first 4 arguments are typeset
5614 by the Japanese font which specified by fifth to eighth arguments
5615 (we say the \emph{alternate font}).
5616 An example is shown in Figure~\ref{fig:altkanji}.
5617
5618 \begin{itemize}
5619  \item
5620 In \cs{ltjdeclarealtfont}, the base font and the alternate font must be already defined.
5621 But this \cs{DeclareAlternateKanjiFont} is not so.
5622 In other words, \cs{DeclareAlternateKanjiFont} is effective only after
5623 current Japanese font is changed, or only after \cs{selectfont} is executed.
5624  \item \dots
5625 \end{itemize}%
5626 \vspace{-\medskipamount}
5627 %</en>
5628 \end{cslist}
5629
5630 %<*en>
5631 As closing this subsection, we shall introduce an example of
5632 \cs{SetRelationFont} and \cs{userelfont}:
5633 %</en>
5634 %<*ja>
5635 この節の終わりに,\cs{SetRelationFont} と \cs{userelfont} の例を
5636 紹介しておこう.\cs{userelfont} の使用によって,「abc」の部分のフォントが
5637 Avant Garde (OT1/pag/m/n) に変わっていることがわかる.
5638 %</ja>
5639 \begin{LTXexample}[width=0.3\textwidth]
5640 \makeatletter
5641 \SetRelationFont{JY3}{\k@family}{m}{n}{OT1}{pag}{m}{n}
5642   % \k@family: current Japanese font family
5643 \userelfont\selectfont あいうabc
5644 \end{LTXexample}
5645
5646 %<*en>
5647 \section{Addons}
5648 \LuaTeX-ja has several addon packages.
5649 These addons are written as \LaTeX\ packages, but
5650 \Pkg{luatexja-otf} and~\Pkg{luatexja-adjust} can be loaded in plain \LuaTeX\
5651 by \cs{input}.
5652 %</en>
5653 %<*ja>
5654 \section{拡張}
5655 \LuaTeX-jaには(動作には必須ではないが)自由に読み込める拡張が付属している.
5656 これらは\LaTeX のパッケージとして制作しているが,
5657 \Pkg{luatexja-otf}と\Pkg{luatexja-adjust}についてはplain \LuaTeX でも\
5658 \cs{input} で読み込み可能である.
5659 %</ja>
5660 \subsection{\texttt{luatexja-fontspec.sty}}
5661 \label{ssec-fontspec2}
5662 %<*en>
5663 As described in Subsection~\ref{ssec-fontspec}, this optional package
5664 provides the counterparts for several commands defined in the
5665 \Pkg{fontspec} package (requires \Pkg{fontspec}~v2.4).
5666 In addition to OpenType font features in the original \Pkg{fontspec},
5667 the following ``font features'' specifications are allowed for
5668 the commands of Japanese version:
5669 %</en>
5670 %<*ja>
5671 \ref{ssec-fontspec}節で述べたように,この追加パッケージは\Pkg{fontspec}
5672 パッケージで定義されているコマンドに対応する和文フォント用のコマンドを提供する.
5673 \emph{以下に述べる和文版の命令の説明は \Pkg{fontspec}~v2.4 使用時にのみ当てはまる.}
5674
5675 \Pkg{fontspec}パッケージで指定可能な各種font featureに加えて,和文版のコマンドには
5676 以下の``font feature''を指定することができる:
5677 %</ja>
5678
5679
5680 \begin{cslist}
5681 \item[CID=<name>\textrm{, }JFM=<name>\textrm{, }JFM-var=<name>]
5682
5683 %<*en>
5684 These 3 keys correspond to \texttt{cid}, \texttt{jfm} and
5685 \texttt{jfmvar} keys for \cs{jfont}~and~\cs{tfont} respectively.
5686 See Subsections~\ref{ssec-jfont} and \ref{ssec-psft} for details
5687  of \texttt{cid}, \texttt{jfm} and
5688 \texttt{jfmvar} keys.
5689
5690 The \texttt{CID} key is effective only when with \texttt{NoEmbed}
5691 described below. The same JFM cannot be used in both horizontal Japanese fonts and
5692              vertical Japanese fonts, hence the \texttt{JFM} key
5693 will be actually used in \texttt{YokoFeatures}~and~\texttt{TateFeatures} keys.
5694 %</en>
5695 %<*ja>
5696 これら3つのキーはそれぞれ \cs{jfont},~\cs{tfont}に対する
5697 \texttt{cid}, \texttt{jfm}, \texttt{jfmvar}キーとそれぞれ対応する.
5698 \texttt{cid}, \texttt{jfm}, \texttt{jfmvar}キーの詳細は\ref{ssec-jfont}節
5699              と\ref{ssec-psft}節を参照.
5700
5701 \texttt{CID} キーは下の \texttt{NoEmbed} と合わせて用いられたときのみ有効である.
5702 また,横組用JFMと縦組用JFMは共用できないため,実際に \texttt{JFM} キーを用いる際は
5703 後に述べる\ \texttt{YokoFeatures} キーや \texttt{TateFeatures}\ の中で用いる
5704 ことになる.
5705 %</ja>
5706
5707 \item[NoEmbed]
5708 %<*en>
5709 By specifying this key, one can use ``name-only'' Japanese font which
5710 will not be embedded in the output PDF file. See Subsection~\ref{ssec-psft}.
5711 %</en>
5712 %<*ja>
5713 これを指定することで,PDFに埋め込まれない「名前だけ」のフォントを指定することが
5714 できる.\ref{ssec-psft}節を参照.
5715 %</ja>
5716
5717 \begin{figure}[!tb]
5718 \begin{LTXexample}
5719 \jfontspec[
5720   YokoFeatures={Color=007F00},
5721   TateFeatures={Color=00007F},
5722   TateFont=KozGoPr6N-Regular
5723 ]{KozMinPr6N-Regular}
5724 \hbox{\yoko 横組のテスト}
5725 \hbox{\tate 縦組のテスト}
5726 \end{LTXexample}
5727 %<ja>\caption{\texttt{TateFeatures} 等の使用例}
5728 %<en>\caption{An example of \texttt{TateFeatures} etc.}
5729 \label{fig:yokotate-fontspec}
5730 \end{figure}
5731
5732
5733 \item[TateFeatures=\{<features>\}\textrm{, }TateFont=<font>]
5734 %<en> ...
5735 %<*ja>
5736 縦組において使用されるフォントや,縦組においてのみ適用されるfeature達を
5737 指定する.使用例は図\ref{fig:yokotate-fontspec}参照.
5738 %</ja>
5739
5740 \item[YokoFeatures=\{<features>\}]
5741 %<en> ...
5742 %<*ja>
5743 横組においてのみ適用されるfeature達を
5744 指定する.使用例は図\ref{fig:yokotate-fontspec}参照.
5745 %</ja>
5746
5747
5748 \begin{figure}[!tb]
5749 \begin{LTXexample}[pos=b]
5750 \jfontspec[
5751   AltFont={
5752     {Range="4E00-"67FF, Color=007F00},
5753     {Range="6800-"9EFF, Color=0000FF},
5754     {Range="3040-"306F, Font=KozGoPr6N-Regular},
5755   }
5756 ]{KozMinPr6N-Regular}
5757 日本国民は、正当に選挙された国会における代表者を通じて行動し、われらとわれらの子孫のために、
5758 諸国民との協和による成果と、わが国全土にわたつて自由のもたらす恵沢を確保し、……
5759 \end{LTXexample}
5760 %<ja>\caption{\texttt{AltFont} の使用例}
5761 %<en>\caption{An example of \texttt{AltFont}}
5762 \label{fig:altkanji-fontspec}
5763 \end{figure}
5764
5765 \item[AltFont]
5766
5767 %<*en>
5768 As \cs{ltjdeclarealtfont}~(Subsection~\ref{ssec-altfont}) and
5769 \cs{DeclareAlternateKanjiFont}~(Subsection~\ref{ssec-nfsspat}),
5770 with this key, one can typeset some Japanese characters
5771 by a different font and/or using different features.
5772 The \texttt{AltFont} feature takes a comma-separated list of comma-separated lists,
5773 as the following:
5774 %</en>
5775 %<*ja>
5776 \ref{ssec-altfont}節の \cs{ltjdeclarealtfont} や,
5777 \ref{ssec-nfsspat}節の \cs{DeclareAlternateKanjiFont} と同様に,
5778 このキーを用いると一部の文字を異なったフォントやfont featureを使って組むことができる.
5779 \texttt{AltFont} キーに指定する値は,次のように二重のコンマ区切りリストである:
5780 %</ja>
5781 \begin{lstlisting}[escapechar=\#]
5782 AltFont = {
5783   ...
5784   { Range=#\LARG range>#, #\LARG features>#},
5785   { Range=#\LARG range>#, Font=#\LARG font~name>#, #\LARG features># },
5786   { Range=#\LARG range>#, Font=#\LARG font~name># },
5787   ...
5788 }
5789 \end{lstlisting}
5790 %<*en>
5791 Each sublist should have the \texttt{Range} key
5792 (sublist which does not contain \texttt{Range} key is simply ignored).
5793 A demonstrarion is shown in Figure~\ref{fig:altkanji-fontspec}.
5794 %</en>
5795 %<*ja>
5796 各部分リストには \texttt{Range} キーが必須である(含まれない部分リストは
5797 単純に無視される).指定例は図\ref{fig:altkanji-fontspec}に示した.
5798 %</ja>
5799 \end{cslist}
5800
5801 %<*ja>
5802 なお,\Pkg{luatexja-fontspec} 読み込み時には和文フォント定義ファイル%
5803 \texttt{<ja-enc><family>.fd}は全く参照されなくなる.
5804 %</ja>
5805
5806
5807 %<*en>
5808 \paragraph{Remark on \texttt{AltFont}, \texttt{YokoFeatures}, \texttt{TateFeatures} keys}
5809 In \texttt{AltFont},~\texttt{YokoFeatures},~\texttt{TateFeatures} keys,
5810 one cannot specify per-shape settings such as \texttt{BoldFeatures}.
5811 For example,
5812 \begin{lstlisting}
5813 AltFont = {
5814   { Font=HogeraMin-Light, BoldFont=HogeraMin-Bold,
5815     Range="3000-"30FF, BoldFeatures={Color=007F00} }
5816 }
5817 \end{lstlisting}
5818 does \emph{not} work. Instead, one have to write
5819 \begin{lstlisting}
5820 UprightFeatures = {
5821   AltFont = { { Font=HogeraMin-Light, Range="3000-"30FF, } },
5822 },
5823 BoldFeatures = {
5824   AltFont =  { { Font=HogeraMin-Bold, Range="3000-"30FF, Color=007F00 } },
5825 }
5826 \end{lstlisting}
5827
5828 On the other hand, \texttt{YokoFeatures}, \texttt{TateFeatures} and  \texttt{TateFont}
5829 keys can be specified in each list in the \texttt{AltFont} key. Also,
5830 one can specify \texttt{AltFont} inside \texttt{YokoFeatures},~\texttt{TateFeatures}.
5831 %</en>
5832 %<*ja>
5833 \paragraph{\texttt{AltFont}, \texttt{YokoFeatures}, \texttt{TateFeatures} 等の制限}
5834 \texttt{AltFont},~\texttt{YokoFeatures},~\texttt{TateFeatures}の各キーは
5835 シェイプ別に指定されるべきものであり,
5836 内部では \texttt{BoldFeatures} などのシェイプ別の指定は行うことが出来ない.
5837 例えば.
5838 \begin{lstlisting}
5839 AltFont = {
5840   { Font=HogeraMin-Light, BoldFont=HogeraMin-Bold,
5841     Range="3000-"30FF, BoldFeatures={Color=007F00} }
5842 }
5843 \end{lstlisting}
5844 のように指定することは出来ず,
5845 \begin{lstlisting}
5846 UprightFeatures = {
5847   AltFont = { { Font=HogeraMin-Light, Range="3000-"30FF, } },
5848 },
5849 BoldFeatures = {
5850   AltFont =  { { Font=HogeraMin-Bold, Range="3000-"30FF, Color=007F00 } },
5851 }
5852 \end{lstlisting}
5853 のように指定しなければならない.
5854
5855 一方,\texttt{AltFont} キー内の各リストでは
5856 \ \texttt{YokoFeatures},~\texttt{TateFeatures} 及び \texttt{TateFont} キーを
5857 指定することは可能であり.また\ \texttt{YokoFeatures},~\texttt{TateFeatures} キーの
5858 中身に \texttt{AltFont} を指定することができる.
5859 %</ja>
5860
5861
5862 \subsection{\texttt{luatexja-otf.sty}}
5863 \label{ssec-ltjotf}
5864 %<*en>
5865 This optional package supports typesetting characters in
5866 Adobe-Japan1 character collection
5867 (or other CID character collection, if the font is supported).
5868 The package \Pkg{luatexja-otf} offers the following 2~low-level
5869 commands:
5870 %</en>
5871 %<*ja>
5872 この追加パッケージはAdobe-Japan1(フォント自身が持っていれば,
5873 別のCID文字セットでも可)の文字の出力をサポートする.
5874 \Pkg{luatexja-otf}は以下の2つの低レベルコマンドを提供する:
5875 %</ja>
5876 \begin{cslist}
5877 \item[\cs{CID}\{<number>\}]
5878 %<*en>
5879 Typeset a character whose CID number is <number>.
5880 %</en>
5881 %<*ja>
5882 CID番号が<number>の文字を出力する.
5883 %</ja>
5884
5885 \item[\cs{UTF}\{<hex\_number>\}]
5886 %<*en>
5887 Typeset a character whose character code is <hex\_number> (in hexadecimal).
5888 This command is similar to \verb+\char"+<hex\_number>,\ %"
5889 but please remind remarks below.
5890 %</en>
5891 %<*ja>
5892 文字コードが(16進で)<hex\_number>の文字を出力する.
5893 このコマンドは \verb+\char"+<hex\_number>と似ているが,下の記述に注意すること.%"
5894 %</ja>
5895 \end{cslist}
5896
5897 %<*ja>
5898 このパッケージは,\texttt{ajmacros.sty}(\Pkg{otf}パッケージ付属のマクロ集,井上浩一氏作)から
5899 漢字コードをUTF8にしたり,plain \LuaTeX でも利用可能にするという
5900 修正を加えた \texttt{luatexja-ajmacros.sty} も自動的に読み込む.
5901 そのため,\texttt{ajmacros.sty} マクロ集にある \verb+\aj半角+ などのマクロもそのまま使用可能である.
5902 %</ja>
5903
5904 %<en>\paragraph{Remarks}
5905 %<ja>\paragraph{注意}
5906 %<*en>
5907 Characters by \cs{CID} and \cs{UTF} commands are different from
5908 ordinary characters in the following points:
5909 %</en>
5910 %<*ja>
5911 \cs{CID} と \cs{UTF} コマンドによって出力される文字は
5912 以下の点で通常の文字と異なる:
5913 %</ja>
5914 \begin{itemize}
5915 %<*en>
5916 \item Always treated as \textbf{JAchar}s.
5917 %</en>
5918 %<*ja>
5919 \item 常に\textbf{JAchar}として扱われる.
5920 %</ja>
5921 %<*en>
5922 \item Processing codes for supporting OpenType features (\textit{e.g.},
5923       glyph replacement and kerning) by the \Pkg{luaotfload} package
5924       is not performed to these characters.
5925 %</en>
5926 %<*ja>
5927 \item OpenType feature(例えばグリフ置換やカーニング)をサポートするための
5928   \Pkg{luaotfload}パッケージのコードはこれらの文字には働かない.
5929 %</ja>
5930 \end{itemize}
5931
5932 %<en>\paragraph{Additional syntax of JFM}
5933 %<ja>\paragraph{JFMへの記法の追加}
5934
5935 %<*en>
5936 The package \Pkg{luatexja-otf} extends the syntax of JFM; the entries of \texttt{
5937 chars} table in JFM now allows a string in the form
5938 \verb+'AJ1-xxx'+, which stands for the character
5939 whose CID number in Adobe-Japan1 is \verb+xxx+.
5940
5941 This extended notation is used in the standard JFM \texttt{jfm-ujis.lua}
5942 to typeset halfwidth Hiragana glyphs (CID~516--598) in halfwidth.
5943 %</en>
5944 %<*ja>
5945 \Pkg{luatexja-otf}パッケージを読み込むと,
5946 JFMの\texttt{chars}テーブルのエントリとして \verb+'AJ1-xxx'+ の形の文字列が
5947 使えるようになる.これはAdobe-Japan1におけるCID番号が \verb+xxx+ の文字を表す.
5948
5949 この拡張記法は,標準JFM~\texttt{jfm-ujis.lua}で,半角ひらがなのグリフ(CID~516--598)を
5950 正しく半角幅で組むために利用されている.
5951 %</ja>
5952
5953 %<*en>
5954 \paragraph{IVS support}
5955 Recent fonts support Ideographic Variation Selector (IVS).
5956 It seems that \Pkg{luaotfload} and \Pkg{fontspec} packages do not support
5957 IVS, so we implemented IVS support in \Pkg{luatexja-otf}.
5958 \emph{IVS support is experimental; if you want to enable this, load
5959 \Pkg{luatexja-otf} and execute the following:}
5960 %</en>
5961 %<*ja>
5962 \paragraph{IVSサポート}
5963 最近のOpenTypeフォントやTrueTypeフォントには,
5964 \texttt{U+E0100}--\texttt{U+E01EF}の範囲の「文字」
5965 (漢字用異体字セレクタ)を後置することによって
5966 字形を指定する仕組み(IVS)が含まれている.
5967 執筆時点の2013年12月では,\Pkg{luaotfload}や\Pkg{fontspec}パッケージ類は
5968 IVSに対応してはいないようである.これらのパッケージで対応してくれるのが理想的だが,
5969 それまでのつなぎとして,\Pkg{luatexja-otf}パッケージ内にIVS対応を仕込んでおいた.
5970
5971 \medskip
5972
5973 \emph{IVS対応は試験的なものである.
5974 有効にするには,\Pkg{luatexja-otf}パッケージを読み込んだ上で以下の命令を実行する%
5975 \footnote{この命令を2回以上実行しても意味がない.}:}
5976 %</ja>
5977 \begin{lstlisting}
5978 \directlua{luatexja.otf.enable_ivs()}
5979 \end{lstlisting}
5980 %<ja> すると,上の命令を実行した箇所以降では,以下のようにIVSによる字形指定が有効となる.
5981 %<en> After executing the command above, you can use IVS like the following:
5982 \begin{LTXexample}
5983 \Large
5984 \jfontspec{KozMinPr6N-Regular}
5985 奈良県葛󠄀城市と,東京都葛󠄁飾区.\\
5986 こんにちは,渡
5987 邉󠄀邉󠄁邉󠄂邉󠄃邉󠄄
5988 邉󠄅邉󠄆邉󠄇邉󠄈邉󠄉
5989 邉󠄊邉󠄋邉󠄌邉󠄍邉󠄎
5990 さん.
5991 \end{LTXexample}
5992 %<*ja>
5993 左上側の入力においては,漢字用異体字セレクタを明示するため,
5994 例えばVariation~Selector~18 (\texttt{U+E0101})を\IVSB{18}のように表記している.
5995 %</ja>
5996 \medskip
5997
5998 %<*en>
5999 Specifying glyph variants by IVS precedes glyph replacement by font features.
6000 For example, only ``葛'' in ``葛西'' is changed by font features
6001 \texttt{jp78}~or~\texttt{jp90}, which does not followed by any variation selector.
6002 %</en>
6003 %<*ja>
6004 また,IVSによる字形指定は,font featureによるそれに優先されることとした.
6005 下の例において,\texttt{jp78}, \texttt{jp90} 指定で字形が変化した文字は
6006 異体字セレクタが続いていない「葛西」中の「葛」のみである.
6007 %</ja>
6008 \begin{LTXexample}
6009  \def\TEST#1{%
6010    {\jfontspec[#1]{KozMinPr6N-Regular}%
6011    葛󠄀城市,葛󠄁飾区,葛西}\\}
6012  指定なし:\TEST{}
6013  \texttt{jp78}:\TEST{CJKShape=JIS1978}
6014  \texttt{jp90}:\TEST{CJKShape=JIS1990}
6015 \end{LTXexample}
6016
6017 %<*ja>
6018 現状では,\TeX 側のインターフェースとなる \Pkg{luatexja-otf.sty} は一切変更していない
6019 ので,ZRさんによる\Pkg{PXipamjm}パッケージ%
6020 \footnote{\url{https://github.com/zr-tex8r/PXipamjm}. 説明は彼のブログ記事
6021 「pxipamjm パッケージの説明書のような何か(\url{http://d.hatena.ne.jp/zrbabbler/20131221})」
6022 にある.}
6023 にあるような気の利いた命令はまだない.
6024 異体字の一覧表示を行いたい場合は,gitリポジトリ内の \texttt{test/test19-ivs.tex} 中にある
6025 Lua・\TeX コードが参考になるだろう.
6026 %</ja>
6027
6028
6029 \subsection{\texttt{luatexja-adjust.sty}}
6030 \label{ssec-adj}
6031 \begin{figure}[t]
6032 \def\sq{%
6033   \hbox to 1\zw{\hss\fboxsep=-.5\fboxrule\fbox{%
6034    \hskip\dimexpr-.5\zw-.2pt\vrule width.4pt height.08\zw depth.12\zw%
6035   \hskip\dimexpr.5\zw-.2pt\relax}\hss}}
6036 \def\sb{\hbox to 1\zw{\hss\fboxsep=-.5\fboxrule\fbox{%
6037   ■\hskip\dimexpr-.5\zw-.2pt\vrule width.4pt height.08\zw depth.12\zw%
6038   \hskip\dimexpr.5\zw-.2pt\relax}\hss}}
6039 \newbox\gridbox
6040 \def\outbox#1{{\Large%
6041   \ltjsetparameter{kanjiskip=0pt plus .2\zw minus .2\zw}%
6042   \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}%
6043   \hbox{\textcolor{cyan}{\copy\gridbox}\hskip-20\zw%
6044   \vbox{\hsize=20\zw\noindent\leftskip0pt\rightskip0pt\parfillskip0pt#1}\vrule}%
6045 }}
6046
6047 {\centering
6048 \begin{tabular}{lc}
6049 \toprule
6050 no adjustment&\outbox{以上の原理は,「包除原理」とよく呼ばれるが\hskip-.5\zw\null}\\
6051 without priority&%
6052 \ltjdisableadjust
6053 \outbox{以上の原理は,「包除原理」とよく呼ばれるが}%
6054 \ltjenableadjust\\
6055 with priority&%
6056 \outbox{以上の原理は,「包除原理」とよく呼ばれるが}
6057 %<en>\ltjdisableadjust
6058 \\
6059 \bottomrule
6060 \end{tabular}\par}
6061 \smallskip
6062
6063 Note: the value of
6064 \Param{kanjiskip} is 0\,pt${}^{+1/5\,\mathrm{em}}_{-1/5\,\mathrm{em}}$ in this figure,
6065 for making the difference obvious.
6066 %<ja>\caption{行長調整}\label{fig-adj}
6067 %<en>\caption{Line adjustment}\label{fig-adj}
6068 \end{figure}
6069
6070
6071 %<*en>
6072 (see Japanese version of this manual)
6073 %</en>
6074 %<*ja>
6075 \pTeX では,行長調整において優先度の概念が存在しなかったため,図
6076 \ref{fig-adj}上段における半角分の半端は,図\ref{fig-adj}中段のように,鍵
6077 括弧周辺の空白と和文間空白(\Param{kanjiskip})の両方によって負担される.し
6078 かし,「日本語組版処理の要件」\cite{jlreq}やJIS~X~4051~\cite{x4051}におい
6079 ては,このような状況では半端は鍵括弧周辺の空白のみで負担し,その他の和文
6080 文字はベタ組で組まれる(図\ref{fig-adj}下段)ことになっている.この追加
6081 パッケージは\cite{jlreq}や\cite{x4051}における規定のような,優先順位付き
6082 の行長調整を提供する.詳細な仕様については\ref{sec-adjspec}章を参照してほしい.
6083 \begin{itemize}
6084  \item 優先度付き行長調整は,段落を行分割した後に個々の行について行われるものである.
6085 そのため,行分割の位置は変化することはない.
6086
6087 また,\verb+\hbox to ... {...}+ のような「幅が指定されたhbox」では無効である.
6088  \item 優先度付き行長調整を行うと,和文処理グルーの自然長は変化しないが,伸び量や縮み量は
6089 一般に変化する.そのため,既に組まれた段落を \cs{unhbox} などを利用して組み直す処理を
6090 行う場合には注意が必要である.
6091 \end{itemize}
6092
6093
6094 \Pkg{luatexja-adjust} は,以下の命令を提供する.これらはすべてグローバルに効力を発揮する.
6095
6096 \begin{cslist}
6097 \item[\cs{ltjdisableadjust}]
6098 優先順位付きの行長調整を無効化する.
6099
6100 \item[\cs{ltjenableadjust}]
6101 優先順位付きの行長調整を有効化する.
6102
6103 \item[\textsf{adjust}\,=<bool>] \cs{ltjsetparameter} で指定可能な追加パラメータであり,
6104 <bool>が\textit{true}なら \cs{ltjenableadjust} を,
6105 そうでなければ \cs{ltjdisableadjust} を実行する.
6106 \end{cslist}
6107 %</ja>
6108
6109 \subsection{\texttt{luatexja-ruby.sty}}
6110 %<*en>
6111 This addon package provides functionality of ``ruby'' (\emph{furigana}) annotations
6112 using callbacks of \LuaTeX-ja.
6113 There is no detailed manual of \Pkg{luatexja-ruby.sty} in English.
6114 (Japanese manual is another PDF file, \url{luatexja-ruby.pdf}.)
6115 %</en>
6116 %<*ja>
6117 この追加パッケージは,\LuaTeX-jaの機能を利用したルビ(振り仮名)の組版機能を提供する.
6118 前後の文字種に応じた前後への自動進入や,
6119 行頭形・行中形・行末形の自動的な使い分けが特徴である.
6120
6121 ルビ組版に設定可能な項目や注意事項が多いため,本追加パッケージの詳細な説明は
6122 使用例と共に \url{luatexja-ruby.pdf}\ という別ファイルに載せている.
6123 この節では簡単な使用方法のみ述べる.
6124 %</ja>
6125
6126 \begin{description}
6127 %<*en>
6128  \item[Group-ruby]
6129 By default, ruby characters (the second argument of \cs{ruby})
6130 are attached to base characters (the first argument), as one object.
6131 This type of ruby is called \emph{group-ruby}.
6132 %</en>
6133 %<*ja>
6134  \item[グループルビ] 標準ではグループルビの形で組まれる.第1引数に親文字,
6135 第2引数にルビを記述する.
6136 %</ja>
6137 \begin{LTXexample}[width=0.3\textwidth]
6138 東西線\ruby{妙典}{みようでん}駅は……\\
6139 東西線の\ruby{妙典}{みようでん}駅は……\\
6140 東西線の\ruby{妙典}{みようでん}という駅……\\
6141 東西線\ruby{葛西}{かさい}駅は……
6142 \end{LTXexample}
6143 %<*en>
6144 As the above example, ruby hangover is allowed on the Hiragana before/after
6145 its base characters.
6146 %</en>
6147 %<ja> この例のように,標準では前後の平仮名にルビ全角までかかるようになっている.
6148
6149 %<*en>
6150 \item[Mono-ruby]
6151 To attach ruby characters to each base characters (\emph{mono-ruby}),
6152 one should use \cs{ruby} multiple times:
6153 %</en>
6154 %<*ja>
6155  \item[モノルビ] 親文字を1文字にするとモノルビとなる.
6156 2文字以上の熟語をモノルビの形で組みたい場合は,面倒でも
6157 その数だけ \cs{ruby} を書く必要がある.
6158 %</ja>
6159 \begin{LTXexample}[width=0.3\textwidth]
6160 東西線の\ruby{妙}{みよう}\ruby{典}{でん}駅は……
6161 \end{LTXexample}
6162
6163 %<*en>
6164  \item[Jukugo-ruby]
6165 Vertical bar~\verb+|+ denotes a boundary of \emph{groups}.
6166 %</en>
6167 %<*ja>
6168  \item[熟語ルビ] 引数内の縦棒 \verb+|+ はグループの区切りを表し,
6169 複数グループのルビは熟語ルビとして組まれる.
6170 \cite{x4051}にあるように,
6171 どのグループでも「親文字」が対応するルビ以上の長さの場合は
6172 各グループごとに,そうでないときは全体をまとめて1つのグループルビとして組まれる.
6173 \cite{jlreq}で規定されている組み方とは異なるので注意.
6174 %</ja>
6175 \begin{LTXexample}
6176 \ruby{妙|典}{みよう|でん}\
6177 \ruby{葛|西}{か|さい}\
6178 \ruby{神楽|坂}{かぐら|ざか}
6179 \end{LTXexample}
6180 %<*en>
6181 If there are multiple groups in one \cs{ruby} call,
6182 A linebreak between two groups is allowed.
6183 %</en>
6184 %<ja> 複数ルビではグループとグループの間で改行が可能である.
6185 \begin{LTXexample}[width=0.3\textwidth]
6186 \vbox{\hsize=6\zw\noindent
6187   \hbox to 2.5\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
6188   \hbox to 2.5\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
6189   \hbox to   3\zw{}\ruby{京|急|蒲|田}{けい|きゆう|かま|た}
6190 }
6191 \end{LTXexample}
6192 \end{description}
6193
6194 %<*en>
6195 If the width of ruby characters are longer than that of base characters,
6196 \cs{ruby} automatically selects the appropriate form
6197 among the line-head form, the line-middle form, and the line-end form.
6198 %</en>
6199 %<*ja>
6200 また,ルビ文字のほうが親文字よりも長い場合は,自動的に
6201 行頭形・行中形・行末形のいずれか適切なものを選択する.
6202 %</ja>
6203 \begin{LTXexample}[width=0.3\textwidth]
6204 \vbox{\hsize=8\zw\noindent
6205 \null\kern3\zw ……を\ruby{承}{うけたまわ}る
6206      \kern1\zw ……を\ruby{承}{うけたまわ}る\\
6207 \null\kern5\zw ……を\ruby{承}{うけたまわ}る
6208 }
6209 \end{LTXexample}
6210
6211
6212 %<*ja>
6213 \subsection{\texttt{lltjext.sty}}
6214 \pLaTeX では縦組用の拡張として \Pkg{plext} パッケージが用意されていたが,
6215 それを\LuaTeX-ja用に書きなおしたものが本追加パッケージ \Pkg{lltjext} である.
6216
6217 従来の \Pkg{plext} パッケージとの違いは,
6218 {\catcode`\<=12
6219 \begin{itemize}
6220  \item 組方向オプション \texttt{<y>}(横組),\texttt{<t>}(縦組),
6221 \texttt{<z>}\ の他に\ \texttt{<d>}(dtou方向),\texttt{<u>}(utod方向)を追加した.
6222 \texttt{<z>} と \texttt{<u>} の違いは,\texttt{<z>} が(\Pkg{plext} パッケージと同様に)
6223 周囲の組方向が縦組のときにしか意味を持たない
6224        のに対し,\texttt{<u>} にはそのような制限がないことである.
6225
6226  \item \Pkg{plext} パッケージでは,表組(\texttt{tabular} 環境,\texttt{align} 環境等)や
6227 \texttt{minipage} 環境,\cs{parbox} 命令において,
6228 垂直位置指定 \texttt{[t]},~\texttt{[b]} の挙動が非読み込み時と微妙に変わることがあった.
6229
6230 \Pkg{lltjext} パッケージでは,垂直位置指定が\LaTeXe と同様の挙動(以下に示す)に
6231 なるように修正した.
6232 \begin{itemize}
6233  \item \texttt{[t]} オプション指定時は,ボックスのベースラインが中身の1行目のベースライン
6234        (1行目の上に罫線などが来た時は,ボックスの上端)に一致するように配置する.
6235  \item \texttt{[b]} オプション指定時は,ボックスのベースラインが中身の最終行のベースライン
6236        (中身の最後が罫線などの時は,ボックスの下端)に一致するように配置する.
6237  \item それ以外のときは,ボックスの中央が「数式の軸」に一致するように配置する.
6238 \end{itemize}
6239
6240  \item 連数字用命令 \cs{rensuji} における位置合わせオプション \texttt{[l]}, \texttt{[c]},
6241        \texttt{[r]} の挙動を若干変更した.
6242
6243 \end{itemize}
6244 }
6245 %</ja>
6246 %<*en>
6247 \subsection{\texttt{lltjext.sty}}
6248 \pLaTeX\ supplies additional macros for vertical writing in the \Pkg{plext} package.
6249 The \Pkg{lltjext} package which we want to describe here is the \LuaTeX-ja
6250 counterpart of the \Pkg{plext} package.
6251 %</en>
6252
6253 %<*ja>
6254 念の為,本 \Pkg{lltjext} パッケージで追加・変更している命令の一覧を載せておく.
6255 \begin{cslist}
6256 \item[tabular\textrm{, }array\textrm{, }minipage環境]
6257 これらの環境は,
6258 \begin{lstlisting}
6259 \begin{tabular}<dir>[pos]{table spec} ... \end{tabular}
6260 \begin{array}<dir>[pos]{table spec}   ... \end{array}
6261 \begin{minipage}<dir>[pos]{width}     ... \end{minipage}
6262 \end{lstlisting}
6263 のように,組方向オプション \texttt{\<dir\>} が拡張されている.
6264 既に述べたように,組方向オプションに指定できる値は以下の5つであり,
6265 それ以外を指定した時や無指定時は周囲の組方向と同じ組方向になる.
6266 \begin{description}
6267  \item[y] 横組(\cs{yoko})
6268  \item[t] 縦組(\cs{tate})
6269  \item[z] 周囲が縦組の時はutod方向,それ以外はそのまま
6270  \item[d] dtou方向
6271  \item[u] utod方向
6272 \end{description}
6273 \item[\cs{parbox}\<<dir>\>{[<pos>]}\{<width>\}\{<contents>\}]
6274 \cs{parbox} 命令も同様に,組方向の指定ができるように拡張されている.
6275
6276 \item[\cs{pbox}\<<dir>\>{[<width>][<pos>]}\{<contents>\}]
6277 組方向<dir>で<contents>の中身をLRモードで組む命令である.
6278 <width>が正の値であるときは,ボックス全体の幅がその値となる.
6279 その際,中身は<pos>の値に従い,左寄せ(\texttt{l}),右揃え(\texttt{r}),
6280 中央揃え(それ以外)される.
6281 \item[picture環境]
6282 図表作成に用いる \texttt{picture} 環境も,
6283 \begin{lstlisting}
6284 \begin{picture}<dir>(x_size, y_size)(x_offset,y_offset)
6285   ...
6286 \end{picture}
6287 \end{lstlisting}
6288 と組方向が指定できるように拡張されている.
6289 $x$成分の増加方向は字送り方向,$y$成分の増加方向は行送り方向の\emph{反対方向}となる.
6290 \Pkg{plext} パッケージと同様に
6291 内部ではベースライン補正(\Param{yalbaselineshift}パラメータなど)の影響を受けないように,
6292 \cs{put},~\cs{line}, \cs{vector}, \cs{dashbox}, \cs{oval},~\cs{circle}も
6293 ベースライン補正を受けないように再定義されている.
6294
6295 \item[\cs{rensuji}{[<pos>]}\{<contents>\}\textrm{, }\cs{rensujiskip}]
6296
6297 \item[\cs{Kanji}\{<counter\_name>\}]
6298
6299 \item[\cs{kasen}\{<contents>\}\textrm{, }\cs{bou}\{<contents>\}\textrm{,
6300                      }\cs{boutenchar}]
6301
6302 \item[参照番号]
6303 \end{cslist}
6304 %</ja>
6305 %<*en>
6306 \begin{cslist}
6307 \item[tabular\textrm{, }array\textrm{, }minipage\textrm{ environments}]
6308 These environments are extended by \texttt{\<dir\>}, which specifies the direction,
6309 as follows:
6310 \begin{lstlisting}
6311 \begin{tabular}<dir>[pos]{table spec} ... \end{tabular}
6312 \begin{array}<dir>[pos]{table spec}   ... \end{array}
6313 \begin{minipage}<dir>[pos]{width}     ... \end{minipage}
6314 \end{lstlisting}
6315 This option permits one of the following five values. If none of them is specified,
6316 the direction inside the environment is same as that outside the enviromnent.
6317 \begin{description}
6318  \item[y] \emph{yoko} direction (horizontal writing)
6319  \item[t] \emph{tate} direction (vertical writing)
6320  \item[z] \emph{utod} direction if direction outside the env.\ is \emph{tate}.
6321  \item[d] \emph{dtou} direction
6322  \item[u] \emph{utod} direction
6323 \end{description}
6324 \item[\cs{parbox}\<<dir>\>{[<pos>]}\{<width>\}\{<contents>\}]
6325 \cs{parbox} command is also extended by \texttt{\<dir\>}.
6326
6327 \item[\cs{pbox}\<<dir>\>{[<width>][<pos>]}\{<contents>\}]
6328 This commands typeset <contents> in LR-mode, in <dir> direction.
6329 If <width> is positive, the width of the box becomes this <width>.
6330 In this case, <contents> will be aligned \dots
6331
6332 \item[picture\textrm{environment}]
6333
6334 \item[\cs{rensuji}{[<pos>]}\{<contents>\}\textrm{, }\cs{rensujiskip}]
6335
6336 \item[\cs{Kanji}\{<counter\_name>\}]
6337
6338 \item[\cs{kasen}\{<contents>\}\textrm{, }\cs{bou}\{<contents>\}\textrm{,
6339                      }\cs{boutenchar}]
6340
6341 \item[参照番号]
6342 \end{cslist}
6343 %</en>
6344
6345
6346
6347 %<en>\part{Implementations}
6348 %<ja>\part{実装}
6349 \label{part-imp}
6350 %<en>\section{Storing Parameters}
6351 %<ja>\section{パラメータの保持}
6352 \label{sec-para}
6353 %<en>\subsection{Used Dimensions, Attributes and Whatsit Nodes}
6354 %<ja>\subsection{\LuaTeX-jaで用いられるレジスタとwhatsitノード}
6355
6356 %<*en>
6357 Here the following is the list of dimensions and attributes which are used in \LuaTeX-ja.
6358 %</en>
6359 %<*ja>
6360 以下は\LuaTeX-jaで用いられる寸法レジスタ(dimension),属性レジスタ(attribute)の
6361 リストである.
6362 %</ja>
6363 \begin{list}{}{%
6364 \def\makelabel{\ttfamily}\advance\leftmargin1\zw
6365 \def\dim#1{\item[\textbackslash #1\ \textrm{(dimension)}]}
6366 \def\cnt#1{\item[\textbackslash #1\ \textrm{(counter)}]}
6367 \def\attr#1{\item[\textbackslash #1\ \textrm{(attribute)}]}
6368 }
6369
6370 \dim{jQ}
6371 %<*en>
6372 \cs{jQ} is equal to
6373                         $1\,\textrm{Q}=0.25\,\textrm{mm}$, where ``Q''~(also called ``級'') is
6374                         a unit used in Japanese phototypesetting.
6375 So one should not change the value of this dimension.
6376 %</en>
6377 %<*ja>
6378 \cs{jQ} は写植で用いられた$1\,\textrm{Q}=0.25\,\textrm{mm}$%
6379 (「級」とも書かれる)に等しい.したがって,
6380 この寸法レジスタの値を変更してはならない.
6381 %</ja>
6382
6383 \dim{jH}
6384 %<*en>
6385 There is also a unit called ``歯'' which equals to $0.25\,\textrm{mm}$ and
6386                          used in Japanese phototypesetting.
6387 This \cs{jH} is the same \cs{dimen} register as \cs{jQ}.
6388 %</en>
6389 %<*ja>
6390 同じく写植で用いられていた単位として「歯」があり,これも$0.25\,\textrm{mm}$と
6391 等しい.この \cs{jH} は \cs{jQ} と同じ寸法レジスタを指す.
6392 %</ja>
6393
6394 \dim{ltj@zw}
6395 %<*en>
6396 A temporal register for the ``full-width'' of current Japanese font.
6397 The command \cs{zw} sets this register to the correct value, and
6398 ``return'' this register itself.
6399 %</en>
6400 %<*ja>
6401 現在の和文フォントの「全角幅」を保持する一時レジスタ.
6402 \cs{zw} 命令は,このレジスタを適切な値に設定した後,
6403 「このレジスタ自体を返す」.
6404 %</ja>
6405
6406 \dim{ltj@zh}
6407 %<*en>
6408 A temporal register for the ``full-height'' (usually the sum of height of imaginary body and its depth) of current Japanese font.
6409 The command \cs{zh} sets this register to the correct value, and
6410 ``return'' this register itself.
6411 %</en>
6412 %<*ja>
6413 現在の和文フォントの「全角高さ」(通常,高さと深さの和)を保持する一時レジスタ.
6414 \cs{zh} 命令は,このレジスタを適切な値に設定した後,
6415 「このレジスタ自体を返す」.
6416 %</ja>
6417
6418 \attr{jfam}
6419 %<*en>
6420 Current number of Japanese font family for math formulas.
6421 %</en>
6422 %<*ja>
6423 数式用の和文フォントファミリの現在の番号.
6424 %</ja>
6425
6426 \attr{ltj@curjfnt}
6427 %<*en>
6428 The font index of current Japanese font for horizontal direction.
6429 %</en>
6430 %<*ja>
6431 現在の横組用和文フォントのフォント番号.
6432 %</ja>
6433
6434 \attr{ltj@curtfnt}
6435 %<*en>
6436 The font index of current Japanese font for vertical direction.
6437 %</en>
6438 %<*ja>
6439 現在の縦組用和文フォントのフォント番号.
6440 %</ja>
6441
6442 \attr{ltj@charclass}
6443 %<*en>
6444 The character class of Japanese \textit{glyph\_node}.
6445 %</en>
6446 %<*ja>
6447 和文文字の\textit{glyph\_node}の文字クラス.
6448 %</ja>
6449
6450 \attr{ltj@yablshift}
6451 %<*en>
6452 The amount of shifting the baseline of alphabetic fonts in scaled point ($2^{-16}\,\textrm{pt}$).
6453 %</en>
6454 %<*ja>
6455 スケールド・ポイント($2^{-16}\,\textrm{pt}$)を単位とした欧文フォントのベースラインの移動量.
6456 %</ja>
6457
6458 \attr{ltj@ykblshift}
6459 %<*en>
6460 The amount of shifting the baseline of Japanese fonts in scaled point ($2^{-16}\,\textrm{pt}$).
6461 %</en>
6462 %<*ja>
6463 スケールド・ポイント($2^{-16}\,\textrm{pt}$)を単位とした和文フォントのベースラインの移動量.
6464 %</ja>
6465
6466 \attr{ltj@tablshift}
6467 \attr{ltj@tkblshift}
6468
6469 \attr{ltj@autospc}
6470 %<*en>
6471 Whether the auto insertion of \Param{kanjiskip} is allowed at the node.
6472 %</en>
6473 %<*ja>
6474 そのノードで\Param{kanjiskip}の自動挿入が許されるかどうか.
6475 %</ja>
6476
6477 \attr{ltj@autoxspc}
6478 %<*en>
6479 Whether the auto insertion of \Param{xkanjiskip} is allowed at the node.
6480 %</en>
6481 %<*ja>
6482 そのノードで\Param{xkanjiskip}の自動挿入が許されるかどうか.
6483 %</ja>
6484
6485 \attr{ltj@icflag}
6486 %<*en>
6487 An attribute for distinguishing ``kinds'' of a node. One of the following value is
6488 assigned to this attribute:
6489 %</en>
6490 %<*ja>
6491 ノードの「種類」を区別するための属性.以下のうちのひとつが値として割り当てられる:
6492 %</ja>
6493 \begin{description}
6494 \item[\textit{italic} (1)]
6495 %<*en>
6496 Kerns from italic correction (\verb+\/+), or from kerning information of a Japanese font.
6497 These kerns are ``ignored'' in the insertion process of \textbf{JAglue},
6498 unlike explicit \cs{kern}.
6499 %</en>
6500 %<*ja>
6501 イタリック補正(\verb+\/+)によるカーン,
6502 または \Pkg{luaotfload} によって挿入されたフォントのカーニング情報由来のカーン.
6503 これらのカーンは通常の \cs{kern} とは異なり,
6504 \textbf{JAglue}の挿入処理においては透過する.
6505 %</ja>
6506
6507 \item[\textit{packed} (2)]
6508
6509 \item[\textit{kinsoku} (3)]
6510 %<*en>
6511 Penalties inserted for the word-wrapping process (\emph{kinsoku shori}) of Japanese characters.
6512 %</en>
6513 %<ja>禁則処理のために挿入されたペナルティ.
6514 \item[\mathversion{bold}$(\textit{from\_jfm}-2)$--$(\textit{from\_jfm}+2)$~(4--8)]
6515 %<en>Glues/kerns from JFM.
6516 %<ja>JFM由来のグルー/カーン.
6517 \item[\textit{kanji\_skip}~(9), \textit{kanji\_skip\_jfm}~(10)]
6518 %<en>Glues from \Param{kanjiskip}.
6519 %<ja>和文間空白\Param{kanjiskip}を表すグルー.
6520 \item[\textit{xkanji\_skip}~(11), \textit{xkanji\_skip\_jfm}~(12)]
6521 %<en>Glues from \Param{xkanjiskip}.
6522 %<ja>和欧文間空白\Param{xkanjiskip}を表すグルー.
6523 \item[\textit{processed} (13)]
6524 %<en>Nodes which is already processed by \ldots.
6525 %<ja>\LuaTeX-ja の内部処理によって既に処理されたノード.
6526 \item[\textit{ic\_processed} (14)]
6527 %<*en>
6528 Glues from an italic correction, but already processed in the insertion process of \textbf{JAglue}s.
6529 %</en>
6530 %<ja>イタリック補正に由来するグルーであって,既に \textbf{JAglue} 挿入処理にかかったもの.
6531 \item[\textit{boxbdd} (15)]
6532 %<en>Glues/kerns that inserted just the beginning or the ending of an hbox or a paragraph.
6533 %<ja>hboxか段落の最初か最後に挿入されたグルー/カーン.
6534 \end{description}
6535
6536 %<*ja>
6537 また,挿入処理の結果であるリストの最初のノードでは,\verb+\ltj@icflag+ の値に
6538 \textit{processed\_begin\_flag}~(128)が追加される.これによって,\cs{unhbox} が
6539 連続した場合でも「ボックスの境界」が識別できるようになっている.
6540 %</ja>
6541
6542 \attr{ltj@kcat\,$i$}
6543 %<*en>
6544 Where $i$~is a natural number which is less than~7.
6545 These 7~attributes store bit~vectors indicating which character block is regarded as a block of \textbf{JAchar}s.
6546 %</en>
6547 %<*ja>
6548 $i$は7より小さい自然数.
6549 これら7つの属性レジスタは,どの文字ブロックが\textbf{JAchar}のブロックとして
6550 扱われるかを示すビットベクトルを格納する.
6551 %</ja>
6552
6553 \attr{ltj@dir}
6554 %<*ja>
6555 \textit{direction}~whatsit(後述)において組方向を示すために,あるいは\textit{dir\_box}の
6556                          組方向を用いる.\textit{direction}~whatsitにおいては値は
6557 \begin{quote}
6558  \textit{dir\_dtou} (1), \textit{dir\_tate} (3),
6559  \textit{dir\_yoko} (4), \textit{dir\_utod} (11)
6560 \end{quote}
6561 のいずれかであり,\textit{dir\_box}ではこれらに次を加えた値をとる(\ref{sec-dir-imp}章参照).
6562 %</ja>
6563 \begin{description}
6564 \item[\textit{dir\_node\_auto} (128)]
6565 %<ja> 異なる組方向に配置するために自動的に作られたボックス.
6566 \item[\textit{dir\_node\_manual} (256)]
6567 %<ja> \cs{ltjsetwd} によって「ボックスの本来の組方向とは異なる組方向での寸法」を
6568 %<ja> 設定したときに,それを記録するためのボックス.
6569 \end{description}
6570 %<ja> \TeX 側から見える値,つまり \verb+\the\ltj@dir+ の値は常に0である.
6571
6572 \end{list}
6573
6574 %<*en>
6575 Furthermore, \LuaTeX-ja uses several user-defined whatsit nodes for
6576 internal processing. All those nodes except \emph{direction} whatsits
6577 store a natural number (hence its \texttt{type} is 100).
6578 \emph{direction} whatsits store a node list, hence its \texttt{type} is 110.
6579 Their \texttt{user\_id} (used for distinguish user-defined whatsits)
6580 are allocated by \texttt{luatexbase.newuserwhatsitid}.
6581 %</en>
6582 %<*ja>
6583 さらに,\LuaTeX-jaはいくつかのuser-defined whatsit nodeを内部処理に用いる.
6584 \textit{direction} whatsitはノードリストを格納するが,
6585 それ以外のwhatsitノードの \texttt{type} は100であり,ノードは自然数を格納している.
6586 user-defined whatsitを識別するための \texttt{user\_id} は\
6587 \texttt{luatexbase.newuserwhatsitid} により確保されており,
6588 下の見出しは単なる識別用でしかない.
6589 %</ja>
6590 \begin{description}
6591 \item[\textit{inhibitglue}]
6592 %<*en>
6593 Nodes for indicating that \cs{inhibitglue} is
6594            specified. The \texttt{value} field of these nodes doesn't matter.
6595 %</en>
6596 %<*ja>
6597 \cs{inhibitglue} が指定されたことを示すノード.これらのノードの\
6598 \texttt{value} フィールドは意味を持たない.
6599 %</ja>
6600
6601 \item[\textit{stack\_marker}]
6602 %<*en>
6603 Nodes for \LuaTeX-ja's stack system (see the next
6604            subsection). The \texttt{value} field of these nodes is
6605            current group level.
6606 %</en>
6607 %<*ja>
6608 \LuaTeX-jaのスタックシステム(次の節を参照)のためのノード.
6609 これらのノードの \texttt{value} フィールドは現在のグループネストレベルを表す.
6610 %</ja>
6611
6612 \item[\textit{char\_by\_cid}]
6613 %<*en>
6614 Nodes for \textbf{JAchar} which the callback process of
6615            \Pkg{luaotfload} won't be applied, and the character code is
6616            stored in the \texttt{value} field. Each node of this type are
6617            converted to a \textit{glyph\_node} \emph{after}
6618            the callback process of luaotfload.
6619 Nodes of this type is used in \cs{CID}, \cs{UTF} and IVS support.
6620 %</en>
6621 %<*ja>
6622 \Pkg{luaotfload}のコールバックによる処理が適用されない\textbf{JAchar}のためのノードで,
6623 \texttt{value} フィールドに文字コードが格納されている.
6624 この種類のノードはそれぞれが\Pkg{luaotfload}のコールバックの処理の
6625 \emph{後で}\textit{glyph\_node}に変換される.
6626 \cs{CID}, \cs{UTF}やIVS対応処理でこの種類のノードが利用されている.
6627 %</ja>
6628
6629 \item[\textit{replace\_vs}]
6630 %<*en>
6631 Similar to \textit{char\_by\_cid} whatsits above.
6632 These nodes are for \textbf{ALchar} which the callback process of
6633            \Pkg{luaotfload} won't be applied.
6634 %</en>
6635 %<*ja>
6636 上の\textit{char\_by\_cid}と同様に,
6637 これらのノードは\Pkg{luaotfload}のコールバックによる処理が適用されない\textbf{ALchar}のた
6638            めものである.
6639 %</ja>
6640
6641 \item[\textit{begin\_par}]
6642 %<*en>
6643 Nodes for indicating beginning of a paragraph.
6644 A paragraph which is started by \cs{item} in list-like environments has a horizontal box
6645 for its label before the actual contents. So \dots
6646 %</en>
6647 %<*ja>
6648 「段落の開始」を意味するノード.
6649 list環境,itemize環境などにおいて,\cs{item} で始まる各項目は……
6650 %</ja>
6651
6652 \item[\textit{direction}]
6653
6654 \end{description}
6655
6656 %<*en>
6657 These whatsits will be removed during the process of inserting \textbf{JAglue}s.
6658 %</en>
6659 %<*ja>
6660 これらのwhatsitノードは\textbf{JAglue}の挿入処理の間に取り除かれる.
6661 %</ja>
6662
6663 %<en>\subsection{Stack System of \LuaTeX-ja}
6664 %<ja>\subsection{\LuaTeX-jaのスタックシステム}
6665 \label{ssec-stack}
6666
6667 %<en>\paragraph{Background}
6668 %<ja>\paragraph{背景}
6669 %<*en>
6670 \LuaTeX-ja has its own stack system, and most parameters of \LuaTeX-ja
6671 are stored in it. To clarify the reason, imagine the parameter
6672 \Param{kanjiskip} is stored by a skip, and consider the following
6673 source:
6674 %</en>
6675 %<*ja>
6676 \LuaTeX-jaは独自のスタックシステムを持ち,\LuaTeX-jaのほとんどのパラメータは
6677 これを用いて保持されている.その理由を明らかにするために,
6678 \Param{kanjiskip}パラメータがスキップレジスタで保持されているとし,
6679 以下のコードを考えてみよう:
6680 %</ja>
6681 \begin{LTXexample}
6682 \ltjsetparameter{kanjiskip=0pt}ふがふが.%
6683 \setbox0=\hbox{%
6684   \ltjsetparameter{kanjiskip=5pt}ほげほげ}
6685 \box0.ぴよぴよ\par
6686 \end{LTXexample}
6687
6688 %<*en>
6689 As described in Subsection~\ref{ssec-param}, the only effective value of
6690 \Param{kanjiskip} in an hbox is the latest value, so the value of
6691 \Param{kanjiskip} which applied in the entire hbox should be 5\,pt.
6692 However, by the implementation method of \LuaTeX, this ``5\,pt'' cannot be
6693 known from any callbacks.  In the \texttt{tex/packaging.w}, which is a
6694 file in the source of \LuaTeX, there are the following codes:
6695 %</en>
6696 %<*ja>
6697 \ref{ssec-param}節で述べたように,あるhboxの中で効力を持つ
6698 \Param{kanjiskip}の値は最後に現れた値のみであり,したがってボックス全体に適用される
6699 \Param{kanjiskip}は5\,ptであるべきである.しかし,\LuaTeX の実
6700 装を観察すると,この5\,ptという長さはどのコールバックからも知ることはできないことがわかる.
6701 \LuaTeX のソースファイルの1つ \texttt{tex/packaging.w} の中に,
6702 以下のコードがある:
6703 %</ja>
6704 \begin{lstlisting}[numbers=left,firstnumber=1226]
6705 void package(int c)
6706 {
6707     scaled h;                   /* height of box */
6708     halfword p;                 /* first node in a box */
6709     scaled d;                   /* max depth */
6710     int grp;
6711     grp = cur_group;
6712     d = box_max_depth;
6713     unsave();
6714     save_ptr -= 4;
6715     if (cur_list.mode_field == -hmode) {
6716         cur_box = filtered_hpack(cur_list.head_field,
6717                                  cur_list.tail_field, saved_value(1),
6718                                  saved_level(1), grp, saved_level(2));
6719         subtype(cur_box) = HLIST_SUBTYPE_HBOX;
6720 \end{lstlisting}
6721 %<*en>
6722 Notice that \texttt{unsave()} is executed \emph{before}
6723 \texttt{filtered\_hpack()}, where \texttt{hpack\_filter} callback is
6724 executed) here. So ``5\,pt'' in the above source is orphaned at
6725 \texttt{unsave()}, and hence it can't be accessed from \texttt{hpack\_filter}
6726 callback.
6727 %</en>
6728 %<*ja>
6729 \texttt{unsave()} が \texttt{filtered\_hpack()}(これは \texttt{hpack\_filter} コールバックが
6730 実行されるところである)の\emph{前に}実行されていることに注意する.
6731 したがって,上記ソース中で5\,ptは \texttt{unsave()} のところで捨てられ,
6732 \texttt{hpack\_filter} コールバックからはアクセスすることができない.
6733 %</ja>
6734
6735 %<en>\paragraph{Implementation}
6736 %<ja>\paragraph{解決法}
6737
6738 %<*en>
6739 The code of stack system is based on that in a post of Dev-luatex mailing list\footnote{%
6740 \texttt{[Dev-luatex] tex.currentgrouplevel}, a post at 2008/8/19 by Jonathan Sauer.}.
6741 %</en>
6742 %<*ja>
6743 スタックシステムのコードはDev-luatexメーリングリストのある投稿\footnote{%
6744 \texttt{[Dev-luatex] tex.currentgrouplevel}: Jonathan Sauerによる2008/8/19の投稿.}を
6745 ベースにしている.
6746 %</ja>
6747
6748 %<*en>
6749 These are two \TeX\ count registers for maintaining information:
6750 \verb+\ltj@@stack+ for the stack level, and \verb+\ltj@@group@level+ for
6751 the \TeX's group level when the last assignment was done.  Parameters
6752 are stored in one big table named \texttt{charprop\_stack\_table}, where
6753 \texttt{charprop\_stack\_table[$i$]} stores data of stack level~$i$. If
6754 a new stack level is created by \cs{ltjsetparameter}, all data of the
6755 previous level is copied.
6756 %</en>
6757 %<*ja>
6758 情報を保持するために,2つの\TeX の整数レジスタを用いている:
6759 \verb+\ltj@@stack+ にスタックレベル,\verb+\ltj@@group@level+ に最後の代入が
6760 なされた時点での\TeX のグループレベルを保持している.
6761 パラメータは\texttt{charprop\_stack\_table}という名前のひとつの大きなテーブルに
6762 格納される.ここで,\texttt{charprop\_stack\_table[$i$]}はスタックレベル$i$の
6763 データを格納している.もし新しいスタックレベルが \cs{ltjsetparameter} によって
6764 生成されたら,前のレベルの全てのデータがコピーされる.
6765 %</ja>
6766
6767 %<*en>
6768 To resolve the problem mentioned in above paragraph ``Background'', \LuaTeX-ja uses
6769 another trick. When the stack level is about to be increased, a whatsit
6770 node whose type, subtype and value are 44~(\textit{user\_defined}),
6771 \textit{stack\_marker} and the current group level respectively is appended to the current
6772 list (we refer this node by \textit{stack\_flag}). This enables us to
6773 know whether assignment is done just inside a hbox. Suppose that the
6774 stack level is~$s$ and the \TeX's group level is~$t$ just after the hbox
6775 group, then:
6776 %</en>
6777 %<*ja>
6778 上の「背景」で述べた問題を解決するために,\LuaTeX-jaでは次の手法を用いる:
6779 スタックレベルが増加するするとき,type, subtype, valueがそれぞれ
6780 44~(\textit{user\_defined}), \textit{stack\_marker},そして現在のグループレベルであるwhatsitノード
6781 を現在のリストに付け加える(このノードを\textit{stack\_flag}とする).
6782 これにより,あるhboxの中で代入がなされたかどうかを知ることが可能
6783 となる.スタックレベルを$s$,そのhbox groupの直後の\TeX のグループレベルを
6784 $t$とすると:
6785 %</ja>
6786 \begin{itemize}
6787 %<*en>
6788 \item If there is no \textit{stack\_flag} node in the list of the contents of the hbox, then
6789       no assignment was occurred inside the hbox. Hence values of
6790       parameters at the end of the hbox are stored in the stack
6791       level~$s$.
6792 %</en>
6793 %<*ja>
6794 \item もしそのhboxの中身を表すリストの中に\textit{stack\_flag}ノードがなければ,
6795   hboxの中では代入は起こらなかったということになる.
6796   したがって,そのhboxの終わりにおけるパラメータの値はスタックレベル$s$に
6797   格納されている.
6798 %</ja>
6799
6800 %<*en>
6801 \item If there is a \textit{stack\_flag} node whose value is~$t+1$, then
6802       an assignment was occurred just inside the hbox group. Hence
6803       values of parameters at the end of the hbox are stored in the
6804       stack level~$s+1$.
6805 %</en>
6806 %<*ja>
6807 \item もし値が$t+1$の\textit{stack\_flag}ノードがあれば,その
6808   hboxの中で代入が起こったことになる.
6809   したがって,hboxの終わりにおけるパラメータの値はスタックレベル$s+1$に
6810   格納されている.
6811 %</ja>
6812
6813 %<*en>
6814 \item If there are \textit{stack\_flag} nodes but all of their values
6815       are more than~$t+1$, then an assignment was occurred in the box,
6816       but it is done in more internal group. Hence values of
6817       parameters at the end of the hbox are stored in the stack
6818       level~$s$.
6819 %</en>
6820 %<*ja>
6821 \item もし\textit{stack\_flag}ノードがあるがそれらの値が全て$t+1$より大きい
6822   場合,そのボックスの中で代入が起こったが,それは「より内部の」グループで
6823   起こったということになる.したがって,hboxの終わりでのパラメータの
6824   値はスタックレベル$s$に格納されている.
6825 %</ja>
6826 \end{itemize}
6827
6828 %<*en>
6829 Note that to work this trick correctly, assignments to
6830 \verb+\ltj@@stack+ and \verb+\ltj@@group@level+ have to be local always,
6831 regardless the value of \cs{globaldefs}.
6832 To solve this problem, we use another trick: the assignment
6833 \hbox{\verb+\directlua{tex.globaldefs=0}+} is always local.
6834 %</en>
6835 %<*ja>
6836 このトリックを正しく働かせるためには,\verb+\ltj@@stack+ と \verb+\ltj@@group@level+ への
6837 代入は \cs{globaldefs} の値によらず常にローカルでなければならないことに注意する.
6838 この問題は \hbox{\verb+\directlua{tex.globaldefs=0}+}(この代入は常にローカル)を
6839 用いることで解決している.
6840 %</ja>
6841
6842 %<*en>
6843 \subsection{Lua Functions of the Stack System}
6844 In this subsection, we will see how a user use \LuaTeX-ja's stack system to
6845 store some data which obeys the grouping of \TeX.
6846 %</en>
6847 %<*ja>
6848 \subsection{スタックシステムで使用される関数}
6849 本節では,ユーザが\LuaTeX-jaのスタックシステムを使用して,
6850 \TeX のグルーピングに従うような
6851 独自のデータを取り扱う方法を述べる.
6852 %</ja>
6853
6854 %<*en>
6855 The following function can be used to store data into a stack:
6856 \begin{lstlisting}
6857 luatexja.stack.set_stack_table(index, <any> data)
6858 \end{lstlisting}
6859 Any values which except \texttt{nil}~and~NaN are usable as \textit{index}.
6860 However, a user should use only negative integers or strings as \textit{index},
6861 since natural numbers are used by \LuaTeX-ja itself.
6862 Also, whether \textit{data} is stored locally or globally
6863 is determined by \texttt{luatexja.isglobal}
6864 (stored globally if and only if \texttt{luatexja.isglobal == 'global'}).
6865 %</en>
6866 %<*ja>
6867 スタックに値を設定するには,以下のLua関数を呼び出せば良い:
6868 \begin{lstlisting}
6869 luatexja.stack.set_stack_table(<any> index, <any> data)
6870 \end{lstlisting}
6871 直感的には,スタックテーブル中のインデックス\textit{index}の値を\textit{data}にする,という意味である.
6872 \textit{index}の値としては \texttt{nil} とNaN以外の任意の値を使えるが,
6873 自然数は\LuaTeX-jaが使用する(将来の拡張用も含む)ので,
6874 ユーザが使用する場合は負の整数値か文字列の値にすることが望ましい.
6875 また,ローカルに設定されるかグローバルに設定されるかは,\texttt{luatexja.isglobal} の値に依存する
6876 (グローバルに設定されるのは,\texttt{luatexja.isglobal == 'global'} であるちょうどその時).
6877 %</ja>
6878
6879 %<*en>
6880 Stored data can be obtained as the return value of
6881 \begin{lstlisting}
6882 luatexja.stack.get_stack_table(index, <any> default, <number> level)
6883 \end{lstlisting}
6884 where \textit{level} is the stack level, which is usually the value of \verb+\ltj@@stack+,
6885 and \textit{default} is the default value which will be returned if no values are stored
6886 in the stack table whose level is \textit{level}.
6887 %</en>
6888 %<*ja>
6889 スタックの値は,
6890 \begin{lstlisting}
6891 luatexja.stack.get_stack_table(<any> index, <any> default, <number> level)
6892 \end{lstlisting}
6893 の戻り値で取得できる.\textit{level}はスタックレベルであり,
6894 通常は \verb+\ltj@@stack+ の値を指定することになるだろう.
6895 \textit{default}はレベル\textit{level}のスタックに値が設定されていなかった場合に
6896 返すデフォルト値である.
6897 %</ja>
6898
6899 \begin{figure}[tb]
6900 \begin{lstlisting}[numbers=left, firstnumber=380]
6901 \protected\def\ltj@setpar@global{%
6902   \relax\ifnum\globaldefs>0\directlua{luatexja.isglobal='global'}%
6903     \else\directlua{luatexja.isglobal=''}\fi
6904 }
6905 \protected\def\ltjsetparameter#1{%
6906   \ltj@setpar@global\setkeys[ltj]{japaram}{#1}\ignorespaces}
6907 \protected\def\ltjglobalsetparameter#1{%
6908   \relax\ifnum\globaldefs<0\directlua{luatexja.isglobal=''}%
6909     \else\directlua{luatexja.isglobal='global'}\fi%
6910   \setkeys[ltj]{japaram}{#1}\ignorespaces}
6911 \end{lstlisting}
6912 %<ja>\caption{パラメータ設定命令の定義}
6913 %<en>\caption{Definiton of parameter setting commands}
6914 \label{fig:setpar-def}
6915 \end{figure}
6916
6917 %<*en>
6918 \subsection{Extending Parameters}
6919 Keys for \cs{ltjsetparameter}~and~\cs{ltjgetparameter} can be extended,
6920 as in \Pkg{luatexja-adjust}.
6921 %</en>
6922 %<*ja>
6923 \subsection{パラメータの拡張}
6924 ここでは,\Pkg{luatexja-adjust}で行なっているように,
6925 \cs{ltjsetparameter},~\cs{ltjgetparameter}に指定可能なキーを追加する方法
6926 を述べる.
6927 %</ja>
6928
6929 %<*en>
6930 \paragraph{Setting parameters}
6931 Figure~\ref{fig:setpar-def} shows the ``most outer'' definition of
6932 two commands,
6933 \cs{ltjsetparameter} and \cs{ltjglobalsetparameter}.
6934 Most important part is the last \cs{setkeys},
6935 which is offered by the \Pkg{xkeyval} package.
6936
6937 Hence, to add a key in \cs{ltjsetparameter}, one only have to add a key
6938 whose prefix is \texttt{ltj} and whose family is \texttt{japaram}, as the following.
6939 \begin{lstlisting}
6940 \define@key[ltj]{japaram}{...}{...}
6941 \end{lstlisting}
6942
6943 \cs{ltjsetparameter}~and~\cs{ltjglobalsetparameter} automatically sets
6944 \texttt{luatexja.isglobal}. Its meaning is the following.
6945 \begin{align}
6946  \texttt{luatexja.isglobal} =
6947 \begin{cases}
6948  \texttt{'global'}&\text{global}\\
6949  \texttt{''}&\text{local}
6950 \end{cases}
6951 \end{align}
6952 This is determined not only by command name
6953 (\cs{ltjsetparameter}~or~\cs{ltjglobalsetparameter}),
6954 but also by the value of \cs{globaldefs}.
6955 %</en>
6956 %<*ja>
6957 \paragraph{パラメータの設定}
6958 \cs{ltjsetparameter} と,\cs{ltjglobalsetparameter} の定義は図\ref{fig:setpar-def}の
6959 のようになっている.
6960 本質的なのは最後の \cs{setkeys} で,これは\Pkg{xkeyval}パッケージの提供する命令である.
6961
6962 このため,\cs{ltjsetparameter} に指定可能なパラメータを追加するには,
6963 <prefix>を \texttt{ltj},<family>を \texttt{japaram} としたキーを
6964 \begin{lstlisting}
6965 \define@key[ltj]{japaram}{...}{...}
6966 \end{lstlisting}
6967 のように定義すれば良いだけである.
6968 なお,パラメータ指定がグローバルかローカルかどうかを示す \texttt{luatexja.isglobal} が,
6969 \begin{align}
6970  \texttt{luatexja.isglobal} =
6971 \begin{cases}
6972  \texttt{'global'}&\text{パラメータ設定はグローバル}\\
6973  \texttt{''}&\text{パラメータ設定はローカル}
6974 \end{cases}
6975 \end{align}
6976 として自動的にセットされる\footnote{命令が \cs{ltjglobalsetparameter} かどうかだけでは
6977 なく,実行時の \cs{globaldefs} の値にも依存して定まる.}.
6978 %</ja>
6979
6980 %<*en>
6981 \paragraph{Getting parameters}
6982 \cs{ltjgetparameter} is implemented by a Lua script.
6983
6984 For parameters that do not need additional arguments, one only have to
6985 define a function in the table \verb+luatexja.unary_pars+.
6986 For example, with the following function,
6987 \verb+\ltjgetparameter{hoge}+ returns a \emph{string} \texttt{42}.
6988 \begin{lstlisting}[numbers=left]
6989 function luatexja.unary_pars.hoge (t)
6990   return 42
6991 end
6992 \end{lstlisting}
6993 Here the argument of \verb+luatexja.unary_pars.hoge+ is
6994 the stack level of \LuaTeX-ja's stack system (see Subsection~\ref{ssec-stack}).
6995
6996 On the other hand, for parameters that need an additional argument
6997 (this must be an integer), one have to define a function in
6998 \verb+luatexja.binary_pars+ first. For example,
6999 \begin{lstlisting}[numbers=left]
7000 function luatexja.binary_pars.fuga (c, t)
7001   return tostring(c) .. ', ' .. tostring(42)
7002 end
7003 \end{lstlisting}
7004 Here the first argument $t$ is the stack level, as before.
7005 The second argument $c$ is just the second argument of \cs{ltjgetparameter}.
7006
7007 For parameters that need an additional argument, one also have to
7008 execute the \TeX\ code like
7009 \begin{lstlisting}
7010 \ltj@@decl@array@param{fuga}
7011 \end{lstlisting}
7012 to indicate that ``the parameter \texttt{fuga} needs an additional argument''.
7013 %</en>
7014 %<*ja>
7015 \paragraph{パラメータの取得}
7016 一方,\cs{ltjgetparameter} はLuaスクリプトによって実装されている.
7017 値を取得するのに追加引数の要らないパラメータについては,\verb+luatexja.unary_pars+\
7018 内に処理内容を記述した関数を定義すれば良い.例えば,Luaスクリプトで
7019 \begin{lstlisting}[numbers=left]
7020 function luatexja.unary_pars.hoge (t)
7021   return 42
7022 end
7023 \end{lstlisting}
7024 を実行すると,\verb+\ltjgetparameter{hoge}+ は \texttt{42} という\emph{文字列}を返す.
7025 関数 \verb+luatexja.unary_pars.hoge+ の引数$t$は,\ref{ssec-stack}節で述べた
7026 \LuaTeX-jaのスタックシステムにおけるスタックレベルである.
7027 戻り値はいかなる値であっても,最終的には文字列として出力されることに注意.
7028
7029 一方,追加引数(\emph{数値しか許容しない})が必要なパラメータについては,
7030 まずLuaスクリプトで処理内容の本体を記述しておく:
7031 \begin{lstlisting}[numbers=left]
7032 function luatexja.binary_pars.fuga (c, t)
7033   return tostring(c) .. ', ' .. tostring(42)
7034 end
7035 \end{lstlisting}
7036 引数$t$は,先に述べた通りのスタックレベルである.一方,引数$c$は\
7037 \cs{ltjgetparameter} の第2引数を表す数値である.
7038 しかしこれだけでは駄目で,
7039 \begin{lstlisting}
7040 \ltj@@decl@array@param{fuga}
7041 \end{lstlisting}
7042 を実行し,\TeX インターフェース側に
7043 「\verb+\ltjgetparameter{fuga}+ は追加引数が必要」ということを通知する必要がある.
7044 %</ja>
7045
7046 %<en>\section{Linebreak after a Japanese Character}
7047 %<ja>\section{和文文字直後の改行}
7048 \label{sec-lbreak}
7049 %<en>\subsection{Reference: Behavior in \pTeX}
7050 %<ja>\subsection{参考:\pTeX の動作}
7051 %<*en>
7052 In~\pTeX, a line break after a Japanese character doesn't emit a space,
7053 since words are not separated by spaces in Japanese writings. However,
7054 this feature isn't fully implemented in \LuaTeX-ja due to the
7055 specification of callbacks in~\LuaTeX. To clarify the difference between
7056 \pTeX~and~\LuaTeX, We briefly describe the handling of a line break in~\pTeX, in
7057 this subsection.
7058
7059 \pTeX's input processor can be described in terms of a finite state
7060 automaton, as that of~\TeX\ in~Section~2.5 of~\cite{texbytopic}. The
7061 internal states are as follows:
7062 \begin{itemize}
7063 \item State~$N$: new line
7064 \item State~$S$: skipping spaces
7065 \item State~$M$: middle of line
7066 \item State~$K$: after a Japanese character
7067 \end{itemize}
7068 The first three states---$N$,~$S$, and~$M$---are as same as \TeX's input
7069 processor.  State~$K$ is similar to state~$M$, and is entered after
7070 Japanese characters.  The diagram of state transitions are indicated in
7071 Figure~\ref{fig-ptexipro}.  Note that \pTeX\ doesn't leave state~$K$
7072 after ``beginning/ending of a group'' characters.
7073 %</en>
7074
7075 %<*ja>
7076 欧文では文章の改行は単語間でしか行わない.そのため,\TeX では,(文字の直後の)改行は
7077 空白文字と同じ扱いとして扱われる.一方,和文ではほとんどどこでも改行が可能なため,
7078 \pTeX では和文文字の直後の改行は単純に無視されるようになっている.
7079
7080 このような動作は,\pTeX が\TeX からエンジンとして拡張されたことによって可能になったことである.
7081 \pTeX の入力処理部は,\TeX におけるそれと同じように,有限オートマトンとして記述することができ,
7082 以下に述べるような4状態を持っている.
7083
7084 \begin{itemize}
7085 \item State~$N$: 行の開始.
7086 \item State~$S$: 空白読み飛ばし.
7087 \item State~$M$: 行中.
7088 \item State~$K$: 行中(和文文字の後).
7089 \end{itemize}
7090 また,状態遷移は,図\ref{fig-ptexipro}のようになっており,図中の数字は
7091 カテゴリーコードを表している.最初の3状態は\TeX の入力処理部と同じであり,
7092 図中から状態$K$と「$j$」と書かれた矢印を取り除けば,\TeX の入力処理部と同
7093 じものになる.
7094
7095 この図から分かることは,
7096 \begin{quote}
7097 行が和文文字(とグループ境界文字)で終わっていれば,改行は無視される
7098 \end{quote}
7099 ということである.
7100 %</ja>
7101
7102 \begin{figure}[!tb]
7103 \let\sp\textvisiblespace\small
7104 \begin{minipage}{.6\textwidth}%
7105 \begin{center}
7106 \unitlength=6.5mm\sf\mathversion{bold}
7107 \begin{tikzpicture}[
7108   ->, auto, shorten >=1pt
7109 ]
7110 \node [shape=rectangle, font=\scriptsize] (init) at (2,7) {start};
7111 \node [shape=circle,draw, fill=b_cyan] (newline) at (4,7) {$N$};
7112 \node [shape=circle,draw, fill=b_cyan] (midline) at (4,4) {$M$};
7113 \node [shape=circle,draw, fill=b_cyan] (skipspc) at (8,7) {$S$};
7114 \node [shape=circle,draw, fill=b_pink]  (kanji) at (8,4) {$K$};
7115 \node [shape=rectangle,draw, fill=b_green] (scanacs) at (6,8) {scan a c.s.};
7116 \node (endk) at (8,2.5) {} ;
7117 \node (endm) at (4,2.5) {} ;
7118 \node (ends) at (8,8.5) {} ;
7119 \node (endn) at (4,8.5) {} ;
7120 \begin{scope}[font=\scriptsize]
7121 \path (newline) edge [bend right]    node [left]{G, O} (midline)
7122       (init)    edge                 node {} (newline)
7123       (midline) edge [bend right=10] node {10} (skipspc)
7124       (skipspc) edge [bend right]    node [left,right=10,above=7]{G, O} (midline)
7125       (skipspc) edge [loop right]    node {10} (skipspc)
7126       (newline) edge [loop right]    node {10} (newline)
7127       (scanacs) edge [bend left]     node [left=3,below]{$(*)$} (skipspc)
7128       (scanacs) edge [bend right]    node [right=30,above=20]{$(*)$} (midline)
7129       (midline) edge                 node {5\ [\sp]} (endm)
7130       (midline) edge [loop left]     node {G, O} (midline)
7131       (skipspc) edge                 node [right] {5} (ends)
7132       (newline) edge                 node {5 [\cs{par}]} (endn);
7133 \begin{scope}[red]
7134 \path (newline) edge [bend right]    node [right=25,below=3]{J} (kanji)
7135       (midline) edge                 node [below]{J} (kanji)
7136       (kanji)   edge [bend left]     node {O} (midline)
7137       (kanji)   edge                 node {10} (skipspc)
7138       (kanji)   edge [loop right]    node {G, J} (kanji)
7139       (skipspc) edge [bend left]     node {J} (kanji)
7140       (kanji)   edge                 node {5} (endk)
7141 ;
7142 \end{scope}
7143 \end{scope}
7144 \end{tikzpicture}
7145 \end{center}
7146 \end{minipage}%
7147 \begin{minipage}{.4\textwidth}
7148 \begin{description}
7149 \item[\textsf{G}] Beginning of group (usually \verb+{+)\\
7150  and ending of group (usually \verb+}+).
7151 \item[\textsf{J}] Japanese characters.
7152 \item[\textsf{5}] \textit{end-of-line} (usually \verb+^+\verb+^J+).
7153 \item[\textsf{10}] space (usually \sp).
7154 \item[\textsf{O}] other characters, whose category code is in $\{3,4,6,7,8,11,12,13\}$.
7155 \item[\textsf{[\sp]}, \textsf{[\cs{par}]}]
7156 emits a space, or~\cs{par}.
7157 \end{description}
7158 \end{minipage}
7159 \begin{itemize}
7160 \item We omitted about category codes
7161 9~(\textit{ignored}), 14~(\textit{comment}), and~15~(\textit{invalid})
7162 from the above diagram. We also ignored the input like ``\verb+^+\verb+^A+'' or ``\verb+^+\verb+^df+''.
7163 \item When a character whose category code is 0 (\textit{escape character}) is seen by \TeX,
7164 the input processor scans a control sequence (\textsf{scan a c.s.}).
7165 These paths are not shown in the above diagram.
7166
7167 After that, the state is changed to State~$S$ (skipping blanks) in most cases, but
7168 to State~$M$ (middle of line) sometimes.
7169 \end{itemize}
7170 %<en>\caption{State transitions of \pTeX's input processor}
7171 %<ja>\caption{\pTeX の入力処理部の状態遷移}
7172 \label{fig-ptexipro}
7173 \end{figure}
7174
7175
7176 %<en>\subsection{Behavior in \LuaTeX-ja}
7177 %<ja>\subsection{\LuaTeX-jaの動作}
7178 %<*en>
7179 States in the input processor of \LuaTeX\ is the same as that of \TeX,
7180 and they can't be customized by any callbacks. Hence, we can only use
7181 \verb+process_input_buffer+ and \verb+token_filter+ callbacks for to
7182 suppress a space by a line break which is after Japanese characters.
7183
7184 However, \verb+token_filter+ callback cannot be used either, since a
7185 character in category code 5~(\textit{end-of-line}) is converted into an space
7186 token \emph{in the input processor}.  So we can use only the
7187 \verb+process_input_buffer+ callback.  This means that suppressing a
7188 space must be done \emph{just before} an input line is read.
7189
7190 Considering these situations, handling of an end-of-line in \LuaTeX-ja are as follows:
7191 \begin{quote}
7192 A character \texttt{U+FFFFF} (its category code is set to 14~(\textit{comment}) by
7193 \LuaTeX-ja) is appended to an input line, \emph{before \LuaTeX\ actually
7194 process it}, if and only if the following three conditions are satisfied:
7195 \begin{enumerate}
7196 \item The category code of \cs{endlinechar}%
7197 \footnote{Usually, it is $\langle$\textit{return}$\rangle$
7198       (whose character code is 13).} is 5~(\textit{end-of-line}).
7199 \item The category code of \texttt{U+FFFFF} itself is 14~(\textit{comment}).
7200 \item The input line matches the following ``regular expression'':
7201 \[
7202   (\text{any char})^*(\textbf{JAchar})
7203   \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
7204 \]
7205 \end{enumerate}
7206 \end{quote}
7207
7208 \paragraph{Remark}
7209 The following example shows the major difference from the behavior of \pTeX.
7210 \begin{LTXexample}
7211 \fontspec[Ligatures=TeX]{TeX Gyre Termes}
7212 \ltjsetparameter{autoxspacing=false}
7213 \ltjsetparameter{jacharrange={-6}}xあ
7214 y\ltjsetparameter{jacharrange={+6}}zい
7215 u
7216 \end{LTXexample}
7217 It is not strange that ``あ'' does not printed in the above output.
7218 This is because \TeX\ Gyre\ Termes does not contain ``あ'', and because
7219 ``あ'' in line~3 is considered as an \textbf{ALchar}.
7220
7221 Note that there is no space before ``y'' in the output, but
7222 there is a space before ``u''. This follows from following reasons:
7223 \begin{itemize}
7224 \item When line~3 is processed by \texttt{process\_input\_buffer} callback,
7225 ``あ'' is considered as an \textbf{JAchar}.
7226 Since  line~3 ends with an \textbf{JAchar},
7227 the comment character \texttt{U+FFFFF} is appended to this line,
7228 and hence the linebreak immediately after this line is ignored.
7229 \item When line~4 is processed by \texttt{process\_input\_buffer} callback,
7230 ``い'' is considered as an \textbf{ALchar}.
7231 Since  line~4 ends with an \textbf{ALchar}, the linebreak immediately after this line
7232 emits a space.
7233 \end{itemize}
7234 %</en>
7235
7236 %<*ja>
7237 \LuaTeX の入力処理部は\TeX のそれと全く同じであり,コールバックによりユーザが
7238 カスタマイズすることはできない.このため,改行抑制の目的でユーザが利用で
7239 きそうなコールバックとしては,\verb+process_input_buffer+や
7240 \verb+token_filter+に限られてしまう.しかし,\TeX の入力処理部をよく見る
7241 と,後者も役には経たないことが分かる:改行文字は,入力処理部によってトー
7242 クン化される時に,カテゴリーコード10の32番文字へと置き換えられてしまうた
7243 め,\verb+token_filter+で非標準なトークン読み出しを行おうとしても,空白文
7244 字由来のトークンと,改行文字由来のトークンは区別できないのだ.
7245
7246 すると,我々のとれる道は,\verb+process_input_buffer+を用いて
7247 \LuaTeX の入力処理部に引き渡される前に入力文字列を編集するというものしかない.
7248 以上を踏まえ,\LuaTeX-jaにおける「和文文字直後の改行抑制」の処理は,次のようになっている:
7249
7250 \begin{quote}
7251 各入力行に対し,\emph{その入力行が読まれる前の内部状態で}
7252 以下の3条件が満たされている場合,\LuaTeX-jaは\texttt{U+FFFFF}の文字
7253 \footnote{この文字はコメント文字として扱われるように\LuaTeX-ja内部で設定をしている.}
7254 を末尾に追加する.よって,その場合に改行は空白とは見做されないこととなる.
7255 \begin{enumerate}
7256 \item \cs{endlinechar}の文字\footnote{普通は,改行文字(文字コード13番)である.}
7257 のカテゴリーコードが5~(\textit{end-of-line})である.
7258 \item \texttt{U+FFFFF}のカテゴリーコードが14~(\textit{comment})である.
7259 \item 入力行は次の「正規表現」にマッチしている:
7260 \[
7261   (\text{any char})^*(\textbf{JAchar})
7262   \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
7263 \]
7264 \end{enumerate}
7265 \end{quote}
7266
7267 この仕様は,前節で述べた\pTeX の仕様にできるだけ近づけたものとなっている.条件1.は,
7268 \texttt{lstlisting}系環境などの日本語対応マクロを書かなくてすませるためのものである.
7269
7270 しかしながら,\pTeX と完全に同じ挙動が実現できたわけではない.
7271 次のように,和文文字の範囲を変更したちょうどその行においては挙動が異なる:
7272 \begin{LTXexample}
7273 \fontspec[Ligatures=TeX]{TeX Gyre Termes}
7274 \ltjsetparameter{autoxspacing=false}
7275 \ltjsetparameter{jacharrange={-6}}xあ
7276 y\ltjsetparameter{jacharrange={+6}}zい
7277 u
7278 \end{LTXexample}
7279 上ソース中の「あ」は欧文文字扱いであり.
7280 ここで使用している欧文フォント\TeX\ Gyre Termesは「あ」を含まない.
7281 よって,出力に「あ」は現れないことは不思議ではない.
7282 それでも,\pTeX とまったく同じ挙動を示すならば,出力は
7283 「\hbox{\ltjsetparameter{autoxspacing=false}x yzいu}」となるはずである.しかし,実際には
7284 上のように異なる挙動となっているが,それは以下の理由による:
7285 \begin{itemize}
7286 \item 3行目を \texttt{process\_input\_buffer} で処理する時点では,
7287       「あ」は和文文字扱いである.よって3行目は和文文字で終わることになり,
7288       コメント文字 \texttt{U+FFFFF} が追加される.
7289       よって,直後の改行文字は無視されることになり,空白は入らない.
7290 \item 4行目を \texttt{process\_input\_buffer} で処理する時点では,
7291       「い」は欧文文字扱いである.よって4行目は欧文文字で終わることになり,
7292       直後の改行文字は空白に置き換わる.
7293 \end{itemize}
7294 このため,トラブルを避けるために,和文文字の範囲を\cs{ltjsetparameter}で編集した場合,
7295 その行はそこで改行するようにした方がいいだろう.
7296 %</ja>
7297
7298 %<*ja>
7299
7300 %<en>\section{Insertion of JFM glues, \Param{kanjiskip} and \Param{xkanjiskip}}
7301 %<ja>\section{JFMグルーの挿入,\Param{kanjiskip}と\Param{xkanjiskip}}
7302 \label{sec-jfmglue}
7303 %<en>\subsection{Overview}
7304 %<ja>\subsection{概要}
7305
7306 \LuaTeX-jaにおける \textbf{JAglue} の挿入方法は,\pTeX のそれとは全く異なる.
7307 \pTeX では次のような仕様であった:
7308 \begin{itemize}
7309 \item JFMグルーの挿入は,和文文字を表すトークンを元に水平リストに(文字を表す)<char\_node>を
7310 追加する過程で行われる.
7311 \item \Param{xkanjiskip}の挿入は,hboxへのパッケージングや行分割前に行われる.
7312 \item \Param{kanjiskip}はノードとしては挿入されない.パッケージングや行分割の計算時に
7313 「和文文字を表す2つの<char\_node>の間には\Param{kanjiskip}がある」ものとみなされる.
7314 \end{itemize}
7315 しかし,\LuaTeX-jaでは,hboxへのパッケージングや行分割前に全ての
7316 \textbf{JAglue},即ちJFMグルー・\Param{xkanjiskip}・\Param{kanjiskip}の
7317 3種類を一度に挿入することになっている.これは,\LuaTeX において欧文の合字・
7318 カーニング処理がノードベースになったことに対応する変更である.
7319
7320 \LuaTeX-jaにおける\textbf{JAglue}挿入処理では,次節で定義する
7321 「クラスタ」を単位にして行われる.大雑把にいうと,「クラスタ」は文字とそれに付随す
7322 るノード達(アクセント位置補正用のカーンや,イタリック補正)をまとめたもの
7323 であり,2つのクラスタの間には,ペナルティ,\cs{vadjust},whatsitなど,行組版
7324 には関係しないものがある.
7325
7326
7327 %<en>\subsection{Definition of a Cluster}
7328 %<ja>\subsection{「クラスタ」の定義}
7329
7330 \def\OA{$\text{\sf O}_{\text{\sf A}}$}
7331 \def\OB{$\text{\sf O}_{\text{\sf B}}$}
7332 \begin{defn}
7333 %<*en>
7334 A \emph{cluster} is consecutive nodes in one of the following forms,
7335 with the \textit{id} of it:
7336 %</en>
7337 %<*ja>
7338 \emph{クラスタ}は以下の形のうちのどれかひとつをとるノードのリストである:
7339 %</ja>
7340 \begin{enumerate}
7341 %<*en>
7342 \item Nodes whose value of\ \verb+\ltj@icflag+ is in $[3,15)$.  These
7343       nodes come from a hbox which is already packaged, by unpackaging
7344       (\cs{unhbox}).
7345       The \textit{id} of the cluster is \textit{id\_pbox}.
7346 %</en>
7347 %<*ja>
7348 \item その \verb+\ltj@icflag+ の値が$[3,15)$に入るノードのリスト.
7349   これらのノードはある既にパッケージングされたhboxから \cs{unhbox} で
7350   アンパックされたものである.
7351   この場合,クラスタの\textit{id}は\textit{id\_pbox}である.
7352 %</ja>
7353
7354 %<*en>
7355 \item A inline math formula, including two \textit{math\_node}s at the boundary of it.
7356       The \textit{id} of the cluster is \textit{id\_math}.
7357 %</en>
7358 %<*ja>
7359 \item インライン数式でその境界に2つの\textit{math\_node}を含むもの.
7360   この場合,クラスタの\textit{id}は\textit{id\_math}である.
7361 %</ja>
7362
7363 %<*en>
7364 \item A \textit{glyph\_node}~$p$, which represents a \textbf{JAchar}, with nodes which relate with it:
7365 %</en>
7366 %<*ja>
7367 \item \textbf{JAchar}を表す\textit{glyph\_node}~$p$とそれに関係するノード:
7368 %</ja>
7369 \begin{enumerate}
7370 %<*en>
7371 \item[(a)] A kern for the italic correction of~$p$.
7372 %</en>
7373 %<*ja>
7374 \item[(a)] $p$のイタリック補正のためのカーン.
7375 %</ja>
7376
7377 %<*en>
7378 \item[(b)] An accent attached to $p$ by \cs{accent}.
7379 %</en>
7380 %<*ja>
7381 \item[(b)] \cs{accent} による$p$に付随したアクセント.
7382 %</ja>
7383 \end{enumerate}
7384 \[
7385 \overbrace{%
7386  \Node{kern}{$\mathit{subtype}=2$}\longrightarrow
7387 \left\{\begin{array}{c}
7388 \Node{glyph}{accent}\\\noalign{\medskip}
7389 \Node{hbox}{accent (shifted vert.)}
7390 \end{array}\right\}\longrightarrow
7391 \Node{kern}{$\mathit{subtype}=2$}}^{\text{(a)}}
7392 \longrightarrow
7393 \Node{glyph}{$p$}\longrightarrow
7394 \overbrace{%
7395 \Node{kern}{italic corr.}}^{\text{(b)}}
7396 \]
7397
7398 %<*en>
7399 In this case, the \textit{id} is \textit{id\_jglyph}.
7400 %</en>
7401 %<*ja>
7402 この場合の\textit{id}は\textit{id\_jglyph}である.
7403 %</ja>
7404
7405 %<*en>
7406 \item A list which begins from a \textit{glyph\_node} which represents a \textbf{ALchar},
7407       and consists of \textbf{ALchar} \textit{glyph\_node}s,
7408       kerns for adjusting accents~(its subtype is 2), kerns for italic corrections and
7409       kerns which are automatically inserted by \LuaTeX~or~luaotfload.
7410       In this case, the \textit{id} is \textit{id\_glyph}.
7411 %</en>
7412 %<*ja>
7413 \item \textbf{ALchar}を表す\textit{glyph\_node},\cs{accent} によるアクセント位置補正用の
7414       カーン(subtypeが2),そしてイタリック補正・カーニングによって挿入されたカーン達が連続
7415       したもの.この場合の\textit{id}は\textit{id\_glyph}である.
7416 %</ja>
7417
7418 %<*en>
7419 \item An box-like node, that is, an hbox, a vbox, a rule (\cs{vrule}) and an \textit{unset\_node}.
7420 The \textit{id} of the cluster is \textit{id\_hlist} if the node is an
7421       hbox which is not shifted vertically, or \textit{id\_box\_like}
7422       otherwise.
7423 %</en>
7424 %<*ja>
7425 \item 水平ボックス(hbox),垂直ボックス,罫線 (\cs{vrule}),
7426   そして\textit{unset\_node}.
7427   クラスタの\textit{id}は垂直に移動していないhboxならば\textit{id\_hlist},
7428   そうでなければ\textit{id\_box\_like}となる.
7429 %</ja>
7430
7431 %<*en>
7432 \item A glue, a kern whose subtype is not 2~(\textit{accent}), and a discretionary break.
7433 The \textit{id} of the cluster is \textit{id\_glue}, \textit{id\_kern}
7434       and \textit{id\_disc}, respectively.
7435 %</en>
7436 %<*ja>
7437 \item グルー,subtypeが 2~(\textit{accent})ではないカーン,そしてdiscretionary break.
7438   その\textit{id} of the clusterはそれぞれ\textit{id\_glue}, \textit{id\_kern},そして
7439   \textit{id\_disc}である.
7440 %</ja>
7441 \end{enumerate}
7442 %<*en>
7443 We use \textit{Np}, \textit{Nq} and \textit{Nr} to denote a cluster.
7444 %</en>
7445 %<*ja>
7446 以下では\textit{Np}, \textit{Nq}, \textit{Nr}でクラスタを表す.
7447 %</ja>
7448 \end{defn}
7449
7450 \paragraph{\textit{id}の意味}
7451 $\mathit{Np}.\mathit{id}$の意味を述べるとともに,
7452 「先頭の文字」を表す\textit{glyph\_node}~$\mathit{Np}.\mathit{head}$と,
7453 「最後の文字」を表す\textit{glyph\_node}~$\mathit{Np}.\mathit{tail}$を次のように定義する.
7454 直感的に言うと,\textit{Np}は$\mathit{Np}.\mathit{head}$で始まり$\mathit{Np}.\mathit{tail}$で終わるような単語,
7455 と見做すことができる.これら$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は
7456 説明用に準備した概念であって,実際のLuaコード中にそのように書かれているわけではないことに注意.
7457
7458 \begin{description}
7459 \item[\textit{id\_jglyph}] 和文文字.\\
7460 $\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は,その和文文字を表している
7461 \textit{glyph\_node}そのものである.
7462 \item[\textit{id\_glyph}] 和文文字を表していない\textit{glyph\_node}~$p$.\\
7463 多くの場合,$p$は欧文文字を格納しているが,「ffi」などの合字によって作られた
7464 \textit{glyph\_node}である可能性もある.
7465 前者の場合,$\mathit{Np}.\mathit{head}$,~$\mathit{Np}.\mathit{tail} = p$である.
7466 一方,後者の場合,
7467 \begin{itemize}
7468 \item $\mathit{Np}.\mathit{head}$は,
7469 合字の構成要素の先頭→(その\textit{glyph\_node}における)合字の構成要素の先頭→……
7470 と再帰的に検索していってたどり着いた\textit{glyph\_node}である.
7471 \item $\mathit{Np}.\mathit{last}$は,同様に末尾→末尾→と検索してたどり着いた\textit{glyph\_node}である.
7472 \end{itemize}
7473 \item[\textit{id\_math}] インライン数式.\\
7474 便宜的に,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$ともに
7475 「文字コード$-1$の欧文文字」とおく.
7476 \item[\textit{id\_hlist}] 縦方向にシフトされていないhbox.\\
7477 この場合,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$はそれぞれ$p$の内容を表すリストの,
7478 先頭・末尾のノードである.
7479 \medskip
7480 \begin{itemize}
7481 \item 状況によっては,\TeX ソースで言うと
7482 \begin{lstlisting}
7483 \hbox{\hbox{abc}...\hbox{\lower1pt\hbox{xyz}}}
7484 \end{lstlisting}
7485 のように,$p$の内容が別のhboxで開始・終了している可能性も十分あり得る.そのような場合,
7486 $\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$の算出は,
7487 \emph{垂直方向にシフトされていない}hboxの
7488 場合だけ内部を再帰的に探索する.例えば上の例では,$\mathit{Np}.\mathit{head}$は文字「a」を表すノードであり,
7489 一方$\mathit{Np}.\mathit{tail}$は垂直方向にシフトされたhbox,
7490 \verb+\lower1pt\hbox{xyz}+ に対応するノードである.
7491 \item また,先頭にアクセント付きの文字がきたり,末尾にイタリック補正用のカーンが
7492 来ることもあり得る.この場合は,クラスタの定義のところにもあったように,それらは無視して算出を行う.
7493 \item 最初・最後のノードが合字によって作られた\textit{glyph\_node}のときは,それぞれに対して\textit{id\_glyph}%
7494 と同様に再帰的に構成要素をたどっていく.
7495 \end{itemize}
7496 \item[\textit{id\_pbox}] 「既に処理された」ノードのリストであり,これらのノードが二度処理を受けないために
7497 まとめて1つのクラスタとして取り扱うだけである.
7498 \textit{id\_hlist}と同じ方法で$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$を算出する,
7499 \item[\textit{id\_disc}] discretionary break (\verb+\discretionary{pre}{post}{nobreak}+).\\
7500 \textit{id\_hlist}と同じ方法で$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$を算出するが,
7501 第3引数の \texttt{nobreak}(行分割が行われない時の内容)を使う.言い換えれば,ここで行分割が発生した時の状況は
7502 全く考慮に入れない.
7503 \item[\textit{id\_box\_like}] \textit{id\_hlist}とならないboxや,rule.\\
7504 この場合は,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$のデータは利用されないので,2つの算出は無意味である.
7505 敢えて明示するならば,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$は共にnil値である.
7506 \item[他] 以上にない\textit{id}に対しても,$\mathit{Np}.\mathit{head}$, $\mathit{Np}.\mathit{tail}$の算出は無意味.
7507 \end{description}
7508
7509 \paragraph{クラスタの別の分類}
7510 さらに,JFMグルー挿入処理の実際の説明により便利なように,\textit{id}とは別のクラスタの分類を行っておく.
7511 挿入処理では2つの隣り合ったクラスタの間に
7512 空白等の実際の挿入を行うことは前に書いたが,ここでの説明では,問題にしているクラスタ\textit{Np}は「後ろ側」のクラスタである
7513 とする.「前側」のクラスタについては,以下の説明で\textit{head}が\textit{last}に置き換わることに注意すること.
7514 \begin{description}
7515 \item[和文A] リスト中に直接出現している和文文字.
7516 \textit{id}が\textit{id\_jglyph}であるか,\\
7517 \textit{id}が\textit{id\_pbox}であって$\mathit{Np}.\mathit{head}$が\textbf{JAchar}であるとき.
7518
7519 \item[和文B] リスト中のhboxの中身の先頭として出現した和文文字.和文Aとの違いは,これの前に
7520 JFMグルーの挿入が行われない(\Param{xkanjiskip},~\Param{kanjiskip}は入り得る)ことである.\\
7521 \textit{id}が\textit{id\_hlist}か\textit{id\_disc}であって$\mathit{Np}.\mathit{head}$が\textbf{JAchar}であるとき.
7522
7523 \item[欧文] リスト中に直接/hboxの中身として出現している欧文文字.次の3つの場合が該当:
7524 \begin{itemize}
7525 \item \textit{id}が\textit{id\_glyph}である.
7526 \item \textit{id}が\textit{id\_math}である.
7527 \item \textit{id}が\textit{id\_pbox}か\textit{id\_hlist}か\textit{id\_disc}であって,$\mathit{Np}.\mathit{head}$が\textbf{ALchar}.
7528 \end{itemize}
7529 \item[箱] box,またはそれに類似するもの.次の2つが該当:
7530 \begin{itemize}
7531 \item \textit{id}が\textit{id\_pbox}か\textit{id\_hlist}か\textit{id\_disc}であって,$\mathit{Np}.\mathit{head}$が\textit{glyph\_node}でない.
7532 \item \textit{id}が\textit{id\_box\_like}である.
7533 \end{itemize}
7534
7535 \end{description}
7536
7537 \subsection{段落/hboxの先頭や末尾}
7538 \paragraph{先頭部の処理}
7539 まず,段落/hboxの一番最初にあるクラスタ\textit{Np}を探索する.
7540 hboxの場合は何の問題もないが,段落の場合では以下のノード達を事前に読み飛ばしておく:
7541 \begin{itemize}
7542 \item \cs{parindent} 由来のhbox($\mathit{subtype}=3$)
7543 \item \textit{subtype}が44~(\textit{user\_defined})でないようなwhatsit
7544 \end{itemize}
7545 これは,\cs{parindent}由来のhboxがクラスタを構成しないようにするためである.
7546
7547 次に,\textit{Np}の直前に空白$g$を必要なら挿入する:
7548 \begin{enumerate}
7549 \item この処理が働くような\textit{Np}は\textsf{和文A}である.
7550 \item 問題のリストが字下げありの段落(\cs{parindent} 由来のhboxあり)の場合は,
7551 この空白$g$は「文字コード \texttt{'parbdd'} の文字」と\textit{Np}の間に入るグルー/カーンである.
7552 \item そうでないとき(\verb+noindent+ で開始された段落やhbox)は,
7553 $g$は「文字コード \texttt{'boxbdd'} の文字」と\textit{Np}の間に入るグルー/カーンである.
7554 \end{enumerate}
7555 ただし,もし$g$がglueであった場合,この挿入によって\textit{Np}による行分割が新たに可能になるべきではない.
7556 そこで,以下の場合には,$g$の直前に \cs{penalty10000} を挿入する:
7557 \begin{itemize}
7558 \item 問題にしているリストが段落であり,かつ
7559 \item \textit{Np}の前には予めペナルティがなく,$g$はglue.
7560 \end{itemize}
7561
7562 \paragraph{末尾の処理}
7563 末尾の処理は,問題のリストが段落のものかhboxのものかによって異なる.
7564 後者の場合は容易い:最後のクラスタを\textit{Nq}とおくと,\textit{Nq}と「文字コード\
7565 \texttt{'boxbdd'} の文字」の間に入るグルー/カーンを,
7566 \textit{Nq}の直後に挿入するのみである.
7567
7568 一方.前者(段落)の場合は,リストの末尾は常に \cs{penalty10000} と,
7569 \cs{parfillskip} 由来のグルーが存在する.%よって,最後のクラスタ\textit{Np}は
7570 %この \cs{parfillskip} 由来のグルーとなり,実質的な中身の最後はその1つ前のクラスタ\textit{Nq}となる.
7571 段落の最後の「通常の和文文字${}+{}$句点」が独立した行となるのを防ぐために,
7572 \Param{jcharwidowpenalty}の値の分だけ適切な場所のペナルティを増やす.
7573
7574 ペナルティ量を増やす場所は,\textit{head}が\textbf{JAchar}であり,
7575 かつその文字の\Param{kcatcode}が偶数であるような
7576 最後のクラスタの直前にあるものたちである%
7577 \footnote{大雑把に言えば,\Param{kcatcode}が奇数であるような\textbf{JAchar}%
7578 を約物として考えていることになる.
7579 \Param{kcatcode}の最下位ビットはこの\Param{jcharwidowpenalty}用にのみ利用される.}.
7580
7581 \subsection{概観と典型例:2つの「和文A」の場合}
7582 \label{ssec-cluster-wa}
7583 先に述べたように,2つの隣り合ったクラスタ,\textit{Nq}と\textit{Np}の間には,
7584 ペナルティ,\cs{vadjust},whatsitなど,行組版には関係しないものがある.模式的に表すと,
7585 \[
7586  \Node{cluster}{\textit{Nq}}\longrightarrow
7587 \overbrace{
7588 \Node{penalty}{$p$}\longrightarrow \cdots\longrightarrow \Node{whatsit}{}}^{\textrm{(a)}}
7589 \longrightarrow \Node{cluster}{\textit{Np}}
7590 \]
7591 のようになっている.間の(a)に相当する部分には,何のノードもない場合ももちろんあり得る.
7592 そうして,JFMグルー挿入後には,この2クラスタ間は次のようになる:
7593 \[
7594  \Node{cluster}{\textit{Nq}}\longrightarrow%\Node{kern}{左空白}\longrightarrow
7595 \overbrace{
7596 \Node{penalty}{$p+x$}\longrightarrow \cdots\longrightarrow
7597 \Node{whatsit}{}}^{\textrm{(a)}}\longrightarrow
7598 \Node{glue or kern}{\raisebox{-.2\zw}{右空白}}\longrightarrow
7599 \Node{cluster}{\textit{Np}}
7600 \]
7601
7602 以後,\emph{典型的な例として,クラスタ\textit{Nq}と\textit{Np}が共に\textsf{\textmd{和文A}}である場合を見ていこう,}
7603 この場合が全ての場合の基本となる.
7604
7605 \paragraph{「右空白」の算出}
7606 まず,「右空白」にあたる量を算出する.通常はこれが,隣り合った2つの和文文字間に入る空白量となる.
7607 \begin{description}
7608 \item[JFM由来{[M]}] JFMの文字クラス指定によって入る空白を以下によって求める.この段階で空白量が未定義(未指定)だった場合,
7609       デフォルト値\Param{kanjiskip}を採用することとなるので,次へ.
7610 \begin{enumerate}
7611 \item もし両クラスタの間で \cs{inhibitglue} が実行されていた場合(証としてwhatsitノードが自動挿入される),
7612       代わりに\Param{kanjiskip}が挿入されることとなる.次へ.
7613 \item \textit{Nq}と\textit{Np}が同じJFM・同じ\texttt{jfmvar}キー・同じサイズの和文フォントであったならば,
7614       共通に使っているJFM内で挿入される空白(グルーかカーン)が決まっているか調べ,決まっていればそれを採用.
7615 \item 1.でも2.でもない場合は,JFM・\texttt{jfmvar}・サイズの3つ組は\textit{Nq}と\textit{Np}で異なる.
7616 この場合,まず
7617 \[
7618 \vcenter{\halign{\hfil$#:={}$&\inhibitglue#\inhibitglue\cr
7619 gb&(\textit{Nq}と「使用フォントが\textit{Nq}のそれと同じで,\hfil\cr
7620 \omit&\quad 文字コードが\textit{Np}のそれの文字」との間に入るグルー/カーン)\hfil\cr
7621 ga&(\inhibitglue 「使用フォントが\textit{Np}のそれと同じで,\hfil\cr
7622 \omit&\quad 文字コードが\textit{Nq}のそれの文字」と\textit{Np}との間に入るグルー/カーン)\hfil\cr
7623 }}
7624 \]
7625 として,前側の文字のJFMを使った時の空白(グルー/カーン)と,後側の文字のJFMを使った時のそれを求める.
7626
7627 $\mathit{gb}$,~$\mathit{ga}$それぞれに対する<ratio>の値を$d_b$,~$d_a$とする.
7628 \begin{itemize}
7629 \item
7630 $\mathit{ga}$と$\mathit{gb}$の両方が未定義であるならば,JFM由来のグルーは挿入されず,
7631 \Param{kanjiskip}を採用することとなる.
7632 どちらか片方のみが未定義であるならば,次のステップでその未定義の方は長さ0のkernで,<ratio>の値は0であるかのように扱われる.
7633 \item
7634 \Param{diffrentjfm}の値が \texttt{pleft}, \texttt{pright},
7635       \texttt{paverage} のとき,
7636 <ratio>の指定に従って比例配分を行う.
7637 JFM由来のグルー/カーンは以下の値となる:
7638 \[
7639  f\left(\frac{1-d_b}2\textit{gb} + \frac{1+d_b}2\textit{ga},
7640 \frac{1-d_a}2\textit{gb} + \frac{1+d_a}2\textit{ga}\right)
7641 \]
7642 ここで.$f(x,y)$は
7643 \[
7644  f(x,y)=\begin{cases}
7645 x&\text{if\ }\Param{diffrentjfm}=\texttt{pleft};\\
7646 y&\text{if\ }\Param{diffrentjfm}=\texttt{pright};\\
7647 (x+y)/2&\text{if\ }\Param{diffrentjfm}=\texttt{paverage};
7648 \end{cases}.
7649 \]
7650 \item
7651 \Param{differentjfm}がそれ以外の値の時は,<ratio>の値は無視され,JFM由来のグルー/カーンは以下の値となる:
7652 \[
7653  f(\textit{gb},\textit{ga})
7654 \]
7655 ここで.$f(x,y)$は
7656 \[
7657  f(x,y)=\begin{cases}
7658 \min(x,y)&\text{if\ }\Param{diffrentjfm}=\texttt{small};\\
7659 \max(x,y)&\text{if\ }\Param{diffrentjfm}=\texttt{large};\\
7660 (x+y)/2&\text{if\ }\Param{diffrentjfm}=\texttt{average};\\
7661 x+y&\text{if\ }\Param{diffrentjfm}=\texttt{both};
7662 \end{cases}.
7663 \]
7664 \end{itemize}
7665 \end{enumerate}
7666
7667 例えば,
7668 \begin{lstlisting}
7669 \jfont\foo=psft:Ryumin-Light:jfm=ujis;-kern
7670 \jfont\bar=psft:GothicBBB-Medium:jfm=ujis;-kern
7671 \jfont\baz=psft:GothicBBB-Medium:jfm=ujis;jfmvar=piyo;-kern
7672 \end{lstlisting}
7673 という3フォントを考え,
7674 \[
7675  \overbrace{\Node{glyph}{\cs{ foo}, `あ'}}^{p}
7676 \longrightarrow \overbrace{\Node{glyph}{\cs{bar}, `い'}}^{q}
7677 \longrightarrow \overbrace{\Node{glyph}{\cs{baz}, `う'}}^{r}
7678 \]
7679 という3ノードを考える(それぞれ単独でクラスタをなす).
7680 この場合,$p$と$q$の間は,実フォントが異なるにもかかわらず2.の状況となる一方で,
7681 $q$と$r$の間は(実フォントが同じなのに)\texttt{jfmvar} キーの内容が異なるので3.の状況となる.
7682 \item[\Param{kanjiskip}~{[K]}] 上の[M]において空白が定まらなかった場合,
7683 以下で定めた量「右空白」として採用する.
7684 この段階においては,\cs{inhibitglue} は効力を持たないため,
7685 結果として,2つの和文文字間には常に何らかのグルー/カーンが挿入されることとなる.
7686 \begin{enumerate}
7687 \item 両クラスタ(厳密には$\mathit{Nq}.\mathit{tail}$,$\mathit{Np}.\mathit{head}$)の中身の文字コードに対する
7688 \Param{autospacing}パラメタが両方ともfalseだった場合は,長さ0のglueとする.
7689 \item ユーザ側から見た\Param{kanjiskip}パラメタの自然長が$\cs{maxdimen}=(2^{30}-1)\,{\rm sp}$で
7690 なければ,\Param{kanjiskip}パラメタの値を持つglueを採用する.
7691 \item 2.でない場合は,\textit{Nq}, \textit{Np}で使われているJFMに指定されている\Param{kanjiskip}の値を用いる.
7692 どちらか片方のクラスタだけが和文文字(\textsf{和文A}・\textsf{和文B})のときは,そちらのクラスタで使われている
7693 JFM由来の値だけを用いる.もし両者で使われているJFMが異なった場合は,上の[M]~3.と同様の方法を用いて調整する.
7694 \end{enumerate}
7695 \end{description}
7696 %\paragraph{「左空白」の算出とそれに伴う補正}
7697 %「左空白」は過去のバージョンでは定義していたが,このバージョンでは
7698 %挿入は一切行われない(機能自体削除している).
7699 %しかし,仕様は流動的であり,将来復活する可能性もあるため,マニュアル中の記述は今のところ極力変更しない.
7700 \paragraph{禁則用ペナルティの挿入}
7701 まず,
7702 \[
7703  a:=(\text{\textit{Nq}{\footnotemark}の文字に対する\Param{postbreakpenalty}の値})
7704 +(\text{\textit{Np}{\footnotemark}の文字に対する\Param{prebreakpenalty}の値})
7705 \]
7706 とおく\footnotetext{厳密にはそれぞれ$\mathit{Nq}.\mathit{tail}$,$\mathit{Np}.\mathit{head}$.}.
7707 ペナルティは通常$[-10000,10000]$の整数値をとり,また$\pm 10000$は正負の無限大を意味することになっているが,この$a$の
7708 算出では単純な整数の加減算を行う.
7709
7710 $a$は禁則処理用に\textit{Nq}と\textit{Np}の間に加えられるべきペナルティ量である.
7711 \begin{description}
7712 \item[P-normal~{[PN]}]
7713 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティ(\textit{penalty\_node})があれば処理は簡単である:
7714 それらの各ノードにおいて,ペナルティ値を($\pm 10000$を無限大として扱いつつ)$a$だけ増加させればよい.
7715 また,$10000 + (-10000) = 0$としている.
7716
7717 少々困るのは,(a)部分にペナルティが存在していない場合である.
7718 直感的に,補正すべき量$a$が0でないとき,その値をもつ\textit{penalty\_node}を作って
7719 「右空白」の(もし未定義なら\textit{Np}の)直前に挿入……
7720 ということになるが,実際には僅かにこれより複雑である.
7721 \begin{itemize}
7722 \item 「右空白」がカーンであるとき,
7723 それは「\textit{Nq}と\textit{Np}の間で改行は許されない」ことを意図している.そのため,
7724 この場合は$a\neq 0$であってもペナルティの挿入はしない.
7725 \item そうでないないときは,$a\neq 0$ならば\textit{penalty\_node}を作って挿入する.
7726 %\item 「左空白」がカーンとしてきっちり定義されている時(このとき,「右空白」はカーンでない),
7727 %この「左空白」の直後での行分割を許容しないといけないので,$a=0$であっても
7728 %\textit{penalty\_node}を作って挿入する.
7729 %\item 以上のどれでもないときは,$a\neq 0$ならば\textit{penalty\_node}を作って挿入する.
7730 \end{itemize}
7731 \end{description}
7732
7733 \def\gkf#1#2#3{\sf$\displaystyle\vphantom{\Bigg(}%
7734   \frac{\hbox to 4\zw{\hss#2\hss}}{\hbox{#3}}$}
7735 \begin{table}[t]
7736 %<en>\caption{Summary of JFM glues}
7737 %<ja>\caption{JFM グルーの概要}
7738 \label{tab-jfmglue}
7739 %<en>\medskip
7740 \begin{center}
7741 \small
7742 \begin{tabular}{c|cccccc}
7743 \toprule
7744 {\bf\textit{Np}}↓&\sf 和文A&\sf 和文B&\sf 欧文&\sf 箱&\sf glue&\sf kern\\\midrule
7745 \sf 和文A&
7746 \gkf{E}{M→K}{PN}&
7747 \gkf{---}{\OA →K}{PN}&
7748 \gkf{---}{\OA →X}{PN}&
7749 \gkf{---}{\OA}{PA}&
7750 \gkf{---}{\OA}{PN}&
7751 \gkf{---}{\OA}{PS}\\
7752 \sf 和文B&
7753 \gkf{E}{\OB→K}{PA}&
7754 \gkf{---}{K}{PS}&
7755 \gkf{---}{X}{PS}\\
7756 \sf 欧文&
7757 \gkf{E}{\OB →X}{PA}&
7758 \gkf{---}{X}{PS}\cr
7759 \sf 箱&\gkf{E}{\OB}{PA}\\
7760 \sf glue&\gkf{E}{\OB}{PN}\\
7761 \sf kern&\gkf{E}{\OB}{PS}\\
7762 \bottomrule
7763 \end{tabular}
7764 \end{center}
7765 \begin{quote}
7766 %<*en>
7767 In the table above, {\small\gkf{E}{M→K}{PN}} means that
7768 %</en>
7769 %<*ja>
7770 上の表において,{\small\gkf{E}{M→K}{PN}}は次の意味である:
7771 %</ja>
7772 \begin{enumerate}
7773 %<*en>
7774 \item To determine the ``right-space'', \LuaTeX-ja first attempts by the method ``\textsf{JFM-origin~[M]}''.
7775 If this attempt fails, \LuaTeX-ja use the method ``\textsf{\Param{kanjiskip}~[K]}''.
7776 %</en>
7777 %<*ja>
7778 \item 「右空白」を決めるために,\LuaTeX-ja はまず「JFM由来{[M]}」の方法を試みる.
7779   これが失敗したら,\LuaTeX-ja は「\Param{kanjiskip}~{[K]}」の方法を試みる.
7780 %</ja>
7781
7782 % %<*en>
7783 % \item The ``left space'' between \textit{Nq}~and~\textit{Np} is
7784 %   determined by the method ``\textsf{line-end~[E]}''.
7785 % %</en>
7786 % %<*ja>
7787 % \item \textit{Nq} と \textit{Np} の間の「左空白」は「\textsf{line-end~[E]}」の
7788 %   方法で決定される.
7789 % %</ja>
7790
7791 %<*en>
7792 \item \LuaTeX-ja adopts the method ``\textsf{P-normal~[PN]}'' to adjust the penalty
7793   between two clusters for \emph{kinsoku shori}.
7794 %</en>
7795 %<*ja>
7796 \item \LuaTeX-jaは2つのクラスタの間の禁則処理用のペナルティを設定するために「\textsf{P-normal~[PN]}」の方法を採用する.
7797 %</ja>
7798 \end{enumerate}
7799 \end{quote}
7800 \end{table}
7801
7802 \subsection{その他の場合}
7803 本節の内容は表\ref{tab-jfmglue}にまとめてある.
7804
7805 \paragraph{和文Aと欧文の間}
7806 \textit{Nq}が\textsf{和文A}で,\textit{Np}が\textsf{欧文}の場合,JFMグルー挿入処理は次のようにして行われる.
7807 \begin{itemize}
7808 \item 「右空白」については,まず以下に述べる\textsf{Boundary-B~[\OB]}により空白を決定しようと試みる.
7809 それが失敗した場合は,\textsf{\Param{xkanjiskip}~[X]}によって定める.
7810 %\item 「左空白」については,既に述べた\textsf{line-end~[E]}をそのまま採用する.それに伴う「右空白」の補正も%同じ.
7811 \item 禁則用ペナルティも,以前述べた\textsf{P-normal~[PN]}と同じである.
7812 \end{itemize}
7813 \begin{description}
7814 \item[Boundary-B~{[\OB]}] 和文文字と「和文でないもの」との間に入る空白を以下によって求め,
7815 未定義でなければそれを「右空白」として採用する.
7816 \textsf{JFM-origin~[M]}の変種と考えて良い.
7817 これによって定まる空白の典型例は,和文の閉じ括弧と欧文文字の間に入る半角アキである.
7818 \begin{enumerate}
7819 \item もし両クラスタの間で \cs{inhibitglue} が実行されていた場合%
7820 (証としてwhatsitノードが自動挿入される),「右空白」は未定義.
7821 \item そうでなければ,
7822 \textit{Nq}と「文字コードが {\tt'jcharbdd'} の文字」との間に入るグルー/カーンとして定まる.
7823 \end{enumerate}
7824 \item[\Param{xkanjiskip}~{[X]}]
7825 この段階では,\textsf{\Param{kanjiskip}~[K]}のときと同じように,
7826 以下で定めた量を「右空白」として採用する.
7827 \cs{inhibitglue} は効力を持たない.
7828 \begin{enumerate}
7829 \item 以下のいずれかの場合は,\Param{xkanjiskip}の挿入は抑止される.しかし,実際には行分割を許容するために,長さ0のglueを採用する:
7830 \begin{itemize}
7831 \item 両クラスタにおいて,それらの中身の文字コードに対する\Param{autoxspacing}パラメタが共にfalseである.
7832 \item \textit{Nq}の中身の文字コードについて,「直後への\Param{xkanjiskip}の挿入」が禁止されている
7833 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメタが2以上).
7834 \item \textit{Np}の中身の文字コードについて,「直前への\Param{xkanjiskip}の挿入」が禁止されている
7835 (つまり,\Param{jaxspmode}~(or \Param{alxspmode})パラメタが偶数).
7836 \end{itemize}
7837 \item ユーザ側から見た\Param{xkanjiskip}パラメタの自然長が$\cs{maxdimen}=(2^{30}-1)\,{\rm sp}$で
7838 なければ,\Param{xkanjiskip}パラメタの値を持つglueを採用する.
7839 \item 2.でない場合は,\textit{Nq}, \textit{Np}(\textsf{和文A}/\textsf{和文B}なのは片方だけ)
7840 で使われているJFMに指定されている\Param{xkanjiskip}の値を用いる.
7841 \end{enumerate}
7842 \end{description}
7843
7844 \paragraph{欧文と和文Aの間}
7845 \textit{Nq}が\textsf{欧文}で,\textit{Np}が\textsf{和文A}の場合,JFMグルー挿入処理は上の場合とほぼ同じである.
7846 \textsf{和文A}のクラスタが逆になるので,\textsf{Boundary-A~[\OA]}の部分が変わるだけ.
7847 \begin{itemize}
7848 \item 「右空白」については,まず以下に述べる\textsf{Boundary-A~[\OA]}により空白を決定しようと試みる.
7849 それが失敗した場合は,\textsf{\Param{xkanjiskip}~[X]}によって定める.
7850 %\item \textit{Nq}が和文でないので,「左空白」は算出されない.
7851 \item 禁則用ペナルティは,以前述べた\textsf{P-normal~[PN]}と同じである.
7852 \end{itemize}
7853 \begin{description}
7854 \item[Boundary-A~{[\OA]}] 「和文でないもの」と和文文字との間に入る空白を以下によって求め,
7855 未定義でなければそれを「右空白」として採用する.
7856 \textsf{JFM-origin~[M]}の変種と考えて良い.
7857 これによって定まる空白の典型例は,欧文文字と和文の開き括弧との間に入る半角アキである.
7858 \begin{enumerate}
7859 \item もし両クラスタの間で \cs{inhibitglue} が実行されていた場合(証としてwhatsitノードが自動挿入される),次へ.
7860 \item そうでなければ,
7861 「文字コードが {\tt'jcharbdd'} の文字」と\textit{Np}との間に入るグルー/カーンとして定まる.
7862 \end{enumerate}
7863 \end{description}
7864
7865 \paragraph{和文Aと箱・グルー・カーンの間}
7866 \textit{Nq}が\textsf{和文A}で,\textit{Np}が\textsf{箱}・グルー・カーンのいずれかであった場合,
7867 両者の間に挿入されるJFMグルーについては同じ処理である.しかし,そこでの行分割に対する仕様が異なるので,
7868 ペナルティの挿入処理は若干異なったものとなっている.
7869
7870 \begin{itemize}
7871 \item 「右空白」については,既に述べた\textsf{Boundary-B~[\OB]}により空白を決定しようと試みる.
7872 それが失敗した場合は,「右空白」は挿入されない.
7873 %\item 「左空白」については,既に述べた\textsf{line-end~[E]}の算出方法をそのまま採用する.それに伴う「右空白」の補正も同じ.
7874 \item 禁則用ペナルティの処理は,後ろのクラスタ\textit{Np}の種類によって異なる.
7875 なお,$\mathit{Np}.\mathit{head}$は無意味であるから,
7876 「$\mathit{Np}.\mathit{head}$に対する\Param{prebreakpenalty}の値」は0とみなされる.言い換えれば,
7877 \[
7878  a:=(\text{\textit{Nq}の文字に対する\Param{postbreakpenalty}の値}).
7879 \]
7880 \begin{description}
7881 \item[箱] \textit{Np}が\textsf{箱}であった場合は,両クラスタの間での行分割は
7882 (明示的に両クラスタの間に \cs{penalty10000} があった場合を除き)いつも許容される.そのため,
7883 ペナルティ処理は,後に述べる\textsf{P-allow~[PA]}が\textsf{P-normal~[PN]}の代わりに用いられる.
7884 \item[グルー] \textit{Np}がグルーの場合,ペナルティ処理は\textsf{P-normal~[PN]}を用いる.
7885 \item[カーン] \textit{Np}がカーンであった場合は,両クラスタの間での行分割は
7886 (明示的に両クラスタの間にペナルティがあった場合を除き)許容されない.
7887 ペナルティ処理は,後に述べる\textsf{P-suppress~[PS]}を使う.
7888 \end{description}
7889 これらの\textsf{P-normal~[PN]},\textsf{P-allow~[PA]},\textsf{P-suppress~[PS]}の違いは,
7890 \textit{Nq}と\textit{Np}の間(以前の図だと(a)の部分)にペナルティが存在しない場合にのみ存在する.
7891 \end{itemize}
7892
7893 \begin{description}
7894 \item[P-allow~{[PA]}]
7895 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティがあれば,\textsf{P-normal~[PN]}と同様に,
7896 それらの各ノードにおいてペナルティ値を$a$だけ増加させる.
7897
7898 (a)部分にペナルティが存在していない場合,
7899 \LuaTeX-ja は\textit{Nq}と\textit{Np}の間の行分割を可能にしようとする.
7900 そのために,以下のいずれかの場合に$a$をもつ\textit{penalty\_node}を作って
7901 「右空白」の(もし未定義なら\textit{Np}の)直前に挿入する:
7902 \begin{itemize}
7903 \item 「右空白」がグルーでない(カーンか未定義)であるとき.
7904 \item $a\neq 0$のときは,「右空白」がグルーであっても\textit{penalty\_node}を作る.
7905 \end{itemize}
7906
7907 \item[P-suppress~{[PS]}]
7908 \textit{Nq}と\textit{Np}の間の(a)部分にペナルティがあれば,\textsf{P-normal~[PN]}と同様に,
7909 それらの各ノードにおいてペナルティ値を$a$だけ増加させる.
7910
7911 (a)部分にペナルティが存在していない場合,
7912 \textit{Nq}と\textit{Np}の間の行分割は元々不可能のはずだったのであるが,
7913 \LuaTeX-ja はそれをわざわざ行分割可能にはしない.
7914 そのため,「右空白」がglueであれば,その直前に \cs{penalty10000} を挿入する.
7915 \end{description}
7916
7917 \paragraph{箱・グルー・カーンと和文Aの間}
7918 \textit{Np}が\textsf{箱}・グルー・カーンのいずれかで,\textit{Np}が\textsf{和文A}であった場合は,
7919 すぐ上の(\textit{Nq}と\textit{Np}の順序が逆になっている)場合と同じである.
7920 %が,「左空白」がなくなることにのみ注意.
7921 \begin{itemize}
7922 \item 「右空白」については,既に述べた\textsf{Boundary-A~[\OA]}により空白を決定しようと試みる.
7923 それが失敗した場合は,「右空白」は挿入されない.
7924 %\item \textit{Nq}が和文でないので,「左空白」は算出されない.
7925 \item 禁則用ペナルティの処理は,\textit{Nq}の種類によって異なる.
7926 $\mathit{Nq}.\mathit{tail}$は無意味なので,
7927 \[
7928  a:=(\text{\textit{Np}の文字に対する\Param{prebreakpenalty}の値}).
7929 \]
7930 \begin{description}
7931 \item[箱] \textit{Nq}が\textsf{箱}の場合は,\textsf{P-allow~[PA]}を用いる.
7932 \item[グルー] \textit{Nq}がグルーの場合は,\textsf{P-normal~[PN]}を用いる.
7933 \item[カーン] \textit{Nq}がカーンの場合は,\textsf{P-suppress~[PS]}を用いる.
7934 \end{description}
7935 \end{itemize}
7936
7937 \paragraph{和文Aと和文Bの違い}
7938 先に述べたように,\textsf{和文B}はhboxの中身の先頭(or 末尾)として出現している
7939 和文文字である.リスト内に直接ノードとして現れている和文文字(\textsf{和文A})との違いは,
7940 \begin{itemize}
7941 \item \textsf{和文B}に対しては,JFMの文字クラス指定から定まる空白
7942 \textsf{JFM-origin~[M]},\textsf{Boundary-A~[\OA]},\textsf{Boundary-B~[\OB]})の挿入は行われない.
7943 %「左空白」の算出も行われない.
7944 例えば,
7945 \begin{itemize}
7946 \item 片方が\textsf{和文A},もう片方が\textsf{和文B}のクラスタの場合,
7947 \textsf{Boundary-A~[\OA]}または\textsf{Boundary-B~[\OB]}の挿入を試み,それがダメなら
7948 \Param{kanjiskip}~\textsf{[K]}の挿入を行う.
7949 \item \textsf{和文B}の2つのクラスタの間には,\Param{kanjiskip}~\textsf{[K]}が自動的に入る.
7950 \end{itemize}
7951 \item \textsf{和文B}と箱・グルー・カーンが隣接したとき(どちらが前かは関係ない),間にJFMグルー・ペナルティの挿入は一切しない.
7952 \item \textsf{和文B}と\textsf{和文B},また\textsf{和文B}と\textsf{欧文}とが隣接した時は,禁則用ペナルティ挿入処理は
7953 \textsf{P-suppress~[PS]}が用いられる.
7954 \item \textsf{和文B}の文字に対する\Param{prebreakpenalty},~\Param{postbreakpenalty}の値は使われず,0として計算される.
7955 \end{itemize}
7956
7957
7958 次が具体例である:
7959 \begin{LTXexample}
7960 あ.\inhibitglue A\\
7961 \hbox{あ.}A\\
7962 あ.A
7963 \end{LTXexample}
7964 \begin{itemize}
7965 \item 1行目の\cs{inhibitglue}は\textsf{Boundary-B~[\OB]}の処理のみを抑止するので,ピリオドと「A」の間には
7966 \Param{xkanjiskip}(四分アキ)が入ることに注意.
7967 \item 2行目のピリオドと「A」の間においては,前者が\textsf{和文B}となる(hboxの中身の末尾として登場しているから)ので,
7968 そもそも\textsf{Boundary-B~[\OB]}の処理は行われない.よって,\Param{xkanjiskip}が入ることとなる.
7969 \item 3行目では,ピリオドの属するクラスタは\textsf{和文A}である.これによって,
7970 ピリオドと「A」の間には\textsf{Boundary-B~[\OB]}由来の半角アキが入ることになる.
7971 \end{itemize}
7972 %</ja>
7973
7974 %<*ja>
7975 \section{ベースライン補正の方法}
7976 \subsection{\texttt{yoffset} フィールド}
7977 \Param{yalbaselineshift}等のベースライン補正は,基本的には対象となっている
7978 \textit{glyph\_node}の \texttt{yoffset} フィールドの値を増減することによって
7979 実装されている.なお,\texttt{yoffset} の値は上方向への移動量であるのに対し,
7980 \Param{yalbaselineshift}などは下方向への移動量である.
7981
7982 さて,\texttt{yoffset} の増減によって見かけのグリフ位置は上下に移動するが,
7983 仮想ボディの高さ$h$,深さ$d$については
7984 \begin{description}
7985 \catcode`\<=12\catcode`\>=12
7986  \item[$\texttt{yoffset}\geq 0$のとき] 
7987 $h = \max(\texttt{height} + \texttt{yoffset}, 0)$, 
7988 $d = \max(\texttt{depth} - \texttt{yoffset}, 0)$, 
7989  \item[$\texttt{yoffset}<0$のとき] 
7990 $h = \max(\texttt{height} + \texttt{yoffset}, 0)$, $d=\texttt{depth}$.
7991 \end{description}
7992 という仕様になっている.つまり,\texttt{yoffset} が負(グリフを下ける)の場合に深さは増加しな
7993 い(表\ref{tab:yoffset_and_im}参照).
7994
7995 \begin{table}[t]
7996 \caption{\texttt{yoffset} and imaginary body}
7997 \label{tab:yoffset_and_im}
7998 \centering\small
7999 \fboxsep0pt
8000 \def\T#1#2{\fcolorbox{blue}{white}{%
8001   \setbox0=\hbox{\LARGE #1%
8002     \directlua{
8003       local p = tex.nest[tex.nest.ptr].tail
8004       p.yoffset = #2 * 65536
8005     }%
8006   }%
8007   \copy0\kern-\wd0\smash{\color{red}\vrule width \wd0 height 0.2pt depth 0.2pt}%
8008 }}
8009 \begin{tabular}{>{\bfseries}lccccc}
8010 \toprule
8011 \texttt{yoffset}&10\,pt&5\,pt&0&$-5$\,pt&$-10$\,pt\\
8012 \midrule
8013 仮想ボディ&\T{y}{10}, \T{H}{10}&\T{y}{5}, \T{H}{5}&\T{y}{0}, \T{H}{0}%
8014 &\T{y}{-5}, \T{H}{-5}&\T{y}{-10}, \T{H}{-10}\\[10pt]
8015 \bottomrule
8016 \end{tabular}
8017 \end{table}
8018
8019 \subsection{\textbf{ALchar}の補正}
8020 上記の問題について,\textbf{ALchar}のベースライン補正では
8021 「正しい深さ」を持った罫線(rule)を補うという対応策をとった.
8022 この罫線による補正は,\textit{id}が\textit{id\_glyph}であるクラスタ単位,
8023 大雑把に言えば音節単位で行われる.
8024 文字列``Typeset''を
8025 \begin{itemize}
8026  \item フォントはLatin Modern Roman (\texttt{lmroman10-regular.otf}) 10\,pt
8027  \item \Param{yalbaselineshift}は5\,pt
8028 \end{itemize}
8029 という状況で組んだ場合を例にとって説明しよう.
8030
8031 \LuaTeX・\Pkg{luaotfload}によるカーニング・ハイフネーションが終わった段階では,
8032
8033
8034
8035 %</ja>
8036
8037 %<en>\section{Patch for the \Pkg{listings} Package}
8038 %<ja>\section{\Pkg{listings} パッケージへの対応}
8039
8040 %<*en>
8041 It is well-known that the \Pkg{listings} package outputs weird results
8042 for Japanese input.
8043 The \Pkg{listings} package makes most of letters active and assigns
8044 output command for each letter~(\cite{listings}).
8045 But Japanese characters are not included in these activated letters.
8046 For \pTeX{} series, there is no method to make Japanese characters active;
8047 a patch \Pkg{jlisting.sty}~(\cite{jlisting}) resolves the problem forcibly.
8048 %</en>
8049 %<*ja>
8050 \Pkg{listings} パッケージが,そのままでは日本語をまともに出力できないこと
8051 はよく知られている.きちんと整形して出力するために,\Pkg{listings}パッケー
8052 ジは内部で「ほとんどの文字」をアクティブにし,各文字に対してその文字の出
8053 力命令を割り当てている(\cite{listings}).
8054 しかし,そこでアクティブにする文字の中に,和文文
8055 字がないためである.\pTeX 系列では,和文文字をアクティブにする手法がなく,
8056 \Pkg{jlisting.sty} というパッチ(\cite{jlisting})を用いることで無理やり解決していた.
8057 %</ja>
8058
8059 %<*en>
8060 In \LuaTeX-ja, the problem is resolved by using the \verb+process_input_buffer+ callback.
8061 The callback function inserts the output command (active character \texttt{U+FFFFF})
8062 before each letter above \texttt{U+0080}.
8063 This method can omits the process to make all Japanese characters active
8064 (most of the activated characters are not used in many cases).
8065 %</en>
8066 %<*ja>
8067 \LuaTeX-jaでは,\verb+process_input_buffer+ コールバックを利用することで,
8068 「各行に出現する\texttt{U+0080}以降の文字に対して,それらの出力命令を前置する」
8069 という方法をとっている.出力命令としては,アクティブ文字化した \texttt{U+FFFFF} を用いている.
8070 これにより,(入力には使用されていないかもしれない)和文文字をもすべてアクティブ化する手間もなく,
8071 見通しが良い実装になっている.
8072 %</ja>
8073
8074
8075 %<*en>
8076 If the \Pkg{listings} package  and \LuaTeX-ja were loaded,
8077 then the patch \Pkg{lltjp-listings} is loaded automatically at \verb+\begin{document}+.
8078 %</en>
8079 %<*ja>
8080 \LuaTeX-ja で利用される \Pkg{listings} パッケージへのパッチ \Pkg{lltjp-listings} は,
8081 \Pkg{listings} と\LuaTeX-jaを読み込んでおけば,
8082 \verb+\begin{document}+ の箇所において自動的に読み込まれるので,通常はあまり
8083 意識する必要はない.
8084 %</ja>
8085
8086 %<en>\subsection{Notes}
8087 %<ja>\subsection{注意}
8088 %<*en>
8089 \paragraph{Escaping to \LaTeX}
8090 We used the \verb+process_input_buffer+ callback to output \textbf{JAchar}s.
8091 But it has a drawback; any commands whose name contains a \textbf{JAchar}
8092 cannot be used in any ``escape to \LaTeX''.
8093
8094 Consider the following input:
8095 %</en>
8096 %<*ja>
8097 \paragraph{\LaTeX へのエスケープ}
8098 日本語対応を行うために \verb+process_input_buffer+ を使用したことで,
8099 \texttt{texcl},~\texttt{escapeinside}といった\emph{「\LaTeX へのエスケープ」中では,
8100 \textbf{JAchar}を名称の一部に含む制御綴は使用不可能}である.
8101 例えば次のような入力を考えよう:
8102 %</ja>
8103 \begin{verbatim*}
8104 \begin{lstlisting}[escapechar=\#]
8105 #\ほげ xぴよ#
8106 \end{lstlisting}
8107 \end{verbatim*}
8108 %<en>The line~2 is transformed by the callback to
8109 %<ja>ここで,2行目は \verb+process_input_buffer+ の作用により,
8110 \begin{lstlisting}[showspaces, escapechar=\!]
8111 #\!\IVSA FFFFF!ほ!\IVSA FFFFF!げ x!\IVSA FFFFF!ぴ!\IVSA FFFFF!よ#
8112 \end{lstlisting}
8113 %<*en>
8114 before the line is actually processed.
8115 In the escape (between the character ``\verb+#+''),
8116 the category code of \texttt{U+FFFFF} is set to 9~(\emph{ignored}).
8117 Hence the control symbol ``\cs{}\IVSA FFFFF'' will be executed,
8118 instead of ``\verb+\ほげ+''.
8119 %</en>
8120 %<*ja>
8121 と変換されてから,実際の処理に回される.
8122 「\verb+#+」で挟まれた「\LaTeX へのエスケープ」中では\
8123 \texttt{U+FFFFF} のカテゴリーコードは9~(\textit{ignored})となるので,
8124 結局「\verb+\ほげ+」の代わりに
8125 「\cs{}\IVSA FFFFF」というcontrol symbolが実行されることになる.
8126 %</ja>
8127
8128 %<*ja>
8129 \paragraph{異体字セレクタの扱い}
8130 \texttt{lstlisting} 環境などの内部にある異体字セレクタを扱うため,
8131 \Pkg{lltjp-listings} では \texttt{vsraw} と \texttt{vscmd} という2つのキーを追加した.
8132 しかし,\Pkg{lltjp-listings} が実際に読み込まれるのは \verb+\begin{document}+\
8133 のところであるので,プリアンブル内ではこれらの追加キーは使用できない.
8134
8135 \texttt{vsraw}は,ブール値の値をとるキーであり,標準ではfalseである.
8136 \begin{itemize}
8137  \item trueの場合は,異体字セレクタは「直前の文字に続けて」出力される.
8138 もしもIVSサポート(\ref{ssec-ltjotf}節)が有効になっていた場合は,
8139 以下の例(左側は入力,右側はその出力)のようになる.
8140 \begin{LTXexample}
8141 \begin{lstlisting}[vsraw=true]
8142 葛󠄀城市,葛󠄁飾区,葛西
8143 \end{lstlisting}
8144 \end{LTXexample}
8145 \item falseの場合は,異体字セレクタは適当な命令によって「見える形で」出力される.
8146 どのような形で出力されるかを規定するのが \texttt{vscmd} キーであり,
8147 \Pkg{lltjp-listings} の標準設定では以下の例の右側のように出力される.
8148 \begin{LTXexample}
8149 \begin{lstlisting}[vsraw=false,
8150    vscmd=\ltjlistingsvsstdcmd]
8151 葛󠄀城市,葛󠄁飾区,葛西
8152 \end{lstlisting}
8153 \end{LTXexample}
8154 ちなみに,本ドキュメントでは次のようにしている:
8155 \begin{lstlisting}[numbers=left]
8156 \def\IVSA#1#2#3#4#5{%
8157   \textcolor{blue}{\raisebox{3.5pt}{\tt%
8158     \fboxsep=0.5pt\fbox{\tiny \oalign{0#1#2\crcr#3#4#5\crcr}}}}%
8159 }
8160 {\catcode`\%=11
8161   \gdef\IVSB#1{\expandafter\IVSA\directlua{
8162     local cat_str = luatexbase.catcodetables['string']
8163     tex.sprint(cat_str, string.format('%X', 0xE00EF+#1))
8164 }}}
8165 \lstset{vscmd=\IVSB}
8166 \end{lstlisting}
8167 \end{itemize}
8168 既定の出力命令を復活させたい場合は\ \verb+vsraw=\ltjlistingsvsstdcmd+\
8169 とすれば良い.
8170 %</ja>
8171
8172 %<en>\subsection{Class of Characters}
8173 %<ja>\subsection{文字種}
8174
8175 %<en>Roughly speaking, the \Pkg{listings} package processes input as follows:
8176 %<ja>\Pkg{listings} パッケージの内部では,大雑把に言うと
8177 \begin{enumerate}
8178 %<en>\item Collects \textit{letters} and \textit{digits}, which can be used for the name of identifiers.
8179 %<ja>\item 識別子として使える文字 (``letter'',~``digit'') たちを集める.
8180 %<en>\item When reading an \textit{other}, outputs the collected character string (with modification, if needed).
8181 %<ja>\item letterでもdigitでもない文字が現れた時に,収集した文字列を(必要なら修飾して)出力する.
8182 %<en>\item Collects \textit{others}.
8183 %<ja>\item 今度は逆に,letterでない文字たちをletterが現れるまで集める.
8184 %<en>\item When reading a \textit{letter} or a \textit{digit}, outputs the collected character string.
8185 %<ja>\item letterが出現したら集めた文字列を出力する.
8186 %<en>\item Turns back to 1.
8187 %<ja>\item 1.に戻る.
8188 \end{enumerate}
8189 %<*en>
8190 By the above process, line breaks inside of an identifier are blocked.
8191 A flag \verb+\lst@ifletter+ indicates whether the previous character can be used
8192 for the name of identifiers or not.
8193 %</en>
8194 %<*ja>
8195 という処理が行われている.これにより,識別子の途中では行分割が行われないようになっている.
8196 直前の文字が識別子として使えるか否かは \verb+\lst@ifletter+ というフラグに格納されている.
8197 %</ja>
8198
8199 %<*en>
8200 For Japanese characters, line breaks are permitted on both sides
8201 except for brackets, dashes, etc.
8202 Hence the patch \Pkg{lltjp-listings} introduces
8203 a new flag \verb+\lst@ifkanji+, which indicates
8204 whether the previous character is a Japanese character or not.
8205 For illustration, we introduce following classes of characters:
8206 %</en>
8207 %<*ja>
8208 さて,日本語の処理である.殆どの和文文字の前後では行分割が可能であるが,その一方で
8209 括弧類や音引きなどでは禁則処理が必要なことから,\Pkg{lltjp-listings} では,
8210 直前が和文文字であるかを示すフラグ \verb+\lst@ifkanji+ を新たに導入した.
8211 以降,説明のために以下のように文字を分類する:
8212 %</ja>
8213 \begin{center}
8214 \small
8215 \begin{tabular}{lccccc}
8216 \toprule
8217 &Letter&Other&Kanji&Open&Close\\\midrule
8218 \verb+\lst@ifletter+&T&F&T&F&T\\
8219 \verb+\lst@ifkanji+&F&F&T&T&F\\
8220 %<en>Meaning&char in an identifier&other alphabet&%
8221 %<en>most of Japanese char&opening brackets&closing brackets\\
8222 %<ja>意図&識別子中の文字&その他欧文文字&殆どの和文文字&開き括弧類&閉じ括弧類\\
8223 \bottomrule
8224 \end{tabular}
8225 \end{center}
8226 %<*en>
8227 Note that \textit{digits} in the \Pkg{listings} package can be Letter or
8228 Other according to circumstances.
8229 %</en>
8230 %<*ja>
8231 なお,本来の\Pkg{listings} パッケージでの分類``digit''は,
8232 出現状況によって,上の表のLetterとOtherのどちらにもなりうる.
8233 また,KanjiとCloseは \verb+\lst@ifletter+ と \verb+\lst@ifkanji+ の値が一致しているが,
8234 これは間違いではない.
8235 %</ja>
8236
8237 %<*en>
8238 For example, let us consider the case an Open comes after a Letter.
8239 Since an Open represents Japanese open brackets,
8240 it is preferred to be permitted to insert line break after the Letter.
8241 Therefore, the collected character string is output in this case.
8242 %</en>
8243 %<*ja>
8244 例えば,Letterの直後にOpenが来た場合を考える.
8245 文字種Openは和文開き括弧類を想定しているので,Letterの直後では行分割が可能であることが望ましい.
8246 そのため,この場合では,すでに収集されている文字列を出力することで行分割を許容するようにした.
8247 %</ja>
8248
8249 %<*en>
8250 The following table summarizes $5\times 5=25$ cases:
8251 %</en>
8252 %<*ja>
8253 同じように,$5\times 5=25$通り全てについて書くと,次のようになる:
8254 %</ja>
8255 \begin{center}
8256 \small
8257 \begin{tabular}{llccccc}
8258 \toprule
8259 %<*en>
8260 &&\multicolumn{4}{c}{Next}\\\cmidrule(lr){3-7}
8261 &&\hbox to 4em{\hss Letter\hss}&\hbox to 4em{\hss Other\hss}
8262 &\hbox to 4em{\hss Kanji\hss}&\hbox to 4em{\hss Open\hss}&Close\\\midrule
8263 &Letter&collects&\multicolumn{3}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
8264 &Other&outputs&collects&\multicolumn{2}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
8265 Prev&Kanji&\multicolumn{4}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
8266 &Open&\multicolumn{5}{c}{\hrulefill \ collects\ \hrulefill}\\
8267 &Close&\multicolumn{4}{c}{\hrulefill \ outputs\ \hrulefill}&collects\\
8268 %</en>
8269 %<*ja>
8270 &&\multicolumn{4}{c}{後ろ側の文字}\\\cmidrule(lr){3-7}
8271 &&\hbox to 4em{\hss Letter\hss}&\hbox to 4em{\hss Other\hss}
8272 &\hbox to 4em{\hss Kanji\hss}&\hbox to 4em{\hss Open\hss}&Close\\\midrule
8273 直&Letter&収集&\multicolumn{3}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
8274 前&Other&出力&収集&\multicolumn{2}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
8275 文&Kanji&\multicolumn{4}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
8276 字&Open&\multicolumn{5}{c}{\hrulefill \ 収集\ \hrulefill}\\
8277 種&Close&\multicolumn{4}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
8278 %</ja>
8279 \bottomrule
8280 \end{tabular}
8281 \end{center}
8282 %<en>In the above table,
8283 %<ja>上の表において,
8284 \begin{itemize}
8285 %<en>\item ``outputs'' means to output the collected character string (i.e., line breaking is permitted there).
8286 %<ja>\item 「出力」は,それまでに集めた文字列を出力(≒ここで行分割可能)を意味する.
8287
8288 %<en>\item ``collects'' means to append the next character to the collected character string (i.e., line breaking is prohibited there).
8289 %<ja>\item 「収集」は,後側の文字を,現在収集された文字列に追加(行分割不可)を意味する.
8290 \end{itemize}
8291
8292 %<*en>
8293 Characters above \texttt{U+0080} \emph{except Variation Selectors}
8294 are classified into above 5~classes by the following rules:
8295 %</en>
8296 %<*ja>
8297 \texttt{U+0080}以降の\emph{異体字セレクタ以外の}各文字が
8298 Letter, Other, Kanji, Open, Closeのどれに属するかは次によって決まる:
8299 %</ja>
8300 \begin{itemize}
8301 %<en>\item \textbf{ALchar}s above \texttt{U+0080} are classified as Letter.
8302 %<ja>\item (\texttt{U+0080}以降の)\textbf{ALchar}は,すべてLetter扱いである.
8303
8304 %<en>\item \textbf{JAchar}s are classified in the order as follows:
8305 %<ja>\item \textbf{JAchar}については,以下の順序に従って文字種を決める:
8306 \begin{enumerate}
8307 %<en>\item Characters whose \Param{prebreakpenalty} is greater than or equal to 0 are classified as Open.
8308 %<ja>\item \Param{prebreakpenalty}が0以上の文字はOpen扱いである.
8309
8310 %<en>\item Characters whose \Param{postbreakpenalty} is greater than or equal to 0 are classified as Close.
8311 %<ja>\item \Param{postbreakpenalty}が0以上の文字はClose扱いである.
8312
8313 %<en>\item Characters that don't satisfy the above two conditions are classified as Kanji.
8314 %<ja>\item 上の3条件のどちらにも当てはまらなかった文字は,Kanji扱いである.
8315 \end{enumerate}
8316 \end{itemize}
8317
8318 %<*en>
8319 The width of halfwidth kana (\texttt{U+FF61}--\texttt{U+FF9F})
8320 is same as the width of \textbf{ALchar};
8321 the width of the other \textbf{JAchar}s is double the width of \textbf{ALchar}.
8322 %</en>
8323 %<*ja>
8324 なお,半角カナ(U+FF61--U+FF9F)以外の\textbf{JAchar}は欧文文字2文字分の幅をとるものとみなされる.
8325 半角カナは欧文文字1文字分の幅となる.
8326 %</ja>
8327
8328 %<*en>
8329 This classification process is executed every time a character appears in
8330 the \texttt{lstlisting} environment or other environments/commands.
8331 %</en>
8332 %<*ja>
8333 これらの文字種決定は,実際に \texttt{lstlisting} 環境などの内部で文字が出てくるたびに行われる.
8334 %</ja>
8335
8336 %<*ja>
8337 \section{和文の行長補正方法}
8338 \label{sec-adjspec}
8339 \Pkg{luatexja-adjust} で提供される優先順位付きの行長調整の詳細を述
8340 べる.大まかに述べると,次のようになる.
8341 \begin{itemize}
8342 \item 通常の\TeX の行分割方法に従って,段落を行分割する.この段階では,行
8343       長に半端が出た場合,その半端分は\textbf{JAglue}(\Param{xkanjiskip},
8344       \Param{kanjiskip},JFMグルー)と
8345       それ以外のグルーの全てで(優先順位なく)負担される.
8346 \item その後,\texttt{post\_linebreak\_filter} callbackを使い,\emph{段
8347       落中の各行ごとに},行末文字の位置を調整したり,優先度付きの行長調整
8348       を実現するためにグルーの伸縮度を調整する.
8349       その処理においては,グルーの自然長と\textbf{JAglue}以外の
8350       グルーの伸び量・縮み量は変更せず,必要に応じて\textbf{JAglue}の伸び量・縮み量のみを
8351       変更する設計とした.
8352
8353 \Pkg{luatexja-adjust} の作用は,この処理を行うcallbackを追加するだけであり,
8354       この章の残りではcallbackでの処理について解説する.
8355 \end{itemize}
8356
8357 \paragraph{準備:合計伸縮量の計算}
8358 グルーの伸縮度(\texttt{plus} や \texttt{minus} で指定されている値)には,
8359 有限値の他に,\texttt{fi},\texttt{fil},\texttt{fill},\texttt{filll}と
8360 いう4つの無限大レベル(後ろの方ほど大きい)があり,行の調整に
8361 \texttt{fi} などの\emph{無限大レベルの伸縮度が用いられている場合は,そ
8362 の行に対しての処理を中止}する.
8363
8364 よって,以降,問題にしている行の行長調整は伸縮度が有限長のグルーを用いて
8365 行われているとして良い.さらに,簡単のため,この行はグルーが広げられている
8366 (自然長で組むと望ましい行長よりの短い)場合しか扱わない.
8367
8368 まず,段落中の行中のグルーを
8369 \begin{itemize}
8370 \item \textbf{JAglue}ではないグルー
8371 \item JFMグルー(優先度\footnote{%
8372   \ref{ssec-jfm-str}節にあるように,
8373   各JFMグルーには$-2$から2までの優先度がついている.}%
8374 別にまとめられる)
8375 \item 和欧文間空白(\Param{xkanjiskip})
8376 \item 和文間空白(\Param{kanjiskip})
8377 \end{itemize}
8378 の$1+1+5+1=8$つに類別し,それぞれの種別ごとに
8379 許容されている伸び量(\texttt{stretch}の値)の合計を計算する.
8380 また,行長と自然長との差を\textit{total}とおく.
8381
8382
8383 \subsection{行末文字の位置調整}
8384 行末が文字クラス$n$の\textbf{JAchar}であった場合,
8385 それを動かすことによって,\textit{total}のうち
8386 \textbf{JAglue}が負担する分を少なくしようとする.
8387 この行末文字の左右の移動可能量は,
8388 JFM中にある文字クラス$n$の定義の
8389 \texttt{end\_stretch},~\texttt{end\_shrink}フィールドに
8390 全角単位の値として記述されている.
8391
8392 例えば,行末文字が句点「。」であり,そこで用いられているJFM中に
8393 \begin{lstlisting}
8394   [2] = {
8395     chars = { '。', ... }, width = 0.5, ...,
8396     end_stretch = 0.5, end_shrink = 0.5,
8397   },
8398 \end{lstlisting}
8399 という指定があった場合,この行末の句点は
8400 \begin{itemize}
8401 \item 通常の\TeX の行分割処理で「半角以上の詰め」が行われていた場合,
8402 この行中の\textbf{JAglue}の負担を軽減するため,
8403 行末の句点を半角だけ右に移動する(ぶら下げ組を行う).
8404 \item 通常の\TeX の行分割処理で「半角以上の空き」が行われていた場合,
8405 逆に行末句点を半角左に移動させる(見た目的に全角取りとなる).
8406 \item 以上のどちらでもない場合,行末句点の位置調整は行わない.
8407 \end{itemize}
8408 となる.
8409
8410 行末文字を移動した場合,その分だけ\textit{total}の値を引いておく.
8411
8412 \subsection{グルーの調整}
8413 \textit{total}の分だけが,行中のグルーの伸び量に応じて負担されることになる.
8414 負担するグルーの優先度は以下の順であり,
8415 できるだけ\Param{kanjiskip}を自然長のままにすることを
8416 試みている.
8417 \begin{enumerate}\def\labelenumi{(\Alph{enumi})}
8418  \item \textbf{JAglue}以外のグルー
8419  \item 優先度2のJFMグルー
8420  \item 優先度1のJFMグルー
8421  \item 優先度0のJFMグルー
8422  \item 優先度$-1$のJFMグルー
8423  \item 優先度$-2$のJFMグルー
8424  \item \Param{xkanjiskip}
8425  \item \Param{kanjiskip}
8426 \end{enumerate}
8427 \begin{enumerate}
8428  \item 行末の和文文字を移動したことで$\textit{total}=0$となれば,
8429 調整の必要はなく,行が格納されているhboxの
8430 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算すればよい.
8431 以降,$\textit{total}\neq 0$と仮定する.
8432  \item \textit{total}が「\textbf{JAglue}以外のグルーの伸び量の合計」(以下,(A)の伸び量の
8433        合計,と称す)よりも小さければ,
8434 それらのグルーに\textit{total}を負担させ,\textbf{JAglue}達自身は自然長で組むことができる.
8435 よって,以下の処理を行う:
8436 \begin{enumerate}
8437 \item 各\textbf{JAglue}の伸び量を0とする.
8438 \item 行が格納されているhboxの
8439 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算する.
8440 これによって,\textit{total}は\textbf{JAglue}以外のグルーによって負担される.
8441 \end{enumerate}
8442 \item \textit{total}が「(A)の伸び量の合計」以上ならば,(A)--(H)のどこまで負担すれば
8443 \textit{total}以上になるかを計算する.
8444 例えば,
8445 \[\catcode`\<=12
8446  \textit{total} = (\text{(A)--(B)の伸び量の合計}) + p\cdot (\text{(C)の伸び量の合計}),
8447  \qquad 0\le p<1
8448 \]
8449 であった場合,各グルーは次のように組まれる:
8450 \begin{itemize}
8451  \item (A),~(B)に属するグルーは各グルーで許された伸び量まで伸ばす.
8452  \item (C)に属するグルーはそれぞれ$p\times (\text{伸び量})$だけ伸びる.
8453  \item (D)--(H)に属するグルーは自然長のまま.
8454 \end{itemize}
8455 実際には,前に述べた「設計」に従い,次のように処理している:
8456 \begin{enumerate}
8457 \item (C)に属するグルーの伸び量を$p$倍する.
8458 \item (D)--(H)に属するグルーの伸び量を0とする.
8459 \item 行が格納されているhboxの
8460 \texttt{glue\_set}, \texttt{glue\_sign}, \texttt{glue\_order}を再計算する.
8461 これによって,\textit{total}は\textbf{JAglue}以外のグルーによって負担される.
8462 \end{enumerate}
8463 \item \textit{total}が(A)--(H)の伸び量の合計よりも大きい場合,どうしようもないので
8464       \verb+^^;+何もしない.
8465 \end{enumerate}
8466
8467 %</ja>
8468
8469 %<*ja>
8470 \section{IVS対応}
8471 \verb+luatexja.otf.enable_ivs()+ を実行し,IVS対応を有効にした状態では,
8472 \verb+pre_linebreak_filter+ や \verb+hpack_filter+ コールバックには
8473 次の4つが順に実行される状態となっている:
8474 \begin{description}
8475 \item[\tt ltj.do\_ivs] \textit{glyph\_node}~$p$の直後に,異体字セレクタ(を表す\textit{glyph\_node})
8476 が連続した場合に,$p$のフォントに対応したが持つ「異体字情報」に従って出力するグリフを変える.
8477
8478 しかし,単に$p.\textit{char}$を変更するだけでは,後から
8479 font featureの適用(すぐ下)により置換される可能性がある.そのため,
8480 \cs{CID} や \cs{UTF} と同じように,\textit{glyph\_node}~$p$の代わりに
8481 \texttt{user\_id} が\textit{char\_by\_cid}であるようなuser-defined whatsitを用いている.
8482 \item[(\Pkg{luaotfload} によるfont featureの適用)]
8483 \item[\tt ltj.otf] \texttt{user\_id} が\textit{char\_by\_cid}であるようなuser-defined whatsitを
8484 きちんと\textit{glyph\_node}に変換する.この処理は,\cs{CID}, \cs{UTF}やIVSによる置換が,
8485 font featureの適用で上書きされてしまうのを防止するためである.
8486 \item[\tt ltj.main\_process] \textbf{JAglue}の挿入処理(\ref{sec-jfmglue}章)と,
8487 JFMの指定に従って各\textbf{JAchar}の「寸法を補正」することを行う.
8488 \end{description}
8489
8490 問題は各フォントの持っているIVS情報をどのように取得するか,である.
8491 \Pkg{luaotfload} はフォント番号<font\_number>の情報を\
8492 \texttt{fonts.hashes.identifiers[<font\_number>]} 以下に格納している.
8493 しかし,OpenTypeフォントのIVS情報は格納されていないようである%
8494 \footnote{TrueTypeフォントに関しては,
8495 \begin{center}
8496 \texttt{fonts.hashes.idenfiers[<font\_number>]%
8497   .resources.variants[<selector>][<base\_char>]}
8498 \end{center}
8499 に,<base\_char>番の文字の後に異体字セレクタ<selector>が続いた場合に
8500 出力すべきグリフが書かれてある.}.
8501 %例えば,小塚明朝Pr6N~Rでは,
8502
8503 一方,\LuaTeX 内部の \texttt{fontloader} の返すテーブルには
8504 OpenTypeフォントでもTrueTypeフォントでもIVS情報が格納されている.
8505 具体的には……
8506
8507 そのため,\LuaTeX-jaのIVS対応においては,\LuaTeX 内部の\
8508 \texttt{fontloader} を直接用いることで,フォントのIVS情報を取得している.
8509 20140114.0以降でキャッシュを用いるようにした要因はここにあり,
8510 \texttt{fontloader} の呼び出しでかなり時間を消費することから,
8511 %%% to_table を使わなくしたことで,メモリ使用量は減った
8512 IVS情報をキャッシュに保存することで2回目以降の実行時間を節約している.
8513
8514
8515 \section{複数フォントの「合成」(未完)}
8516
8517 \section{\LuaTeX-jaにおけるキャッシュ}
8518 \Pkg{luaotfload}パッケージが,各TrueType・OpenTypeフォントの情報を
8519 キャッシュとして保存しているのと同様の方法で,
8520 \LuaTeX-jaもいくつかのキャッシュファイルを作成するようになった.
8521 \begin{itemize}
8522  \item 通常,キャッシュは\texttt{\$TEXMFVAR/luatexja/}以下に保存され,
8523 そこから読み込みが行われる.
8524  \item 「通常の」テキスト形式のキャッシュ(拡張子は \texttt{.lua})以外にも,
8525 それをバイナリ形式(バイトコード)に変換したものもサポートしている.
8526 \begin{itemize}
8527  \item \LuaTeX とLuaJIT\TeX ではバイトコードの形式が異なるため,バイナリ形式の
8528 キャッシュは共有できない.\LuaTeX 用のバイナリキャッシュは \texttt{.luc},
8529 LuaJIT\TeX 用のは \texttt{.lub} と拡張子を変えることで対応している.
8530  \item キャッシュを読み込む時,同名のバイナリキャッシュがあれば,
8531 テキスト形式のものよりそちらを優先して読み込む.
8532  \item テキスト形式のキャッシュが更新/作成される際は,そのバイナリ版も
8533 同時に更新される.
8534 また,(バイナリ版が見つからず)テキスト形式のキャッシュ側が読み込まれたときは,
8535 \LuaTeX-jaはバイナリキャッシュを作成する.
8536 \end{itemize}
8537 \end{itemize}
8538 %</ja>
8539 %<*en>
8540 \section{Cache Management of \LuaTeX-ja}
8541 \LuaTeX-ja creates some cache files to reduce the loading time.
8542 in a similar way to the \Pkg{luaotfload} package:
8543 \begin{itemize}
8544  \item Cache files are usually stored in (and loaded from)
8545 \texttt{\$TEXMFVAR/luatexja/}.
8546  \item In addition to caches of the text form (the extension is ``\texttt{.lua}''),
8547 caches of the \emph{binary}, precompiled form are supported.
8548 \begin{itemize}
8549  \item We cannot share same binary cache for \LuaTeX\ and LuaJIT\TeX.
8550 Hence we distinguish them by their extension, ``\texttt{.luc}'' for \LuaTeX\
8551 and ``\texttt{.lub}'' for LuaJIT\TeX.
8552  \item In loading a cache, the binary cache precedes
8553 the text form.
8554  \item When \LuaTeX-ja updates a cache \texttt{hoge.lua},
8555 its binary version is also updated.
8556 \end{itemize}
8557 \end{itemize}
8558 %</en>
8559
8560 %<*ja>
8561 \subsection{キャッシュの使用箇所}
8562
8563 \LuaTeX-ja では以下の3種類のキャッシュを使用している:
8564 \begin{cslist}
8565 \item[ltj-cid-auto-adobe-japan1.lua]
8566 Ryumin-Lightのような非埋め込みフォントの情報を格納しており,
8567 (それらが\LuaTeX-jaの標準和文フォントなので)\LuaTeX-jaの読み込み時に自動で読まれる.
8568 生成には\texttt{UniJIS2004-UTF32-\{H, V\}}, \texttt{Adobe-Japan1-UCS2}という3つの
8569 CMapが必要である.
8570
8571 \pageref{para-cid}ページで述べたように,\texttt{cid}キーを使って
8572 非埋め込みの中国語・韓国語フォントを定義する場合,同様のキャッシュが生成される.
8573 キャッシュの名称,必要となるCMapについては表\ref{tab:cid-cache}を参照して欲しい.
8574
8575 \item[extra\_***.lua]
8576 フォント``\texttt{***}''における異体字セレクタの情報,縦組用字形への変換テーブル,そして
8577 縦組時における幅を格納している.構造は以下の通り:
8578 %</ja>
8579 %<*en>
8580 \subsection{Use of Cache}
8581
8582 \LuaTeX-ja uses the following cache:
8583 \begin{cslist}
8584 \item[ltj-cid-auto-adobe-japan1.lua]
8585 The font table of a CID-keyed non-embedded Japanese font.
8586 This is loaded in every run.
8587 It is created from two CMaps, \texttt{UniJIS2004-UTF32-H} and
8588              \texttt{Adobe-Japan1-UCS2},
8589 and this is why these two CMaps are needed in the first run of \LuaTeX-ja.
8590
8591 Similar caches are created as Table~\ref{tab:cid-cache},
8592 if you specified \texttt{cid} key in \cs{jfont}
8593 to use other CID-keyed non-embedded fonts for Chinese or Korean,
8594 as in Page~\pageref{para-cid}.
8595
8596 \item[extra\_***.lua]
8597 This file stores the table which stores the following.
8598 \begin{itemize}
8599  \item unicode variants in a font ``\texttt{***}''
8600  \item vertical width of glyphs, if it is not equal to the sum of 
8601 the height of ascender and the depth of descender
8602  \item vertical variants
8603 \end{itemize}
8604 The following is the structure of the that table.
8605 %</en>
8606
8607 \begin{table}[!tb]
8608  \centering\small
8609 \caption{\texttt{cid} key and corresponding files}
8610 \label{tab:cid-cache}
8611 \vspace*{\medskipamount}
8612 \begin{tabular}{>{\tt}l>{\tt}l>{\tt}l>{\tt}l}
8613 \toprule
8614 \bf \texttt{cid} key&\bf name of the cache &
8615 \multicolumn{2}{c}{\bf used CMaps}\\
8616 \midrule
8617 Adobe-Japan1-*&ltj-cid-auto-adobe-japan1.lua&UniJIS2004-UTF32-H&Adobe-Japan1-UCS2\\
8618 Adobe-Korea1-*&ltj-cid-auto-adobe-korea1.lua&UniKS-UTF32-H&Adobe-Korea1-UCS2\\
8619 Adobe-GB1-*&ltj-cid-auto-adobe-gb1.lua&UniGB-UTF32-H&Adobe-GB1-UCS2\\
8620 Adobe-CNS1-*&ltj-cid-auto-adobe-cns1.lua&UniCNS-UTF32-H&Adobe-CNS1-UCS2\\
8621 \bottomrule
8622 \end{tabular}
8623 \end{table}
8624
8625 \begin{lstlisting}
8626 return {
8627  {
8628   [10955]={    -- U+2ACB "Subset Of Above Not Equal To"
8629    [65024]=983879, -- <2ACB FE00>
8630    ["vwidth"]=0.98, -- vertical width
8631   },
8632   [37001]={    -- U+9089 "邉"
8633    [0]=37001,  --   <9089 E0100>
8634    991049,     --   <9089 E0101>
8635    ...
8636    ["vert"]=995025, -- vertical variant
8637   },
8638   ...
8639  },
8640  ["chksum"]="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", -- checksum of the fontfile
8641  ["version"]=2, -- version of the cache
8642 }
8643 \end{lstlisting}
8644 %<*ja>
8645 \item[ltj-jisx0208.\{luc|lub\}]
8646 \LuaTeX-ja配布中の\texttt{ltj-jisx0208.lua}をバイナリ化したものである.
8647 これはJIS~X~0208とUnicodeとの変換テーブルであり,
8648 \pTeX との互換目的の文字コード変換命令で用いられる.
8649 %</ja>
8650 %<*en>
8651 \item[ltj-jisx0208.\{luc|lub\}]
8652 The binary version of \texttt{ltj-jisx0208.lua}.
8653 This is the conversion table between JIS~X~0208 and Unicode
8654 which is used in Kanji-code conversion commands for compatibility with \pTeX.
8655 %</en>
8656 \end{cslist}
8657
8658 %<*en>
8659 \subsection{Internal}
8660 Cache management system of \LuaTeX-ja is stored in \texttt{luatexja.base}
8661 (\texttt{ltj-base.lua}).
8662 There are three public functions for cache management in \texttt{luatexja.base},
8663 where <filename> stands for the file name \emph{without suffix}:
8664 \begin{cslist}
8665 \item[save\_cache(<filename>, <data>)]
8666 Save a non-nil table <data> into a cache <filename>.
8667 Both the text form <filename>\texttt{.lua} and its binary version
8668 are created or updated.
8669
8670 \item[save\_cache\_luc(<filename>, <data>{[, <serialized\_data>]})]
8671
8672 Same as \texttt{save\_cache}, except that only the binary cache is updated.
8673 The third argument <serialized\_data> is not usually given.
8674 But if this is given, it is treated as a string representation of <data>.
8675
8676 \item[load\_cache(<filename>, <outdate>)]
8677 Load the cache <filename>.
8678 <outdate> is a function which takes one argument (the contents of the cache),
8679 and its return value is whether the cache is outdated.
8680
8681 \texttt{load\_cache} first tries to
8682 read the binary cache <filename>\texttt{.\{luc|lub\}}.
8683 If its contents is up-to-date, \texttt{load\_cache} returns the contents.
8684 If the binary cache is not found or
8685 its contents is outdated, \texttt{load\_cache} tries to
8686 read the text form <filename>\texttt{.lua}.
8687 Hence, the return value of \texttt{load\_cache} is non-nil,
8688 if and only if the updated cache is found.
8689 \end{cslist}
8690 %</en>
8691 %<*ja>
8692 \subsection{内部命令}
8693 \LuaTeX-jaにおけるキャッシュ管理は,\texttt{luatexja.base}~(\texttt{ltj-base.lua})に
8694 実装しており,以下の3関数が公開されている.
8695 ここで,<filename>は保存するキャッシュのファイル名を\emph{拡張子なしで}指定する.
8696 \begin{cslist}
8697 \item[save\_cache(<filename>, <data>)]
8698 nilでない<data>をキャッシュ<filename>に保存する.
8699 テキスト形式の<filename>\texttt{.lua}のみならず,
8700 そのバイナリ版も作成/更新される.
8701
8702 \item[save\_cache\_luc(<filename>, <data>{[, <serialized\_data>]})]
8703
8704 \texttt{save\_cache}と同様だが,バイナリキャッシュのみが更新される.
8705 第3引数<serialized\_data>が与えられた場合,それを
8706 <data>の文字列化表現として使用する.
8707 そのため,<serialized\_data>は普通は指定しないことになるだろう.
8708
8709 \item[load\_cache(<filename>, <outdate>)]
8710 キャッシュ<filename>を読み込む.
8711 <outdate>は1引数(キャッシュの中身)をとる関数であり,
8712 その戻り値は「キャッシュの更新が必要」かどうかを示すブール値でないといけない.
8713
8714 \texttt{load\_cache}は,まずバイナリキャッシュ<filename>\texttt{.\{luc|lub\}}を
8715 読みこむ.もしその内容が「新しい」,つまり<outdate>の評価結果が \texttt{false} なら
8716 \texttt{load\_cache}はこのバイナリキャッシュの中身を返す.
8717 もしバイナリキャッシュが見つからなかったか,「古すぎる」ならばテキスト版
8718              <filename>\texttt{.lua}を読み込み,その値を返す.
8719
8720 以上より,\texttt{load\_cache}自体がnilでない値を返すのは,ちょうど「新しい」キャッシュが
8721 見つかった場合である.
8722 \end{cslist}
8723 %</ja>
8724
8725
8726 %<*ja>
8727 \section{縦組の実装}
8728 \label{sec-dir-imp}
8729 \ref{sec-direction}章の最初でも述べたように,
8730 \LuaTeX-jaは横組(\texttt{TLT})で組んだボックスを回転させる方式で
8731 縦組を実装している.
8732
8733 \LuaTeX-jaにおける縦組の実装は
8734 \pTeX における実装(\cite{ptexdoc,ptextug})をベースにしている.
8735
8736 \subsection{direction~whatsit}
8737 \textit{direction}~whatsitとは,\textit{direction}という特定の \verb+user_id+ を持つ
8738 whatsitのことであり,以下のタイミングで作られる.
8739 \begin{itemize}
8740  \item 組方向を \cs{tate} 等で変更したとき.
8741  \item \cs{hbox}, \cs{vbox}, \cs{vtop} による明示的なボックスの開始時.\\
8742 \verb+\hbox{}+, \verb+\vbox{}+ といった,
8743 \begin{itemize}
8744  \item \cs{tate} 等によりボックス内部の組方向を変更していない
8745  \item ボックスの中身のリストが空である
8746 \end{itemize}
8747 場合は,\LuaTeX の \verb+hpack_filter+, \verb+vpack_filter+ といった
8748 callbackに処理が回らない.そこで,\LuaTeX-ja では,\cs{everyhbox}, \cs{everyvbox} を利用す
8749        ることで各ボックスの先頭に確実に追加するようにしている\footnote{%
8750   問題は \cs{hbox to 25pt\{\}} という状況である.実際のこのボックスの中身は空でない(少な
8751        くともdirection whatsitがある)ため,何も対策をしなければhpack時にUnderfill警告が発
8752        生してしまうことになる.\LuaTeX-jaではそうならないように「\cs{hbadness},
8753        \cs{vbadness} を一時的に10000に変更し,hpack, vpack後に元の値に戻す」処理を行ってい
8754        る.
8755 }.
8756  \item \cs{vsplit}によってvboxを分割した時の「残り」の先頭.
8757  \item \LuaTeX-ja読み込み前に作成したボックスの寸法を \cs{ltjsetwd} 等によって変更した時.
8758  \item \cs{insert} によるinsertionでは,中身の先頭に\textit{direction}~whatsitは作られず,
8759 その代わりに中身の各ボックス・罫線の直前に作られる\footnote{%
8760  これは,ページ分割の過程でinsertionが分割される時,「現在のページで出力される部分」が空と
8761        なることがあることによる.先頭にwhatsitを置くと,最悪でも「現在のページにwhatsitが
8762        残る」ことになってしまう.}.
8763 \end{itemize}
8764 なお,\verb+\vtop{...}+ の場合は,先頭にdirection whatsitを置くと
8765 ボックスの高さが常に0\,ptになるという問題が発生する.そのため,この場合に限っては
8766 vpack時にdirection whatsitをリストの2番目に移動させている.
8767
8768 direction whatsitはあくまでも組方向処理のための補助的なノードであるので,
8769 \cs{unhbox}, \cs{unhcopy} によってボックスの中身が展開される時には展開直前に削除される.
8770 これは
8771 \begin{lstlisting}
8772  % yoko direction
8773 \setbox0=\hbox{\tate B}
8774 \noindent % 水平モードに入る.この時点でのリストの中身は空
8775 \unhbox0 A
8776 \end{lstlisting}
8777 といった場合に,段落が縦組で組まれたり,あるいは
8778 \begin{lstlisting}
8779 \setbox0=\hbox{}
8780 \leavevmode \hbox{A}\unhbox0
8781 \setbox1=\lastbox % \box1 はどうなる?
8782 \end{lstlisting}
8783 で \cs{box1} が \cs{hbox\{A\}} でなく空になってしまうことを防ぐためである.
8784
8785
8786 \subsection{\textit{dir\_box}}
8787 縦中横など異方向のボックスを配置する場合に,周囲の組方向と大きさを整合させるため,
8788 \LuaTeX-jaでは \verb+\ltj@dir+ が128以降の\textit{hlist\_node}, \textit{vlist\_node}を
8789 用いる.これらは\pTeX における\textit{dir\_node}の役割と同じ果たしており,
8790 この文章中では\textit{dir\_box}と呼称する.
8791
8792 \subsubsection{異方向のボックスの整合}
8793 \textit{dir\_box}の第一の使用目的は,異方向のボックスの大きさを整合させることである.
8794 例えば,
8795 \begin{lstlisting}
8796  % yoko direction
8797 平成\hbox{\tate 26}年
8798 \end{lstlisting}
8799 は段落中で
8800 \[
8801  \xymatrix{
8802    {}\Node{glyph}{`平'}\ar[r]&{}\Node{glyph}{`成'}\ar[r]&
8803    {}\HNode{hlist}{10.00003}{3.02779}{0.0}\ar[r]\ar[d]^{\text{中身}}&{}\Node{glyph}{`年'}\\
8804    &&{}\Node{whatsit}{\cs{tate}}\ar[r]&{}\Node{glyph}{`2'}\ar[r]&{}\Node{glyph}{`6'}
8805  }
8806 \]
8807 というリストを作る.その後,この段落が終了したときに,
8808 \LuaTeX-jaの\textbf{JAglue}挿入処理が行われ
8809 \[
8810  \xymatrix{
8811    {}\Node{glyph}{`平'}\ar[r]
8812   &{}\textcolor{blue}{\Node{glue}{\Param{xkanjiskip}}}\ar[r]
8813   &{}\Node{glyph}{`成'}\ar[r]
8814   &{}\textcolor{blue}{\Node{penalty}{0}}
8815     \ar`r[d] `[l] `[ddll] `[dl] [dl]
8816   \\
8817   &&{}\textcolor{red}{\HNode{hlist}{3.02779}{10.00003}{0.0}}\ar[r]\ar[d]^{\text{中身}}
8818   &{}\textcolor{blue}{\Node{penalty}{0}}\ar[r]
8819   &{}\Node{glyph}{`年'}\\
8820   &&{}\HNode{\textit{dir\_box} (\cs{yoko})}{10.00003}{3.02779}{0.0}\ar[d]^{\text{中身}}\\
8821   &&{}\Node{whatsit}{\cs{tate}}\ar[r]&{}\Node{glyph}{`2'}\ar[r]&{}\Node{glyph}{`6'}
8822  }
8823 \]
8824 のようになる(青字は\textbf{JAglue},赤字が整合処理のための\textit{dir\_box}である).
8825 \TeX の \cs{showbox} 形式で書けば
8826
8827 \medskip{\narrowbaselines\ttfamily\obeylines\parindent0pt
8828 \catcode`\@=0 @catcode`@\=12
8829 .\tenmin 平
8830 @textcolor{blue}{.\glue 0.0 plus 0.4 minus 0.4}
8831 .\tenmin 成
8832 @textcolor{blue}{.\penalty 0}
8833 @textcolor{red}{.\hbox(10.00003+0.0)x3.02779, direction TLT}
8834 ..\hbox(3.02779+0.0)x10.00003, direction TLT
8835 ...\whatsit4=[]
8836 ...\tenrm 2
8837 ...\tenrm 6
8838 @textcolor{blue}{.\penalty 0}
8839 .\tenmin 年
8840 }\medskip
8841
8842 \noindent である.
8843
8844 なお,\cs{raise},~\cs{lower}, \cs{moveleft},~\cs{moveright} といったボックス移動命令では.
8845 移動を正しく表現するために段落やボックスの途中でも異方向のボックスは\textit{dir\_box}にカ
8846 プセル化している.
8847 例えば
8848 \begin{lstlisting}
8849  % yoko direction
8850 平成\raise1pt\hbox{\tate 26}年\showlists
8851 \end{lstlisting}
8852 は以下のような結果を得る.
8853
8854 \medskip{\narrowbaselines\ttfamily\obeylines\parindent0pt
8855 \catcode`\@=0 @catcode`@\=12
8856 (前略)
8857 \tenrm 平
8858 \tenrm 成
8859 @textcolor{red}{\hbox(10.00003+0.0)x3.02779, shifted -1.0, direction TLT}
8860 .\hbox(3.02779+0.0)x10.00003, direction TLT
8861 ..\whatsit4=[]
8862 ..\tenrm 2
8863 ..\tenrm 6
8864 \tenrm 年
8865 }\medskip
8866
8867 また,メインの垂直リストに異方向のボックスが追加される場合にも同様に即座に
8868 \textit{dir\_box}にカプセル化している.ページ分割のタイミングを正
8869 しく\TeX が判断するためである.
8870 \cs{lastbox} によるボックスの取得では,\textit{dir\_box}は削除される.
8871
8872 \subsubsection{異方向のボックス寸法の格納}
8873 第二の使用目的は,現在の組方向がボックス本来の組方向とは異なる状況で,
8874 \cs{ltjsetwd} によってボックス寸法を設定されたことを記録することである.
8875
8876 例えば
8877 \begin{lstlisting}[numbers=left]
8878 \setbox0=\hbox{\vrule width 10pt height 5pt depth 2pt}
8879 \setbox1=\hbox{\tate\ltjsetwd0=20pt}
8880 \wd0=9pt
8881 \setbox1=\hbox{\dtou\ltjsetwd0=20pt}
8882 \setbox0=\hbox{\dtou a\box0}
8883 \end{lstlisting}
8884 というコードを考える.1行目で \cs{box0} には横組の
8885 幅10\,pt,高さ5\,pt,深さ2\,ptのボックスが代入される.
8886 よって,
8887 \begin{itemize}
8888  \item 縦組下では \cs{box0} は幅7\,pt,高さ・深さ5\,ptのボックスとして扱われる.
8889  \item \cs{dtou} 下では \cs{box0} は幅7\,pt,高さ10\,pt,深さ0\,ptのボックスとして扱われる.
8890 \end{itemize}
8891 このとき,\cs{box0} の\emph{中身}は
8892 \[
8893  \xymatrix{
8894    {}\Node{whatsit}{\cs{yoko}}\ar[r]&{}\Node{rule}{}
8895  }
8896 \]
8897 である.
8898
8899 さて,2行目で縦組時の \cs{box0} の幅が20\,ptに設定される.この情報が
8900 direction~whatsit内部のノードリストに,\textit{dir\_box}として格納される:
8901 \[
8902  \xymatrix{
8903    {}\Node{whatsit}{\cs{yoko}}\ar[r]\ar[d]_{\text{中身}}&{}\Node{rule}{}\\
8904    {}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{tate})}{20.0}{5.0}{5.0}}
8905  }
8906 \]
8907
8908 次に,3行目では横組時の,つまり \cs{box0} 本来の組方向での深さが9\,ptに変更される.
8909 このとき,\cs{box0} は
8910 \begin{itemize}
8911  \item 縦組下では寸法代入が既に行われているので,2行目で作成された\textit{dir\_box}の通り
8912        に幅20\,pt,高さ・深さ5\,ptのボックスとして扱われる.
8913  \item \cs{dtou} 下ではまだ寸法代入が行われていないので,
8914 \cs{box0} の寸法変更に追従し,幅7\,pt,高さ9\,pt,深さ0\,ptのボックスとして扱われる.
8915 \end{itemize}
8916
8917 4行目では \cs{dtou} 下での\cs{box0} の幅が20\,ptに設定されるので,2行目と同じように
8918 \[
8919  \xymatrix{
8920    {}\Node{whatsit}{\cs{yoko}}\ar[r]\ar[d]_{\text{中身}}&{}\Node{rule}{}\\
8921    {}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{dtou})}{20.0}{9.0}{0.0}}\ar[r]&
8922    {}\HNode{\textit{dir\_box} (\cs{tate})}{20.0}{5.0}{5.0}
8923  }
8924 \]
8925 と\textit{dir\_box}が作成される.
8926
8927 このように寸法代入によってつくられた\textit{dir\_box}は,前節の整合過程のときに再利用され
8928 る.上記の例でいえば,5行目を実行した後の \cs{box0} の内容は
8929 \[
8930  \xymatrix{
8931    {}\Node{whatsit}{\cs{dtou}}\ar[r]&
8932    {}\Node{glyph}{`a'}\ar[r]&
8933    {}\textcolor{red}{\HNode{\textit{dir\_box} (\cs{dtou})}{20.0}{9.0}{0.0}}\ar[d]_{\text{中身}}\\
8934    &&{}\HNode{hlist}{9.0}{5.0}{2.0}\ar[d]_{\text{中身}}\\
8935    &&{}\Node{whatsit}{\cs{yoko}}\ar[r]&{}\Node{rule}{}
8936  }
8937 \]
8938 のようになる.
8939 %</ja>
8940
8941 \newpage
8942 \begin{thebibliography}{99}
8943   \addcontentsline{toc}{section}{\refname}
8944 \bibitem{texbytopic}
8945 Victor Eijkhout. \newblock \textit{\TeX\ by Topic, A \TeX nician's Reference}, Addison-Wesley, 1992.
8946 \bibitem{listings} C.\ Heinz, B.\ Moses. \newblock The \textsf{Listings} Package.
8947 \bibitem{uptex} Takuji Tanaka. \newblock
8948 upTeX---Unicode version of pTeX with CJK extensions,
8949 TUG 2013, October 2013.
8950 %<ja>\newblock
8951 %<en>\\\null\hfill
8952 \url{http://tug.org/tug2013/slides/TUG2013_upTeX.pdf}
8953 \bibitem{jlisting} Thor Watanabe. \newblock Listings\ -\ MyTeXpert.
8954 %<en>\newblock
8955 %<ja>\\\null\hfill
8956 \url{http://mytexpert.sourceforge.jp/index.php?Listings}
8957 \bibitem{jlreq}  W3C Japanese Layout Task Force~(ed). \newblock
8958 Requirements for Japanese Text Layout (W3C Working Group Note), 2011, 2012. \newblock
8959 \url{http://www.w3.org/TR/jlreq/}%
8960 %<ja> \\日本語訳の書籍版:W3C日本語組版タスクフォース(編),『W3C技術ノート 日本語組版処理の要件』,東京電機大学出版局,2012.
8961 \bibitem{min10} 乙部厳己.min10フォントについて.\\\null\hfill
8962 \url{http://argent.shinshu-u.ac.jp/~otobe/tex/files/min10.pdf}
8963 \bibitem{x4051} 日本工業規格(Japanese Industrial Standard). JIS~X~4051,
8964 日本語文書の組版方法(Formatting rules for Japanese documents), 1993, 1995, 2004.
8965 \bibitem{ptexdoc} 濱野尚人,田村明史,倉沢良一.\TeX の出版への応用—縦組み機能の組み込み—.
8966 \\\null\hfill\texttt{.../texmf-dist/doc/ptex/base/ptexdoc.pdf}
8967 \bibitem{ptextug} Hisato Hamano. \newblock
8968 \textit{Vertical Typesetting with \TeX}, TUGBoat~\textbf{11}(3), 346--352, 1990.
8969 \bibitem{pdfstd} International Organization for Standardization. \newblock
8970 ISO 32000-1:2008, \textit{Document management -- Portable document format -- Part 1: PDF
8971       1.7}, 2008. \newblock
8972 \\\null\hfill
8973 \url{http://www.iso.org/iso/iso\_catalogue/catalogue_tc/catalogue\_detail.htm?csnumber=51502}
8974 \end{thebibliography}
8975
8976 \end{document}
8977 %</!showexpl>
8978 %<*showexpl>
8979 %%
8980 %% config file for showexpl.sty
8981 %%
8982 %% Copyright The LuaTeX-ja project team, 2012
8983 %%
8984 \ProvidesFile{showexpl.cfg}
8985   [2012/05/20 v0.01 Definitions for the showexpl package (luatexja)]
8986 \lstset{}
8987 \def\SX@Info{}
8988 \endinput
8989 %</*showexpl>