1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Font Macros Classes and Files}
15
16\unprotect
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44\unexpanded\def\startfontclass
45 {\dosingleempty\font_basics_start_font_class}
46
47\def\font_basics_start_font_class[#class]
48 {\push_macro_fontclass
49 \doifelse{#class}\v!each
50 {\let\fontclass\empty}
51 {\doifsomething{#class}{\def\fontclass{#class}}}}
52
53\unexpanded\def\stopfontclass
54 {\pop_macro_fontclass}
55
56\def\classfont#class#name{#class#name}
57
58
59
60
61
62
63
64
65
66
67
68
69
70\installcorenamespace {fontfile}
71
72\let\m_font_name\empty
73\let\m_font_file\empty
74
75\def \defaultfontfile{\truefontname{Normal}}
76\edef\nullfontname {\fontname\nullfont}
77
78\unexpanded\def\definefontsynonym[#name]#crap[#file]
79 {\edef\m_font_name{#name}
80 \edef\m_font_file{#file}
81 \ifx\fontclass\empty
82 \expandafter\font_basics_define_font_synonym_nop
83 \else
84 \expandafter\font_basics_define_font_synonym_yes
85 \fi}
86
87\unexpanded\def\font_basics_define_font_synonym_nop
88 {\expandafter\let\csname\??fontfile\m_font_name\endcsname\m_font_file
89 \doifelsenextoptionalcs\font_basics_define_font_synonym_nop_opt\font_basics_define_font_synonym_nop_nil}
90
91\unexpanded\def\font_basics_define_font_synonym_yes
92 {\expandafter\let\csname\??fontfile\fontclass\m_font_name\endcsname\m_font_file
93 \doifelsenextoptionalcs\font_basics_define_font_synonym_yes_opt\font_basics_define_font_synonym_yes_nil}
94
95\unexpanded\def\edefinefontsynonym[#name]#crap[#file]
96 {\edef\m_font_name{#name}
97 \edef\m_font_file{#file}
98 \ifx\fontclass\empty
99 \expandafter\font_basics_define_font_synonym_nop_expanded
100 \else
101 \expandafter\font_basics_define_font_synonym_yes_expanded
102 \fi}
103
104\unexpanded\def\font_basics_define_font_synonym_nop_expanded#crap[#spec]
105 {\expandafter\let\csname\??fontfile\m_font_name\endcsname\m_font_file
106 \normalexpanded{\font_basics_define_font_synonym_nop_opt[#spec]}}
107
108\unexpanded\def\font_basics_define_font_synonym_yes_expanded#crap[#spec]
109 {\expandafter\let\csname\??fontfile\fontclass\m_font_name\endcsname\m_font_file
110 \normalexpanded{\font_basics_define_font_synonym_yes_opt[#spec]}}
111
112\unexpanded\def\font_basics_define_font_synonym_nop_opt[#specification]
113 {\let\p_features \undefined
114 \let\p_fallbacks \undefined
115 \let\p_goodies \undefined
116 \let\p_designsize\undefined
117 \expandafter\font_basics_get_font_parameter_nop#specification,]=,}
118
119\unexpanded\def\font_basics_define_font_synonym_yes_opt[#specification]
120 {\let\p_features \undefined
121 \let\p_fallbacks \undefined
122 \let\p_goodies \undefined
123 \let\p_designsize\undefined
124 \expandafter\font_basics_get_font_parameter_yes#specification,]=,}
125
126
127
128
129\def\font_basics_get_font_parameter_nop#key=#value,
130 {\if]#key
131 \font_basics_get_font_parameter_nop_finish
132 \else
133 \expandafter\normaldef\csname p#key\endcsname{#value}
134 \expandafter\font_basics_get_font_parameter_nop
135 \fi}
136
137\def\font_basics_get_font_parameter_yes#key=#value,
138 {\if]#key
139 \font_basics_get_font_parameter_yes_finish
140 \else
141 \expandafter\normaldef\csname p#key\endcsname{#value}
142 \expandafter\font_basics_get_font_parameter_yes
143 \fi}
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158\def\font_basics_define_font_synonym_nop_nil
159 {\expandafter\let\csname\??fontfile\m_font_name\s!features \endcsname\undefined
160 \expandafter\let\csname\??fontfile\m_font_name\s!fallbacks \endcsname\undefined
161 \expandafter\let\csname\??fontfile\m_font_name\s!goodies \endcsname\undefined
162 \expandafter\let\csname\??fontfile\m_font_name\s!designsize\endcsname\undefined}
163
164\def\font_basics_define_font_synonym_yes_nil
165 {\expandafter\glet\csname\??fontfile\fontclass\m_font_name\s!features \endcsname\undefined
166 \expandafter\glet\csname\??fontfile\fontclass\m_font_name\s!fallbacks \endcsname\undefined
167 \expandafter\glet\csname\??fontfile\fontclass\m_font_name\s!goodies \endcsname\undefined
168 \expandafter\glet\csname\??fontfile\fontclass\m_font_name\s!designsize\endcsname\undefined}
169
170\def\font_basics_get_font_parameter_nop_finish
171 {\expandafter\let\csname\??fontfile\m_font_name\s!features \endcsname\p_features
172 \expandafter\let\csname\??fontfile\m_font_name\s!fallbacks \endcsname\p_fallbacks
173 \expandafter\let\csname\??fontfile\m_font_name\s!goodies \endcsname\p_goodies
174 \expandafter\let\csname\??fontfile\m_font_name\s!designsize\endcsname\p_designsize}
175
176\def\font_basics_get_font_parameter_yes_finish
177 {\expandafter\glet\csname\??fontfile\fontclass\m_font_name\s!features \endcsname\p_features
178 \expandafter\glet\csname\??fontfile\fontclass\m_font_name\s!fallbacks \endcsname\p_fallbacks
179 \expandafter\glet\csname\??fontfile\fontclass\m_font_name\s!goodies \endcsname\p_goodies
180 \expandafter\glet\csname\??fontfile\fontclass\m_font_name\s!designsize\endcsname\p_designsize}
181
182
183
184
185
186\unexpanded\def\defineclassfontsynonym
187 {\dotripleargument\font_basics_define_class_font_synonym}
188
189
190
191\def\font_basics_define_class_font_synonym[#tag][#class][#fileortag]
192 {\expandafter\normaldef\csname\??fontfile\fontclass#tag\endcsname{\fontclassname{#class}{#fileortag}}
193 \font_basics_define_font_synonym_yes_nil}
194
195\let\definefontfile\definefontsynonym
196
197\unexpanded\def\setupfontsynonym
198 {\dodoubleempty\dosetupfontsynonym}
199
200\def\dosetupfontsynonym[#name][#settings]
201 {}
202
203
204
205\def\truefontname#name
206 {\expandafter\font_helpers_true_fontname#name*\empty*\relax}
207
208\def\font_helpers_true_fontname#name*#first#rest*#crap\relax
209 {\ifcsname\??fontfile\fontclass#name\endcsname
210 \ifx#first\empty
211
212 \expandafter\truefontname\lastnamedcs
213 \else
214
215 \expandafter\font_helpers_true_fontname_check\lastnamedcs*#first#rest
216 \fi
217 \else\ifcsname\??fontfile\defaultfontclass#name\endcsname
218 \ifx#first\empty
219
220 \expandafter\truefontname\lastnamedcs
221 \else
222
223 \expandafter\font_helpers_true_fontname_check\lastnamedcs*#first#rest
224 \fi
225 \else\ifcsname\??fontfile#name\endcsname
226 \ifx#first\empty
227
228 \expandafter\truefontname\lastnamedcs
229 \else
230
231 \expandafter\font_helpers_true_fontname_check\lastnamedcs*#first#rest
232 \fi
233 \else
234 #name\ifx#first\empty\else*#first#rest\fi
235 \fi\fi\fi}
236
237\def\font_helpers_true_fontname_check#name
238 {\expandafter\font_helpers_true_fontname_check_indeed#name*\relax}
239
240\def\font_helpers_true_fontname_check_indeed#name*#crap\relax
241 {\ifcsname\??fontfile\fontclass#name\endcsname
242
243 \expandafter\font_helpers_true_fontname_check\lastnamedcs
244 \else\ifcsname\??fontfile\defaultfontclass#name\endcsname
245
246 \expandafter\font_helpers_true_fontname_check\lastnamedcs
247 \else\ifcsname\??fontfile#name\endcsname
248
249 \expandafter\font_helpers_true_fontname_check\lastnamedcs
250 \else
251 #name
252 \fi\fi\fi}
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272\def\expandfontsynonym#command#name
273 {\ifcsname\??fontfile\fontclass#name\endcsname
274
275 \expandafter\normaldef\expandafter#command\expandafter{\lastnamedcs}
276 \else\ifcsname\??fontfile\defaultfontclass#2\endcsname
277
278 \expandafter\normaldef\expandafter#command\expandafter{\lastnamedcs}
279 \fi\fi}
280
281\def\doifelsefontsynonym#name
282 {\ifcsname\??fontfile\fontclass#name\endcsname
283 \singleexpandafter\firstoftwoarguments
284 \else\ifcsname\??fontfile\defaultfontclass#name\endcsname
285 \doubleexpandafter\firstoftwoarguments
286 \else
287 \doubleexpandafter\secondoftwoarguments
288 \fi\fi}
289
290\let\doiffontsynonymelse\doifelsefontsynonym
291
292
293
294
295
296
297\def\tracedfontname#name
298 {#name\ifcsname\??fontfile\fontclass#name\endcsname
299
300 \expandafter\tracedfontname\lastnamedcs
301 \else\ifcsname\??fontfile#name\endcsname
302
303 \expandafter\tracedfontname\lastnamedcs
304 \fi\fi}
305
306
307
308
309
310
311
312
313\let\fontclass \empty
314\let\defaultfontclass\empty
315
316\def\fontclassname#class#name
317 {\ifcsname\??fontfile#class#name\endcsname
318 \fontclassname{#class}{\csname\??fontfile#class#name\endcsname}
319 \else\ifcsname\??fontfile#name\endcsname
320 \fontclassname{#class}{\csname\??fontfile#name\endcsname}
321 \else
322 #2
323 \fi\fi}
324
325\installmacrostack\fontclass
326
327
328
329
330
331
332
333
334\def\font_helpers_update_font_class_parameters
335 {\edef\m_font_class_direction {\begincsname\??fontclass\fontclass\fontstyle\s!direction \endcsname}
336 \edef\m_font_class_features {\begincsname\??fontclass\fontclass\fontstyle\s!features \endcsname}
337 \edef\m_font_class_fallbacks {\begincsname\??fontclass\fontclass\fontstyle\s!fallbacks \endcsname}
338 \edef\m_font_class_goodies {\begincsname\??fontclass\fontclass\fontstyle\s!goodies \endcsname}
339 \edef\m_font_class_designsize{\begincsname\??fontclass\fontclass\fontstyle\s!designsize\endcsname}}
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415\def\font_helpers_set_features_yes#name
416 {\ifcsname\??fontfile\fontclass#name\s!features\endcsname \edef\m_font_features{\lastnamedcs}\else
417 \ifcsname\??fontfile #name\s!features\endcsname \edef\m_font_features{\lastnamedcs}\else
418 \ifcsname\??fontfile\fontclass#name\endcsname \expandafter\font_helpers_set_features_yes\lastnamedcs \else
419 \ifcsname\??fontfile #name\endcsname \expandafter\font_helpers_set_features_yes\lastnamedcs \else
420 \let\m_font_features\empty\fi\fi\fi\fi}
421
422\def\font_helpers_set_fallbacks_yes#name
423 {\ifcsname\??fontfile\fontclass#name\s!fallbacks\endcsname \edef\m_font_fallbacks{\lastnamedcs}\else
424 \ifcsname\??fontfile #name\s!fallbacks\endcsname \edef\m_font_fallbacks{\lastnamedcs}\else
425 \ifcsname\??fontfile\fontclass#name\endcsname \expandafter\font_helpers_set_fallbacks_yes\lastnamedcs \else
426 \ifcsname\??fontfile #name\endcsname \expandafter\font_helpers_set_fallbacks_yes\lastnamedcs \else
427 \let\m_font_fallbacks\empty\fi\fi\fi\fi}
428
429\def\font_helpers_set_goodies_yes#name
430 {\ifcsname\??fontfile\fontclass#name\s!goodies \endcsname \edef\m_font_goodies{\lastnamedcs}\else
431 \ifcsname\??fontfile #name\s!goodies \endcsname \edef\m_font_goodies{\lastnamedcs}\else
432 \ifcsname\??fontfile\fontclass#name\endcsname \expandafter\font_helpers_set_goodies_yes\lastnamedcs \else
433 \ifcsname\??fontfile #name\endcsname \expandafter\font_helpers_set_goodies_yes\lastnamedcs \else
434 \let\m_font_goodies\empty\fi\fi\fi\fi}
435
436\def\font_helpers_set_designsize_yes#name
437 {\ifcsname\??fontfile\fontclass#name\s!designsize\endcsname \edef\m_font_designsize{\lastnamedcs}\else
438 \ifcsname\??fontfile #name\s!designsize\endcsname \edef\m_font_designsize{\lastnamedcs}\else
439 \ifcsname\??fontfile\fontclass#name\endcsname \expandafter\font_helpers_set_designsize_yes\lastnamedcs \else
440 \ifcsname\??fontfile #name\endcsname \expandafter\font_helpers_set_designsize_yes\lastnamedcs \else
441 \let\m_font_designsize\empty\fi\fi\fi\fi}
442
443\def\font_helpers_set_features_nop#name
444 {\ifcsname\??fontfile#name\s!features\endcsname \edef\m_font_features{\lastnamedcs}\else
445 \ifcsname\??fontfile#name\endcsname \expandafter\font_helpers_set_features_nop\lastnamedcs \else
446 \let\m_font_features\empty\fi\fi}
447
448\def\font_helpers_set_fallbacks_nop#name
449 {\ifcsname\??fontfile#name\s!fallbacks\endcsname \edef\m_font_fallbacks{\lastnamedcs}\else
450 \ifcsname\??fontfile#name\endcsname \expandafter\font_helpers_set_fallbacks_nop\lastnamedcs \else
451 \let\m_font_fallbacks\empty\fi\fi}
452
453\def\font_helpers_set_goodies_nop#name
454 {\ifcsname\??fontfile#name\s!goodies\endcsname \edef\m_font_goodies{\lastnamedcs}\else
455 \ifcsname\??fontfile#name\endcsname \expandafter\font_helpers_set_goodies_nop\lastnamedcs \else
456 \let\m_font_goodies\empty\fi\fi}
457
458\def\font_helpers_set_designsize_nop#name
459 {\ifcsname\??fontfile#name\s!designsize\endcsname \edef\m_font_designsize{\lastnamedcs}\else
460 \ifcsname\??fontfile#name\endcsname \expandafter\font_helpers_set_designsize_nop\lastnamedcs \else
461 \let\m_font_designsize\empty\fi\fi}
462
463\def\font_helpers_update_font_parameters_yes
464 {\font_helpers_set_features_yes \somefontname
465 \font_helpers_set_fallbacks_yes \somefontname
466 \font_helpers_set_goodies_yes \somefontname
467 \font_helpers_set_designsize_yes\somefontname}
468
469\def\font_helpers_update_font_parameters_nop
470 {\font_helpers_set_features_nop \somefontname
471 \font_helpers_set_fallbacks_nop \somefontname
472 \font_helpers_set_goodies_nop \somefontname
473 \font_helpers_set_designsize_nop\somefontname}
474
475\def\font_helpers_update_font_parameters
476 {\ifx\fontclass\empty\font_helpers_update_font_parameters_nop\else\font_helpers_update_font_parameters_yes\fi}
477
478\installcorenamespace{fontclass}
479
480
481
482
483
484
485
486
487
488
489
490\unexpanded\def\savefontclassparameters#style#rscale#features#fallbacks#goodies#designsize#direction
491 {\letgvalue{\??fontclass\fontclass#style\s!rscale }#rscale
492 \letgvalue{\??fontclass\fontclass#style\s!features }#features
493 \letgvalue{\??fontclass\fontclass#style\s!fallbacks }#fallbacks
494 \letgvalue{\??fontclass\fontclass#style\s!goodies }#goodies
495 \letgvalue{\??fontclass\fontclass#style\s!designsize}#designsize
496 \letgvalue{\??fontclass\fontclass#style\s!direction }#direction}
497
498
499
500\let\currentfontinstancespec\clf_currentfontinstancespec
501
502\protect \endinput
503 |