1
2
3
4
5
6
7
8
9
10
11\writestatus{loading}{ConTeXt User Module Selectfont}
12
13\registerctxluafile{fontsel}{}
14
15\unprotect
16
17\installcorenamespace {selectfont}
18\installsimplecommandhandler \??selectfont {selectfont}
19
20\let\selectfont_index\!!zerocount
21
22\protected\def\selectfont_register[#style][#settings]
23 {\begingroup
24 \edef\currentselectfont{\expandnamespacevalue\??fontshortstyle{#style}\s!rm}
25 \checkselectfontparent
26 \setupcurrentselectfont[#settings]
27 \edef\p_selectfont_preset{\selectfontparameter\c!preset}
28 \ifempty\p_selectfont_preset \else
29 \processcommacommand[\p_selectfont_preset]\selectfont_preset_process
30 \setupcurrentselectfont[#settings]
31 \fi
32 \font_helpers_process_alternative_list\clf_registerfontalternative
33 \setexpandedselectfontparameter\c!style{\expandnamespaceparameter\??fontshortstyle\selectfontparameter\c!style\s!rm}
34 \xdef\selectfont_index{\clf_registerfontfamily
35 metadata {
36 typeface {\selectfontparameter\c!label}
37 style {\selectfontparameter\c!style}
38 family {\selectfontparameter\c!name}
39 }
40 options {
41 designsize {\selectfontparameter\s!designsize}
42 rscale {\selectfontparameter\s!rscale}
43 goodies {\selectfontparameter\c!goodies}
44 extras {\selectfontparameter\c!extras}
45 features {\selectfontparameter\c!features}
46 preset {\selectfontparameter\c!preset}
47 range {\selectfontparameter\c!range}
48 offset {\selectfontparameter\c!offset}
49 check {\selectfontparameter\c!check}
50 force {\selectfontparameter\c!force}
51 }
52 userdata {
53 \luaexpanded{#settings}
54 }}
55 \endgroup}
56
57
58
59
60\installcorenamespace {selectfontpreset}
61
62\permanent\tolerant\protected\def\definefontfamilypreset[#name]#spacer[#settings]
63 {\defcsname\??selectfontpreset#name\endcsname{\setupcurrentselectfont[#settings]}
64 \clf_definefontfamilypreset{#name}{\luaexpanded{#settings}}}
65
66\def\selectfont_preset_process#name
67 {\ifcsname\??selectfontpreset#name\endcsname
68 \lastnamedcs
69 \else
70
71 \fi}
72
73\definefontfamilypreset
74 [range:chinese]
75 [\c!range={cjkcompatibilityforms,
76 cjkcompatibilityideographs,
77 cjkcompatibilityideographssupplement,
78 cjkradicalssupplement,
79 cjkstrokes,
80 cjksymbolsandpunctuation,
81 cjkunifiedideographs,
82 cjkunifiedideographsextensiona,
83 cjkunifiedideographsextensionb,
84 halfwidthandfullwidthforms,
85 verticalforms,
86 bopomofo,
87 bopomofoextended}]
88
89\definefontfamilypreset
90 [range:japanese]
91 [\c!range={cjkcompatibilityforms,
92 cjkcompatibilityideographs,
93 cjkcompatibilityideographssupplement,
94 cjkradicalssupplement,
95 cjkstrokes,
96 cjksymbolsandpunctuation,
97 cjkunifiedideographs,
98 cjkunifiedideographsextensiona,
99 cjkunifiedideographsextensionb,
100 halfwidthandfullwidthforms,
101 verticalforms,
102 hiragana,
103 katakana}]
104
105\definefontfamilypreset
106 [range:korean]
107 [\c!range={cjkcompatibilityforms,
108 cjkcompatibilityideographs,
109 cjkcompatibilityideographssupplement,
110 cjkradicalssupplement,
111 cjkstrokes,
112 cjksymbolsandpunctuation,
113 cjkunifiedideographs,
114 cjkunifiedideographsextensiona,
115 cjkunifiedideographsextensionb,
116 halfwidthandfullwidthforms,
117 verticalforms,
118 hangulcompatibilityjamo,
119 hanguljamo,
120 hanguljamoextendeda,
121 hanguljamoextendedb,
122 hangulsyllables}]
123
124\definefontfamilypreset
125 [range:cyrillic]
126 [\c!range={cyrillic,
127 cyrillicextendeda,
128 cyrillicextendedb,
129 cyrillicsupplement}]
130
131\definefontfamilypreset
132 [range:greek]
133 [\c!range={greekandcoptic,
134 greekextended,
135 ancientgreeknumbers}]
136
137\definefontfamilypreset
138 [range:hebrew]
139 [\c!range={hebrew,
140 alphabeticpresentationforms}]
141
142\definefontfamilypreset [math:digitsnormal] [\c!range=digitsnormal]
143\definefontfamilypreset [math:digitsbold] [\c!range=digitsnormal,\c!offset=digitsbold,\s!tf=style:bold]
144
145\definefontfamilypreset [math:uppercasenormal] [\c!range=uppercasenormal]
146\definefontfamilypreset [math:uppercaseitalic] [\c!range=uppercasenormal,\c!offset=uppercaseitalic, \s!tf=style:italic]
147\definefontfamilypreset [math:uppercasebold] [\c!range=uppercasenormal,\c!offset=uppercasebold, \s!tf=style:bold]
148\definefontfamilypreset [math:uppercasebolditalic] [\c!range=uppercasenormal,\c!offset=uppercasebolditalic,\s!tf=style:bolditalic]
149
150\definefontfamilypreset [math:lowercasenormal] [\c!range=lowercasenormal]
151\definefontfamilypreset [math:lowercaseitalic] [\c!range=lowercasenormal,\c!offset=lowercaseitalic, \s!tf=style:italic]
152\definefontfamilypreset [math:lowercasebold] [\c!range=lowercasenormal,\c!offset=lowercasebold, \s!tf=style:bold]
153\definefontfamilypreset [math:lowercasebolditalic] [\c!range=lowercasenormal,\c!offset=lowercasebolditalic,\s!tf=style:bolditalic]
154
155\definefontfamilypreset [math:mathematicaloperators] [\c!range=mathematicaloperators]
156
157\definefontfamilypreset [math:lowercasegreeknormal] [\c!range=lowercasegreeknormal]
158\definefontfamilypreset [math:lowercasegreekitalic] [\c!range=lowercasegreeknormal,\c!offset=lowercasegreekitalic, \s!tf=style:italic]
159\definefontfamilypreset [math:lowercasegreekbold] [\c!range=lowercasegreeknormal,\c!offset=lowercasegreekbold, \s!tf=style:bold]
160\definefontfamilypreset [math:lowercasegreekbolditalic] [\c!range=lowercasegreeknormal,\c!offset=lowercasegreekbolditalic,\s!tf=style:bolditalic]
161
162\definefontfamilypreset [math:uppercasegreeknormal] [\c!range=uppercasegreeknormal]
163\definefontfamilypreset [math:uppercasegreekitalic] [\c!range=uppercasegreeknormal,\c!offset=uppercasegreekitalic, \s!tf=style:italic]
164\definefontfamilypreset [math:uppercasegreekbold] [\c!range=uppercasegreeknormal,\c!offset=uppercasegreekbold, \s!tf=style:bold]
165\definefontfamilypreset [math:uppercasegreekbolditalic] [\c!range=uppercasegreeknormal,\c!offset=uppercasegreekbolditalic,\s!tf=style:bolditalic]
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251\permanent\tolerant\protected\def\definefontfamily[#typeface]#spacer[#style]#spacer[#family]#spacer[#settings]
252 {\ifhastok={#settings}
253 \selectfont_register[#style][\c!label={#typeface},\c!style={#style},\c!name={#family},#settings]
254 \else
255 \selectfont_register[#style][\c!label={#typeface},\c!style={#style},\c!name={#family},\c!preset={#settings}]
256 \fi
257 \clf_definefontfamily\selectfont_index\relax}
258
259\permanent\tolerant\def\definefallbackfamily[#typeface]#spacer[#style]#spacer[#family]#spacer[#settings]
260 {\ifhastok={#settings}
261 \selectfont_register[#style][\c!label={#typeface},\c!style={#style},\c!name={#family},#settings]
262 \else
263 \selectfont_register[#style][\c!label={#typeface},\c!style={#style},\c!name={#family},\c!preset={#settings}]
264 \fi
265 \clf_definefallbackfamily\selectfont_index\relax}
266
267\permanent\tolerant\protected\def\setupfontfamily[#style]#spacer[#settings]
268 {\ifparameter#settings\or
269 \edef\currentselectfont{\expandnamespacevalue\??fontshortstyle{#style}\s!rm}
270 \setupcurrentselectfont[#settings]
271 \else
272 \lettonothing\currentselectfont
273 \setupcurrentselectfont[#style]
274 \fi}
275
276\setupselectfont
277 [ \c!features=\s!default,
278 \s!designsize=\s!default,
279 \s!rscale=\selectfontparameter\c!scale,
280 \c!scale=1]
281
282\protect
283 |