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}{autosuffix}
22
23
24
25
26
27
28
29
30
31
32\installcorenamespace{capitals}
33
34\installcommandhandler \??capitals {capitals} \??capitals
35
36
37
38
39
40\setupcapitals
41 [\c!category=\zerocount,
42 \c!xscale=\plusthousand,
43 \c!yscale=\plusthousand]
44
45\definecapitals[\v!WORD] [\c!category=\plusone]
46\definecapitals[\v!capital] [\c!category=\plusthree]
47\definecapitals[\v!Capital] [\c!category=\plusthree]
48\definecapitals[\v!mixed] [\c!category=\plusthree]
49\definecapitals[\v!Word] [\c!category=\plusthree]
50\definecapitals[\v!Words] [\c!category=\plusthree]
51\definecapitals[\v!camel] [\c!category=\plusthree]
52
53\definecapitals[\v!cap] [\v!capital]
54\definecapitals[\v!Cap] [\v!Capital]
55
56\definecapitals
57 [\v!word]
58 [\c!category=\plustwo,
59 \c!style=]
60
61\definecapitals
62 [\v!Camel]
63 [\c!xscale=900,
64 \c!yscale=900,
65 \c!category=\plusthree]
66
67\permanent\protected\def\resetcharactercasing{\c_attr_case\attributeunsetvalue}
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98\permanent\tolerant\protected\def\setcharactercasing[#1]
99 {\clf_setcharactercasing
100 {#1}
101 \numexpr\namedcapitalsparameter{#1}\c!category\relax
102 \numexpr\namedcapitalsparameter{#1}\c!xscale\relax
103 \numexpr\namedcapitalsparameter{#1}\c!yscale\relax}
104
105\protected\def\casing[#1]{\groupedcommand{\setcharactercasing[#1]}{}}
106\protected\def\nocasing {\groupedcommand{\resetcharactercasing}{}}
107
108\protected\def\typo_capital_WORD {\setcharactercasing[\v!WORD ]}
109\protected\def\typo_capital_word {\setcharactercasing[\v!word ]}
110\protected\def\typo_capital_Word {\setcharactercasing[\v!Word ]}
111\protected\def\typo_capital_Words{\setcharactercasing[\v!Words]}
112\protected\def\typo_capital_camel{\setcharactercasing[\v!camel]}
113\protected\def\typo_capital_Camel{\setcharactercasing[\v!Camel]}
114
115\pushoverloadmode
116
117\permanent\protected\def\WORD {\triggergroupedcommandcs\typo_capital_WORD }
118\permanent\protected\def\word {\triggergroupedcommandcs\typo_capital_word }
119\permanent\protected\def\Word {\triggergroupedcommandcs\typo_capital_Word }
120\permanent\protected\def\Words{\triggergroupedcommandcs\typo_capital_Words}
121\permanent\protected\def\camel{\triggergroupedcommandcs\typo_capital_camel}
122\permanent\protected\def\Camel{\triggergroupedcommandcs\typo_capital_Camel}
123
124\aliased\let\WORDS\WORD
125\aliased\let\words\word
126
127\popoverloadmode
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179\newconditional\c_typo_capitals_pseudo
180
181\permanent\protected\def\usepseudocaps{\c_typo_capitals_pseudo\conditionaltrue}
182\permanent\protected\def\userealcaps {\c_typo_capitals_pseudo\conditionalfalse}
183
184\usepseudocaps
185
186
187
188
189
190\def\typo_capitals_set_fake#1
191 {\cdef\currentcapitals{#1}
192 \setcharactercasing[\currentcapitals]
193 \usecapitalsstyleparameter\c!style}
194
195\def\typo_capitals_set_real#1#2
196 {\cdef\currentcapitals{#1}
197 \sc
198 \setcharactercasing[\currentcapitals]}
199
200\permanent\protected\def\pseudosmallcapped{\triggergroupedcommandcs\font_style_pseudosmallcapped}
201\permanent\protected\def\pseudoSmallcapped{\triggergroupedcommandcs\font_style_pseudoSmallcapped}
202\permanent\protected\def\pseudoSmallCapped{\triggergroupedcommandcs\font_style_pseudoSmallCapped}
203\permanent\protected\def\pseudoMixedCapped{\triggergroupedcommandcs\font_style_pseudoMixedCapped}
204
205\permanent\protected\def\realsmallcapped {\triggergroupedcommandcs\font_style_realsmallcapped}
206\permanent\protected\def\realSmallcapped {\triggergroupedcommandcs\font_style_realSmallcapped}
207\permanent\protected\def\realSmallCapped {\triggergroupedcommandcs\font_style_realSmallCapped}
208
209\permanent\protected\def\notsmallcapped {\triggergroupedcommandcs\font_style_notsmallcapped}
210
211\protected\def\font_style_pseudosmallcapped{\typo_capitals_set_fake\v!WORD}
212\protected\def\font_style_pseudoSmallcapped{\typo_capitals_set_fake\v!capital}
213\protected\def\font_style_pseudoSmallCapped{\typo_capitals_set_fake\v!Capital}
214\protected\def\font_style_pseudoMixedCapped{\typo_capitals_set_fake\v!mixed }
215
216\protected\def\font_style_realsmallcapped {\typo_capitals_set_real\v!WORD}
217\protected\def\font_style_realSmallcapped {\typo_capitals_set_real\v!Word}
218\protected\def\font_style_realSmallCapped {\typo_capitals_set_real\v!Words}
219
220\protected\def\font_style_notsmallcapped {\typo_capitals_set_fake\v!word}
221
222\protected\def\typo_capitals_smallcaps
223 {\ifconditional\c_typo_capitals_pseudo
224 \expandafter\firstoftwoarguments
225 \else
226 \expandafter\secondoftwoarguments
227 \fi}
228
229\permanent\protected\def\smallcapped{\typo_capitals_smallcaps\pseudosmallcapped\realsmallcapped}
230\permanent\protected\def\Smallcapped{\typo_capitals_smallcaps\pseudoSmallcapped\realSmallcapped}
231\permanent\protected\def\SmallCapped{\typo_capitals_smallcaps\pseudoSmallCapped\realSmallCapped}
232
233\permanent\protected\def\font_style_smallcapped{\typo_capitals_smallcaps\font_style_pseudosmallcapped\font_style_realsmallcapped}
234\permanent\protected\def\font_style_Smallcapped{\typo_capitals_smallcaps\font_style_pseudoSmallcapped\font_style_realSmallcapped}
235\permanent\protected\def\font_style_SmallCapped{\typo_capitals_smallcaps\font_style_pseudoSmallCapped\font_style_realSmallCapped}
236
237\permanent\protected\def\autocap{\ifmmode\expandafter\normalcap\else\expandafter\smallcapped\fi}
238
239\prependtoks
240 \enforced\let\normalcap\cap
241\to \everydump
242
243\appendtoks
244 \enforced\let\cap\autocap
245\to \everydump
246
247\ifdefined\kap\else \aliased\let\kap\cap \fi
248
249\aliased\let\Caps\SmallCapped
250
251\aliased\let\mixedcaps\pseudoMixedCapped
252
253\aliased\let\normalsmallcapped\smallcapped
254\aliased\let\normalWORD \WORD
255\aliased\let\normalword \word
256
257\aliased\let\font_style_normalsmallcapped\font_style_smallcapped
258\aliased\let\font_style_normalWORD \WORD
259\aliased\let\font_style_normalword \word
260
261\appendtoks
262 \ifempty\currentcapitals
263 \ifcstok{\directcapitalsparameter\c!title}\v!yes
264 \definealternativestyle[\v!capital ][\font_style_normalsmallcapped][\font_style_normalsmallcapped]
265 \definealternativestyle[\v!smallcaps][\setsmallcaps][\setsmallcaps]
266 \else
267 \definealternativestyle[\v!capital ][\font_style_normalsmallcapped][\font_style_normalWORD]
268 \definealternativestyle[\v!smallcaps][\setsmallcaps][\font_style_normalWORD]
269 \fi
270 \ifcstok{\directcapitalsparameter\s!sc}\v!yes
271 \userealcaps
272 \else
273 \usepseudocaps
274 \fi
275 \fi
276\to \everysetupcapitals
277
278\aliased\let\uppercased\normalWORD
279\aliased\let\lowercased\normalword
280
281\setupcapitals
282 [\c!title=\v!yes,
283 \c!style=\tx,
284 \s!sc=\v!no]
285
286\definefont
287 [MixedCaps]
288 [CurrentFont*default cp 1.2\exheight]
289
290
291
292\setupcapitals
293 [\v!mixed]
294 [\c!style=MixedCaps]
295
296
297
298
299
300
301
302
303
304\permanent\protected\def\randomizetext{\triggergroupedcommand{\c_attr_case\pluseight}}
305
306\definestartstop[randomized][\c!before=\dosetattribute{case}{8},\c!after=]
307
308\protect \endinput
309 |