summaryrefslogtreecommitdiff
path: root/Master
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
parent46aa657c376559aa9bab5ca73a107a4f243100b0 (diff)
luamplib (28mar14)
git-svn-id: svn://tug.org/texlive/trunk@33316 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/luatex/luamplib/NEWS8
-rw-r--r--Master/texmf-dist/doc/luatex/luamplib/luamplib.pdfbin128882 -> 129549 bytes
-rw-r--r--Master/texmf-dist/source/luatex/luamplib/luamplib.dtx92
-rw-r--r--Master/texmf-dist/tex/luatex/luamplib/luamplib.lua70
-rw-r--r--Master/texmf-dist/tex/luatex/luamplib/luamplib.sty12
5 files changed, 110 insertions, 72 deletions
diff --git a/Master/texmf-dist/doc/luatex/luamplib/NEWS b/Master/texmf-dist/doc/luatex/luamplib/NEWS
index 0ddf1a479df..7eee2c333bc 100644
--- a/Master/texmf-dist/doc/luatex/luamplib/NEWS
+++ b/Master/texmf-dist/doc/luatex/luamplib/NEWS
@@ -1,5 +1,13 @@
History of the luamplib package
+2014/03/26 2.6.1
+ * now luamplib does not disregard 'show' command, even if
+ 'luamplib.showlog' is false. Incidentally, it does not raise
+ error, but just prints a warning, even if output contains
+ no figure.
+ * fix a bug wrt color, which might come to the fore under
+ math mode 'double' or 'decimal'.
+
2014/03/08 2.6.0
* new macro \mplibtextextlabel{enable} enables string labels typeset
with textext() instead of infont operator. Every string label
diff --git a/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf b/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf
index 34b39af74d1..59a5d474f17 100644
--- a/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf
+++ b/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx b/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx
index 860f3f8c5ce..b233fae02ec 100644
--- a/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx
+++ b/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx
@@ -85,7 +85,7 @@ See source file '\inFileName' for licencing and contact information.
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{luamplib.drv}%
- [2014/03/08 v2.6.0 Interface for using the mplib library]%
+ [2014/03/26 v2.6.1 Interface for using the mplib library]%
\documentclass{ltxdoc}
\usepackage{metalogo,multicol,mdwlist,fancyvrb,xspace}
\usepackage[x11names]{xcolor}
@@ -154,7 +154,7 @@ See source file '\inFileName' for licencing and contact information.
% \author{Hans Hagen, Taco Hoekwater, Elie Roux, Philipp Gesang and Kim Dohyun\\
% Maintainer: LuaLaTeX Maintainers ---
% Support: \email{lualatex-dev@tug.org}}
-% \date{2014/03/08 v2.6.0}
+% \date{2014/03/26 v2.6.1}
%
% \maketitle
%
@@ -319,8 +319,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.",
})
@@ -681,21 +681,34 @@ 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")
+% \end{macrocode}
+% v2.6.1: now luamplib does not disregard |show| command,
+% even when |luamplib.showlog| is false. Incidentally,
+% it does not raise error, but just prints a warning,
+% even if output has no figure.
+% \begin{macrocode}
+ 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
@@ -1093,18 +1106,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
@@ -1113,6 +1126,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
@@ -1152,11 +1166,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
@@ -1171,6 +1186,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
@@ -1180,7 +1200,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, " ")
@@ -1195,9 +1215,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)
@@ -1205,7 +1225,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
@@ -1390,13 +1410,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
@@ -1421,7 +1441,7 @@ luamplib.colorconverter = colorconverter
\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
@@ -1473,9 +1493,8 @@ luamplib.colorconverter = colorconverter
\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~}}}
% \end{macrocode}
%
% The Plain-specific stuff.
@@ -1485,9 +1504,8 @@ luamplib.colorconverter = colorconverter
\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
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