\documentclass[twoside]{jarticle} \addtolength{\textwidth}{0.9in} \setlength{\oddsidemargin}{.4in} \setlength{\evensidemargin}{.4in} \pagestyle{headings} \title{JFMファイルフォーマット} \author{ASCII Corporation \& Japanese \TeX\ Development Community} \begin{document} \maketitle \section{JFM file format} JFMファイルのフォーマットは、 基本的にはTFMファイルのフォーマットに準拠しており、 TFMを拡張した形になっている。 ここでは、主にその拡張部分について説明を行い、 その他の部分に関しては、 \TeX\ the program等のTFMの説明を参照してもらいたい。 この文書はもともと株式会社アスキーが開発したp\TeX{}に付属していた ものである。2018年に日本語\TeX{}開発コミュニティはJFMフォーマットを 拡張したため、その内容について追記してある。 \subsection{JFMファイルの構成} JFMファイル全体の構成は、 Table~\ref{構成}(\pageref{構成}ページ)に示すとおりである。 \\ ここでTFMと異なるのは次の点である。 \begin{enumerate} \item {\it char\_type}のテーブルが付け加えられたこと。 \item {\it exten}の換わりに{\it glue}のテーブルが設けられたこと。 \item 2に関連して、{\it lig\_kern}から{\it glue\_kern}テーブルへ変更されたこと。 \item これらに伴い、先頭のファイル内の各部分を規定する パラメータ表が変更されている。 また、オリジナルのTFMとの区別のためにidを付加している。 \end{enumerate} 最初の7ワードは半ワード(=2バイト)ずつに区切られ、 JFMファイルを構成する14個の要素のサイズが収められている。 これらの値は、すべて$2^{15}$よりも小さい非負の値で、 次の条件を満たしていなければならない: \begin{eqnarray*} bc &=& 0 \\ lf &=& 7 + lh + (ec - bc + 1) + nw + nh + nd + ni + nl + nk + ng + np \end{eqnarray*} \subsection{char\_type} 今回の\TeX の日本語化においては、同一の文字幅、 高さ前後に挿入されるグルー等、その文字が持つ属性全てが 同じものを、1つの{\it `char\_type'}として英字フォントの1キャラクタと 同様にして扱うようにしている。 そこで、漢字の文字コードとこの{\it char\_type}との対応付けを このテーブルを使って行う。 このテーブルの各エントリーは1ワード(=4バイト)で構成され、 上位3バイトに漢字コード、下位1バイトにキャラクタタイプを持つ \footnote{これが日本語\TeX{}開発コミュニティによって2018年1月に導入された 新仕様である;オリジナルのアスキーによる仕様では、「上位半ワードに 漢字コード、下位半ワードにキャラクタタイプを持つ」というものであった。 p\TeX{}では内部処理にJISが用いられ、JFMで扱う漢字コードは2バイトが 上限だったため十分であったが、up\TeX{}でBMP超えの3バイトの文字を JFMで扱うことを目的に仕様拡張した。}。 漢字コードは、それが16進数24bit(3バイト)で0xABcdefと表されるとき、 {\it char\_type}テーブルには{\tt cd ef AB}として格納される \footnote{オリジナルの仕様では、下位半ワードにキャラクタタイプを 格納していたが、キャラクタタイプの上限は255なので、実はその上位バイトは 常に{\tt 00}であった。このことを利用し、日本語\TeX{}開発コミュニティの 新仕様では「この{\tt 00}が実は漢字コードの上位だった」ということに して、3バイト(U+10000以上)の漢字コードで不足する1バイトを確保した。 これにより、新仕様はオリジナルの仕様の上位互換であることが保証されている。}。 テーブル内にはコードの値の順番に収められていなければならない。 またこのテーブルの先頭には、デフォルトのインデックスとして 漢字コード及びキャラクタタイプの項が0のものが、 必ず1つ存在しなければならず、このテーブルに登録されていない文字は、 キャラクタタイプが0として扱う。 つまり、このデフォルト以外の文字幅、カーン等の属性を持つキャラクタ のコードとタイプが2番目以降のエントリーとして存在しなければならない。 \subsection{char\_info} {\it char\_type}をインデックスとしてこのテーブルを 参照することにより、各{\it char\_type}の属性を検索する。 各テーブルへのインデックス等の情報を次の順番でパッキング して1ワードに収めてある。 \begin{description} \item{{\it width\_index} (8bits)} width\_tableへのインデックス \item{{\it height\_index} (4bits)} height\_tableへのインデックス \item{{\it depth\_index} (4bits)} depth\_tableへのインデックス \item{{\it italic\_index} (6bits)} italic\_tableへのインデックス \item{{\it tag} (2bits)} \begin{description} \item{${\it tag}=0$} {\it remainder}の項は無効であり 使用しないことを示す。 \item{${\it tag}=1$} {\it remainder}の項が{\it glue\_kern}への有効な インデックスであることを示す。 \item{${\it tag}=2, 3$} JFMでは使用していない。 \end{description} \item{remainder (8bits)} \end{description} JFMでは$bc$は必ずゼロ\footnote{前節にある通り、漢字コード及び キャラクタタイプの項が0のものが必ず1つ存在するため。}なので、 1つのJFMに含まれる{\it char\_info}は全部で$ec+1$ワードになる。 \subsection{glue\_kern} 特定のキャラクタタイプの組み合せ時に挿入すべき{\it glue}又は{\it kern}を 簡単なプログラム言語によって指定する。 各命令は、以下の4バイトで構成される。 \begin{description} \item{第1バイト({\it skip\_byte})} \begin{itemize} \item 128より大きいとき\\ 現在のワードが{\it char\_info}から示された最初のワード である場合は、実際の{\it glue\_kern}プログラムが {\it glue\_kern}[$256*{\it op\_byte}+{\it remainder}$]から 収められている(すなわち、再配置されている)ことを示す \footnote{「再配置」は、サイズが256を超える大きな {\it glue\_kern}テーブルを格納するための方策であり、 欧文TFMの{\it lig\_kern}テーブルにおけるそれと同様である。 2018年2月に日本語\TeX{}開発コミュニティによって、 p\TeX{}及びpPLtoTFで新たにサポートされた。}。 最初のワードでない場合(すなわち、既に再配置先あるいは プログラムのステップを開始した後のワードである場合)は、 その場でプログラムを終了する。 \item 128のとき\\ このワードを実行してプログラムを終了する。 \item 128より小さいとき\\ このワードを実行した後、次のステップまでスキップする ワード数を示す \footnote{「スキップ」(SKIP)は、元々アスキーの公式ページ {\tt http://ascii.asciimw.jp/pb/ptex/tfm/jfm.html}に文書化 されてはいたが、実際には(p)PLtoTFの{\it glue\_kern}テーブル内で SKIP命令を使用することができず、p\TeX{}もやはりSKIP命令を サポートしていなかった。 2018年2月の日本語\TeX{}開発コミュニティの改修により、 新たにサポートが開始された。}。 \end{itemize} \item{第2バイト({\it char\_type})} \begin{itemize} \item 次の文字のキャラクタタイプが、 このバイトで示すキャラクタタイプ \footnote{ここにキャラクタタイプが格納されるため、 キャラクタタイプの上限は255なのである。}と同じ場合、 第3バイトの処理を実行し、プログラム終了。 \item そうでなければ次のステップへ。 \end{itemize} \item{第3バイト({\it op\_byte})}\\ この値によってグルーを扱うかカーンを扱うかを規定する。 \begin{itemize} \item 127以下の場合{\it glue[remainder$\times$3]}のグルーを挿入。 \item 128以上の場合{\it kern[remainder]}のカーンを挿入。 \end{itemize} \item{第4バイト({\it remainder})}\\ 第3バイトにより規定される {\it glue}または{\it kern}へのインデックスを示す。 \end{description} % \subsection{glueテーブル} 自然長、伸び長、縮み長の3ワードで1つのグルーを構成する (したがって、$ng$は必ず3の倍数となる)。 各値は、$design size\times2^{-20}$を単位として表す。 \begin{description} \item{第1ワード} width \item{第2ワード} stretch \item{第3ワード} shrink \end{description} % \subsection{paramテーブル} \begin{description} \item{param[1]} 文字の傾き (italic slant)。 \item{param[2][3][4]} 漢字間に挿入するグルーのデフォルト値。 \item{param[5]} p\TeX{}でzhで参照される寸法。 \item{param[6]} p\TeX{}でzwで参照される寸法。 \item{param[7][8][9]} 漢字と英字間に挿入するグルーのデフォルト値。 \end{description} % \newpage \begin{table}[h] \begin{minipage}[b]{2in} \begin{tabular}{|c|c|} \hline \hbox to.8in{\hfil$id$\hfil} & \hbox to.8in{\hfil$nt$\hfil} \\ \hline $lf$ & $lh$ \\ \hline $bc$ & $ec$ \\ \hline $nw$ & $nh$ \\ \hline $nd$ & $ni$ \\ \hline $nl$ & $nk$ \\ \hline $ng$ & $np$ \\ \hline \multicolumn{2}{|c|}{} \\ \multicolumn{2}{|c|}{header} \\ \multicolumn{2}{|c|}{}\\ \hline \multicolumn{2}{|c|}{} \\ \multicolumn{2}{|c|}{char\_type} \\ \multicolumn{2}{|c|}{}\\ \hline \multicolumn{2}{|c|}{}\\ \multicolumn{2}{|c|}{char\_info} \\ \multicolumn{2}{|c|}{}\\ \hline \multicolumn{2}{|c|}{}\\ \multicolumn{2}{|c|}{width} \\ \multicolumn{2}{|c|}{}\\ \hline \multicolumn{2}{|c|}{}\\ \multicolumn{2}{|c|}{height} \\ \multicolumn{2}{|c|}{}\\ \hline \multicolumn{2}{|c|}{}\\ \multicolumn{2}{|c|}{depth} \\ \multicolumn{2}{|c|}{}\\ \hline \multicolumn{2}{|c|}{}\\ \multicolumn{2}{|c|}{italic} \\ \multicolumn{2}{|c|}{}\\ \hline \multicolumn{2}{|c|}{}\\ \multicolumn{2}{|c|}{glue\_kern} \\ \multicolumn{2}{|c|}{}\\ \hline \multicolumn{2}{|c|}{}\\ \multicolumn{2}{|c|}{kern} \\ \multicolumn{2}{|c|}{}\\ \hline \multicolumn{2}{|c|}{}\\ \multicolumn{2}{|c|}{glue} \\ \multicolumn{2}{|c|}{}\\ \hline \multicolumn{2}{|c|}{}\\ \multicolumn{2}{|c|}{param} \\ \multicolumn{2}{|c|}{}\\ \hline \end{tabular} \end{minipage} \begin{minipage}[b]{3.3in} \noindent \begin{tabular}{l} $id=$ JFM\_ID number. ($=11$ for yoko, $9$ for tate) \\ $nt=$ number of words in the character type table. \\ $lf=$ length of the entire file, in words. \\ $lh=$ length of the header data, in words. \\ $bc=$ smallest character type in the font. ($=0$ for JFM) \\ $ec=$ largest character type in the font. \\ $nw=$ number of words in the width table. \\ $nh=$ number of words in the height table. \\ $nd=$ number of words in the depth table. \\ $ni=$ number of words in the italic correction table. \\ $nl=$ number of words in the glue/kern table. \\ $nk=$ number of words in the kern table. \\ $ng=$ number of words in the glue table. \\ $np=$ number of font parameter words. \\ \end{tabular} \end{minipage} \caption{JFMファイルの構成\label{構成}} \end{table} \end{document}