summaryrefslogtreecommitdiff
path: root/tex/context/base/mlib-pdf.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mlib-pdf.lua')
-rw-r--r--tex/context/base/mlib-pdf.lua77
1 files changed, 10 insertions, 67 deletions
diff --git a/tex/context/base/mlib-pdf.lua b/tex/context/base/mlib-pdf.lua
index d5f22cd7e..963309951 100644
--- a/tex/context/base/mlib-pdf.lua
+++ b/tex/context/base/mlib-pdf.lua
@@ -10,9 +10,8 @@ if not modules then modules = { } end modules ['mlib-pdf'] = {
local format, concat, gsub = string.format, table.concat, string.gsub
local abs, sqrt, round = math.abs, math.sqrt, math.round
-local setmetatable, rawset, tostring, tonumber, type = setmetatable, rawset, tostring, tonumber, type
-local P, S, C, Ct, Cc, Cg, Cf, Carg = lpeg.P, lpeg.S, lpeg.C, lpeg.Ct, lpeg.Cc, lpeg.Cg, lpeg.Cf, lpeg.Carg
-local lpegmatch = lpeg.match
+local setmetatable = setmetatable
+local Cf, C, Cg, Ct, P, S, lpegmatch = lpeg.Cf, lpeg.C, lpeg.Cg, lpeg.Ct, lpeg.P, lpeg.S, lpeg.match
local formatters = string.formatters
local report_metapost = logs.reporter("metapost")
@@ -31,12 +30,13 @@ metapost.flushers = metapost.flushers or { }
local pdfflusher = { }
metapost.flushers.pdf = pdfflusher
-metapost.multipass = false -- to be stacked
+metapost.multipass = false
metapost.n = 0
-metapost.optimize = true -- false
+metapost.optimize = true -- false
local experiment = true -- uses context(node) that already does delayed nodes
-local savedliterals = nil -- needs checking
+
+local savedliterals = nil -- needs checking
local mpsliteral = nodes.pool.register(node.new("whatsit",nodes.whatsitcodes.pdfliteral)) -- pdfliteral.mode = 1
local pdfliteral = function(s)
@@ -268,48 +268,7 @@ metapost.flushnormalpath = flushnormalpath
-- performance penalty, but so is passing extra arguments (result, flusher, after)
-- and returning stuff.
-local ignore = function () end
-
-local space = P(" ")
-local equal = P("=")
-local key = C((1-equal)^1) * equal
-local newline = S("\n\r")^1
-local number = (((1-space-newline)^1) / tonumber) * (space^0)
-local variable =
- lpeg.P("1:") * key * number
- + lpeg.P("2:") * key * C((1-newline)^0)
- + lpeg.P("3:") * key * (P("false") * Cc(false) + P("true") * Cc(true))
- + lpeg.S("4568") * P(":") * key * Ct(number^1)
- + lpeg.P("7:") * key * Ct(Ct(number * number^-5)^1)
-
-local pattern = Cf ( Carg(1) * (Cg(variable * newline^0)^0), rawset)
-
-metapost.variables = { } -- to be stacked
-metapost.llx = 0 -- to be stacked
-metapost.lly = 0 -- to be stacked
-metapost.urx = 0 -- to be stacked
-metapost.ury = 0 -- to be stacked
-
-function commands.mprunvar(key,n)
- local value = metapost.variables[key]
- if value ~= nil then
- local tvalue = type(value)
- if tvalue == "table" then
- local ntype = type(n)
- if ntype == "number" then
- context(value[n])
- elseif ntype == "string" then
- context(concat(value,n))
- else
- context(concat(value," "))
- end
- elseif tvalue == "number" or tvalue == "boolean" then
- context(tostring(value))
- elseif tvalue == "string" then
- context(value)
- end
- end
-end
+local function ignore() end
function metapost.flush(result,flusher,askedfig)
if result then
@@ -324,29 +283,15 @@ function metapost.flush(result,flusher,askedfig)
local stopfigure = flusher.stopfigure
local flushfigure = flusher.flushfigure
local textfigure = flusher.textfigure
- for f=1,#figures do
+ for f=1, #figures do
local figure = figures[f]
local objects = getobjects(result,figure,f)
- local fignum = figure:charcode() or 0
+ local fignum = figure:charcode() or 0
if askedfig == "direct" or askedfig == "all" or askedfig == fignum then
local t = { }
local miterlimit, linecap, linejoin, dashed = -1, -1, -1, false
local bbox = figure:boundingbox()
local llx, lly, urx, ury = bbox[1], bbox[2], bbox[3], bbox[4]
- local variables = { }
- metapost.variables = variables
- metapost.properties = {
- llx = llx,
- lly = lly,
- urx = urx,
- ury = ury,
- slot = figure:charcode(),
- width = figure:width(),
- height = figure:height(),
- depth = figure:depth(),
- italic = figure:italcorr(),
- }
- -- replaced by the above
metapost.llx = llx
metapost.lly = lly
metapost.urx = urx
@@ -363,10 +308,8 @@ function metapost.flush(result,flusher,askedfig)
for o=1,#objects do
local object = objects[o]
local objecttype = object.type
- if objecttype == "start_bounds" or objecttype == "stop_bounds" then
+ if objecttype == "start_bounds" or objecttype == "stop_bounds" or objecttype == "special" then
-- skip
- elseif objecttype == "special" then
- lpegmatch(pattern,object.prescript,1,variables)
elseif objecttype == "start_clip" then
t[#t+1] = "q"
flushnormalpath(object.path,t,false)