char-ini.tex / last modification: 2008-06-25 10:27
%D \module
%D   [       file=char-ini,
%D        version=2006.08.20,
%D          title=\CONTEXT\ Character Macros,
%D       subtitle=Character Support (Initialization),
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright=PRAGMA]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\writestatus{loading}{Character Support (initialization)}

\registerctxluafile{char-ini}{1.001}
\registerctxluafile{char-cmp}{1.001} % maybe we will load this someplace else
\registerctxluafile{char-tok}{1.001} % maybe we will load this someplace else

% \def\defchar
%   {\afterassignment\dodefchar\scratchcounter}

% \def\dodefchar
%   {\catcode\scratchcounter\active\relax
%    \ctxlua{tex.sprint("\\unexpanded\\def"..utf.char(\the\scratchcounter))}}

\def\utfchar#1{\ctxlua{tex.uprint(\number#1)}}

% \def\checkedchar#1% #2%
%   {\relax\iffontchar\font#1 \expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi{\char#1}}
%
% impossible in math mode so there always fallback (till we have gyre):

\def\checkedchar        {\relax\ifmmode\expandafter\checkedmathchar\else\expandafter\checkedtextchar\fi} % #1#2
\def\checkedmathchar#1#2{#2}
\def\checkedtextchar  #1{\iffontchar\font#1 \expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi{\char#1}}

\endinput