summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/lpdf-eng.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/lpdf-eng.lua')
-rw-r--r--tex/context/base/mkiv/lpdf-eng.lua106
1 files changed, 106 insertions, 0 deletions
diff --git a/tex/context/base/mkiv/lpdf-eng.lua b/tex/context/base/mkiv/lpdf-eng.lua
new file mode 100644
index 000000000..6f2e75c46
--- /dev/null
+++ b/tex/context/base/mkiv/lpdf-eng.lua
@@ -0,0 +1,106 @@
+if not modules then modules = { } end modules ['lpdf-eng'] = {
+ version = 1.001,
+ comment = "companion to lpdf-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+if CONTEXTLMTXMODE > 0 then
+ return
+end
+
+-- Here we plug in the regular luatex image handler. The low level module itself
+-- is hidden from the user.
+
+local codeinjections = backends.pdf.codeinjections
+local imgnew = img.new
+
+function codeinjections.newimage(specification)
+ if type(specification) == "table" then
+ specification.kind = nil
+ end
+ return imgnew(specification)
+end
+
+codeinjections.copyimage = img.copy
+codeinjections.scanimage = img.scan
+codeinjections.embedimage = img.immediatewrite
+codeinjections.wrapimage = img.node
+
+-- We cannot nil the img table because the backend code explicitly accesses the
+-- new field when dealing with virtual characters. I should patch luatex for that
+-- and maybe I will. So no:
+--
+-- img = nil
+--
+-- We keep the low level img.new function but make the rest kind of unseen. At some
+-- point the other ones will be gone and one has to use the images.* wrappers.
+
+local unpack = unpack
+local sortedkeys = table.sortedkeys
+local context = context
+
+img = table.setmetatableindex (
+ {
+ new = images.create,
+ },
+ {
+ -- new = images.create,
+ scan = images.scan,
+ copy = images.copy,
+ node = images.wrap,
+ write = function(specification) context(images.wrap(specification)) end,
+ immediatewrite = images.embed,
+ immediatewriteobject = function() end, -- not upported, experimental anyway
+ boxes = function() return sortedkeys(images.sizes) end,
+ fields = function() return images.keys end,
+ types = function() return { unpack(images.types,0,#images.types) } end,
+ }
+)
+
+--
+
+do
+
+ local function prepare()
+ if not environment.initex then
+ -- install new functions in pdf namespace
+ updaters.apply("backend.update.pdf")
+ -- install new functions in lpdf namespace
+ updaters.apply("backend.update.lpdf")
+ -- adapt existing shortcuts to lpdf namespace
+ updaters.apply("backend.update.tex")
+ -- adapt existing shortcuts to tex namespace
+ updaters.apply("backend.update")
+ --
+ end
+ end
+
+ local function outputfilename()
+ if not filename then
+ filename = addsuffix(tex.jobname,"pdf")
+ end
+ return filename
+ end
+
+ function lpdf.flushers()
+ return { }
+ end
+
+ function lpdf.actions()
+ return {
+ convert = tex.shipout,
+ outputfilename = outputfilename,
+ prepare = prepare,
+ }
+ end
+
+ drivers.install {
+ name = "pdf",
+ flushers = lpdf.flushers(),
+ actions = lpdf.actions(),
+ }
+
+end
+