OSDN Git Service

Changed character range 8 to ALchar
[luatex-ja/luatexja.git] / doc / luatexja.dtx
index 1c30699..f3e910c 100644 (file)
   \vskip\belowcaptionskip}
 
 \def\_{\leavevmode \kern .06em\vbox {\hrule \@width .333em}}
-\def\cs#1{\texttt{\upshape\textbackslash\ltjsetparameter{autoxspacing=false}#1}}
+\def\cs#1{\texttt{\upshape
+  \texorpdfstring{\textbackslash\ltjsetparameter{autoxspacing=false}#1}{\textbackslash#1}}}
 
 %%%%%%%%
 \makeatother
@@ -737,7 +738,7 @@ For changes from \pTeX, see Subsection~\ref{ssec:chgptex}.
 %</ja>
 \begin{itemize}
 %<*en>
-\item The encoding of your source file must be UTF-8. No other
+\item The encoding of your source file must be UTF-8. Other
       encodings, such as EUC-JP or Shift-JIS, are not supported.
 %</en>
 %<*ja>
@@ -745,17 +746,23 @@ For changes from \pTeX, see Subsection~\ref{ssec:chgptex}.
       従来日本語の文字コードとして用いられてきたEUC-JPやShift-JISは使用できない.
 %</ja>
 %<*en>
-\item By default, \LuaTeX-ja uses Japanese fonts to typeset Greek and Cyrillic letters,
-      and some Unicode symbols such as \P~and~\S. To change this behavior, 
-      put \lstinline!\ltjsetparameter{jacharrange={-2,-3,-8}}! in the preamble.
+\item By default, \LuaTeX-ja uses Japanese fonts to typeset Greek and Cyrillic letters.
+      To change this behavior, 
+      put \verb!\ltjsetparameter{jacharrange={-2,-3}}! in the preamble.
       For the detailed description, see Subsection~\ref{ssec-setrange}.
 %</en>
 %<*ja>
 \item 
-標準では,\LuaTeX-jaはギリシャ文字やキリル文字,それに\P や\S などの記号を和文フォントを使っ
+標準では,\LuaTeX-jaはギリシャ文字やキリル文字を和文フォントを使っ
       て組む.ギリシャ語などを本格的に組むなどこの状況が望ましくない場合,
-      プリアンブルに \lstinline!\ltjsetparameter{jacharrange={-2,-3,-8}}! を入れると
+      プリアンブルに
+\begin{lstlisting}
+ \ltjsetparameter{jacharrange={-2,-3}}
+\end{lstlisting}
+      を入れると
       上記種類の文字は欧文フォントを用いて組まれるようになる.
+      なお,\P,~\S といったISO~8859-1の上位領域とJIS~X~0208の共通部分の文字は
+      本バージョンから標準で欧文扱い(\textbf{ALchar})となった.
       詳しい説明は\ref{ssec-setrange}節を参照してほしい.
 %</ja>
 %<*en>
@@ -1425,17 +1432,17 @@ before \Pkg{luatexja-preset}:
 
 \item[nfssonly]
 %<*en>
-With this option,selecting Japanese fonts won't be performed using  the functionality of
-            the \Pkg{fontspec} package, but only standard NFSS2.
+With this option, selecting Japanese fonts won't be performed using the functionality of
+            the \Pkg{fontspec} package, but only standard NFSS2 (hence without
+            \cs{addjfontfeatures} etc.).
+This option is ignored when \Pkg{luatexja-fontspec} package is loaded.
 
-This option will be disabled when \Pkg{luatexja-fontspec} package is loaded.
 Note that the \Pkg{fontspec} can coexist with the option as the following:
 \begin{lstlisting}
 \usepackage{fontspec}
 \usepackage[hiragino-pron,nfssonly]{luatexja-preset}
 \end{lstlisting}
-Note that the functionality of the \Pkg{luatexja-fontspec} package, such as
-            \cs{setmainjfont}, cannot be used in the example above.
+In this case, one can use \cs{setmainfont} etc.\ to select \emph{alphabetic} fonts.
 %</en>
 %<*ja>
 \LaTeX 標準のフォント選択機構(NFSS2)を用いて
@@ -1586,8 +1593,6 @@ There is not rounded gothic family in Kozuka fonts.
 \end{tabular}
 \end{center}
 
-%<ja>\newpage
-
  \item[hiragino-pro]  Hiragino Pro (Adobe-Japan1-5) fonts.
 %<en>    \\*[-\dimexpr\medskipamount+\baselineskip\relax]
  \item[hiragino-pron] Hiragino ProN (Adobe-Japan1-5, JIS04-savvy) fonts.
@@ -1967,6 +1972,7 @@ and the character ``漢'' to the character range~100.
 \begin{lstlisting}
 \ltjdefcharrange{100}{"20000-"2FFFF,`漢}
 \end{lstlisting}
+
 %<*en>
 A character can belong to only one character range.
 For example, whole SIP belong to the range~4 in the default setting of \LuaTeX-ja,
@@ -1975,18 +1981,18 @@ removed from the range~4.
 %</en>
 %<*ja>
 各文字はただ一つの文字範囲に所属することができる.
-例えば,SIPは全て\LuaTeX-jaのデフォルトでは4番の文字範囲に
-属しているが,上記の指定を行えばSIPは100番に属すようになり,4番からは除かれる.
+例えば,SIP内の文字は全て\LuaTeX-jaのデフォルトでは4番の文字範囲に
+属しているが,上記の指定を行えばSIP内の文字は100番に属すようになり,4番からは除かれる.
 %</ja>
 
 %<*en>
-The distinction between \textbf{ALchar} and \textbf{JAchar} is done for character ranges.
+The distinction between \textbf{ALchar} and \textbf{JAchar} is performed by character ranges.
 This can be edited by setting the \textsf{jacharrange} parameter.
-For example, this is just the default setting of \LuaTeX-ja, and
+For example, the code below is just the default setting of \LuaTeX-ja, and
 it sets
 \begin{itemize}
- \item a character which belongs character ranges 1,~4, and~5 is \textbf{ALchar},
- \item a character which belongs character ranges 2,~3, 6, 7, and~8 is \textbf{JAchar}.
+ \item a character which belongs character ranges 1,~4, 5, and~8 is \textbf{ALchar},
+ \item a character which belongs character ranges 2,~3, 6, and~7 is \textbf{JAchar}.
 \end{itemize}
 %</en>
 %<*ja>
@@ -1994,12 +2000,12 @@ it sets
 これは\textsf{jacharrange}パラメータによって編集できる.
 例えば,以下は\LuaTeX-jaの初期設定であり,次の内容を設定している:
 \begin{itemize}
- \item 1番,4番,5番の文字範囲に属する文字は\textbf{ALchar}.
- \item 2番,3番,6番,7番,8番の文字範囲に属する文字は\textbf{JAchar}.
+ \item 1番,4番,5番,8番の文字範囲に属する文字は\textbf{ALchar}.
+ \item 2番,3番,6番,7番の文字範囲に属する文字は\textbf{JAchar}.
 \end{itemize}
 %</ja>
 \begin{lstlisting}
-\ltjsetparameter{jacharrange={-1, +2, +3, -4, -5, +6, +7, +8}}
+\ltjsetparameter{jacharrange={-1, +2, +3, -4, -5, +6, +7, -8}}
 \end{lstlisting}
 %<*en>
 The argument to \textsf{jacharrange} parameter is a list of non-zero integer.
@@ -2014,12 +2020,12 @@ and positive integer $+n$ means that ``\dots\ is a \textbf{JAchar}''.
 %</ja>
 
 %<*en>
-\paragraph{Default setting}
+\paragraph{Default character ranges}
 \LuaTeX-ja predefines eight character ranges for convenience. They are
 determined from the following data:
 %</en>
 %<*ja>
-\paragraph{初期設定}
+\paragraph{文字範囲の初期値}
 \LuaTeX-jaでは8つの文字範囲を予め定義しており,
 これらは以下のデータに基づいて決定している.
 %</ja>
@@ -2037,24 +2043,26 @@ Now we describe these eight ranges. The superscript ``J'' or ``A'' after the
 number shows whether each character in the range is treated as
 \textbf{JAchar}s or not by default. These settings are similar to the
 \texttt{prefercjk} settings defined in \texttt{PXbase} bundle.
-Any characters above \texttt{U+0080} which does not belong to
+Any characters equal to or above \texttt{U+0080} which does not belong to
 these eight ranges belongs to the character range~217.
 %</en>
 %<*ja>
 以下ではこれら8つの文字範囲について記述する.添字のアルファベット「J」「A」
-は,その文字範囲内の文字が\textbf{JAchar}か\textbf{ALchar}かを表している.これらの設定は
-\texttt{PXbase}バンドルで定義されている\texttt{prefercjk}と類似のものである.
+は,その文字範囲内の文字が\textbf{JAchar}か\textbf{ALchar}かを表している.これらの初期設定は
+\texttt{PXbase}バンドルで定義されている\texttt{prefercjk}と類似のものであるが,
+8ビットフォント使用時のトラブルを防ぐために \texttt{U+0080}--\texttt{U+00FF} の文字は全部
+\textbf{ALchar}としている.
 なお,\texttt{U+0080} 以降でこれら8つの文字範囲に属さない文字は,217番の文字範囲に属することになっている.
 %</ja>
 \begin{description}
 %<*en>
 
-\item[Range~8${}^{\kern.1em\text{J}}$] The intersection of the upper half of ISO~8859-1
+\item[Range~8${}^{\text{A}}$] The intersection of the upper half of ISO~8859-1
         (Latin-1 Supplement) and JIS~X~0208 (a basic character set for Japanese). This character range
         consists of the following characters:
 %</en>
 %<*ja>
-\item[範囲8${}^{\kern.1em\text{J}}$] ISO~8859-1の上位領域(ラテン1補助)と
+\item[範囲8${}^{\text{A}}$] ISO~8859-1の上位領域(ラテン1補助)と
                              JIS~X~0208の共通部分.この文字範囲は
                              以下の文字で構成される:
 %</ja>
@@ -2088,9 +2096,10 @@ This range consists of the following Unicode ranges, \emph{except characters in
 \item \texttt{U+0180}--\texttt{U+024F}: Latin Extended-B
 \item \texttt{U+0250}--\texttt{U+02AF}: IPA Extensions
 \item \texttt{U+02B0}--\texttt{U+02FF}: Spacing Modifier Letters
-\item \texttt{U+0300}--\texttt{U+036F}: \\\null\hfill Combining Diacritical Marks
-\item \texttt{U+1E00}--\texttt{U+1EFF}: \\\null\hfill Latin Extended Additional
-\par\
+%<en>\par\ 
+\item \texttt{U+0300}--\texttt{U+036F}: \\*\null\hfill Combining Diacritical Marks
+\item \texttt{U+1E00}--\texttt{U+1EFF}: \\*\null\hfill Latin Extended Additional
+%<ja>\par\
 \end{itemize}
 \end{multicols}
 %<*en>
@@ -2099,7 +2108,7 @@ This range consists of the following Unicode ranges, \emph{except characters in
 %</en>
 %<*ja>
 \item[範囲2${}^{\text{\kern.1emJ}}$] ギリシャ文字とキリル文字.JIS~X~0208(したがってほとんどの
-                             å\92\8cæ\96\87ã\83\95ã\82©ã\83³ã\83\88ï¼\89ã\81¯ã\81\93ã\82\8cã\82\89ã\81®æ\96\87å­\97ã\82\92æ\8c\81ã\81¤
+                             å\92\8cæ\96\87ã\83\95ã\82©ã\83³ã\83\88ï¼\89ã\81«ã\81¯ï¼\8cã\81\93ã\82\8cã\82\89ã\81®æ\96\87å­\97ã\81®ä¸\80é\83¨ã\81\8cå\90«ã\81¾ã\82\8cã\81¦ã\81\84ã\82\8b
 %</ja>
 \begin{multicols}{2}
 \begin{itemize}
@@ -2224,6 +2233,54 @@ The block list is indicated in Table~\ref{table-rng7}.
 \end{table}
 \end{description}
 
+%<*en>
+\paragraph{Notes on \texttt{U+0080}--\texttt{U+00FF}}
+You should treat characters in \\texttt{U+0080}--\texttt{U+00FF} as \textbf{ALchar}, 
+when you use traditional 8-bit fonts, such as the \Pkg{textcomp} package or the
+\Pkg{marvosym} package.
+
+For example, the codepoint \cs{textparagraph} which is provided by the \Pkg{textcomp}
+package is 182. This codepoint corresponds \P\ (\text{U+00B6}) in Unicode.
+Similarly, \cs{Frowny} which is provided by the \Pkg{marvosym} package has
+the same codepoint as \S\ (\text{U+00A7}).
+Hence, as previous versions of \LuaTeX-ja, if these characters are treated as
+\text{JAchar}s, then \cs{textparagraph} produces ``ltjjachar`¶'' (in a Japanese font), 
+and  \cs{Frowny} produces ``\ltjjachar`§'' (in a Japanese font).
+
+To avoid such situations, the default  setting of \LuaTeX-ja is changed in this release
+so that all characters \texttt{U+0080}--\texttt{U+00FF} are treated as \textbf{ALchar}.
+If you want to output a character as \textbf{ALchar}/\textbf{JAchar} regardless the range
+setting, you can use \cs{ltjalchar}/\cs{ltjjachar} respectively.
+\begin{LTXexample}[width=0.3\textwidth]
+\gtfamily 
+¶,\ltjalchar`¶,\ltjjachar`¶\\   % default: ALchar
+α,\ltjalchar`α,\ltjjachar`α  % default: JAchar
+\end{LTXexample}
+%</en>
+%<*ja>
+\paragraph{\texttt{U+0080}--\texttt{U+00FF}についての注意}
+\LuaTeX-jaで,\Pkg{textcomp}パッケージや\Pkg{marvosym}パッケージ等,Unicodeフォントでなく
+伝統的な8ビットフォントを用いる場合には注意が必要である.
+
+例えば,\Pkg{textcomp}パッケージの提供する \cs{textparagraph} は,
+符号位置が182,つまり \texttt{0xB6} であり,Unicodeではこの符号位置では\P\ (\text{U+00B6}) に対応する.
+また,\Pkg{marvosym}パッケージの提供する \cs{Frowny} も,符号位置は167,つまりUnicodeにおける
+\S\ (\text{U+00A7}) と同じ符号位置にある.
+即ち,以前のバージョンのように,「前節の文字範囲8内の文字は\textbf{JAchar}」という設定で
+あったとすると,上記の \cs{textparagraph} は和文フォントで「\ltjjachar`¶」を出力し,
+また \cs{Frowny} は和文フォントで「\ltjjachar`§」を出力することになる.
+このような事態を避けるために,\emph{本バージョンからは \texttt{U+0080}--\texttt{U+00FF} の範囲の
+文字は全て\textbf{ALchar}となるように初期設定を変更}している.
+
+なお,文字範囲の設定に関わらず文字を\textbf{ALchar}, \textbf{JAchar}で出力したい場合には,
+それぞれ \cs{ltjalchar},~\cs{ltjjachar} に該当文字の文字コードを渡せばよい.
+\begin{LTXexample}[width=0.3\textwidth]
+\gtfamily 
+¶,\ltjalchar`¶,\ltjjachar`¶\\   % default: ALchar
+α,\ltjalchar`α,\ltjjachar`α  % default: JAchar
+\end{LTXexample}
+%</ja>
+
 %<en>\subsection{\Param{kanjiskip} and \Param{xkanjiskip}}
 %<ja>\subsection{\Param{kanjiskip}と\Param{xkanjiskip}}
 \label{subs-kskip}
@@ -3010,7 +3067,7 @@ the direction  inside the box and that outside the box differ.
      \put(0,0){\vector(1,0){5}} \put(2.5,-0.2){\makebox(0,0)[t]{$h_{\mathrm{T}}$}}
      \put(0,0){\vector(-1,0){2}}\put(-1,-0.2){\makebox(0,0)[t]{$d_{\mathrm{T}}$}}
      \put(0,0){\vector(0,-1){7}}\put(0.2,-3.5){\makebox(0,0)[l]{$w_{\mathrm{T}}$}}
-   \end{picture}}}
+   \end{picture}}}%
  }
  \def\DTOUeg{%
    \hbox{\smash{\begin{picture}(0,0)(-5,0)
@@ -3021,7 +3078,7 @@ the direction  inside the box and that outside the box differ.
      \put(0,0){\vector(-1,0){5}} \put(-2.5,0.3){\makebox(0,0)[b]{$h_{\mathrm{D}}$}}
      \put(0,0){\vector(1,0){2}}\put(1,0.3){\makebox(0,0)[b]{$d_{\mathrm{D}}$}}
      \put(0,0){\vector(0,1){7}}\put(-0.2,3.5){\makebox(0,0)[r]{$w_{\mathrm{D}}$}}
-   \end{picture}}}
+   \end{picture}}}%
  }
  \def\YOKOeg{%
    \hbox{\smash{\begin{picture}(0,0)
@@ -3032,7 +3089,7 @@ the direction  inside the box and that outside the box differ.
      \put(0,0){\vector(0,1){5}} \put(0.3,2.5){\makebox(0,0)[l]{$h_{\mathrm{Y}}$}}
      \put(0,0){\vector(0,-1){2}}\put(0.3,-1){\makebox(0,0)[l]{$d_{\mathrm{Y}}$}}
      \put(0,0){\vector(1,0){7}}\put(3.5,0.2){\makebox(0,0)[b]{$w_{\mathrm{Y}}$}}
-   \end{picture}}}
+   \end{picture}}}%
  }
 \begin{tabular}{ccc}
 \toprule
@@ -3138,7 +3195,7 @@ the direction  inside the box and that outside the box differ.
    \begin{align*}
    W_{\mathrm{Y}} &= h_{\mathrm{D}}+d_{\mathrm{D}},\\
    H_{\mathrm{Y}} &= w_{\mathrm{D}},\\
-   D_{\mathrm{Y}} &= 0\,pt
+   D_{\mathrm{Y}} &= 0\,\mathrm{pt}
    \end{align*}%
  }&
  \parbox[c]{15\unitlength}{\begin{picture}(15,15)(0,-4)
@@ -5588,7 +5645,7 @@ With the help of this example, we remark the specification of \cs{inhibitglue}:
 Using \cs{ltjdeclarealtfont}, one can ``compose'' more than one Japanese fonts.
 This \cs{ltjdeclarealtfont} uses in the following form:
 \begin{quote}
-\ttfamily \textbackslash ltjdeclarealtfont<base\_font\_cs><alt\_font\_cs>{<range>}
+\ttfamily \textbackslash ltjdeclarealtfont<base\_font\_cs><alt\_font\_cs>\{<range>\}
 \end{quote}
 where  <base\_font\_cs>~and~<alt\_font\_cs> are defined by \cs{jfont}.
 Its meaning is
@@ -5596,8 +5653,7 @@ Its meaning is
 If the current Japanese font is <base\_font\_cs>, characters which belong to <range>
 is typeset by another Japanese font <alt\_font\_cs>, instead of <base\_font\_cs>.
 \end{quote}
-
-<range> is a comma-separated list of character codes, but also accepts negative integers:
+Here <range> is a comma-separated list of character codes, but also accepts negative integers:
 $-n$~($n≥1$) means that all characters of character classes~$n$, with respect to JFM used
 by <base\_font\_cs>. Note that characters which do not exist in <alt\_font\_cs> are
 ignored.
@@ -5621,7 +5677,7 @@ are typeset by \cs{piyo}.
 
 \cs{ltjdeclarealtfont} は以下の書式で使用する:
 \begin{quote}
-\ttfamily \textbackslash ltjdeclarealtfont<base\_font\_cs><alt\_font\_cs>{<range>}
+\ttfamily \textbackslash ltjdeclarealtfont<base\_font\_cs><alt\_font\_cs>\{<range>\}
 \end{quote}
 これは「現在の和文フォント」が<base\_font\_cs>であるとき,
 <range>に属する文字は<alt\_font\_cs>を用いて組版される,という意味である.
@@ -5840,103 +5896,196 @@ In \LuaTeX-ja, this \cs{adjustbaseline} does same task, namely setting the
 \item[\cs{fontfamily}\{<family>\}]
 %<*en>
 As in \LaTeXe, this command changes current font family (alphabetic, Japanese,~\emph{or both})
-to <family>.
+to <family>. See Subsection~\ref{ssec-fontfamilycmd} for detail.
+%</en>
+%<*ja>
+元々の\LaTeXe におけるものと同様に,このコマンドは現在のフォントファミリ(欧文,
+和文,\emph{もしくは両方})を<family>に変更する.詳細は\ref{ssec-fontfamilycmd}節を参照すること.
+%</ja>
+
+
+\begin{figure}[!tb]
+\begin{LTXexample}[pos=b]
+\DeclareKanjiFamily{JY3}{edm}{}
+\DeclareFontShape{JY3}{edm}{m}{n}    {<-> s*KozMinPr6N-Regular:jfm=ujis;}{}
+\DeclareFontShape{JY3}{edm}{m}{green}{<-> s*KozMinPr6N-Regular:jfm=ujis;color=007F00}{}
+\DeclareFontShape{JY3}{edm}{m}{blue} {<-> s*KozMinPr6N-Regular:jfm=ujis;color=0000FF}{}
+\DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{green}{"4E00-"67FF,{-2}-{-2}}
+\DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{blue}{ "6800-"9FFF}
+{\kanjifamily{edm}\selectfont
+日本国民は、正当に選挙された国会における代表者を通じて行動し、……}
+\end{LTXexample}
+%<ja>\caption{\cs{DeclareAlternateKanjiFont} の使用例}
+%<en>\caption{An example of \cs{DeclareAlternateKanjiFont}}
+\label{fig:altkanji}
+\end{figure}
+
+\item[\cs{DeclareAlternateKanjiFont}\{<base-encoding>\}\{<base-family>\}\{<base-series>\}\{<base-shape>\}\\
+  \null\hfill\{<alt-encoding>\}\{<alt-family>\}\{<alt-series>\}\{<alt-shape>\}\{<range>\}]
+%<*ja>
+\ref{ssec-altfont}節の\
+\cs{ltjdeclarealtfont} と同様に,前半の4引数の
+和文フォント(基底フォント)のうち<range>中の文字を
+第5から第8引数の和文フォントを使って組むように指示する.
+使用例を図\nobreak\ref{fig:altkanji}に載せた.
+
+\begin{itemize}
+ \item
+\cs{ltjdeclarealtfont} では基底フォント・置き換え先和文フォントはあらかじめ定義されてい
+            ないといけない(その代わり即時発効)であったが,
+\cs{DeclareAlternateKanjiFont} の設定が
+実際に効力が発揮するのは,書体変更やサイズ変更を行った時,
+あるいは(これらを含むが)\cs{selectfont} が実行された時である.
+ \item
+段落やhboxの最後での設定値が段落/hbox全体にわたって通用する点や,
+<range>に負数$-n$を指定した場合,それが「基底フォントの文字クラス$n$に属する文字全体」
+と解釈されるのは \cs{ltjdeclarealtfont} と同じである.
+\end{itemize}%
+%</ja>
+%<*en>
+As \cs{ltjdeclarealtfont}~(Subsection~\ref{ssec-altfont}),
+characters in <range> of the Japanese font (we say the \emph{base font})
+which specified by first 4 arguments are typeset
+by the Japanese font which specified by fifth to eighth arguments
+(we say the \emph{alternate font}).
+An example is shown in Figure~\ref{fig:altkanji}.
+
+\begin{itemize}
+ \item
+In \cs{ltjdeclarealtfont}, the base font and the alternate font must be already defined.
+But this \cs{DeclareAlternateKanjiFont} is not so.
+In other words, \cs{DeclareAlternateKanjiFont} is effective only after
+current Japanese font is changed, or only after \cs{selectfont} is executed.
+ \item \dots
+\end{itemize}%
+\vspace{-\medskipamount}
+%</en>
+\end{cslist}
+
+%<*en>
+As closing this subsection, we shall introduce an example of
+\cs{SetRelationFont} and \cs{userelfont}:
+%</en>
+%<*ja>
+この節の終わりに,\cs{SetRelationFont} と \cs{userelfont} の例を
+紹介しておこう.\cs{userelfont} の使用によって,「abc」の部分のフォントが
+Avant Garde (OT1/pag/m/n) に変わっていることがわかる.
+%</ja>
+\begin{LTXexample}[width=0.3\textwidth]
+\makeatletter
+\SetRelationFont{JY3}{\k@family}{m}{n}{OT1}{pag}{m}{n}
+  % \k@family: current Japanese font family
+\userelfont\selectfont あいうabc
+\end{LTXexample}
+
+%<en>\subsection{\cs{fontfamily}}
+%<ja>\subsection{\cs{fontfamily}}
+\label{ssec-fontfamilycmd}
+%<*en>
+In this subsection, we describe when \cs{fontfamily}<family> changes current
+Japanese/alphabetic font family. Basically, current Japanese fotn family is changed to
+<family> if it is recognized as a Japanese font family, and similar with alphabetic font
+family. There is a case that current Japanese/alphabetic font family are both changed to
+<family>, and another case that <family> isn't recognized as a Japanese/alphabetic font
+family either.
 
-First, Whether Japanese font family will be changed is determined by following conditions.
+\paragraph{Recognition as Japanese font family}
+First, Whether Japanese font family will be changed is determined in following order.
+This order is very similar to \cs{fontfamily} in \pLaTeXe, but we re-implemented in Lua.
 We use an auxiliary list~$N_{\mathrm{J}}$.
 %</en>
 %<*ja>
-元々の\LaTeXe におけるものと同様に,このコマンドは現在のフォントファミリ(欧文,
-和文,\emph{もしくは両方})を<family>に変更する.
-まず,和文フォントファミリが変更されるかは以下の順序で決定される.
-補助的に「和文フォントファミリではない」ファミリを格納したリスト$N_{\mathrm{J}}$を用いる.
+本節では,\cs{fontfamily}<family> がいつ和文/欧文フォントファミリを変更するかについて解説
+する.基本的には,<family>が和文フォントファミリだと認識されれば和文側が,欧文フォントファ
+ミリだと認識されれば欧文側が変更される.どちらとも認識されれば和文・欧文の両方が変わるこ
+とになるし,当然どちらとも認識されないこともある.
+
+\paragraph{和文フォントファミリとしての認識}
+まず,<family>が和文フォントファミリとして認識されるかは以下の順序で決定される.
+これは\pLaTeXe の \cs{fontfamily} にとても似ているが,ここではLuaによって実装している.
+補助的に「和文フォントファミリではないと認識された」ファミリを格納したリスト$N_{\mathrm{J}}$を用いる.
 %</ja>
 \begin{enumerate}
 %<*en>
 \item If the family~<family> has been defined already by \cs{DeclareKanjiFamily},
-      current Japanese font family will be changed to <family>.
+      <family> is recognized as a  Japanese font family.
       Note that <family> need not be defined under \emph{current} Japanese font encoding.
 %</en>
 %<*ja>
 \item ファミリ<family>が既に \cs{DeclareKanjiFamily} によって定義されている場合,
-      和文フォントファミリは<family>に変更される.
+      <family>は和文フォントファミリであると認識される.
       ここで,<family>は現在の和文フォントエンコーディングで定義されていなくてもよい.
 %</ja>
 %<*en>
 \item If the family~<family> has been listed in a list~$N_{\mathrm{J}}$, this means
-      that <family> is not a Japanese font family, hence current Japanese font family
-      won't be changed.
+      that <family> is not a Japanese font family.
 %</en>
 %<*ja>
 \item ファミリ<family>がリスト$N_{\mathrm{J}}$に既に含まれていれば,それは
-      <family>が和文フォントファミリではないことを意味するので,和文フォントファミリは変更されない
+      <family>が和文フォントファミリではないことを意味する.
 %</ja>
 %<*en>
-\item If the \Pkg{luatexja-fontspec} package is loaded, we stop here, and current Japanese font family
-      won't be changed.
+\item If the \Pkg{luatexja-fontspec} package is loaded, we stop here, and <family> is not
+      recognized as a Japanese font family.
 
       If the \Pkg{luatexja-fontspec} package is \emph{not} loaded, 
 now \LuaTeX-ja looks whether there exists a Japanese font encoding~<enc> such that
       a font definition named \texttt{<enc><family>.fd} (the file name is
-      all lowercase) exists. If so, current Japanese font family will be changed to
-      <family>~(the font definition file won't be loaded here). 
-      If not, current Japanese font family won't be changed, and
+      all lowercase) exists. If so, <family> is recognized as a  Japanese font family (the font definition file won't be loaded here). 
+      If not, <family> is not a Japanese font family, and 
       <family> is appended to the list~$N_{\mathrm{J}}$.
 %</en>
 %<*ja>
 \item もし\Pkg{luatexja-fontspec}パッケージが読み込まれていれば,ここで終了であり,
-和文フォントファミリは変更されないことになる.
+<family>は和文フォントファミリとして認識されないことになる.
 
 もし\Pkg{luatexja-fontspec}パッケージが読み込まれていなければ,和文エンコーディング<enc>で
 フォント定義ファイル\texttt{<enc><family>.fd}(ファイル名は全て小文字)が存在するようなも
       のがあるかどうかを調べる.
-存在すれば,和文フォントファミリは<family>に変更される(フォント定義ファイルは変更されな
+存在すれば,<family>は和文フォントファミリと認識される(フォント定義ファイルは読み込まれな
       い).
-存在しなければ,リスト$N_{\mathrm{J}}$に<family>を追加するだけで,和文フォントファミリは変更されない
+存在しなければ,<family>は和文フォントファミリでないと認識され,リスト$N_{\mathrm{J}}$に<family>を追加することでそれを記憶する
 
 %</ja>
 \end{enumerate}
 
 %<*en>
-Next, whether alphabetic font family will be changed is determined by following conditions.
-We use an auxiliary lists $F_{\mathrm{A}}$~and~$N_{\mathrm{A}}$, and
-patches \cs{DeclareFontEncoding}~and~\cs{DeclareFontFamily} to keep track of alphabetic
-            font encodings~and~families.
+\paragraph{Recognition as alphabetic font family}
+Next, whether alphabetic font family will be changed is determined in following order.
+We use auxiliary lists $F_{\mathrm{A}}$~and~$N_{\mathrm{A}}$, 
 %</en>
 %<*ja>
-次に,欧文フォントファミリについての判定を述べていく.
-補助的に「欧文フォントファミリと判明した」ファミリのリスト$F_{\textrm{A}}$と,
-「欧文フォントファミリではない」ファミリを格納したリスト$N_{\mathrm{A}}$を用いる.
+\paragraph{欧文フォントファミリとしての認識}
+同様に,<family>が和文フォントファミリとして認識されるかは以下の順序で決定される.
+補助的に「欧文フォントファミリと既に認識された」ファミリのリスト$F_{\textrm{A}}$と,
+「欧文フォントファミリではないと認識された」ファミリを格納したリスト$N_{\mathrm{A}}$を用いる.
 %</ja>
 
 \begin{enumerate}
 %<*en>
 \item If the family~<family> has been listed in a list~$F_{\mathrm{A}}$, 
-      current alphabetic font family will be changed to <family>.
-      Note that <family> need not be defined under \emph{current} alphabetic font encoding.
+      <family> is recognized as an alphabetic font family.
 %</en>
 %<*ja>
 \item ファミリ<family>がリスト$F_{\mathrm{A}}$に既に含まれていれば,
-      欧文フォントファミリは<family>に変更される.
-      ここで,<family>は現在の欧文フォントエンコーディングで定義されていなくてもよい.
+      <family>は欧文フォントファミリと認識される.
 %</ja>
 %<*en>
 \item If the family~<family> has been listed in a list~$N_{\mathrm{A}}$, this means
-      that <family> is not a alphabetic font family, hence current alphabetic font family
-      won't be changed.
+      that <family> is not  an alphabetic font family.
 %</en>
 %<*ja>
 \item ファミリ<family>がリスト$N_{\mathrm{A}}$に既に含まれていれば,それは
-      <family>が欧文フォントファミリではないことを意味するので,欧文フォントファミリは変更されない
+      <family>が欧文フォントファミリではないことを意味する.
 %</ja>
 %<*en>
 \item If there exists an alphabetic font encoding such that the family~<family> has been
-      defined under it, current alphabetic font family will be changed to <family>, and
-      <family> is appended to the list~$F_{\mathrm{A}}$.
+      defined under it, <family> is recognized as an alphabetic font family, and
+      to memorize this, <family> is appended to the list~$F_{\mathrm{A}}$.
 %</en>
 %<*ja>
 \item ある欧文フォントエンコーディング下でファミリ<family>が定義されていれば,
-      リスト$F_{\mathrm{A}}$に<family>を追加し,欧文フォントファミリは<family>に変更される.
+      <family>は欧文フォントファミリと認識され,リスト$F_{\mathrm{A}}$に<family>を追加することでこのことを記憶する.
 %</ja>
 %<*en>
 \item Now \LuaTeX-ja looks whether there exists an alphabetic font encoding~<enc> such that
@@ -5950,108 +6099,50 @@ patches \cs{DeclareFontEncoding}~and~\cs{DeclareFontFamily} to keep track of alp
 \item 最終段階では,欧文エンコーディング<enc>で
 フォント定義ファイル\texttt{<enc><family>.fd}(ファイル名は全て小文字)が存在するようなも
       のがあるかどうかを調べる.
-存在すれば,欧文フォントファミリは<family>に変更される(フォント定義ファイルは変更されな
-      い).
-存在しなければ,リスト$N_{\mathrm{A}}$に<family>を追加するだけで,欧文フォントファミリは変更されない.
-
+存在すれば,<family>は欧文フォントファミリと認識される(フォント定義ファイルは読み込まれない).
+存在しなければ,<family>は欧文フォントファミリと認識されないので,リスト$N_{\mathrm{A}}$に
+      <family>を追加してそのことを記憶する.
 %</ja>
 \end{enumerate}
-%<*en>
-Of course, there is a case that ``Japanese font family nor alphabetic font family is changed''.
-In this case, \LuaTeX-ja treats ``the argument <family> is wrong'', so 
-the default family for font substitution is used for alphabetic and Japanese fonts. 
-%%% Note that current font encoding will not
-%%%      be set to <family>, unlike the original implementation in \LaTeX.
 
-Note that the execution of \cs{DeclareFontFamily} \emph{after} loading of \LuaTeX-ja makes
+%<*en>
+Also, each call of \cs{DeclareFontFamily} \emph{after} loading of \LuaTeX-ja makes
 the second argument (family) is appended to the list~$F_{\mathrm{A}}$.
 %</en>
 %<*ja>
-さて,引数によっては,「和文フォントファミリも欧文フォントファミリも変更されませんでした」
-という時代もあり得る.
-  この場合,引数<family>は不正だった,ということになるので,
-代替フォントに用いられるデフォルトのフォントファミリが欧文フォントと
-  和文フォントに用いられる.
-%%%LaTeX のオリジナルの実装とは異なり,
-%%%  現在のエンコーディングは<family>には設定されないことに注意する.
-
-なお,\cs{DeclareFontFamily}を\LuaTeX-jaの読み込み後に実行した場合は,
+また,\cs{DeclareFontFamily}が\LuaTeX-jaの読み込み後に実行された場合は,
 第2引数(ファミリ名)が自動的に$F_{\mathrm{A}}$に追加される.
 %</ja>
 
-\begin{figure}[!tb]
-\begin{LTXexample}[pos=b]
-\DeclareKanjiFamily{JY3}{edm}{}
-\DeclareFontShape{JY3}{edm}{m}{n}    {<-> s*KozMinPr6N-Regular:jfm=ujis;}{}
-\DeclareFontShape{JY3}{edm}{m}{green}{<-> s*KozMinPr6N-Regular:jfm=ujis;color=007F00}{}
-\DeclareFontShape{JY3}{edm}{m}{blue} {<-> s*KozMinPr6N-Regular:jfm=ujis;color=0000FF}{}
-\DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{green}{"4E00-"67FF,{-2}-{-2}}
-\DeclareAlternateKanjiFont{JY3}{edm}{m}{n}{JY3}{edm}{m}{blue}{ "6800-"9FFF}
-{\kanjifamily{edm}\selectfont
-日本国民は、正当に選挙された国会における代表者を通じて行動し、……}
-\end{LTXexample}
-%<ja>\caption{\cs{DeclareAlternateKanjiFont} の使用例}
-%<en>\caption{An example of \cs{DeclareAlternateKanjiFont}}
-\label{fig:altkanji}
-\end{figure}
-
-\item[\cs{DeclareAlternateKanjiFont}\{<base-encoding>\}\{<base-family>\}\{<base-series>\}\{<base-shape>\}\\
-  \null\hfill\{<alt-encoding>\}\{<alt-family>\}\{<alt-series>\}\{<alt-shape>\}\{<range>\}]
-%<*ja>
-\ref{ssec-altfont}節の\
-\cs{ltjdeclarealtfont} と同様に,前半の4引数の
-和文フォント(基底フォント)のうち<range>中の文字を
-第5から第8引数の和文フォントを使って組むように指示する.
-使用例を図\nobreak\ref{fig:altkanji}に載せた.
-
-\begin{itemize}
- \item
-\cs{ltjdeclarealtfont} では基底フォント・置き換え先和文フォントはあらかじめ定義されてい
-            ないといけない(その代わり即時発効)であったが,
-\cs{DeclareAlternateKanjiFont} の設定が
-実際に効力が発揮するのは,書体変更やサイズ変更を行った時,
-あるいは(これらを含むが)\cs{selectfont} が実行された時である.
- \item
-段落やhboxの最後での設定値が段落/hbox全体にわたって通用する点や,
-<range>に負数$-n$を指定した場合,それが「基底フォントの文字クラス$n$に属する文字全体」
-と解釈されるのは \cs{ltjdeclarealtfont} と同じである.
-\end{itemize}%
-%</ja>
 %<*en>
-As \cs{ltjdeclarealtfont}~(Subsection~\ref{ssec-altfont}),
-characters in <range> of the Japanese font (we say the \emph{base font})
-which specified by first 4 arguments are typeset
-by the Japanese font which specified by fifth to eighth arguments
-(we say the \emph{alternate font}).
-An example is shown in Figure~\ref{fig:altkanji}.
-
-\begin{itemize}
- \item
-In \cs{ltjdeclarealtfont}, the base font and the alternate font must be already defined.
-But this \cs{DeclareAlternateKanjiFont} is not so.
-In other words, \cs{DeclareAlternateKanjiFont} is effective only after
-current Japanese font is changed, or only after \cs{selectfont} is executed.
- \item \dots
-\end{itemize}%
-\vspace{-\medskipamount}
+The above order is very similar to \cs{fontfamily} in \pLaTeXe, but more complicated (clause~3.).
+This is because  \pLaTeXe\ is a \emph{format} however \LuaTeX-ja is not, 
+hence \LuaTeX-ja does not know calls of \cs{DeclareFontFamily} \emph{before} itself is
+loaded.
 %</en>
-\end{cslist}
+%<*ja>
+以上の方針は\pLaTeXe における \cs{fontfamily} にやはり類似しているが,3.が加わり若干複雑になっている.
+それは\pLaTeXe がフォーマットであるのに対し\LuaTeX-jaはそうでないため,
+\LuaTeX-jaは自身が読み込まれる前にどういう\cs{DeclareFontFamily}の呼び出しがあったか
+把握できないからである.
+%</ja>
 
+%<en>\paragraph{Remarks}
+%<ja>\paragraph{注意}
 %<*en>
-As closing this subsection, we shall introduce an example of
-\cs{SetRelationFont} and \cs{userelfont}:
+Of course, there is a case that <family> is not recognized as a Japanese font family,  nor
+an alphabetic font family.
+In this case, \LuaTeX-ja treats ``the argument <family> is wrong'', so
+set both current alphabetic and Japanese font family to <family>,
+to use the default family for font substitution.
 %</en>
 %<*ja>
-この節の終わりに,\cs{SetRelationFont} と \cs{userelfont} の例を
-紹介しておこう.\cs{userelfont} の使用によって,「abc」の部分のフォントが
-Avant Garde (OT1/pag/m/n) に変わっていることがわかる.
+さて,引数によっては,「和文フォントファミリとも欧文フォントファミリも認識されなかった」
+という事態もあり得る.
+  この場合,引数<family>は不正だった,ということになるので,
+和文・欧文の両方のフォントファミリを<family>に設定し,代用フォントが使われるに任せることにする.
 %</ja>
-\begin{LTXexample}[width=0.3\textwidth]
-\makeatletter
-\SetRelationFont{JY3}{\k@family}{m}{n}{OT1}{pag}{m}{n}
-  % \k@family: current Japanese font family
-\userelfont\selectfont あいうabc
-\end{LTXexample}
+
 
 %<*en>
 \section{Addons}