font-vfc.lua /size: 2667 b    last modification: 2020-07-01 14:35
1
if
not
modules
then
modules
=
{
}
end
modules
[
'
font-vfc
'
]
=
{
2
version
=
1
.
001
,
3
comment
=
"
companion to font-ini.mkiv and hand-ini.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
select
,
type
=
select
,
type
10
local
insert
=
table
.
insert
11 12
local
fonts
=
fonts
13
local
helpers
=
fonts
.
helpers
14 15
local
setmetatableindex
=
table
.
setmetatableindex
16
local
makeweak
=
table
.
makeweak
17 18
-- Helpers dealing with virtual fonts: beware, these are final values so
19
-- don't change the content of tables gotten this way!
20 21
local
push
=
{
"
push
"
}
22
local
pop
=
{
"
pop
"
}
23
local
dummy
=
{
"
comment
"
}
24 25
function
helpers
.
prependcommands
(
commands
,
...
)
26
insert
(
commands
,
1
,
push
)
27
for
i
=
select
(
"
#
"
,
...
)
,
1
,
-1
do
28
local
s
=
(
select
(
i
,
...
)
)
29
if
s
then
30
insert
(
commands
,
1
,
s
)
31
end
32
end
33
insert
(
commands
,
pop
)
34
return
commands
35
end
36 37
function
helpers
.
appendcommands
(
commands
,
...
)
38
insert
(
commands
,
1
,
push
)
39
insert
(
commands
,
pop
)
40
for
i
=
1
,
select
(
"
#
"
,
...
)
do
41
local
s
=
(
select
(
i
,
...
)
)
42
if
s
then
43
insert
(
commands
,
s
)
44
end
45
end
46
return
commands
47
end
48 49
function
helpers
.
prependcommandtable
(
commands
,
t
)
50
insert
(
commands
,
1
,
push
)
51
for
i
=
#
t
,
1
,
-1
do
52
local
s
=
t
[
i
]
53
if
s
then
54
insert
(
commands
,
1
,
s
)
55
end
56
end
57
insert
(
commands
,
pop
)
58
return
commands
59
end
60 61
function
helpers
.
appendcommandtable
(
commands
,
t
)
62
insert
(
commands
,
1
,
push
)
63
insert
(
commands
,
pop
)
64
for
i
=
1
,
#
t
do
65
local
s
=
t
[
i
]
66
if
s
then
67
insert
(
commands
,
s
)
68
end
69
end
70
return
commands
71
end
72 73
-- todo: maybe weak
74
-- todo: maybe indirect so that we can't change them
75 76
local
char
=
setmetatableindex
(
function
(
t
,
k
)
77
-- local v = { "char", k }
78
local
v
=
{
"
slot
"
,
0
,
k
}
79
t
[
k
]
=
v
80
return
v
81
end
)
82 83
local
right
=
setmetatableindex
(
function
(
t
,
k
)
84
local
v
=
{
"
right
"
,
k
}
85
t
[
k
]
=
v
86
return
v
87
end
)
88 89
local
left
=
setmetatableindex
(
function
(
t
,
k
)
90
local
v
=
{
"
right
"
,
-
k
}
91
t
[
k
]
=
v
92
return
v
93
end
)
94 95
local
down
=
setmetatableindex
(
function
(
t
,
k
)
96
local
v
=
{
"
down
"
,
k
}
97
t
[
k
]
=
v
98
return
v
99
end
)
100 101
local
up
=
setmetatableindex
(
function
(
t
,
k
)
102
local
v
=
{
"
down
"
,
-
k
}
103
t
[
k
]
=
v
104
return
v
105
end
)
106 107
-- makeweak(char)
108
-- makeweak(right)
109
-- makeweak(left)
110
-- makeweak(up)
111
-- makeweak(down)
112 113
helpers
.
commands
=
utilities
.
storage
.
allocate
{
114
char
=
char
,
115
right
=
right
,
116
left
=
left
,
117
down
=
down
,
118
up
=
up
,
119
push
=
push
,
120
pop
=
pop
,
121
dummy
=
dummy
,
122
}
123 124