1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34\writestatus{loading}{ConTeXt Encoding Macros Initialization}
35
36\unprotect
37
38
39
40\immutable\let\defaultencoding\s!default
41
42
43
44
45
46
47\installcorenamespace{accents}
48
49
50
51\permanent\protected\def\defineaccent#1 #2 #3
52 {\dodefineaccentcommand{#1}
53 \dodefineaccent{#1}{#2}{#3}}
54
55\permanent\protected\def\dodefineaccentcommand#1
56 {\ifcsname\string#1\endcsname\else
57 \edefcsname\string#1\endcsname{\noexpand\dohandleaccent{\string#1}}
58 \fi}
59
60\permanent\protected\def\dodefineaccent#1#2#3
61 {\defcsname\??accents\string#1\string#2\empty\endcsname{#3}}
62
63\permanent\protected\def\dohandleaccent#1#2
64 {\csname\??accents
65 \ifcsname\??accents\string#1#2\empty\endcsname
66 \string#1#2\empty
67 \orelse\ifcsname\??accents\string#1\string#2\empty\endcsname
68 \string#1\string#2\empty
69 \else
70 \endcsname#2\csname\??accents
71 \fi
72 \endcsname}
73
74\immutable\letcsname\??accents\endcsname\empty
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89\permanent\protected\def\dodefinecombine#1#2
90 {\ifcsname\string#1\endcsname\else
91 \permanent\protected\defcsname with#1\endcsname##1{\chr{##1#2}}
92 \fi}
93
94
95
96
97\permanent\protected\def\definecharacter#1 #2
98 {\doifelsenumber{\string#2}
99 {\edefcsname\string#1\endcsname{\tocharacter#2}}
100 {\protected\defcsname\string#1\endcsname{#2}}}
101
102
103
104
105\permanent\protected\def\definecommand#1 #2
106 {\protected\defcsname\string#1\endcsname{#2}}
107
108\permanent\protected\def\dodefinecommand#1#2
109 {
110 \frozen\protected\defcsname\string#1\endcsname{#2}}
111
112
113
114\clf_defineaccents
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138\pushoverloadmode
139
140\suggestedalias \` \withgrave
141\suggestedalias \' \withacute
142\suggestedalias \^ \withcircumflex
143\suggestedalias \~ \withtilde
144\suggestedalias \= \withmacron
145\suggestedalias \u \withbreve
146\suggestedalias \. \withdot
147\suggestedalias \" \withdieresis
148\suggestedalias \r \withring
149\suggestedalias \H \withdoubleacute
150\suggestedalias \v \withcaron
151\suggestedalias \c \withcedilla
152\suggestedalias \k \withogonek
153\suggestedalias \d \withdotbelow
154
155\popoverloadmode
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183\newbox\b_enco_accent
184
185
186
187
188\permanent\protected\def\buildtextaccent#1#2
189 {\dontleavehmode\begingroup
190 \setbox\scratchboxone\hbox{#1}
191 \setbox\scratchboxtwo\hbox{#2}
192 \scratchheight{\ht\scratchboxtwo\ht\scratchboxone}
193 \scratchdepth {\dp\scratchboxtwo\dp\scratchboxone}
194 \scratchwidth \wd\scratchboxtwo
195 \hbox to \wd\ifdim\wd\scratchboxone>\wd\scratchboxtwo\scratchboxone\else\scratchboxtwo\fi\bgroup
196 \hss\box\scratchboxtwo\hss
197 \hskip\scratchwidth
198 \hss
199 \ifdim\ht\scratchboxone>\exheight
200
201 \raise{\scratchheight\exheight3}
202 \else
203 \lower{\scratchdepth\exheight3}
204 \fi
205 \box\scratchboxone
206 \hss
207 \egroup
208 \endgroup}
209
210\permanent\protected\def\bottomaccent#1#2#3#4#5
211 {\dontleavehmode
212 \vtop
213 {\forgetall
214 \baselineskip\zeroskip
215 \lineskip#1\relax
216 \everycr\emptytoks
217 \tabskip\zeroskip
218 \lineskiplimit\zeropoint
219 \setbox0\hbox{#4}
220 \halign
221 {##\crcr\hbox{#5}\crcr
222 \hskip\hideskip
223 \hskip#2\wd0
224 \hskip#3\slantperpoint
225 \vpack to .2\exheight{\box0\vss}
226 \hskip\hideskip
227 \crcr}}}
228
229\permanent\protected\def\buildtextmacron {\bottomaccent{.25ex}{0}{15}{\textmacron}}
230\permanent\protected\def\buildtextbottomdot {\bottomaccent{.25ex}{0}{5}{\textbottomdot}}
231\permanent\protected\def\buildtextcedilla {\bottomaccent{0ex}{0}{5}{\textcedilla}}
232\permanent\protected\def\buildtextogonek {\bottomaccent{.1ex}{.5}{0}{\textogonek}}
233\permanent\protected\def\buildtextbottomcomma{\bottomaccent{.15ex}{0}{5}{\tx,}}
234
235\permanent\protected\def\topaccent#1#2#3#4#5
236 {\dontleavehmode
237 \bgroup
238 \setbox0\hbox{#4}
239 \setbox2\hbox{#5}
240 \hbox to \wd2 \bgroup
241 \hss\copy2\hss
242 \hskip\wd2
243 \hss\hskip#2\wd0\hskip#3\slantperpoint\raise#1\hbox{#4}\hss
244 \egroup
245 \egroup}
246
247\permanent\protected\def\buildtextgrave
248 {\topaccent{0pt}{0}{15}{\textgrave}}
249
250\permanent\protected\def\definemathaccent#1 #2
251 {\defcsname#1\endcsname{\mathaccent#2 }}
252
253
254
255
256
257
258
259
260
261\immutable\def\eszett {ß} \immutable\def\Eszett {SS} \permanent\def\Ssharp{SS}
262\immutable\def\lslash {ł} \immutable\def\Lslash {Ł}
263\immutable\def\dslash {đ} \immutable\def\Dslash {Đ}
264
265\immutable\def\dcroat {đ} \immutable\def\Dcroat {Đ}
266\immutable\def\kcedilla{ķ} \immutable\def\Kcedilla{Ķ}
267\immutable\def\lcedilla{ļ} \immutable\def\Lcedilla{Ļ}
268\immutable\def\ncedilla{ņ} \immutable\def\Ncedilla{Ņ}
269\immutable\def\rcedilla{ŗ} \immutable\def\Rcedilla{Ŗ}
270\immutable\def\aumlaut {ä} \immutable\def\Aumlaut {Ä}
271\immutable\def\eumlaut {ë} \immutable\def\Eumlaut {Ë}
272\immutable\def\iumlaut {ï} \immutable\def\Iumlaut {Ï}
273\immutable\def\oumlaut {ö} \immutable\def\Oumlaut {Ö}
274\immutable\def\uumlaut {ü} \immutable\def\Uumlaut {Ü}
275
276
277
278\immutable\def\textflorin{ƒ} \immutable\def\florin {ƒ}
279\immutable\def\pound {£} \immutable\def\sterling{£}
280\immutable\def\promille {‰} \immutable\def\permille{‰}
281
282
283
284\pushoverloadmode
285
286\permanent\protected\def\ampersand{\mathortext\mathampersand\textampersand}
287
288\immutable\let\percent\textpercent
289\immutable\let\procent\textpercent
290\immutable\let\dollar \textdollar
291\immutable\let\hash \texthash
292
293\popoverloadmode
294
295
296
297\ifdefined\softhyphen \else
298 \aliased\let\softhyphen\explicitdiscretionary
299\fi
300
301
302
303\aliased\let\hyphen \softhyphen
304
305
306
307
308
309
310
311
312
313
314
315
316
317\aliased\let\lowerleftsingleninequote \quotesinglebase
318\aliased\let\lowerleftdoubleninequote \quotedblbase
319\aliased\let\lowerrightsingleninequote\quotesinglebase
320\aliased\let\lowerrightdoubleninequote\quotedblbase
321
322\aliased\let\upperleftsingleninequote \quoteright
323\aliased\let\upperleftdoubleninequote \quotedblright
324\aliased\let\upperrightsingleninequote\quoteright
325\aliased\let\upperrightdoubleninequote\quotedblright
326
327\aliased\let\upperleftsinglesixquote \quoteleft
328\aliased\let\upperleftdoublesixquote \quotedblleft
329\aliased\let\upperrightsinglesixquote \quoteleft
330\aliased\let\upperrightdoublesixquote \quotedblleft
331
332\aliased\let\leftsubguillemot \guilsingleleft
333\aliased\let\rightsubguillemot \guilsingleright
334
335
336
337\permanent\protected\def\textblacksquare{\dontleavehmode\hpack{\vrule\s!width.3\s!em\s!height.4\s!em\s!depth.1\s!em}}
338
339\permanent\protected\def\schwagrave {\buildtextgrave\schwa}
340
341\installcorenamespace{controlspace}
342
343\permanent\protected\def\fallbackcontrolspace
344 {\hbox to \interwordspace \bgroup
345 \hss
346 \ifcsname\??controlspace\number\interwordspace\endcsname
347 \csname\??controlspace\number\interwordspace\endcsname
348 \else
349 \enco_fast_control_space_define
350 \fi
351 \textcontrolspace
352 \hss
353 \egroup}
354
355\protected\def\enco_fast_control_space_define
356 {\scratchdimen\interwordspace
357 \definedfont[LMTypewriterRegular at \the\dimexpr\currentfontbodyscale\dimexpr\fontbody]
358 \gletcsname\??controlspace\number\scratchdimen\endcsname\lastrawfontcall}
359
360\permanent\protected\def\normalcontrolspace
361 {\iffontchar\font\numexpr\expandafter\textcontrolspace\relax
362 \textcontrolspace
363 \else
364 \fallbackcontrolspace
365 \fi}
366
367\aliased\let\textvisiblespace\normalcontrolspace
368
369\permanent\protected\def\optionalcontrolspace
370 {\iffontchar\font\numexpr\expandafter\textcontrolspace\relax
371 \textcontrolspace
372 \else
373 \asciispacechar
374 \fi}
375
376
377
378\permanent\protected\def\fakeunderscore
379 {\relax\ifmmode
380 \vrule
381 \s!depth .12\fontexheight\mathstylefont\normalmathstyle
382 \s!width \fontinterwordspace\mathstylefont\normalmathstyle
383 \s!height\zeropoint
384 \relax
385 \else
386 \dontleavehmode\hbox\bgroup
387 \vrule
388 \s!depth .12\fontexheight\font
389 \s!width \fontinterwordspace\font
390 \s!height\zeropoint
391 \egroup
392 \fi}
393
394\permanent\protected\def\fakeunderscores{\enforced\let\_\fakeunderscore}
395\permanent\protected\def\textunderscores{\enforced\let\_\textunderscore}
396
397\textunderscores
398
399\ifdefined\mathunderscore \else \aliased\let\mathunderscore\fakeunderscore \fi
400\ifdefined\textunderscore \else \aliased\let\textunderscore\fakeunderscore \fi
401
402\permanent\protected\def\normalunderscore{\ifmmode\mathunderscore\else\textunderscore\fi}
403
404\pushoverloadmode
405 \enforced\let\_\normalunderscore
406\popoverloadmode
407
408
409
410\pushoverloadmode
411
412\permanent\protected\def\textminus
413 {\char
414 \iffontchar\font"2012 "2012 \orelse
415 \iffontchar\font"2013 "2013 \orelse
416 \iffontchar\font"2212 "2212 \else
417 "002D \fi}
418
419\permanent\protected\def\textplus
420 {\char"002B }
421
422\popoverloadmode
423
424
425
426
427
428
429
430\permanent\protected\def\celsius #1{#1\iffontchar\font℃℃\else\mathematics{\circ}C\fi}
431
432\permanent\protected\def\fraction#1#2{\mathematics{\Uabove exact .125\exheight {#1}{#2}}}
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472\permanent\protected\def\fakeminute{\startimath\mathsurround\zeropoint\mathatom \mathunspacedcode{}\prime \stopimath}
473\permanent\protected\def\fakesecond{\startimath\mathsurround\zeropoint\mathatom \mathunspacedcode{}\doubleprime\stopimath}
474
475\permanent\protected\def\mathminute{\begingroup\resetmathcollapsing\textminute\endgroup}
476\permanent\protected\def\mathsecond{\begingroup\resetmathcollapsing\textsecond\endgroup}
477
478\permanent\protected\def\minute{\ifmmode\mathminute\orelse\iffontchar\font\textminute\textminute\else\fakeminute\fi}
479\permanent\protected\def\second{\ifmmode\mathsecond\orelse\iffontchar\font\textsecond\textsecond\else\fakesecond\fi}
480
481\aliased\let\foot\minute
482\aliased\let\inch\second
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498\installcorenamespace {periods}
499
500\installsetuponlycommandhandler \??periods {periods}
501
502\setupperiods
503 [\c!n=3,
504 \c!width=.5\emwidth,
505 \c!distance=.25\emwidth,
506 \c!symbol=.]
507
508\permanent\protected\def\periods
509 {\dontleavehmode
510 \hbox\bgroup
511 \doifelsenextoptional\enco_periods_yes\enco_periods_nop}
512
513\protected\def\enco_periods_yes[#1]
514 {\doifelseassignment{#1}
515 {\setupcurrentperiods[#1]
516 \scratchcounter{\periodsparameter\c!n}}
517 {\scratchcounter{\ifempty{#1}\periodsparameter\c!n\else#1\fi}}
518 \enco_periods_finish}
519
520\protected\def\enco_periods_nop
521 {\scratchcounter{\periodsparameter\c!n}
522 \enco_periods_finish}
523
524\protected\def\enco_periods_finish
525 {\edef\p_width{\periodsparameter\c!width}
526 \ifx\p_width\v!fit
527 \enco_periods_finish_fit
528 \else
529 \enco_periods_finish_width
530 \fi
531 \egroup}
532
533\protected\def\enco_periods_finish_width
534 {\setbox\scratchbox\hbox to {\p_width}
535 {\hss\periodsparameter\c!symbol\hss}
536 \dorecurse\scratchcounter{\copy\scratchbox}}
537
538\protected\def\enco_periods_finish_fit
539 {\edef\p_symbol{\periodsparameter\c!symbol}
540 \scratchdistance{\periodsparameter\c!distance}
541 \hskip\scratchdistance
542 \dorecurse\scratchcounter{\p_symbol\hskip\scratchdistance}}
543
544\permanent\protected\def\unknown
545 {\dontleavehmode
546 \hbox\bgroup
547 \enco_periods_nop}
548
549
550
551\appendtoks
552 \enforced\let\buildtextaccent\secondoftwoarguments
553\to \everysimplifycommands
554
555
556
557\protect \endinput
558 |