font-ini.mklx /size: 97 Kb    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=font-ini,
3
%D version=1998.09.11, % (second)
4
%D version=2001.02.20, % (third)
5
%D title=\CONTEXT\ Font Macros,
6
%D subtitle=Initialization,
7
%D author=Hans Hagen,
8
%D date=\currentdate,
9
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
10
%C
11
%C This module is part of the \CONTEXT\ macro||package and is
12
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
13
%C details.
14 15
% todo: < 3 pt => 3pt
16
% todo: check where more class usage
17
% todo: split font-nam (style/alternative/size)
18
% todo: split font-dim (scales etc)
19
% todo: reconsider defaultfontclass
20
%
21 22
%D Watch out: as we define inside macros in sometimes special ways,
23
%D an occasional \type {\normaldef} is used in order to please the
24
%D \MKVI\ parser.
25 26
%D Beware, we use a special set of parameters here:
27
%D
28
%D \starttabulate[|l|l|]
29
%D \NC system variable (fixed) \NC \type {\s!text} \NC \NR
30
%D \NC system variable (fixed) \NC \type {\s!script} \NC \NR
31
%D \NC system variable (fixed) \NC \type {\s!scriptscript} \NC \NR
32
%D \NC system variable (fixed) \NC \type {\s!x} \NC \NR
33
%D \NC system variable (fixed) \NC \type {\s!xx} \NC \NR
34
%D \NC variable (value) \NC \type {\v!big} \NC \NR
35
%D \NC variable (value) \NC \type {\v!small} \NC \NR
36
%D \NC constant (regular key) \NC \type {\c!interlinespace} \NC \NR
37
%D \NC constant (regular key) \NC \type {\c!em} \NC \NR
38
%D \stoptabulate
39
%D
40
%D The math related ones are similar to the ones used in \TEX\ itself,
41
%D the size related ones show up as keywords in the user interface
42
%D when switching sizes, and the two constants are used in key|/|value
43
%D situations.
44 45
%D We should consider design sizes ... maybe kick 'm out which removes
46
%D the size code and simplifies things considerably. After all, there
47
%D will be no latin modern math in sizes.
48 49
\writestatus
{
loading
}{
ConTeXt
Font
Macros
/
Initialization
}
50 51
%D Documentation is somewhat messy as it contains bits and pieces of
52
%D previous versions.
53 54
\unprotect
55 56
%D There are several ways to specify a font. Three of them are pure \TEX\ ones, the
57
%D fourth one is new:
58
%D
59
%D \starttyping
60
%D \font\name=cmr12
61
%D \font\name=cmr12 at 10pt
62
%D \font\name=cmr12 scaled 2
63
%D \font\name=cmr12 sa 1.440
64
%D \stoptyping
65
%D
66
%D The non||\TEX\ alternative \type{sa} stands for {\em scaled at}. This means as
67
%D much as: scale the bodyfontsize with this factor. The scaled option is not that
68
%D useful as one needs to know the design size.
69
%D
70
%D Because \type {sa} (scaled at) and \type {mo} (mapped on) are not low level \TEX\
71
%D supported alternatives, we have to test for it ourselves. In doing so, we need an
72
%D auxiliary \DIMENSION. We cannot use \type{\scratchdimen} because font loading can
73
%D happen at any moment due to postponed loading. We could instead have used dirty
74
%D grouping tricks, but this one works too.
75 76
% \enableexperiments[fonts.autorscale]
77
%
78
% \starttypescript[mscore]
79
% \definetypeface [mscore] [rm] [serif] [mscoretimes] [default]
80
% \definetypeface [mscore] [ss] [sans] [mscorearial] [default] [rscale=auto] % 0.860]
81
% \definetypeface [mscore] [tt] [mono] [mscorecourier] [default] [rscale=auto] % 1.065]
82
% \definetypeface [mscore] [mm] [math] [times] [default] [rscale=auto] % 1.020]
83
% \stoptypescript
84
%
85
% \starttext
86
% \setupbodyfont[mscore,12pt]
87
% \startTEXpage
88
% test \ss test \tt test
89
% \stopTEXpage
90
% \stoptext
91 92
% \definetypeface[one][rm][serif][computer-roman][default]
93
% \definetypeface[two][rm][serif][computer-roman][default][rscale=.9]
94
%
95
% {\one \bf test \two test}
96
% {\one \bf test \pushcurrentfont \two \popcurrentfont test}
97 98
%D \macros
99
%D {rm,ss,tt,hw,cg}
100
%D
101
%D Fonts are defined in separate files. When we define a font, we distinguish
102
%D between several styles. In most cases we will use:
103
%D
104
%D \startlinecorrection
105
%D \starttable[|l||]
106
%D \HL
107
%D \NC roman regular serif \NC \type{\rm} \NC\FR
108
%D \NC sansserif sans support \NC \type{\ss} \NC\MR
109
%D \NC type teletype mono \NC \type{\tt} \NC\LR
110
%D \HL
111
%D \stoptable
112
%D \stoplinecorrection
113
%D
114
%D The number of styles is not limited to these three. When using Lucida Bright we
115
%D can for instance also define:
116
%D
117
%D \startlinecorrection
118
%D \starttable[|l||]
119
%D \HL
120
%D \NC handwritten \NC \type{\hw} \NC\FR
121
%D \NC calligraphic \NC \type{\cg} \NC\LR
122
%D \HL
123
%D \stoptable
124
%D \stoplinecorrection
125
%D
126
%D Within such a font set (\type{cmr}) and style (\type{\rm}) we can define a number
127
%D of text font alternatives:
128
%D
129
%D \startlinecorrection
130
%D \starttable[|l||]
131
%D \HL
132
%D \NC typeface \NC \type{\tf} \NC\FR
133
%D \NC boldface \NC \type{\bf} \NC\MR
134
%D \NC slanted \NC \type{\sl} \NC\MR
135
%D \NC italic \NC \type{\it} \NC\MR
136
%D \NC boldslanted \NC \type{\bs} \NC\MR
137
%D \NC bolditalic \NC \type{\bi} \NC\MR
138
%D \NC smallcaps \NC \type{\sc} \NC\LR
139
%D \HL
140
%D \stoptable
141
%D \stoplinecorrection
142
%D
143
%D Internally fonts are stored as combination of size, style
144
%D and alternative, e.g. \type{12pt}+\type{\ss}+\type{\bf}. Users are not confronted
145
%D with sizes, but use the style or style+alternative to activate them.
146
%D
147
%D During the definition of a bodyfont one can also declare the available larger
148
%D alternatives:
149
%D
150
%D \starttyping
151
%D \tf \tfa \tfb \tfc ...
152
%D \bf \bfa \bfb \bfc ...
153
%D \sl \sla \slb \slc ...
154
%D \stoptyping
155
%D
156
%D The smaller ones are automatically supplied and derived from
157
%D the the bodyfont environment.
158
%D
159
%D \starttyping
160
%D \tfx \tfxx
161
%D \bfx \bfxx
162
%D \slx \slxx
163
%D \stoptyping
164
%D
165
%D There are only two smaller alternatives per style. The larger alternatives on the
166
%D other hand have no limitations.
167
%D
168
%D These larger alternatives are mostly used in chapter and section titles or on
169
%D title pages. When one switches to a larger alternative, the bold an other ones
170
%D automatically adapt themselves:
171
%D
172
%D \startbuffer
173
%D \tfd Hi \bf there\sl, here \tfb I \bf am
174
%D \stopbuffer
175
%D
176
%S \startnarrower
177
%D \typebuffer
178
%S \stopnarrower
179
%D
180
%D therefore becomes:
181
%D
182
%D \startexample
183
%D \getbuffer
184
%D \stopexample
185
%D
186
%D Maybe this mechanism isn't always as logic, but as said before, we tried to make
187
%D it as intuitive as possible.
188
%D
189
%D So a specific kind of glyph can be characterized by:
190
%D
191
%D \startnarrower
192
%D family (cmr) + bodyfont (12pt) + style (rm) + alternative (bf) + size (a)
193
%D \stopnarrower
194
%D
195
%D The last component (the size) is optional.
196
%D
197
%D We introduced \type {\tf} as command to call for the current normally sized
198
%D typeface. This commands results in roman, sans serif, teletype or whatever style
199
%D is in charge. Such rather massive switches of style sometimes take more
200
%D processing time than comfortable. Of course there is a workaround for this: we
201
%D can call fonts directly by means of commands like:
202
%D
203
%D \starttyping
204
%D \rmtf \sssl \tttf \rmbsa
205
%D \stoptyping
206
%D
207
%D One should realize that this fast calls have limitations, they lack for instance
208
%D automatic super- and subscript support.
209
%D
210
%D This leaves us two more commands: \type {\tx} and \type {\txx}. These activate a
211
%D smaller and even more smaller font than the current one and adapt themselves to
212
%D the current alternative, so when \type {\bf} is active, \type {\tx} gives a
213
%D smaller boldface, which in turn can be called directly by \type {\bfx}.
214
%D
215
%D These two smaller alternatives are specified by the bodyfont environment and
216
%D therefore not necessarily have similar sizes as \type {\scriptsize} and \type
217
%D {\scriptscriptsize}. The main reason for this incompatibility (which can easily
218
%D be undone) lays in the fact that we often want a bit bigger characters than in
219
%D math mode. In \CONTEXT\ for instance the \type {\tx} and \type {\txx} commands
220
%D are used for surrogate \cap {smallcaps} which support both nesting and
221
%D alternatives, like in {\bf \cap {a \cap {small} world}}, which was typeset by
222
%D
223
%D \starttyping
224
%D \bf\cap{a \cap{small} world}
225
%D \stoptyping
226
%D
227
%D And compare $\rm \scriptstyle THIS$ with the slightly larger \cap {THIS}:
228
%D \ruledhbox {$\rm \scriptstyle scriptstyle: THIS$} or \ruledhbox {\cap {x style:
229
%D THIS}} makes a big difference.
230
%D
231
%D The \type {x..d} sizes should be used grouped. If you don't group them, i.e. call
232
%D them in a row, \CONTEXT\ will not be able to sort out your intention (\type {x}
233
%D inside \type {d} inside \type {x}. etc.). The following table demonstrates this:
234
%D
235
%D \def\FontState{\setstrut\ruledhbox{\strut Hello}}
236
%D
237
%D \starttabulate[|||||]
238
%D \HL
239
%D \NC \rlap{\quad\bf grouped} \NC \NC \type {\tx} \NC \type {\txx} \NC \NR
240
%D \HL
241
%D \NC \type{\tfx} \NC \tfx \FontState \NC \tfx \tx \FontState \NC \tfx \txx \FontState \NC \NR
242
%D \NC \type{\tfxx} \NC \tfxx \FontState \NC \tfxx\tx \FontState \NC \tfxx\txx \FontState \NC \NR
243
%D \NC \type{\tf} \NC \tf \FontState \NC \tf \tx \FontState \NC \tf \txx \FontState \NC \NR
244
%D \NC \type{\tfa} \NC \tfa \FontState \NC \tfa \tx \FontState \NC \tfa \txx \FontState \NC \NR
245
%D \NC \type{\tfb} \NC \tfb \FontState \NC \tfb \tx \FontState \NC \tfb \txx \FontState \NC \NR
246
%D \NC \type{\tfc} \NC \tfc \FontState \NC \tfc \tx \FontState \NC \tfc \txx \FontState \NC \NR
247
%D \NC \type{\tfd} \NC \tfd \FontState \NC \tfd \tx \FontState \NC \tfd \txx \FontState \NC \NR
248
%D \NC \type{\tfx} \NC \tfx \FontState \NC \tfx \tx \FontState \NC \tfx \txx \FontState \NC \NR
249
%D \NC \type{\tfxx} \NC \tfxx \FontState \NC \tfxx\tx \FontState \NC \tfxx\txx \FontState \NC \NR
250
%D \HL
251
%D \stoptabulate
252
%D
253
%D \blank
254
%D
255
%D \starttabulate[|||||]
256
%D \HL
257
%D \NC \rlap{\quad\bf stacked} \NC \NC \type {\tx} \NC \type {\txx} \NC \NR
258
%D \HL
259
%D \NC \type{\tfx}
260
%D \NC \tfx \FontState
261
%D \NC \tfx \tx \FontState
262
%D \NC \tfx \txx \FontState
263
%D \NC \NR
264
%D \NC \type{\tfxx}
265
%D \NC \tfx\tfxx \FontState
266
%D \NC \tfx\tfxx \tx \FontState
267
%D \NC \tfx\tfxx \txx \FontState
268
%D \NC \NR
269
%D \NC \type{\tf}
270
%D \NC \tfx\tfxx\tf \FontState
271
%D \NC \tfx\tfxx\tf \tx \FontState
272
%D \NC \tfx\tfxx\tf \txx \FontState
273
%D \NC \NR
274
%D \NC \type{\tfa}
275
%D \NC \tfx\tfxx\tf\tfa \FontState
276
%D \NC \tfx\tfxx\tf\tfa \tx \FontState
277
%D \NC \tfx\tfxx\tf\tfa \txx \FontState
278
%D \NC \NR
279
%D \NC \type{\tfb}
280
%D \NC \tfx\tfxx\tf\tfa\tfb \FontState
281
%D \NC \tfx\tfxx\tf\tfa\tfb \tx \FontState
282
%D \NC \tfx\tfxx\tf\tfa\tfb \txx \FontState
283
%D \NC \NR
284
%D \NC \type{\tfc}
285
%D \NC \tfx\tfxx\tf\tfa\tfb\tfc \FontState
286
%D \NC \tfx\tfxx\tf\tfa\tfb\tfc \tx \FontState
287
%D \NC \tfx\tfxx\tf\tfa\tfb\tfc \txx \FontState
288
%D \NC \NR
289
%D \NC \type{\tfd}
290
%D \NC \tfx\tfxx\tf\tfa\tfb\tfd \FontState
291
%D \NC \tfx\tfxx\tf\tfa\tfb\tfd \tx \FontState
292
%D \NC \tfx\tfxx\tf\tfa\tfb\tfd \txx \FontState
293
%D \NC \NR
294
%D \NC \type{\tfx}
295
%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx \FontState
296
%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx \tx \FontState
297
%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx \txx \FontState
298
%D \NC \NR
299
%D \NC \type{\tfxx}
300
%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx\tfxx \FontState
301
%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx\tfxx \tx \FontState
302
%D \NC \tfx\tfxx\tf\tfa\tfb\tfc\tfx\tfxx \txx \FontState
303
%D \NC \NR
304
%D \HL
305
%D \stoptabulate
306 307
\fontslantperpoint
\nullfont
0
\scaledpoint
308
\fontinterwordspace
\nullfont
2
5
6
3
7
7
\scaledpoint
309
\fontinterwordstretch
\nullfont
1
2
8
1
8
8
\scaledpoint
310
\fontinterwordshrink
\nullfont
8
5
4
5
9
\scaledpoint
311
\fontexheight
\nullfont
3
3
8
9
5
2
\scaledpoint
312
\fontemwidth
\nullfont
7
8
6
4
3
2
\scaledpoint
313
\fontextraspace
\nullfont
8
5
4
5
9
\scaledpoint
314 315
\appendtoks
316
\fontslantperpoint
\nullfont
0
\scaledpoint
317
\fontinterwordspace
\nullfont
2
5
6
3
7
7
\scaledpoint
318
\fontinterwordstretch
\nullfont
1
2
8
1
8
8
\scaledpoint
319
\fontinterwordshrink
\nullfont
8
5
4
5
9
\scaledpoint
320
\fontexheight
\nullfont
3
3
8
9
5
2
\scaledpoint
321
\fontemwidth
\nullfont
7
8
6
4
3
2
\scaledpoint
322
\fontextraspace
\nullfont
8
5
4
5
9
\scaledpoint
323
\to
\everyjob
324 325
%D Tracing
326 327
\newtoks
\t_font_tracers_definitions
328 329
\unexpanded
\def
\tracefontdefinitions
330
{
\the
\t_font_tracers_definitions
}
331 332
%D Some housekeeping macros:
333 334
\unexpanded
\def
\setfontparameters
335
{
\setfalse
\c_font_synchronize
336
\the
\everybodyfont
337
\settrue
\c_font_synchronize
}
338 339
\let
\savedfont
\empty
340 341
\installmacrostack
\savedfont
342 343
\unexpanded
\def
\savefont
344
{
\edef
\savedfont
{
\the\font
}
% gives \csname
345
\push_macro_savedfont
}
346 347
\unexpanded
\def
\restorefont
348
{
\pop_macro_savedfont
349
\savedfont
}
350 351
\unexpanded
\def
\pushcurrentfont
352
{
\edef
\popcurrentfont
353
{
\def\noexpand
\fontbody
{
\fontbody
}
%
354
\def\noexpand
\fontstyle
{
\fontstyle
}
%
355
\def\noexpand
\fontalternative
{
\fontalternative
}
%
356
\def\noexpand
\fontsize
{
\fontsize
}
%
357
\font_helpers_check_big_math_synchronization
358
\font_helpers_synchronize_font
}}
359 360
%D \macros{definedfont}
361 362
\let
\thedefinedfont
\relax
% not to be confused with \everydefinefont
363 364
\unexpanded
\def
\definedfont
365
{
\doifelsenextoptionalcs
\font_basics_defined_font_yes
\font_basics_defined_font_nop
}
366 367
\def
\font_basics_defined_font_yes
[#
specification
]
%
368
{
\c_font_feature_inheritance_mode
\c_font_feature_inheritance_fontonly
369
\font_basics_define_font_without_parameters
{
thedefinedfont
}{
#
specification
}
%
370
\thedefinedfont
371
\the
\everydefinedfont
}
372 373
\def
\font_basics_defined_font_nop
374
{
\c_font_feature_inheritance_mode
\c_font_feature_inheritance_fontonly
375
\thedefinedfont
376
\the
\everydefinedfont
}
377 378
%D \macros{startfont}
379 380
\unexpanded
\def
\startfont
{
\begingroup
\definedfont
}
381
\unexpanded
\def
\stopfont
{
\endgroup
}
382 383
%D \macros
384
%D {everybodyfont,everyglobalbodyfont}
385
%D
386
%D Every change in bodyfont size has conseqences for the baseline distance and skips
387
%D between paragraphs. These are initialized in other modules. Here we only provide
388
%D the hooks that garantees their handling.
389
%D
390
%D At the system level one can initialize thing like:
391
%D
392
%D \starttyping
393
%D \appendtoks \setupspacing \to \everybodyfont
394
%D \stoptyping
395 396
%D \macros
397
%D {globalbodyfontsize,localbodyfontsize,bodyfontsize}
398
%D
399
%D Here we have to distinguish between the global (overal) bodyfont size and the
400
%D local (sometimes in the textflow) size. We store these dimensions in two
401
%D \DIMENSION\ registers. These registers are not to be misused in calculations.
402 403
\ifdefined
\globalbodyfontsize
\else
\newdimen
\globalbodyfontsize
\fi
\globalbodyfontsize
=
1
2
pt
404
\ifdefined
\localbodyfontsize
\else
\newdimen
\localbodyfontsize
\fi
\localbodyfontsize
=
\globalbodyfontsize
405
\ifdefined
\bodyfontsize
\else
\newdimen
\bodyfontsize
\fi
\bodyfontsize
=
\globalbodyfontsize
406 407
%D When we assign for instance 12pt to a \DIMENSION\ register the \type {\the}'d
408
%D value comes out as 12.0pt, which is often not the way users specify the bodyfont
409
%D size. Therefore we use normalized values. They are cached to save overhead in
410
%D \LUA\ calls.
411 412
\installcorenamespace
{
fontnormalizedbody
}
413 414
\def
\normalizebodyfontsize
#
macro
#
body
%
415
{
\expandafter\let\expandafter
#
macro
\csname
\??fontnormalizedbody
\number\dimexpr
#
body
\endcsname
416
\ifx
#
macro
\relax
417
\normalizebodyfontsize_indeed
#
macro
{
#
body
}
%
418
\fi
}
419 420
\def
\normalizebodyfontsize_indeed
#
macro
#
body
%
421
{
\edef
#
macro
{
\clf_nbfs
\dimexpr
#
body
\relax
}
%
422
\expandafter
\glet
\csname
\??fontnormalizedbody
\number\dimexpr
#
body
\endcsname
#
macro
}
423 424
\def
\thenormalizedbodyfontsize
#
body
%
425
{
\clf_nbfs
\dimexpr
#
body
\relax
}
426 427
\edef
\normalizedglobalbodyfontsize
{
\thenormalizedbodyfontsize\bodyfontsize
}
428
\edef
\normalizedlocalbodyfontsize
{
\thenormalizedbodyfontsize\bodyfontsize
}
429
\edef
\normalizedbodyfontsize
{
\thenormalizedbodyfontsize\bodyfontsize
}
430 431
%D \macros
432
%D {mapfontsize}
433
%D
434
%D For special purposes, like in math, you may want to use slightly different sizes
435
%D than the ones given. This happens for instance with the Math Times fonts. Mapped
436
%D font sizes can be specified by using the \type {mo} key instead of \type {sa} in
437
%D font definitions.
438
%D
439
%D \startbuffer
440
%D \mapfontsize[10pt][11pt]
441
%D \mapfontsize[11pt][12pt]
442
%D \mapfontsize[12pt][13pt]
443
%D
444
%D \definefont[test][Serif]\test TEST \par
445
%D \definefont[test][Serif sa 5]\test TEST \par
446
%D \definefont[test][Serif mo 5]\test TEST \par
447
%D \definefont[test][Serif sa d]\test TEST \par
448
%D \definefont[test][Serif at 60pt]\test TEST \par
449
%D \definefont[test][Serif scaled 6000]\test TEST \par
450
%D \stopbuffer
451
%D
452
%D \typebuffer
453
%D
454
%D \startpacked
455
%D \getbuffer
456
%D \stoppacked
457 458
\installcorenamespace
{
mappedfontsize
}
459 460
\unexpanded
\def
\mapfontsize
461
{
\dodoubleargument
\font_basics_map_fontsize
}
462 463
\def
\font_basics_map_fontsize
[#
from
][#
to
]
%
464
{
\setvalue
{
\??mappedfontsize
\the\dimexpr
#
from
\relax
}{
#
to
}}
465 466
\def
\font_basics_set_mapped_fontsize
#
from
%
467
{
\ifcsname
\??mappedfontsize
\the\dimexpr
#
from
\relax\endcsname
468
\lastnamedcs\else
#
from
%
469
\fi
}
470 471
\installcorenamespace
{
fontbodyknown
}
472
\installcorenamespace
{
fontclassyes
}
% fontclass
473
\installcorenamespace
{
fontclassnop
}
% nofontclass
474 475
\def
\font_helpers_process_relative_size_list
#
command
% could be a toks
476
{
#
command
\v!big
477
#
command
\v!small
}
478 479
\let
\v_font_size_relative
\plusone
480
\def
\v_font_size_absolute
{
\fontbody
}
481 482
\let
\v_font_rscale_default
\!!plusone
483
\let
\p_font_rscale
\v_font_rscale_default
484 485
\def
\font_helpers_check_relative_font_id
% can be plugged in later
486
{
\let
\p_font_rscale
\minusone
487
\let
\p_font_rscale
\v_font_rscale_default
}
488 489
\def
\font_helpers_check_relative_font_size
#
style
%
490
{
\edef
\p_font_rscale
491
{
\ifcsname
\??fontclass
\fontclass
#
style
\s!rscale
\endcsname
492
\lastnamedcs
493
\orelse\ifcsname
\??fontclass
\defaultfontclass
#
style
\s!rscale
\endcsname
% brr
494
\lastnamedcs
495
\else
496
\v_font_rscale_default
497
\fi
}
%
498
% move elsewhere
499
\ifx
\p_font_rscale
\v!auto
500
\let
\p_font_rscale
\plusone
501
\font_helpers_check_relative_font_id
502
\else
503
\let
\relativefontid
\minusone
504
\fi
}
505 506
\def
\font_rscale_xx
#
style
%
507
{
\ifcsname
\??fontclass
\fontclass
#
style
\s!rscale
\endcsname
508
\lastnamedcs
509
\else
510
\v_font_rscale_default
511
\fi
}
512 513
\def
\font_rscale_mm
514
{
\ifcsname
\??fontclass
\fontclass
\s!mm\s!rscale
\endcsname
515
\lastnamedcs
516
\else
517
\v_font_rscale_default
518
\fi
}
519 520
\def
\font_helpers_register_fontbody
#
body
%
521
{
\expandafter\let\csname
\??fontbodyknown
#
body
\endcsname
\empty
}
522 523
%D \macros
524
%D {definefontstyle,definefontsize,definefontalternative}
525
%D
526
%D When setting of switching the overall style we can use the short identifier like
527
%D rm and ss, but when defined we can also use more verbose names like roman or
528
%D sansserif. Such names are defined by:
529
%D
530
%D \starttyping
531
%D \definefontstyle [serif,rm] [rm]
532
%D \definefontstyle [sansserif,ss] [ss]
533
%D \stoptyping
534 535
\installcorenamespace
{
fontstyle
}
% full style prefix (roman etc)
536
\installcorenamespace
{
fontshortstyle
}
% short style prefix (rm etc)
537 538
\installcorenamespace
{
fontstyleknown
}
539
\installcorenamespace
{
fontalternativeknown
}
540
\installcorenamespace
{
fontsizeknown
}
541 542
\newtoks
\t_font_style_commands
543
\newtoks
\t_font_size_commands
544
\newtoks
\t_font_alternative_commands
545 546
\setnewmacro
\m_font_style_command
\gobbleoneargument
547
\setnewmacro
\m_font_size_command
\gobbleoneargument
548
\setnewmacro
\m_font_alternative_command
\gobbleoneargument
549 550
\def
\font_helpers_process_style_list
#
command
{
\def
\m_font_style_command
{
#
command
}
\the
\t_font_style_commands
}
551
\def
\font_helpers_process_size_list
#
command
{
\def
\m_font_size_command
{
#
command
}
\the
\t_font_size_commands
}
552
\def
\font_helpers_process_alternative_list
#
command
{
\def
\m_font_alternative_command
{
#
command
}
\the
\t_font_alternative_commands
}
553 554
\def
\font_helpers_register_style
#
style
{
\expandafter\let\csname
\??fontstyleknown
#
style
\endcsname
\empty
}
555
\def
\font_helpers_register_size
#
size
{
\expandafter\let\csname
\??fontsizeknown
#
size
\endcsname
\empty
}
556
\def
\font_helpers_register_alternative
#
alternative
{
\expandafter\let\csname
\??fontalternativeknown
#
alternative
\endcsname
\empty
}
557 558
\unexpanded
\def
\definefontstyle
559
{
\dodoubleargument
\font_basics_define_fontstyle
}
560 561
\def
\font_basics_define_fontstyle
[#
commands
][#
style
]
% style: rm ss tt ...
562
{
\ifcsname
\??fontstyleknown
#
style
\endcsname
\else
% can be delayed till used (cg, hw)
563
\font_helpers_register_style
{
#
style
}
%
564
\toksapp
\t_font_style_commands
{
\m_font_style_command
{
#
style
}}
%
565
\fi
566
\processcommalist
[#
commands
]
{
\font_basics_define_fontstyle_indeed
{
#
style
}}}
567 568
\def
\font_basics_define_fontstyle_indeed
#
style
#
command
%
569
{
\setvalue
{
\??fontshortstyle
#
command
}{
#
style
}
%
570
\setvalue
{
\??fontstyle
#
command
}{
\csname
#
style
\endcsname
}}
571 572
\unexpanded
\def
\definefontsize
[#
size
]
%
573
{
\ifcsname
\??fontsizeknown
#
size
\endcsname
\else
574
\font_helpers_register_size
{
#
size
}
%
575
\toksapp
\t_font_size_commands
{
\m_font_size_command
{
#
size
}}
%
576
\fi
577
\font_helpers_check_fontname_combinations
}
578 579
\unexpanded
\def
\definefontalternative
[#
alternative
]
%
580
{
\ifcsname
\??fontalternativeknown
#
alternative
\endcsname
\else
581
\font_helpers_register_alternative
{
#
alternative
}
%
582
\toksapp
\t_font_alternative_commands
{
\m_font_alternative_command
{
#
alternative
}}
%
583
\fi
584
\font_helpers_check_fontname_combinations
}
585 586
\unexpanded
\def
\font_helpers_check_fontname_combinations
% we need to split math and text here ... todo (math only has mr and mb)
587
{
\font_helpers_process_style_list
\font_helpers_check_fontname_combinations_s
}
588 589
\def
\font_helpers_check_fontname_combinations_s
#
style
%
590
{
\font_helpers_process_alternative_list
{
\font_helpers_check_fontname_combinations_indeed_s_a
{
#
style
}}}
591 592
\def
\font_helpers_check_fontname_combinations_indeed_s_a
#
style
#
alternative
%
593
{
\font_helpers_process_size_list
{
\font_basics_check_fontname_combination
{
#
style
}{
#
alternative
}}}
594 595
\definefontstyle
[
\s!mm
]
[
\s!mm
]
596
\definefontstyle
[
\s!rm
]
[
\s!rm
]
597
\definefontstyle
[
\s!ss
]
[
\s!ss
]
598
\definefontstyle
[
\s!tt
]
[
\s!tt
]
599 600
%D We define all the font switching commands globally. After all they are part of
601
%D the formal font interface once defined. The size can be empty (so checking is
602
%D needed as \type {\bf} is already defined).
603
%D
604
%D The \type {\normal..} variants are available as extras for cases where the \type
605
%D {..} is overloaded.
606 607
\newmacro
\m_font_mm
608 609
\def
\font_basics_check_fontname_combination
#
style
% alternative size
610
{
\edef
\m_font_mm
{
#
style
}
%
611
\ifx
\m_font_mm
\s!mm
% prevents \max and alike (re)defs
612
\expandafter
\font_basics_check_math_bodyfont
613
\else
614
\expandafter
\font_basics_check_text_bodyfont
615
\fi
{
#
style
}}
% no \m_font_mm, not expanded later on
616 617
\def
\font_basics_check_math_bodyfont
#
style
#
alternative
#
size
%
618
{}
619 620
\def
\font_basics_check_text_bodyfont_step
#
whatever
#
body
% size can be empty (checking needed as \bf is already defined)
621
{
\ifcsname
#
whatever
\endcsname\else
622
\setugvalue
{
#
whatever
}{
#
body
}
%
623
\fi
}
624 625
\def
\font_basics_check_text_bodyfont
#
style
#
alternative
#
size
% size can be empty (checking needed as \bf is already defined)
626
{
\font_basics_check_text_bodyfont_step
{
#
style
#
size
}{
\font_helpers_set_current_font_style_size
{
#
style
}{
#
size
}}
% \rma
627
\font_basics_check_text_bodyfont_step
{
#
alternative
#
size
}{
\font_helpers_set_current_font_alternative_size
{
#
alternative
}{
#
size
}}
% \sla
628
\font_basics_check_text_bodyfont_step
{
#
style
#
alternative
#
size
}{
\font_helpers_set_current_font_style_alternative_size
{
#
style
}{
#
alternative
}{
#
size
}}
% \rmsla
629
\font_basics_check_text_bodyfont_step
{
#
style
}{
\font_helpers_set_current_font_style
{
#
style
}}
% \rm
630
\font_basics_check_text_bodyfont_step
{
#
alternative
}{
\font_helpers_set_current_font_alternative
{
#
alternative
}}
% \sl
631
\font_basics_check_text_bodyfont_step
{
#
style
\s!x
}{
\font_helpers_set_current_font_x_style_alternative
{
#
style
}}
% \rmx
632
\font_basics_check_text_bodyfont_step
{
#
style
\s!xx
}{
\font_helpers_set_current_font_xx_style_alternative
{
#
style
}}
% \rmxx
633
\font_basics_check_text_bodyfont_step
{
#
alternative
\s!x
}{
\font_helpers_set_current_font_x_alternative
{
#
alternative
}}
% \slx
634
\font_basics_check_text_bodyfont_step
{
#
alternative
\s!xx
}{
\font_helpers_set_current_font_xx_alternative
{
#
alternative
}}
% \slxx
635
\font_basics_check_text_bodyfont_step
{
#
style
#
alternative
}{
\font_helpers_set_current_font_style_alternative
{
#
style
}{
#
alternative
}}}
% \rmsl
636 637
%D Scaling macros:
638
%D
639
%D This system is somewhat complicated by two (possible conflicting) demands:
640
%D
641
%D \startitemize
642
%D \item We support wildcards like \type {sa *} which will adapt to the current
643
%D size. This is also the default specification.
644
%D \item We support named scales like \type {sa d}; beware: \type {x} and \type {xx}
645
%D are valid scales but they are not alway the same as the ones used in for
646
%D instance \type {\bfx} because there the sized come from the bodyfont
647
%D environment. In the future there maybe a switch that also honors the
648
%D environment in named scales.
649
%D \stopitemize
650
%D
651
%D Keep in mind that the smaller sizes are just for text super and subscripts while
652
%D larger sizes can be used in titles where for instance math follows the size.
653 654
% b:x{\definedfont[SerifBold sa b]x}{\bfb x $x^x$}\par
655
% 1:x{\definedfont[SerifBold sa 1]x}{\bf x $x^x$}\par
656
% x:x{\definedfont[SerifBold sa x]x}{\bfx x $x^x$}\par
657
% xx:x{\definedfont[SerifBold sa xx]x}{\bfxx x $x^x$}\par
658
%
659
% *:x{\definedfont[Serif sa *]x}\par
660
% 1:x{\definedfont[Serif sa 1]x}\par
661
% 2:x{\definedfont[Serif sa 2]x}\par
662
% 3:x{\definedfont[Serif sa 3]x}\par
663
% 4:x{\definedfont[Serif sa 4]x}\par
664
% 5:x{\definedfont[Serif sa 5]x}\par
665 666
\def
\safontscale
{
\number\dimexpr
\v_font_size_absolute
\relax
}
667
\def
\mofontscale
{
\number\dimexpr
\font_basics_set_mapped_fontsize
\v_font_size_absolute
\relax
}
668 669
\let
\somefontname
\s!unknown
670
\let
\somefontspec
\s!unknown
671
\let
\somefontsize
\zerocount
672 673
\newcount
\scaledfontmode
% also used at the lua end
674
\newcount
\scaledfontsize
% also used at the lua end
675
\newcount
\lastfontid
% also used at the lua end / tex end
676
\newtoks
\everydefinefont
677 678
\let
\relativefontid
\minusone
% todo, not yet used
679 680
\let
\c_font_feature_inheritance_fontnone
\zerocount
% none
681
\let
\c_font_feature_inheritance_fontonly
\plusone
% fontonly
682
\let
\c_font_feature_inheritance_classonly
\plustwo
% classonly
683
\let
\c_font_feature_inheritance_fontfirst
\plusthree
% fontfirst
684
\let
\c_font_feature_inheritance_classfirst
\plusfour
% classfirst
685 686
\let
\c_font_feature_inheritance_default
\c_font_feature_inheritance_fontfirst
687 688
\setnewconstant
\c_font_feature_inheritance_mode
\c_font_feature_inheritance_default
689 690
\newdimen
\d_font_scaled_text_face
691
\newdimen
\d_font_scaled_font_size
692
\newconditional
\c_font_body_scale
693
\newfraction
\f_font_body_scale
694 695
\unexpanded
\def
\font_helpers_low_level_define
#
specification
#
csname
%
696
{
% we can now set more at the lua end
697
\glet
\somefontname
\defaultfontfile
698
\let
\somefontsize
\empty
699
\clf_definefont_one
{
\detokenize\expandafter
{
\normalexpanded
{
#
specification
}}}
% the escapestring catches at \somedimen
700
% sets \scaledfontmode and \somefontname and \somefontsize
701
\ifcase
\fontface
\relax
702
% \let\v_font_size_absolute\textface % fontbody
703
\or
704
\let
\v_font_size_absolute
\textface
705
\or
706
\let
\v_font_size_absolute
\scriptface
707
\or
708
\let
\v_font_size_absolute
\scriptscriptface
709
\or
710
\let
\v_font_size_absolute
\xtextface
711
\or
712
\let
\v_font_size_absolute
\xxtextface
713
\fi
714
%
715
\ifcase
\scaledfontmode
\relax
716
% none, avoid the designsize if possible
717
\d_font_scaled_font_size
-
\plusthousand\scaledpoint
718
\or
719
% at
720
\d_font_scaled_font_size
\somefontsize
721
\or
722
% sa
723
\d_font_scaled_font_size
\v_font_size_absolute
\relax
724
\d_font_scaled_font_size
\currentfontbodysize
\d_font_scaled_font_size
% uses \somefontsize set by lua
725
\or
726
% mo
727
\d_font_scaled_font_size
\font_basics_set_mapped_fontsize
\v_font_size_absolute
728
\d_font_scaled_font_size
\currentfontbodysize
\d_font_scaled_font_size
729
\or
730
% scaled, don't use this one as it's unpredictable
731
\d_font_scaled_font_size
-
\somefontsize
\scaledpoint
732
\else
% ht cp
733
% experiment, yet undocumented
734
\d_font_scaled_font_size
\somefontsize
735
\fi
736
\relax
737
\d_font_scaled_font_size
\v_font_size_relative
\d_font_scaled_font_size
738
\ifconditional
\c_font_auto_size
739
\font_helpers_check_body_scale
\fontsize
740
\ifconditional
\c_font_body_scale
741
\d_font_scaled_font_size
\f_font_body_scale
\d_font_scaled_font_size
742
\d_font_scaled_text_face
\f_font_body_scale
\dimexpr
\textface
\relax
743
\else
744
\d_font_scaled_font_size
\f_font_body_scale
745
\d_font_scaled_text_face
\textface
746
\fi
747
\else
748
\d_font_scaled_text_face
\textface
749
\fi
750
\edef
\somefontspec
{
at
\number
\d_font_scaled_font_size
sp
}
%
751
\edef
\somefontfile
{
\truefontname
\somefontname
}
%
752
\ifx
\somefontfile
\s!unknown
753
\edef
\somefontfile
{
\defaultfontfile
}
%
754
\fi
755
\font_helpers_update_font_parameters
756
\font_helpers_update_font_class_parameters
757
%\writestatus{fonts}{low level define: #csname/\somefontfile/\number\d_font_scaled_font_size/\fontface/\number\d_font_scaled_text_face}%
758
\clf_definefont_two
759
\ifempty
\fontclass
\s!false
\else
\s!true
\fi
760
{
#
csname
}
%
761
{
\somefontfile
}
%
762
\d_font_scaled_font_size
763
\c_font_feature_inheritance_mode
764
{
\m_font_class_features
}
%
765
{
\m_font_features
}
%
766
{
\m_font_class_fallbacks
}
%
767
{
\m_font_fallbacks
}
%
768
\fontface
769
\d_font_scaled_text_face
770
\relativefontid
771
{
\m_font_class_goodies
}
%
772
{
\m_font_goodies
}
%
773
{
\m_font_class_designsize
}
%
774
{
\m_font_designsize
}
%
775
\scaledfontmode
776
\relax
777
\ifcase
\scaledfontsize
778
%\scaledfontsize\plusone
779
\let
\somefontspec
\empty
780
\let
\lastrawfontcall
\relax
781
\expandafter\let\csname
#
csname
\endcsname\relax
782
\else
783
\edef
\somefontspec
{
at
\number
\scaledfontsize
sp
}
% we need the resolved designsize (for fallbacks)
784
\expandafter\let\expandafter
\lastrawfontcall
\csname
#
csname
\endcsname
785
\the
\everydefinefont
786
\fi
787
\c_font_feature_inheritance_mode
\c_font_feature_inheritance_default
}
788 789
\def
\font_helpers_check_body_scale
#
fontsize
% gets character (x xx a etc)
790
{
\ifcsname
\??fontenvironments
\fontclass\fontbody
#
fontsize
\endcsname
791
\expandafter\let\expandafter
\f_font_body_scale
\lastnamedcs
792
\setfalse
\c_font_body_scale
% !
793
\orelse\ifcsname
\??fontenvironments
\fontclass
\s!default
#
fontsize
\endcsname
794
\expandafter\let\expandafter
\f_font_body_scale
\lastnamedcs
795
\settrue
\c_font_body_scale
796
\orelse\ifcsname
\??fontenvironments
\fontbody
#
fontsize
\endcsname
797
\expandafter\let\expandafter
\f_font_body_scale
\lastnamedcs
798
\setfalse
\c_font_body_scale
% !
799
\orelse\ifcsname
\??fontenvironments\s!default
#
fontsize
\endcsname
800
\expandafter\let\expandafter
\f_font_body_scale
\lastnamedcs
801
\settrue
\c_font_body_scale
802
\orelse\ifcsname
\??fontenvironments
\fontclass
\s!default\s!text
\endcsname
803
\expandafter\let\expandafter
\f_font_body_scale
\lastnamedcs
804
\settrue
\c_font_body_scale
805
\orelse\ifcsname
\??fontenvironments\s!default\s!text
\endcsname
806
\expandafter\let\expandafter
\f_font_body_scale
\lastnamedcs
807
\settrue
\c_font_body_scale
808
\else
809
\let
\f_font_body_scale
\plusone
810
\settrue
\c_font_body_scale
811
\fi
}
812 813
%D The following macros are used at the \LUA\ end. Watch the \type {\normal}
814
%D hackery: this makes the mkvi parser happy.
815 816
% \normaldef\fntsetdefname {\glet\somefontname\defaultfontfile} % do before calling
817
% \normaldef\fntsetnopsize {\let\somefontsize\empty} % do before calling
818
% \normaldef\fntsetsomename{\normalgdef\somefontname} % takes argument
819
% \normaldef\fntsetsomesize{\normaldef\somefontsize} % takes argument
820 821
\newif
\ifskipfontcharacteristics
\skipfontcharacteristicstrue
822 823
\tracingfonts
\plussix
% <id: name @ size>
824 825
%D When fontclasses are used, we define the font global, since namespaces are
826
%D used. Otherwise we parse the specs each time.
827 828
\let
\fontfile
\s!unknown
829 830
%D Relatively new:
831 832
\installcorenamespace
{
fonts
}
833
\installcorenamespace
{
fontslanguage
}
834 835
\installsetuponlycommandhandler
\??fonts
{
fonts
}
836 837
\newconstant
\c_fonts_auto_language
838 839
\letvalue
{
\??fontslanguage\v!auto
}
\plusone
% experimental
840
%letvalue{\??fontslanguage\v!yes }\plustwo % less efficient, for experiments
841 842
\appendtoks
843
\c_fonts_auto_language
844
\ifcsname
\??fontslanguage
\fontsparameter
\c!language
\endcsname
845
\lastnamedcs
846
\else
847
\zerocount
848
\fi
849
\to
\everysetupfonts
850 851
\appendtoks
852
\ifcase
\c_fonts_auto_language
853
% nothing
854
\or
855
\addfflanguage
856
% \or
857
% font
858
\fi
859
\to
\everylanguage
860 861
% \setupfonts
862
% [\c!language=\v!auto]
863 864
%D \macros
865
%D {everyfont,everyfontswitch}
866 867
\ifdefined
\everyfont
\else
\newtoks
\everyfont
\fi
868
\ifdefined
\everyfontswitch
\else
\newtoks
\everyfontswitch
\fi
869 870
\def
\setfontcharacteristics
{
\the
\everyfont
}
871 872
% \appendtoks
873
% \ifcase\c_fonts_auto_language
874
% % nothing
875
% \or
876
% % auto
877
% \or
878
% \addfflanguage
879
% \fi
880
% \to \everyfont
881 882
%D \macros
883
%D {definefont}
884
%D
885
%D We also accept \type{sa a}||\type{sa d} as specification.
886
%D
887
%D Before we implement the main definition macro, we first show one for local use:
888
%D
889
%D \starttyping
890
%D \definefont[Some][LucidaBright at 100pt] \Some some
891
%D \definefont[More][LucidaBright scaled 3000] \More more
892
%D \definefont[Nice][LucidaBright mo 2] \Nice nice
893
%D \definefont[Text][LucidaBright sa 5.4] \Text last
894
%D \stoptyping
895
%D
896
%D The implementation looks as follows:
897 898
\unexpanded
\def
\definefont
% [name][spec][1.6 | line=10pt | setup_id]
899
{
\dotripleempty
\font_basics_define_font
}
900 901
\def
\font_basics_define_font
902
{
\ifthirdargument
903
\expandafter
\font_basics_define_font_a
904
\else
905
\expandafter
\font_basics_define_font_b
906
\fi
}
907 908
\def
\font_basics_define_font_a
[#
name
][#
specification
][#
settings
]
% [name][spec][1.6 | line=10pt | setup_id]
909
{
\doifelsesetups
{
#
settings
}
%
910
{
\setuvalue
{
#
name
}{
\font_basics_define_font_with_setups
{
#
name
}{
#
specification
}{
#
settings
}}}
911
{
\setuvalue
{
#
name
}{
\font_basics_define_font_with_parameters
{
#
name
}{
#
specification
}{
#
settings
}}}}
912 913
\def
\font_basics_define_font_b
[#
name
][#
specification
][#
dummy
]
%
914
{
\setuvalue
{
#
name
}{
\font_basics_define_font_without_parameters
{
#
name
}{
#
specification
}}}
915 916
\def
\font_basics_define_font_with_parameters
#
name
#
specification
#
settings
%
917
{
\font_basics_define_font_without_parameters
{
#
name
}{
#
specification
}
%
918
\setuplocalinterlinespace
[#
settings
]
%
919
\setupspacing
\relax
}
% is this really needed ?
920 921
\def
\font_basics_define_font_with_setups
#
name
#
specification
#
settings
%
922
{
\font_basics_define_font_without_parameters
{
#
name
}{
#
specification
}
%
923
\setups
[#
settings
]
}
924 925
%D Beware, in the frozen variants no settings are supported yet, but that might happen
926
%D some day.
927 928
\unexpanded
\def
\definefrozenfont
929
{
\dotripleempty
\font_basics_define_frozen_font
}
930 931
% \def\font_basics_define_frozen_font[#name][#specification][#settings]%
932
% {\begingroup
933
% \font_basics_define_font[#name][#specification][#settings]%
934
% \csname#name\endcsname
935
% \expandafter\expandafter\expandafter\endgroup\expandafter\let\csname#name\endcsname\lastrawfontcall}
936 937
\def
\font_basics_define_frozen_font
[#
name
][#
specification
][#
settings
]
%
938
{
\begingroup
939
\font_basics_define_font
[#
name
][#
specification
][#
settings
]
%
940
\csname
#
name
\endcsname
941
\glet
\lastglobalrawfontcall
\lastrawfontcall
942
\endgroup
943
\expandafter\let\csname
#
name
\endcsname
\lastglobalrawfontcall
}
944 945
%D The instance namespace protection makes the switch local so that we can redefine a
946
%D logical name and/or change the size in between.
947 948
% todo: now mathsize twice in name (so it can go here)
949
% todo: check when mathsize is needed
950 951
\ifdefined
\??fontinstanceready
\else
\installcorenamespace
{
fontinstanceready
}
\fi
952
\ifdefined
\??fontinstancebasic
\else
\installcorenamespace
{
fontinstancebasic
}
\fi
953
\ifdefined
\??fontinstanceclass
\else
\installcorenamespace
{
fontinstanceclass
}
\fi
954 955
\newconditional
\c_font_auto_size
\settrue
\c_font_auto_size
956 957
\let
\lastfontidentifier
\empty
958 959
\def
\v_font_identifier_basic
{
\??fontinstancebasic
\lastfontidentifier
-
\fontsize
-
\fontface
}
960
\def
\v_font_identifier_class
{
\??fontinstanceclass
\fontclass
-
\lastfontidentifier
-
\fontsize
-
\fontface
}
961 962
\let
\v_font_identifier_basic_saved
\v_font_identifier_basic
963
\let
\v_font_identifier_class_saved
\v_font_identifier_class
964 965
% \def\v_font_identifier_class{\??fontinstanceclass\fontclass-\lastfontidentifier-\fontstyle-\fontsize} % no \fontface
966 967
\def
\font_basics_define_font_without_parameters
#
identifier
#
2
%
968
{
\c_font_feature_inheritance_mode
\c_font_feature_inheritance_fontonly
969
\edef
\lastfontidentifier
{
#
identifier
}
%
970
\let
\v_font_size_relative
\v_font_rscale_default
971
\let
\v_font_size_absolute
\fontbody
972
\font_helpers_low_level_define
{
#
2
}
\v_font_identifier_basic
973
\csname
\v_font_identifier_basic
\endcsname
974
\setfalse
\c_font_auto_size
975
\setfontcharacteristics
976
\the
\everyfontswitch
977
\let
\v_font_identifier_basic
\v_font_identifier_basic_saved
}
978 979
\unexpanded
\def
\font_helpers_trigger
#
identifier
% make a traced variant
980
{
\edef
\lastfontidentifier
{
#
identifier
}
%
981
\ifcsname
\v_font_identifier_class
\endcsname
982
% \writestatus{fonts}{trigger: reusing \v_font_identifier_class}%
983
\expandafter
\font_helpers_trigger_reuse
984
\else
985
% \writestatus{fonts}{trigger: defining \v_font_identifier_class}%
986
\expandafter
\font_helpers_trigger_define
987
\fi
}
988 989
\def
\font_helpers_trigger_define
#
relative
#
absolute
#
specification
%
990
{
\def
\v_font_size_relative
{
#
relative
}
%
991
\def
\v_font_size_absolute
{
#
absolute
}
%
992
\font_helpers_low_level_define
{
#
specification
}
\v_font_identifier_class
993
\csname
\v_font_identifier_class
\endcsname
994
\setfalse
\c_font_auto_size
995
\ifskipfontcharacteristics
\else
996
\setfontcharacteristics
997
\the
\everyfontswitch
998
\fi
999
\let
\v_font_identifier_class
\v_font_identifier_class_saved
}
1000 1001
\def
\font_helpers_trigger_reuse
#
relative
#
absolute
#
specification
%
1002
{
\csname
\v_font_identifier_class
\endcsname
1003
\setfalse
\c_font_auto_size
1004
\ifskipfontcharacteristics
\else
1005
\setfontcharacteristics
1006
\the
\everyfontswitch
1007
\fi
1008
\let
\v_font_identifier_class
\v_font_identifier_class_saved
}
1009 1010
%D \macros
1011
%D {currentfontbodyscale}
1012
%D
1013
%D Sometimes we need to have access to the font scale including the \type {a}||\type
1014
%D {d} sizes. The next macro returns the current scaling factor. Take a look at
1015
%D \type {cont-log.tex} for an example of its use.
1016 1017
\installcorenamespace
{
fontenvironments
}
1018 1019
\def
\currentfontbodysize
% gets number (the normal sa 1 etc)
1020
{
\ifcsname
\??fontenvironments
\fontclass
\s!default
\somefontsize
\endcsname
1021
\lastnamedcs
1022
\orelse\ifcsname
\??fontenvironments\s!default
\somefontsize
\endcsname
1023
\lastnamedcs
1024
\else
1025
\somefontsize
1026
\fi
}
1027 1028
\def
\currentfontbodyscale
% gets character (x xx a etc)
1029
{
\csname
\??fontenvironments
1030
\ifcsname
\??fontenvironments
\fontclass
\s!default
\fontsize
\endcsname
\fontclass
\s!default
\fontsize
\orelse
1031
\ifcsname
\??fontenvironments
\s!default
\fontsize
\endcsname
\s!default
\fontsize
\orelse
1032
\ifcsname
\??fontenvironments
\fontclass
\s!default\s!text
\endcsname
\fontclass
\s!default\s!text
\orelse
1033
\ifcsname
\??fontenvironments
\s!default\s!text
\endcsname
\s!default\s!text
\else
1034
\s!default
\fi
1035
\endcsname
}
1036 1037
\def
\font_currentfontbodyscale
% gets character (x xx a etc)
1038
{
\ifcsname
\??fontenvironments
\fontclass
\s!default
\fontsize
\endcsname\lastnamedcs\orelse
1039
\ifcsname
\??fontenvironments
\s!default
\fontsize
\endcsname\lastnamedcs\orelse
1040
\ifcsname
\??fontenvironments
\fontclass
\s!default\s!text
\endcsname\lastnamedcs\orelse
1041
\ifcsname
\??fontenvironments
\s!default\s!text
\endcsname\lastnamedcs\else
1042
\csname
\??fontenvironments
\s!default
\endcsname
\fi
}
1043 1044
\def
\currentfontscale
% used in default definition
1045
{
\csname
\??fontenvironments
1046
\ifcsname
\??fontenvironments
\fontclass
\s!default
\xfontsize
\endcsname
\fontclass
\s!default
\fontsize
\orelse
1047
\ifcsname
\??fontenvironments
\s!default
\xfontsize
\endcsname
\s!default
\fontsize
\orelse
1048
\ifcsname
\??fontenvironments
\fontclass
\s!default\s!text
\endcsname
\fontclass
\s!default\s!text
\orelse
1049
\ifcsname
\??fontenvironments
\s!default\s!text
\endcsname
\s!default\s!text
\else
1050
\s!default
\fi
1051
\endcsname
}
1052 1053
\def
\font_currentfontscale
% used in default definition
1054
{
\ifcsname
\??fontenvironments
\fontclass
\s!default
\xfontsize
\endcsname\lastnamedcs\orelse
1055
\ifcsname
\??fontenvironments
\s!default
\xfontsize
\endcsname\lastnamedcs\orelse
1056
\ifcsname
\??fontenvironments
\fontclass
\s!default\s!text
\endcsname\lastnamedcs\orelse
1057
\ifcsname
\??fontenvironments
\s!default\s!text
\endcsname\lastnamedcs\else
1058
\csname
\??fontenvironments
\s!default
\endcsname
\fi
}
1059 1060
\setvalue
{
\??fontenvironments\s!default
}{
1
}
1061 1062
%D In the following macros we use \type {\currentxfontsize} to hold the current
1063
%D x||size of the font. This enables us to support for instance \type {\sl} inside a
1064
%D \type {\tx} switch.
1065 1066
\newconstant
\currentxfontsize
1067 1068
\def
\xfontsize
{
\ifcase
\currentxfontsize
\fontsize
\or
\s!x
\else
\s!xx
\fi
}
1069 1070
%D Now we enter the area of font switching. The switching mechanism has to take care
1071
%D of several situations, like:
1072
%D
1073
%D \startitemize[packed]
1074
%D \item changing the overal document fonts (including margins, headers and footers)
1075
%D \item changing local fonts (only the running text)
1076
%D \item smaller and even more smaller alternatives (super- and subscripts)
1077
%D \stopitemize
1078
%D
1079
%D \TEX\ offers a powerfull family mechanism for super- and subscripts in math mode.
1080
%D In text mode however, we don't use families for the smaller alternatives, and
1081
%D therefore have to take care of it otherwise.
1082
%D
1083
%D \macros
1084
%D {definebodyfontenvironment,setupbodyfontenvironment}
1085
%D
1086
%D The relationship between the several sizes of a font, is
1087
%D defined by:
1088
%D
1089
%D \showsetup{definebodyfontenvironment}
1090
%D
1091
%D Later on we will see how these parameters are used, so for the moment we stick
1092
%D with an example:
1093
%D
1094
%D \starttyping
1095
%D \definebodyfontenvironment
1096
%D [12pt]
1097
%D [ text=12pt,
1098
%D script=9pt,
1099
%D scriptscript=7pt,
1100
%D x=10pt,
1101
%D xx=8pt,
1102
%D big=12pt,
1103
%D small=10pt]
1104
%D \stoptyping
1105
%D
1106
%D The first argument specifies the bodyfont size to which the settings apply. All
1107
%D second parameters are specified in dimensions and tell us more about related
1108
%D sizes.
1109
%D
1110
%D Afterwards, one can change values with
1111
%D
1112
%D \showsetup{setupbodyfontenvironment}
1113
%D
1114
%D When instead of a size the keyword \type{unknown} is
1115
%D passed, fractions (relations) are used instead of fixed
1116
%D sizes.
1117 1118
%D {\bf Remark:} We need to cover the following cases, otherwise users can get
1119
%D confused:
1120
%D
1121
%D \starttyping
1122
%D \setupbodyfont[23pt]
1123
%D
1124
%D \definebodyfontenvironment[23pt]
1125
%D \setupbodyfont[23pt]
1126
%D
1127
%D \definebodyfontenvironment[23pt]
1128
%D \definebodyfont[23pt][rm,ss,tt][default]
1129
%D \setupbodyfont[23pt]
1130
%D \stoptyping
1131
%D
1132
%D Beware: while some font defs can be global, the bodyfont environment checks
1133
%D local. This means that multiple local checks resulting in definitions are not
1134
%D that efficient. So, apart from an occasional switch, one should define an
1135
%D environment at the outer level.
1136 1137
% \definebodyfontenvironment[33pt]
1138
% \definebodyfontenvironment[dejavu][default][1=.5]
1139
% \definebodyfontenvironment[dejavu][default][x=1.2]
1140
% \definebodyfontenvironment[dejavu][default][a=5]
1141
% \definebodyfontenvironment[dejavu][33pt][x=100pt]
1142 1143
% the lookup order is:
1144
%
1145
% [class] [dimension] [parameters]
1146
% [class] [default] [parameters] % factors
1147
% [dimension] [parameters]
1148
% [default] [parameters] % factors
1149
%
1150
% with defaults providing factors
1151 1152
% todo: class:size
1153
% todo: make assignments global
1154 1155
\letvalue
\??fontenvironments
\empty
% so we default to empty
1156 1157
\def
\bodyfontvariable
#
parameter
%
1158
{
\csname
\??fontenvironments
1159
\ifcsname
\??fontenvironments
\fontclass
\normalizedbodyfontsize
#
parameter
\endcsname
\fontclass
\normalizedbodyfontsize
#
parameter
\orelse
1160
\ifcsname
\??fontenvironments
\fontclass
#
parameter
\endcsname
\fontclass
#
parameter
\orelse
1161
\ifcsname
\??fontenvironments
\normalizedbodyfontsize
#
parameter
\endcsname
\normalizedbodyfontsize
#
parameter
\orelse
1162
\ifcsname
\??fontenvironments\s!default
#
parameter
\endcsname
\s!default
#
parameter
\fi
1163
\endcsname
}
1164 1165
\def
\font_bodyfontvariable
#
parameter
%
1166
{
\ifcsname
\??fontenvironments
\fontclass
\normalizedbodyfontsize
#
parameter
\endcsname\lastnamedcs\orelse
1167
\ifcsname
\??fontenvironments
\fontclass
#
parameter
\endcsname\lastnamedcs\orelse
1168
\ifcsname
\??fontenvironments
\normalizedbodyfontsize
#
parameter
\endcsname\lastnamedcs\orelse
1169
\ifcsname
\??fontenvironments\s!default
#
parameter
\endcsname\lastnamedcs\fi
}
1170 1171
\def
\bodyfontsizevariable
#
size
#
parameter
%
1172
{
\csname
\??fontenvironments
1173
\ifcsname
\??fontenvironments
\fontclass
#
size
#
parameter
\endcsname
\fontclass
#
size
#
parameter
\orelse
1174
\ifcsname
\??fontenvironments
\fontclass
#
parameter
\endcsname
\fontclass
#
parameter
\orelse
1175
\ifcsname
\??fontenvironments
#
size
#
parameter
\endcsname
#
size
#
parameter
\orelse
1176
\ifcsname
\??fontenvironments\s!default
#
parameter
\endcsname
\s!default
#
parameter
\fi
1177
\endcsname
}
1178 1179
\def
\font_bodyfontsizevariable
#
size
#
parameter
%
1180
{
\ifcsname
\??fontenvironments
\fontclass
#
size
#
parameter
\endcsname\lastnamedcs\orelse
1181
\ifcsname
\??fontenvironments
\fontclass
#
parameter
\endcsname\lastnamedcs\orelse
1182
\ifcsname
\??fontenvironments
#
size
#
parameter
\endcsname\lastnamedcs\orelse
1183
\ifcsname
\??fontenvironments\s!default
#
parameter
\endcsname\lastnamedcs\fi
}
1184 1185
\def
\bodyfontinterlinespace
{
\bodyfontvariable
\c!interlinespace
}
% used elsewhere
1186 1187
\def
\bodyfontdimension
#
class
#
size
#
parameter
#
body
%
1188
{
\the\dimexpr
1189
\ifcsname
\??fontenvironments
#
class
#
size
#
parameter
\endcsname
\lastnamedcs
\orelse
1190
\ifcsname
\??fontenvironments
#
class
\s!default
#
parameter
\endcsname
\lastnamedcs\dimexpr
#
body
\relax\orelse
% factor
1191
\ifcsname
\??fontenvironments
#
size
#
parameter
\endcsname
\lastnamedcs
\else
1192
\lastnamedcs\dimexpr
#
body
\relax\fi
% factor
1193
\relax
}
1194 1195
\unexpanded
\def
\definebodyfontenvironment
1196
{
\dotripleempty
\font_basics_define_body_font_environment
}
1197 1198
\let
\setupbodyfontenvironment\definebodyfontenvironment
1199 1200
\installcorenamespace
{
fontenvironmentknown
}
1201 1202
\def
\font_helpers_register_environment
#
class
#
body
%
1203
{
\expandafter\let\csname
\??fontenvironmentknown
#
class
#
body
\endcsname
\empty
}
1204 1205
\newmacro
\m_font_body
1206
\newmacro
\m_font_body_normalized
1207 1208
\def
\font_basics_define_body_font_environment
1209
{
\ifthirdargument
1210
\singleexpandafter
\font_basics_define_body_font_environment_class
1211
\orelse
\ifsecondargument
1212
\expandafter
\font_basics_define_body_font_environment_empty
1213
\else
1214
\expandafter
\font_basics_define_body_font_environment_unset
1215
\fi
}
1216 1217
%D First we handle the class specific case. Beware: you can change values before
1218
%D a bodyfont is loaded but changing them afterwards can be sort of tricky as
1219
%D values are not consulted afterwards.
1220 1221
\def
\processbodyfontenvironmentlist
#
1
% no \unexpanded as then we cannot use it in alignments
1222
{
\clf_processbodyfontsizes
{
\strippedcsname
#
1
}}
1223 1224
\def
\bodyfontenvironmentlist
1225
{
\clf_getbodyfontsizes
}
1226 1227
\def
\font_basics_define_body_font_environment_class
[#
class
][#
body
][#
settings
]
%
1228
{
\edef
\m_font_body
{
#
body
}
%
1229
\ifx
\m_font_body
\s!default
1230
% these are the last resort within a class
1231
\getrawparameters
[
\??fontenvironments
#
class
\s!default
][#
settings
]
%
1232
\else
1233
\normalizebodyfontsize
\m_font_body_normalized
\m_font_body
1234
\font_basics_define_body_font_environment_size
[#
class
][
\m_font_body_normalized
][#
settings
]
%
1235
\clf_registerbodyfontsize
{
\m_font_body_normalized
}
%
1236
\fi
}
1237 1238
%D The empty case uses the same code but needs to ignore the current class settings
1239
%D (just to be sure, as it's not really needed).
1240 1241
\def
\font_basics_define_body_font_environment_empty
[#
body
][#
settings
][#
dummy
]
%
1242
{
\push_macro_fontclass
1243
\let
\fontclass
\empty
1244
\font_basics_define_body_font_environment_class
[][#
body
][#
settings
]
%
1245
\pop_macro_fontclass
}
1246 1247
\def
\font_basics_define_body_font_environment_unset
[#
body
][#
dummya
][#
dummyb
]
%
1248
{
\push_macro_fontclass
1249
\let
\fontclass
\empty
1250
\font_basics_define_body_font_environment_class
[][#
body
][]
%
1251
\pop_macro_fontclass
}
1252 1253
%D We don't check too soon as we can refer to later definitions.
1254 1255
\newconditional
\c_font_defining_environment_state
% controls messages
1256 1257
\def
\font_basics_define_body_font_environment_size
[#
class
][#
normalizedbody
][#
settings
]
% normalized body
1258
{
\getrawparameters
[
\??fontenvironments
#
class
#
normalizedbody
][#
settings
]
%
1259
\ifcsname
\??fontenvironmentknown
#
class
#
normalizedbody
\endcsname
1260
% environment and size already defined
1261
\orelse
\ifproductionrun
1262
\push_macro_fontclass
1263
\edef
\fontclass
{
#
class
}
%
1264
\font_helpers_register_environment
{
#
class
}{
#
normalizedbody
}
%
1265
\settrue
\c_font_defining_environment_state
1266
\font_helpers_define_unknown_font
{
#
normalizedbody
}
% current class
1267
\setfalse
\c_font_defining_environment_state
1268
\pop_macro_fontclass
1269
\fi
1270
\font_helpers_register_fontbody
{
#
normalizedbody
}}
1271 1272
%D Checking
1273 1274
\def
\font_helpers_check_bodyfont_environment
#
normalizedbody
#
body
%
1275
{
\ifcsname
\??fontenvironmentknown
\fontclass
#
normalizedbody
\endcsname
1276
% already defined
1277
\else
1278
\font_helpers_check_bodyfont_environment_indeed
{
#
normalizedbody
}{
#
body
}
%
1279
\fi
}
1280 1281
\def
\font_helpers_check_bodyfont_environment_indeed
#
normalizedbody
#
body
%
1282
{
\font_helpers_register_environment
\fontclass
{
#
normalizedbody
}
%
1283
\ifcsname
\??fontbodyknown
#
normalizedbody
\endcsname
1284
\else
1285
\font_helpers_define_unknown_font
{
#
normalizedbody
}
%
1286
\fi
}
1287 1288
%D We default all parameters to the main bodyfont size, so the next setup is valid
1289
%D too:
1290
%D
1291
%D \starttyping
1292
%D \definebodyfontenvironment[24pt]
1293
%D \stoptyping
1294
%D
1295
%D All parameters can be redefined when needed, so one doesnot have to stick to the
1296
%D default ones.
1297 1298
%D \macros
1299
%D {definebodyfont}
1300
%D
1301
%D The next step in defining a bodyfont involves the actual font files, which can be
1302
%D recognized by their extension \type {tfm}. Installing those file is often beyond
1303
%D the scope of the user and up to the system administrator.
1304
%D
1305
%D \showsetup{definebodyfont}
1306
%D
1307
%D This commands takes three arguments: a (series of) bodyfont size(s), the style
1308
%D group to which the definitions belong, and an alternative, as specified by the
1309
%D \TEX\ (math) families, extended with~a, b~\unknown.
1310
%D
1311
%D We show two examples, that show all the alternative scaling options. The \type
1312
%D {\tfa} alternatives can be extended with \type {\bfa}, \type {\slb}, etc. or even
1313
%D \type {e} and higher alternatives. The magic scaled values are derived from plain
1314
%D \TEX's \type {\magstep}:
1315
%D
1316
%D \starttyping
1317
%D \definebodyfont [12pt] [rm]
1318
%D [tf=cmr12,
1319
%D bf=cmbx12,
1320
%D it=cmti12,
1321
%D sl=cmsl12,
1322
%D bi=cmbxti10 at 12pt,
1323
%D bs=cmbxsl10 at 12pt,
1324
%D tfa=cmr12 scaled 1.200,
1325
%D tfb=cmr12 scaled 1.440,
1326
%D tfc=cmr12 scaled 1.728,
1327
%D tfd=cmr12 scaled 2.074,
1328
%D sc=cmcsc10 at 12pt]
1329
%D
1330
%D \definebodyfont [12pt,11pt,10pt,9pt,8pt] [rm]
1331
%D [tf=lbr sa 1,
1332
%D bf=lbd sa 1,
1333
%D it=lbi sa 1,
1334
%D sl=lbsl sa 1,
1335
%D bi=lbdi sa 1,
1336
%D bs=lbdi sa 1,
1337
%D tfa=lbr sa 1.200,
1338
%D tfb=lbr sa 1.440,
1339
%D tfc=lbr sa 1.728,
1340
%D tfd=lbr sa 2.074,
1341
%D sc=lbr sa 0.833]
1342
%D \stoptyping
1343
%D
1344
%D The second example shows that we can define more sizes at once. The main
1345
%D difference between these examples is that the Computer Modern Roman come in many
1346
%D design sizes. This means that there we cannot define them in bulk using \type
1347
%D {sa}. Instead of \type {rm} (roman) one can define \type {ss} (sans serif), \type
1348
%D {tt} (teletype), \type {hw} (hand written), \type {cg} (calygraphic) and whatever
1349
%D styles.
1350
%D
1351
%D The first argument may be a comma separated list. This, combined with
1352
%D specifications using \type{sa} can save a lot of typing. Although all arguments
1353
%D should be specified, we treat the second argument as optional.
1354
%D
1355
%D Defining a bodyfont involves two actions: defining the specific style related
1356
%D alternatives, like \type {\rma}, \type {\bfa} and \type {\rmsla}, and storing the
1357
%D definitions of their bodyfont size related fonts. The first step is bodyfont
1358
%D independant but executed every time. This permits user definitions like \type
1359
%D {\tfw} or \type {\bfq} for real large alternatives.
1360
%D
1361
%D If we move design size info to the lfg file (after all only lm has design sizes)
1362
%D we can get rid of much code .. 2012 or so.
1363 1364
\installcorenamespace
{
fontdefinitions
}
1365 1366
% [class] [name] [rm,ss] [settings]
1367
% [class] [10pt,11pt] [rm,ss] [settings]
1368
% [class] [10pt,11pt] [rm,ss] [name]
1369 1370
% [class] [name] [settings] == [name] [rm] [settings]
1371
% [class] [10pt,11pt] [settings] == [name] [rm] [settings]
1372
% [class] [10pt,11pt] [name] == [10pt,11pt] [rm] [name]
1373 1374
\unexpanded
\def
\definebodyfont
1375
{
\doquadrupleempty
\font_basics_define_body_font
}
1376 1377
\def
\font_basics_define_body_font
[#
1
][#
2
][#
3
][#
4
]
%
1378
{
\iffourthargument
1379
\processcommacommand
[#
1
]
{
\font_basics_define_body_font_class_given
[#
2
][#
3
][#
4
]
}
%
1380
\else
1381
\font_basics_define_body_font_class_known
[#
1
][#
2
][#
3
]
%
1382
\fi
}
1383 1384
\def
\font_basics_define_body_font_class_given
[#
1
][#
2
][#
3
]#
4
%
1385
{
\push_macro_fontclass
1386
\doifelse
{
#
4
}
\s!default
1387
{
\let
\fontclass
\empty
}
1388
{
\def
\fontclass
{
#
4
}}
%
1389
\definebodyfont
[#
1
][#
2
][#
3
]
%
1390
\pop_macro_fontclass
}
1391 1392
\def
\font_basics_define_body_font_class_known
1393
{
\ifthirdargument
1394
\singleexpandafter
\font_basics_define_body_font_a
1395
\orelse
\ifsecondargument
1396
\expandafter
\font_basics_define_body_font_b
1397
\else
1398
\expandafter
\font_basics_define_body_font_c
1399
\fi
}
1400 1401
\unexpanded
\def
\font_basics_define_body_font_b
[#
whatever
][#
specification
][#
dummy
]
% body|identifier defs|identifier
1402
{
\font_basics_define_body_font_a
[#
whatever
][
\s!rm
][#
specification
]
}
1403 1404
\unexpanded
\def
\font_basics_define_body_font_c
[#
whatever
][#
dummya
][#
dummyb
]
% body|identifier
1405
{
\font_basics_define_body_font_a
[#
whatever
][
\s!rm
][]
}
1406 1407
\unexpanded
\def
\font_basics_define_body_font_a
[#
whatever
]
%
1408
{
\doifelsenumber
{
#
whatever
}
%
1409
\font_basics_define_body_font_body
1410
\font_basics_define_body_font_name
1411
[#
whatever
]
}
1412 1413
\unexpanded
\def
\font_basics_define_body_font_body
[#
body
][#
style
][#
specification
]
%
1414
{
\ifcondition
\validassignment
{
#
specification
}
%
1415
\expandafter
\font_basics_define_body_font_body_assignment
1416
\else
1417
\expandafter
\font_basics_define_body_font_body_identifier
1418
\fi
1419
[#
body
][#
style
][#
specification
]
}
%
1420 1421
\unexpanded
\def
\font_basics_define_body_font_name
[#
name
][#
style
][#
specification
]
%
1422
{
\ifcondition
\validassignment
{
#
specification
}
%
1423
\expandafter
\font_basics_define_body_font_name_assignment
1424
\else
1425
\expandafter
\font_basics_define_body_font_name_identifier
1426
\fi
1427
[#
name
][#
style
][#
specification
]
}
%
1428 1429
\unexpanded
\def
\font_basics_define_body_font_body_assignment
[#
bodylist
][#
stylelist
][#
assignments
]
%
1430
{
\processcommalist
[#
bodylist
]
{
\font_basics_define_body_font_body_assignment_a
{
#
stylelist
}{
#
assignments
}}}
1431 1432
\unexpanded
\def
\font_basics_define_body_font_body_assignment_a
#
stylelist
#
assignments
#
body
%
1433
{
\normalizebodyfontsize
\m_font_asked_body
{
#
body
}
%
1434
% normally we define quite a lot in advance, i.e global defs
1435
\font_helpers_check_bodyfont_environment
\m_font_asked_body
\m_font_asked_body
% !!
1436
\processcommalist
[#
stylelist
]
{
\font_basics_define_body_font_body_assignment_b
{
#
assignments
}}}
1437 1438
\unexpanded
\def
\font_basics_define_body_font_body_assignment_b
#
assignments
#
style
%
1439
{
\edef
\m_font_asked_style
{
#
style
}
%
1440
\processcommalist
[#
assignments
]
\font_basics_define_body_font_defs
}
1441 1442
\unexpanded
\def
\font_basics_define_body_font_defs
1443
{
\ifempty
\fontclass
1444
\expandafter
\font_basics_define_body_font_defs_nop
1445
\else
1446
\expandafter
\font_basics_define_body_font_defs_yes
1447
\fi
}
1448 1449
\unexpanded
\def
\font_basics_define_body_font_defs_yes_normal
#
assignment
%
1450
{
\ifx
\m_font_asked_style
\s!mm
1451
\expandafter
\font_basics_define_body_font_yes_mm
1452
\else
1453
\expandafter
\font_basics_define_body_font_yes_xx
1454
\fi
[#
assignment
]
}
1455 1456
\unexpanded
\def
\font_basics_define_body_font_defs_nop_normal
#
assignment
%
1457
{
\ifx
\m_font_asked_style
\s!mm
1458
\expandafter
\font_basics_define_body_font_nop_mm
1459
\else
1460
\expandafter
\font_basics_define_body_font_nop_xx
1461
\fi
[#
assignment
]
}
1462 1463
\unexpanded
\def
\font_basics_define_body_font_defs_yes_traced
#
assignment
%
1464
{
\writestatus
\m!fonts
{
[
\fontclass
]
[
\m_font_asked_body
]
[
\m_font_asked_style
]
[#
assignment
]
}
%
1465
\ifx
\m_font_asked_style
\s!mm
1466
\expandafter
\font_basics_define_body_font_yes_mm
1467
\else
1468
\expandafter
\font_basics_define_body_font_yes_xx
1469
\fi
[#
assignment
]
}
1470 1471
\unexpanded
\def
\font_basics_define_body_font_defs_nop_traced
#
assignment
%
1472
{
\writestatus
\m!fonts
{
[
\fontclass
]
[
\m_font_asked_body
]
[
\m_font_asked_style
]
[#
assignment
]
}
%
1473
\ifx
\m_font_asked_style
\s!mm
1474
\expandafter
\font_basics_define_body_font_nop_mm
1475
\else
1476
\expandafter
\font_basics_define_body_font_nop_xx
1477
\fi
[#
assignment
]
}
1478 1479
\let
\font_basics_define_body_font_defs_yes
\font_basics_define_body_font_defs_yes_normal
1480
\let
\font_basics_define_body_font_defs_nop
\font_basics_define_body_font_defs_nop_normal
1481 1482
\appendtoks
1483
\let
\font_basics_define_body_font_defs_yes
\font_basics_define_body_font_defs_yes_traced
1484
\let
\font_basics_define_body_font_defs_nop
\font_basics_define_body_font_defs_nop_traced
1485
\to
\t_font_tracers_definitions
1486 1487
%D We split into two characters (first part of spec) and the rest: the first two are
1488
%D the style and the rest is a size, although in practice one will seldom define the
1489
%D size directly. We might even drop that as it gives faster code.
1490 1491
\unexpanded
\def
\font_basics_define_body_font_nop_xx
[#
one
#
two
#
rest
=#
value
]
% local
1492
{
\ifcsname
\m_font_asked_style
#
one
#
two
#
rest
\endcsname\else
\font_basics_check_fontname_combination
\m_font_asked_style
{
#
one
#
two
}{
#
rest
}
\fi
1493
\expandafter\let\csname
\??fontinstanceclass
\m_font_asked_body
-
\m_font_asked_style
-
#
one
#
two
-
#
rest
-
0
\endcsname
\undefined
1494
\unexpanded
\expandafter\normaledef\csname
\??fontinstanceready
\m_font_asked_body
-
\m_font_asked_style
-
#
one
#
two
-
#
rest
-
0
\endcsname
1495
{
\font_helpers_trigger
{
\m_font_asked_body
-
\m_font_asked_style
-
#
one
#
two
#
rest
}{
\noexpand
\font_rscale_xx
{
\m_font_asked_style
}}{
\m_font_asked_body
}{
\normalunexpanded
{
#
value
}}}
%
1496
\expandafter\let\csname
\??fontinstanceclass
\m_font_asked_body
-
\m_font_asked_style
-
#
one
#
two
-
#
rest
-
4
\endcsname
\undefined
1497
\unexpanded
\expandafter\normaledef\csname
\??fontinstanceready
\m_font_asked_body
-
\m_font_asked_style
-
#
one
#
two
-
#
rest
-
4
\endcsname
1498
{
\font_helpers_trigger
{
\m_font_asked_body
-
\m_font_asked_style
-
#
one
#
two
#
rest
}{
\noexpand
\font_rscale_xx
{
\m_font_asked_style
}}{
\m_font_asked_body
}{
\normalunexpanded
{
#
value
}}}
%
1499
\expandafter\let\csname
\??fontinstanceclass
\m_font_asked_body
-
\m_font_asked_style
-
#
one
#
two
-
#
rest
-
5
\endcsname
\undefined
1500
\unexpanded
\expandafter\normaledef\csname
\??fontinstanceready
\m_font_asked_body
-
\m_font_asked_style
-
#
one
#
two
-
#
rest
-
5
\endcsname
1501
{
\font_helpers_trigger
{
\m_font_asked_body
-
\m_font_asked_style
-
#
one
#
two
#
rest
}{
\noexpand
\font_rscale_xx
{
\m_font_asked_style
}}{
\m_font_asked_body
}{
\normalunexpanded
{
#
value
}}}
%
1502
}
1503 1504
\unexpanded
\def
\font_basics_define_body_font_yes_xx
[#
one
#
two
#
rest
=#
value
]
% global
1505
{
\ifcsname
\m_font_asked_style
#
one
#
two
#
rest
\endcsname\else
\font_basics_check_fontname_combination
\m_font_asked_style
{
#
one
#
two
}{
#
rest
}
\fi
1506
\expandafter
\glet
\csname
\??fontinstanceclass
\fontclass
-
\m_font_asked_body
-
\m_font_asked_style
-
#
one
#
two
-
#
rest
-
1
\endcsname
\undefined
1507
\unexpanded
\expandafter\normalxdef\csname
\??fontinstanceready
\fontclass
-
\m_font_asked_body
-
\m_font_asked_style
-
#
one
#
two
-
#
rest
-
0
\endcsname
1508
{
\font_helpers_trigger
{
\m_font_asked_body
-
\m_font_asked_style
-
#
one
#
two
#
rest
-
0
}{
\number
\p_font_rscale
}{
\m_font_asked_body
}{
\normalunexpanded
{
#
value
}}}
%
1509
\expandafter
\glet
\csname
\??fontinstanceclass
\fontclass
-
\m_font_asked_body
-
\m_font_asked_style
-
#
one
#
two
-
#
rest
-
2
\endcsname
\undefined
1510
\unexpanded
\expandafter\normalxdef\csname
\??fontinstanceready
\fontclass
-
\m_font_asked_body
-
\m_font_asked_style
-
#
one
#
two
-
#
rest
-
4
\endcsname
1511
{
\font_helpers_trigger
{
\m_font_asked_body
-
\m_font_asked_style
-
#
one
#
two
#
rest
-
4
}{
\number
\p_font_rscale
}{
\m_font_asked_body
}{
\normalunexpanded
{
#
value
}}}
%
1512
\expandafter
\glet
\csname
\??fontinstanceclass
\fontclass
-
\m_font_asked_body
-
\m_font_asked_style
-
#
one
#
two
-
#
rest
-
3
\endcsname
\undefined
1513
\unexpanded
\expandafter\normalxdef\csname
\??fontinstanceready
\fontclass
-
\m_font_asked_body
-
\m_font_asked_style
-
#
one
#
two
-
#
rest
-
5
\endcsname
1514
{
\font_helpers_trigger
{
\m_font_asked_body
-
\m_font_asked_style
-
#
one
#
two
#
rest
-
5
}{
\number
\p_font_rscale
}{
\m_font_asked_body
}{
\normalunexpanded
{
#
value
}}}
%
1515
}
1516 1517
% \writestatus{fonts}{define \m_asked_style\space yes: {\expandafter\meaning\csname\fontclass\m_font_asked_body\m_font_asked_style#one#two#rest\endcsname}
1518 1519
%D Here the rest concerns rl or lr so in this case it is not a size specifier but
1520
%D a directional one.
1521 1522
\unexpanded
\def
\font_basics_define_body_font_nop_mm
[#
one
#
two
#
rest
=#
value
]
% local
1523
{
%\ifcsname\s!mm\endcsname\else\font_basics_check_fontname_combination\s!mm{#one#two}{#rest}\fi
1524
\expandafter\let\csname
\??fontinstanceclass
\m_font_asked_body
-
\s!mm
-
#
one
#
two
#
rest
-
1
\endcsname
\undefined
1525
% \expandafter\let\csname\??fontinstanceclass\m_font_asked_body-\s!mm-#one#two#rest-2\endcsname\undefined
1526
% \expandafter\let\csname\??fontinstanceclass\m_font_asked_body-\s!mm-#one#two#rest-3\endcsname\undefined
1527
\unexpanded
\expandafter\normaledef\csname
\??fontinstanceready
\m_font_asked_body
-
\s!mm
-
#
one
#
two
#
rest
\endcsname
1528
{
\font_helpers_trigger
{
\m_font_asked_body
-
\s!mm
-
#
one
#
two
#
rest
}{
\noexpand
\font_rscale_mm
}{
\m_font_asked_body
}{
\normalunexpanded
{
#
value
}}}
%
1529
}
1530 1531
% \writestatus{fonts}{define \m_asked_style\space nop: \expandafter\meaning\csname\m_font_asked_body\m_font_asked_style#one#two#rest\endcsname}%
1532 1533
\unexpanded
\def
\font_basics_define_body_font_yes_mm
[#
one
#
two
#
rest
=#
value
]
% global
1534
{
%\ifcsname\s!mm\endcsname\else\font_basics_check_fontname_combination\s!mm{#one#two}{#rest}\fi
1535
\expandafter
\glet
\csname
\??fontinstanceclass
\fontclass
-
\m_font_asked_body
-
\s!mm
-
#
one
#
two
#
rest
-
1
\endcsname
\undefined
1536
% \expandafter\glet\csname\??fontinstanceclass\fontclass-\m_font_asked_body-\s!mm-#one#two#rest-2\endcsname\undefined
1537
% \expandafter\glet\csname\??fontinstanceclass\fontclass-\m_font_asked_body-\s!mm-#one#two#rest-3\endcsname\undefined
1538
\unexpanded
\expandafter\normalxdef\csname
\??fontinstanceready
\fontclass
-
\m_font_asked_body
-
\s!mm
-
#
one
#
two
#
rest
\endcsname
1539
{
\font_helpers_trigger
{
\m_font_asked_body
-
\s!mm
-
#
one
#
two
#
rest
}{
\number
\p_font_rscale
}{
\m_font_asked_body
}{
\normalunexpanded
{
#
value
}}}
%
1540
}
1541 1542
% \writestatus{fonts}{define \m_asked_style\space yes: \expandafter\meaning\csname\fontclass\m_font_asked_body\m_font_asked_style#one#two#rest\endcsname}%
1543 1544
\unexpanded
\def
\font_basics_define_body_font_body_identifier
[#
bodylist
][#
stylelist
][#
name
]
%
1545
{
\processcommalist
[#
bodylist
]
{
\font_basics_define_body_font_body_identifier_a
{
#
stylelist
}{
#
name
}}}
1546 1547
\unexpanded
\def
\font_basics_define_body_font_body_identifier_a
#
stylelist
#
name
#
body
%
1548
{
\normalizebodyfontsize
\m_font_asked_body
{
#
body
}
%
1549
\font_helpers_check_bodyfont_environment
\m_font_asked_body
\m_font_asked_body
% !!
1550
\processcommalist
[#
stylelist
]
{
\font_basics_define_body_font_body_identifier_b
{
#
name
}}}
1551 1552
\unexpanded
\def
\font_basics_define_body_font_body_identifier_b
#
name
#
style
%
1553
{
\edef
\m_font_asked_style
{
#
style
}
%
1554
%\writestatus\m!fonts{[\fontclass] [\m_font_asked_body] [\m_font_asked_style] => [#name]}%
1555
\csname
\??fontdefinitions
#
name
:
\m_font_asked_style
\endcsname
}
% no checking
1556 1557
\unexpanded
\def
\font_basics_define_body_font_name_assignment
[#
name
][#
stylelist
][#
assignments
]
%
1558
{
\processcommalist
[#
stylelist
]
{
\font_basics_define_body_font_name_assignment_a
{
#
name
}{
#
assignments
}}}
1559 1560
\unexpanded
\def
\font_basics_define_body_font_name_assignment_a
#
name
#
assignments
#
style
%
1561
{
%\writestatus\m!fonts{[#name:#style] => [#assignments]}%
1562
\setevalue
{
\??fontdefinitions
#
name
:
#
style
}{
\font_basics_define_body_font_default
{
#
assignments
}}}
1563 1564
\unexpanded
\def
\font_basics_define_body_font_name_identifier
[#
name
][#
stylelist
][#
identifier
]
%
1565
{
\processcommalist
[#
stylelist
]
{
\font_basics_define_body_font_name_identifier_a
{
#
name
}{
#
identifier
}}}
1566 1567
\unexpanded
\def
\font_basics_define_body_font_name_identifier_a
#
name
#
identifier
#
style
%
1568
{
%\writestatus\m!fonts{[#name:#style] => [##identifier:#style]}%
1569
\ifcsname
\??fontdefinitions
#
name
:
#
style
\endcsname
1570
\expandafter\let\csname
\??fontdefinitions
#
name
:
#
style
\expandafter\endcsname\csname
\??fontdefinitions
#
identifier
:
#
style
\endcsname
1571
\else
1572
\expandafter\def\csname
\??fontdefinitions
#
name
:
#
style
\endcsname
{
\csname
\??fontdefinitions
#
identifier
:
#
style
\endcsname
}
%
1573
\fi
}
1574 1575
%D The unknown:
1576 1577
\newconditional
\c_font_defining_unknown
1578
\newconditional
\c_font_defining_state
1579 1580
\unexpanded
\def
\font_helpers_define_unknown_font
#
body
% one level only
1581
{
\font_helpers_register_fontbody
{
#
body
}
% prevents loop, can go
1582
\setfalse
\c_font_defining_state
1583
\font_helpers_process_relative_size_list
{
\font_helpers_define_unknown_check_sizes
{
#
body
}}
%
1584
\ifconditional
\c_font_defining_state
1585
\setfalse
\c_font_defining_state
1586
\font_helpers_process_style_list
{
\font_helpers_define_unknown_check_definitions
{
#
body
}}
%
1587
\ifconditional
\c_font_defining_state
1588
\ifconditional
\c_font_defining_environment_state
\else
1589
%\showmessage\m!fonts{14}{#body}% main
1590
\clf_registerunknownbodysize
{
#
body
}
%
1591
\fi
1592
\setfalse
\c_font_defining_state
1593
\font_helpers_register_fontbody
{
#
body
}
%
1594
% needed ?
1595
\ifconditional
\c_font_defining_unknown
1596
\else
1597
\settrue
\c_font_defining_unknown
1598
\font_helpers_process_relative_size_list
{
\font_helpers_define_unknown_check_relatives
{
#
body
}}
%
1599
\setfalse
\c_font_defining_unknown
1600
\fi
1601
\fi
1602
\fi
}
1603 1604
\def
\font_helpers_define_unknown_check_sizes
#
body
#
relativesize
%
1605
{
\ifcsname
\??fontenvironments\s!default
#
relativesize
\endcsname
% fontclass ?
1606
\expandafter
\normalizebodyfontsize
\csname
\??fontenvironments
#
body
#
relativesize
\endcsname
{
\csname
\??fontenvironments\s!default
#
relativesize
\endcsname\dimexpr
#
body
\relax
}
%
1607
\settrue
\c_font_defining_state
1608
\fi
}
1609 1610
\def
\font_helpers_define_unknown_check_definitions
#
body
#
style
%
1611
{
\ifcsname
\??fontdefinitions\s!default
:
#
style
\endcsname
1612
\edef
\m_font_asked_body
{
#
body
}
%
1613
\edef
\m_font_asked_style
{
#
style
}
%
1614
\lastnamedcs
1615
\settrue
\c_font_defining_state
1616
\fi
}
1617 1618
% \def\font_helpers_define_unknown_check_relatives#body#relativesize%
1619
% {\ifcsname\??fontbodyknown\csname\??fontenvironments#body#relativesize\endcsname\endcsname \else
1620
% % how \lastnamedcs here
1621
% \expandafter\font_helpers_define_unknown_font\csname\??fontenvironments#body#relativesize\endcsname
1622
% \settrue\c_font_defining_state
1623
% \fi}
1624 1625
\def
\font_helpers_define_unknown_check_relatives
#
body
#
relativesize
%
1626
{
\ifcsname
\??fontbodyknown
\csname
\??fontenvironments
#
body
#
relativesize
\endcsname\endcsname
\else
1627
\expandafter
\font_helpers_define_unknown_font
\csname
\??fontenvironments
#
body
#
relativesize
\endcsname
1628
\settrue
\c_font_defining_state
1629
\fi
}
1630 1631
\unexpanded
\def
\font_basics_define_body_font_default
#
assignments
%
1632
{
\font_helpers_check_relative_font_size
\m_font_asked_style
% still needed here?
1633
\ifcsname
\m_font_asked_style
\endcsname\else
1634
\normalexpanded
{
\definefontstyle
[
\m_font_asked_style
][
\m_font_asked_style
]
}
%
1635
\fi
1636
\processcommalist
[#
assignments
]
\font_basics_define_body_font_defs
1637
\let
\p_font_rscale
\v_font_rscale_default
}
1638 1639
%D These macros show that quite some definitions take place. Fonts are not loaded
1640
%D yet! This means that at format generation time, no font files are present.
1641 1642
\unexpanded
\def
\font_basics_switch_points
#
body
%
1643
{
\ifcsname
\??fontbodyknown
#
body
\endcsname
\else
1644
% we need to check the relative sizes for this body
1645
\font_helpers_define_unknown_font
{
#
body
}
%
1646
\fi
%
1647
\ifcsname
\??fontbodyknown
#
body
\endcsname
% always true now
1648
\font_basics_complete_switch
{
#
body
}
%
1649
\localbodyfontsize
#
body
\relax
1650
\normalizebodyfontsize
\normalizedbodyfontsize
\localbodyfontsize
1651
\font_helpers_check_bodyfont_environment
\normalizedbodyfontsize
\normalizedbodyfontsize
% !!
1652
\else
1653
\showmessage
\m!fonts
4
{
#
body
}
%
1654
\fi
}
1655 1656
\unexpanded
\def
\font_basics_switch_style
#
style
%
1657
{
\ifcsname
\??fontstyle
#
style
\endcsname
1658
\lastnamedcs
1659
\edef
\fontstyle
{
#
style
}
%
1660
\ifmmode
\mr
\fi
% in order to be compatible with \rm in math mode
1661
% \the\everybodyfont % cleaner, in setting size as well as style
1662
\else
1663
\showmessage
\m!fonts
5
{
#
style
}
%
1664
\fi
}
1665 1666
%D Here comes the main font switching macros. These macros handle changes in size as
1667
%D well as returning to the global bodyfont size.
1668 1669
\ifdefined
\font_preloads_at_definition
\else
\let
\font_preloads_at_definition
\relax
\fi
1670 1671
\def
\font_helpers_set_font
#
method
#
specification
%
1672
{
\edef
\m_font_specification
{
#
specification
}
%
1673
\ifempty
\m_font_specification
\else
1674
\ifx
\m_font_specification
\v!global
% we can have all kind of presets
1675
\restoreglobalbodyfont
1676
\else
1677
\processcommacommand
[
\m_font_specification
]
{
\font_helpers_set_font_check_size
}
%
1678
\processcommacommand
[
\m_font_specification
]
{
\font_helpers_set_font_set_font
{
#
method
}}
%
1679
\ifproductionrun
1680
\font_preloads_at_definition
1681
\font_basics_switch_points
\normalizedbodyfontsize
1682
\font_basics_switch_style
\fontstyle
1683
\ifempty
\defaultfontclass
1684
\let
\defaultfontclass
\fontclass
1685
\fi
1686
\fi
1687
\fi
1688
\currentxfontsize
\zerocount
1689
\fi
}
1690 1691
\def
\font_helpers_set_font_check_size
#
option
%
1692
{
\doifelsenumber
{
#
option
}{
\font_helpers_check_bodyfont_environment
{
#
option
}{
#
option
}}
\donothing
}
1693 1694
\def
\font_helpers_set_font_set_font
#
method
#
option
% method=1: set, method=2: switch
1695
{
\doifsomething
{
#
option
}{
\font_helpers_set_font_set_font_option
{
#
method
}{
#
option
}}}
1696 1697
\def
\font_helpers_set_font_set_font_option
#
method
#
option
%
1698
{
\doifelsenumber
{
#
option
}
%
1699
\font_helpers_set_font_set_font_option_body
1700
\font_helpers_set_font_set_font_option_keyword
1701
{
#
method
}{
#
option
}{
#
option
}}
1702 1703
\newmacro
\m_font_keyword
1704 1705
\unexpanded
\def
\font_helpers_set_font_set_font_option_keyword
#
method
#
keyword
#
message
%
1706
{
\edef
\m_font_keyword
{
#
keyword
}
%
1707
\ifcsname
\??fontenvironments
\normalizedbodyfontsize
\m_font_keyword
\endcsname
1708
\edef
\m_font_step
{
\font_bodyfontvariable
\m_font_keyword
}
%
1709
\normalexpanded
{
\font_helpers_set_font_set_font_option_body
{
#
method
}{
\m_font_step
}{
#
message
}}
%
1710
\orelse\ifx
\m_font_keyword
\v!reset
1711
\let
\fontstyle
\empty
% new 31/7/2006
1712
\let
\fontsize
\empty
1713
\orelse\ifcsname
\??fontstyle
\m_font_keyword
\endcsname
1714
\let
\fontstyle
\m_font_keyword
1715
\else
1716
\setcurrentfontclass
\m_font_keyword
1717
\ifcase
#
method
\relax
1718
\let
\globalfontclass
\globalfontclass
% -)
1719
\else
1720
\let
\globalfontclass
\fontclass
1721
\fi
1722
\font_helpers_set_fontstyle_of_fontclass
1723
\fi
}
1724 1725
\def
\font_helpers_set_fontstyle_of_fontclass
% will be overloaded later
1726
{
\let
\fontstyle
\s!rm
}
1727 1728
\unexpanded
\def
\font_helpers_set_font_set_font_option_body
#
method
#
body
#
message
%
1729
{
\normalizebodyfontsize
\normalizedsetfont
{
#
body
}
% redundant for some calls
1730
\ifcsname
\??fontbodyknown
\normalizedsetfont
\endcsname
\else
1731
\font_helpers_define_unknown_font
\normalizedsetfont
1732
\fi
1733
\ifcsname
\??fontbodyknown
\normalizedsetfont
\endcsname
1734
\localbodyfontsize
\normalizedsetfont
1735
\let
\normalizedbodyfontsize
\normalizedsetfont
1736
\else
1737
\showmessage
\m!fonts
4
{
#
message
}
%
1738
%\font_helpers_set_font_set_font_option_body_fallbacks{#method}{#body}%
1739
\fi
}
1740 1741
% we need to check the fontclass
1742 1743
\def
\registerfontclass
#
class
%
1744
{
\letgvalue
{
\??fontclassyes
#
class
}
\v!yes
}
% global ?
1745 1746
\def
\setcurrentfontclass
#
class
%
1747
{
\ifcsname
\??fontclassyes
#
class
\endcsname
1748
\edef
\fontclass
{
#
class
}
%
1749
\orelse\ifcsname
\??fontclassnop
#
class
\endcsname
1750
% already tried
1751
\else
% too messy: \ifcase\currentgrouplevel % (unpredictable)
1752
\trycurrentfontclass
{
#
class
}
%
1753
\fi
}
1754 1755
\ifdefined
\trycurrentfontclass
\else
1756 1757
\unexpanded
\def
\trycurrentfontclass
#
typeface
%
1758
{
\letvalueempty
{
\??fontclassnop
#
typeface
}}
1759 1760
\fi
1761 1762
\let
\defaultfontstyle
\s!rm
1763
\let
\defaultfontalternative
\s!tf
1764
\let
\defaultfontsize
\empty
1765
\let
\defaultfontface
\!!zerocount
1766 1767
%D So far for synchronisation. (We can inline the following macros.)
1768 1769
\unexpanded
\def
\setcurrentfont
#
body
#
style
#
alternative
#
size
% not used
1770
{
\edef
\fontbody
{
#
body
}
%
1771
\edef
\fontstyle
{
#
style
}
%
1772
\edef
\fontalternative
{
#
alternative
}
%
1773
\edef
\fontsize
{
#
size
}
%
1774
\font_helpers_check_big_math_synchronization
1775
\font_helpers_synchronize_font
}
1776 1777
\unexpanded
\def
\setcurrentfontbody
#
body
% % not used
1778
{
\edef
\fontbody
{
#
body
}
%
1779
\font_helpers_synchronize_font
}
1780 1781
% For Taco: optional fall backs:
1782 1783
\ifdefined
\font_typescripts_inherit_check
\else
1784
\let
\font_typescripts_inherit_check
\gobbleoneargument
% implemented in type-ini
1785
\fi
1786 1787
\unexpanded
\def
\font_helpers_set_current_font_style
#
style
%
1788
{
\edef
\fontstyle
{
#
style
}
%
1789
\font_typescripts_inherit_check
\fontstyle
1790
\ifmmode
\mr
\fi
% otherwise \rm not downward compatible ... not adapted yet
1791
\font_helpers_synchronize_font
}
1792 1793
\unexpanded
\def
\font_helpers_set_current_xsize_alternative
#
xsize
#
alternative
%
1794
{
\edef
\fontface
{
#
xsize
}
%
1795
\edef
\fontalternative
{
#
alternative
}
%
1796
\font_helpers_synchronize_font
}
1797 1798
\unexpanded
\def
\font_helpers_set_current_font_alternative
#
alternative
%
1799
{
\edef
\fontalternative
{
#
alternative
}
%
1800
\font_helpers_synchronize_font
}
1801 1802
\unexpanded
\def
\font_helpers_set_current_font_size
#
size
%
1803
{
\edef
\fontsize
{
#
size
}
%
1804
\font_helpers_check_big_math_synchronization
% double? better in everymath?
1805
\font_helpers_synchronize_font
}
1806 1807
\unexpanded
\def
\font_helpers_set_current_font_style_alternative
#
style
#
alternative
% \rmsl
1808
{
\edef
\fontstyle
{
#
style
}
%
1809
\edef
\fontalternative
{
#
alternative
}
%
1810
\font_helpers_synchronize_font
}
1811 1812
\unexpanded
\def
\font_helpers_set_current_font_style_size
#
style
#
size
% \rma
1813
{
\edef
\fontstyle
{
#
style
}
%
1814
\edef
\fontsize
{
#
size
}
%
1815
\font_helpers_check_big_math_synchronization
% double? better in everymath?
1816
\font_helpers_synchronize_font
}
1817 1818
\unexpanded
\def
\font_helpers_set_current_font_alternative_size
#
alternative
#
size
% \sla
1819
{
\edef
\fontalternative
{
#
alternative
}
%
1820
\edef
\fontsize
{
#
size
}
%
1821
\font_helpers_check_big_math_synchronization
% double? better in everymath?
1822
\font_helpers_synchronize_font
}
1823 1824
\unexpanded
\def
\font_helpers_set_current_font_style_alternative_size
#
style
#
alternative
#
size
% \rmsla
1825
{
\edef
\fontstyle
{
#
style
}
%
1826
\edef
\fontalternative
{
#
alternative
}
%
1827
\edef
\fontsize
{
#
size
}
%
1828
\font_helpers_check_big_math_synchronization
% double? better in everymath?
1829
\font_helpers_synchronize_font
}
1830 1831
\unexpanded
\def
\font_helpers_synchronize_font
% we can have dups i.e. no need to let fontstrategy
1832
{
\ifempty
\fontclass
1833
\applyfontstrategies
1834
\else
1835
\applyfontclassstrategies
1836
\fi
1837
\setfalse
\c_font_auto_size
1838
\ifskipfontcharacteristics
1839
\setfontcharacteristics
1840
\the
\everyfontswitch
1841
\fi
}
1842 1843
%D This is the resolver for special cases (sizes) and in practice it is not called
1844
%D that often so further optimization makes no sense.
1845 1846
\def
\font_helpers_check_strategy_class_a
% --- --- --- --- % pt tt bf a
1847
{
\ifcsname
\??fontinstanceready
\fontclass
-
\fontbody
-
\fontstyle
-
\fontalternative
-
\fontsize
-
\fontface
\endcsname
1848
\setfalse
\c_font_auto_size
1849
\lastnamedcs
1850
\else
1851
\expandafter
\font_helpers_check_strategy_class_b
1852
\fi
}
1853 1854
\def
\font_helpers_check_strategy_class_b
% --- --- --- def % pt tt bf
1855
{
\ifcsname
\??fontinstanceready
\fontclass
-
\fontbody
-
\fontstyle
-
\fontalternative
-
\defaultfontsize
-
\fontface
\endcsname
1856
\settrue
\c_font_auto_size
1857
\lastnamedcs
1858
\else
1859
\expandafter
\font_helpers_check_strategy_class_c
1860
\fi
}
1861 1862
\def
\font_helpers_check_strategy_class_c
% --- --- def --- % pt tt tf a
1863
{
\ifcsname
\??fontinstanceready
\fontclass
-
\fontbody
-
\fontstyle
-
\defaultfontalternative
-
\fontsize
-
\fontface
\endcsname
1864
\settrue
\c_font_auto_size
1865
\lastnamedcs
1866
\else
1867
\expandafter
\font_helpers_check_strategy_class_d
1868
\fi
}
1869 1870
\def
\font_helpers_check_strategy_class_d
% --- --- def def % pt tt tf
1871
{
\ifcsname
\??fontinstanceready
\fontclass
-
\fontbody
-
\fontstyle
-
\defaultfontalternative
-
\defaultfontsize
-
\fontface
\endcsname
1872
\settrue
\c_font_auto_size
1873
\lastnamedcs
1874
\else
1875
\expandafter
\font_helpers_check_strategy_class_e
1876
\fi
}
1877 1878
\def
\font_helpers_check_strategy_class_e
% --- def def def % pt rm tf
1879
{
\ifcsname
\??fontinstanceready
\fontclass
-
\fontbody
-
\defaultfontstyle
-
\defaultfontalternative
-
\defaultfontsize
-
\fontface
\endcsname
1880
\setfalse
\c_font_auto_size
1881
\lastnamedcs
1882
\else
1883
\expandafter
\font_helpers_check_strategy_class_f
1884
\fi
}
1885 1886
\def
\font_helpers_check_strategy_class_f
% def def def def % rm tf
1887
{
\ifcsname
\??fontinstanceready
\fontclass
-
\defaultfontbody
-
\defaultfontstyle
-
\defaultfontalternative
-
\defaultfontsize
-
\fontface
\endcsname
1888
\settrue
\c_font_auto_size
1889
\lastnamedcs
1890
\else
1891
\expandafter
\font_helpers_check_strategy_a
1892
\fi
}
1893 1894
% no class
1895 1896
\def
\font_helpers_check_strategy_a
% --- --- --- --- % pt tt bf a
1897
{
\ifcsname
\??fontinstanceready
\fontbody
-
\fontstyle
-
\fontalternative
-
\fontsize
-
\fontface
\endcsname
1898
\setfalse
\c_font_auto_size
1899
\lastnamedcs
1900
\else
1901
\expandafter
\font_helpers_check_strategy_b
1902
\fi
}
1903 1904
\def
\font_helpers_check_strategy_b
% --- --- --- --- % pt tt bf a
1905
{
\ifcsname
\??fontinstanceready
\fontbody
-
\fontstyle
-
\fontalternative
-
\defaultfontsize
-
\fontface
\endcsname
1906
\settrue
\c_font_auto_size
1907
\lastnamedcs
1908
\else
1909
\expandafter
\font_helpers_check_strategy_c
1910
\fi
}
1911 1912
\def
\font_helpers_check_strategy_c
% --- --- --- --- % pt tt bf a
1913
{
\ifcsname
\??fontinstanceready
\fontbody
-
\fontstyle
-
\defaultfontalternative
-
\fontsize
-
\fontface
\endcsname
1914
\settrue
\c_font_auto_size
1915
\lastnamedcs
1916
\else
1917
\expandafter
\font_helpers_check_strategy_d
1918
\fi
}
1919 1920
\def
\font_helpers_check_strategy_d
% --- --- --- --- % pt tt bf a
1921
{
\ifcsname
\??fontinstanceready
\fontbody
-
\fontstyle
-
\defaultfontalternative
-
\defaultfontsize
-
\fontface
\endcsname
1922
\settrue
\c_font_auto_size
1923
\lastnamedcs
1924
\else
1925
\expandafter
\font_helpers_check_strategy_e
1926
\fi
}
1927 1928
\def
\font_helpers_check_strategy_e
% --- --- --- --- % pt tt bf a
1929
{
\ifcsname
\??fontinstanceready
\fontbody
-
\defaultfontstyle
-
\defaultfontalternative
-
\defaultfontsize
-
\fontface
\endcsname
1930
\setfalse
\c_font_auto_size
1931
\lastnamedcs
1932
\else
1933
\expandafter
\font_helpers_check_strategy_f
1934
\fi
}
1935 1936
\def
\font_helpers_check_strategy_f
% --- --- --- --- % pt tt bf a
1937
{
\ifcsname
\??fontinstanceready
\defaultfontbody
-
\defaultfontstyle
-
\defaultfontalternative
-
\defaultfontsize
-
\fontface
\endcsname
1938
\settrue
\c_font_auto_size
1939
\lastnamedcs
1940
\fi
}
1941 1942
\let
\applyfontstrategies
\font_helpers_check_strategy_a
1943
\let
\applyfontclassstrategies
\font_helpers_check_strategy_class_a
1944 1945
%D Let's synchronize:
1946 1947
\newconditional
\c_font_synchronize
\settrue
\c_font_synchronize
1948 1949
\prependtoks
1950
\ifconditional
\c_font_synchronize
1951
\font_helpers_synchronize_math
1952
\font_helpers_synchronize_font
% problem: syncs last font
1953
\fi
1954
\to
\everybodyfont
1955 1956
%D Setting the normal sizes as well as the x and xx smaller sizes is accomplished by
1957
%D the next set of macros. When in math mode, the commands \type {\tx} and \type
1958
%D {\txx} are just a switch to the script and double script styles, but in text mode
1959
%D the values defined by the bodyfontenvironment are used. Here we also set \type
1960
%D {\currentxfontsize}.
1961 1962
\def
\font_helpers_set_current_font_xxx_alternative
#
alternative
#
xsize
#
scriptstyle
%
1963
{
\ifmmode
1964
#
scriptstyle
%
1965
\else
1966
\font_helpers_set_current_xsize_alternative
{
#
xsize
}{
#
alternative
}
%
1967
\fi
}
1968 1969
\def
\font_helpers_reset_x_fontsize
1970
{
\ifcase
\currentxfontsize
\else
1971
\currentxfontsize
\zerocount
1972
% also \sx and \sxx ?
1973
\let
\tx
\normaltx
1974
\let
\txx
\normaltxx
1975
\fi
}
1976 1977
\let
\font_helpers_check_nested_x_fontsize
\relax
1978 1979
\def
\font_helpers_set_current_font_x_alternative
#
alternative
%
1980
{
\font_helpers_check_nested_x_fontsize
1981
\font_helpers_set_current_font_xxx_alternative
{
#
alternative
}{
4
}
\scriptstyle
1982
\currentxfontsize
\plusone
1983
\let
\tx\txx
}
1984 1985
\def
\font_helpers_set_current_font_xx_alternative
#
alternative
%
1986
{
\font_helpers_check_nested_x_fontsize
1987
\font_helpers_set_current_font_xxx_alternative
{
#
alternative
}{
5
}
\scriptscriptstyle
1988
\currentxfontsize
\plustwo
1989
\let
\tx
\empty
1990
\let
\txx
\empty
}
1991 1992
%D This alterative is not really needed, but for old time's sake we keep it there.
1993
%D We can speed it up when needed.
1994 1995
\def
\font_helpers_set_current_font_x_style_alternative
#
alternative
{
\csname
#
alternative
\endcsname
\tx
}
1996
\def
\font_helpers_set_current_font_xx_style_alternative
#
alternative
{
\csname
#
alternative
\endcsname
\txx
}
1997 1998
%D These macros also show us that when we call for \type {\tx}, this macro is
1999
%D redefined to be \type {\txx}. Therefore calls like:
2000
%D
2001
%D \startbuffer
2002
%D {small \tx is \tx beautiful}
2003
%D {small \tx is \txx beautiful}
2004
%D {small \txx is \tx beautiful}
2005
%D {small \txx is \txx beautiful}
2006
%D \stopbuffer
2007
%D
2008
%D \typebuffer
2009
%D
2010
%D result in:
2011
%D
2012
%D \startlines
2013
%D \getbuffer
2014
%D \stoplines
2015
%D
2016
%D Setting the main size involves the style list and therefore takes a bit more
2017
%D time. Keep in mind that the fontsize is represented by a character or empty.
2018 2019
\installcorenamespace
{
fontscalex
}
2020
\installcorenamespace
{
fontscalexx
}
2021 2022
\newconditional
\c_font_inherit_scale
2023 2024
\def
\font_scale_inherit
#
1
%
2025
{
\begingroup
2026
\scratchcounterone
\fontid\font\relax
2027
\currentxfontsize
\plusone
2028
\normalexpanded
{
\definedfont
[
\clf_specifiedfont
\scratchcounterone
\font_currentfontscale
\relax
]
}
%
2029
\scratchcountertwo
\fontid\font\relax
2030
\currentxfontsize
\plustwo
2031
\normalexpanded
{
\definedfont
[
\clf_specifiedfont
\scratchcounterone
\font_currentfontscale
\relax
]
}
%
2032
\scratchcounterthree
\fontid\font\relax
2033
% parent -> x -> xx
2034
% parent -> xx
2035
\global\expandafter\chardef\csname
\??fontscalex
\number
\scratchcounterone
\endcsname
\scratchcountertwo
2036
\global\expandafter\chardef\csname
\??fontscalexx
\number
\scratchcounterone
\endcsname
\scratchcounterthree
2037
\global\expandafter\chardef\csname
\??fontscalex
\number
\scratchcountertwo
\endcsname
\scratchcounterthree
2038
\global\expandafter\chardef\csname
\??fontscalexx
\number
\scratchcountertwo
\endcsname
\scratchcounterthree
2039
\endgroup
2040
\setfontid\csname
#
1
\number\fontid\font\endcsname
}
2041 2042
\def
\font_scale_inherit_x
2043
{
\ifcsname
\??fontscalex
\number\fontid\font\endcsname
2044
\setfontid\lastnamedcs
2045
\else
2046
\font_scale_inherit
\??fontscalex
2047
\fi
2048
\ifskipfontcharacteristics
2049
\setfontcharacteristics
2050
\the
\everyfontswitch
2051
\fi
}
2052 2053
\def
\font_scale_inherit_xx
2054
{
\ifcsname
\??fontscalexx
\number\fontid\font\endcsname
2055
\setfontid\lastnamedcs
2056
\else
2057
\font_scale_inherit
\??fontscalexx
2058
\fi
2059
\ifskipfontcharacteristics
2060
\setfontcharacteristics
2061
\the
\everyfontswitch
2062
\fi
}
2063 2064
\def
\font_scale_defined_x
2065
{
\let
\fontface
\!!plusfour
2066
\let
\fontalternative\fontalternative
2067
\font_helpers_synchronize_font
}
2068 2069
\def
\font_scale_defined_xx
2070
{
\let
\fontface
\!!plusfive
2071
\let
\fontalternative\fontalternative
2072
\font_helpers_synchronize_font
}
2073 2074
\unexpanded
\def
\tx
2075
{
\currentxfontsize
\plusone
2076
\ifmmode
2077
\scriptstyle
2078
\else
\ifconditional
\c_font_inherit_scale
2079
\font_scale_inherit_x
2080
\else
2081
\font_scale_defined_x
2082
\fi\fi
2083
\let
\tx\txx
}
2084 2085
\unexpanded
\def
\txx
2086
{
\currentxfontsize
\plustwo
2087
\ifmmode
2088
\scriptscriptstyle
2089
\else
\ifconditional
\c_font_inherit_scale
2090
\font_scale_inherit_xx
2091
\else
2092
\font_scale_defined_xx
2093
\fi\fi
2094
\let
\tx
\empty
2095
\let
\txx
\empty
}
2096 2097
\unexpanded
\def
\sx
2098
{
\currentxfontsize
\plusone
2099
\ifmmode
2100
\scriptstyle
2101
\else
2102
\font_scale_inherit_x
2103
\fi
2104
\let
\tx\txx
2105
\let
\sx
\sxx
}
2106 2107
\unexpanded
\def
\sxx
2108
{
\currentxfontsize
\plustwo
2109
\ifmmode
2110
\scriptscriptstyle
2111
\else
2112
\font_scale_inherit_xx
2113
\fi
2114
\let
\tx
\empty
2115
\let
\txx
\empty
2116
\let
\sx
\empty
2117
\let
\sxx
\empty
}
2118 2119
\unexpanded
\def
\useinheritxsizes
{
\settrue
\c_font_inherit_scale
}
% not yet public, playground for WS and me
2120
\unexpanded
\def
\usedefinedxsizes
{
\setfalse
\c_font_inherit_scale
}
% not yet public, playground for WS and me
2121 2122
\let
\normaltx
\tx
2123
\let
\normaltxx
\txx
2124 2125
\let
\normalsx
\sx
2126
\let
\normalsxx
\sxx
2127 2128
%D When asking for a complete font switch, for instance from 10 to 12~points, the
2129
%D next macro does the job. First we normalize the size, next we define the current
2130
%D range of text, script and scriptscript sizes, then we set the text fonts and the
2131
%D math families and finally we activate the default typeface and also set the font
2132
%D specific parameters assigned to \type {\everybodyfont}.
2133 2134
\def
\textface
{
\currentbodyfontdimension
\s!text
}
2135
\def
\scriptface
{
\currentbodyfontdimension
\s!script
}
2136
\def
\scriptscriptface
{
\currentbodyfontdimension
\s!scriptscript
}
2137
\def
\xtextface
{
\currentbodyfontdimension
\s!x
}
2138
\def
\xxtextface
{
\currentbodyfontdimension
\s!xx
}
2139 2140
\installcorenamespace
{
fontbodyfaces
}
2141 2142
\unexpanded
\def
\font_basics_complete_switch
#
size
%
2143
{
\bodyfontsize
#
size
\relax
2144
\normalizebodyfontsize
\normalizedbodyfontsize
\bodyfontsize
2145
\expandafter\let\expandafter
\font_basics_set_faces
\csname
\??fontbodyfaces
\fontbody
\endcsname
2146
\ifx
\font_basics_set_faces
\relax
2147
\font_basics_set_faces_preset
2148
\fi
2149
\font_basics_set_faces
}
2150 2151
\def
\font_basics_set_faces_preset
2152
{
\edef
\font_basics_set_faces
{
% 0.2 sec on 10K \tfa
2153
\noexpand\edef\noexpand
\textface
{
\currentbodyfontdimension
\s!text
}
%
2154
\noexpand\edef\noexpand
\scriptface
{
\currentbodyfontdimension
\s!script
}
%
2155
\noexpand\edef\noexpand
\scriptscriptface
{
\currentbodyfontdimension
\s!scriptscript
}
%
2156
\noexpand\edef\noexpand
\xtextface
{
\currentbodyfontdimension
\s!x
}
%
2157
\noexpand\edef\noexpand
\xxtextface
{
\currentbodyfontdimension
\s!xx
}
%
2158
}
%
2159
\expandafter
\glet
\csname
\??fontbodyfaces
\fontbody
\endcsname
\font_basics_set_faces
}
2160 2161
\def
\currentbodyfontdimension
#
parameter
% there can be factors here
2162
{
\the\dimexpr
2163
\ifcsname
\??fontenvironments
\fontclass
\normalizedbodyfontsize
#
parameter
\endcsname
2164
\lastnamedcs
2165
\orelse\ifcsname
\??fontenvironments
\fontclass
\s!default
#
parameter
\endcsname
2166
\lastnamedcs
2167
\dimexpr
\normalizedbodyfontsize
\relax
2168
\orelse\ifcsname
\??fontenvironments
\normalizedbodyfontsize
#
parameter
\endcsname
2169
\lastnamedcs
2170
\else
2171
\csname
\??fontenvironments\s!default
#
parameter
\endcsname
2172
\dimexpr
\normalizedbodyfontsize
\relax
2173
\fi
2174
\relax
}
2175 2176
%D \macros
2177
%D {setupbodyfont,switchtobodyfont}
2178
%D
2179
%D The next two macros are user ones. With \type {\setupbodyfont} one can set the
2180
%D document bodyfont size, font family, style and/or options defined in files, for
2181
%D example:
2182
%D
2183
%D \starttyping
2184
%D \setupbodyfont[modern,12pt,roman]
2185
%D \stoptyping
2186
%D
2187
%D This command affects the document as a whole: text, headers and footers. The
2188
%D second macro however affects only the text:
2189
%D
2190
%D \starttyping
2191
%D \switchtobodyfont[10pt]
2192
%D \stoptyping
2193
%D
2194
%D So we've got:
2195
%D
2196
%D \showsetup{setupbodyfont}
2197
%D \showsetup{switchtobodyfont}
2198
%D
2199
%D Both macros look alike. The second one also has to take all kind of keywords into
2200
%D account.
2201 2202
\ifx
\saveinterlinespace
\undefined
\let
\saveinterlinespace
\relax
\fi
2203
\ifx
\restoreinterlinespace
\undefined
\let
\restoreinterlinespace
\relax
\fi
2204 2205
% \newtoks \everysetupbodyfont
2206
% \newtoks \everyswitchtobodyfont
2207 2208
\unexpanded
\def
\setupbodyfont
2209
{
\doifelsenextoptionalcs
\font_basics_setupbodyfont_yes
\font_basics_setupbodyfont_nop
}
2210 2211
\def
\font_basics_setupbodyfont_nop
2212
{
\restoreglobalbodyfont
2213
\saveinterlinespace
}
2214 2215
\def
\font_basics_setupbodyfont_yes
[#
specification
]
%
2216
{
\doifsomething
{
#
specification
}
2217
{
\font_helpers_set_font
\plusone
{
#
specification
}
%
2218
\globalbodyfontsize
\localbodyfontsize
2219
\normalizebodyfontsize
\normalizedglobalbodyfontsize
\globalbodyfontsize
2220
\let
\globalfontstyle
\fontstyle
2221
\ifproductionrun
2222
\the
\everybodyfont
2223
\the
\everyglobalbodyfont
2224
\saveinterlinespace
2225
\fi
2226
\the
\everysetupbodyfont
}}
2227 2228
\unexpanded
\def
\font_basics_switchtobodyfont
#
specification
%
2229
{
\edef
\m_font_step
{
\font_bodyfontvariable
{
#
specification
}}
%
2230
\ifempty
\m_font_step
2231
\font_helpers_set_font
\zerocount
{
#
specification
}
%
2232
\else
2233
\font_helpers_switch_bodyfont_step
% so we have a fast [small] switch
2234
\fi
2235
\the
\everybodyfont
2236
\the
\everyswitchtobodyfont
}
2237 2238
\unexpanded
\def
\switchtobodyfont
[#
specification
]
% could become an ifx
2239
{
\doifsomething
{
#
specification
}{
\font_basics_switchtobodyfont
{
#
specification
}}}
2240 2241
\unexpanded
\def
\usebodyfontparameter
#
1
%
2242
{
\edef
\m_font_bodyfont_asked
{
#
1
\c!bodyfont
}
%
2243
\ifempty
\m_font_bodyfont_asked
\else
2244
\font_basics_switchtobodyfont
\m_font_bodyfont_asked
2245
\fi
}
2246 2247
\def
\font_helpers_switch_bodyfont_step
2248
{
\font_basics_switch_points
\m_font_step
2249
\font_basics_switch_style
\fontstyle
}
2250 2251
%D The following alternative is meant for math||to||text switching and will be
2252
%D optimized.
2253 2254
\unexpanded
\def
\fastswitchtobodyfont
#
name
%
2255
{
\ifcsname
\??fontenvironments
\normalizedbodyfontsize
#
name
\endcsname
2256
%\edef\futurebodyfontsize{\csname\??fontenvironments\normalizedbodyfontsize#name\endcsname}%
2257
\edef
\futurebodyfontsize
{
\lastnamedcs
}
%
2258
\ifcsname
\??fontbodyknown
\futurebodyfontsize
\endcsname
2259
\font_basics_complete_switch
\futurebodyfontsize
2260
\localbodyfontsize
\futurebodyfontsize
\relax
2261
\fi
2262
\fi
2263
\csname
\??fontstyle
\fontstyle
\endcsname
2264
\the
\everybodyfont
}
2265 2266
%D \starttyping
2267
%D $\cases{& \ccaron}$ $x=\hbox{\ccaron $x=\hbox{\ccaron}$}$
2268
%D \stoptyping
2269 2270
%D \macros
2271
%D {usebodyfont}
2272
%D
2273
%D This looks nicer then a switch in the preamble
2274
%D
2275
%D \starttyping
2276
%D \usebodyfont[pagella,10pt]
2277
%D \usebodyfont[termes,10pt]
2278
%D \usebodyfont[dejavu,10pt]
2279
%D
2280
%D \setupbodyfont[dejavu]
2281
%D
2282
%D \starttext
2283
%D test
2284
%D \stoptext
2285
%D \stoptyping
2286 2287
\unexpanded
\def
\usebodyfont
[#
1
]
%
2288
{
\ifempty
\fontclass
2289
\setupbodyfont
[#
1
]
%
2290
\else
2291
\switchtobodyfont
[#
1
]
%
2292
\fullrestoreglobalbodyfont
2293
\fi
}
2294 2295
\unexpanded
\def
\showbodyfontstate
2296
{
\dontleavehmode
2297
\start
2298
\infofont
2299
[
fontclass
:
\fontclass
,
\space
2300
fontbody
:
\fontbody
,
\space
2301
fontface
:
\fontface
,
\space
2302
fontsize
:
\fontsize
]
%
2303
\stop
}
2304 2305
%D Handy for manuals:
2306 2307
%D The \type {\tochar} commmand takes a specification:
2308
%D
2309
%D \starttabulate[|l|l|l|]
2310
%D \NC e \NC entity \NC e:eacute \NC \NR
2311
%D \NC x \NC hexadecimal unicode \NC x:013D \NC \NR
2312
%D \NC d \NC decimal unicode \NC d:123 \NC \NR
2313
%D \NC s \NC hexadecimal index (slot) \NC s:210D \NC \NR
2314
%D \NC i \NC decimal index \NC i:456 \NC \NR
2315
%D \NC n \NC name \NC n:eight \NC \NR
2316
%D \NC c \NC name \NC c:x \NC \NR
2317
%D \NC u \NC unicode descriptions \NC u:dog \NC \NR
2318
%D \NC a \NC all (also descriptions) \NC a:rewind \NC \NR
2319
%D \stoptabulate
2320
%D
2321
%D This is an expandable command!
2322 2323
\unexpanded
\def
\fontchar
#
character
{
\clf_fontchar
{
#
character
}}
2324
\unexpanded
\def
\fontcharbyindex
#
index
{
\clf_fontcharbyindex
#
index
\relax
}
2325
\def
\tochar
#
specifications
{
\clf_tochar
{
#
specifications
}}
% expanded (also used in edef)
2326 2327
%D The next auxilliary macro is an alternative to \type {\fontname}.
2328 2329
\def
\purefontname
#
font
{
\clf_purefontname
{
\fontname
#
font
}}
2330 2331
%D \macros
2332
%D {switchstyleonly}
2333
%D
2334
%D For switching a style but keeping the alternative, there
2335
%D is:
2336
%D
2337
%D \starttyping
2338
%D {\bf text \switchstyleonly\ss text}
2339
%D {\bf text \switchstyleonly[ss]text}
2340
%D {\sl text \switchstyleonly[sansserif]text}
2341
%D \stoptyping
2342 2343
\unexpanded
\def
\switchstyleonly
2344
{
\doifelsenextoptionalcs
\font_basics_switch_style_only_opt
\font_basics_switch_style_only_arg
}
2345 2346
\def
\font_basics_switch_style_only_arg
#
name
% stupid version
2347
{
\font_helpers_set_current_font_style
{
\csname
\??fontshortstyle
\checkedstrippedcsname
#
name
\endcsname
}
%
2348
\the
\everybodyfont
}
% needed ?
2349 2350
\def
\font_basics_switch_style_only_opt
[#
name
]
% todo : check
2351
{
\font_helpers_set_current_font_style
{
\csname
\??fontshortstyle
#
name
\endcsname
}
%
2352
\the
\everybodyfont
}
% needed ?
2353 2354
%D \macros
2355
%D {definebodyfontswitch}
2356
%D
2357
%D \PLAIN\ \TEX\ defines some macro's like \type {\tenpoint} to switch to a specific
2358
%D bodyfontsize. Just for the sake of compatibility we can define them like:
2359
%D
2360
%D \starttyping
2361
%D \definebodyfontswitch [twelvepoint] [12pt]
2362
%D \stoptyping
2363
%D
2364
%D We don't support language specific synonyms here.
2365 2366
\unexpanded
\def
\definebodyfontswitch
2367
{
\dodoubleargument
\font_basics_define_bodyfont_switch
}
2368 2369
\def
\font_basics_define_bodyfont_switch
[#
command
][#
specification
]
% no longer a commalist (not useful)
2370
{
\setvalue
{
#
command
}{
\switchtobodyfont
[#
specification
]
}}
%
2371 2372
%D \macros
2373
%D {setsmallbodyfont,setmainbodyfont,setbigbodyfont}
2374
%D
2375
%D When we're typesetting at for instance 10pt, we can call for the \type {small} as
2376
%D well as the \type {big} alternative, related to this main size, using \type
2377
%D {\switchtobodyfont[small]}. The three alternatives can be activated by the next
2378
%D three system calls and are defined by the bodyfontenvironment.
2379 2380
\newmacro
\m_font_step
2381 2382
\def
\font_helpers_set_bodyfont_step
#
step
%
2383
{
\edef
\m_font_step
{
\font_bodyfontvariable
{
#
step
}}
% not always \cs
2384
\font_basics_switch_points
\m_font_step
2385
\font_basics_switch_style
\fontstyle
}
2386 2387
\unexpanded
\def
\setsmallbodyfont
{
\font_helpers_set_bodyfont_step
\v!small
\the
\everybodyfont
}
2388
\unexpanded
\def
\setbigbodyfont
{
\font_helpers_set_bodyfont_step
\v!big
\the
\everybodyfont
}
2389 2390
\unexpanded
\def
\setmainbodyfont
2391
{
\font_basics_switch_points
\normalizedbodyfontsize
2392
\font_basics_switch_style
\fontstyle
2393
\the
\everybodyfont
2394
\the
\everyglobalbodyfont
2395
\saveinterlinespace
}
2396 2397
%D \macros
2398
%D {restoreglobalbodyfont}
2399
%D
2400
%D Users can set whatever font available while typesetting text. Pagenumbers,
2401
%D footers, headers etc. however must be typeset in the main bodyfont and style of
2402
%D the document. Returning to the global state can be done with the next macro:
2403
%D
2404
%D This macro has to be called when entering the pagebody handling routine as well
2405
%D as the footnote insert routine. Users can access this feature |<|for instance
2406
%D when one wants to typeset tables and alike in the main bodyfont and style while
2407
%D the running text is temporary set to a smaller one|>| by saying \type
2408
%D {\switchtobodyfont [global]}.
2409 2410
\let
\globalfontstyle
\s!rm
2411 2412
\unexpanded
\def
\fullrestoreglobalbodyfont
2413
{
\let
\fontsize
\defaultfontsize
2414
\let
\fontbody
\defaultfontbody
2415
\let
\fontface
\defaultfontface
2416
\currentxfontsize
\zerocount
2417
\let
\fontclass
\globalfontclass
2418
\font_basics_switch_points
\normalizedglobalbodyfontsize
2419
\font_basics_switch_style
\globalfontstyle
2420
\redoconvertfont
% just in case a pagebreak occurs
2421
\tf
2422
\the
\everybodyfont
2423
\the
\everyglobalbodyfont
2424
\saveinterlinespace
}
2425 2426
\unexpanded
\def
\partialrestoreglobalbodyfont
2427
{
\let
\fontsize
\defaultfontsize
2428
\let
\fontbody
\defaultfontbody
2429
\let
\fontface
\defaultfontface
2430
\currentxfontsize
\zerocount
2431
\redoconvertfont
2432
\tf
2433
\the
\everybodyfont
% indeed needed
2434
\the
\everyglobalbodyfont
% indeed needed
2435
\saveinterlinespace
}
2436 2437
\unexpanded
\def
\restoreglobalbodyfont
% ook style etc
2438
{
\ifx
\fontclass
\globalfontclass
2439
\ifx
\fontstyle
\globalfontstyle
2440
\ifx
\normalizedbodyfontsize
\normalizedglobalbodyfontsize
2441
\partialrestoreglobalbodyfont
2442
\else
2443
\fullrestoreglobalbodyfont
2444
\fi
2445
\else
2446
\fullrestoreglobalbodyfont
2447
\fi
2448
\else
2449
\fullrestoreglobalbodyfont
2450
\fi
}
2451 2452
% in case of troubles: \let\restorebodyfont\fullrestoreglobalbodyfont
2453 2454
%D Here are some fast variants that can be used in cases where no font system is
2455
%D needed and where fonts are frozen:
2456
%D
2457
%D \starttyping
2458
%D \definefont [TestA][Serif at 10pt]
2459
%D \predefinefont[TestB][Serif at 20pt]
2460
%D
2461
%D \testfeatureonce{1000}{{\TestA}} % .312
2462
%D \testfeatureonce{1000}{{\TestB}} % < .016
2463
%D \testfeatureonce{1000}{{\definedfont[Serif at 30pt]}} % .312
2464
%D \testfeatureonce{1000}{{\predefinedfont[Serif at 40pt]}} % < .016
2465
%D \stoptyping
2466 2467
\installcorenamespace
{
predefinedfont
}
2468 2469
\unexpanded
\def
\predefinefont
[#
1
]#
2
[#
3
]
% global !
2470
{
\setugvalue
{
#
1
}{
\font_basics_predefine
{
#
1
}{
#
3
}}}
2471 2472
\unexpanded
\def
\predefinedfont
[#
1
]
% global !
2473
{
\ifcsname
\??predefinedfont
#
1
\endcsname
2474
\lastnamedcs
2475
\else
2476
\font_basics_predefined
{
#
1
}
%
2477
\fi
}
2478 2479
\unexpanded
\def
\font_basics_predefine
#
1
#
2
%
2480
{
\font_basics_defined_font_yes
[#
2
]
%
2481
\expandafter
\glet
\csname
#
1
\expandafter\endcsname\csname
\v_font_identifier_basic
\endcsname
}
2482 2483
\unexpanded
\def
\font_basics_predefined
#
1
%
2484
{
\font_basics_predefine
{
\??predefinedfont
#
1
}{
#
1
}}
2485 2486
%D Handy helper:
2487 2488
\unexpanded
\def
\savedefinedfont
[#
1
]
%
2489
{
\bgroup
2490
\definedfont
[#
1
]
%
2491
\xdef
\saveddefinedfontid
{
\number\fontid\font
}
%
2492
\xdef
\saveddefinedfontname
{
\fontname\font
}
%
2493
\egroup
}
2494 2495
\def
\saveddefinedfontid
{
\number\fontid\font
}
2496
\def
\saveddefinedfontname
{
\fontname\font
}
2497 2498
%D Ugly helper:
2499 2500
\unexpanded
\def
\saverunningstyleandcolor
2501
{
\unexpanded
\edef
\restorerunningstyleandcolor
2502
{
\setfontid
\number\fontid\font
2503
\c_attr_colormodel
\the
\c_attr_colormodel
2504
\c_attr_color
\the
\c_attr_color
2505
\c_attr_transparency
\the
\c_attr_transparency
2506
\relax
}}
2507 2508
\let
\restorerunningstyleandcolor
\relax
2509 2510
%D Handy for defining additional glyphs:
2511 2512
\let
\getprivateglyphslot
\clf_getprivateglyphslot
% kind of private macro
2513 2514
\let
\getprivatechar
\clf_getprivatechar
% gives back a utf !
2515
\let
\getprivatemathchar
\clf_getprivatemathchar
% gives back a utf !
2516
\let
\getprivateslot
\clf_getprivateslot
% companion to fonts.helpers.addprivate
2517 2518
% \unexpanded\def\getprivatemathchar#1%
2519
% {\begingroup\the\textfont\zerocount\getprivatechar{#1}\endgroup}
2520 2521
\def
\privatechar
% the text variant gets expanded to utf
2522
{
\ifmmode
2523
\expandafter
\getprivatemathchar
2524
\else
2525
\expandafter
\getprivatechar
2526
\fi
}
2527 2528
%D Some fonts can have color specifiers:
2529
%D
2530
%D \starttyping
2531
%D \definefontfeature[seguiemj-cl][default][colr=yes,ccmp=yes,dist=yes]
2532
%D \definefontsynonym[emoji][seguiemj*seguiemj-cl]
2533
%D
2534
%D \definecolor[emoji-red] [r=.4]
2535
%D \definecolor[emoji-gray][s=1,t=.5,a=1]
2536
%D
2537
%D %definefontcolorpalette [emoji-r] [emoji-red,emoji-gray,textcolor] % bad
2538
%D \definefontcolorpalette [emoji-r] [emoji-red,emoji-gray] % okay
2539
%D
2540
%D \definefontfeature[seguiemj-r][ccmp=yes,dist=yes,colr=emoji-r]
2541
%D
2542
%D \definefont[MyEmojiR][seguiemj*seguiemj-r @ 100pt]
2543
%D
2544
%D \startTEXpage[offset=10pt]
2545
%D \MyEmojiR\resolvedemoji{triangular ruler}
2546
%D \stopTEXpage
2547
%D \stoptyping
2548 2549
\unexpanded
\def
\definefontcolorpalette
2550
{
\dodoubleargument
\font_define_color_palette
}
2551 2552
\def
\font_define_color_palette
[#
1
][#
2
]
%
2553
{
\clf_definefontcolorpalette
{
#
1
}{
#
2
}}
2554 2555
%D \macros
2556
%D {addfontpath}
2557
%D
2558
%D A way to add a path at runtime (no need to generate database):
2559 2560
\unexpanded
\def
\usefontpath
[#
1
]
%
2561
{
\clf_addfontpath
{
#
1
}}
2562 2563
\protect
\endinput
2564