summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luamplib
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-01-06 23:23:06 +0000
committerKarl Berry <karl@freefriends.org>2015-01-06 23:23:06 +0000
commit74e692423a7de7dd8025088ba676249e85443d9e (patch)
tree5c8d663c16667e533edbd602cf6096505ebb5c82 /Master/texmf-dist/tex/luatex/luamplib
parentd9c7d6c59e9daf56e5fda7f969e0d6e90146d8d3 (diff)
luamplib (6jan15)
git-svn-id: svn://tug.org/texlive/trunk@35974 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luamplib')
-rw-r--r--Master/texmf-dist/tex/luatex/luamplib/luamplib.lua38
-rw-r--r--Master/texmf-dist/tex/luatex/luamplib/luamplib.sty12
2 files changed, 33 insertions, 17 deletions
diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
index df329392c0b..3f9a7e7a904 100644
--- a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
+++ b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
@@ -18,8 +18,8 @@ luamplib.lastlog = ""
local err, warn, info, log = luatexbase.provides_module({
name = "luamplib",
- version = "2.8.1",
- date = "2014/07/04",
+ version = "2.9.0",
+ date = "2015/01/05",
description = "Lua package to typeset Metapost with LuaTeX's MPLib.",
})
@@ -323,6 +323,10 @@ else
math_mode = luamplib.numbersystem,
random_seed = randomseed,
}
+ local preamble = preamble .. luamplib.mplibcodepreamble
+ if luamplib.textextlabel then
+ preamble = preamble .. luamplib.textextlabelpreamble
+ end
local result
if not mpx then
result = { status = 99, error = "out of memory"}
@@ -361,7 +365,6 @@ end
local function process_indeed (mpx, data, indeed)
local converted, result = false, {}
- local mpx = luamplib.load(mpx)
if mpx and data then
result = mpx:execute(data)
local log = luamplib.reporterror(result)
@@ -382,11 +385,20 @@ local function process_indeed (mpx, data, indeed)
end
return converted, result
end
+
+luamplib.codeinherit = false
+local mplibinstances = {}
local process = function (data,indeed)
- if not indeed then
- randomseed = math.random(65535)
+ local standalone, firstpass = not luamplib.codeinherit, not indeed
+ local currfmt = currentformat .. luamplib.numbersystem
+ currfmt = firstpass and currfmt or (currfmt.."2")
+ local mpx = mplibinstances[currfmt]
+ if standalone or not mpx then
+ randomseed = firstpass and math.random(65535) or randomseed
+ mpx = luamplib.load(currentformat)
+ mplibinstances[currfmt] = mpx
end
- return process_indeed(currentformat, data, indeed)
+ return process_indeed(mpx, data, indeed)
end
luamplib.process = process
@@ -588,6 +600,7 @@ let VerbatimTeX = specialVerbatimTeX;
extra_beginfig := extra_beginfig & " let VerbatimTeX = ignoreVerbatimTeX;" ;
extra_endfig := extra_endfig & " let VerbatimTeX = specialVerbatimTeX;" ;
]]
+luamplib.mplibcodepreamble = mplibcodepreamble
local textextlabelpreamble = [[
primarydef s infont f = rawtextext(s) enddef;
@@ -600,6 +613,7 @@ def fontsize expr f =
endgroup
enddef;
]]
+luamplib.textextlabelpreamble = textextlabelpreamble
local function protecttextext(data)
local everymplib = tex.toks['everymplibtoks'] or ''
@@ -690,11 +704,7 @@ local function makeTEXboxes (data)
data = stringgsub(data, "!!!!!LEFTBRCE!!!!!","{")
data = stringgsub(data, "!!!!!RGHTBRCE!!!!!","}")
data = stringgsub(data, "!!!!!SHARPE!!!!!", "#" )
- local preamble = mplibcodepreamble
- if luamplib.textextlabel then
- preamble = preamble .. textextlabelpreamble
- end
- local _,result = process(preamble .. data, false)
+ local _,result = process(data, false)
domakeTEXboxes(result)
return data
end
@@ -718,11 +728,7 @@ local function processwithTEXboxes (data)
num, box.height/factor,
num, box.depth /factor)
end
- local preamble = prepreamble .. mplibcodepreamble
- if luamplib.textextlabel then
- preamble = preamble .. textextlabelpreamble
- end
- process(preamble .. data, true)
+ process(prepreamble .. data, true)
end
luamplib.processwithTEXboxes = processwithTEXboxes
diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty
index ffee72280ff..60744698c6a 100644
--- a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty
+++ b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty
@@ -14,7 +14,7 @@
\else
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{luamplib}
- [2014/07/04 v2.8.1 mplib package for LuaTeX]
+ [2015/01/05 v2.9.0 mplib package for LuaTeX]
\RequirePackage{luatexbase-modutils}
\fi
\RequireLuaModule{luamplib}
@@ -168,6 +168,16 @@
\fi
\endgroup
}
+\def\mplibcodeinherit#1{%
+ \begingroup
+ \def\tempa{enable}\def\tempb{#1}%
+ \ifx\tempa\tempb
+ \directlua{luamplib.codeinherit = true}%
+ \else
+ \directlua{luamplib.codeinherit = false}%
+ \fi
+ \endgroup
+}
\ifx\mplibscratchbox\undefined \newbox\mplibscratchbox \fi
\def\mplibstarttoPDF#1#2#3#4{%
\hbox\bgroup