summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luamplib
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-12-19 22:50:05 +0000
committerKarl Berry <karl@freefriends.org>2013-12-19 22:50:05 +0000
commite79024c0c4b136036ad806dc3f848b5e388fdbf3 (patch)
tree158495cd8c96909130b92cca8b9a92cd06a9bd08 /Master/texmf-dist/tex/luatex/luamplib
parent0eeb8fd7c5fc267ce00c5e410b6f8335dad303c8 (diff)
luamplib (19dec13)
git-svn-id: svn://tug.org/texlive/trunk@32451 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luamplib')
-rw-r--r--Master/texmf-dist/tex/luatex/luamplib/luamplib.lua81
-rw-r--r--Master/texmf-dist/tex/luatex/luamplib/luamplib.sty4
2 files changed, 53 insertions, 32 deletions
diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
index 4969538ec15..fe8c03cc1a9 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.03,
- date = "2013/12/11",
+ version = 2.1,
+ date = "2013/12/19",
description = "Lua package to typeset Metapost with LuaTeX's MPLib.",
})
@@ -315,23 +315,27 @@ def textext (expr t) =
image( special "%%mkTEXbox:"&t; )
enddef;
let TEX = textext;
+def VerbatimTeX (text t) = enddef;
]]
local mplibcodepreamblesecond = [[
-vardef textext (expr t) =
- TEXBOX := TEXBOX + 1;
+vardef textext (text t) =
+ TEXBOX_ := TEXBOX_ + 1;
image (
addto currentpicture doublepath unitsquare
- xscaled TEXBOXwd[TEXBOX]
- yscaled (TEXBOXht[TEXBOX] + TEXBOXdp[TEXBOX])
- shifted (0, -TEXBOXdp[TEXBOX])
+ xscaled TEXBOX_wd[TEXBOX_]
+ yscaled (TEXBOX_ht[TEXBOX_] + TEXBOX_dp[TEXBOX_])
+ shifted (0, -TEXBOX_dp[TEXBOX_])
withprescript "%%TEXtxtbox:" &
- decimal TEXBOX & ":" &
- decimal TEXBOXwd[TEXBOX] & ":" &
- decimal(TEXBOXht[TEXBOX]+TEXBOXdp[TEXBOX]);
-)
+ decimal TEXBOX_ & ":" &
+ decimal TEXBOX_wd[TEXBOX_] & ":" &
+ decimal(TEXBOX_ht[TEXBOX_]+TEXBOX_dp[TEXBOX_]);
+ )
+enddef;
+def TEX (text t) = textext (t) enddef;
+def VerbatimTeX (text t) =
+ message "verbatimtex '"& t &"' is ignored";
enddef;
-def TEX (expr t) = textext (t) enddef;
]]
local factor = 65536*(7227/7200)
@@ -347,7 +351,12 @@ local function putTEXboxes (object)
local rx, ry = (second.y_coord - ty)/tw, (fourth.x_coord - tx)/th
if sx == 0 then sx = 0.00001 end
if sy == 0 then sy = 0.00001 end
+ local cs = object.color
+ if cs and #cs > 0 then
+ cs = luamplib.colorconverter(cs)
+ end
pdf_literalcode("q %f %f %f %f %f %f cm",sx,rx,ry,sy,tx,ty)
+ if cs then pdf_literalcode(cs) end
texsprint(format("\\mplibputtextbox{%i}",n))
pdf_literalcode("Q")
end
@@ -364,12 +373,10 @@ local function domakeTEXboxes (data)
for o=1,#objects do
local object = objects[o]
local prescript = object.prescript
- if prescript and stringfind(prescript,"%%%%mkTEXbox:") then
+ local str = prescript and stringmatch(prescript, "%%%%mkTEXbox:(.*)")
+ if str then
num = num + 1
- stringgsub(prescript, "%%%%mkTEXbox:(.+)",
- function(str)
- texsprint(format("\\setbox%i\\hbox{%s}",num,str))
- end)
+ texsprint(format("\\setbox%i\\hbox{%s}",num,str))
end
end
end
@@ -378,10 +385,20 @@ local function domakeTEXboxes (data)
end
local function makeTEXboxes (data)
- data = stringgsub(data,"(%A)btex(%A.-%A)etex(%A)",
- function(pre,texcode,post)
- texcode = stringgsub(texcode,"^%s*(.-)%s*$","%1")
- return pre .. "textext(\"" .. texcode .. "\")" .. post
+ data = stringgsub(data, "([^A-Z_a-z])btex([^A-Z_a-z])",
+ function(pre,post)
+ post = stringgsub(post,"%s","")
+ return pre .. 'textext("' .. post
+ end)
+ data = stringgsub(data, "([^A-Z_a-z])verbatimtex([^A-Z_a-z])",
+ function(pre,post)
+ post = stringgsub(post,"%s","")
+ return pre .. 'VerbatimTeX("' .. post
+ end)
+ data = stringgsub(data, "([^A-Z_a-z])etex([^A-Z_a-z])",
+ function(pre,post)
+ pre = stringgsub(pre,"%s","")
+ return pre .. '")' .. post
end)
local mpx = luamplib.load(currentformat)
if mpx and data then
@@ -395,16 +412,15 @@ luamplib.makeTEXboxes = makeTEXboxes
local function processwithTEXboxes (data)
local num = tex.count[14] -- the same newbox register
- local prepreamble = "numeric TEXBOX, TEXBOXwd[], TEXBOXht[], TEXBOXdp[];\n"..
- "TEXBOX := "..num..";\n"
+ local prepreamble = "TEXBOX_ := "..num..";\n"
while true do
num = num + 1
local box = tex.box[num]
if not box then break end
prepreamble = prepreamble ..
- "TEXBOXwd["..num.."] := "..box.width/factor ..";\n"..
- "TEXBOXht["..num.."] := "..box.height/factor..";\n"..
- "TEXBOXdp["..num.."] := "..box.depth /factor..";\n"
+ "TEXBOX_wd["..num.."] := "..box.width /factor..";\n"..
+ "TEXBOX_ht["..num.."] := "..box.height/factor..";\n"..
+ "TEXBOX_dp["..num.."] := "..box.depth /factor..";\n"
end
process(prepreamble .. mplibcodepreamblesecond .. data)
end
@@ -451,16 +467,19 @@ local function flush(result,flusher)
-- not supported
elseif objecttype == "text" then
local ot = object.transform -- 3,4,5,6,1,2
+ local cs = object.color
+ if cs and #cs > 0 then
+ cs = luamplib.colorconverter(cs)
+ end
pdf_literalcode("q %f %f %f %f %f %f cm",ot[3],ot[4],ot[5],ot[6],ot[1],ot[2])
+ if cs then pdf_literalcode(cs) end
pdf_textfigure(object.font,object.dsize,object.text,object.width,object.height,object.depth)
pdf_literalcode("Q")
else
- local cs = object.color
- local cr = nil
+ local cs, cr = object.color, nil
if cs and #cs > 0 then
- local start,stop = luamplib.colorconverter(cs)
- pdf_literalcode(start)
- cr = stop
+ cs, cr = luamplib.colorconverter(cs)
+ pdf_literalcode(cs)
end
local ml = object.miterlimit
if ml and ml ~= miterlimit then
diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty
index ea377e7e895..ceff5edcddb 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}
- [2013/12/11 v2.03 mplib package for LuaTeX]
+ [2013/12/19 v2.1 mplib package for LuaTeX]
\RequirePackage{luatexbase-modutils}
\RequirePackage{pdftexcmds}
\fi
@@ -44,6 +44,7 @@
\bgroup\expandafter\expandafter\expandafter\egroup
\expandafter\ifx\csname ProvidesPackage\endcsname\relax
\def\mplibcode{%
+ \begingroup
\bgroup
\mplibsetupcatcodes
\mplibdocode %
@@ -56,6 +57,7 @@
\directlua{
luamplib.processwithTEXboxes(luamplib.tempdata)
}%
+ \endgroup
}
\else
\newenvironment{mplibcode}{\toks@{}\ltxdomplibcode}{}