1
2
3
4
5
6
7
8
9
10
11
12
13
14\endinput
15
16\writestatus { loading } { ConTeXt Language Macros Frequency Tables }
17
18
19
20
21\unprotect
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55\chardef \charwidthmethod = 3
56
57
58
59
60
61
62\def \charwidthlanguage { \currentmainlanguage }
63
64
65
66
67
68
69\def \charfreq # 1 # 2
70 { ( \ifcase \charwidthmethod
71 # 2 \dimexpr 1 0 0 \onepoint \relax
72 \or
73 # 2 \dimexpr \emwidth 2 \relax
74 \or
75 # 2 \dimexpr \exheight \relax
76 \or
77 # 2 \fontcharwd \font # 1
78 \or
79 \dimexpr 1 0 0 \fontcharwd \font # 1 \charactertsize \charwidthlanguage \relax
80 \else
81 # 2 \dimexpr \exheight \relax
82 \fi ) }
83
84
85
86
87
88
89
90\installcorenamespace { frequencywidths }
91\installcorenamespace { frequencycounts }
92
93\let \stopcharactertable \relax
94
95\unexpanded \def \startcharactertable [ # 1 ] # 2 \stopcharactertable
96 { \startnointerference
97 \setgvalue { \??frequencywidths # 1 } { # 2 }
98 \scratchcounter \zerocount \def \charfreq # # 1 # # 2 { \advance \scratchcounter \plusone } # 2
99 \setxvalue { \??frequencycounts # 1 } { \the \scratchcounter }
100 \stopnointerference }
101
102
103
104
105
106
107
108
109\def \charactertable # 1
110 { \csname \??frequencywidths \ifcsname \??frequencywidths # 1 \endcsname # 1 \else \s!en \fi \endcsname }
111
112\def \charactertsize # 1
113 { \csname \??frequencycounts \ifcsname \??frequencycounts # 1 \endcsname # 1 \else \s!en \fi \endcsname }
114
115
116
117
118
119
120
121\startcharactertable [ en ]
122
123\stopcharactertable
124
125
126
127
128
129
130
131\def \averagecharwidth { \dimexpr ( \zeropoint \charactertable \charwidthlanguage ) 1 0 0 \relax }
132
133\unexpanded \def \showcharfreq
134 { \hbox \bgroup
135 \charwidthlanguage :
136 \dostepwiserecurse \zerocount \plusfour \plusone
137 { \chardef \charwidthmethod \recurselevel \relax
138 \enspace \recurselevel \the \dimexpr ( \averagecharwidth ) }
139 \egroup }
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209\let \normalaveragecharacterwidth \averagecharacterwidth
210
211\unexpanded \def \freezeaveragecharacterwidth
212 { \xdef \averagecharacterwidth { \dimexpr \the \normalaveragecharacterwidth \relax } }
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235\protect \endinput
236 |