font-run.mkiv /size: 13 Kb    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=font-run,
3
%D version=1998.09.11, % (second)
4
%D version=2001.02.20, % (third)
5
%D title=\CONTEXT\ Font Macros,
6
%D subtitle=Runtime Macros,
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
%D [This code is hooked into the core macros and saves some format
16
%D space. It needs a cleanup as it's real old derioved \MKII\ code]
17
%D
18
%D Better use \type{\bTABLE...\eTABLE}.
19 20
\unprotect
21 22
\gdef
\font_show_only_english
#
1
%
23
{
\blank
{
\tttf
\type
{
#
1
}
is
only
available
in
the
english
interface
}
\blank
}
24 25
\gdef
\font_show_title
#
1
%
26
{
\tabskip
\zeropoint
27
\parindent
\zeropoint
28
\setlocalhsize
29
\doifelsenothing
{
#
1
}
30
{
\def
\title
{
[
\the
\bodyfontsize
]
}}
31
{
\switchtobodyfont
[#
1
]
\def
\title
{
[#
1
]
}}
32
\doifsomething
\fontclass
33
{
\doifnot
{
[
\fontclass
]
}
\title
34
{
\edef
\title
{
[
\fontclass
]
\space
\title
}}}}
35 36
\unexpanded
\gdef
\showbodyfont
37
{
\dosingleempty
\font_show_bodyfont
}
38 39
\gdef
\font_show_bodyfont
[#
1
]
%
40
{
\ifinsidefloat
\else
\startbaselinecorrection
\fi
41
\vbox
42
{
\font_show_title
{
#
1
}
%
43
\def
\bigstrut
##
1
##
2
%
44
{
\hbox
{
\vrule
45
\s!height
##
1
\strutht
46
\s!depth
##
2
\strutdp
47
\s!width
\zeropoint
}}
48
\def
\next
##
1
##
2
##
3
%
49
{
&&
##
1
&&
##
2
\tf
##
3
&&
##
2
\sc
##
3
%
50
&&
##
2
\sl
##
3
&&
##
2
\it
##
3
&&
##
2
\bf
##
3
&&
##
2
\bs
##
3
&&
##
2
\bi
##
3
%
51
&&
##
2
\tfx
##
3
&&
##
2
\tfxx
##
3
%
52
&&
##
2
\tfa
##
3
&&
##
2
\tfb
##
3
&&
##
2
\tfc
##
3
&&
##
2
\tfd
##
3
&
\cr
}
%
53
\halign
to
\localhsize
54
{
\bigstrut
{
1
.
5
}{
2
}
##
&
\vrule
##
55
\tabskip
\zeropoint
\s!plus
1
\s!fill
56
&
\hfil
##
\hfil
&
\vrule
##
&
\hfil
##
\hfil
&
\vrule
##
57
&
\hfil
##
\hfil
&
\vrule
##
&
\hfil
##
\hfil
&
\vrule
##
58
&
\hfil
##
\hfil
&
\vrule
##
&
\hfil
##
\hfil
&
\vrule
##
59
&
\hfil
##
\hfil
&
\vrule
##
&
\hfil
##
\hfil
&
\vrule
##
60
&
\hfil
##
\hfil
&
\vrule
##
&
\hfil
##
\hfil
&
\vrule
##
61
&
\hfil
##
\hfil
&
\vrule
##
&
\hfil
##
\hfil
&
\vrule
##
62
&
\hfil
##
\hfil
&
\vrule
##
&
\hfil
##
\hfil
&
##
\vrule
63
\tabskip
=
\zeropoint
\cr
64
\noalign
{
\hrule
}
65
&
\multispan
{
2
9
}{
\vrule\hfil
\tttf
\strut
\title
\hfil
66
\llap
{
\string
\mr
\hpack
to
\emwidth
{
\hss
:
\hss
}
\normalstartimath
\mr
\languageparameter
\c!text
\normalstopimath\quad
}
\vrule
}
\cr
67
\noalign
{
\hrule
}
\next
{}{
\tt
\string
}{}
68
\noalign
{
\hrule
}
\next
{
\tt
\string
\rm
}
\rm
{
\languageparameter
\c!text
}
69
\noalign
{
\hrule
}
\next
{
\tt
\string
\ss
}
\ss
{
\languageparameter
\c!text
}
70
\noalign
{
\hrule
}
\next
{
\tt
\string
\tt
}
\tt
{
\languageparameter
\c!text
}
71
\noalign
{
\hrule
}}}
72
\ifinsidefloat
\else
\stopbaselinecorrection
\fi
}
73 74
\unexpanded
\gdef
\showbodyfontenvironment
75
{
\dosingleempty
\font_show_bodyfont_environment
}
76 77
\gdef
\font_show_bodyfont_environment
[#
1
]
%
78
{
\ifinsidefloat
\else
\startbaselinecorrection
\fi
79
\vbox
80
{
\font_show_title
{
#
1
}
%
81
\def
\next
##
1
%
82
{
&&
\bodyfontsizevariable
{
##
1
}
\s!text
83
&&
\bodyfontsizevariable
{
##
1
}
\s!script
84
&&
\bodyfontsizevariable
{
##
1
}
\s!scriptscript
85
&&
\bodyfontsizevariable
{
##
1
}
\s!x
86
&&
\bodyfontsizevariable
{
##
1
}
\s!xx
87
&&
\bodyfontsizevariable
{
##
1
}
\v!small
88
&&
\bodyfontsizevariable
{
##
1
}
\v!big
89
&&
\bodyfontsizevariable
{
##
1
}
\c!interlinespace
90
&
\cr
91
\noalign
{
\hrule
}}
92
\halign
to
\localhsize
93
{
##
&
\vrule
##
\strut
94
\tabskip
=
\zeropoint
\s!plus
1
\s!fill
95
&
\hfil
##
\hfil
&
\vrule
##
&
\hfil
##
\hfil
&
\vrule
##
&
\hfil
##
\hfil
&
\vrule
##
96
&
\hfil
##
\hfil
&
\vrule
##
&
\hfil
##
\hfil
&
\vrule
##
&
\hfil
##
\hfil
&
\vrule
##
97
&
\hfil
##
\hfil
&
\vrule
##
&
\hfil
##
\hfil
&
##
\vrule
98
\tabskip
\zeropoint
\cr
99
\noalign
{
\hrule
}
100
&
\multispan
{
1
7
}{
\vrule\hfil
\tttf
\strut
\title
\hfil
}
\vrule\cr
101
\noalign
{
\hrule
}
102
&&
\tttf
\tx
\s!text
&&
\tttf
\tx
\s!script
&&
\tttf
\tx
\s!scriptscript
103
&&
\tttf
\tx
\s!x
&&
\tttf
\tx
\s!xx
&&
\tttf
\tx
\v!small
&&
\tttf
\tx
\v!big
104
&&
\tttf
\tx
\c!interlinespace
&
\cr
105
\noalign
{
\hrule
}
%
106
\processbodyfontenvironmentlist
\next
}}
107
\ifinsidefloat
\else
\stopbaselinecorrection
\fi
}
108 109
\unexpanded
\gdef
\showfont
110
{
\dodoubleempty
\font_show_font
}
111 112
\gdef
\font_show_font
[#
1
][#
2
]
% doing this in lua is much faster
113
{
\bgroup
114
\iffirstargument
115
\definefont
[
\s!dummy
][#
1
]
\dummy
116
\fi
117
\doifelsenothing
{
#
2
}
118
{
\font_show_font_indeed
{
#
1
}
\zerocount
}
119
{
\doifelse
{
#
2
}
\v!all
120
{
\dostepwiserecurse
\zerocount
{
2
5
5
}
\plusone
121
{
\scratchcounterone
\recurselevel
122
\scratchcountertwo
\numexpr
\scratchcounterone
*
2
5
6
\relax
123
\scratchcounterthree
\numexpr
\scratchcountertwo
+
2
5
5
\relax
124
\doloop
125
{
\iffontchar
\font
\scratchcountertwo
126
\font_show_font_indeed
{
#
1
}
\scratchcounterone
127
\exitloop
128
\else\ifnum
\scratchcountertwo
=
\scratchcounterthree
129
\exitloop
130
\else
131
\advance
\scratchcountertwo
\plusone
132
\fi\fi
}}}
133
{
\processcommalist
[#
2
]
{
\font_show_font_indeed
{
#
1
}}}}
%
134
\egroup
}
135 136
\gdef
\font_show_font_indeed
#
1
#
2
% made some 50% faster but still slow
137
{
\bgroup
138
\iffirstargument
139
% \definefont[\s!dummy][#1]\dummy
140
\else\ifdim
2
.
5
\emwidth
>
.
0
5
\hsize
\tx
141
\ifdim
2
.
5
\emwidth
>
.
0
5
\hsize
\txx
142
\fi\fi\fi
143
\ifinsidefloat
\else
\startbaselinecorrection
\fi
144
\vbox
\bgroup
145
\scratchdimenone
2
.
5
\emwidth
146
\scratchdimentwo
2
.
4
\emwidth
147
\scratchdimenthree
2
.
3
\emwidth
148
\edef
\charplane
{
\number
#
2
}
%
149
\forgetall
150
\startoverlay
% easier in cld
151
{
\vbox
152
{
\tf
153
\setstrut
154
\dummy
155
\offinterlineskip
156
\unexpanded
\def
\wrapbox
##
1
%
157
{
\vpack
to
\scratchdimenone
158
{
\vss
159
\hpack
to
\scratchdimenone
160
{
\dummy
161
\ifzeropt
\interwordspace
162
\setbox
##
1
\hpack
163
{
\raise
.
5
\dp
##
1
\hpack
164
{
\lower
.
5
\ht
##
1
\copy
##
1
}}
%
165
\ht
##
1
\zeropoint
166
\dp
##
1
\zeropoint
167
\else
168
\ht
##
1
\strutht
169
\dp
##
1
\strutdp
170
\strut
171
\fi
172
\hss\copy
##
1
\hss
}
173
\vss
}}
%
174
\unexpanded
\def
\textbox
##
1
%
175
{
\vpack
to
\scratchdimentwo
176
{
\hsize
\scratchdimenthree
177
##
1
%
178
\par
}}
%
179
\unexpanded
\def
\scratchnum
180
{
\blue
181
\tinyfont
182
\hfill
183
\number
\scratchcounter
184
\vfill
185
\octnumber
\scratchcounter
186
\hfill
187
\lchexnumbers
\scratchcounter
}
%
188
\setbox
\scratchboxone
\hpack
{
\tf
\textbox
{}}
%
189
\setbox
\scratchboxtwo
\hpack
{
\tf
\gray
\vrule
\s!width
\exheight
\s!height
.
5
\exheight
\s!depth
.
5
\exheight
}
%
190
\setbox
\scratchboxtwo
\wrapbox
\scratchboxtwo
191
\setbox
\scratchboxthree
\hpack
192
{
\startoverlay
193
{
\box
\scratchboxtwo
}
194
{
\box
\scratchboxone
}
195
\stopoverlay
}
%
196
\dostepwiserecurse
\zerocount
{
1
5
}
\plusone
197
{
\scratchcounterone\recurselevel
198
\hpack
199
{
\dostepwiserecurse
\zerocount
{
1
5
}
\plusone
200
{
\scratchcountertwo
\recurselevel
201
\scratchcounter
\numexpr
\scratchcounterone
*
1
6
+
\scratchcountertwo
\relax
202
\scratchcounterthree
\numexpr
\charplane
*
2
5
6
+
\scratchcounter
\relax
203
\iffontchar
\font
\scratchcounterthree
204
\setbox
\scratchbox\ruledhpack
{
\char
\scratchcounterthree
}
%
205
\bgroup
206
\tf
207
\startoverlay
208
{
\wrapbox
\scratchbox
}
209
{
\textbox
\scratchnum
}
210
\stopoverlay
211
\egroup
212
\else
213
\copy
\scratchboxthree
214
\fi
}}}
%
215
\par
}}
216
{
\tf
\basegrid
[
\c!nx
=
1
6
,
\c!ny
=
1
6
,
\c!dx
=
2
.
5
,
\c!dy
=
2
.
5
,
\c!unit
=
em
]
}
217
\stopoverlay
218
\nointerlineskip
219
\vskip
2
\points
220
% the \noexpand before \blank is needed for non etex
221
\edef
\theshowfontspecs
{
name
:
{
\noexpand
\black
\fontname\font
}
\quad
plane
:
\charplane
\enspace
"
\hexnumber
\charplane
}
%
222
\tf
% also sets em
223
\hbox
to
4
0
\emwidth
{
\blue
\hfill
\tinyfont\setstrut\strut
\theshowfontspecs
}
224
\egroup
225
\ifinsidefloat
\else
\stopbaselinecorrection
\fi
226
\egroup
}
227 228
% \showfontstyle[modern][rm][tf][all] % #2, #3 and #4 can be 'all'
229 230
\unexpanded
\gdef
\showfontstyle
{
\dodoubleempty
\font_show_style
}
231
\unexpanded
\gdef
\font_show_style_a
{
\dotripleempty
\font_show_style_b
}
232
\unexpanded
\gdef
\font_show_style_c
{
\doquadrupleempty
\font_show_style_d
}
233 234
% no lists any more, so no 'all' any longer
235 236
\gdef
\font_show_style
[#
1
][#
2
]
%
237
{
\doifelsenothing
{
#
2
}
238
{
\font_show_style_a
[#
1
][
\s!rm
,
\s!ss
,
\s!tt
,
\s!mm
]
}
239
{
\font_show_style_a
[#
1
][#
2
]
}}
240 241
\gdef
\font_show_style_b
[#
1
][#
2
][#
3
]
%
242
{
\doifelsenothing
{
#
3
}
243
{
\font_show_style_c
[#
1
][#
2
][
\s!tf
,
\s!bf
,
\s!it
,
\s!sl
,
\s!bs
,
\s!bi
]
}
244
{
\font_show_style_c
[#
1
][#
2
][#
3
]
}}
245 246
\gdef
\font_show_style_d
[#
1
][#
2
][#
3
][#
4
]
%
247
{
\font_show_style_e
[#
1
][#
2
][#
3
][#
4
]
}
248 249
% so far
250 251
\gdef
\font_show_style_e
[#
1
][#
2
][#
3
][#
4
]
%
252
{
\bgroup
253
\raggedright
254
\switchtobodyfont
[#
1
]
255
\def
\dododocommand
##
1
%
256
{
\dostepwiserecurse
\zerocount
{
2
5
5
}
\plusone
257
{
\scratchcounter
\numexpr
##
1
*
2
5
6
+
\recurselevel
\relax
258
\iffontchar
\font
\scratchcounter
\relax
259
\char
\scratchcounter
260
\space
261
\fi
}}
%
262
\def
\dodocommand
##
1
##
2
%
263
{
\starttextrule
{
\tttf
#
1
##
1
##
2
}
264
\nobreak\getvalue
{
##
2
}
%
265
\doifelsenothing
{
#
4
}
266
{
\dododocommand
\zerocount
}
267
{
\doifelse
{
#
4
}
\v!all
268
{
\dostepwiserecurse
\zerocount
{
2
5
5
}
\plusone
{
\expanded
{
\dododocommand
{
\recurselevel
}}}}
269
{
\processcommalist
[#
4
]
{
\dododocommand
}}}
%
270
\par
\nobreak
271
\stoptextrule
}
272
\def
\docommand
##
1
%
273
{
\getvalue
{
##
1
}
%
274
\processcommacommand
[#
3
]
{
\dodocommand
{
##
1
}}}
275
\processcommalist
[#
2
]
\docommand
276
\egroup
}
277 278
\unexpanded
\gdef
\showligature
#
1
%
279
{
\hbox
{
\type
{
#
1
}
\enspace
\red
\ruledhbox
{
\black
#
1
}}}
280 281
\unexpanded
\gdef
\showligatures
[#
1
]
% we keep it around for compatibility reasons
282
{
\ifx
\starttabulate
\undefined
283
\font_show_only_english
\showligatures
284
\else
285
\bgroup
286
\def
\font_show_ligature
##
1
{
\hbox
{
\red
\ruledhbox
{
\black
##
1
}}}
%
287
\definedfont
[#
1
*
default
]
%
288
%starttabulate[|*{9}{c|}]
289
\starttabulate
[
|
*
{
7
}{
c
|
}
]
290
\NC
\type
{
ff
}
291
\NC
\type
{
fi
}
292
\NC
\type
{
fl
}
293
\NC
\type
{
ffi
}
294
\NC
\type
{
ffl
}
295
%NC\type{``}
296
%NC\type{''}
297
\NC
\type
{
--
}
298
\NC
\type
{
---
}
299
\NC
\NR
300
\NC
\font_show_ligature
{
ff
}
301
\NC
\font_show_ligature
{
fi
}
302
\NC
\font_show_ligature
{
fl
}
303
\NC
\font_show_ligature
{
ffi
}
304
\NC
\font_show_ligature
{
ffl
}
305
%NC\font_show_ligature{``}
306
%NC\font_show_ligature{''}
307
\NC
\font_show_ligature
{
--
}
308
\NC
\font_show_ligature
{
---
}
309
\NC
\NR
310
\stoptabulate
311
\egroup
312
\fi
}
313 314
\unexpanded
\gdef
\showfontstrip
315
{
\dosingleempty
\font_show_strip
}
316 317
\gdef
\font_show_strip
[#
1
]
%
318
{
\ifx
\starttabulate
\undefined
319
\font_show_only_english
\showfontstrip
320
\else
321
\bgroup
322
\def
\font_show_strip_a
##
1
##
2
%
323
{
\tttf
\string
##
1
}
324
\def
\font_show_strip_b
##
1
##
2
%
325
{
\ruledhbox
{
\switchtobodyfont
[#
1
]##
1
{
##
2
}}}
326
\def
\font_show_strip_c
##
1
##
2
%
327
{
\setbox
\scratchbox
\hbox
{
\switchtobodyfont
[#
1
]##
1
{
##
2
}}
%
328
\tt
\tfx
\the\ht
\scratchbox
}
%
329
\def
\font_show_strip_d
##
1
##
2
%
330
{
\setbox
\scratchbox
\hbox
{
\switchtobodyfont
[#
1
]##
1
{
##
2
}}
%
331
\tt
\tfx
\the\wd
\scratchbox
}
%
332
\def
\font_show_strip_indeed
##
1
##
2
##
3
%
333
{
\NC
##
2
\rm
{
##
3
}
\NC
334
##
2
\ss
{
##
3
}
\NC
335
##
2
\tt
{
##
3
}
\NC
336
##
2
\mathematics
{
##
3
}
\NC
337
\tttf
##
1
\NR
}
338
\starttabulate
[
|
c
|
c
|
c
|
c
|
c
|
]
339
\font_show_strip_indeed
\relax
\font_show_strip_a
\empty
340
\TB
341
\font_show_strip_indeed
\relax
\font_show_strip_b
{
xxxx
}
342
\font_show_strip_indeed
\relax
\font_show_strip_b
{
1
2
3
4
5
}
343
\font_show_strip_indeed
\relax
\font_show_strip_b
{
(
Agw
)
}
344
\TB
345
\font_show_strip_indeed
{
(
x
height
)
}
\font_show_strip_c
{
x
}
346
\font_show_strip_indeed
{
(
m
width
)
}
\font_show_strip_d
{
m
}
347
\stoptabulate
348
\egroup
349
\fi
}
350 351
\ifdefined
\databox
\else
\newbox
\databox
\fi
352 353
\unexpanded
\gdef
\testminimalbaseline
#
1
% to be used in a 10 column tabulate
354
{
\setbox
\databox
\ruledhbox
{
#
1
}
%
355
\scratchdimen\htdp
\databox
356
\normalexpanded
{
357
\NC
\ruledhbox
{
#
1
}
%
358
\NC
-
>
359
\NC
\the
\htdp
\databox
360
\NC
=
361
\NC
\the\ht
\databox
362
\NC
+
363
\NC
\the\dp
\databox
364
\NC
\ifdim
\scratchdimen
<
\baselineskip
<
365
\else\ifdim
\scratchdimen
=
\baselineskip
=
366
\else
>
\fi\fi
367
\NC
\the\baselineskip
368
\NC
(
\ifdim
\scratchdimen
>
\baselineskip
not
\fi
ok
)
369
\NC
\NR
}
370
}
371 372
\unexpanded
\gdef
\showminimalbaseline
373
{
\ifx
\starttabulate
\undefined
374
\font_show_only_english
\showminimalbaseline
375
\else
376
\starttabulate
[
|
l
|
T
|
T
|
T
|
T
|
T
|
T
|
T
|
T
|
T
|
]
377
\testminimalbaseline
{
\hbox
to
\emwidth
{
\hss
\showstruts\strut
\hss
}}
%
378
\testminimalbaseline
{
(
/
)
}
%
379
\testminimalbaseline
{
\normalstartimath
\frac
{
1
}{
2
}
x
\normalsuperscript
2
\normalsubscript
3
\normalstopimath
}
380
\stoptabulate
381
\fi
}
382 383
\unexpanded
\gdef
\showkerning
#
1
%
384
{
\bgroup
385
\let
\MPfshowcommand
\ruledhbox
386
\setMPtext
\s!dummy
{
#
1
}
%
387
\startMPcode
draw
textext
(
\MPstring
\s!dummy
)
;
\stopMPcode
388
\egroup
}
389 390
\unexpanded
\gdef
\showcharratio
391
{
\dowithnextboxcontent
392
{
\switchtobodyfont
[
1
0
pt
]
}
%
393
{
(
\withoutpt
\the
\nextboxht
,
\withoutpt
\the
\nextboxdp
)
}
%
394
\hbox
}
395 396
\unexpanded
\gdef
\showfontparameters
397
{
\starttabulate
[
|
tl
|
l
|
]
398
\NC
slantperpoint
\NC
\the
\fontslantperpoint
\font
\NC
\NR
399
\NC
interwordspace
\NC
\the
\fontinterwordspace
\font
\NC
\NR
400
\NC
interwordstretch
\NC
\the
\fontinterwordstretch
\font
\NC
\NR
401
\NC
interwordshrink
\NC
\the
\fontinterwordshrink
\font
\NC
\NR
402
\NC
exheight
\NC
\the
\fontexheight
\font
\NC
\NR
403
\NC
emwidth
\NC
\the
\fontemwidth
\font
\NC
\NR
404
\NC
extraspace
\NC
\the
\fontextraspace
\font
\NC
\NR
405
\stoptabulate
}
406 407
\protect
\endinput
408