Skip to content

Instantly share code, notes, and snippets.

@aminophen
Created September 10, 2023 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aminophen/d9b872c9cffee73a642910102d4f2548 to your computer and use it in GitHub Desktop.
Save aminophen/d9b872c9cffee73a642910102d4f2548 to your computer and use it in GitHub Desktop.
(u)pTeX: JFM glue/kern with more than 256 different value
%#!uptex
%% まずは kern が 256 を超える時:
% * (u)pPLtoTF はエラー発生しないが正常に格納できず→修正が必要
% * (u)pTFtoPL は元々読み出し OK
% * (u)pTeX は元々読み出し OK
% ※オリジナルの欧文版は max_kerns=5000 まで許容
\prebreakpenalty`…=0
\prebreakpenalty`「=0
\prebreakpenalty`・=0
\prebreakpenalty`。=0
\prebreakpenalty`」=0
\prebreakpenalty`;=0
\tracingonline1
\showboxdepth10000
\showboxbreadth10000
\ptextracingfonts2
\font\x=upjisr-h\x
\setbox0=\hbox{あ……あ}\showbox0
\box0
\font\y=gk-over256-kern\y
\setbox2=\hbox{あ……あ}\showbox2
\box2
\newfam\mx
\newfam\my
\textfont\mx=\x \scriptfont\mx=\x \scriptscriptfont\mx=\x
\textfont\my=\y \scriptfont\my=\y \scriptscriptfont\my=\y
\jfam\mx
\setbox4=\hbox{$あ……あ$}\showbox4
\box4
\jfam\my
\setbox6=\hbox{$あ……あ$}\showbox6
\box6
%% 次に glue が 256 を超える時:
% * (u)pPLtoTF は 256 を超えるとエラー→修正が必要
% * (u)pTFtoPL は読み出せず→修正が必要
% * (u)pTeX も正常に読み出せず→修正が必要
% →新しい (u)pTeX では max_kerns*3 = 15000 まで許容してみた
\font\z=upjisg-h\z
\setbox0=\hbox{あ・・あ。あ}\showbox0
\box0
\font\w=gk-over256-glue\w
\setbox2=\hbox{あ・・あ。あ}\showbox2
\box2
\newfam\mz
\newfam\mw
\textfont\mz=\z \scriptfont\mz=\z \scriptscriptfont\mz=\z
\textfont\mw=\w \scriptfont\mw=\w \scriptscriptfont\mw=\w
\jfam\mz
\setbox4=\hbox{$あ・・あ。あ$}\showbox4
\box4
\jfam\mw
\setbox6=\hbox{$あ・・あ。あ$}\showbox6
\box6
\bye
@aminophen
Copy link
Author

\box0 と \box2,\box4 と \box6 が同じ組み方にならなければならない。

テスト用の JFM は texjporg/tex-jp-build#162 に置いた。

@aminophen
Copy link
Author

JFM の説明書 (jfm.pdf) の glue_kern テーブルの修正:元は

\item[第3バイト] (\node{op\_byte})\\
  この値によってグルーを扱うかカーンを扱うかを規定する.
  \begin{itemize}
  \item 127以下の場合\node{glue}[$\size{remainder}\times 3$]のグルーを挿入.
  \item 128以上の場合\node{kern}[$\size{remainder}$]のカーンを挿入.
  \end{itemize}
\item[第4バイト] (\node{remainder})\\
  第3バイトにより規定される
  \node{glue}または\node{kern}へのインデックスを示す.

だったのを

\item[第3バイト] (\node{op\_byte})\\
  この値によってグルーを扱うかカーンを扱うかを規定する.
  \begin{itemize}
  \item 127以下の場合\node{glue}[$(\size{op\_byte}\times256+\size{remainder})\times 3$]のグルーを挿入.
  \item 128以上の場合\node{kern}[$(\size{op\_byte}-128)\times256+\size{remainder}$]のカーンを挿入.
  \end{itemize}
\item[第4バイト] (\node{remainder})\\
  第3バイトにより規定される
  \node{glue}または\node{kern}へのインデックスを示す.

にする。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment