% tex-ini-files 2026-03-25: xetex.ini

% Public domain.  Originally by Jonathan Kew.

%% Disable the \font\preloaded=... entries from plain.tex
%% as XeTeX is primarily intended for use with other fonts
\catcode`\{=1 \catcode`\}=2 \catcode`\#=6 \catcode`\^=7 \catcode`\@=11

\scrollmode

% General Unicode set up
\input load-unicode-data.tex %

% Classes that have always been defined by the XeTeX format
\input load-unicode-xetex-classes.tex %

% Let etex.src handle things if eTeX is not enabled!
\ifx\XeTeXinterchartoks\undefined
\else
  % basic line-breaking support for CJK etc; override for more sophisticated spacing,
  % automatic font changes, etc.

  \gdef\xtxHanGlue{\hskip0pt plus 0.1em\relax} % between ideographs
  \gdef\xtxHanSpace{\hskip0.2em plus 0.2em minus 0.1em\relax} % before/after runs of CJK

  \global\XeTeXinterchartoks 0 1 = {\xtxHanSpace}
  \global\XeTeXinterchartoks 0 2 = {\xtxHanSpace}
  \global\XeTeXinterchartoks 0 3 = {\nobreak\xtxHanSpace}

  \global\XeTeXinterchartoks 1 0 = {\xtxHanSpace}
  \global\XeTeXinterchartoks 2 0 = {\nobreak\xtxHanSpace}
  \global\XeTeXinterchartoks 3 0 = {\xtxHanSpace}

  \global\XeTeXinterchartoks 1 1 = {\xtxHanGlue}
  \global\XeTeXinterchartoks 1 2 = {\xtxHanGlue}
  \global\XeTeXinterchartoks 1 3 = {\nobreak\xtxHanGlue}

  \global\XeTeXinterchartoks 2 1 = {\nobreak\xtxHanGlue}
  \global\XeTeXinterchartoks 2 2 = {\nobreak\xtxHanGlue}
  \global\XeTeXinterchartoks 2 3 = {\xtxHanGlue}

  \global\XeTeXinterchartoks 3 1 = {\xtxHanGlue}
  \global\XeTeXinterchartoks 3 2 = {\xtxHanGlue}
  \global\XeTeXinterchartoks 3 3 = {\nobreak\xtxHanGlue}
\fi

\let\s@vef@nt=\font
\let\preloaded=2
\def\font{\futurelet\next\d@ntpreload}
\def\d@ntpreload{\ifx\next\preloaded
   \let\next\sk@pf@nt
   \begingroup \catcode`\%=12 \catcode13=12
 \else
   \let\next\s@vef@nt
 \fi \next}
\begingroup
\lccode1=13
\lowercase{\endgroup
  \def\sk@pf@nt\preloaded=#1^^A{\endgroup}}

\input etex.src

% Restore the \font command and undefine other stuff
\catcode`\@=11
\let\font=\s@vef@nt
\let\d@ntpreload=\und@fined
\let\sk@pf@nt=\und@fined
\let\s@vef@nt=\und@fined

%
% Allocator for \XeTeXintercharclass values, from Enrico Gregorio
%
\newcount\xe@alloc@intercharclass % allocates intercharclass
\xe@alloc@intercharclass=\thr@@   % from 4 (1,2 and 3 are used by CJK, AFAIK)
\def\xe@alloc@#1#2#3#4#5{\global\advance#1\@ne
 \xe@ch@ck#1#4#2% make sure there's still room
 \allocationnumber#1%
 \global#3#5\allocationnumber
 \wlog{\string#5=\string#2\the\allocationnumber}}
\def\xe@ch@ck#1#2#3{%
 \ifnum#1<#2\else
  \errmessage{No room for a new #3}%
 \fi}
\def\newXeTeXintercharclass{%
 \xe@alloc@\xe@alloc@intercharclass\XeTeXcharclass\chardef\xe@charclass@boundary}

% The limit for character class has been enlarged from 256 to 4096 since XeTeX 0.99994.
% So the boundary of character class is changed from 255 to 4095.
% Primitive \XeTeXinterwordspaceshaping is introduced by XeTeX 0.99994.
% We can use it as a flag.
\ifx\XeTeXinterwordspaceshaping\und@fined
  \chardef\xe@charclass@boundary=\@cclv
\else
  \chardef\xe@charclass@boundary=4095 %
\fi

% Primitives in pdfTeX and LuaTeX, we'll just use macros here.
% Since we are generating a whatsit, not 100% compatible,
% but hopefully close enough.
\protected\def\pdfmapfile#1{\special{pdf:mapfile #1}}
\protected\def\pdfmapline#1{\special{pdf:mapline #1}}

\catcode`\@=12

\XeTeXuseglyphmetrics=1
\XeTeXdashbreakstate=1

\errorstopmode

\dump
\endinput
