summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/context/luatex-mplib.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/context/luatex-mplib.lua')
-rw-r--r--Master/texmf-dist/tex/generic/context/luatex-mplib.lua86
1 files changed, 54 insertions, 32 deletions
diff --git a/Master/texmf-dist/tex/generic/context/luatex-mplib.lua b/Master/texmf-dist/tex/generic/context/luatex-mplib.lua
index 0afad083ac2..c6628acb3b8 100644
--- a/Master/texmf-dist/tex/generic/context/luatex-mplib.lua
+++ b/Master/texmf-dist/tex/generic/context/luatex-mplib.lua
@@ -1,4 +1,4 @@
-if not modules then modules = { } end modules ['supp-mpl'] = {
+if not modules then modules = { } end modules ['luatex-mplib'] = {
version = 1.001,
comment = "companion to luatex-mplib.tex",
author = "Hans Hagen & Taco Hoekwater",
@@ -25,7 +25,7 @@ else
local format, concat, abs, match = string.format, table.concat, math.abs, string.match
local mplib = require ('mplib')
- local kpse = require ('kpse')
+ local kpse = require ('kpse')
--[[ldx--
<p>We create a namespace and some variables to it. If a namespace is
@@ -93,11 +93,11 @@ else
metapost.lastlog = ""
end
- metapost.make = metapost.make or function(name,mem_name,dump)
- if false then
- metapost.report("no format %s made for %s",mem_name,name)
- return false
- else
+ local mplibone = tonumber(mplib.version()) <= 1.50
+
+ if mplibone then
+
+ metapost.make = metapost.make or function(name,mem_name,dump)
local t = os.clock()
local mpx = mplib.new {
ini_version = true,
@@ -113,25 +113,52 @@ else
end
return mpx
end
- end
- function metapost.load(name)
- local mem_name = file.replacesuffix(name,"mem")
- local mpx = mplib.new {
- ini_version = false,
- mem_name = mem_name,
- find_file = metapost.finder
- }
- if not mpx and type(metapost.make) == "function" then
- -- when i have time i'll locate the format and dump
- mpx = metapost.make(name,mem_name)
+ function metapost.load(name)
+ local mem_name = file.replacesuffix(name,"mem")
+ local mpx = mplib.new {
+ ini_version = false,
+ mem_name = mem_name,
+ find_file = metapost.finder
+ }
+ if not mpx and type(metapost.make) == "function" then
+ -- when i have time i'll locate the format and dump
+ mpx = metapost.make(name,mem_name)
+ end
+ if mpx then
+ metapost.report("using format %s",mem_name,false)
+ return mpx, nil
+ else
+ return nil, { status = 99, error = "out of memory or invalid format" }
+ end
end
- if mpx then
- metapost.report("using format %s",mem_name,false)
- return mpx, nil
- else
- return nil, { status = 99, error = "out of memory or invalid format" }
+
+ else
+
+ local preamble = [[
+ boolean mplib ; mplib := true ;
+ let dump = endinput ;
+ input %s ;
+ ]]
+
+ metapost.make = metapost.make or function()
end
+
+ function metapost.load(name)
+ local mpx = mplib.new {
+ ini_version = true,
+ find_file = metapost.finder,
+ }
+ local result
+ if not mpx then
+ result = { status = 99, error = "out of memory"}
+ else
+ result = mpx:execute(format(preamble, file.replacesuffix(name,"mp")))
+ end
+ metapost.reporterror(result)
+ return mpx, result
+ end
+
end
function metapost.unload(mpx)
@@ -221,15 +248,10 @@ else
local rx, sx, sy, ry, tx, ty, divider = 1, 0, 0, 1, 0, 0, 1
local function pen_characteristics(object)
- if mplib.pen_info then
- local t = mplib.pen_info(object)
- rx, ry, sx, sy, tx, ty = t.rx, t.ry, t.sx, t.sy, t.tx, t.ty
- divider = sx*sy - rx*ry
- return not (sx==1 and rx==0 and ry==0 and sy==1 and tx==0 and ty==0), t.width
- else
- rx, sx, sy, ry, tx, ty, divider = 1, 0, 0, 1, 0, 0, 1
- return false, 1
- end
+ local t = mplib.pen_info(object)
+ rx, ry, sx, sy, tx, ty = t.rx, t.ry, t.sx, t.sy, t.tx, t.ty
+ divider = sx*sy - rx*ry
+ return not (sx==1 and rx==0 and ry==0 and sy==1 and tx==0 and ty==0), t.width
end
local function concat(px, py) -- no tx, ty here