1
2
3
4
5
6
7
8
9
10
11
12
13
14\registerctxluafile{metatex}{}
15
16\unprotect
17
18
19
20
21
22\installcorenamespace{graphictextext}
23\installcorenamespace{graphictexdepth}
24\installcorenamespace{graphictexarguments}
25
26\unexpanded\def\startTeXtexts#1\stopTeXtexts
27 {#1}
28
29\let\stopTeXtexts\relax
30
31\unexpanded\def\TeXtext
32 {\dosingleempty\meta_textext}
33
34\def\meta_textext[#1]#2#3
35 {\setxvalue{\??graphictextext#2}{\meta_textext_indeed{#1}{#3}}}
36
37\unexpanded\def\meta_textext_indeed#1#2
38 {\begingroup
39 \setbox\nextbox\hbox{#2}
40 \ifcsname\??graphictexdepth#1\endcsname
41 \lastnamedcs
42 \else
43 \syst_boxes_lower_nextbox_dp
44 \fi
45 \box\nextbox
46 \endgroup}
47
48\def\getTeXtext#1
49 {\begincsname\??graphictextext#1\endcsname}
50
51\letvalue{\??graphictexdepth d}\syst_boxes_lower_nextbox_dp
52\letvalue{\??graphictexdepth \s!depth}\syst_boxes_lower_nextbox_dp
53\letvalue{\??graphictexdepth n}\donothing
54\letvalue{\??graphictexdepth\s!nodepth}\donothing
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72\unexpanded\def\definetextext[#1]
73 {\def\currenttextext{#1}
74 \doifelsenextoptionalcs\meta_textext_define_one\meta_textext_define_zero}
75
76\def\meta_textext_define_one {\setvalue{\??graphictexarguments1:\currenttextext}}
77\def\meta_textext_define_zero{\setvalue{\??graphictexarguments0:\currenttextext}}
78
79\def\sometxt#1#{\meta_some_txt{#1}}
80
81\def\meta_some_txt#1#2
82 {textext.drt("\mpsometxt#1{\clf_metapostescaped{#2}}")}
83
84\unexpanded\def\mpsometxt
85 {\doifelsenextoptionalcs\meta_some_txt_indeed_yes\meta_some_txt_indeed_nop}
86
87\def\meta_some_txt_indeed_yes[#1]
88 {\def\currenttextext{#1}
89 \csname\??graphictexarguments
90 \ifcsname\??graphictexarguments0:#1\endcsname0\else
91 \ifcsname\??graphictexarguments1:#1\endcsname1\else
92 ?\fi\fi
93 \endcsname}
94
95\def\meta_some_txt_indeed_nop
96 {}
97
98\setvalue{\??graphictexarguments ?}{}
99\setvalue{\??graphictexarguments 0}{\csname\??graphictexarguments\currenttextext\endcsname}
100\setvalue{\??graphictexarguments 1}{\dosingleempty\meta_gx_one}
101
102\def\meta_gx_one{\csname\??graphictexarguments1:\currenttextext\endcsname}
103
104
105
106
107
108
109
110
111
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\unexpanded\def\MPexponent #1#2{\mathematics{#1\times10{#2}}}
145\unexpanded\def\MPformatted #1#2{\clf_metapostformatted{#1}{#2}}
146\unexpanded\def\MPgraphformat#1#2{\clf_metapostgraphformat{#1}{#2}}
147
148
149
150\unexpanded\def\MPLIBoutlinetext#1#2#3
151 {\begingroup
152 \setbox\scratchbox\hbox{#3}
153 \clf_MPLIBconvertoutlinetext\numexpr#1\relax{#2}\scratchbox
154 \endgroup}
155
156
157
158
159\definefontsynonym[serifnormalnormal] [\s!Serif]
160\definefontsynonym[serifnormalitalic] [\s!SerifItalic]
161\definefontsynonym[serifnormaloblique][\s!SerifSlanted]
162\definefontsynonym[serifboldnormal] [\s!SerifBold]
163\definefontsynonym[serifbolditalic] [\s!SerifBoldItalic]
164\definefontsynonym[serifboldoblique] [\s!SerifBoldSlanted]
165
166\definefontsynonym[sansnormalnormal] [\s!Sans]
167\definefontsynonym[sansnormalitalic] [\s!SansItalic]
168\definefontsynonym[sansnormaloblique] [\s!SansSlanted]
169\definefontsynonym[sansboldnormal] [\s!SansBold]
170\definefontsynonym[sansbolditalic] [\s!SansBoldItalic]
171\definefontsynonym[sansboldoblique] [\s!SansBoldSlanted]
172
173\definefontsynonym[mononormalnormal] [\s!Mono]
174\definefontsynonym[mononormalitalic] [\s!MonoItalic]
175\definefontsynonym[mononormaloblique] [\s!MonoSlanted]
176\definefontsynonym[monoboldnormal] [\s!MonoBold]
177\definefontsynonym[monobolditalic] [\s!MonoBoldItalic]
178\definefontsynonym[monoboldoblique] [\s!MonoBoldSlanted]
179
180\installcorenamespace {svgfamily}
181
182\setvalue{\??svgfamily }{serif}
183\setvalue{\??svgfamily serif}{serif}
184\setvalue{\??svgfamily sans}{sans}
185\setvalue{\??svgfamily mono}{mono}
186
187
188
189\unexpanded\def\svgscaled#1
190 {\fastsxsy{#1}{#1}\svgnormal}
191
192\unexpanded\def\svgnormal#1#2#3#4
193 {\bgroup
194 \edef\p_family{#1}
195 \ifx\p_family\empty\else
196 \edef\p_font{\ifcsname\??svgfamily#1\endcsname\lastnamedcs\else#1\fi#2#3}
197 \predefinedfont[\s!spec:\p_font*\s!default\space @ 10bp]
198 \fi
199 #4
200 \egroup}
201
202\unexpanded\def\svgcolored#1#2#3#4
203 {\colored[r=#1,g=#2,b=#3]{#4}}
204
205\unexpanded\def\svgplaced#1#2#3#4
206 {\doifelsenothing{#3}
207 {\hpack}
208 {\hpack to #3}
209 {\raise#2\onebasepoint\hbox{\kern#1\onebasepoint\relax#4}}}
210
211\newdimen\grph_svg_scratchwidth
212
213\unexpanded\def\svgposchar#1#2#3
214 {\setbox\scratchbox\hpack\bgroup
215 \raise#2\onebasepoint\hbox\bgroup
216 \kern\dimexpr#1\onebasepoint\grph_svg_scratchwidth\relax
217 \char#3\relax
218 \egroup
219 \egroup
220 \advance\grph_svg_scratchwidth\wd\scratchbox
221 \box\scratchbox}
222
223\unexpanded\def\svgchar#1
224 {\char#1\relax}
225
226\definelayer[svgmps][\c!method=\v!fit]
227
228\unexpanded\def\svgstartlayer
229 {\resetlayer[svgmps]
230 \setlayer[svgmps]\bgroup}
231
232\unexpanded\def\svgstoplayer
233 {\egroup
234 \flushlayer[svgmps]}
235
236\unexpanded\def\svgsetlayer#1#2
237 {\setlayer[svgmps][\c!x=#1\onebasepoint,\c!y=#2\onebasepoint]}
238
239\unexpanded\def\svghashed#1
240 {\clf_svghashed#1\relax}
241
242\protect \endinput
243 |