data-env.lua /size: 9400 b    last modification: 2020-07-01 14:35
1
if
not
modules
then
modules
=
{
}
end
modules
[
'
data-env
'
]
=
{
2
version
=
1
.
001
,
3
comment
=
"
companion to luat-lib.mkiv
"
,
4
author
=
"
Hans Hagen, PRAGMA-ADE, Hasselt NL
"
,
5
copyright
=
"
PRAGMA ADE / ConTeXt Development Team
"
,
6
license
=
"
see context related readme files
"
,
7
}
8 9
local
lower
,
gsub
=
string
.
lower
,
string
.
gsub
10
local
next
,
rawget
=
next
,
rawget
11 12
local
resolvers
=
resolvers
13 14
local
allocate
=
utilities
.
storage
.
allocate
15
local
setmetatableindex
=
table
.
setmetatableindex
16
local
suffixonly
=
file
.
suffixonly
17 18
local
formats
=
allocate
(
)
19
local
suffixes
=
allocate
(
)
20
local
dangerous
=
allocate
(
)
21
local
suffixmap
=
allocate
(
)
22
local
usertypes
=
allocate
(
)
23 24
resolvers
.
formats
=
formats
25
resolvers
.
suffixes
=
suffixes
26
resolvers
.
dangerous
=
dangerous
27
resolvers
.
suffixmap
=
suffixmap
28
resolvers
.
usertypes
=
usertypes
29 30
local
luasuffixes
=
utilities
.
lua
.
suffixes
31 32
local
relations
=
allocate
{
-- todo: handlers also here
33
core
=
{
34
ofm
=
{
-- will become obsolete
35
names
=
{
"
ofm
"
,
"
omega font metric
"
,
"
omega font metrics
"
}
,
36
variable
=
'
OFMFONTS
'
,
37
suffixes
=
{
'
ofm
'
,
'
tfm
'
}
,
38
}
,
39
ovf
=
{
-- will become obsolete
40
names
=
{
"
ovf
"
,
"
omega virtual font
"
,
"
omega virtual fonts
"
}
,
41
variable
=
'
OVFFONTS
'
,
42
suffixes
=
{
'
ovf
'
,
'
vf
'
}
,
43
}
,
44
tfm
=
{
45
names
=
{
"
tfm
"
,
"
tex font metric
"
,
"
tex font metrics
"
}
,
46
variable
=
'
TFMFONTS
'
,
47
suffixes
=
{
'
tfm
'
}
,
48
}
,
49
vf
=
{
50
names
=
{
"
vf
"
,
"
virtual font
"
,
"
virtual fonts
"
}
,
51
variable
=
'
VFFONTS
'
,
52
suffixes
=
{
'
vf
'
}
,
53
}
,
54
otf
=
{
55
names
=
{
"
otf
"
,
"
opentype
"
,
"
opentype font
"
,
"
opentype fonts
"
}
,
56
variable
=
'
OPENTYPEFONTS
'
,
57
suffixes
=
{
'
otf
'
}
,
58
}
,
59
ttf
=
{
60
names
=
{
"
ttf
"
,
"
truetype
"
,
"
truetype font
"
,
"
truetype fonts
"
,
"
truetype collection
"
,
"
truetype collections
"
,
"
truetype dictionary
"
,
"
truetype dictionaries
"
}
,
61
variable
=
'
TTFONTS
'
,
62
suffixes
=
{
'
ttf
'
,
'
ttc
'
,
'
dfont
'
}
,
63
}
,
64
afm
=
{
65
names
=
{
"
afm
"
,
"
adobe font metric
"
,
"
adobe font metrics
"
}
,
66
variable
=
"
AFMFONTS
"
,
67
suffixes
=
{
"
afm
"
}
,
68
}
,
69
pfb
=
{
70
names
=
{
"
pfb
"
,
"
type1
"
,
"
type 1
"
,
"
type1 font
"
,
"
type 1 font
"
,
"
type1 fonts
"
,
"
type 1 fonts
"
}
,
71
variable
=
'
T1FONTS
'
,
72
suffixes
=
{
'
pfb
'
,
'
pfa
'
}
,
73
}
,
74
fea
=
{
75
names
=
{
"
fea
"
,
"
font feature
"
,
"
font features
"
,
"
font feature file
"
,
"
font feature files
"
}
,
76
variable
=
'
FONTFEATURES
'
,
77
suffixes
=
{
'
fea
'
}
,
78
}
,
79
cid
=
{
80
names
=
{
"
cid
"
,
"
cid map
"
,
"
cid maps
"
,
"
cid file
"
,
"
cid files
"
}
,
81
variable
=
'
FONTCIDMAPS
'
,
82
suffixes
=
{
'
cid
'
,
'
cidmap
'
}
,
83
}
,
84
fmt
=
{
85
names
=
{
"
fmt
"
,
"
format
"
,
"
tex format
"
}
,
86
variable
=
'
TEXFORMATS
'
,
87
suffixes
=
{
'
fmt
'
}
,
88
}
,
89
mem
=
{
-- will become obsolete
90
names
=
{
'
mem
'
,
"
metapost format
"
}
,
91
variable
=
'
MPMEMS
'
,
92
suffixes
=
{
'
mem
'
}
,
93
}
,
94
mp
=
{
95
names
=
{
"
mp
"
}
,
96
variable
=
'
MPINPUTS
'
,
97
suffixes
=
{
'
mp
'
,
'
mpvi
'
,
'
mpiv
'
,
'
mpxl
'
,
'
mpii
'
}
,
98
usertype
=
true
,
99
}
,
100
tex
=
{
101
names
=
{
"
tex
"
}
,
102
variable
=
'
TEXINPUTS
'
,
103
suffixes
=
{
"
tex
"
,
"
mkiv
"
,
"
mkvi
"
,
"
mkxl
"
,
"
mklx
"
,
"
mkii
"
,
"
cld
"
,
"
lfg
"
,
"
xml
"
}
,
-- known suffixes have less lookups
104
usertype
=
true
,
105
}
,
106
icc
=
{
107
names
=
{
"
icc
"
,
"
icc profile
"
,
"
icc profiles
"
}
,
108
variable
=
'
ICCPROFILES
'
,
109
suffixes
=
{
'
icc
'
}
,
110
}
,
111
texmfscripts
=
{
112
names
=
{
"
texmfscript
"
,
"
texmfscripts
"
,
"
script
"
,
"
scripts
"
}
,
113
variable
=
'
TEXMFSCRIPTS
'
,
114
suffixes
=
{
'
lua
'
,
'
rb
'
,
'
pl
'
,
'
py
'
}
,
115
}
,
116
lua
=
{
117
names
=
{
"
lua
"
}
,
118
variable
=
'
LUAINPUTS
'
,
119
suffixes
=
{
luasuffixes
.
lua
,
luasuffixes
.
luc
,
luasuffixes
.
tma
,
luasuffixes
.
tmc
}
,
120
usertype
=
true
,
121
}
,
122
lib
=
{
123
names
=
{
"
lib
"
}
,
124
variable
=
'
CLUAINPUTS
'
,
125
suffixes
=
os
.
libsuffix
and
{
os
.
libsuffix
}
or
{
'
dll
'
,
'
so
'
}
,
126
}
,
127
bib
=
{
128
names
=
{
'
bib
'
}
,
129
variable
=
'
BIBINPUTS
'
,
130
suffixes
=
{
'
bib
'
}
,
131
usertype
=
true
,
132
}
,
133
bst
=
{
134
names
=
{
'
bst
'
}
,
135
variable
=
'
BSTINPUTS
'
,
136
suffixes
=
{
'
bst
'
}
,
137
usertype
=
true
,
138
}
,
139
fontconfig
=
{
140
names
=
{
'
fontconfig
'
,
'
fontconfig file
'
,
'
fontconfig files
'
}
,
141
variable
=
'
FONTCONFIG_PATH
'
,
142
}
,
143
pk
=
{
144
names
=
{
"
pk
"
}
,
145
variable
=
'
PKFONTS
'
,
146
suffixes
=
{
'
pk
'
}
,
147
}
,
148
}
,
149
obsolete
=
{
150
enc
=
{
151
names
=
{
"
enc
"
,
"
enc files
"
,
"
enc file
"
,
"
encoding files
"
,
"
encoding file
"
}
,
152
variable
=
'
ENCFONTS
'
,
153
suffixes
=
{
'
enc
'
}
,
154
}
,
155
map
=
{
156
names
=
{
"
map
"
,
"
map files
"
,
"
map file
"
}
,
157
variable
=
'
TEXFONTMAPS
'
,
158
suffixes
=
{
'
map
'
}
,
159
}
,
160
lig
=
{
161
names
=
{
"
lig files
"
,
"
lig file
"
,
"
ligature file
"
,
"
ligature files
"
}
,
162
variable
=
'
LIGFONTS
'
,
163
suffixes
=
{
'
lig
'
}
,
164
}
,
165
opl
=
{
166
names
=
{
"
opl
"
}
,
167
variable
=
'
OPLFONTS
'
,
168
suffixes
=
{
'
opl
'
}
,
169
}
,
170
ovp
=
{
171
names
=
{
"
ovp
"
}
,
172
variable
=
'
OVPFONTS
'
,
173
suffixes
=
{
'
ovp
'
}
,
174
}
,
175
}
,
176
kpse
=
{
-- subset
177
base
=
{
178
names
=
{
'
base
'
,
"
metafont format
"
}
,
179
variable
=
'
MFBASES
'
,
180
suffixes
=
{
'
base
'
,
'
bas
'
}
,
181
}
,
182
cmap
=
{
183
names
=
{
'
cmap
'
,
'
cmap files
'
,
'
cmap file
'
}
,
184
variable
=
'
CMAPFONTS
'
,
185
suffixes
=
{
'
cmap
'
}
,
186
}
,
187
cnf
=
{
188
names
=
{
'
cnf
'
}
,
189
suffixes
=
{
'
cnf
'
}
,
190
}
,
191
web
=
{
192
names
=
{
'
web
'
}
,
193
suffixes
=
{
'
web
'
,
'
ch
'
}
194
}
,
195
cweb
=
{
196
names
=
{
'
cweb
'
}
,
197
suffixes
=
{
'
w
'
,
'
web
'
,
'
ch
'
}
,
198
}
,
199
gf
=
{
200
names
=
{
'
gf
'
}
,
201
suffixes
=
{
'
<resolution>gf
'
}
,
202
}
,
203
mf
=
{
204
names
=
{
'
mf
'
}
,
205
variable
=
'
MFINPUTS
'
,
206
suffixes
=
{
'
mf
'
}
,
207
}
,
208
mft
=
{
209
names
=
{
'
mft
'
}
,
210
suffixes
=
{
'
mft
'
}
,
211
}
,
212
pk
=
{
213
names
=
{
'
pk
'
}
,
214
suffixes
=
{
'
<resolution>pk
'
}
,
215
}
,
216
}
,
217
}
218 219
resolvers
.
relations
=
relations
220 221
-- formats: maps a format onto a variable
222 223
function
resolvers
.
updaterelations
(
)
224
for
category
,
categories
in
next
,
relations
do
225
for
name
,
relation
in
next
,
categories
do
226
local
rn
=
relation
.
names
227
local
rv
=
relation
.
variable
228
if
rn
and
rv
then
229
local
rs
=
relation
.
suffixes
230
local
ru
=
relation
.
usertype
231
for
i
=
1
,
#
rn
do
232
local
rni
=
lower
(
gsub
(
rn
[
i
]
,
"
"
,
"
"
)
)
233
formats
[
rni
]
=
rv
234
if
rs
then
235
suffixes
[
rni
]
=
rs
236
for
i
=
1
,
#
rs
do
237
local
rsi
=
rs
[
i
]
238
suffixmap
[
rsi
]
=
rni
239
end
240
end
241
end
242
if
ru
then
243
usertypes
[
name
]
=
true
244
end
245
end
246
end
247
end
248
end
249 250
resolvers
.
updaterelations
(
)
-- push this in the metatable -> newindex
251 252
local
function
simplified
(
t
,
k
)
253
return
k
and
rawget
(
t
,
lower
(
gsub
(
k
,
"
"
,
"
"
)
)
)
or
nil
254
end
255 256
setmetatableindex
(
formats
,
simplified
)
257
setmetatableindex
(
suffixes
,
simplified
)
258
setmetatableindex
(
suffixmap
,
simplified
)
259 260
-- A few accessors, mostly for command line tool.
261 262
function
resolvers
.
suffixofformat
(
str
)
263
local
s
=
suffixes
[
str
]
264
return
s
and
s
[
1
]
or
"
"
265
end
266 267
function
resolvers
.
suffixofformat
(
str
)
268
return
suffixes
[
str
]
or
{
}
269
end
270 271
for
name
,
format
in
next
,
formats
do
272
dangerous
[
name
]
=
true
-- still needed ?
273
end
274 275
-- because vf searching is somewhat dangerous, we want to prevent
276
-- too liberal searching esp because we do a lookup on the current
277
-- path anyway; only tex (or any) is safe
278 279
dangerous
.
tex
=
nil
280 281
--~ print(table.serialize(dangerous))
282 283
-- more helpers
284 285
function
resolvers
.
formatofvariable
(
str
)
286
return
formats
[
str
]
or
'
'
287
end
288 289
function
resolvers
.
formatofsuffix
(
str
)
-- of file
290
return
suffixmap
[
suffixonly
(
str
)
]
or
'
tex
'
-- so many map onto tex (like mkiv, cld etc)
291
end
292 293
function
resolvers
.
variableofformat
(
str
)
294
return
formats
[
str
]
or
'
'
295
end
296 297
function
resolvers
.
variableofformatorsuffix
(
str
)
298
local
v
=
formats
[
str
]
299
if
v
then
300
return
v
301
end
302
v
=
suffixmap
[
suffixonly
(
str
)
]
303
if
v
then
304
return
formats
[
v
]
305
end
306
return
'
'
307
end
308 309