summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luamplib
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-01-08 00:06:05 +0000
committerKarl Berry <karl@freefriends.org>2016-01-08 00:06:05 +0000
commitc93aadda1a0628b25e0c02305d42ea4330d51d91 (patch)
tree63b5754e28b4030536115b3231561d4693081585 /Master/texmf-dist/tex/luatex/luamplib
parent4ed56a2178d1e7438de5fe9a4f9cd9adc59dea8c (diff)
luamplib (6jan16)
git-svn-id: svn://tug.org/texlive/trunk@39312 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luamplib')
-rw-r--r--Master/texmf-dist/tex/luatex/luamplib/luamplib.lua46
-rw-r--r--Master/texmf-dist/tex/luatex/luamplib/luamplib.sty31
2 files changed, 44 insertions, 33 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 = {}
diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty
index be09b7aa3a1..3cfeb24912b 100644
--- a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty
+++ b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty
@@ -10,16 +10,25 @@
%%
\bgroup\expandafter\expandafter\expandafter\egroup
\expandafter\ifx\csname selectfont\endcsname\relax
- \input luatexbase-modutils.sty
+ \input ltluatex
\else
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{luamplib}
- [2015/10/02 v2.11.1 mplib package for LuaTeX]
- \RequirePackage{luatexbase-modutils}
+ [2016/01/02 v2.11.2 mplib package for LuaTeX]
+ \ifx\newluafunction\@undefined
+ \input ltluatex
+ \fi
+\fi
+\directlua{require("luamplib")}
+\ifx\scantextokens\undefined
+ \let\scantextokens\luatexscantextokens
+\fi
+\ifx\pdfoutput\undefined
+ \let\pdfoutput\outputmode
+ \protected\def\pdfliteral{\pdfextension literal}
\fi
-\RequireLuaModule{luamplib}
-\def\mplibsetformat#1{%
- \directlua{luamplib.setformat("\luatexluaescapestring{#1}")}}
+
+\def\mplibsetformat#1{\directlua{luamplib.setformat("#1")}}
\ifnum\pdfoutput>0
\let\mplibtoPDF\pdfliteral
\else
@@ -27,9 +36,9 @@
\ifcsname PackageWarning\endcsname
\PackageWarning{luamplib}{take dvipdfmx path, no support for other dvi tools currently.}
\else
- \write16{}
- \write16{luamplib Warning: take dvipdfmx path, no support for other dvi tools currently.}
- \write16{}
+ \write128{}
+ \write128{luamplib Warning: take dvipdfmx path, no support for other dvi tools currently.}
+ \write128{}
\fi
\fi
\def\mplibsetupcatcodes{%
@@ -44,13 +53,13 @@
\def\mplibreplacenewlinebr{%
\begingroup \mplibpostmpcatcodes \mplibdoreplacenewlinebr}
\begingroup\lccode`\~=`\^^M \lowercase{\endgroup
- \def\mplibdoreplacenewlinebr#1^^J{\endgroup\luatexscantextokens{{}#1~}}}
+ \def\mplibdoreplacenewlinebr#1^^J{\endgroup\scantextokens{{}#1~}}}
\bgroup\expandafter\expandafter\expandafter\egroup
\expandafter\ifx\csname selectfont\endcsname\relax
\def\mplibreplacenewlinecs{%
\begingroup \mplibpostmpcatcodes \mplibdoreplacenewlinecs}
\begingroup\lccode`\~=`\^^M \lowercase{\endgroup
- \def\mplibdoreplacenewlinecs#1^^J{\endgroup\luatexscantextokens{\relax#1~}}}
+ \def\mplibdoreplacenewlinecs#1^^J{\endgroup\scantextokens{\relax#1~}}}
\def\mplibcode{%
\mplibstartlineno\inputlineno
\begingroup