summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luamplib/luamplib.lua')
-rw-r--r--Master/texmf-dist/tex/luatex/luamplib/luamplib.lua46
1 files changed, 24 insertions, 22 deletions
diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
index 9cae3851d65..db75e0d90c0 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 = ""
luatexbase.provides_module {
name = "luamplib",
- version = "2.11.1",
- date = "2015/10/02",
+ version = "2.11.2",
+ date = "2016/01/02",
description = "Lua package to typeset Metapost with LuaTeX's MPLib.",
}
@@ -40,7 +40,6 @@ local texsprint = tex.sprint
local textprint = tex.tprint
local texget = tex.get
-local texset = tex.set
local texgettoks = tex.gettoks
local texgetbox = tex.getbox
@@ -769,7 +768,8 @@ local function processwithTEXboxes (data)
end
luamplib.processwithTEXboxes = processwithTEXboxes
-local pdfmode = texget("pdfoutput") > 0 and true or false
+local pdfoutput = tonumber(texget("outputmode")) or tonumber(texget("pdfoutput"))
+local pdfmode = pdfoutput > 0
local function start_pdf_code()
if pdfmode then
@@ -812,8 +812,13 @@ local function putTEXboxes (object,prescript)
end
local pdf_objs = {}
+local token, getpageres, setpageres = newtoken or token
+local pgf = { bye = "pgfutil@everybye", extgs = "pgf@sys@addpdfresource@extgs@plain" }
-if not pdfmode then
+if pdfmode then -- repect luaotfload-colors
+ getpageres = pdf.getpageresources or function() return pdf.pageresources end
+ setpageres = pdf.setpageresources or function(s) pdf.pageresources = s end
+else
texsprint("\\special{pdf:obj @MPlibTr<<>>}",
"\\special{pdf:obj @MPlibSh<<>>}")
end
@@ -842,8 +847,6 @@ local transparancy_modes = { [0] = "Normal",
"Compatible",
}
-local pgf_loaded
-
local function update_tr_res(res,mode,opaq)
local os = format("<</BM /%s/ca %.3f/CA %.3f/AIS false>>",mode,opaq,opaq)
local on, new = update_pdfobjs(os)
@@ -851,8 +854,8 @@ local function update_tr_res(res,mode,opaq)
if pdfmode then
res = format("%s/MPlibTr%i %i 0 R",res,on,on)
else
- if pgf_loaded then
- texsprint(format("\\csname pgf@sys@addpdfresource@extgs@plain\\endcsname{/MPlibTr%i%s}",on,os))
+ if pgf.loaded then
+ texsprint(format("\\csname %s\\endcsname{/MPlibTr%i%s}", pgf.extgs, on, os))
else
texsprint(format("\\special{pdf:put @MPlibTr<</MPlibTr%i%s>>}",on,os))
end
@@ -862,27 +865,28 @@ local function update_tr_res(res,mode,opaq)
end
local function tr_pdf_pageresources(mode,opaq)
- pgf_loaded = pgf_loaded or (newtoken and newtoken.create("pgfutil@everybye").cmdname == "assign_toks")
+ if token and pgf.bye and not pgf.loaded then
+ pgf.loaded = token.create(pgf.bye).cmdname == "assign_toks"
+ pgf.bye = pgf.loaded and pgf.bye
+ end
local res, on_on, off_on = "", nil, nil
res, off_on = update_tr_res(res, "Normal", 1)
res, on_on = update_tr_res(res, mode, opaq)
if pdfmode then
if res ~= "" then
- local tpr = texget("pdfpageresources") -- respect luaotfload-colors
- local no_extgs = not stringfind(tpr,"/ExtGState<<.*>>")
- local pgf_pdf_loaded = no_extgs and pgf_loaded
- if pgf_pdf_loaded then
- texsprint(format("\\csname pgf@sys@addpdfresource@extgs@plain\\endcsname{%s}",res))
+ if pgf.loaded then
+ texsprint(format("\\csname %s\\endcsname{%s}", pgf.extgs, res))
else
- if no_extgs then
- tpr = tpr.."/ExtGState<<>>"
+ local tpr, n = getpageres() or "", 0
+ tpr, n = tpr:gsub("/ExtGState<<", "%1"..res)
+ if n == 0 then
+ tpr = format("%s/ExtGState<<%s>>", tpr, res)
end
- tpr = tpr:gsub("/ExtGState<<","%1"..res)
- texset("global","pdfpageresources",tpr)
+ setpageres(tpr)
end
end
else
- if not pgf_loaded then
+ if not pgf.loaded then
texsprint(format("\\special{pdf:put @resources<</ExtGState @MPlibTr>>}"))
end
end
@@ -890,8 +894,6 @@ local function tr_pdf_pageresources(mode,opaq)
end
local shading_res
-local getpageres = pdf.getpageresources or function() return pdf.pageresources end
-local setpageres = pdf.setpageresources or function(s) pdf.pageresources = s end
local function shading_initialize ()
shading_res = {}