1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Typesetting Macros Caps}
15
16\unprotect
17
18
19
20
21\registerctxluafile{typocap}{optimize}
22
23
24
25
26
27
28
29
30
31
32
33\installcorenamespace{capitals}
34
35\installcommandhandler \??capitals {capitals} \??capitals
36
37
38
39\definecapitals[\v!WORD]
40\definecapitals[\v!capital]
41\definecapitals[\v!Capital]
42\definecapitals[\v!mixed]
43\definecapitals[\v!Word]
44\definecapitals[\v!Words]
45\definecapitals[\v!camel]
46\definecapitals[\v!word][\c!style=]
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78\unexpanded\def\setcharactercasing[#1]
79 {\clf_setcharactercasing{#1}\fontid\font}
80
81
82
83
84
85
86
87
88
89\unexpanded\def\typo_capitale_WORD {\clf_setcharactercasing{\v!WORD }\fontid\font}
90\unexpanded\def\typo_capitale_word {\clf_setcharactercasing{\v!word }\fontid\font}
91\unexpanded\def\typo_capitale_Word {\clf_setcharactercasing{\v!Word }\fontid\font}
92\unexpanded\def\typo_capitale_Words{\clf_setcharactercasing{\v!Words}\fontid\font}
93\unexpanded\def\typo_capitale_camel{\clf_setcharactercasing{\v!camel}\fontid\font}
94
95\unexpanded\def\WORD {\triggergroupedcommandcs\typo_capitale_WORD }
96\unexpanded\def\word {\triggergroupedcommandcs\typo_capitale_word }
97\unexpanded\def\Word {\triggergroupedcommandcs\typo_capitale_Word }
98\unexpanded\def\Words{\triggergroupedcommandcs\typo_capitale_Words}
99\unexpanded\def\camel{\triggergroupedcommandcs\typo_capitale_camel}
100
101\let\WORDS\WORD
102\let\words\word
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158\let\disablepseudocaps\relax
159
160\newconditional\c_typo_capitals_pseudo
161
162\unexpanded\def\usepseudocaps{\settrue \c_typo_capitals_pseudo}
163\unexpanded\def\userealcaps {\setfalse\c_typo_capitals_pseudo}
164
165\usepseudocaps
166
167
168
169
170
171\def\typo_capitals_set_fake#1
172 {\edef\currentcapitals{#1}
173 \clf_setcharactercasing{\currentcapitals}\fontid\font
174 \usecapitalsstyleparameter\c!style}
175
176\def\typo_capitals_set_real#1
177 {\edef\currentcapitals{#1}
178 \sc
179 \clf_setcharactercasing{\currentcapitals}\fontid\font}
180
181
182
183
184
185
186
187
188
189
190
191
192\unexpanded\def\pseudosmallcapped{\triggergroupedcommandcs\font_style_pseudosmallcapped}
193\unexpanded\def\pseudoSmallcapped{\triggergroupedcommandcs\font_style_pseudoSmallcapped}
194\unexpanded\def\pseudoSmallCapped{\triggergroupedcommandcs\font_style_pseudoSmallCapped}
195\unexpanded\def\pseudoMixedCapped{\triggergroupedcommandcs\font_style_pseudoMixedCapped}
196
197\unexpanded\def\realsmallcapped {\triggergroupedcommandcs\font_style_realsmallcapped}
198\unexpanded\def\realSmallcapped {\triggergroupedcommandcs\font_style_realSmallcapped}
199\unexpanded\def\realSmallCapped {\triggergroupedcommandcs\font_style_realSmallCapped}
200
201\unexpanded\def\notsmallcapped {\triggergroupedcommandcs\font_style_notsmallcapped}
202
203\unexpanded\def\font_style_pseudosmallcapped{\typo_capitals_set_fake\v!WORD }
204\unexpanded\def\font_style_pseudoSmallcapped{\typo_capitals_set_fake\v!capital}
205\unexpanded\def\font_style_pseudoSmallCapped{\typo_capitals_set_fake\v!Capital}
206\unexpanded\def\font_style_pseudoMixedCapped{\typo_capitals_set_fake\v!mixed }
207
208\unexpanded\def\font_style_realsmallcapped {\typo_capitals_set_real\v!WORD }
209\unexpanded\def\font_style_realSmallcapped {\typo_capitals_set_real\v!Word }
210\unexpanded\def\font_style_realSmallCapped {\typo_capitals_set_real\v!Words }
211
212\unexpanded\def\font_style_notsmallcapped {\typo_capitals_set_fake\v!word }
213
214\unexpanded\def\typo_capitals_smallcaps
215 {\ifconditional\c_typo_capitals_pseudo
216 \expandafter\firstoftwoarguments
217 \else
218 \expandafter\secondoftwoarguments
219 \fi}
220
221\unexpanded\def\smallcapped{\typo_capitals_smallcaps\pseudosmallcapped\realsmallcapped}
222\unexpanded\def\Smallcapped{\typo_capitals_smallcaps\pseudoSmallcapped\realSmallcapped}
223\unexpanded\def\SmallCapped{\typo_capitals_smallcaps\pseudoSmallCapped\realSmallCapped}
224
225\unexpanded\def\font_style_smallcapped{\typo_capitals_smallcaps\font_style_pseudosmallcapped\font_style_realsmallcapped}
226\unexpanded\def\font_style_Smallcapped{\typo_capitals_smallcaps\font_style_pseudoSmallcapped\font_style_realSmallcapped}
227\unexpanded\def\font_style_SmallCapped{\typo_capitals_smallcaps\font_style_pseudoSmallCapped\font_style_realSmallCapped}
228
229\unexpanded\def\autocap{\ifmmode\expandafter\normalcap\else\expandafter\smallcapped\fi}
230
231\prependtoks
232 \let\normalcap\cap
233\to \everydump
234
235\appendtoks
236 \let\cap\autocap
237\to \everydump
238
239\let\kap\cap
240\let\Caps\SmallCapped
241
242\let\mixedcaps\pseudoMixedCapped
243
244\let\normalsmallcapped\smallcapped
245\let\normalWORD \WORD
246\let\normalword \word
247
248\let\font_style_normalsmallcapped\font_style_smallcapped
249\let\font_style_normalWORD \WORD
250\let\font_style_normalword \word
251
252
253
254\let\normalsmallcapped\smallcapped
255
256\appendtoks
257 \ifx\currentcapitals\empty
258 \doifelse{\directcapitalsparameter\c!title}\v!yes
259 {\definealternativestyle[\v!capital ][\font_style_normalsmallcapped][\font_style_normalsmallcapped]
260 \definealternativestyle[\v!smallcaps][\setsmallcaps][\setsmallcaps]}
261 {\definealternativestyle[\v!capital ][\font_style_normalsmallcapped][\font_style_normalWORD]
262 \definealternativestyle[\v!smallcaps][\setsmallcaps][\font_style_normalWORD]}
263 \doifelse{\directcapitalsparameter\s!sc}\v!yes
264 \userealcaps
265 \usepseudocaps
266 \fi
267\to \everysetupcapitals
268
269\let\uppercased\normalWORD
270\let\lowercased\normalword
271
272\setupcapitals
273 [\c!title=\v!yes,
274 \c!style=\tx,
275 \s!sc=\v!no]
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290\definefont
291 [MixedCaps]
292 [CurrentFont*default cp 1.2\exheight]
293
294\setupcapitals
295 [\v!mixed]
296 [\c!style=MixedCaps]
297
298
299
300
301
302
303
304
305
306\unexpanded\def\randomizetext{\triggergroupedcommand{\c_attr_case\pluseight}}
307
308\definestartstop[randomized][\c!before=\dosetattribute{case}{8},\c!after=]
309
310\protect \endinput
311 |