1 %#! lualatex -shell-escape manual.ins
3 %<en>\documentclass[a4paper,titlepage]{article}
4 %<ja>\documentclass[a4paper,titlepage]{ltjsarticle}
5 \usepackage[margin=20mm,footskip=5mm]{geometry}
7 \usepackage{amsmath,amssymb,xcolor,pict2e,multienum,amsthm,float}
8 \usepackage{booktabs,listings,lltjlisting,showexpl,multicol}
9 \usepackage{luatexja-otf}
10 \usepackage[unicode]{hyperref}
14 \DeclareRobustCommand\eTeX{\ensuremath{\varepsilon}-\kern-.125em\TeX}
15 \DeclareRobustCommand\LuaTeX{Lua\TeX}
16 \DeclareRobustCommand\pdfTeX{pdf\TeX}
17 \DeclareRobustCommand\pTeX{p\kern-.05em\TeX}
18 \DeclareRobustCommand\upTeX{p\kern-.05em\TeX}
19 \DeclareRobustCommand\pLaTeX{p\kern-.05em\LaTeX}
20 \DeclareRobustCommand\pLaTeXe{p\kern-.05em\LaTeXe}
21 \DeclareRobustCommand\epTeX{\ensuremath{\varepsilon}-\kern-.125em\pTeX}
23 \theoremstyle{definition}
24 %<en>\newtheorem{defn}{Definition}
25 %<ja>\newtheorem{defn}{定義}
27 \newenvironment{cslist}{%
28 \leftskip2em\parindent=0pt\def\makelabel##1{{\tt\char92##1}}
29 \def\{{\char`\{}\def\}{\char`\}}
31 \def\item[##1]{\par\smallskip\par\hskip-\leftskip\makelabel{##1}\par}
35 \long\def\@makecaption#1#2{%
36 \vskip\abovecaptionskip
37 \sbox\@tempboxa{{\small #1. #2}}%
38 \ifdim \wd\@tempboxa >\hsize
41 \global \@minipagefalse
42 \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
44 \vskip\belowcaptionskip}
48 \title{The \LuaTeX-ja package}
49 \author{The \LuaTeX-ja project team}
52 \title{\LuaTeX-jaパッケージ}
53 \author{\LuaTeX-jaプロジェクトチーム}
57 basicstyle=\ttfamily\small, pos=o, breaklines=true,
58 numbers=none, rframe={}, basewidth=0.5em
61 \parskip=\smallskipamount
62 \protected\def\Param#1{\textsf{#1}} % parameter name
63 \protected\def\Pkg#1{\underline{\smash{\texttt{#1}}}} % packages/classes
67 \def<#1>{{\normalfont\rm\itshape$\langle$#1$\rangle$}}
74 {\Large\bf This documentation is far from complete. It may have many
75 grammatical (and contextual) errors.}
78 \textbf{\large 本ドキュメントはまだまだ未完成です.}
82 %<en>\part{User's manual}
83 %<ja>\part{ユーザーズマニュアル}
85 %<en>\section{Introduction}
89 The \LuaTeX-ja package is a macro package for typesetting high-quality
90 Japanese documents when using \LuaTeX.
93 \LuaTeX-jaパッケージは,次世代標準\TeX である\LuaTeX の上で,\pTeX と同等
94 /それ以上の品質の日本語組版を実現させようとするマクロパッケージである.
97 %<en>\subsection{Backgrounds}
101 Traditionally, ASCII \pTeX, an extension of \TeX, and its derivatives
102 are used to typeset Japanese documents in \TeX. \pTeX\ is an engine
103 extension of \TeX: so it can produce high-quality Japanese documents
104 without using very complicated macros. But this point is a mixed
105 blessing: \pTeX\ is left behind from other extensions of \TeX,
106 especially \eTeX\ and pdf\TeX, and from changes about
107 Japanese processing in computers (\textit{e.g.}, the UTF-8 encoding).
110 従来,「\TeX を用いて日本語組版を行う」といったとき,エンジンとしては
111 ASCII \pTeX やそれの拡張物が用いられることが一般的であった.\pTeX は\TeX
112 のエンジン拡張であり,(少々仕様上不便な点はあるものの)商業印刷の分野に
113 も用いられるほどの高品質な日本語組版を可能としている.だが,それは弱点に
114 もなってしまった:\pTeX という(組版的に)満足なものがあったため,海外で
115 行われている数々の\TeX の拡張──例えば\eTeX や\pdfTeX ──や,TrueType,
116 OpenType, Unicodeといった計算機で日本語を扱う際の状況の変化に追従すること
121 Recently extensions of \pTeX, namely \upTeX\ (Unicode-implementation
122 of \pTeX) and \epTeX\ (merging of \pTeX\ and
123 \eTeX\ extension), have developed to fill those gaps to some
124 extent, but gaps still exist.
127 ここ数年,若干状況は改善されてきた.現在手に入る大半の\pTeX バイナリでは
128 外部UTF-8入力が利用可能となり,さらにUnicode化を推進し,\pTeX の内部処理
129 までUnicode化した\upTeX も開発されている.また,\pTeX に\eTeX 拡張をマー
130 ジした\epTeX も登場し,\TeX\ Live\ 2011では\pLaTeX が\epTeX の上で動作す
131 るようになった.だが,\pdfTeX 拡張(pdf直接出力やmicro-typesetting)を
132 \pTeX に対応させようという動きはなく,海外とのgapは未だにあるのが現状であ
137 However, the appearance of \LuaTeX\ changed the whole situation. With
138 using Lua `callbacks', users can customize the internal processing of
139 \LuaTeX. So there is no need to modify sources of engines to
140 support Japanese typesetting: to do this, we only have to write Lua
141 scripts for appropriate callbacks.
144 しかし,\LuaTeX の登場で,状況は大きく変わることになった.Luaコードで
145 `callback'を書くことにより,\LuaTeX の内部処理に割り込みをかけることが可
146 能となった.これは,エンジン拡張という真似をしなくても,Luaコードとそれに
147 関する\TeX マクロを書けば,エンジン拡張とほぼ同程度のことができるようになっ
148 たということを意味する.\LuaTeX-jaは,このアプローチによってLuaコード・
149 \TeX マクロによって日本語組版を\LuaTeX の上で実現させようという目的で開発
153 %<en>\subsection{Major Changes from \pTeX}
154 %<ja>\subsection{\pTeX からの主な変更点}
157 The \LuaTeX-ja package is under much influence of \pTeX\ engine. The initial
158 target of development was to implement features of \pTeX. However,
159 \emph{\LuaTeX-ja is not a just porting of \pTeX; unnatural
160 specifications/behaviors of \pTeX\ were not adopted}.
163 \LuaTeX-jaは,\pTeX に多大な影響を受けている.初期の開発目標は,\pTeX の機
164 能をLuaコードにより実装することであった.しかし,開発が進むにつれ,\pTeX
165 の完全な移植は不可能であり,また\pTeX における実装がいささか不可解になっ
166 ているような状況も発見された.そのため,\textbf{\LuaTeX-ja は,もはや
167 \pTeX の完全な移植は目標とはしない.\pTeX における不自然な仕様・挙動があ
172 The followings are major changes from \pTeX:
175 以下は \pTeX からの主な変更点である.
180 \item A Japanese font is a tuple of a `real' font, a Japanese font
181 metric (\textbf{JFM}, for short), and an optional string called
185 \item 和文フォントは「実際の」フォント,和文フォントメトリック(JFM と呼ぶ),そ
186 して `variation' と呼ばれる文字列の組である.
190 \item In \pTeX, a linebreak after Japanese character is ignored (and
191 doesn't yield a space), since linebreaks (in source files) are
192 permitted almost everywhere in Japanese texts. However, \LuaTeX-ja
193 doesn't have this function completely, because of a specification
197 \item 日本語の文書中では改行はほとんどどこでも許されるので,\pTeX では和文文字
198 直後の改行は無視される(スペースが入らない)ようになっていた.しかし,
199 \LuaTeX-ja では \LuaTeX の仕様のためにこの機能は完全には実装されていない.
203 \item The insertion process of glues/kerns between two Japanese
204 characters and between a Japanese character and other characters
205 (we refer these glues/kerns as \textbf{JAglue}) is rewritten from
209 \item 2つの和文文字の間,和文文字と欧文文字の間に入るグルー/カーン
210 (\textbf{JAglue} と呼ぶ)の挿入処理が0から書き直されている.
215 \item As \LuaTeX's internal character handling is `node-based'
216 (\textit{e.g.}, \verb+of{}fice+ doesn't prevent ligatures), the
217 insertion process of \textbf{JAglue} is now `node-based'.
220 \item \LuaTeX の内部での文字の扱いが「ノードベース」になっているように(例えば,
221 \verb+of{}fice+ で合字は抑制されない),\textbf{JAglue} の挿入処理も
226 \item Furthermore, nodes between two characters which have no effects in
227 linebreak (\textit{e.g.}, \verb+\special+ node) are ignored in the
231 \item さらに,2つの文字の間にある行末では効果を持たないノード(例えば
232 \verb+\special+ ノード)は挿入処理中では無視される.
236 \item In the process, two Japanese fonts which differ in their `real'
237 fonts only are identified.
240 \item 処理中では,2つの和文フォントは「実際の」フォントが異なる場合のみ区別され
246 \item At the present, vertical typesetting (\emph{tategaki}), is not
247 supported in \LuaTeX-ja.
250 \item 現時点では,縦書きは \LuaTeX-ja ではサポートされていない.
256 For detailed information, see Part~\ref{part-imp}.
259 詳細については第 \ref{part-imp} 部を見よ.
262 %<en>\subsection{Notations}
263 %<ja>\subsection{用語と記法}
266 In this document, the following terms and notations are used:
269 本ドキュメントでは,以下の用語と記法を用いる:
274 \item Characters are divided into two types:
281 \item \textbf{JAchar}: standing for Japanese characters such as
282 Hiragana, Katakana, Kanji and other punctuation marks for
286 \item \textbf{JAchar}: ひらがな,カタカナ,漢字,和文用の約物といった和文文字の
291 \item \textbf{ALchar}: standing for all other characters like alphabets.
294 \item \textbf{ALchar}: アルファベットを始めとする,その他全ての文字を指す.
299 We say `alphabetic fonts' for fonts used in \textbf{ALchar}, and `Japanese fonts' for fonts used in \textbf{JAchar}.
302 そして,\textbf{ALchar} に用いられるフォントを「欧文フォント」と呼び,
303 \textbf{JAchar} に用いられるフォントを「和文フォント」と呼ぶ.
307 \item A word in a sans-serif font (like \Param{prebreakpenalty})
308 means an internal parameter for Japanese typesetting, and it
309 is used as a key in \verb+\ltjsetparameter+ command.
312 \item サンセリフ体で書かれた語(例:\Param{prebreakpenalty})は日本語組版用の
313 パラメータを表し,これらは \verb+\ltjsetparameter+ コマンドのキーとして
318 \item A word in typewriter font with underline (like \Pkg{fontspec})
319 means a package or a class of \LaTeX.
322 \item 下線付きのタイプライタ体で書かれた語(例:\Pkg{fontspec})は \LaTeX の
327 \item The word `primitive' is used not only for primitives in \LuaTeX,
328 but also for control sequences that defined in the core module of
332 \item 「プリミティブ」という語を,\LuaTeX のプリミティブだけではなく \LuaTeX-ja
333 のコアモジュールで定義されたコントロールシーケンスに対しても用いる.
337 \item In this document, natural numbers start from~0.
340 \item 本ドキュメントでは,自然数は0から始まる.
344 %<en>\subsection{About the project}
345 %<ja>\subsection{プロジェクトについて}
348 \paragraph{Project Wiki} Project Wiki is under construction.
351 \paragraph{プロジェクト Wiki} プロジェクト Wiki は構築中である.
356 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28en%29} (English)
357 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage} (Japanese)
362 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage}(日本語)
363 \item \url{http://sourceforge.jp/projects/luatex-ja/wiki/FrontPage%28en%29}(英語)
368 This project is hosted by SourceForge.JP.
371 本プロジェクトは SourceForge.JP のサービスを用いて運営されている.
374 %<en>\paragraph{Members}\
375 %<ja>\paragraph{開発メンバー}\
377 \begin{multienumerate}
378 \def\labelenumi{$\bullet$}
379 \mitemxxx{Hironori KITAGAWA}{Kazuki MAEDA}{Takayuki YATO}
380 \mitemxxx{Yusuke KUROKI}{Noriyuki ABE}{Munehiro YAMAMOTO}
381 \mitemx{Tomoaki HONDA}
385 \begin{multienumerate}
386 \def\labelenumi{$\bullet$}
387 \mitemxxx{北川 弘典}{前田 一貴}{八登 崇之}
388 \mitemxxx{黒木 裕介}{阿部 紀行}{山本 宗宏}
394 % \paragraph{Acknowledgments} -- 挿入するならここ
397 %<en>\section{Getting Started}
399 %<en>\subsection{Installation}
400 %<ja>\subsection{インストール}
401 To install the \LuaTeX-ja\ package, you will need:
403 \item \LuaTeX\ (version 0.65.0-beta or later) and its supporting packages.\\
404 If you are using \TeX~Live~2011 or current W32\TeX, you don't have to worry.
405 \item The source archive of \LuaTeX-ja, of course{\tt:)}
408 The installation methods are as follows:
410 \item Download the source archive.
412 At the present, \LuaTeX-ja has no official release, so you have to retrieve
413 the archive from the repository.
414 You can retrieve the Git repository via
416 $ git clone git://git.sourceforge.jp/gitroot/luatex-ja/luatexja.git
418 or download the archive of HEAD in \texttt{master} branch from
420 \url{http://git.sourceforge.jp/view?p=luatex-ja/luatexja.git;a=snapshot;h=HEAD;sf=tgz}.
423 Note that the forefront of development may not be in \texttt{master} branch.
424 \item Extract the archive. You will see {\tt src/} and several other sub-directories.
425 \item Copy all the contents of {\tt src/} into one of your \texttt{TEXMF} tree.
426 \item If {\tt mktexlsr} is needed to update the filename database, make it so.
429 %<en>\subsection{Cautions}
430 %<ja>\subsection{注意点}
432 \item The encoding of your source file must be UTF-8. No other
433 encodings, such as EUC-JP or Shift-JIS, are not supported.
434 \item May be conflict with other packages.
436 For example, the default setting of \textbf{JAchar} in the present
437 version does not coexist with the \Pkg{unicode-math}
438 package. Putting the following line in preamble makes that
439 mathematical symbols will be typeset correctly, but several
440 Japanese characters will be treated as an \textbf{ALchar} as
443 \ltjsetparameter{jacharrange={-3, -8}}
447 %<en>\subsection{Using in plain \TeX}
448 %<ja>\subsection{plain \TeX で使う}
450 To use \LuaTeX-ja in plain \TeX, simply put the following at the beginning of the document:
455 This does minimal settings (like {\tt ptex.tex}) for typesetting Japanese documents:
457 \item The following 6~Japanese fonts are preloaded:
459 \begin{tabular}{ccccc}
461 \textbf{classification}&\textbf{font name}&\bf `10\,pt'&\bf`7\,pt'&\bf`5\,pt'\\\midrule
462 \emph{mincho}&Ryumin-Light &\verb+\tenmin+&\verb+\sevenmin+&\verb+\fivemin+\\
463 \emph{gothic}&GothicBBB-Medium&\verb+\tengt+ &\verb+\sevengt+ &\verb+\fivegt+\\
468 \item The `Q' is a unit used in Japanese phototypesetting, and
469 $1\,\textrm{Q}=0.25\,\textrm{mm}$. This length is stored in a
470 dimension \verb+\jQ+.
472 \item It is widely accepted that the font `Ryumin-Light' and
473 `GothicBBB-Medium' aren't embedded into PDF files, and PDF reader
474 substitute them by some external Japanese fonts (\textit{e.g.},
475 Kozuka Mincho is used for Ryumin-Light in Adobe Reader). We adopt this custom to
477 \item A character in an alphabetic font is generally smaller than a
478 Japanese font in the same size. So actual size specification of
479 these Japanese fonts is in fact smaller than that of alphabetic
480 fonts, namely scaled by 0.962216.
482 \item The amount of glue that are inserted between a \textbf{JAchar} and
483 an \textbf{ALchar} (the parameter \Param{xkanjiskip}) is set to
485 (0.25\cdot 13.5\,\textrm{Q})^{+1\,\text{pt}}_{-1\,\text{pt}}
486 = {27\over 32}\,\mathrm{mm}^{+1\,\text{pt}}_{-1\,\text{pt}}.
490 %<en>\subsection{Using in \LaTeX}
491 %<ja>\subsection{\LaTeX で使う}
494 Using in \LaTeXe\ is basically same. To set up the minimal environment
495 for Japanese, you only have to load {\tt luatexja.sty}:
497 \usepackage{luatexja}
499 It also does minimal settings (counterparts in \pLaTeX\ are {\tt
500 plfonts.dtx} and {\tt pldefs.ltx}):
503 \item {\tt JY3} is the font encoding for Japanese fonts (in horizontal direction).\\
504 When vertical typesetting is supported by \LuaTeX-ja in the future, {\tt JT3} will be used for vertical fonts.
505 \item Two font families {\tt mc} and {\tt gt} are defined:
507 \begin{tabular}{ccccc}
509 \textbf{classification}&\textbf{family}&\verb+\mdseries+&\verb+\bfseries+&\textbf{scale}\\\midrule
510 \emph{mincho}&\tt mc&Ryumin-Light &GothicBBB-Medium&0.962216\\
511 \emph{gothic}&\tt gt&GothicBBB-Medium&GothicBBB-Medium&0.962216\\
515 Remark that the bold series in both family are same as the medium series of \emph{gothic} family.
516 This is a convention in \pLaTeX.
518 \item Japanese characters in math mode are typeset by the font family {\tt mc}.
521 However, above settings are not sufficient for Japanese-based
522 documents. To typeset Japanese-based documents, You are better to use
523 class files other than {\tt article.cls}, {\tt book.cls}, and so on. At
524 the present, we have the counterparts of \Pkg{jclasses} (standard
525 classes in \pLaTeX) and \Pkg jsclasses (classes by Haruhiko
526 Okumura), namely, \Pkg{ltjclasses} and \Pkg{ltjsclasses}.
528 \paragraph{{\tt\char92 CID, {\tt\char92 UTF}} and macros in OTF package}
529 Under \pTeX, \Pkg{otf} package (developed by Shuzaburo Saito) is
530 used for typesetting characters which is in Adobe-japan1-6 CID but not
531 in JIS~X~0208. Since this package is widely used, \LuaTeX-ja
532 supports some of functions in \Pkg{otf} package.
535 森\UTF{9DD7}外と内田百\UTF{9592}とが\UTF{9AD9}島屋に行く。
537 \CID{7652}飾区の\CID{13706}野家,
540 %lltjlisting.sty要修正?:↑「森」の直後で改行.
543 %<en>\subsection{Changing Fonts}
544 %<ja>\subsection{フォントの変更}
546 \paragraph{Remark: Japanese Characters in Math Mode}
547 Since \pTeX\ supports Japanese characters in math mode, there are
548 sources like the following:
551 $f_{高温}$~($f_{\text{high temperature}}$).
552 \[ y=(x-1)^2+2\quad{}よって\quad y>0 \]
553 $5\in{}素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
556 We (the project members of \LuaTeX-ja) think that using
557 Japanese characters in math mode are allowed if and only if these are used as identifiers.
558 In this point of view,
560 \item The lines 1~and~2 above are not correct, since `高温' in above is used as a textual label, and
561 `よって' is used as a conjunction.
562 \item However, the line~3 is correct, since `素' is used as an identifier.
564 Hence, in our opinion, the above input should be corrected as:
567 ($f_{\text{high temperature}}$).
569 \mathrel{\text{よって}}\quad y>0 \]
570 $5\in{}素:=\{\,p\in\mathbb N:\text{$p$ is a prime}\,\}$.
572 %BUG?: \{\}がなければ「素」がでない.上の段落の「よって」もでてない.
573 We also believe that using Japanese characters as identifiers is rare,
574 hence we don't describe how to change Japanese fonts in math mode in
575 this chapter. For the method, please see Part~\ref{part-ref}.
578 \paragraph{plain \TeX}
579 To change Japanese fonts in plain \TeX, you must use the primitive
580 \verb+\jfont+. So please see Part~\ref{part-ref}.
584 For \LaTeXe, \LuaTeX-ja simply adopted the font selection system from that
585 of \pLaTeXe\ (in {\tt plfonts.dtx}).
587 \item Two control sequences \verb+\mcdefault+ and \verb+\gtdefault+ are
588 used to specify the default font families for \emph{mincho} and
589 \emph{gothic}, respectively. Default values: \texttt{mc} for
590 \verb+\mcdefault+ and \texttt{gt} for \verb+\gtdefault+.
591 \item Commands \verb+\fontfamily+, \verb+\fontseries+,
592 \verb+\fontshape+ and \verb+\selectfont+ can be used to change
593 attributes of Japanese fonts.
595 \begin{tabular}{cccccc}
597 &\textbf{encoding}&\textbf{family}&\textbf{series}&\textbf{shape}&\textbf{selection}\\\midrule
599 &\verb+\romanencoding+&\verb+\romanfamily+&\verb+\romanseries+&\verb+\romanshape+
602 &\verb+\kanjiencoding+&\verb+\kanjifamily+&\verb+\kanjiseries+&\verb+\kanjishape+
604 both&---&--&\verb+\fontseries+&\verb+\fontshape+&---\\
605 auto select&\verb+\fontencoding+&\verb+\fontfamily+&---&---&\verb+\usefont+\\
611 ここで,\verb+\fontencoding{<encoding>}+は,引数により和文側か欧文側かの
612 どちらかが切り替わる.例えば,次の入力で最初の\verb+\fontencoding+
613 の呼び出しは和文フォントのエンコーディングを\texttt{JT3}に変更し,
614 2回目の呼びだしでは欧文フォント側を\texttt{T1}へと変更する.
616 \fontencoding{JY3}\fontencoding{T1}
618 \verb+\fontfamily+も引数により和文側,欧文側,\textbf{あるいは両方}のフォ
620 詳細はSubsection~\ref{ssub-nfsspat}を参照すること.
623 \item For defining a Japanese font family, use
624 \verb+\DeclareKanjiFamily+ instead of
625 \verb+\DeclareFontFamily+. However, in the present implementation,
626 using \verb+\DeclareFontFamily+ doesn't cause any problem.
630 To coexist with the \Pkg{fontspec} package, it is needed to load
631 \Pkg{luatexja-fontspec} package in the preamble. This additional
632 package automatically loads \Pkg{luatexja} and \Pkg{fontspec}
635 In \Pkg{luatexja-fontspec} package, the following 7~commands are defined as
636 counterparts of original commands in the \Pkg{fontspec} package:
638 \begin{tabular}{ccccc}
641 &\verb+\jfontspec+&\verb+\setmainjfont+&\verb+\setsansjfont+&\verb+\newjfontfamily+\\
643 &\verb+\fontspec+&\verb+\setmainfont+&\verb+\setsansfont+&\verb+\newfontfamily+\\
646 &\verb+\newjfontface+&\verb+\defaultjfontfeatures+&\verb+\addjfontfeatures+\\
648 &\verb+\newfontface+&\verb+\defaultfontfeatures+&\verb+\addfontfeatures+\\
655 Note that there is no command named \verb+\setmonojfont+, since it is
656 popular for Japanese fonts that nearly all Japanese glyphs have same
657 widths. Also note that the kerning feature is set off by default in
658 these 7~commands, since this feature and \textbf{JAglue} will clash (see
661 %<en>\section{Changing Parameters}
662 %<ja>\section{パラメータの変更}
663 There are many parameters in \LuaTeX-ja. And due to the behavior of \LuaTeX,
664 most of them are not stored as internal register of \TeX, but as an
665 original storage system in \LuaTeX-ja. Hence, to assign or acquire those
666 parameters, you have to use commands \verb+\ltjsetparameter+ and
667 \verb+\ltjgetparameter+.
669 %<en>\subsection{Editing the range of \textbf{JAchar}s}
670 %<ja>\subsection{\textbf{JAchar} の範囲の設定}
672 To edit the range of \textbf{JAchar}s, You have to assign a non-zero
673 natural number which is less than 217 to the character range first. This
674 can be done by using \verb+\ltjdefcharrange+ primitive. For example, the
675 next line assigns whole characters in Supplementary Multilingual Plane
676 and the character `漢' to the range number~100.
678 \ltjdefcharrange{100}{"10000-"1FFFF,`漢}
680 This assignment of numbers to ranges are always global, so you should
681 not do this in the middle of a document.
683 If some character has been belonged to some non-zero numbered range,
684 this will be overwritten by the new setting. For example, whole SMP
685 belong the range~4 in the default setting of \LuaTeX-ja, and if you
686 specify the above line, then SMP will belong the range~100 and be
687 removed from the range~4.
689 After assigning numbers to ranges, the {\sf jacharrange} parameter can
690 be used to customize which character range will be treated as ranges of
691 \textbf{JAchar}s, as the following line (this is just the default
692 setting of \LuaTeX-ja):
694 \ltjsetparameter{jacharrange={-1, +2, +3, -4, -5, +6, +7, +8}}
696 The argument to {\sf jacharrange} parameter is a list of integer. Negative interger $-n$ in the list means that `the character range~$n$ is ...'.
698 \paragraph{Default Setting}
699 Lua\TeX-ja predefines eight character ranges for convinience. They are
700 determined from the following data:
702 \item Blocks in Unicode~6.0.
703 \item The \texttt{Adobe-Japan1-UCS2} mapping between a CID Adobe-Japan1-6 and Unicode.
704 \item The \texttt{PXbase} bundle for \upTeX\ by Takayuki Yato.
707 Now we describe these eight ranges. The alphabet `J' or `A' after the
708 number shows whether characters in the range is treated as
709 \textbf{JAchar}s or not by default. These settings are similar to \texttt{prefercjk} ...
711 \item[Range~8${}^{\text{J}}$] Symbols in the intersection of the upper half of ISO~8859-1
712 (Latin-1 Supplement) and JIS~X~0208 (a basic character set for Japanese). This character range
713 consists of the following charatcers:
716 \def\ch#1#2{\item \char"#1\ ({\tt U+00#1}, #2)}%"
717 \ch{A7}{Section Sign}
718 \ch{A8}{Umlaut or diaeresis}
720 \ch{B1}{Plus-minus sign}
721 \ch{B4}{Spacing acute}
722 \ch{B6}{Paragraph sign}
723 \ch{D7}{Multiplication sign}
724 \ch{F7}{Division Sign}
727 \item[Range~1${}^{\text{A}}$] Latin characters that some of them are included in Adobe-Japan1-6.
728 This range consist of the following Unicode ranges, \emph{except characters in the range~8 above}:
731 \item {\tt U+0080}--{\tt U+00FF}: Latin-1 Supplement
732 \item {\tt U+0100}--{\tt U+017F}: Latin Extended-A
733 \item {\tt U+0180}--{\tt U+024F}: Latin Extended-B
734 \item {\tt U+0250}--{\tt U+02AF}: IPA Extensions
735 \item {\tt U+02B0}--{\tt U+02FF}: Spacing Modifier Letters
736 \item {\tt U+0300}--{\tt U+036F}: Combining Diacritical Marks
737 \item {\tt U+1E00}--{\tt U+1EFF}: Latin Extended Additional
741 \item[Range~2${}^{\text{J}}$] Greek and Cyrillic letters. JIS~X~0208 (hence most of Japanese
742 fonts) has some of these characters.
745 \item {\tt U+0370}--{\tt U+03FF}: Greek and Coptic
746 \item {\tt U+0400}--{\tt U+04FF}: Cyrillic
747 \item {\tt U+1F00}--{\tt U+1FFF}: Greek Extended
751 \item[Range~3${}^{\text{J}}$] Punctuations and Miscellaneous symbols. The block list is
752 indicated in Table~\ref{table-rng3}.
754 \caption{Unicode blocks in predefined character range~3.}\label{table-rng3}
755 \catcode`\"=13\def"#1#2#3#4{{\tt U+#1#2#3#4}}%"
757 \begin{tabular}{llll}
758 "2000--"206F&General Punctuation&
759 "2070--"209F&Superscripts and Subscripts\\
760 "20A0--"20CF&Currency Symbols&
761 "20D0--"20FF&Comb.\ Diacritical Marks for Symbols\\
762 "2100--"214F&Letterlike Symbols&
763 "2150--"218F&Number Forms\\
765 "2200--"22FF&Mathematical Operators\\
766 "2300--"23FF&Miscellaneous Technical&
767 "2400--"243F&Control Pictures\\
768 "2500--"257F&Box Drawing&
769 "2580--"259F&Block Elements\\
770 "25A0--"25FF&Geometric Shapes&
771 "2600--"26FF&Miscellaneous Symbols\\
772 "2700--"27BF&Dingbats&
773 "2900--"297F&Supplemental Arrows-B\\
774 "2980--"29FF&Misc.\ Mathematical Symbols-B&
775 "2B00--"2BFF&Miscellaneous Symbols and Arrows\\
776 "E000--"F8FF&Private Use Area&
780 \item[Range~4${}^{\text{A}}$] Characters usually not in Japanese fonts. This range consists
781 of almost all Unicode blocks which are not in other
782 predefined ranges. Hence, instead of showing the block list,
783 we put the definition of this range itself:
785 \ltjdefcharrange{4}{%
786 "500-"10FF, "1200-"1DFF, "2440-"245F, "27C0-"28FF, "2A00-"2AFF,
787 "2C00-"2E7F, "4DC0-"4DFF, "A4D0-"A82F, "A840-"ABFF, "FB50-"FE0F,
788 "FE20-"FE2F, "FE70-"FEFF, "FB00-"FB4F, "10000-"1FFFF} % non-Japanese
790 \item[Range~5${}^{\text{A}}$] Surrogates and Supplementary Private Use Areas.
791 \item[Range~6${}^{\text{J}}$] Characters used in Japanese. The block list is indicated in Table~\ref{table-rng6}.
793 \caption{Unicode blocks in predefined character range~6.}\label{table-rng6}
794 \catcode`\"=13\def"#1#2#3#4{{\tt U+#1#2#3#4}}%"
796 \begin{tabular}{llll}
797 "2460--"24FF&Enclosed Alphanumerics&
798 "2E80--"2EFF&CJK Radicals Supplement\\
799 "3000--"303F&CJK Symbols and Punctuation&
800 "3040--"309F&Hiragana\\
801 "30A0--"30FF&Katakana&
802 "3190--"319F&Kanbun\\
803 "31F0--"31FF&Katakana Phonetic Extensions&
804 "3200--"32FF&Enclosed CJK Letters and Months\\
805 "3300--"33FF&CJK Compatibility&
806 "3400--"4DBF&CJK Unified Ideographs Extension A\\
807 "4E00--"9FFF&CJK Unified Ideographs&
808 "F900--"FAFF&CJK Compatibility Ideographs\\
809 "FE10--"FE1F&Vertical Forms&
810 "FE30--"FE4F&CJK Compatibility Forms\\
811 "FE50--"FE6F&Small Form Variants&
812 "{20}000--"{2F}FFF&(Supplementary Ideographic Plane)
816 \item[Range~7${}^{\text{J}}$] Characters used in CJK languages, but not included in Adobe-Japan1-6.
817 The block list is indicated in Table~\ref{table-rng7}.
819 \caption{Unicode blocks in predefined character range~7.}\label{table-rng7}
820 \catcode`\"=13\def"#1#2#3#4{{\tt U+#1#2#3#4}}%"
822 \begin{tabular}{llll}
823 "1100--"11FF&Hangul Jamo&
824 "2F00--"2FDF&Kangxi Radicals\\
825 "2FF0--"2FFF&Ideographic Description Characters&
826 "3100--"312F&Bopomofo\\
827 "3130--"318F&Hangul Compatibility Jamo&
828 "31A0--"31BF&Bopomofo Extended\\
829 "31C0--"31EF&CJK Strokes&
830 "A000--"A48F&Yi Syllables\\
831 "A490--"A4CF&Yi Radicals&
832 "A830--"A83F&Common Indic Number Forms\\
833 "AC00--"D7AF&Hangul Syllables&
834 "D7B0--"D7FF&Hangul Jamo Extended-B
841 %<en>\subsection{\Param{kanjiskip} and \Param{xkanjiskip}}
842 %<ja>\subsection{\Param{kanjiskip} と \Param{xkanjiskip}}
844 \textbf{JAglue} is divided into the following three categories:
846 \item Glues/kerns specified in JFM. If \verb+\inhibitglue+ is issued
847 around a Japanese character, this glue will be not inserted at the
849 \item The default glue which inserted between two \textbf{JAchar}s ({\sf
851 \item The default glue which inserted between a \textbf{JAchar} and an
852 \textbf{ALchar} (\Param{xkanjiskip}).
854 The value (a skip) of \Param{kanjiskip} or \Param{xkanjiskip} can be
855 changed as the following.
857 \ltjsetparameter{kanjiskip={0pt plus 0.4pt minus 0.4pt},
858 xkanjiskip={0.25\zw plus 1pt minus 1pt}}
862 It may occur that JFM contains the data of `ideal width of {\sf
863 kanjiskip}' and/or `ideal width of \Param{xkanjiskip}'.
864 To use these data from JFM, set the value of \Param{kanjiskip} or
865 \Param{xkanjiskip} to \verb+\maxdimen+.
867 %<en>\subsection{Insertion Setting of \Param{xkanjiskip}}
868 %<ja>\subsection{\Param{xkanjiskip} の設定の挿入}
869 It is not desirable that \Param{xkanjiskip} is inserted between every
870 boundary between \textbf{JAchar}s and \textbf{ALchar}s. For example,
871 \Param{xkanjiskip} should not be inserted after opening parenthesis
872 (\textit{e.g.}, compare `(あ' and `(\hskip\ltjgetparameter{xkanjiskip}あ').
874 \LuaTeX-ja can control whether \Param{xkanjiskip} can be inserted
875 before/after a character, by changing \Param{jaxspmode} for \textbf{JAchar}s and
876 \Param{alxspmode} parameters \textbf{ALchar}s respectively.
878 \ltjsetparameter{jaxspmode={`あ,preonly}, alxspmode={`\!,postonly}}
882 The second argument {\tt preonly} means `the insertion of
883 \Param{xkanjiskip} is allowed before this character, but not after'.
884 the other possible values are {\tt postonly}, {\tt allow} and {\tt
885 inhibit}. For the compatibility with \pTeX, natural numbers between
886 0~and~3 are also allowed as the second argument\footnote{But we don't
887 recommend this: since numbers 1~and~2 have opposite meanings in
888 \Param{jaxspmode} and \Param{alxspmode}.}.
890 If you want to enable/disable all insertions of \Param{kanjiskip} and
891 \Param{xkanjiskip}, set \Param{autospacing} and \Param{autoxspacing}
892 parameters to {\tt false}, respectively.
895 %<en>\subsection{Shifting Baseline}
896 %<ja>\subsection{ベースラインの移動}
897 To make a match between a Japanese font and an alphabetic font, sometimes
898 shifting of the baseline of one of the pair is needed. In \pTeX, this is achieved
899 by setting \verb+\ybaselineshift+ to a non-zero length (the
900 baseline of alphabetic fonts is shifted below). However, for documents
901 whose main language is not Japanese, it is good to shift the baseline of
902 Japanese fonts, but not that of alphabetic fonts.
903 Because of this, \LuaTeX-ja can independently set the shifting amount
904 of the baseline of alphabetic fonts (\Param{yalbaselineshift}
905 parameter) and that of Japanese fonts (\Param{yjabaselineshift}
909 \vrule width 150pt height 0.4pt depth 0pt\hskip-120pt
910 \ltjsetparameter{yjabaselineshift=0pt, yalbaselineshift=0pt}abcあいう
911 \ltjsetparameter{yjabaselineshift=5pt, yalbaselineshift=2pt}abcあいう
913 Here the horizontal line in above is the baseline of a line.
915 There is an interesting side-effect: characters in different size can be
916 vertically aligned center in a line, by setting two parameters appropriately.
917 The following is an example (beware the value is not well tuned):
921 \ltjsetparameter{yjabaselineshift=-1pt,
922 yalbaselineshift=-1pt}
928 %<en>\subsection{Cropmark}
929 %<ja>\subsection{トンボ}
930 Cropmark is a mark for indicating 4~corners and horizontal/vertical
931 center of the paper. In Japanese, we call cropmark as tombo(w).
932 \pLaTeX\ and this \LuaTeX-ja support `tombow' by their kernel.
933 The following steps are needed to typeset cropmark:
936 \item First, define the banner which will be printed at the upper left
937 of the paper. This is done by assigning a token list to
938 \verb+\@bannertoken+.
940 For example, the following sets banner as `{\tt filename (2012-01-01 17:01)}':
944 \hour\time \divide\hour by 60 \@tempcnta\hour \multiply\@tempcnta 60\relax
945 \minute\time \advance\minute-\@tempcnta
947 \jobname\space(\number\year-\two@digits\month-\two@digits\day
948 \space\two@digits\hour:\two@digits\minute)}%
955 %<en>\part{Reference}
958 %<en>\section{Font Metric and Japanese Font}
959 %<ja>\section{フォントメトリックと日本語フォント}
960 %<en>\subsection{\texttt{\char92jfont} primitive}
961 %<ja>\subsection{\texttt{\char92jfont} プリミティブ}
962 To load a font as a Japanese font, you must use the
963 \verb+\jfont+ primitive instead of~\verb+\font+, while
964 \verb+\jfont+ admits the same syntax used in~\verb+\font+.
965 \LuaTeX-ja automatically loads \Pkg{luaotfload} package,
966 so TrueType/OpenType fonts with features can be used for Japanese fonts:
968 \jfont\tradgt={file:ipaexg.ttf:script=latn;%
969 +trad;-kern;jfm=ujis} at 14pt
973 Note that the defined control sequence
974 (\verb+\tradgt+ in the example above) using \verb+\jfont+ is not a
975 \textit{font\_def} token, hence the input like \verb+\fontname\tradgt+
976 causes a error. We denote control sequences which are defined in
977 \verb+\jfont+ by <jfont\_cs>.
979 \paragraph{Prefix \texttt{psft}}
980 Besides \texttt{file:}\ and \texttt{name:}\ prefixes, \texttt{psft:}\
981 can be used a prefix in \verb+\jfont+ (and~\verb+\font+) primitive.
982 Using this prefix, you can specify a `name-only' Japanese font which
983 will be not embedded to PDF. Typical use of this prefix is to specify
984 the `standard' Japanese fonts, namely, `Ryumin-Light' and
985 `GothicBBB-Medium'. For kerning or other informations, that of Kozuka
986 Mincho Pr6N Regular (this is a font by Adobe Inc., and included in
987 Japanese Font Packs for Adore Reader) will be used.
991 As noted in Introduction, a JFM has measurements of characters and
992 glues/kerns that are automatically inserted for Japanese
993 typesetting. The structure of JFM will be described in the next
994 subsection. At the calling of \verb+\jfont+ primitive, you must specify
995 which JFM will be used for this font by the following keys:
997 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}}
999 Specify the name of JFM. A file named \texttt{jfm-<name>.lua} will be searched and/or loaded.
1001 The followings are JFMs shipped with Lua\TeX-ja:
1003 \item[\tt jfm-ujis.lua] A standard JFM in Lua\TeX-ja. This JFM is
1004 based on \verb+upnmlminr-h.tfm+, a metric for UTF/OTF package that
1005 is used in \upTeX. When you use the \Pkg{luatexja-otf} package, please use this JFM.
1006 \item[\tt jfm-jis.lua] A counterpart for \verb+jis.tfm+, `JIS font
1007 metric' which is widely used in \pTeX. A major difference of
1008 \texttt{jfm-ujis.lua} and this \texttt{jfm-jis.lua} is that
1009 most haracters under \texttt{jfm-ujis.lua} are square-shaped,
1010 while that under \texttt{jfm-jis.lua} are horizontal
1013 \item[\tt jfm-min.lua] A counterpart for \verb+min10.tfm+, which is one
1014 of the default Japanese font metric shipped with \pTeX. There
1015 are notable difference between this JFM and other 2~JFMs, as
1016 shown in Table~\ref{tab-difjfm}.
1019 \item[jfmvar=<string>] Sometimes there is a need that
1023 \caption{Differences between JFMs shipped with \LuaTeX-ja}
1026 \def\r#1{{\jfont\g=psft:Ryumin-Light:jfm=#1 at 14.43324pt \g
1027 \setbox0=\vtop{\hsize=7\zw\noindent ◆◆◆◆◆◆◆
1028 ある日モモちゃんがお使いで迷子になって泣きました.}\copy0
1029 \vrule height 0pt depth \dp0}}
1030 \def\s#1{{\jfont\g=psft:Ryumin-Light:jfm=#1 at 14.43324pt \g
1031 \setbox0=\vtop{\hsize=7\zw\noindent ちょっと!何}\copy0}}
1032 \def\t#1{{\jfont\g=psft:Ryumin-Light:jfm=#1 at 19.24432pt \g
1034 \vrule width 0.4pt height\ht0 depth\dp0\kern-.2pt\copy0
1035 \kern-\wd0\vrule width\wd0height .2pt depth .2pt
1036 \kern-\wd0\raise\ht0\hbox{\vrule width\wd0height .2pt depth .2pt}%
1037 \kern-\wd0\lower\dp0\hbox{\vrule width\wd0height .2pt depth .2pt}%
1038 \kern-.2pt\vrule width 0.4pt height\ht0 depth \dp0}}
1039 \begin{tabular}{rccc}
1041 &\tt jfm-ujis.lua&\tt jfm-jis.lua&\tt jfm-min.lua\\
1043 Example~1&\r{ujis}&\r{jis}&\r{min}\\
1044 Example~2&\s{ujis}&\s{jis}&\s{min}\\
1045 Bounding Box&\t{ujis}&\t{jis}&\t{min}\\
1051 \paragraph{Note: kern feature}\label{para-kern}
1052 Some fonts have information for inter-glyph spacing. However, this
1053 information is not well-compatible with \LuaTeX-ja. More concretely,
1054 this kerning space from this information are inserted \emph{before} the
1055 insertion process of \textbf{JAglue}, and this causes incorrect spacing
1056 between two characters when both a glue/kern from the data in the font
1057 and it from JFM are present.
1060 \item You should specify {\tt -kern} in
1061 {\tt\char92jfont} primitive, when you want to use other font features,
1062 such as {\tt script=...}\,.
1063 \item If you want to use Japanese fonts in proportinal width, and use
1064 information from this font, use \texttt{jfm-prop.lua} for its JFM, and ...
1070 %<en>\subsection{Structure of JFM file}
1071 %<ja>\subsection{JFM ファイルの構造}
1072 A JFM file is a Lua script which has only one function call:
1074 luatexja.jfont.define_jfm { ... }
1076 Real data are stored in the table which indicated above by
1077 \verb+{ ... }+. So, the rest of this subsection are devoted to describe the
1078 structure of this table. Note that all lengths in a JFM file are
1079 floating-point numbers in design-size unit.
1081 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}}
1082 \item[dir=<direction>] (required)
1084 The direction of JFM. At the present, only \texttt{'yoko'} is supported.
1086 \item[zw=<length>] (required)
1088 The amount of the length of the `full-width'.
1090 \item[zh=<length>] (required)
1092 \item[kanjiskip=\{<natural>, <stretch>, <shrink>\}] (optional)
1094 This field specifies the `ideal' amount of \Param{kanjiskip}. As noted
1095 in Subsection~\ref{subs-kskip}, if the parameter
1096 \Param{kanjiskip} is \verb+\maxdimen+, the value specified
1097 in this field is actually used (if this field is not specified in
1098 JFM, it is regarded as 0\,pt). Note that <stretch> and <shrink>
1099 fields are in design-size unit too.
1102 \item[xkanjiskip=\{<natural>, <stretch>, <shrink>\}] (optional)
1104 Like the \Param{kanjiskip} field, this field specifies the `ideal'
1105 amount of \Param{xkanjiskip}.
1109 Besides from above fields, a JFM file have several sub-tables those
1110 indices are natural numbers. The table indexed by~$i\in\omega$ stores
1111 informations of `character class'~$i$. At least, the character class~0 is
1112 always present, so each JFM file must have a sub-table whose index is
1113 \texttt{[0]}. Each sub-table (its numerical index is denoted by $i$) has
1114 the following fields:
1116 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}}
1117 \item[chars=\{<character>, ...\}] (required except character class~0)
1119 This field is a list of characters which are in this character
1120 type~$i$. This field is not required if $i=0$, since all
1121 \textbf{JAchar} which are not in any character class other
1122 than 0 (hence, the character class~0 contains most of
1123 \textbf{JAchar}s). In the list, a character can be
1124 specified by its code number, or by the character itself
1125 (as a string of length~1). Moreover, there are `imaginary
1126 characters' which specified in the list. We will describe these later.
1128 \item[width=<length>, height=<length>, depth=<length>, italic=<length>]\ (required)
1130 Specify width of characters in character class~$i$, height, depth and
1131 the amount of italic correction. All characters in character class~$i$ are regarded that its width, height and depth are
1132 as values of these fields.
1133 But there is one exception: if \texttt{'prop'} is specified in \texttt{width} field, width of a character becomes that of its `real' glyph
1135 \item[left=<length>, down=<length>, align=<align>]\
1137 These fields are for adjusting the position of the `real' glyph. Legal
1138 values of \texttt{align} field are \texttt{'left'},
1139 \texttt{'middle'} and \texttt{'right'}. If one of these
1140 3~fields are omitted, \texttt{left} and \texttt{down} are
1141 treated as~0, and \texttt{align} field is treated as
1143 The effects of these 3~fields are indicated in Figure~\ref{fig-pos}.
1145 In most cases, \texttt{left} and \texttt{down} fields are~0, while
1146 it is not uncommon that the \texttt{align} field is \texttt{'middle'} or \texttt{'right'}.
1147 For example, setting the \texttt{align} field to \texttt{'right'} is practically needed
1148 when the current character class is the class for opening delimiters'.
1150 \begin{minipage}{0.4\textwidth}%
1151 \begin{center}\unitlength=10pt\small
1152 \begin{picture}(15,12)(-1,-4)
1153 \color{black!10!white}% real glyph :step1
1154 \put(0,0){\vrule width 12\unitlength height 8\unitlength depth 3\unitlength}
1156 \color{red!20!white}% real glyph :step1
1157 \put(-1,-1.5){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
1159 \color{red}% real glyph
1161 \put(-1,-1.5){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
1162 \put(5,-1.5){\line(0,1){7}\line(0,-1){2.5}}
1163 \put(-1,5.5){\line(1,0){6}}
1164 \put(-1,-4){\line(1,0){6}}
1166 \color{green!20!white}% real glyph :step1
1167 \put(3,0){\vrule width 6\unitlength height 7\unitlength depth 2.5\unitlength}
1169 \color{black}% real glyph :step1
1171 \put(0,0){\vector(0,1){8}\line(0,-1){3}\vector(1,0){12}}
1172 \put(12,0){\line(0,1){8}\vector(0,-1){3}}
1173 \put(0,8){\line(1,0){12}}
1174 \put(0,-3){\line(1,0){12}}
1175 \put(0.2,4){\makebox(0,0)[l]{\texttt{height}}}
1176 \put(12.2,-1.5){\makebox(0,0)[l]{\texttt{depth}}}
1177 \put(6,0.2){\makebox(0,0)[b]{\texttt{width}}}
1179 \color{green!50!black}% real glyph :step1
1181 \put(3,0){\vector(0,1){7}\vector(0,-1){2.5}\vector(1,0){6}}
1182 \put(9,0){\line(0,1){7}\line(0,-1){2.5}}
1183 \put(3,7){\line(1,0){6}}
1184 \put(3,-2.5){\line(1,0){6}}
1185 \newsavebox{\eqdist}
1186 \savebox{\eqdist}(0,0)[b]{%
1188 \put(-0.08,0.2){\line(0,-1){0.4}}%
1189 \put(0.08,0.2){\line(0,-1){0.4}}}
1190 \put(1.5,0){\usebox{\eqdist}}
1191 \put(10.5,0){\usebox{\eqdist}}
1193 \color{blue}% shifted
1195 \put(3,-1.5){\vector(-1,0){4}}
1196 \put(1,-1.7){\makebox(0,0)[t]{\texttt{left}}}
1197 \put(3,0){\vector(0,-1){1.5}}
1198 \put(3.2,-0.75){\makebox(0,0)[l]{\texttt{down}}}
1202 \begin{minipage}{0.6\textwidth}%
1203 Consider a node containing Japanese character whose value of the \texttt{align}
1204 field is \texttt{'middle'}.
1206 \item The black rectangle is a frame of the node.
1207 Its width, height and depth are specified by JFM.
1208 \item Since the \texttt{align} field is \texttt{'middle'},
1209 the `real' glyph is centered horizontally (the green rectangle).
1210 \item Furthermore, the glyph is shifted according to values of fields
1211 \texttt{left} and \texttt{down}. The ultimate position of the real
1212 glyph is indicated by the red rectangle.
1215 \caption{The position of the `real' glyph.}
1220 \item[kern={\{[$j$]=<kern>, ...\}}]
1222 \item[glue={\{[$j$]=\{<width>, <stretch>, <shrink>\}, ...\}}]
1226 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}}
1227 \item['lineend'] An ending of a line.
1228 \item['diffmet'] Used at a boundary between two \textbf{JAchar}s whose JFM or size is different.
1229 \item['boxbdd'] The beginning/ending of a horizontal box, and the beginging of a noindented paragraph.
1230 \item['parbdd'] The beginning of an (indented) paragraph.
1231 \item['jcharbdd'] A boundary between \textbf{JAchar} and anything else
1232 (such as \textbf{ALchar}, kern, glue, ...).
1233 \item[$-1$] The left/right boundary of an inline math formula.
1238 上で説明した通り,\texttt{chars}フィールド中にはいくつかの「特殊文字」も
1239 指定可能である.これらは,大半が\pTeX のJFMグルーの挿入処理ではみな「文字
1240 クラス0の文字」として扱われていた文字であり,その結果として\pTeX より細か
1241 い組版調整ができるようになっている.以下のその一覧を述べる:
1242 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}}
1243 \item['lineend'] 行の終端を表す.
1246 \item['boxbdd'] hboxの先頭と末尾,及びインデントされていない
1247 (\verb+\noindent+で開始された)段落の先頭を表す.
1248 \item['parbdd'] 通常の(\verb+\noindent+で開始されていない)段落の先頭.
1249 \item['jcharbdd'] 和文文字と「その他のもの」(欧文文字,glue,kern等)との境界.
1250 \item[$-1$] 行中数式と地の文との境界.
1253 \paragraph{\pTeX 用和文フォントメトリックの移植}
1254 以下に,\pTeX 用和文フォントメトリックを\LuaTeX-ja用に移植する場合の注意点を挙げておく.
1256 \item 実際に出力される和文フォントのサイズがdesign sizeとなる.
1257 このため,例えば$1\,\textrm{zw}$がdesign sizeの0.962216倍であるJISフォン
1260 \item JFM中の全ての数値を$1/0.962216$倍しておく.
1261 \item \TeX ソース中で使用するところで,サイズ指定を0.962216倍にする.
1262 \LaTeX でのフォント宣言なら,例えば次のように:
1264 \DeclareFontShape{JY3}{mc}{m}{n}{<-> s*[0.962216] psft:Ryumin-Light:jfm=jis}{}
1267 \item 上に述べた特殊文字は,\texttt{'boxbdd'}を除き文字クラスを全部0とする
1269 \item \texttt{'boxbdd'}については,それのみで一つの文字クラスを形成し,その
1270 文字クラスに関してはglue/kernの設定はしない.
1273 hboxの先頭・末尾とインデントされていない(\verb+\noindent+で開始さ
1274 れた)段落の先頭にはJFMグルーは入らないという仕様を実現させるためである.
1275 \item \pTeX の組版を再現させようというのが目的であれば以上の注意を守れば十分である.
1277 ところで,\pTeX では通常の段落の先頭にJFMグルーが残るという仕様があるので,
1278 段落先頭の開き括弧は全角二分下がりになる.全角下がりを実現させるに
1279 は,段落の最初に手動で\verb+\inhibitglue+を追加するか,あるいは
1280 \verb+\everypar+のhackを行い,それを自動化させるしかなかった.
1282 一方,\LuaTeX-jaでは,\texttt{'parbdd'}によって,それがJFM側で調整できるよ
1283 うになった.例えば,\LuaTeX-ja同梱のJFMのように,\texttt{'boxbdd'}と同じ文字クラスに
1284 \texttt{'parbdd'}を入れれば全角下がりとなる.
1287 \jfont\g=psft:Ryumin-Light:jfm=test \g
1288 \parindent1\zw\noindent{}◆◆◆◆◆
1297 %<en>\subsection{Math Font Family}
1298 %<ja>\subsection{数式フォントファミリ}
1299 \TeX\ handles fonts in math formulas by 16~font families\footnote{Omega,
1300 Aleph, \LuaTeX~and $\varepsilon$-\kern-.125em(u)\pTeX can handles 256~families, but
1301 an external package is needed to support this in plain \TeX\ and
1302 \LaTeX.}, and each family has three fonts:
1303 \verb+\textfont+, \verb+\scriptfont+ and \verb+\scriptscriptfont+.
1305 \LuaTeX-ja's handling of Japanese fonts in math formulas is similar;
1306 Table~\ref{tab-math} shows counterparts to \TeX's primitives for math
1307 font families. There is no relation between the value of
1308 \verb+\fam+ and that of \verb+\jfam+; with appropreate settings,
1309 you can set both \verb+\fam+ and \verb+\jfam+ to~the same value.
1312 \caption{Primitives for Japanese math fonts.}
1314 \begin{center}\def\{{\char`\{}\def\}{\char`\}}
1315 \begin{tabular}{lll}
1317 &Japanese fonts&alphabetic fonts\\
1319 font family&\verb+\jfam+${}\in [0,256)$&\verb+\fam+\\
1320 text size&\tt\Param{jatextfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\verb+\textfont+<fam>=<font\_cs>\\
1321 script size&\tt\Param{jascriptfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\verb+\scriptfont+<fam>=<font\_cs>\\
1322 scriptscript size&\tt\Param{jascriptscriptfont}\,=\{<jfam>,<jfont\_cs>\}&\tt\verb+\scriptscriptfont+<fam>=<font\_cs>\\
1328 %<en>\subsection{Callbacks}
1329 %<ja>\subsection{コールバック}
1330 Like \LuaTeX\ itself, \LuaTeX-ja also has callbacks. These callbacks can
1331 be accessed via \verb+luatexbase.add_to_callback+ function and so on, as other callbacks
1333 {\def\makelabel#1{\bfseries#1}}
1334 \item[\texttt{luatexja.load\_jfm} callback]
1335 With this callback you can overwrite JFMs.
1338 function (<table> jfm_info, <string> jfm_name)
1339 return <table> new_jfm_info
1343 The argument \verb+jfm_info+ contains a table similar to the table in a JFM file, except
1344 this argument has \texttt{chars} field which contains character codes
1345 whose character class is not~0.
1347 An example of this callback is the \texttt{ltjarticle} class, with
1348 forcefully assigning character class~0 to \texttt{'parbdd'}
1349 in the JFM \texttt{jfm-min.lua}. This callback doesn't
1350 replace any code of \LuaTeX-ja.
1352 \item[\texttt{luatexja.define\_font} callback]
1353 This callback and the next callback form a pair, and you can assign letters which don't have
1354 fixed codepoints in Unicode to non-zero character classes.
1355 This \texttt{luatexja.define\_font} callback is called just when new Japanese font is loaded.
1357 function (<table> jfont_info, <number> font_number)
1358 return <table> new_jfont_info
1362 You may assume that \verb+jfont_info+ has the following fields:
1364 \item[\tt jfm] The index number of JFM.
1365 \item[\tt size] Font size in a scaled point (${}=2^{-16}\,\textrm{pt}$).
1366 \item[\tt var] The value specified in \texttt{jfmvar=...} at a call of \verb+\jfont+.
1369 The returned table \verb+new_jfont_info+ also should include these three fields.
1370 The \verb+font_number+ is a font number.
1372 A good example of this and the next callbacks is the \Pkg{luatexja-otf}
1373 package, supporting \verb+"AJ1-xxx"+ form for Adobe-Japan1
1374 CID characters in a JFM. This callback doesn't replace any
1378 \item[\texttt{luatexja.find\_char\_class} callback]
1379 This callback is called just when \LuaTeX-ja inready to determine which
1380 character class a character \verb+chr_code+ belongs.
1381 A function used in this callback should be in the following form:
1382 \begin{lstlisting}[numbers=left]
1383 function (<number> char_class, <table> jfont_info, <number> chr_code)
1384 if char_class~=0 then return char_class
1387 return (<number> new_char_class or 0)
1392 The argument \verb+char_class+ is the result of \LuaTeX-ja's default
1393 routine or previous function calls in this callback, hence
1394 this argument may not be 0. Moreover, the returned
1395 \verb+new_char_class+ should be as same as \verb+char_class+ when \verb+char_class+
1396 is not~0, otherwise you will overwrite the \LuaTeX-ja's
1399 This callback doesn't replace any code of \LuaTeX-ja.
1407 %<en>\section{Parameters}
1408 %<ja>\section{パラメータ}
1409 %<en>\subsection{{\tt\char92 ltjsetparameter} primitive}
1410 %<ja>\subsection{{\tt\char92 ltjsetparameter} プリミティブ}
1411 As noted before, \verb+\ltjsetparameter+ and \verb+\ltjgetparameter+ are
1412 primitives for accessing most parameters of \LuaTeX-ja. One of the main
1413 reason that \LuaTeX-ja didn't adopted the syntax similar to that of \pTeX\
1414 (\textit{e.g.},~\verb+\prebreakpenalty`)=10000+)
1415 is the position of \verb+hpack_filter+ callback in the source
1416 of \LuaTeX, see Section~\ref{sec-para}.
1418 \verb+\ltjsetparameter+ and \verb+\ltjglobalsetparameter+ are primitives
1419 for assigning parameters. These take one argument which is a
1420 \texttt{<key>=<value>} list. Allowed keys are described in the next
1422 The difference between
1423 \verb+\ltjsetparameter+ and \verb+\ltjglobalsetparameter+ is only the
1424 scope of assignment;
1425 \verb+\ltjsetparameter+ does a local assignment and
1426 \verb+\ltjglobalsetparameter+ does a global one.
1427 They also obey the value of \verb+\globaldefs+,
1428 like other assignment.
1430 \verb+\ltjgetparameter+ is the primitive for acquiring parameters. It
1431 always takes a parameter name as first argument, and also takes the
1432 additional argument---a character code, for example---in some cases.
1434 \ltjgetparameter{differentjfm},
1435 \ltjgetparameter{autospacing},
1436 \ltjgetparameter{prebreakpenalty}{`)}.
1438 \emph{The return value of\/ {\normalfont\tt\char92ltjgetparameter} is
1439 always a string}. This is outputted by \texttt{tex.write()}, so any
1440 character other than space~`{\tt\char32}'~(U+0020) has the category code
1441 12~(other), while the space has 10~(space).
1443 %<en>\subsection{List of Parameters}
1444 %<ja>\subsection{パラメータ一覧}
1445 The following is the list of parameters which can be specificated by the
1446 \verb+\ltjsetparameter+ command. [\verb+\cs+] indicates the counterpart
1447 in \pTeX, and symbols beside each parameter has the following meaning:
1449 \item No mark: values at the end of the paragraph or the hbox are
1450 adopted in the whole paragraph/hbox.
1451 \item `\ast' : local parameters, which can change everywhere inside a paragraph/hbox.
1452 \item `\dagger': assignments are always global.
1455 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}}
1456 \item[\Param{jcharwidowpenalty}\,=<penalty>] [\verb+\jcharwidowpenalty+]
1458 Penalty value for supressing orphans. This penalty is inserted just
1459 after the last \textbf{JAchar} which is not regarded as a
1460 (Japanese) punctuation mark.
1462 \item[\Param{kcatcode}\,=\{<chr\_code>,<natural number>\}]\
1464 An additional attributes having each character whose character code is <chr\_code>.
1465 At the present version, the lowermost bit of <natural number> indicates
1466 whether the character is considered as a punctuation mark
1467 (see the description of \Param{jcharwidowpenalty} above).
1470 \item[\Param{prebreakpenalty}\,=\{<chr\_code>,<penalty>\}] [\verb+\prebreakpenalty+]\
1472 文字コード<chr\_code>の\textbf{JAchar}が行頭にくることを抑止するために,
1473 この文字の前に挿入/追加されるペナルティの量を指定する.
1475 例えば閉じ括弧「〗」は絶対に行頭にきてはならないので,標準で読み込まれる
1476 \texttt{luatexja-kinsoku.tex}において
1478 \ltjsetparameter{prebreakpenalty={`〙,10000}}
1480 と,最大値の10000が指定されている.他にも,小書きのカナなど,絶対禁止とい
1481 うわけではないができれば行頭にはきて欲しくない場合に,0と
1482 10000の間の値を指定するのも有用であろう.
1484 \ltjsetparameter{prebreakpenalty={`ゕ,150}}
1488 \item[\Param{postbreakpenalty}\,=\{<chr\_code>,<penalty>\}] [\verb+\postbreakpenalty+]
1490 文字コード<chr\_code>の\textbf{JAchar}が行末にくることを抑止するために,
1491 この文字の後に挿入/追加されるペナルティの量を指定する.
1493 \pTeX では,\verb+\prebreakpenalty+, \verb+\postbreakpenalty+において,
1495 \item 一つの文字に対して,pre, postどちらか一つしか指定することができなかっ
1497 \item pre, post合わせて256文字分の情報を格納することしかできなかった.
1499 という制限があったが,\LuaTeX-ja ではこれらの制限は解消されている.
1502 \item[\Param{jatextfont}\,=\{<jfam>,<jfont\_cs>\}] [\verb+\textfont+ in \TeX]
1503 \item[\Param{jascriptfont}\,=\{<jfam>,<jfont\_cs>\}] [\verb+\scriptfont+ in \TeX]
1504 \item[\Param{jascriptscriptfont}\,=\{<jfam>,<jfont\_cs>\}] [\verb+\scriptscriptfont+ in \TeX]
1505 \item[\Param{yjabaselineshift}\,=<dimen>$^\ast$]\
1506 \item[\Param{yalbaselineshift}\,=<dimen>$^\ast$] [\verb+\ybaselineshift+]
1508 \item[\Param{jaxspmode}\,=\{<chr\_code>,<mode>\}] [\verb+\inhibitxspcode+]
1510 Setting whether inserting \Param{xkanjiskip} is allowed before/after a \textbf{JAchar} whose character code is <chr\_code>.
1511 The followings are allowed for <mode>:
1513 \item[0, \texttt{inhibit}] Insertion of \Param{xkanjiskip} is inhibited before the charater, nor after the charater.
1514 \item[2, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed before the charater, but not after.
1515 \item[1, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed after the charater, but not before.
1516 \item[3, \texttt{allow}] Insertion of \Param{xkanjiskip} is allowed before the charater and after the charater.
1517 This is the default value.
1520 \item[\Param{alxspmode}\,=\{<chr\_code>,<mode>\}] [\verb+\xspcode+]
1522 Setting whether inserting \Param{xkanjiskip} is allowed before/after a
1523 \textbf{ALchar} whose character code is <chr\_code>.
1524 The followings are allowed for <mode>:
1526 \item[0, \texttt{inhibit}] Insertion of \Param{xkanjiskip} is inhibited
1527 before the charater, nor after the charater.
1528 \item[1, \texttt{preonly}] Insertion of \Param{xkanjiskip} is allowed
1529 before the charater, but not after.
1530 \item[2, \texttt{postonly}] Insertion of \Param{xkanjiskip} is allowed
1531 after the charater, but not before.
1532 \item[3, \texttt{allow}] Insertion of \Param{xkanjiskip} is allowed both
1533 before the charater and after the charater.
1534 This is the default value.
1536 Note that parameters \Param{jaxspmode} and \Param{alxspmode} use a common table.
1538 \item[\Param{autospacing}\,=<bool>$^\ast$] [\verb+\autospacing+]
1539 \item[\Param{autoxspacing}\,=<bool>$^\ast$] [\verb+\autoxspacing+]
1540 \item[\Param{kanjiskip}\,=<skip>] [\verb+\kanjiskip+]
1541 \item[\Param{xkanjiskip}\,=<skip>] [\verb+\xkanjiskip+]
1543 \item[\Param{differentjfm}\,=<mode>$^\dagger$]
1545 Specify how glues/kerns between two \textbf{JAchar}s whose JFM (or size) are different.
1546 The allowed arguments are the followings:
1548 \item[\texttt{average}]
1549 \item[\texttt{both}]
1550 \item[\texttt{large}]
1551 \item[\texttt{small}]
1554 \item[\Param{jacharrange}\,=<ranges>$^\ast$]
1555 \item[\Param{kansujichar}\,=\{<digit>, <chr\_code>\}] [\verb+\kansujichar+]
1559 %<en>\section{Other Primitives}
1560 %<ja>\section{その他のプリミティブ}
1561 %<en>\subsection{Primitives for Compatibility}
1562 %<ja>\subsection{互換プリミティブ}
1563 The following primtives are implemented for compatibility with \pTeX:
1564 \begin{list}{}{\def\makelabel{\ttfamily\char92 }}
1572 %<en>\subsection{{\tt\char92 inhibitglue} primitive}
1573 %<ja>\subsection{{\tt\char92 inhibitglue} プリミティブ}
1574 The primitive \verb+\inhibitglue+ suppresses the insertion of \textbf{JAglue}.
1575 The following is an example, using a special JFM that there will be a glue between
1576 the beginning of a box and `あ', and also between `あ' and `ウ'.
1579 \jfont\g=psft:Ryumin-Light:jfm=test \g
1580 あウあ\inhibitglue{}ウ\inhibitglue\par
1581 あ\par\inhibitglue{}あ
1582 \par\inhibitglue\hrule{}あoff\inhibitglue ice
1585 With the help of this example, we remark the specification of \verb+\inhibitglue+:
1587 \item The call of \verb+\inhibitglue+ in the (internal) vertical mode is
1588 effective at the beginning of the next paragraph. This is realized
1589 by hacking \verb+\everypar+.
1590 \item The call of \verb+\inhibitglue+ in the (restricted) horizontal
1591 mode is only effective on the spot; does not get over boundary of
1592 paragraphs. Moreover, \verb+\inhibitglue+ cancels ligatures and
1593 kernings, as shown in line~4 of above example.
1594 \item The call of \verb+\inhibitglue+ in math mode is just ignored.
1597 %<en>\section{Control Sequences for \LaTeXe}
1598 %<ja>\section{\LaTeXe 用のコントロールシーケンス}
1599 %<en>\subsection{Patch for NFSS2}
1600 %<ja>\subsection{NFSS2 へのパッチ}
1601 \label{ssub-nfsspat}
1602 As described in Subsection~\ref{ssec-ltx}, \LuaTeX-ja simply adopted
1603 \texttt{plfonts.dtx} in \pLaTeXe\ for the Japanese patch for NFSS2.
1604 For an convinience, we will describe
1605 commands which are not described in Subsection~\ref{ssub-chgfnt}.
1608 \item[DeclareYokoKanjiEncoding\{<encoding>\}\{<text-settings>\}\{<math-settings>\}]
1609 In NFSS2 under \LuaTeX-ja, distinction between alphabetic font families
1610 and Japanese font families is only made by its
1611 encoding. For example, encodings OT1 and T1 are for
1612 alphabetic font families, and a Japanese font family cannot
1613 have these encodings. This command defines a new encoding
1614 scheme for Japanese font family (in horizontal direction).
1616 \item[DeclareKanjiEncodingDefaults\{<text-settings>\}\{<math-settings>\}]
1617 \item[DeclareKanjiSubstitution\{<encoding>\}\{<family>\}\{<series>\}\{<shape>\}]
1618 \item[DeclareErrorKanjiFont\{<encoding>\}\{<family>\}\{<series>\}\{<shape>\}\{<size>\}]
1620 The above 3~commands are just the counterparts for \verb+DeclareFontEncodingDefaults+ and~others.
1622 \item[reDeclareMathAlphabet\{<unified-cmd>\}\{<al-cmd>\}\{<ja-cmd>\}]
1623 和文・欧文の数式用フォントファミリを一度に変更する命令を作成する.
1624 具体的には,欧文数式用フォントファミリ変更の命令<al-cmd>と,和文数式用フォ
1625 ントファミリ変更の命令<ja-cmd>の2つを同時に行う命令として
1626 <unified-cmd>を(再)定義する.実際の使用では<unified-cmd>と
1627 <al-cmd>に同じものを指定する,すなわち,<al-cmd>に和文側も変
1628 更させるようにするのが一般的と思われる.
1630 本コマンドの使用については,\pLaTeX 配布中の\texttt{plfonts.dtx}に詳しく
1631 注意点が述べられているので,そちらを参照されたい.
1633 \item[DeclareRelationFont\{<ja-encoding>\}\{<ja-family>\}\{<ja-series>\}\{<ja-shape>\}\\
1634 \hfill\{<al-encoding>\}\{<al-family>\}\{<al-series>\}\{<al-shape>\}]
1636 This command sets the `accompanied' alphabetic font family (given by the latter 4~arguments)
1637 with respect to a Japanese font family given by the former 4~arguments.
1640 いわゆる「従属欧文」を設定するための命令である.前半の4引数で表される和文フォントファミリに対して,
1641 そのフォントに対応する「従属欧文」フォントファミリを後半の4引数により与える.
1643 \item[SetRelationFont]
1644 This command is almost same as \verb+\DeclareRelationFont+, except that this command does a local
1645 assignment, where \verb+\DeclareRelationFont+ does a global assignment.
1647 Change current alphabetic font encoding/family/\dots\ to the `accompanied' alphabetic
1648 font family with respect to current Japanese font family,
1650 \verb+\DeclareRelationFont+ or \verb+SetRelationFont+.
1651 Like \verb+\fontfamily+, \verb+\selectfont+ is required to take an effect.
1653 \item[adjustbaseline]
1656 \item[fontfamily\{<family>\}]
1658 As in \LaTeXe, this command changes current font family (alphabetic, Japanese,~\emph{or both})
1659 to <family>. Which family will be changed is determined as follows:
1661 \item Let current encoding scheme for Japanese fonts be
1662 <ja-enc>. Current Japanese font family will be changed to
1663 <family>, if one of the following two conditions is met:
1665 \item The family <fam> under the encoding <ja-enc> is already defined by
1666 \verb+\DeclareKanijFamily+.
1667 \item A font definition named \texttt{<enc><ja-enc>.fd} (the filename is
1668 all lowercase) exists.
1670 \item Let current encoding scheme for Japanese fonts be
1671 <al-enc>. For alphabetic font family, the criterion as above is used.
1672 \item There is a case which none of the above applies, that is, the font
1673 family named <family> doesn't seem to be defined neither under the
1674 encoding <ja-enc>, nor under <al-enc>.
1676 In this case, the default family for font substitution is used for
1677 alphabetic and Japanese fonts. Note that current encoding will not
1678 be set to <family>, unlike the original inplementation in \LaTeX.
1683 As closing this subsection, we shall introduce an example of
1684 \verb+SetRelationFont+ and \verb+\userelfont+:
1687 \SetRelationFont{JY3}{gt}{m}{n}{OT1}{pag}{m}{n}
1688 \userelfont\selectfont{}あいうabc
1692 %<en>\subsection{Cropmark/`tombow'}
1693 %<ja>\subsection{トンボ}
1695 %<en>\section{Extensions}
1697 \subsection{{\tt luatexja-fontspec.sty}}
1699 \subsection{{\tt luatexja-otf.sty}}
1700 This optional package supports typesetting charaters in
1701 Adobe-Japan1. {\tt luatexja-otf.sty} offers the following 2~low-level
1703 \begin{list}{}{\def\makelabel{\ttfamily}\def\{{\char`\{}\def\}{\char`\}}}
1704 \item[\char92CID\{<number>\}]
1705 Typeset a character whose CID number is <number>.
1706 \item[\char92UTF\{<hex\_number>\}]
1707 Typeset a character whose character code is <hex\_number> (in hexadecimal).
1708 This command is similar to \verb+\char"+<hex\_number>,\ %"
1709 but please remind remarks below.
1713 Characters by \verb+\CID+ and \verb+\UTF+ commands are different from
1714 ordinary characters in the following points:
1716 \item Always treated as \textbf{JAchar}s.
1717 \item Processing codes for supporting OpenType features (\textit{e.g.},
1718 glyph replacement and kerning) by the \Pkg{luaotfload} package
1719 is not performed to these characters.
1723 \paragraph{Additionally Syntax of JFM}
1724 {\tt luatexja-otf.sty} extends the syntax of JFM; the entries of {\tt
1725 chars} table in JFM now allows a string in the form
1726 \verb+'AJ1-xxx'+, which stands for the character
1727 whose CID number in Adobe-Japan1 is \verb+xxx+.
1729 %<en>\part{Implementations}
1732 %<en>\section{Storing Parameters}
1733 %<ja>\section{パラメータの保持}
1735 %<en>\subsection{Used Dimensions, Attributes and whatsit nodes}
1736 %<ja>\subsection{ディメンション,アトリビュート,whatsit ノードを用いて}
1737 Here the following is the list of dimension and attributes which are used in \LuaTeX-ja.
1739 \def\makelabel{\ttfamily}
1740 \def\dim#1{\item[\char92 #1\ \textrm{(dimension)}]}
1741 \def\attr#1{\item[\char92 #1\ \textrm{(attribute)}]}
1745 As explained in Subsection~\ref{ssec-plain}, \verb+\jQ+ is equal to
1746 $1\,\textrm{Q}=0.25\,\textrm{mm}$, where `Q'~(also called `級') is
1747 a unit used in Japanese phototypesetting. So one should not change the value of this dimension.
1749 There is also a unit called `歯' which equals to $0.25\,\textrm{mm}$ and
1750 used in Japanese phototypesetting. The dimension
1751 \verb+\jH+ stores this length, similar to \verb+\jQ+.
1752 \dim{ltj@zw} A temporal register for the `full-width' of current Japanese font.
1753 \dim{ltj@zh} A temporal register for the `full-height' (usually the sum of height of imaginary body and its depth) of current Japanese font.
1754 \attr{jfam} Current number of Japanese font family for math formulas.
1755 \attr{ltj@curjfnt} The font index of current Japanese font.
1756 \attr{ltj@charclass} The character class of Japanese \textit{glyph\_node}.
1757 \attr{ltj@yablshift} The amount of shifting the baseline of alphabetic
1758 fonts in scaled point ($2^{-16}\,\textrm{pt}$).
1759 \attr{ltj@ykblshift} The amount of shifting the baseline of Japanese
1760 fonts in scaled point ($2^{-16}\,\textrm{pt}$).
1761 \attr{ltj@autospc} Whether the auto insertion of \Param{kanjiskip} is allowed at the node.
1762 \attr{ltj@autoxspc} Whether the auto insertion of \Param{xkanjiskip} is allowed at the node.
1763 \attr{ltj@icflag} An attribute for distinguishing `kinds' of a node. One of the following value is
1764 assigned to this attribute:
1766 \item[\textit{italic} (1)] Glues from an itaric correction
1767 (\verb+\/+). This distinction of origins of glues
1768 (from explicit \verb+\kern+, or from \verb+\/+)
1769 is needed in the insertion process of \Param{xkanjiskip}.
1770 \item[\textit{packed} (2)]
1771 \item[\textit{kinsoku} (3)] Penalties inserted for the word-wrapping process of Japanese characters (\emph{kinsoku}).
1772 \item[\textit{from\_jfm} (4)] Glues/kerns from JFM.
1773 \item[\textit{line\_end} (5)] Kerns for ...
1774 \item[\textit{kanji\_skip} (6)] Glues for \Param{kanjiskip}.
1775 \item[\textit{xkanji\_skip} (7)] Glues for \Param{xkanjiskip}.
1776 \item[\textit{processed} (8)] Nodes which is already processed by ...
1777 \item[\textit{ic\_processed} (9)] Glues from an itaric correction, but also already processed.
1778 \item[\textit{boxbdd} (15)] Glues/kerns that inserted just the beginning or the ending of an hbox or a paragraph.
1780 \attr{ltj@kcat$i$} Where $i$~is a natural number which is less than~7.
1781 These 7~attributes store bit~vectors indicating which character block is regarded as a block of \textbf{JAchar}s.
1784 Furthermore, \LuaTeX-ja uses several `user-defined' whatsit nodes for
1785 typesetting. All those nodes store a natural number (hence the node's
1786 \texttt{type} is 100).
1788 \item[30111] Nodes for indicating that \verb+\inhibitglue+ is
1789 specified. The \texttt{value} field of these nodes doesn't matter.
1790 \item[30112] Nodes for \LuaTeX-ja's stack system (see the next
1791 subsection). The \texttt{value} field of these nodes is
1793 \item[30113] Nodes for Japanese Characters which the callback process of
1794 luaotfload won't be applied, andd the character code is
1795 stored in the \texttt{value} field. Each node having this
1796 \verb+user_id+ is converted to a `glyph\_node' \emph{after}
1797 the callback process of luaotfload.
1799 These whatsits will be removed during the process of inserting \textbf{JAglue}s.
1801 %<en>\subsection{Stack System of \LuaTeX-ja}
1802 %<ja>\subsection{\LuaTeX-ja のスタックシステム}
1804 \paragraph{Background}
1805 \LuaTeX-ja has its own stack system, and most parameters of \LuaTeX-ja
1806 are stored in it. To clarify the reason, imagine the parameter
1807 \Param{kanjiskip} is stored by a skip, and consider the following
1810 \ltjsetparameter{kanjiskip=0pt}ふがふが.%
1811 \setbox0=\hbox{\ltjsetparameter{kanjiskip=5pt}ほげほげ}
1815 As described in Part~\ref{part-ref}, the only effective value of
1816 \Param{kanjiskip} in an hbox is the latest value, so the value of
1817 \Param{kanjiskip} which applied in the entire hbox should be 5\,pt.
1818 However, by the implementation method of \LuaTeX, this `5\,pt' cannot be
1819 known from any callbacks. In the \texttt{tex/packaging.w} (which is a
1820 file in the source of \LuaTeX), there are the following codes:
1824 scaled h; /* height of box */
1825 halfword p; /* first node in a box */
1826 scaled d; /* max depth */
1832 if (cur_list.mode_field == -hmode) {
1833 cur_box = filtered_hpack(cur_list.head_field,
1834 cur_list.tail_field, saved_value(1),
1835 saved_level(1), grp, saved_level(2));
1836 subtype(cur_box) = HLIST_SUBTYPE_HBOX;
1838 Notice that \verb+unsave+ is executed \emph{before}
1839 \verb+filtered_hpack+ (this is where \verb+hpack_filter+ callback is
1840 executed): so `5\,pt' in the above source is orphaned at
1841 \texttt+unsave+, and hence it can't be accessed from \verb+hpack_filter+
1844 \paragraph{The method}
1845 The code of stack system is based on that in a post of Dev-luatex mailing list\footnote{%
1846 \texttt{[Dev-luatex] tex.currentgrouplevel}, a post at 2008/8/19 by Jonathan Sauer.}.
1848 These are two \TeX\ count registers for maintaining informations:
1849 \verb+\ltj@@stack+ for the stack level, and \verb+\ltj@@group@level+ for
1850 the \TeX's group level when the last assignment was done. Parameters
1851 are stored in one big table named \texttt{charprop\_stack\_table}, where
1852 \texttt{charprop\_stack\_table[$i$]} stores data of stack level~$i$. If
1853 a new stack level is created by \verb+\ltjsetparameter+, all data of the
1854 previous level is copied.
1856 To resolve the problem mentioned in `Background' above, \LuaTeX-ja uses
1857 another thing: When a new stack level is about to be created, a whatsit
1858 node whose type, subtype and value are 44~(\textit{user\_defined}),
1859 30112, and current group level respectively is appended to the current
1860 list (we refer this node by \textit{stack\_flag}). This enables us to
1861 know whether assignment is done just inside a hbox. Suppose that the
1862 stack level is~$s$ and the \TeX's group level is~$t$ just after the hbox
1865 \item If there is no \textit{stack\_flag} node in the list of hbox, then
1866 no assignment was occurred inside the hbox. Hence values of
1867 parameters at the end of the hbox are stored in the stack
1869 \item If there is a \textit{stack\_flag} node whose value is~$t+1$, then
1870 an assignment was occurred just inside the hbox group. Hence
1871 values of parameters at the end of the hbox are stored in the
1873 \item If there are \textit{stack\_flag} nodes but all of their values
1874 are more than~$t+1$, then an assignment was occurred in the box,
1875 but it is done is `more internal' group. Hence values of
1876 parameters at the end of the hbox are stored in the stack
1880 Note that to work this trick correctly, assignments to
1881 \verb+\ltj@@stack+ and \verb+\ltj@@group@level+ have to be local always,
1882 regardless the value of \verb+\globaldefs+.
1883 This problem is resolved by using
1884 \hbox{\verb+\directlua{tex.globaldefs=0}+} (this assignment is local).
1887 %<en>\section{Linebreak after Japanese Character}
1888 %<ja>\section{和文文字直後の改行}
1890 %<en>\subsection{Reference: Behavior in \pTeX}
1891 %<ja>\subsection{参考: \pTeX の挙動}
1893 In~\pTeX, a linebreak after a Japanese character doesn't emit a space,
1894 since words are not separated by spaces in Japanese writings. However,
1895 this feature isn't fully implemented in \LuaTeX-ja due to the
1896 specification of callbacks in~\LuaTeX. To clarify the difference between
1897 \pTeX~and~\LuaTeX, We briefly describe the handling of a linebreak in~\pTeX, in
1900 \pTeX's input processor can be described in terms of a finite state
1901 automaton, as that of~\TeX\ in~Section~2.5 of~\cite{texbytopic}. The
1902 internal states are as follows:
1904 \item State~$N$: new line
1905 \item State~$S$: skipping spaces
1906 \item State~$M$: middle of line
1907 \item State~$K$: after a Japanese character
1909 The first three states---$N$, $S$~and~$M$---are as same as \TeX's input
1910 processor. State~$K$ is similar to state~$M$, and is entered after
1911 Japanese characters. The diagram of state transitions are indicated in
1912 Figure~\ref{fig-ptexipro}. Note that \pTeX\ doesn't leave state~$K$
1913 after `beginning/ending of a group' characters.
1917 欧文では文章の改行は単語間でしか行わない.そのため,\TeX では,(文字の直後の)改行は
1918 空白文字と同じ扱いとして扱われる.一方,和文ではほとんどどどこでも改行が可能なため,
1919 \pTeX では和文文字の直後の改行は単純に無視されるようになっている.
1921 このような動作は,\pTeX が\TeX からエンジンとして拡張されたことによって可能になったことである.
1922 \pTeX の入力処理部は,\TeX におけるそれと同じように,有限オートマトンとして記述することができ,
1926 \item State~$N$: 行の開始.
1927 \item State~$S$: 空白読み飛ばし.
1928 \item State~$M$: 行中.
1929 \item State~$K$: 行中(和文文字の後).
1931 また,状態遷移は,図\label{fig-ptexipro}のようになっており,図中の数字は
1932 カテゴリーコードを表している.最初の3状態は\TeX の入力処理部と同じであり,
1933 図中から状態$K$と「$j$」と書かれた矢印を取り除けば,\TeX の入力処理部と同
1938 行が和文文字(とグループ境界文字)で終わっていれば,改行は無視される
1945 \def\sp{\text{\tt\char32}}
1947 {\text{scan a cs}}\ar@(r,ul)[dr]&\\
1949 *++[o][F-]{N}\ar[ur]^0\ar[dd]_{d,\ g}\ar[u]^{5\ (\text{\tt\char92par})}
1950 \ar@{->}@(d,l)[ddrr]_(0.45){j}&&
1951 *++[o][F-]{S}\ar@(l,dr)[ul]^0\ar@(l,ur)[ddll]_{d,\ g}\ar[u]_{5}
1952 \ar@{->}@(r,r)[dd]^{j}\\&\\&
1953 *++[o][F-]{M}\ar[uuur]^0\ar@(r,dl)[uurr]_(0.55){10\ (\sp)}
1954 \ar[d]_{5\ ({\sp})}\ar@{->}@(dr,dl)[rr]_{j}&&
1955 *++[o][F-]{K}\ar@{->}@(ul,d)[uuul]^0\ar@{->}[ll]^{d}
1956 \ar@{->}@(ur,dr)[uu]^{10\ (\sp)}\ar@{->}[d]_5\\
1959 d:=\{3,4,6,7,8,11,12,13\},\quad g:=\{1,2\},\quad j:=(\text{Japanese characters})
1962 \item Numbers represent category codes.
1963 \item Category codes 9~(ignored), 14~(comment)~and~15~(invalid) are omitted in above diagram.
1965 \caption{State transitions of \pTeX's input processor.}
1966 \label{fig-ptexipro}
1970 %<en>\subsection{Behavior in \LuaTeX-ja}
1971 %<ja>\subsection{\LuaTeX-ja の挙動}
1973 States in the input processoe of \LuaTeX\ is the same as that of \TeX,
1974 and they can't be customized by any callbacks. Hence, we can only use
1975 \verb+process_input_buffer+ and \verb+token_filter+ callbacks for to
1976 suppress a space by a linebreak which is after Japanese characters.
1978 However, \verb+token_filter+ callback cannot be used either, since a
1979 character in category code 5~(end-of-line) is converted into an space
1980 token \emph{in the input processor}. So we can use only the
1981 \verb+process_input_buffer+ callback. This means that suppressing a
1982 space must be done \emph{just before} an input line is read.
1984 Considering these situations, handling of an end-of-line in \LuaTeX-ja are as follows:
1986 A character U+FFFFF (its category code is set to 14~(comment) by
1987 \LuaTeX-ja) is appended to an input line, \emph{before \LuaTeX\ actually
1988 process it}, if and only if the following two conditions are satisfied:
1990 \item The category code of the character $\langle${return}$\rangle$
1991 (whose character code is 13) is 5~(end-of-line).
1992 \item The input line matches the following `regular expression':
1994 (\text{any char})^*(\textbf{JAchar})
1995 \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
2001 The following example shows the major difference from the behavior of \pTeX:
2003 \ltjsetparameter{autoxspacing=false}
2004 \ltjsetparameter{jacharrange={-6}}xあ
2005 y\ltjsetparameter{jacharrange={+6}}zあ
2009 \item There is no space between `x' and `y', since the line~2 ends with a \textbf{JAchar} `あ'
2010 (this `あ' considered as an \textbf{JAchar} at the ending of line~1).
2011 \item There is no space between `あ' (in the line~3) and `u', since the
2012 line~3 ends with an \textbf{ALchar}
2013 (the letter `あ' considered as an \textbf{ALchar} at the ending of line~2).
2018 \LuaTeX の入力処理部は\TeX のそれと全く同じであり,callbackによりユーザが
2019 カスタマイズすることはできない.このため,改行抑制の目的でユーザが利用で
2020 きそうなcallbackとしては,\verb+process_input_buffer+や
2021 \verb+token_filter+に限られてしまう.しかし,\TeX の入力処理部をよく見る
2022 と,後者も役には経たないことが分かる:改行文字は,入力処理部によってトー
2023 クン化される時に,カテゴリーコード10の32番文字へと置き換えられてしまうた
2024 め,\verb+token_filter+で非標準なトークン読み出しを行おうとしても,空白文
2025 字由来のトークンと,改行文字由来のトークンは区別できないのだ.
2027 すると,我々のとれる道は,\verb+process_input_buffer+を用いて
2028 \LuaTeX の入力処理部に引き渡される前に入力文字列を編集するというものしかない.
2029 以上を踏まえ,\LuaTeX-jaにおける「和文文字直後の改行抑制」の処理は,次のようになっている:
2032 各入力行に対し,\textbf{その入力行が読まれる前の内部状態で}
2033 以下の2条件が満たされている場合,\LuaTeX-jaはU+FFFFF番の文字
2034 \footnote{この文字はコメント文字として扱われるように\LuaTeX-ja内部で設定をしている.}
2035 を末尾に追加する.よって,その場合に改行は空白とは見做されないこととなる.
2037 \item 改行文字(文字コード13番)のカテゴリーコードが5~(end-of-line)である.
2038 \item 入力行は次の「正規表現」にマッチしている:
2040 (\text{any char})^*(\textbf{JAchar})
2041 \bigl(\{\text{catcode}=1\}\cup\{\text{catcode}=2\}\bigr)^*
2046 この仕様は,前節で述べた\pTeX の仕様にできるだけ近づけたものとなっている.最初の条件は,
2047 \texttt{verbatim}系環境などの日本語対応マクロを書かなくてすませるためのものである.
2048 しかしながら,完全に同じ挙動が実現できたわけではない.
2049 差異は,次の例が示すように,和文文字の範囲を変更した行の改行において見られる:
2051 \ltjsetparameter{autoxspacing=false}
2052 \ltjsetparameter{jacharrange={-6}}xあ
2053 y\ltjsetparameter{jacharrange={+6}}zあ
2056 もし\pTeX とまったく同じ挙動を示すならば,出力は
2057 「\hbox{\ltjsetparameter{autoxspacing=false}x yzあu}」となるべきである.しかし,実際には
2060 \item 2行目は「あ」という和文文字で終わる(2行目を処理する前の時点では,
2061 「あ」は和文文字扱いである)ため,直後の改行文字は無視される.
2062 \item 3行目は「あ」という欧文文字で終わる(2行目を処理する前の時点では,
2063 「あ」は欧文文字扱いである)ため,直後の改行文字は空白に置き換わる.
2065 このため,トラブルを避けるために,和文文字の範囲を\verb+\ltjsetparameter+で編集した場合,
2066 その行はそこで改行するようにした方がいいだろう.
2070 %<en>\section{Insertion of JFM glues, \Param{kanjiskip} and \Param{xkanjiskip}}
2071 %<ja>\section{JFM グルーの挿入,\Param{kanjiskip} と \Param{xkanjiskip}}
2072 %<en>\subsection{Overview}
2073 %<ja>\subsection{概要}
2079 \LuaTeX-ja における和文処理グルーの挿入方法は,\pTeX のそれとは全く異なる.
2080 \pTeX では次のような仕様であった:
2082 \item JFMグルーの挿入は,和文文字を表すトークンを元に水平リストに(文字を表す)<char\_node>を
2084 \item \Param{xkanjiskip}の挿入は,hboxへのパッケージングや行分割前に行われる.
2085 \item \Param{kanjiskip}はノードとしては挿入されない.パッケージングや行分割の計算時に
2086 「和文文字を表す2つの<char\_node>の間には\Param{kanjiskip}がある」ものとみなされる.
2088 しかし,\LuaTeX-jaでは,hboxへのパッケージングや行分割前に全ての
2089 \textbf{JAglue},即ちJFMグルー・\Param{xkanjiskip}・\Param{kanjiskip}の
2090 3種類を一度に挿入することになっている.これは,\LuaTeX において欧文の合字・
2091 カーニング処理がノードベースになったことに対応する変更である.
2093 \LuaTeX-jaにおける\textbf{JAglue}挿入処理では,下の図\ref{fig-clu}のよう
2094 に「塊」を単位にして行われる.大雑把にいうと,「塊」は文字とそれに付随す
2095 るノード達(アクセント位置補正用のkernや,イタリック補正)をまとめたもの
2096 であり,2つの塊の間には,ペナルティ,\verb+\vadjust+,whatsitなど,行組版
2097 には関係しないものがある.そのため,……
2100 % \begin{figure}[!tb]
2104 %<en>\subsection{Definition of a `cluster'}
2105 %<ja>\subsection{「クラスタ」の定義}
2108 A \emph{cluster} is a list of nodes in one of the following forms, with the \textit{id} of it:
2110 \item Nodes whose value of\ \verb+\ltj@icflag+ is in $[3,15)$. These
2111 nodes come from a hbox which is already packaged, by unpackaging
2113 The \textit{id} is \textit{id\_pbox}.
2114 \item A inline math formula, including two \textit{math\_node}s at the boundary of it:
2116 The \textit{id} is \textit{id\_math}.
2117 \item A \textit{glyph\_node} with nodes which relate with it:
2119 The \textit{id} is \textit{id\_jglyph} or
2120 \textit{id\_glyph}, according to whether the \textit{glyph\_node}
2121 represents a Japanese character or not.
2122 \item An box-like node, that is, an hbox, an vbox and an rule (\verb+\vrule+).
2123 The \textit{id} is \textit{id\_hlist} if the node is an
2124 hbox which is not shifted vertically, or \textit{id\_box\_like}
2126 \item A glue, a kern whose subtype is not 2~(\textit{accent}), and a discretionary break.
2127 The \textit{id} is \textit{id\_glue}, \textit{id\_kern}
2128 and \textit{id\_disc}, respectively.
2129 %Just a node which will \dots, \textit{i.e.}, a node which is \emph{not} one of the following:
2130 %\textit{ins\_node}, \textit{mark\_node}, \textit{adjust\_node}, \textit{whatsit\_node}
2131 %and \textit{penalty\_node}.
2133 We denote a cluster by \textit{Np}, \textit{Nq} and \textit{Nr}.
2136 Internally, a cluster is represented by a table $\textit{Np}$ with the following fields.
2139 \def\makelabel#1{\textbf{\textit{#1}}}
2140 \item[first, last] The first/last node of the cluster.
2141 \item[id] The \textit{id} in above definition.
2145 \item[auto\_kspc, auto\_xspc]
2146 \item[xspc\_before, xspc\_after]