char-ini.mkiv /size: 4151 b    last modification: 2021-10-28 13:50
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}{}
19\registerctxluafile{char-ent}{}
20\registerctxluafile{char-scr}{}
21
22\unprotect
23
24% ¨äëïöüÿ
25% ´áćéíĺńóŕśúýź
26% ˙ċėġiż
27% ¯āēīōū
28% ˝őű
29% ˆâĉêĝĥîĵôŝûŵŷ
30% `àèìòùỳ
31% ¸çķļņŗşţ
32% ˛ąęįų
33% ˚åů
34% ˘ăĕğĭŏŭ
35% ˇčďěľňřšťž
36% ˜ãĩñõũ
37
38% \def\checkedchar#1% #2%
39%   {\relax\iffontchar\font#1 \expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi{\char#1}}
40%
41% impossible in math mode so there always fallback (till we have gyre):
42%
43% use \normalUchar when possible .. the next one is nice for documents and it also accepts
44% 0x prefixed numbers
45
46\def\utfchar #1{\clf_utfchar {#1}}
47\def\safechar#1{\clf_safechar{#1}}
48
49\unexpanded\def\Ux #1{\Uchar\numexpr"#1\relax} % used in xml
50           \def\eUx#1{\Uchar\numexpr"#1\relax} % used in xml
51
52\unexpanded\def\expandUx{\let\Ux\eUx}
53
54\def\checkedchar        {\relax\ifmmode\expandafter\checkedmathchar\else\expandafter\checkedtextchar\fi} % #1#2
55\def\checkedmathchar#1#2{#2}
56%def\checkedtextchar  #1{\iffontchar\font#1 \expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi{\char#1}}
57
58\unexpanded\def\checkedtextchar#1% #2%
59  {\clf_doifelsecharinfont\numexpr#1\relax{\char#1}} % {#2}
60
61% \unexpanded\def\textormathchar#1%
62%   {\relax\ifmmode
63%      \char#1\relax
64%    \else\iffontchar\font#1\relax
65%      \char#1\relax
66%    \else
67%      \normalstartimath\char#1\normalstopimath
68%    \fi\fi}
69
70\newconditional\prefermathovertextchar
71
72\unexpanded\def\textormathchar#1%
73  {\begingroup
74   \scratchcounter#1\relax
75   \ifmmode
76     \char\scratchcounter
77   \else
78      \ifconditional\prefermathovertextchar
79        % dirty trick .. maybe let this adapt to bf too ?
80        \setfontid\fontid\textfont\c_font_fam_mr
81      \fi
82      \iffontchar\font\scratchcounter
83        \char\scratchcounter
84      \else
85        \normalstartimath\char\scratchcounter\normalstopimath
86      \fi
87   \fi
88   \endgroup}
89
90\unexpanded\def\textormathchars#1%
91  {{\font_text_or_mathchars#1\relax}}
92
93\unexpanded\def\font_text_or_mathchars#1#2\relax
94  {\relax\ifmmode
95     #1#2%
96   \else\iffontchar\font`#1\relax
97     #1#2\relax
98   \else
99     \normalstartimath#1#2\normalstopimath
100   \fi\fi}
101
102%D The codes are stored in the format, so we don't need to reinitialize
103%D them (unless of course we have adapted the table). It is on the agenda
104%D to do this with \type {tex.lccode} cum suis once they're available.
105
106% \def\setcclcuc#1#2#3{\global\catcode#1=\lettercatcode\global\lccode#1=#2\global\uccode#1=#3\relax}
107% \def\setcclcucself#1{\global\catcode#1=\lettercatcode\global\lccode#1=#1\global\uccode#1=#1\relax }
108
109% Is setting up vrb tpa and tpb needed?
110
111% move to lua side
112
113%clf_setcharactercodes
114
115\clf_setlettercatcodes\texcatcodes
116\clf_setlettercatcodes\ctxcatcodes
117\clf_setlettercatcodes\notcatcodes
118%clf_setlettercatcodes\mthcatcodes
119\clf_setlettercatcodes\vrbcatcodes
120\clf_setlettercatcodes\prtcatcodes
121\clf_setlettercatcodes\tpacatcodes
122\clf_setlettercatcodes\tpbcatcodes
123\clf_setlettercatcodes\txtcatcodes
124
125\clf_setactivecatcodes\ctxcatcodes
126\clf_setactivecatcodes\notcatcodes
127\clf_setactivecatcodes\prtcatcodes
128
129\clf_setcharacternames\ctxcatcodes
130
131\def\chardescription#1{\clf_chardescription#1\relax}
132
133% experiment (watch out: this is global and very font dependent when used with
134% casing mechanisms)
135%
136% \overloaduppercase{0xDF}{0x1E9E}}
137% \overloaduppercase{0xDF}{0x53,0x53}
138
139\unexpanded\def\overloaduppercase{\clf_overloaduppercase}
140\unexpanded\def\overloadlowercase{\clf_overloadlowercase}
141
142\protect \endinput
143