summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-03-28 21:33:39 +0000
committerKarl Berry <karl@freefriends.org>2014-03-28 21:33:39 +0000
commit643a275222a3d5c712cd0259d6c9a8e92de6d543 (patch)
tree807b59c997038f80d79e4eec5c6562e2dbc6a7db /Master/texmf-dist/tex
parent46aa657c376559aa9bab5ca73a107a4f243100b0 (diff)
luamplib (28mar14)
git-svn-id: svn://tug.org/texlive/trunk@33316 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/luatex/luamplib/luamplib.lua70
-rw-r--r--Master/texmf-dist/tex/luatex/luamplib/luamplib.sty12
2 files changed, 47 insertions, 35 deletions
diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
index a247ac12958..f3d5fd3b4d5 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.6.0",
- date = "2014/03/08",
+ version = "2.6.1",
+ date = "2014/03/26",
description = "Lua package to typeset Metapost with LuaTeX's MPLib.",
})
@@ -336,21 +336,28 @@ local function process_indeed (mpx, data)
local converted, result = false, {}
local mpx = luamplib.load(mpx)
if mpx and data then
- local result = mpx:execute(data)
- if not result then
- err("no result object returned")
- elseif result.status > 0 then
- err("%s",(result.term or "no-term") .. "\n" .. (result.error or "no-error"))
+ local result = mpx:execute(data)
+ if not result then
+ err("no result object returned")
+ else
+ local term = stringgsub(result.term or "no-term","^%s+","\n")
+ if result.status > 0 then
+ err("%s",term .. "\n" .. (result.error or ""))
elseif luamplib.showlog then
- luamplib.lastlog = luamplib.lastlog .. "\n" .. result.term
- info("%s",result.term or "no-term")
- elseif result.fig then
- converted = luamplib.convert(result)
+ luamplib.lastlog = luamplib.lastlog .. "\n" .. term
+ info("%s",luamplib.lastlog)
+ luamplib.resetlastlog()
else
- err("unknown error, maybe no beginfig/endfig")
+ if stringfind(term,"\n>>") then info("%s",term) end
+ if result.fig then
+ converted = luamplib.convert(result)
+ else
+ warn("No figure output. Maybe no beginfig/endfig")
+ end
end
+ end
else
- err("Mem file unloadable. Maybe generated with a different version of mplib?")
+ err("Mem file unloadable. Maybe generated with a different version of mplib?")
end
return converted, result
end
@@ -723,18 +730,18 @@ local transparancy_modes = { [0] = "Normal",
}
local function update_tr_res(res,mode,opaq)
- local os = format("<</BM /%s/ca %g/CA %g/AIS false>>",mode,opaq,opaq)
+ local os = format("<</BM /%s/ca %.3f/CA %.3f/AIS false>>",mode,opaq,opaq)
local on, new = update_pdfobjs(os)
if new then
- res = res .. format("/MPlibTr%s%g %i 0 R",mode,opaq,on)
+ res = res .. format("/MPlibTr%i %i 0 R",on,on)
end
- return res
+ return res,on
end
local function tr_pdf_pageresources(mode,opaq)
- local res = ""
- res = update_tr_res(res, "Normal", 1)
- res = update_tr_res(res, mode, opaq)
+ 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 res ~= "" then
local tpr = tex.pdfpageresources -- respect luaotfload-colors
if not stringfind(tpr,"/ExtGState<<.*>>") then
@@ -743,6 +750,7 @@ local function tr_pdf_pageresources(mode,opaq)
tpr = stringgsub(tpr,"/ExtGState<<","%1"..res)
tex.set("global","pdfpageresources",tpr)
end
+ return on_on, off_on
end
-- luatexbase.mcb is not yet updated: "finish_pdffile" callback is missing
@@ -782,11 +790,12 @@ end
local function do_preobj_color(object,prescript)
-- transparency
local opaq = prescript and prescript.tr_transparency
+ local tron_no, troff_no
if opaq then
local mode = prescript.tr_alternative or 1
mode = transparancy_modes[tonumber(mode)]
- tr_pdf_pageresources(mode,opaq)
- pdf_literalcode("/MPlibTr%s%g gs",mode,opaq)
+ tron_no, troff_no = tr_pdf_pageresources(mode,opaq)
+ pdf_literalcode("/MPlibTr%i gs",tron_no)
end
-- color
local cs = object.color
@@ -801,6 +810,11 @@ local function do_preobj_color(object,prescript)
local centerb = prescript.sh_center_b
local colora = prescript.sh_color_a or {0};
local colorb = prescript.sh_color_b or {1};
+ for _,t in pairs({colora,colorb}) do
+ for i,v in ipairs(t) do
+ t[i] = format("%.3f",v)
+ end
+ end
if #colora > #colorb then
color_normalize(colora,colorb)
elseif #colorb > #colora then
@@ -810,7 +824,7 @@ local function do_preobj_color(object,prescript)
if #colorb == 1 then colorspace = "DeviceGray"
elseif #colorb == 3 then colorspace = "DeviceRGB"
elseif #colorb == 4 then colorspace = "DeviceCMYK"
- else return opaq
+ else return troff_no
end
colora = tableconcat(colora, " ")
colorb = tableconcat(colorb, " ")
@@ -825,9 +839,9 @@ local function do_preobj_color(object,prescript)
shade_no = sh_pdfpageresources(3,domain,colorspace,colora,colorb,coordinates)
end
pdf_literalcode("q /Pattern cs")
- return opaq,shade_no
+ return troff_no,shade_no
end
- return opaq
+ return troff_no
end
local function do_postobj_color(tr,sh)
@@ -835,7 +849,7 @@ local function do_postobj_color(tr,sh)
pdf_literalcode("W n /MPlibSh%s sh Q",sh)
end
if tr then
- pdf_literalcode("/MPlibTrNormal1 gs")
+ pdf_literalcode("/MPlibTr%i gs",tr)
end
end
@@ -995,13 +1009,13 @@ local function colorconverter(cr)
local n = #cr
if n == 4 then
local c, m, y, k = cr[1], cr[2], cr[3], cr[4]
- return format("%.3g %.3g %.3g %.3g k %.3g %.3g %.3g %.3g K",c,m,y,k,c,m,y,k), "0 g 0 G"
+ return format("%.3f %.3f %.3f %.3f k %.3f %.3f %.3f %.3f K",c,m,y,k,c,m,y,k), "0 g 0 G"
elseif n == 3 then
local r, g, b = cr[1], cr[2], cr[3]
- return format("%.3g %.3g %.3g rg %.3g %.3g %.3g RG",r,g,b,r,g,b), "0 g 0 G"
+ return format("%.3f %.3f %.3f rg %.3f %.3f %.3f RG",r,g,b,r,g,b), "0 g 0 G"
else
local s = cr[1]
- return format("%.3g g %.3g G",s,s), "0 g 0 G"
+ return format("%.3f g %.3f G",s,s), "0 g 0 G"
end
end
luamplib.colorconverter = colorconverter
diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty
index 7d09685e809..d230e3b503a 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/03/08 v2.6.0 mplib package for LuaTeX]
+ [2014/03/26 v2.6.1 mplib package for LuaTeX]
\RequirePackage{luatexbase-modutils}
\RequirePackage{pdftexcmds}
\fi
@@ -45,16 +45,14 @@
\catcode`\{=12 \catcode`\}=12 \catcode`\#=12 \catcode`\%=12 }
\def\mplibreplacenewlinebr{%
\begingroup \mplibpostmpcatcodes \mplibdoreplacenewlinebr}
-\begingroup\lccode`\~=`\^^M \lowercase{%
- \gdef\mplibdoreplacenewlinebr#1^^J{\endgroup\luatexscantextokens{{}#1~}}}
-\endgroup
+\begingroup\lccode`\~=`\^^M \lowercase{\endgroup
+ \def\mplibdoreplacenewlinebr#1^^J{\endgroup\luatexscantextokens{{}#1~}}}
\bgroup\expandafter\expandafter\expandafter\egroup
\expandafter\ifx\csname ProvidesPackage\endcsname\relax
\def\mplibreplacenewlinecs{%
\begingroup \mplibpostmpcatcodes \mplibdoreplacenewlinecs}
-\begingroup\lccode`\~=`\^^M \lowercase{%
- \gdef\mplibdoreplacenewlinecs#1^^J{\endgroup\luatexscantextokens{\relax#1~}}}
-\endgroup
+\begingroup\lccode`\~=`\^^M \lowercase{\endgroup
+ \def\mplibdoreplacenewlinecs#1^^J{\endgroup\luatexscantextokens{\relax#1~}}}
\def\mplibcode{%
\mplibstartlineno\inputlineno
\begingroup