lpdf-eng.lua /size: 3018 b    last modification: 2020-07-01 14:35
1
if
not
modules
then
modules
=
{
}
end
modules
[
'
lpdf-eng
'
]
=
{
2
version
=
1
.
001
,
3
comment
=
"
companion to lpdf-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
-- Here we plug in the regular luatex image handler. The low level module itself
10
-- is hidden from the user.
11 12
local
codeinjections
=
backends
.
pdf
.
codeinjections
13
local
imgnew
=
img
.
new
14 15
function
codeinjections
.
newimage
(
specification
)
16
if
type
(
specification
)
=
=
"
table
"
then
17
specification
.
kind
=
nil
18
end
19
return
imgnew
(
specification
)
20
end
21 22
codeinjections
.
copyimage
=
img
.
copy
23
codeinjections
.
scanimage
=
img
.
scan
24
codeinjections
.
embedimage
=
img
.
immediatewrite
25
codeinjections
.
wrapimage
=
img
.
node
26 27
-- We cannot nil the img table because the backend code explicitly accesses the
28
-- new field when dealing with virtual characters. I should patch luatex for that
29
-- and maybe I will. So no:
30
--
31
-- img = nil
32
--
33
-- We keep the low level img.new function but make the rest kind of unseen. At some
34
-- point the other ones will be gone and one has to use the images.* wrappers.
35 36
local
unpack
=
unpack
37
local
sortedkeys
=
table
.
sortedkeys
38
local
context
=
context
39 40
img
=
table
.
setmetatableindex
(
41
{
42
new
=
images
.
create
,
43
}
,
44
{
45
-- new = images.create,
46
scan
=
images
.
scan
,
47
copy
=
images
.
copy
,
48
node
=
images
.
wrap
,
49
write
=
function
(
specification
)
context
(
images
.
wrap
(
specification
)
)
end
,
50
immediatewrite
=
images
.
embed
,
51
immediatewriteobject
=
function
(
)
end
,
-- not upported, experimental anyway
52
boxes
=
function
(
)
return
sortedkeys
(
images
.
sizes
)
end
,
53
fields
=
function
(
)
return
images
.
keys
end
,
54
types
=
function
(
)
return
{
unpack
(
images
.
types
,
0
,
#
images
.
types
)
}
end
,
55
}
56
)
57 58
--
59 60
do
61 62
local
function
prepare
(
driver
)
63
if
not
environment
.
initex
then
64
-- install new functions in pdf namespace
65
updaters
.
apply
(
"
backend.update.pdf
"
)
66
-- install new functions in lpdf namespace
67
updaters
.
apply
(
"
backend.update.lpdf
"
)
68
-- adapt existing shortcuts to lpdf namespace
69
updaters
.
apply
(
"
backend.update.tex
"
)
70
-- adapt existing shortcuts to tex namespace
71
updaters
.
apply
(
"
backend.update
"
)
72
--
73
end
74
end
75 76
local
function
outputfilename
(
driver
)
77
if
not
filename
then
78
filename
=
addsuffix
(
tex
.
jobname
,
"
pdf
"
)
79
end
80
return
filename
81
end
82 83
drivers
.
install
{
84
name
=
"
pdf
"
,
85
flushers
=
{
86
-- nothing here
87
}
,
88
actions
=
{
89
convert
=
drivers
.
converters
.
engine
,
90
outputfilename
=
outputfilename
,
91
prepare
=
prepare
,
92
}
,
93
}
94 95
end
96 97