summaryrefslogtreecommitdiff
path: root/tex/context/base/lpdf-nod.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/lpdf-nod.lua')
-rw-r--r--tex/context/base/lpdf-nod.lua41
1 files changed, 33 insertions, 8 deletions
diff --git a/tex/context/base/lpdf-nod.lua b/tex/context/base/lpdf-nod.lua
index 184e9cff7..fe0c975f7 100644
--- a/tex/context/base/lpdf-nod.lua
+++ b/tex/context/base/lpdf-nod.lua
@@ -6,17 +6,24 @@ if not modules then modules = { } end modules ['lpdf-nod'] = {
license = "see context related readme files"
}
-local copy_node = node.copy
-local new_node = node.new
+local format = string.format
-local nodepool = nodes.pool
-local register = nodepool.register
+local copy_node = node.copy
+local new_node = node.new
-local pdfliteral = register(new_node("whatsit", 8)) pdfliteral.mode = 1
-local pdfdest = register(new_node("whatsit",19)) pdfdest.named_id = 1 -- xyz_zoom untouched
-local pdfannot = register(new_node("whatsit",15))
+local nodepool = nodes.pool
+local register = nodepool.register
+local whatsitcodes = nodes.whatsitcodes
+local nodeinjections = backends.nodeinjections
-local variables = interfaces.variables
+local pdfliteral = register(new_node("whatsit", whatsitcodes.pdfliteral)) pdfliteral.mode = 1
+local pdfsave = register(new_node("whatsit", whatsitcodes.pdfsave))
+local pdfrestore = register(new_node("whatsit", whatsitcodes.pdfrestore))
+local pdfsetmatrix = register(new_node("whatsit", whatsitcodes.pdfsetmatrix))
+local pdfdest = register(new_node("whatsit", whatsitcodes.pdfdest)) pdfdest.named_id = 1 -- xyz_zoom untouched
+local pdfannot = register(new_node("whatsit", whatsitcodes.pdfannot))
+
+local variables = interfaces.variables
local views = { -- beware, we do support the pdf keys but this is *not* official
xyz = 0, [variables.standard] = 0,
@@ -42,6 +49,24 @@ function nodepool.pdfdirect(str)
return t
end
+function nodepool.pdfsave()
+ return copy_node(pdfsave)
+end
+
+function nodepool.pdfrestore()
+ return copy_node(pdfrestore)
+end
+
+function nodepool.pdfsetmatrix(rx,sx,sy,ry,tx,ty)
+ local t = copy_node(pdfsetmatrix)
+ t.data = format("%s %s %s %s",rs or 0,sx or 0,sy or 0,rx or 0) -- todo: tx ty
+ return t
+end
+
+nodeinjections.save = nodepool.pdfsave
+nodeinjections.restore = nodepool.pdfrestore
+nodeinjections.transform = nodepool.pdfsetmatrix
+
function nodepool.pdfannotation(w,h,d,data,n)
local t = copy_node(pdfannot)
if w and w ~= 0 then t.width = w end