%<*en>
This field is a list of characters which are in this character
- type~$i$. This field is not required if $i=0$, since all
- \textbf{JAchar} which are not in any character class other
+ type~$i$. This field is optional if $i=0$, since all
- \textbf{JAchar} which are not in any character class other
++ \textbf{JAchar} which do not belong any character classes other
than 0 are in the character class 0
(hence, the character class~0 contains most of
-- \textbf{JAchar}s). In the list, a character can be
-- specified by its code number, or by the character itself
-- (as a string of length~1). Moreover, there are `imaginary
- characters' which specified in the list. We will describe these later.
- characters' which can be specified in the list. We will describe these later.
++ \textbf{JAchar}s). In the list, character(s) can be specified in the following form:
++\begin{itemize}
++\item a Unicode code point
++\item the character itself (as a Lua string, like \verb+'あ'+)
++\item a string like \verb+'あ*'+ (the character followed by an asterisk)
++\item several ``imaginary'' characters (We will describe these later.)
++\end{itemize}
%</en>
%<*ja>
このフィールドは文字クラス$i$に属する文字のリストである.このフィールドは$i=0$の
You may assume that \verb+jfont_info+ has the following fields:
%</en>
%<*ja>
- \verb+jfont_info+ は以下のフィールドを持つ:
+ \verb+jfont_info+ は以下の2フィールドを持つ:
%</ja>
\begin{description}
- \item[\tt jfm]
- %<en>The index number of JFM.
- %<ja>JFMのインデックス番号.
- %<zh>JFM索引编号。
-
- \item[\tt size]
- %<en>Font size in a scaled point (${}=2^{-16}\,\textrm{pt}$).
- %<ja>スケールド・ポイント(${}=2^{-16}\,\textrm{pt}$)を単位としたフォントのサイズ.
- %<zh>以参照点(${}=2^{-16}\,\textrm{pt}$)为点位的字体大小。
+ \item[\tt size\_cache]
+ %<*ja>
+ 使用されているJFMの情報が格納されているテーブルで,
+ \textbf{このテーブルを書き換えてはならない}.
+ 中身はほぼJFMファイルに書かれている唯一のテーブルであるが,次のように若干変わっている:
+ \begin{itemize}
+ \item 各文字クラス$i$に属する文字達のテーブル
+ \texttt{[$i$].chars=\{<character>, ...\}}は,トップレベルにまとめられ,
+ \texttt{chars=\{[<character>]=$i$, ...\}}という形になっている.
+ \item \texttt{zw},~\texttt{zh}, \texttt{kanjiskip},~\texttt{xkanjiskip} の各フィールドの値は,
+ 実際に使われるフォントサイズに合わせたsp ($1\,\mathrm{sp}=2^{-6}\,\mathrm{pt}$)単位の長さに変わっている.
+ \item 各文字クラス$i$の情報を格納したテーブルも,\texttt{char\_type} フィールドの下にまとめられている.
+ 例えば,文字クラス1に属する文字の高さは \texttt{char\_type[1].height} で参照できる.
+ \item \texttt{dir} フィールドはこのテーブルにはない.
+ \end{itemize}
+ %</ja>
-%<!ja> ...
++%<*en>
++A table which contains the information of a JFM, and \emph{this table must not be changed}.
++The contents of this table are similar to that which is written is the JFM file, but
++the following differ:
++\begin{itemize}
++\item There is a \texttt{chars} table, \dots
++\item The value in \texttt{zw},~\texttt{zh}, \texttt{kanjiskip},~\texttt{xkanjiskip} fields are
++now scaled by real font size, and in scaled-pont unit.
++\item ...
++\item There is no \texttt{dir} field in this table.
++\end{itemize}
++%</en>
++%<zh> ...
\item[\tt var]
%<en>The value specified in \texttt{jfmvar=...} at a call of \verb+\jfont+.
%<zh>\subsection{基本语句兼容性}
%<*en>
--The following primitives are implemented for compatibility with \pTeX:
++The following primitives are implemented for compatibility with \pTeX.
++Note that these primitives don't support JIS~X~0213, but only JIS~X~0208.
%</en>
%<*ja>
以下のプリミティブは\pTeX との互換性のために実装されている:
\section{psft}
-
+ %<*ja>
+ \section{\Pkg{listings} パッケージへの対応}
+ \Pkg{listings} パッケージが,そのままでは日本語をまともに出力できないこと
+ はよく知られている,きちんと整形して出力するために,\Pkg{listings}パッケー
+ ジは内部で「ほとんどの文字」をアクティブにし,各文字に対してその文字の出
+ 力命令を割り当てている (\cite{listings}).
+ しかし,そこでアクティブにする文字の中に,和文文
+ 字がないためである.p\TeX 系列では,和文文字をアクティブにする手法がなく,
+ \Pkg{jlisting.sty} というパッチ\cite{jlisting}を用いることで無理やり解決していたが,
+ \LuaTeX-jaでは,(\LuaTeX がネイティブでUnicodeを理解することから)「和文
+ 文字をアクティブ化し,それらに対して適切に出力命令を設定する」というより正統的な
+ 方法を取ることにした.
+
+ \LuaTeX-ja で利用される \Pkg{listings} パッケージへのパッチ \Pkg{lltjp-listings.sty} は,
+ \Pkg{listings.sty} と\LuaTeX-jaを読み込んでおけば,
+ \verb+\begin{document}+ の箇所において自動的に読み込まれるので,通常はあまり
+ 意識する必要はない.
+
+ \paragraph{文字種}
+ \Pkg{listings} パッケージの内部では,大雑把に言うと
+ \begin{enumerate}
+ \item 識別子として使える文字 (``letter'',~``digit'') たちを
+ 集める.
+ \item letterでもdigitでもない文字が現れた時に,収集した文字列を(必要なら修飾して)出力する.
+ \item 今度は逆に,letterでない文字たちをletterが現れるまで集める.
+ \item letterが出現したら集めた文字列を出力する.
+ \item 1.に戻る.
+ \end{enumerate}
+ という処理が行われている.これにより,識別子の途中では行分割が行われないようになっている.
+ 直前の文字が識別子として使えるか否かは \verb+\lst@ifletter+ というフラグに格納されている.
+
+ さて,日本語の処理である.殆どの和文文字の前後では行分割が可能であるが,その一方で
+ 括弧類や音引きなどでは禁則処理が必要なことから,\Pkg{lltjp-listings.sty} では,
+ 直前が和文文字であるかを示すフラグ \verb+lst@kanji+ を新たに導入した.
+ 以降,説明のために以下のように文字を分類する:
+ \begin{center}
+ \small
+ \begin{tabular}{lccccc}
+ \toprule
+ &Letter&Other&Kanji&Open&Close\\\midrule
+ \verb+\lst@ifletter+&T&F&T&F&T\\
+ \verb+\lst@ifkanji+&F&F&T&T&F\\
+ 意図&識別子中の文字&その他欧文文字&殆どの和文文字&開き括弧類&閉じ括弧類\\
+ \bottomrule
+ \end{tabular}
+ \end{center}
+ なお,本来の\Pkg{listings} パッケージでの分類``digit''は,
+ 出現状況によって,上の表のLetterとOtherのどちらにもなりうる.
+ また,KanjiとCloseは \verb+\lst@ifletter+ と \verb+\lst@ifkanji+ の値が一致しているが,
+ これは間違いではない.
+
+ 例えば,Letterの直後にOpenが来た場合を考える.
+ 文字種Openは和文開き括弧類を想定しているので,Letterの直後では行分割が可能であることが望ましい.
+ そのため,この場合では,すでに収集されている文字列を出力することで行分割を許容するようにした.
+ 同じように,$5\times 5=25$通り全てについて書くと,次のようになる:
+ \begin{center}
+ \small
+ \begin{tabular}{llccccc}
+ \toprule
+ &&\multicolumn{4}{c}{後ろ側の文字}\\\cmidrule(lr){3-7}
+ &&\hbox to 4em{\hss Letter\hss}&\hbox to 4em{\hss Other\hss}
+ &\hbox to 4em{\hss Kanji\hss}&\hbox to 4em{\hss Open\hss}&Close\\\midrule
+ 直&Letter&収集&\multicolumn{3}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
+ 前&Other&出力&収集&\multicolumn{2}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
+ 文&Kanji&\multicolumn{4}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
+ 字&Open&\multicolumn{5}{c}{\hrulefill \ 収集\ \hrulefill}\\
+ 種&Close&\multicolumn{4}{c}{\hrulefill \ 出力\ \hrulefill}&収集\\
+ \bottomrule
+ \end{tabular}
+ \end{center}
+ 上の表において,
+ \begin{itemize}
+ \item 「出力」は,それまでに集めた文字列を出力(≒ここで行分割可能)を意味する.
+ \item 「収集」は,後側の文字を,現在収集された文字列に追加(行分割不可)を意味する.
+ \end{itemize}
+
+ \paragraph{和文文字扱いとなる文字}
+ \Pkg{listings} パッケージにおいて和文文字と扱われる
+ (前に述べたKanji, Open,あるいは「閉じ括弧類」分類)か否かは,
+ 通常の\textbf{JAchar}/\textbf{Alchar}の範囲の設定(\ref{ssec-setrange}節)とは全く関係ない.
+
+ また,禁則処理に関する\Param{prebreakpenalty},~\Param{postbreakpenalty}の設定も
+ \Pkg{listings} パッケージ内部ではまったく影響しない.
+
+ \medskip
+ 現在の実装では,
+ \begin{itemize}
+ \item 基本多言語面のU+2000--U+FFFF,追加漢字面の文字は,以下の場合を除きKanji扱いとなり,
+ また欧文文字2文字分の幅をとる..但し,以下は例外.
+ \item U+FF61--U+FF9Fの半角カナはKanji扱いだが,欧文文字1文字分しか幅がない.
+ \item 禁則処理のパラメータの標準値を定めている \texttt{luatexja-kinsoku.tex}\ %
+ において \Param{prebreakpenalty} が
+ 10000と設定されている文字はClose扱いである.
+ \item \texttt{luatexja-kinsoku.tex} で \Param{postbreakpenalty} が10000
+ と設定されている文字はOpen扱いである.
+ \end{itemize}
+ これらの設定をユーザが\TeX ソースで変更させる仕組みはまだ作成していない.
+
+ %</ja>
-
++%<*en>
++\section{Patch for the \Pkg{listings} package}
++\dots
++%</en>
+
\begin{thebibliography}{99}
\addcontentsline{toc}{section}{\refname}
\bibitem{texbytopic}
%%
%% config file for showexpl.sty
%%
--%% Copyright The LuaTeX-ja project team, 2005
++%% Copyright The LuaTeX-ja project team, 2012
%%
\ProvidesFile{showexpl.cfg}
[2012/05/20 v0.01 Definitions for the showexpl package (luatexja)]