1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Font Macros Symbolic Access}
15
16\unprotect
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32\def\v_font_string_a
33 {\ifx\fontstyle\s!rm \s!Serif \else
34 \ifx\fontstyle\s!ss \s!Sans \else
35 \ifx\fontstyle\s!tt \s!Mono \else
36 \s!Serif \fi\fi\fi}
37
38\def\v_font_string_b
39 {\ifx\fontstyle\s!rm \s!Regular \else
40 \ifx\fontstyle\s!ss \s!Support \else
41 \ifx\fontstyle\s!tt \s!Type \else
42 \s!Serif \fi\fi\fi}
43
44\def\v_font_string_c
45 {\ifx\fontalternative\s!bf \s!Bold \else
46 \ifx\fontalternative\s!sl \s!Slanted \else
47 \ifx\fontalternative\s!it \s!Italic \else
48 \ifx\fontalternative\s!bs \s!BoldSlanted \else
49 \ifx\fontalternative\s!bi \s!BoldItalic \fi\fi\fi\fi\fi}
50
51\let\v_font_string_d\s!Serif
52
53\definefontsynonym
54 [CurrentFont]
55 [\noexpand\v_font_string_a\noexpand\v_font_string_c]
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85\def\fontstylesuffix
86 {\ifx\fontalternative\s!tf \s!Regular \else
87 \ifx\fontalternative\s!bf \s!Bold \else
88 \ifx\fontalternative\s!sl \s!Slanted \else
89 \ifx\fontalternative\s!it \s!Italic \else
90 \ifx\fontalternative\s!bs \s!BoldSlanted \else
91 \ifx\fontalternative\s!bi \s!BoldItalic \else
92 \ifx\fontalternative\s!sc \s!Caps \else
93 \s!Regular \fi\fi\fi\fi\fi\fi\fi}
94
95\def\glyphfontfile#base
96 {#base
97 \ifcsname\??fontfile#base\v_font_string_a\v_font_string_c\endcsname
98 \v_font_string_a\v_font_string_c
99 \else\ifcsname\??fontfile#base\v_font_string_b\v_font_string_c\endcsname
100 \v_font_string_b\v_font_string_c
101 \else\ifcsname\??fontfile#base\v_font_string_a\endcsname
102 \v_font_string_a
103 \else\ifcsname\??fontfile#base\v_font_string_b\endcsname
104 \v_font_string_b
105 \else\ifcsname\??fontfile#base\v_font_string_c\endcsname
106 \v_font_string_c
107 \fi\fi\fi\fi\fi}
108
109
110
111\def\doifelseitalic#yes#nop
112 {\ifx\fontalternative\s!sl#yes\else
113 \ifx\fontalternative\s!it#yes\else
114 \ifx\fontalternative\s!bs#yes\else
115 \ifx\fontalternative\s!bi#yes\else#nop\fi\fi\fi\fi}
116
117\let\doifitalicelse\doifelseitalic
118
119
120
121
122
123
124
125
126
127
128\installcorenamespace{symbolfont}
129
130\let\thedefinedfont\relax
131
132\def\setscaledstyledsymbolicfont#1#2#3
133 {\edef\askedsymbolfont{\truefontname{\glyphfontfile{#3}} at \the\dimexpr#2\dimexpr\currentfontbodyscale\dimexpr#1}
134 \ifcsname\??symbolfont\askedsymbolfont\endcsname
135 \lastnamedcs
136 \else
137 \font_basics_define_symbolic_font
138 \fi}
139
140\def\setscaleddirectsymbolicfont#1#2#3
141 {\edef\askedsymbolfont{\truefontname{#3} at \the\dimexpr#2\dimexpr\currentfontbodyscale\dimexpr#1}
142 \ifcsname\??symbolfont\askedsymbolfont\endcsname
143 \lastnamedcs
144 \else
145 \font_basics_define_symbolic_font
146 \fi}
147
148\def\setstyledsymbolicfont#fontname
149 {\edef\askedsymbolfont{\truefontname{\glyphfontfile{#fontname}} at \the\dimexpr\currentfontbodyscale\dimexpr\fontbody}
150 \ifcsname\??symbolfont\askedsymbolfont\endcsname
151 \lastnamedcs
152 \else
153 \font_basics_define_symbolic_font
154 \fi}
155
156\def\setdirectsymbolicfont#fontname
157 {\edef\askedsymbolfont{\truefontname{#fontname} at \the\dimexpr\currentfontbodyscale\dimexpr\fontbody}
158 \ifcsname\??symbolfont\askedsymbolfont\endcsname
159 \lastnamedcs
160 \else
161 \font_basics_define_symbolic_font
162 \fi}
163
164\def\font_basics_define_symbolic_font
165 {\definefont[currentsymbolfont][\askedsymbolfont]
166 \currentsymbolfont
167 \expandafter\glet\csname\??symbolfont\askedsymbolfont\endcsname\lastrawfontcall}
168
169\unexpanded\def\getnamedglyphstyled#fontname#character{{\setstyledsymbolicfont{#fontname}\clf_fontchar{#character}}}
170\unexpanded\def\getnamedglyphdirect#fontname#character{{\setdirectsymbolicfont{#fontname}\clf_fontchar{#character}}}
171\unexpanded\def\getglyphstyled #fontname#character{{\setstyledsymbolicfont{#fontname}\doifelsenumber{#character}\char\donothing#character}}
172\unexpanded\def\getglyphdirect #fontname#character{{\setdirectsymbolicfont{#fontname}\doifelsenumber{#character}\char\donothing#character}}
173\unexpanded\def\resolvedglyphstyled#fontname#character{{\setstyledsymbolicfont{#fontname}\clf_tochar{#character}}}
174\unexpanded\def\resolvedglyphdirect#fontname#character{{\setdirectsymbolicfont{#fontname}\clf_tochar{#character}}}
175
176
177
178\unexpanded\def\getscaledglyph#scale#name#content
179 {{\setscaledstyledsymbolicfont\fontbody{#scale}{#name}\doifelsenumber{#content}\char\donothing#content}}
180
181\let\getglyph \getglyphstyled
182\let\getrawglyph \getglyphdirect
183\let\symbolicsizedfont\setscaledstyledsymbolicfont
184\let\symbolicfont \setstyledsymbolicfont
185
186\unexpanded\def\symbolicscaledfont{\setsscaledstyledsymbolicfont\fontbody}
187\unexpanded\def\symbolicscaledfont{\setscaledstyledsymbolicfont\fontbody}
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218\unexpanded\def\setfont
219 {\afterassignment\font_basics_set_font\font\nextfont=}
220
221\def\font_basics_set_font
222 {\nextfont\setupinterlinespace}
223
224
225
226
227
228
229
230
231
232
233
234\unexpanded\def\doifelsefontchar#specification#unicode
235 {\begingroup
236 \font_basics_define_font_without_parameters{thedefinedfont}{#specification}
237 \iffontchar\font#unicode\relax
238 \endgroup\expandafter\firstoftwoarguments
239 \else
240 \endgroup\expandafter\secondoftwoarguments
241 \fi}
242
243\let\doiffontcharelse\doifelsefontchar
244
245\protect \endinput
246 |