char-ini.mkxl /size: 4030 b    last modification: 2024-01-16 09:02
1%D \module
2%D   [       file=char-ini,
3%D        version=2006.08.20,
4%D          title=\CONTEXT\ Character Support,
5%D       subtitle=Initialization,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\writestatus{loading}{ConTeXt Character Support / Initialization}
15
16\registerctxluafile{char-fio}{}
17\registerctxluafile{char-map}{} % maybe we will load this someplace else
18\registerctxluafile{char-tex}{autosuffix}
19\registerctxluafile{char-ent}{}
20\registerctxluafile{char-scr}{}
21%registerctxluafile{char-brl}{}
22
23\unprotect
24
25% ¨äëïöüÿ
26% ´áćéíĺńóŕśúýź
27% ˙ċėġiż
28% ¯āēīōū
29% ˝őű
30% ˆâĉêĝĥîĵôŝûŵŷ
31% `àèìòùỳ
32% ¸çķļņŗşţ
33% ˛ąęįų
34% ˚åů
35% ˘ăĕğĭŏŭ
36% ˇčďěľňřšťž
37% ˜ãĩñõũ
38
39% \def\checkedchar#1% #2%
40%   {\relax\iffontchar\font#1 \expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi{\char#1}}
41%
42% impossible in math mode so there always fallback (till we have gyre):
43%
44% use \tocharacter when possible .. the next one is nice for documents and it also accepts
45% 0x prefixed numbers
46
47\permanent\def\utfchar #1{\clf_utfchar {#1}} % todo: define public at lua end
48\permanent\def\safechar#1{\clf_safechar{#1}} % todo: define public at lua end
49
50\permanent\protected\def\Ux #1{\tocharacter\numexpr"#1\relax} % used in xml (sometimes overloaded)
51\permanent          \def\eUx#1{\tocharacter\numexpr"#1\relax} % used in xml (sometimes overloaded)
52
53\permanent\def\expandUx{\enforced\let\Ux\eUx}
54
55\permanent          \def\checkedchar        {\relax\ifmmode\expandafter\checkedmathchar\else\expandafter\checkedtextchar\fi} % #1#2
56\permanent          \def\checkedmathchar#1#2{#2}
57\permanent\protected\def\checkedtextchar  #1{\clf_doifelsecharinfont\numexpr#1\relax{\char#1}} % {#2}
58
59\newconditional\prefermathovertextchar
60
61\permanent\protected\def\textormathchar#1%
62  {\begingroup
63   \scratchcounter#1\relax
64   \ifmmode
65     \char\scratchcounter
66   \else
67      \ifconditional\prefermathovertextchar
68        % dirty trick .. maybe let this adapt to bf too ?
69        \setfontid\fontid\textfont\c_font_fam_mr
70      \fi
71      \iffontchar\font\scratchcounter
72        \char\scratchcounter
73      \else
74        \normalstartimath\char\scratchcounter\normalstopimath
75      \fi
76   \fi
77   \endgroup}
78
79\permanent\protected\def\textormathchars#1%
80  {{\font_text_or_mathchars#1\relax}}
81
82\protected\def\font_text_or_mathchars#1#2\relax
83  {\relax\ifmmode
84     #1#2%
85   \orelse\iffontchar\font`#1\relax
86     #1#2\relax
87   \else
88     \normalstartimath#1#2\normalstopimath
89   \fi}
90
91%D The codes are stored in the format, so we don't need to reinitialize them (unless
92%D of course we have adapted the table). It is on the agenda to do this with \type
93%D {tex.lccode} cum suis once they're available.
94
95% Is setting up vrb tpa and tpb needed?
96
97% move to lua side
98
99\clf_setlettercatcodes\texcatcodes
100\clf_setlettercatcodes\ctxcatcodes
101\clf_setlettercatcodes\notcatcodes
102%clf_setlettercatcodes\mthcatcodes
103\clf_setlettercatcodes\vrbcatcodes % hm ... we need to  hyphemate
104\clf_setlettercatcodes\prtcatcodes
105\clf_setlettercatcodes\tpacatcodes % hm
106\clf_setlettercatcodes\tpbcatcodes % hm
107\clf_setlettercatcodes\txtcatcodes
108
109\clf_setothercatcodes \rlncatcodes
110
111\clf_setactivecatcodes\ctxcatcodes
112\clf_setactivecatcodes\notcatcodes
113\clf_setactivecatcodes\prtcatcodes
114
115\clf_setcharacternames\ctxcatcodes
116
117\permanent\def\chardescription#1{\clf_chardescription#1\relax}
118
119% experiment (watch out: this is global and very font dependent when used with
120% casing mechanisms)
121%
122% \overloaduppercase{0xDF}{0x1E9E}}
123% \overloaduppercase{0xDF}{0x53,0x53}
124
125\permanent\protected\def\overloaduppercase{\clf_overloaduppercase} % todo: define public at lua end
126\permanent\protected\def\overloadlowercase{\clf_overloadlowercase} % todo: define public at lua end
127
128\protect \endinput
129