type-ini.mklx /size: 21 Kb    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=type-ini,
3
%D version=2001.03.05,
4
%D title=\CONTEXT\ Typescript Macros,
5
%D subtitle=Initialization,
6
%D author=Hans Hagen,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
\writestatus
{
loading
}{
ConTeXt
Typescript
Macros
/
Initialization
}
15 16
\registerctxluafile
{
type
-
ini
}{}
17 18
%D The default fontclass is empty. We could demand always using fontclasses, and
19
%D then make the calling macros simplier (always assume fontclass) but apart from
20
%D downward compatibility issues, it would make global, class spanning definitions a
21
%D pain. Some day we will introduce a default class.
22
%D
23
%D The \type {type-ini} and \type {font-ini} modules come as a pair and have mutual
24
%D dependencies.
25
%D
26
%D At some point we will only store in memory so some code can go away.
27 28
\unprotect
29 30
\definesystemvariable
{
ts
}
% TypeScript / for the moment we keep this one
31 32
\newcount
\c_font_typescripts_n_of_preloaded
33
\newconditional
\c_font_typescripts_quit
34
\newtoks
\c_font_typescripts_document
35
\newconditional
\c_font_typescripts_preload
36
\newconditional
\c_font_typescripts_first_pass
\settrue
\c_font_typescripts_first_pass
37 38
\newif
\iftypescriptfound
% will become a mode
39
\newif
\iftracetypescripts
40 41
\newtoks
\everybeforedefinetypeface
42
\newtoks
\everyafterdefinetypeface
43 44
\let
\typescriptfiles
\empty
45
\let
\currenttypescripts
\empty
46
\let
\currenttypefile
\empty
47 48
\installmacrostack
\currenttypefile
49 50
\let
\typescriptone
\empty
% public, used in typescripts
51
\let
\typescripttwo
\empty
% public, used in typescripts
52
\let
\typescriptthree\empty
% public, used in typescripts
53 54
\installmacrostack\typescriptone
55
\installmacrostack\typescripttwo
56
\installmacrostack\typescriptthree
57 58
\let
\fontclassstyle
\empty
59 60
\installmacrostack
\fontclassstyle
61 62
\let
\m_font_typescripts_one
\empty
63
\let
\m_font_typescripts_two
\empty
64
\let
\m_font_typescripts_three
\empty
65
\let
\m_font_typescripts_check
\empty
66
\let
\m_font_typescripts_match
\empty
67 68
\installmacrostack
\m_font_typescripts_one
69
\installmacrostack
\m_font_typescripts_two
70
\installmacrostack
\m_font_typescripts_three
71 72
\let
\t_font_typescripts
\relax
% uses as synonym
73 74
\installcorenamespace
{
typescriptcache
}
75
\installcorenamespace
{
typescriptfiles
}
76
\installcorenamespace
{
typescriptonce
}
77
\installcorenamespace
{
typescriptsynonyms
}
78
\installcorenamespace
{
typescriptprefix
}
79
\installcorenamespace
{
typescriptinheritances
}
80
\installcorenamespace
{
typescriptdefaultstyles
}
81
\installcorenamespace
{
typescriptrelatives
}
82 83
\definesystemvariable
{
ts
}
% TypeScript
84 85
% tricky ... here we push/pop ... so \let
86 87
\let
\typescriptmethod
\plusone
% 1: empty==all==true 2: empty==false
88
\let
\typescriptstate
\plustwo
% 1: process 2: store
89 90
\installmacrostack
\typescriptmethod
91
\installmacrostack
\typescriptstate
92 93
%D When these are loaded it is possible to get spaces but the whole idea is to do
94
%D that loading in vertical mode. Adding \type {\pushendofline} and \type
95
%D {\popendofline} is an option but not watertight as it can still interfere, for
96
%D instance work comments and leading spaces. Also, in horizontal mode it is likely
97
%D that one is also grouped and loading bodyfonts grouped is a real bad idea.
98
%D Ignoring all spaces is also not a solution. So, our verdict is: no catch.
99 100
\unexpanded
\def
\starttypescriptcollection
101
{
\dosingleempty
\font_typescripts_collection_start
}
102 103
\def
\font_typescripts_collection_start
[#
tag
]
%
104
{}
105 106
\let
\stoptypescriptcollection
\relax
107 108
\unexpanded
\def
\usetypescriptfile
[#
filename
]
%
109
{
\doifelse
{
#
filename
}
\v!reset
110
{
\let
\typescriptfiles
\empty
}
111
{
\splitfilename
{
#
filename
}
%
112
\addtocommalist\splitoffbase
\typescriptfiles
}}
113 114
\unexpanded
\def
\usetypescript
{
\dotripleempty
\font_typescripts_use_one
}
115
\unexpanded
\def
\usetypescriptexact
{
\dotripleempty
\font_typescripts_use_two
}
116 117
\def
\font_typescripts_use_one
{
\let
\typescriptmethod
\plusone
\font_typescripts_use
}
118
\def
\font_typescripts_use_two
{
\let
\typescriptmethod
\plustwo
\font_typescripts_use
}
119 120
\installmacrostack\stoptypescript
121 122
\unexpanded
\def
\font_typescripts_use
[#
one
][#
two
][#
three
]
%
123
{
\push_macro_m_font_typescripts_one
124
\push_macro_m_font_typescripts_two
125
\push_macro_m_font_typescripts_three
126
\edef
\m_font_typescripts_one
{
\truetypescript
{
#
one
}}
%
127
\edef
\m_font_typescripts_two
{
\truetypescript
{
#
two
}}
%
128
\edef
\m_font_typescripts_three
{
\truetypescript
{
#
three
}}
%
129
\push_macro_typescriptone
130
\push_macro_typescripttwo
131
\push_macro_typescriptthree
132
\push_macro_typescriptmethod
133
\push_macro_typescriptstate
134
\push_macro_stoptypescript
135
\typescriptfoundfalse
136
\let
\typescriptstate
\plusone
% why
137
\iftracetypescripts
138
\writestatus
\m!fonts
{
request
:
[
\m_font_typescripts_one
]
[
\m_font_typescripts_two
]
[
\m_font_typescripts_three
]
}
%
139
\fi
140
\ifhmode
141
\font_typescripts_use_inline
142
\else
143
\font_typescripts_use_display
144
\fi
145
\setfalse
\c_font_typescripts_first_pass
146
\pop_macro_stoptypescript
147
\pop_macro_typescriptstate
148
\pop_macro_typescriptmethod
149
\pop_macro_typescriptthree
150
\pop_macro_typescripttwo
151
\pop_macro_typescriptone
152
\pop_macro_m_font_typescripts_three
153
\pop_macro_m_font_typescripts_two
154
\pop_macro_m_font_typescripts_one
}
155 156
\def
\font_typescripts_use_display
157
{
\processcommacommand
[
\typescriptfiles
]
\font_typescripts_load_file
158
\the
\c_font_typescripts_document
}
159 160
\let
\font_typescripts_use_inline
\font_typescripts_use_display
161 162
\unexpanded
\def
\preloadtypescripts
163
{
\ifproductionrun
\settrue
\c_font_typescripts_preload
\fi
}
164 165
\prependtoks
166
\preloadtypescripts
167
\to
\everyjob
168 169
\unexpanded
\def
\loadtypescriptfile
[#
1
]
%
170
{
\push_macro_typescriptstate
171
\let
\typescriptstate
\plustwo
% assumes 2 at the outer level
172
\clf_loadtypescriptfile
{
#
1
}
%
173
\pop_macro_typescriptstate
}
174 175
\unexpanded
\def
\loadfoundtypescriptfile
#
1
#
2
% name foundname / not a user command
176
{
\startreadingfile
177
\unprotect
178
\pushendofline
179
\input
{
#
2
}
%
180
\popendofline
181
\protect
182
\stopreadingfile
}
183 184
\unexpanded
\def
\quittypescriptscanning
185
{
\settrue
\c_font_typescripts_quit
}
% public
186 187
\def
\font_typescripts_start_store
#
definitions
\stoptypescript
188
{
\global\advance
\c_font_typescripts_n_of_preloaded
\plusone
189
\expandafter\normalgdef\csname
\??typescriptcache
\the
\c_font_typescripts_n_of_preloaded
\endcsname
190
{
\starttypescript
#
definitions
\stoptypescript
}
%
191
\gtoksapp
\t_font_typescripts
\expandafter
192
{
\csname
\??typescriptcache
\the
\c_font_typescripts_n_of_preloaded
\endcsname
}}
193 194
\def
\font_typescripts_collection_start_store
#
definitions
\stoptypescriptcollection
195
{
\global\advance
\c_font_typescripts_n_of_preloaded
\plusone
196
\expandafter\normalgdef\csname
\??typescriptcache
\the
\c_font_typescripts_n_of_preloaded
\endcsname
197
{
\starttypescriptcollection
#
definitions
\stoptypescriptcollection
}
%
198
\gtoksapp
\t_font_typescripts
\expandafter
199
{
\csname
\??typescriptcache
\the
\c_font_typescripts_n_of_preloaded
\endcsname
}}
200 201
\def
\font_typescripts_load_file
#
filename
%
202
{
\setfalse
\c_font_typescripts_quit
203
\push_macro_currenttypefile
204
\def
\currenttypefile
{
#
filename
}
%
205
\ifconditional
\c_font_typescripts_preload
206
\font_typescript_process_typescript_file_and_store
207
\else
208
\font_typescript_process_typescript_file
209
\fi
210
\pop_macro_currenttypefile
211
\ifconditional
\c_font_typescripts_quit
212
\quitcommalist
213
\setfalse
\c_font_typescripts_quit
214
\fi
}
215 216
\def
\font_typescript_process_typescript_file_and_store
217
{
\expandafter\let\expandafter
\t_font_typescripts
\csname
\??typescriptfiles
\currenttypefile
\endcsname
218
\ifx
\t_font_typescripts
\relax
219
\font_typescript_process_typescript_store_indeed
220
\fi
221
\the
\t_font_typescripts
}
222 223
\def
\font_typescript_process_typescript_store_indeed
224
{
\newtoks
\t_font_typescripts
% is \relaxed elsewhere
225
\begingroup
226
\let
\starttypescript
\font_typescripts_start_store
227
\let
\starttypescriptcollection
\font_typescripts_collection_start_store
228
\font_typescript_process_typescript_file
229
\endgroup
230
\expandafter\let\csname
\??typescriptfiles
\currenttypefile
\endcsname
\t_font_typescripts
}
231 232
\def
\font_typescript_process_typescript_file
233
{
\clf_doprocesstypescriptfile
{
\currenttypefile
}}
234 235
\unexpanded
\def
\usetypescriptonce
236
{
\dotripleempty
\font_typescripts_use_once
}
237 238
\def
\font_typescripts_use_once
[#
one
][#
two
][#
three
]
%
239
{
\ifcsname
\??typescriptonce
#
one
:
#
two
:
#
three
\endcsname
240
\writestatus
\m!fonts
{
once
(#
one
)
(#
two
)
(#
three
)
}
%
241
\else
242
\expandafter\let\csname
\??typescriptonce
#
one
:
#
two
:
#
three
\endcsname\relax
243
\font_typescripts_use
[#
one
][#
two
][#
three
]
%
244
\fi
}
245 246
% \definetypescriptsynonym[lbr][cmr]
247 248
\unexpanded
\def
\definetypescriptsynonym
249
{
\dodoubleempty
\font_typescripts_synonym_define
}
250 251
\def
\font_typescripts_synonym_define
[#
name
][#
synonym
]
%
252
{
\ifsecondargument
\setevalue
{
\??typescriptsynonyms
#
name
}{
#
synonym
}
\fi
}
253 254
\def
\truetypescript
#
name
% recursive so no \lastnamedcs
255
{
\ifcsname
\??typescriptsynonyms
#
name
\endcsname
256
%\expandafter\truetypescript\csname\??typescriptsynonyms#name\endcsname
257
\expandafter
\truetypescript
\lastnamedcs
258
\else
259
#
name
%
260
\fi
}
261 262
% script [serif] [default] [size]
263
% script [serif] [computer-modern] [size]
264
% script [serif] [computer-modern] [ec]
265
% script [serif] [computer-modern] [name]
266
% script [serif] [computer-modern] [special]
267 268
\prependtoks
269
\settrue
\c_font_typescripts_first_pass
270
\to
\everyjob
271 272
\unexpanded
\def
\starttypescript
273
{
\ifcase
\typescriptstate
274
% 0 = skip
275
\expandafter
\font_typescripts_start_gobble
276
\or
277
% 1 = process
278
\expandafter
\font_typescripts_start_process
279
\or
280
% 2 = store
281
\expandafter
\font_typescripts_start_document
282
\else
283
% ? = skip
284
\expandafter
\font_typescripts_start_gobble
285
\fi
}
286 287
\def
\font_typescripts_start_gobble
#
ignore
\stoptypescript
{}
288 289
\def
\font_typescripts_start_document
#
definitions
\stoptypescript
290
{
\toksapp
\c_font_typescripts_document
{
\starttypescript
#
definitions
\stoptypescript
}}
291 292
\def
\font_typescripts_start_process
% could be a faster \doifelsenextoptionalif needed
293
{
\let
\typescriptone
\m_font_typescripts_one
294
\let
\typescripttwo
\m_font_typescripts_two
295
\let
\typescriptthree
\m_font_typescripts_three
296
\let
\m_font_typescripts_match
\empty
297
\doifelsenextoptionalcs
\font_typescripts_start_process_one
\font_typescripts_start_process_all
}
298 299
\def
\font_typescripts_start_process_all
% could be a \let
300
{
\ifconditional
\c_font_typescripts_first_pass
301
\expandafter
\font_typescripts_start_process_indeed
302
\else
303
% skip this since it may do unwanted resets, like
304
% setting symbolic font names to unknown, especially
305
% in run time user type scripts
306
\expandafter
\font_typescripts_start_gobble
307
\fi
}
308 309
\def
\font_typescripts_show_match
310
{
\writestatus
\m!fonts
{
match
:
\ifx
\currenttypefile
\relax
\space
*
\fi
\m_font_typescripts_match
}}
311 312
\def
\font_typescripts_start_process_yes
313
{
\ifdone
314
\typescriptfoundtrue
315
\iftracetypescripts
\font_typescripts_show_match
\fi
316
\expandafter
\font_typescripts_start_process_indeed
317
\else
318
\expandafter
\font_typescripts_start_gobble
319
\fi
}
320 321
\def
\font_typescripts_start_process_one
322
{
\font_typescripts_check
\m_font_typescripts_one
\typescriptone
\font_typescripts_start_process_again_one
}
323 324
\def
\font_typescripts_start_process_two
325
{
\font_typescripts_check
\m_font_typescripts_two
\typescripttwo
\font_typescripts_start_process_again_two
}
326 327
\def
\font_typescripts_start_process_three
328
{
\font_typescripts_check
\m_font_typescripts_three
\typescriptthree
\font_typescripts_start_process_again_three
}
329 330
\def
\font_typescripts_start_process_again_one
331
{
\doifelsenextoptionalcs
\font_typescripts_start_process_two
\font_typescripts_start_process_yes
}
332 333
\def
\font_typescripts_start_process_again_two
334
{
\doifelsenextoptionalcs
\font_typescripts_start_process_three
\font_typescripts_start_process_yes
}
335 336
\let
\font_typescripts_start_process_again_three
\font_typescripts_start_process_yes
337 338
\def
\font_typescripts_start_process_indeed
339
{
\push_macro_fontclass
}
340 341
\unexpanded
\def
\stoptypescript
342
{
\pop_macro_fontclass
}
343 344
\def
\font_typescripts_check
#
asked
#
target
#
followup
[#
value
]
% script use value next
345
{
\donefalse
346
\edef
\m_font_typescripts_check
{
#
value
}
%
347
\ifempty
\m_font_typescripts_check
% no longer needed / met
348
\ifcase
\typescriptmethod
\or
\donetrue
\fi
349
\orelse\ifx
#
asked
\s!all
350
\donetrue
351
\orelse\ifx
\m_font_typescripts_check
\s!all
352
\donetrue
353
\orelse\ifx
#
asked
\m_font_typescripts_check
% saves 10% trace so probably faster too
354
\donetrue
355
\let
#
target
\m_font_typescripts_check
356
\else
357
\doifelsecommon
\m_font_typescripts_check
#
asked
\donetrue\donefalse
358
\ifdone
359
\let
#
target
\commalistelement
360
\fi
361
\fi
362
\ifdone
363
\iftracetypescripts
\extendtypescriptmatch
\fi
364
\expandafter
#
followup
%
365
\else
366
\expandafter
\font_typescripts_start_gobble
367
\fi
}
368 369
\def
\extendtypescriptmatch
370
{
\edef
\m_font_typescripts_match
{
\m_font_typescripts_match
\space
[
\m_font_typescripts_check
]
}}
371 372
%D Map files will go away in \LUATEX, but till that happens we use stripped down
373
%D support for loading them.
374 375
\unexpanded
\def
\loadmapfile
{
\dosingleempty
\font_map_load_file
}
376
\unexpanded
\def
\loadmapline
{
\dodoubleempty
\font_map_load_line
}
377 378
\def
\font_map_load_file
[#
filename
]
%
379
{
\clf_loadmapfile
{
#
filename
}}
380 381
\def
\font_map_load_line
[#
kind
][#
data
]
%
382
{
\clf_loadmapline
{
#
kind
}{
#
data
}}
383 384
\unexpanded
\def
\forgetmapfiles
385
{
\clf_resetmapfiles
}
386 387
% \prependtoks
388
% \loadmapfile[mkiv-base.map]% can't we preload this one?
389
% \to \everystarttext
390 391
%D A handy shortcut:
392 393
% \definetypescriptprefix[serif][Serif]
394
% \definetypescriptprefix[sans] [Sans]
395
% \definetypescriptprefix[mono] [Mono]
396
%
397
% \starttypescript [serif,sans,mono] [handling,hanging,hz] [pure,normal,hz,quality]
398
% \setupfontsynonym [\typescriptprefix\typescriptone] [handling=\typescriptthree]
399
% \stoptypescript
400 401
\unexpanded
\def
\definetypescriptprefix
402
{
\dodoubleargument
\font_typescripts_define_prefix
}
403 404
\def
\font_typescripts_define_prefix
[#
name
][#
prefix
]
%
405
{
\setgvalue
{
\??typescriptprefix
#
name
}{
#
prefix
}}
% made global
406 407
\def
\typescriptprefix
#
name
%
408
%{\ifcsname\??typescriptprefix#name\endcsname\csname\??typescriptprefix#name\endcsname\else#name\fi}
409
{
\ifcsname
\??typescriptprefix
#
name
\endcsname\lastnamedcs\else
#
name
\fi
}
410 411
% defining typefaces:
412
%
413
% \definetypeface [joke] [rm]
414
% \definetypeface [joke] [rm] [settings]
415
% \definetypeface [joke] [rm] [serif] [lucida]
416
% \definetypeface [joke] [rm] [serif] [lucida] [size]
417
% \definetypeface [joke] [rm] [serif] [lucida] [size] [settings]
418
% \definetypeface [joke] [specification]
419 420
\unexpanded
\def
\definetypeface
421
{
\dosixtupleargument
\font_typefaces_define
}
422 423
\appendtoks
424
\font_helpers_reset_fontclass_math_families
\fontclass
425
\to
\everybeforedefinetypeface
426 427
%D This hooks into the font switcher:
428 429
\settrue
\autotypescripts
430 431
\unexpanded
\def
\trycurrentfontclass
#
typeface
%
432
{
\ifconditional
\autotypescripts
433
\usetypescript
[#
typeface
]
%
434
\ifcsname
\??fontclassyes
#
typeface
\endcsname
435
\edef
\fontclass
{
#
typeface
}
%
436
\else
437
\iftracetypescripts
\writestatus
\m!fonts
{
auto
load
typescript
file
1
:
[#
typeface
]
}
\fi
438
\usetypescriptfile
[#
typeface
]
%
439
\usetypescript
[#
typeface
]
%
440
\ifcsname
\??fontclassyes
#
typeface
\endcsname
441
\edef
\fontclass
{
#
typeface
}
%
442
\else
443
% todo: message
444
\letvalueempty
{
\??fontclassnop
#
typeface
}
%
445
\fi
446
\fi
447
\else
448
% todo: message
449
\letvalueempty
{
\??fontclassnop
#
typeface
}
%
450
\fi
}
451 452
%D Now we define:
453 454
\def
\font_typefaces_define
455
{
\iffifthargument
456
\expandafter
\font_typefaces_define_a
457
\orelse
\iffourthargument
458
\expandafter
\font_typefaces_define_b
459
\orelse
\ifthirdargument
460
\expandafter
\font_typefaces_define_c
461
\else
462
\expandafter
\font_typefaces_define_d
463
\fi
}
464 465
\def
\font_typefaces_define_a
[#
name
][#
style
][#
fontshape
][#
fontname
][#
fontsize
][#
settings
]
%
466
{
\iftracetypescripts
\writestatus
\m!fonts
{
define
:
[#
name
]
[#
style
]
[#
fontshape
]
[#
fontname
]
}
\fi
467
\font_typefaces_define_indeed
[#
name
][#
style
]
%
468
\font_typefaces_defining_start
{
#
name
}{
#
style
}{
#
settings
}
%
469
\font_typescripts_use_one
[#
fontshape
][#
fontname
][
\s!name
]
% [\s!name,\s!default]%
470
\iftypescriptfound
471
% we're okay
472
\orelse
\ifconditional
\autotypescripts
473
\iftracetypescripts
\writestatus
\m!fonts
{
auto
load
typescript
file
2
:
[#
fontname
]
}
\fi
474
\usetypescriptfile
[#
fontname
]
%
475
\font_typescripts_use_one
[#
fontshape
][#
fontname
][
\s!name
]
% [\s!name,\s!default]%
476
\fi
477
\font_typescripts_use_one
[#
fontshape
][#
fontsize
][
\s!size
]
%
478
\font_typefaces_defining_stop
}
479 480
\def
\font_typefaces_define_b
[#
name
][#
style
][#
fontshape
][#
fontname
][#
dummya
][#
dummyb
]
%
481
{
\font_typefaces_define_a
[#
name
][#
style
][#
fontshape
][#
fontname
][
\s!default
][#
dummyb
]
}
482 483
\def
\font_typefaces_define_c
[#
name
][#
style
][#
dummya
][#
dummyb
][#
dummyc
][#
dummyd
]
%
484
{
\font_typefaces_define_indeed
[#
name
][#
style
]
}
485 486
\def
\font_typefaces_define_d
[#
name
][#
specification
][#
dummya
][#
dummyb
][#
dummyc
][#
dummyd
]
% use definitions in lfg file
487
{
\clf_definetypeface
{
#
name
}{
#
specification
}}
488 489
\def
\font_typefaces_define_indeed
[#
name
][#
style
]
% saveguard against redefinition
490
{
\doifsomething
{
#
name
}
491
{
\ifcsname
\??typescriptdefaultstyles
#
name
\endcsname
\else
492
\registerfontclass
{
#
name
}
%
493
\setxvalue
{
\??typescriptdefaultstyles
#
name
}{
#
style
}
%
494
\fi
495
\ifcsname
#
name
\endcsname
\else
496
\setugvalue
{
#
name
}{
\switchtotypeface
[#
name
][#
style
]
}
%
497
\fi
}}
498 499
\def
\font_typefaces_defining_start
#
name
#
style
#
settings
%
500
{
\let
\@@tsrscale
\!!plusone
% as we push/pop
501
\let
\@@tsfeatures
\empty
502
\let
\@@tsfallbacks
\empty
503
\let
\@@tsgoodies
\empty
504
\let
\@@tsdirection
\empty
505
\let
\@@tsdesignsize
\empty
506
\geteparameters
[
\??ts
][#
settings
]
% todo raw
507
\push_macro_fontclass
508
\push_macro_fontclassstyle
509
\setcurrentfontclass
{
#
name
}
%
510
\savefontclassparameters
{
#
style
}
\@@tsrscale
\@@tsfeatures
\@@tsfallbacks
\@@tsgoodies
\@@tsdesignsize
\@@tsdirection
511
\the
\everybeforedefinetypeface
}
512 513
\def
\tsvar
#
key
#
default
% undocumented and unofficial
514
{
\expandafter\ifempty\csname
\??ts
#
key
\endcsname
515
#
default
%
516
\else
517
\csname
\??ts
#
key
\endcsname
518
\fi
}
519 520
\def
\font_typefaces_defining_stop
521
{
\the
\everyafterdefinetypeface
522
\pop_macro_fontclassstyle
523
\pop_macro_fontclass
}
524 525
\def
\dofastdefinetypeface
#
name
#
style
#
fontshape
#
fontsize
#
settings
% called from the lua end (via case d)
526
{
\font_typefaces_define_indeed
[#
name
][#
style
]
%
527
\font_typefaces_defining_start
{
#
name
}{
#
style
}{
#
settings
}
%
528
\font_typescripts_use_one
[#
fontshape
][#
fontsize
][
\s!size
]
%
529
\font_typefaces_defining_stop
}
530 531
\unexpanded
\def
\setuptypeface
% [class] [settings]
532
{
\dodoubleempty
\font_typefaces_setup
}
533 534
\unexpanded
\def
\switchtotypeface
% [class] [settings]
535
{
\dodoubleempty
\font_typefaces_switch
}
536 537
\def
\font_typefaces_setup
[#
class
][#
settings
]
%
538
{
\setcurrentfontclass
{
#
class
}
%
539
\let
\globalfontclass
\fontclass
540
\ifsecondargument
541
\setupbodyfont
[#
settings
]
%
542
\orelse\ifempty
\fontclass
543
\setupbodyfont
[
\s!rm
]
%
544
\orelse\ifcsname
\??typescriptdefaultstyles
\fontclass
\endcsname
545
%\setupbodyfont[\csname\??typescriptdefaultstyles\fontclass\endcsname]%
546
\expandafter
\setupbodyfont
\expandafter
[
\lastnamedcs
]
%
547
\else
548
\setupbodyfont
[
\s!rm
]
%
549
\fi
550
\ifmmode
\mr
\else
\tf
\fi
}
% needed ?
551 552
\def
\font_typefaces_switch
[#
class
][#
settings
]
%
553
{
\setcurrentfontclass
{
#
class
}
%
554
\let
\globalfontclass
\globalfontclass
555
\ifsecondargument
556
\switchtobodyfont
[#
settings
]
%
557
\orelse\ifempty
\fontclass
558
\switchtobodyfont
[
\s!rm
]
%
559
\orelse\ifcsname
\??typescriptdefaultstyles
\fontclass
\endcsname
560
%\switchtobodyfont[\csname\??typescriptdefaultstyles\fontclass\endcsname]%
561
\expandafter
\switchtobodyfont
\expandafter
[
\lastnamedcs
]
%
562
\else
563
\switchtobodyfont
[
\s!rm
]
%
564
\fi
565
\ifmmode
\mr
\else
\tf
\fi
}
% needed ?
566 567
%D For Taco:
568
%D
569
%D \starttyping
570
%D \inherittypeface[palatino][rm][postscript]
571
%D \inherittypeface[palatino][rm][\fontclass]
572
%D \inherittypeface[palatino][rm] % == \fontclass
573
%D \inherittypeface[palatino] % == [rm,ss,tt,mm]
574
%D \stoptyping
575 576
\unexpanded
\def
\inherittypeface
577
{
\dotripleempty
\font_typescripts_inherit_indeed
}
578 579
\def
\font_typescripts_inherit_indeed
[#
name
][#
styles
][#
parentclass
]
%
580
{
\doifelsenothing
{
#
styles
}
581
{
\font_typescripts_inherit_indeed
[#
name
][
\s!rm
,
\s!ss
,
\s!tt
,
\s!mm
][
\fontclass
]
}
582
{
\doifnot
{
#
name
}{
#
parentclass
}
583
{
\glet
\font_typescripts_inherit_check
\font_typescripts_inherit_check_indeed
584
\def
\font_typescripts_inherit_check_step
#
style
{
\setevalue
{
\??typescriptinheritances
#
name
:
#
style
}{
#
parentclass
}}
%
585
\processcommalist
[#
styles
]
\font_typescripts_inherit_check_step
}}}
586 587
\let
\font_typescripts_inherit_check_step
\relax
588 589
%D This hooks into the font mechanism with:
590 591
\def
\font_typescripts_inherit_check_indeed
#
name
% called often
592
{
\ifcsname
\??typescriptinheritances
\fontclass
:
#
name
\endcsname
593
%\expandafter\let\expandafter\fontclass\csname\??typescriptinheritances\fontclass:#name\endcsname
594
\expandafter\let\expandafter
\fontclass
\lastnamedcs
595
\fi
}
596 597
\let
\font_typescripts_inherit_check
\gobbleoneargument
598 599
% not yet:
600
%
601
% \def\font_helpers_check_relative_font_id
602
% {\ifcsname\??typescriptrelatives\fontclass\endcsname
603
% \expandafter\let\expandafter\relativefontid\csname\??typescriptrelatives\fontclass\endcsname
604
% \else
605
% \expandafter\normalxdef\csname\??typescriptrelatives\fontclass\endcsname{\the\lastfontid}%
606
% \let\relativefontid\minusone
607
% \fi}
608 609
\def
\v_font_string_d
% default fontstyle (expands to \s!Serif in font-ini)
610
{
\expandafter\ifx\csname
\??typescriptdefaultstyles
\fontclass
\endcsname
\s!rm
\s!Serif
\else
611
\expandafter\ifx\csname
\??typescriptdefaultstyles
\fontclass
\endcsname
\s!ss
\s!Sans
\else
612
\expandafter\ifx\csname
\??typescriptdefaultstyles
\fontclass
\endcsname
\s!tt
\s!Mono
\else
613
\s!Serif
\fi\fi\fi
}
614 615
\unexpanded
\def
\font_helpers_set_fontstyle_of_fontclass
616
{
\ifempty
\fontclass
617
\let
\fontstyle
\s!rm
618
\orelse\ifcsname
\??typescriptdefaultstyles
\fontclass
\endcsname
619
%\edef\fontstyle{\csname\??typescriptdefaultstyles\fontclass\endcsname}%
620
\edef
\fontstyle
{
\lastnamedcs
}
%
621
\else
622
\let
\fontstyle
\s!rm
623
\fi
}
624 625
\protect
\endinput
626