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\unexpanded\def\selectfont_register[#style][#settings]
21 {\begingroup
22 \edef\currentselectfont{\expandnamespacevalue\??fontshortstyle{#style}\s!rm}
23 \checkselectfontparent
24 \setupcurrentselectfont[#settings]
25 \edef\p_selectfont_preset{\selectfontparameter\c!preset}
26 \ifx\p_selectfont_preset\empty \else
27 \processcommacommand[\p_selectfont_preset]\selectfont_preset_process
28 \setupcurrentselectfont[#settings]
29 \fi
30 \font_helpers_process_alternative_list\clf_registerfontalternative
31 \setexpandedselectfontparameter\c!style{\expandnamespaceparameter\??fontshortstyle\selectfontparameter\c!style\s!rm}
32 \xdef\selectfont_index{\clf_registerfontfamily
33 metadata {
34 typeface {\selectfontparameter\c!label}
35 style {\selectfontparameter\c!style}
36 family {\selectfontparameter\c!name}
37 }
38 options {
39 designsize {\selectfontparameter\s!designsize}
40 rscale {\selectfontparameter\s!rscale}
41 goodies {\selectfontparameter\c!goodies}
42 extras {\selectfontparameter\c!extras}
43 features {\selectfontparameter\c!features}
44 preset {\selectfontparameter\c!preset}
45 range {\selectfontparameter\c!range}
46 offset {\selectfontparameter\c!offset}
47 check {\selectfontparameter\c!check}
48 force {\selectfontparameter\c!force}
49 }
50 userdata {
51 \luaexpanded{#settings}
52 }}
53 \endgroup}
54
55
56
57
58\installcorenamespace {selectfontpreset}
59
60\unexpanded\def\definefontfamilypreset
61 {\dodoubleargument\selectfont_preset_define}
62
63\def\selectfont_preset_define[#name][#settings]
64 {\doifelseassignment{#settings}
65 {\setvalue{\??selectfontpreset#name}{\setupcurrentselectfont[#settings]}}
66 {\setvalue{\??selectfontpreset#name}{\csname\??selectfontpreset#settings\endcsname}}}
67
68\def\selectfont_preset_process#name
69 {\ifcsname\??selectfontpreset#name\endcsname
70 \lastnamedcs
71 \else
72
73 \fi}
74
75\def\selectfont_preset_define[#name][#settings]
76 {\setvalue{\??selectfontpreset#name}{\setupcurrentselectfont[#settings]}
77 \clf_definefontfamilypreset{#name}{\luaexpanded{#settings}}}
78
79\definefontfamilypreset
80 [range:chinese]
81 [\c!range={cjkcompatibilityforms,
82 cjkcompatibilityideographs,
83 cjkcompatibilityideographssupplement,
84 cjkradicalssupplement,
85 cjkstrokes,
86 cjksymbolsandpunctuation,
87 cjkunifiedideographs,
88 cjkunifiedideographsextensiona,
89 cjkunifiedideographsextensionb,
90 halfwidthandfullwidthforms,
91 verticalforms,
92 bopomofo,
93 bopomofoextended}]
94
95\definefontfamilypreset
96 [range:japanese]
97 [\c!range={cjkcompatibilityforms,
98 cjkcompatibilityideographs,
99 cjkcompatibilityideographssupplement,
100 cjkradicalssupplement,
101 cjkstrokes,
102 cjksymbolsandpunctuation,
103 cjkunifiedideographs,
104 cjkunifiedideographsextensiona,
105 cjkunifiedideographsextensionb,
106 halfwidthandfullwidthforms,
107 verticalforms,
108 hiragana,
109 katakana}]
110
111\definefontfamilypreset
112 [range:korean]
113 [\c!range={cjkcompatibilityforms,
114 cjkcompatibilityideographs,
115 cjkcompatibilityideographssupplement,
116 cjkradicalssupplement,
117 cjkstrokes,
118 cjksymbolsandpunctuation,
119 cjkunifiedideographs,
120 cjkunifiedideographsextensiona,
121 cjkunifiedideographsextensionb,
122 halfwidthandfullwidthforms,
123 verticalforms,
124 hangulcompatibilityjamo,
125 hanguljamo,
126 hanguljamoextendeda,
127 hanguljamoextendedb,
128 hangulsyllables}]
129
130\definefontfamilypreset
131 [range:cyrillic]
132 [\c!range={cyrillic,
133 cyrillicextendeda,
134 cyrillicextendedb,
135 cyrillicsupplement}]
136
137\definefontfamilypreset
138 [range:greek]
139 [\c!range={greekandcoptic,
140 greekextended,
141 ancientgreeknumbers}]
142
143\definefontfamilypreset
144 [range:hebrew]
145 [\c!range={hebrew,
146 alphabeticpresentationforms}]
147
148\definefontfamilypreset [math:digitsnormal] [\c!range=digitsnormal]
149\definefontfamilypreset [math:digitsbold] [\c!range=digitsnormal,\c!offset=digitsbold,\s!tf=style:bold]
150
151\definefontfamilypreset [math:uppercasenormal] [\c!range=uppercasenormal]
152\definefontfamilypreset [math:uppercaseitalic] [\c!range=uppercasenormal,\c!offset=uppercaseitalic, \s!tf=style:italic]
153\definefontfamilypreset [math:uppercasebold] [\c!range=uppercasenormal,\c!offset=uppercasebold, \s!tf=style:bold]
154\definefontfamilypreset [math:uppercasebolditalic] [\c!range=uppercasenormal,\c!offset=uppercasebolditalic,\s!tf=style:bolditalic]
155
156\definefontfamilypreset [math:lowercasenormal] [\c!range=lowercasenormal]
157\definefontfamilypreset [math:lowercaseitalic] [\c!range=lowercasenormal,\c!offset=lowercaseitalic, \s!tf=style:italic]
158\definefontfamilypreset [math:lowercasebold] [\c!range=lowercasenormal,\c!offset=lowercasebold, \s!tf=style:bold]
159\definefontfamilypreset [math:lowercasebolditalic] [\c!range=lowercasenormal,\c!offset=lowercasebolditalic,\s!tf=style:bolditalic]
160
161\definefontfamilypreset [math:mathematicaloperators] [\c!range=mathematicaloperators]
162
163\definefontfamilypreset [math:lowercasegreeknormal] [\c!range=lowercasegreeknormal]
164\definefontfamilypreset [math:lowercasegreekitalic] [\c!range=lowercasegreeknormal,\c!offset=lowercasegreekitalic, \s!tf=style:italic]
165\definefontfamilypreset [math:lowercasegreekbold] [\c!range=lowercasegreeknormal,\c!offset=lowercasegreekbold, \s!tf=style:bold]
166\definefontfamilypreset [math:lowercasegreekbolditalic] [\c!range=lowercasegreeknormal,\c!offset=lowercasegreekbolditalic,\s!tf=style:bolditalic]
167
168\definefontfamilypreset [math:uppercasegreeknormal] [\c!range=uppercasegreeknormal]
169\definefontfamilypreset [math:uppercasegreekitalic] [\c!range=uppercasegreeknormal,\c!offset=uppercasegreekitalic, \s!tf=style:italic]
170\definefontfamilypreset [math:uppercasegreekbold] [\c!range=uppercasegreeknormal,\c!offset=uppercasegreekbold, \s!tf=style:bold]
171\definefontfamilypreset [math:uppercasegreekbolditalic] [\c!range=uppercasegreeknormal,\c!offset=uppercasegreekbolditalic,\s!tf=style:bolditalic]
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
252
253
254
255
256
257\unexpanded\def\definefontfamily
258 {\doquadrupleempty\selectfont_family_define}
259
260\def\selectfont_family_define[#typeface][#style][#family][#settings]
261 {\doifelseassignment{#settings}
262 {\selectfont_register[#style][\c!label={#typeface},\c!style={#style},\c!name={#family},#settings]}
263 {\selectfont_register[#style][\c!label={#typeface},\c!style={#style},\c!name={#family},\c!preset={#settings}]}
264 \clf_definefontfamily\selectfont_index\relax}
265
266\unexpanded\def\definefallbackfamily
267 {\doquadrupleempty\selectfont_fallback_define}
268
269\def\selectfont_fallback_define[#typeface][#style][#family][#settings]
270 {\doifelseassignment{#settings}
271 {\selectfont_register[#style][\c!label={#typeface},\c!style={#style},\c!name={#family},#settings]}
272 {\selectfont_register[#style][\c!label={#typeface},\c!style={#style},\c!name={#family},\c!preset={#settings}]}
273 \clf_definefallbackfamily\selectfont_index\relax}
274
275\unexpanded\def\setupfontfamily
276 {\dodoubleargument\selectfont_family_setup}
277
278\def\selectfont_family_setup[#style][#settings]
279 {\ifsecondargument
280 \edef\currentselectfont{\expandnamespacevalue\??fontshortstyle{#style}\s!rm}
281 \setupcurrentselectfont[#settings]
282 \else
283 \let\currentselectfont\empty
284 \setupcurrentselectfont[#style]
285 \fi}
286
287\setupselectfont
288 [ \c!features=\s!default,
289 \s!designsize=\s!default,
290 \s!rscale=\selectfontparameter\c!scale,
291 \c!scale=1]
292
293\protect
294 |