%% xeplain.ini -- XeTeX with csplain
%% Petr Olsak  2013
%% ------------------------------------
%% You can generate the xeplain format:  xetex -etex -ini xeplain.ini
%% See the end of this file for more information
 
\catcode`\{=1 \catcode`\}=2  \catcode`\#=6

%% We will skip the \font section in plain.tex file. 
%% In order to do this we temporary re-define the \font primitive:
   \let\orifont=\font
   \long\def\font#1\ttfam=\tentt{}   % skip the font section from plain.tex
   \let\rm=\relax \let\tenex=\relax  % some macros are set to temporary meaning
   \orifont\tenrm=cmr10  \orifont\tenit=cmti10 % temporary fonts
   \def\mit{\fam1 } \def\cal{\fam2 } % some macros are set by plain TeX  
   \def\it{\fam\itfam\tenit} \def\sl{\fam\slfam\tensl} 
   \def\bf{\fam\bffam\tenbf} \def\tt{\fam\ttfam\tentt}
   \def\oldstyle{\fam1 \the\textfont1 } 

%% \outer macros do problems only, no profit:
   \let\outer=\relax

%% plain TeX macros are loaded now (including hyphenation pattern 0):
   \input plain    % format Plain

%% XeTeX initialisation:
   \newcount\XeTeXallocatorG \XeTeXallocatorG=3
   \def\newXeTeXintercharclass#1{% \newXeTeXintercharclas is documented
      \global\advance\XeTeXallocatorG by1 % in xetex-reference.pdf
      \ifnum\XeTeXallocatorG<255
        \global\chardef#1=\XeTeXallocatorG
        \wlog{\string#1=\string\XeTeXintercharclass\the\XeTeXallocatorG}%
      \else \errmessage{No room for a new \XeTeXintercharclass}\fi}
   \XeTeXuseglyphmetrics=1 % use -etex extension during format generation

%% Next base macros:
   \input plaina4  % \hsize and \vsize for A4
   \pdfpagewidth=210mm \pdfpageheight=297mm
   \def\font#1 {}  % ignore \font\tenbi=csbxti10
   \input csfontsm % macros: \sizespec, \resizefont, \resizeall, \tenbi, \bi
   \let\font=\orifont
   \input ucode    % extra codes for czech / slovak letters in Unicode
   \input ams-math % AMS math fonts 
   \def\fontfeatures{mapping=tex-text;script=latn}

%% Hyphenation patterns loading:
   % \let\allpatterns=y  % uncomment this if you needd all patterns
   % \let\deUnicode=y    % uncomment this if you need only en+cs+sk+de patterns 
   \let\onlyUnicode=y    % comment this if you need Iso+Cork+Unicode patterns
   \input hyphen.lan 

\everyjob={%
   \message{The format: xeplain based on csplain <Nov. 2013>.}%
   \message{Unicode internal encoding is set.}%
   \font\tenrm="[lmroman10-regular]:\fontfeatures"
   \font\tenbf="[lmroman10-bold]:\fontfeatures"
   \font\tenit="[lmroman10-italic]:\fontfeatures"
   \font\tenbi="[lmroman10-bolditalic]:\fontfeatures"
   \font\tentt="[texgyrecursor-regular]"
   \tenrm
   \message{Latin Modern fonts + ams-math are preloaded and A4 size implicitly defined.}%
   \message{\the\numpatterns\space hyphenation patterns are preloaded 
            (see \string\pattlist), \string\enlang\space is default.}}

\dump

==================== Comments ========================

You can generate your XeTeX format based o csplain by:

   xetex -ini -etex xeplain.ini

and use it by:

   xetex -fmt xeplain document

You can create an alias "xeplain = xetex -fmt xeplain" in your system.
You can modify this file for your needs without limitation.

Here is a test:

   \cslang
   Ahoj světe, toto je česky napsaný text zpracovaný v Unicode.
   \end

Try to process it by ``xeplain document''.

The main reason of this format: user needn't to write lines

   \input ucode 
   \input lmfonts

at the beginning of his/her document. The document processed by csplain
(with encTeX and pdfTeX) should give the same result as processing it by
xeplain.


Notices about triks used in this file
-------------------------------------

The part of loading fonts in plain.tex file is skipped because we needn't to
preload the old 7bit fonts. These fonts are unusable in Unicoded TeX-engine 
when Czech or Slovak languages are used. On the other hand, the Latin Modern
fonts (in Unicode) are preloded.

So: the \font primitive is re-defined before \input plain.tex.
Some skipped macros from plain.tex are copied here.

You can comment/uncomment or add names of the desired language patterns in
the Hyphenation section of this file. See the hyphen.lan file for more details.

XeTeX is unable to store OTF fonts into format file. This is the reason why
the LM fonts are read in \everyjob. Only math 8bit fonts are preloaded from 
ams-math file.


------------------------------------------------
