1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Font Macros Emphasis}
15
16\unprotect
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41\lettonothing\m_font_emphasized_typeface
42
43\def\font_emphasis_checked_typeface#slanted#italic
44 {\edef\m_font_emphasized_typeface{\font_bodyfontvariable\s!em}
45 \ifx\m_font_emphasized_typeface\v!slanted
46 #slanted
47 \orelse\ifx\m_font_emphasized_typeface\v!italic
48 #italic
49 \orelse\ifempty\m_font_emphasized_typeface
50 #slanted
51 \else
52 \csname\m_font_emphasized_typeface\endcsname
53 \fi}
54
55\permanent\protected\def\emphasistypeface{\font_emphasis_checked_typeface\sl\it}
56\permanent\protected\def\emphasisboldface{\font_emphasis_checked_typeface\bs\bi}
57
58\permanent\protected\def\normalboldface
59 {\relax
60 \ifx\fontalternative\s!tf\bf\orelse
61 \ifx\fontalternative\s!it\bi\orelse
62 \ifx\fontalternative\s!sl\bs\orelse
63 \ifx\fontalternative\s!bf \orelse
64 \ifx\fontalternative\s!bi \orelse
65 \ifx\fontalternative\s!bs \else
66 \bf\fi}
67
68\permanent\protected\def\normalitalicface
69 {\relax
70 \ifx\fontalternative\s!tf\it\orelse
71 \ifx\fontalternative\s!it \orelse
72 \ifx\fontalternative\s!sl\it\orelse
73 \ifx\fontalternative\s!bf\bi\orelse
74 \ifx\fontalternative\s!bi\bi\orelse
75 \ifx\fontalternative\s!bs\bi\else
76 \it\fi}
77
78\permanent\protected\def\normalslantedface
79 {\relax
80 \ifx\fontalternative\s!tf\sl\orelse
81 \ifx\fontalternative\s!it\sl\orelse
82 \ifx\fontalternative\s!sl \orelse
83 \ifx\fontalternative\s!bf\bs\orelse
84 \ifx\fontalternative\s!bi\bs\orelse
85 \ifx\fontalternative\s!bs\bs\else
86 \sl\fi}
87
88\permanent\protected\def\normaltypeface
89 {\relax
90 \ifx\fontalternative\s!tf \orelse
91 \ifx\fontalternative\s!it\tf\orelse
92 \ifx\fontalternative\s!sl\tf\orelse
93 \ifx\fontalternative\s!bf \orelse
94 \ifx\fontalternative\s!bi\bf\orelse
95 \ifx\fontalternative\s!bs\bf\else
96 \tf\fi}
97
98\permanent\protected\def\swaptypeface
99 {\relax
100 \ifx\fontalternative\s!it \tf \orelse
101 \ifx\fontalternative\s!sl \tf \orelse
102 \ifx\fontalternative\s!bf \emphasisboldface \orelse
103 \ifx\fontalternative\s!bs \bf \orelse
104 \ifx\fontalternative\s!bi \bf \else
105 \emphasistypeface \fi}
106
107\aliased\let\typeface \normaltypeface
108\aliased\let\boldface \normalboldface
109\aliased\let\slantedface\normalslantedface
110\aliased\let\italicface \normalitalicface
111\aliased\let\swapface \swaptypeface
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155\newconditional\c_font_emphasis_needed
156
157\permanent\protected\def\em
158 {\relax
159 \ifdim\slantperpoint>\zeropoint
160 \c_font_emphasis_needed\conditionaltrue
161 \else
162 \c_font_emphasis_needed\conditionalfalse
163 \fi
164 \font_emphasis_set_emphasis_boldface
165 \ifx\fontalternative\s!it
166 \enforced\permanent\protected\def\emphasistypeface{\it}\tf
167 \orelse\ifx\fontalternative\s!sl
168 \enforced\permanent\protected\def\emphasistypeface{\sl}\tf
169 \orelse\ifx\fontalternative\s!bf
170 \emphasisboldface
171 \orelse\ifx\fontalternative\s!bs
172 \enforced\permanent\protected\def\emphasisboldface{\bs}\bf
173 \orelse\ifx\fontalternative\s!bi
174 \enforced\permanent\protected\def\emphasisboldface{\bi}\bf
175 \else
176 \emphasistypeface
177 \fi
178 \ifconditional\c_font_emphasis_needed\else
179 \expandafter\aftergroup
180 \fi
181 \emphasiscorrection}
182
183
184
185
186\let\font_emphasis_saved_emphasis_boldface\relax
187
188\def\font_emphasis_set_emphasis_boldface
189 {\let\font_emphasis_saved_emphasis_boldface\bf
190 \let\font_emphasis_set_emphasis_boldface\relax
191 \enforced\let\bf\font_emphasis_bold_bold}
192
193\protected\def\font_emphasis_bold_bold
194 {
195 \enforced\let\bf\relax
196 \ifx\fontalternative\s!it
197 \bi
198 \orelse\ifx\fontalternative\s!sl
199 \bs
200 \else
201 \font_emphasis_saved_emphasis_boldface
202 \fi
203 \enforced\let\bf\font_emphasis_saved_emphasis_boldface}
204
205
206
207
208
209\aliased\let\normalitaliccorrection\/
210
211\let\italiccorrection\normalitaliccorrection
212
213\permanent\protected\def\emphasiscorrection
214 {\ifhmode\ifnum\currentgrouptype=\aligngroupcode\else
215 \expandafter\expandafter\expandafter\font_emphasis_look
216 \fi\fi}
217
218\def\font_emphasis_look
219 {\begingroup
220 \futurelet\nexttoken\font_emphasis_test}
221
222\def\font_emphasis_test
223 {\ifcat\noexpand\nexttoken,
224 \expandafter\font_emphasis_a
225 \else
226 \expandafter\font_emphasis_b
227 \fi}
228
229\def\font_emphasis_a
230 {\futurelet\nexttoken\font_emphasis_correction}
231
232\def\font_emphasis_correction
233 {\setbox\scratchbox\hbox{\nexttoken}
234 \ifzeropt\ht\scratchbox
235 \expandafter\font_emphasis_b
236 \orelse\ifdim\ht\scratchbox<.3\exheight
237 \expandafter\expandafter\expandafter\endgroup
238 \else
239 \expandafter\expandafter\expandafter\font_emphasis_b
240 \fi}
241
242\def\font_emphasis_b
243 {\scratchskip\lastskip
244 \ifzeropt\scratchskip
245 \italiccorrection\relax
246 \else
247 \unskip\italiccorrection\hskip\scratchskip
248 \fi
249 \endgroup}
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290\permanent\protected\def\font_tf{\tf} \permanent\protected\def\font_bf{\bf}
291\permanent\protected\def\font_sl{\sl} \permanent\protected\def\font_bs{\bs}
292\permanent\protected\def\font_it{\it} \permanent\protected\def\font_bi{\bi}
293
294\protected\def\font_emphasis_bf{\bf\enforced\aliased\let\emphit\font_bi
295 \enforced\aliased\let\emphsl\font_bs}
296\protected\def\font_emphasis_it{\it\enforced\aliased\let\emphbf\font_bi
297 \enforced\aliased\let\emphsl\font_sl}
298\protected\def\font_emphasis_sl{\sl\enforced\aliased\let\emphbf\font_bs
299 \enforced\aliased\let\emphit\font_it}
300\protected\def\font_emphasis_tf{\tf\enforced\aliased\let\emphbf\font_bf
301 \enforced\aliased\let\emphit\font_it
302 \enforced\aliased\let\emphsl\font_sl}
303
304\permanent\protected\def\emphbf{\triggergroupedcommandcs\font_emphasis_bf}
305\permanent\protected\def\emphit{\triggergroupedcommandcs\font_emphasis_it}
306\permanent\protected\def\emphsl{\triggergroupedcommandcs\font_emphasis_sl}
307\permanent\protected\def\emphtf{\triggergroupedcommandcs\font_emphasis_tf}
308\permanent\protected\def\emph {\triggergroupedcommandcs\em}
309
310\permanent\protected\def\emphasized{\bgroup\em\let\nexttoken}
311
312
313
314
315
316
317
318
319
320
321
322\protect \endinput
323 |