summaryrefslogtreecommitdiff
path: root/Master/texmf-dist
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r--Master/texmf-dist/doc/luatex/luamplib/NEWS7
-rw-r--r--Master/texmf-dist/doc/luatex/luamplib/luamplib.pdfbin126379 -> 128882 bytes
-rw-r--r--Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex6
-rw-r--r--Master/texmf-dist/doc/luatex/luamplib/test-luamplib-plain.tex6
-rw-r--r--Master/texmf-dist/source/luatex/luamplib/luamplib.dtx216
-rw-r--r--Master/texmf-dist/tex/luatex/luamplib/luamplib.lua182
-rw-r--r--Master/texmf-dist/tex/luatex/luamplib/luamplib.sty12
7 files changed, 266 insertions, 163 deletions
diff --git a/Master/texmf-dist/doc/luatex/luamplib/NEWS b/Master/texmf-dist/doc/luatex/luamplib/NEWS
index 24e92825cf4..0ddf1a479df 100644
--- a/Master/texmf-dist/doc/luatex/luamplib/NEWS
+++ b/Master/texmf-dist/doc/luatex/luamplib/NEWS
@@ -1,5 +1,12 @@
History of the luamplib package
+2014/03/08 2.6.0
+ * new macro \mplibtextextlabel{enable} enables string labels typeset
+ with textext() instead of infont operator. Every string label
+ thereafter will be typeset with current TeX font.
+ * fixed a bug wrt btex ... etex parsing (issue #39)
+ * [doc] added a mention about \MPllx, \MPlly, \MPurx, and \MPury.
+
2014/03/01 2.5.3
* using \mplibcachedir{<directory path>}, users can change the
directory for storing cache files. By default, it is the directory
diff --git a/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf b/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf
index 0676a222cdf..34b39af74d1 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/doc/luatex/luamplib/test-luamplib-latex.tex b/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex
index 3708916fe51..84ef88c4149 100644
--- a/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex
+++ b/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex
@@ -114,4 +114,10 @@ endfig;
endgraph;
endfig;
\end{mplibcode}%
+\mplibtextextlabel{enable}%
+\begin{mplibcode}
+beginfig(0);
+dotlabel.rt("$\sqrt2$",origin);
+endfig;
+\end{mplibcode}%
\end{document}
diff --git a/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-plain.tex b/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-plain.tex
index ee5a5231d54..c679a18a960 100644
--- a/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-plain.tex
+++ b/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-plain.tex
@@ -116,4 +116,10 @@ endfig;
endgraph;
endfig;
\endmplibcode
+\mplibtextextlabel{enable}%
+\mplibcode
+beginfig(0);
+dotlabel.rt("$\sqrt2$",origin);
+endfig;
+\endmplibcode
\bye
diff --git a/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx b/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx
index 0024de422f3..860f3f8c5ce 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/01 v2.5.3 Interface for using the mplib library]%
+ [2014/03/08 v2.6.0 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/01 v2.5.3}
+% \date{2014/03/08 v2.6.0}
%
% \maketitle
%
@@ -187,7 +187,7 @@ See source file '\inFileName' for licencing and contact information.
%
% \begin{itemize}
% \item a \LaTeX\ environment
-% \item all \TeX\ macros start by \texttt{mplib}
+% \item all \TeX\ macros start by |mplib|
% \item use of luatexbase for errors, warnings and declaration
% \item possibility to use |btex ... etex| to typeset \TeX\ code.
% |textext()| is a more versatile macro equivalent to |TEX()| from TEX.mp.
@@ -215,6 +215,9 @@ See source file '\inFileName' for licencing and contact information.
% |verbatimtex ... etex|.
% \item Notice that, after each figure is processed, macro \cs{MPwidth} stores
% the width value of latest figure; \cs{MPheight}, the height value.
+% Incidentally, also note that \cs{MPllx}, \cs{MPlly}, \cs{MPurx}, and
+% \cs{MPury} store the bounding box information of latest figure
+% without the unit |bp|.
% \item Since v2.3, new macros \cs{everymplib} and \cs{everyendmplib} redefine
% token lists \cs{everymplibtoks} and \cs{everyendmplibtoks} respectively,
% which will
@@ -253,7 +256,7 @@ See source file '\inFileName' for licencing and contact information.
% \item To support |btex ... etex| in external |.mp| files, \textsf{luamplib}
% inspects the content of each and every |.mp| input files and makes caches
% if nececcsary, before returning their paths to \LuaTeX's mplib library.
-% This would make the compile time longer wastefully, as most |.mp| files
+% This would make the compilation time longer wastefully, as most |.mp| files
% do not contain |btex ... etex| command. So \textsf{luamplib} provides
% macros as follows, so that users can give instruction about files
% that do not require this functionality.
@@ -270,9 +273,18 @@ See source file '\inFileName' for licencing and contact information.
% as the user's home directory (on windows machines as well).
% As backslashes (|\|) should be escaped by users, it is easier to use
% slashes (|/|) instead.
+% \item Starting with v2.6, |\mplibtextextlabel{enable}| enables
+% string labels typeset via |textext()| instead of |infont| operator.
+% So, |label("my text",origin)| thereafter is exactly the same as
+% |label(textext("my text"),origin)|. \textsc{n.b.} In the background,
+% \textsf{luamplib} redefines |infont| operator so that the right side
+% argument (the font part) is totally ignored. Every string label
+% therefore will be typeset with current \TeX\ font.
+% Also take care of |char| operator in the left side argument,
+% as this might bring unpermitted characters into \TeX.
% \item At the end of package loading, \textsf{luamplib} searches
% |luamplib.cfg| and, if found, reads the file in automatically.
-% Frequently used settings such as |\everymplib| or |\mplibcachedir|
+% Frequently used settings such as \cs{everymplib} or \cs{mplibcachedir}
% are suitable for going into this file.
%
% \end{itemize}
@@ -307,8 +319,8 @@ luamplib.lastlog = ""
local err, warn, info, log = luatexbase.provides_module({
name = "luamplib",
- version = "2.5.3",
- date = "2014/03/01",
+ version = "2.6.0",
+ date = "2014/03/08",
description = "Lua package to typeset Metapost with LuaTeX's MPLib.",
})
@@ -325,6 +337,7 @@ local stringgsub = string.gsub
local stringfind = string.find
local stringmatch = string.match
local stringgmatch = string.gmatch
+local stringexplode = string.explode
local tableconcat = table.concat
local texsprint = tex.sprint
@@ -474,8 +487,8 @@ local function replaceinputmpfile (name,file)
local data = fh:read("*all"); fh:close()
data = stringgsub(data, "\"[^\n]-\"",
function(str)
- str = stringgsub(str,"%%","*****PERCENT*****")
- str = stringgsub(str,"([bem])tex%f[^A-Z_a-z]","%1***T***E***X***")
+ str = stringgsub(str,"%%","!!!!!PERCENT!!!!!")
+ str = stringgsub(str,"([bem])tex%f[^A-Z_a-z]","%1!!!T!!!E!!!X!!!")
return str
end)
data = stringgsub(data,"%%.-\n","")
@@ -501,14 +514,16 @@ local function replaceinputmpfile (name,file)
end
return file
end
- data = stringgsub(data,"([bem])***T***E***X***","%1tex")
- data = stringgsub(data,"*****PERCENT*****","%%")
+ data = stringgsub(data,"([bem])!!!T!!!E!!!X!!!","%1tex")
+ data = stringgsub(data,"!!!!!PERCENT!!!!!","%%")
fh = ioopen(newfile,"w")
if not fh then return file end
fh:write(data); fh:close()
lfstouch(newfile,currenttime,ofmodify)
return newfile
end
+
+local randomseed = nil
% \end{macrocode}
% As the finder function for |mplib|, use the |kpse| library and
% make it behave like as if MetaPost was used (or almost, since the engine
@@ -617,6 +632,7 @@ else
% See \url{https://github.com/lualatex/luamplib/issues/21}.
% \begin{macrocode}
math_mode = luamplib.numbersystem,
+ random_seed = randomseed,
}
local result
if not mpx then
@@ -832,72 +848,68 @@ local further_split_keys = {
}
local function script2table(s)
- local t = {}
- for i in stringgmatch(s,"[^\13]+") do
- local k,v = stringmatch(i,"(.-)=(.+)") -- v may contain =.
- if k and v then
- local vv = {}
- if further_split_keys[k] then
- for j in stringgmatch(v,"[^:]+") do
- vv[#vv+1] = j
- end
- end
- if #vv > 0 then
- t[k] = vv
- else
- t[k] = v
- end
- end
+ local t = {}
+ for _,i in ipairs(stringexplode(s,"\13+")) do
+ local k,v = stringmatch(i,"(.-)=(.*)") -- v may contain = or empty.
+ if k and v and k ~= "" then
+ if further_split_keys[k] then
+ t[k] = stringexplode(v,":")
+ else
+ t[k] = v
+ end
end
- return t
+ end
+ return t
end
local mplibcodepreamble = [[
vardef rawtextext (expr t) =
- if unknown TEXBOX_:
- image( special "MPlibmkTEXbox="&t; )
+ if unknown TEXBOX_:
+ image( special "MPlibmkTEXbox="&t; )
+ else:
+ TEXBOX_ := TEXBOX_ + 1;
+ if known TEXBOX_wd_[TEXBOX_]:
+ image ( addto currentpicture doublepath unitsquare
+ xscaled TEXBOX_wd_[TEXBOX_]
+ yscaled (TEXBOX_ht_[TEXBOX_] + TEXBOX_dp_[TEXBOX_])
+ shifted (0, -TEXBOX_dp_[TEXBOX_])
+ withprescript "MPlibTEXboxID=" &
+ decimal TEXBOX_ & ":" &
+ decimal TEXBOX_wd_[TEXBOX_] & ":" &
+ decimal(TEXBOX_ht_[TEXBOX_]+TEXBOX_dp_[TEXBOX_]); )
else:
- TEXBOX_ := TEXBOX_ + 1;
- image (
- addto currentpicture doublepath unitsquare
- xscaled TEXBOX_wd[TEXBOX_]
- yscaled (TEXBOX_ht[TEXBOX_] + TEXBOX_dp[TEXBOX_])
- shifted (0, -TEXBOX_dp[TEXBOX_])
- withprescript "MPlibTEXboxID=" &
- decimal TEXBOX_ & ":" &
- decimal TEXBOX_wd[TEXBOX_] & ":" &
- decimal(TEXBOX_ht[TEXBOX_]+TEXBOX_dp[TEXBOX_]);
- )
+ image( special "MPlibTEXError=1"; )
fi
+ fi
enddef;
if known context_mlib:
- defaultfont := "cmtt10";
- let infont = normalinfont;
- let fontsize = normalfontsize;
- vardef thelabel@#(expr p,z) =
- if string p :
- thelabel@#(p infont defaultfont scaled defaultscale,z)
- else :
- p shifted (z + labeloffset*mfun_laboff@# -
- (mfun_labxf@#*lrcorner p + mfun_labyf@#*ulcorner p +
- (1-mfun_labxf@#-mfun_labyf@#)*llcorner p))
- fi
- enddef;
- def graphictext primary filename =
- if (readfrom filename = EOF):
- errmessage "Please prepare '"&filename&"' in advance with command"&
- " 'pstoedit -ssp -dt -f mpost yourfile.ps "&filename&"'";
- fi
- closefrom filename;
- def data_mpy_file = filename enddef;
- mfun_do_graphic_text (filename)
- enddef;
- if unknown TEXBOX_: def mfun_do_graphic_text text t = enddef; fi
+ defaultfont := "cmtt10";
+ let infont = normalinfont;
+ let fontsize = normalfontsize;
+ vardef thelabel@#(expr p,z) =
+ if string p :
+ thelabel@#(p infont defaultfont scaled defaultscale,z)
+ else :
+ p shifted (z + labeloffset*mfun_laboff@# -
+ (mfun_labxf@#*lrcorner p + mfun_labyf@#*ulcorner p +
+ (1-mfun_labxf@#-mfun_labyf@#)*llcorner p))
+ fi
+ enddef;
+ def graphictext primary filename =
+ if (readfrom filename = EOF):
+ errmessage "Please prepare '"&filename&"' in advance with"&
+ " 'pstoedit -ssp -dt -f mpost yourfile.ps "&filename&"'";
+ fi
+ closefrom filename;
+ def data_mpy_file = filename enddef;
+ mfun_do_graphic_text (filename)
+ enddef;
+ if unknown TEXBOX_: def mfun_do_graphic_text text t = enddef; fi
else:
- vardef textext@# (text t) = rawtextext (t) enddef;
+ vardef textext@# (text t) = rawtextext (t) enddef;
fi
def externalfigure primary filename =
- draw rawtextext("\includegraphics{"& filename &"}")
+ draw rawtextext("\includegraphics{"& filename &"}")
enddef;
def TEX = textext enddef;
def fontmapfile primary filename = enddef;
@@ -908,6 +920,20 @@ extra_beginfig := extra_beginfig & " let VerbatimTeX = ignoreVerbatimTeX;" ;
extra_endfig := extra_endfig & " let VerbatimTeX = specialVerbatimTeX;" ;
]]
+local textextlabelpreamble = [[
+primarydef s infont f = rawtextext(s) enddef;
+let normalinfont = infont;
+def fontsize expr f =
+ begingroup
+ save size,pic; numeric size; picture pic;
+ pic := rawtextext("\hskip\pdffontsize\font");
+ size := xpart urcorner pic - xpart llcorner pic;
+ if size = 0: 10pt else: size fi
+ endgroup
+enddef;
+let normalfontsize = fontsize;
+]]
+
local function protecttextext(data)
local everymplib = tex.toks['everymplibtoks'] or ''
local everyendmplib = tex.toks['everyendmplibtoks'] or ''
@@ -915,8 +941,8 @@ local function protecttextext(data)
data = stringgsub(data,"\r","\n")
data = stringgsub(data, "\"[^\n]-\"",
function(str)
- str = stringgsub(str,"%%","****PERCENT****")
- str = stringgsub(str,"([bem])tex%f[^A-Z_a-z]","%1***T***E***X***")
+ str = stringgsub(str,"%%","!!!!!PERCENT!!!!!")
+ str = stringgsub(str,"([bem])tex%f[^A-Z_a-z]","%1!!!T!!!E!!!X!!!")
return str
end)
data = stringgsub(data,"%%.-\n","")
@@ -936,11 +962,11 @@ local function protecttextext(data)
end)
data = stringgsub(data, "\"[^\n]-\"",
function(str)
- str = stringgsub(str,"([bem])***T***E***X***","%1tex")
- str = stringgsub(str,"{", "****LEFTBRCE****")
- str = stringgsub(str,"}", "****RGHTBRCE****")
- str = stringgsub(str,"#", "****SHARPE****")
- return format("\\unexpanded{%s}",str)
+ str = stringgsub(str,"([bem])!!!T!!!E!!!X!!!","%1tex")
+ str = stringgsub(str,"{", "!!!!!LEFTBRCE!!!!!")
+ str = stringgsub(str,"}", "!!!!!RGHTBRCE!!!!!")
+ str = stringgsub(str,"#", "!!!!!SHARPE!!!!!")
+ return format("\\detokenize{%s}",str)
end)
texsprint(data)
end
@@ -950,7 +976,7 @@ luamplib.protecttextext = protecttextext
local TeX_code_t = {}
local function domakeTEXboxes (data)
- local num = tex.count[14] -- newbox register
+ local num = 255 -- output box
if data and data.fig then
local figures = data.fig
for f=1, #figures do
@@ -983,13 +1009,18 @@ end
local function makeTEXboxes (data)
data = stringgsub(data, "##", "#") -- restore # doubled in input string
- data = stringgsub(data, "****PERCENT****", "%%")
- data = stringgsub(data, "****LEFTBRCE****","{")
- data = stringgsub(data, "****RGHTBRCE****","}")
- data = stringgsub(data, "****SHARPE****", "#" )
+ data = stringgsub(data, "!!!!!PERCENT!!!!!", "%%")
+ data = stringgsub(data, "!!!!!LEFTBRCE!!!!!","{")
+ data = stringgsub(data, "!!!!!RGHTBRCE!!!!!","}")
+ data = stringgsub(data, "!!!!!SHARPE!!!!!", "#" )
+ local preamble = mplibcodepreamble
+ if luamplib.textextlabel then
+ preamble = textextlabelpreamble .. preamble
+ end
+ randomseed = math.random(65535)
local mpx = luamplib.load(currentformat)
if mpx and data then
- local result = mpx:execute(mplibcodepreamble .. data)
+ local result = mpx:execute(preamble .. data)
domakeTEXboxes(result)
end
return data
@@ -1000,18 +1031,22 @@ luamplib.makeTEXboxes = makeTEXboxes
local factor = 65536*(7227/7200)
local function processwithTEXboxes (data)
- local num = tex.count[14] -- the same newbox register
+ local num = 255 -- output box
local prepreamble = "TEXBOX_ := "..num..";\n"
while true do
num = num + 1
local box = tex.box[num]
if not box then break end
prepreamble = prepreamble ..
- "TEXBOX_wd["..num.."] := "..box.width /factor..";\n"..
- "TEXBOX_ht["..num.."] := "..box.height/factor..";\n"..
- "TEXBOX_dp["..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
+ local preamble = prepreamble .. mplibcodepreamble
+ if luamplib.textextlabel then
+ preamble = textextlabelpreamble .. preamble
end
- process(prepreamble .. mplibcodepreamble .. data)
+ process(preamble .. data)
end
luamplib.processwithTEXboxes = processwithTEXboxes
@@ -1229,6 +1264,9 @@ local function flush(result,flusher)
miterlimit, linecap, linejoin, dashed = -1, -1, -1, false
elseif objecttype == "special" then
-- not supported
+ if prescript and prescript.MPlibTEXError then
+ warn("textext() anomaly. Try disabling \\mplibtextextlabel.")
+ end
elseif objecttype == "text" then
local ot = object.transform -- 3,4,5,6,1,2
pdf_literalcode("q %f %f %f %f %f %f cm",ot[3],ot[4],ot[5],ot[6],ot[1],ot[2])
@@ -1383,7 +1421,7 @@ luamplib.colorconverter = colorconverter
\else
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{luamplib}
- [2014/03/01 v2.5.3 mplib package for LuaTeX]
+ [2014/03/08 v2.6.0 mplib package for LuaTeX]
\RequirePackage{luatexbase-modutils}
\RequirePackage{pdftexcmds}
\fi
@@ -1551,6 +1589,16 @@ luamplib.colorconverter = colorconverter
\fi
}
\def\mplibcachedir#1{\directlua{luamplib.getcachedir("\unexpanded{#1}")}}
+\def\mplibtextextlabel#1{%
+ \begingroup
+ \def\tempa{enable}\def\tempb{#1}%
+ \ifx\tempa\tempb
+ \directlua{luamplib.textextlabel = true}%
+ \else
+ \directlua{luamplib.textextlabel = false}%
+ \fi
+ \endgroup
+}
% \end{macrocode}
%
% We use a dedicated scratchbox.
diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
index 575e030539b..a247ac12958 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.5.3",
- date = "2014/03/01",
+ version = "2.6.0",
+ date = "2014/03/08",
description = "Lua package to typeset Metapost with LuaTeX's MPLib.",
})
@@ -30,6 +30,7 @@ local stringgsub = string.gsub
local stringfind = string.find
local stringmatch = string.match
local stringgmatch = string.gmatch
+local stringexplode = string.explode
local tableconcat = table.concat
local texsprint = tex.sprint
@@ -168,8 +169,8 @@ local function replaceinputmpfile (name,file)
local data = fh:read("*all"); fh:close()
data = stringgsub(data, "\"[^\n]-\"",
function(str)
- str = stringgsub(str,"%%","*****PERCENT*****")
- str = stringgsub(str,"([bem])tex%f[^A-Z_a-z]","%1***T***E***X***")
+ str = stringgsub(str,"%%","!!!!!PERCENT!!!!!")
+ str = stringgsub(str,"([bem])tex%f[^A-Z_a-z]","%1!!!T!!!E!!!X!!!")
return str
end)
data = stringgsub(data,"%%.-\n","")
@@ -195,8 +196,8 @@ local function replaceinputmpfile (name,file)
end
return file
end
- data = stringgsub(data,"([bem])***T***E***X***","%1tex")
- data = stringgsub(data,"*****PERCENT*****","%%")
+ data = stringgsub(data,"([bem])!!!T!!!E!!!X!!!","%1tex")
+ data = stringgsub(data,"!!!!!PERCENT!!!!!","%%")
fh = ioopen(newfile,"w")
if not fh then return file end
fh:write(data); fh:close()
@@ -204,6 +205,8 @@ local function replaceinputmpfile (name,file)
return newfile
end
+local randomseed = nil
+
local mpkpse = kpse.new("luatex", "mpost")
local function finder(name, mode, ftype)
@@ -285,6 +288,7 @@ else
ini_version = true,
find_file = luamplib.finder,
math_mode = luamplib.numbersystem,
+ random_seed = randomseed,
}
local result
if not mpx then
@@ -481,72 +485,68 @@ local further_split_keys = {
}
local function script2table(s)
- local t = {}
- for i in stringgmatch(s,"[^\13]+") do
- local k,v = stringmatch(i,"(.-)=(.+)") -- v may contain =.
- if k and v then
- local vv = {}
- if further_split_keys[k] then
- for j in stringgmatch(v,"[^:]+") do
- vv[#vv+1] = j
- end
- end
- if #vv > 0 then
- t[k] = vv
- else
- t[k] = v
- end
- end
+ local t = {}
+ for _,i in ipairs(stringexplode(s,"\13+")) do
+ local k,v = stringmatch(i,"(.-)=(.*)") -- v may contain = or empty.
+ if k and v and k ~= "" then
+ if further_split_keys[k] then
+ t[k] = stringexplode(v,":")
+ else
+ t[k] = v
+ end
end
- return t
+ end
+ return t
end
local mplibcodepreamble = [[
vardef rawtextext (expr t) =
- if unknown TEXBOX_:
- image( special "MPlibmkTEXbox="&t; )
+ if unknown TEXBOX_:
+ image( special "MPlibmkTEXbox="&t; )
+ else:
+ TEXBOX_ := TEXBOX_ + 1;
+ if known TEXBOX_wd_[TEXBOX_]:
+ image ( addto currentpicture doublepath unitsquare
+ xscaled TEXBOX_wd_[TEXBOX_]
+ yscaled (TEXBOX_ht_[TEXBOX_] + TEXBOX_dp_[TEXBOX_])
+ shifted (0, -TEXBOX_dp_[TEXBOX_])
+ withprescript "MPlibTEXboxID=" &
+ decimal TEXBOX_ & ":" &
+ decimal TEXBOX_wd_[TEXBOX_] & ":" &
+ decimal(TEXBOX_ht_[TEXBOX_]+TEXBOX_dp_[TEXBOX_]); )
else:
- TEXBOX_ := TEXBOX_ + 1;
- image (
- addto currentpicture doublepath unitsquare
- xscaled TEXBOX_wd[TEXBOX_]
- yscaled (TEXBOX_ht[TEXBOX_] + TEXBOX_dp[TEXBOX_])
- shifted (0, -TEXBOX_dp[TEXBOX_])
- withprescript "MPlibTEXboxID=" &
- decimal TEXBOX_ & ":" &
- decimal TEXBOX_wd[TEXBOX_] & ":" &
- decimal(TEXBOX_ht[TEXBOX_]+TEXBOX_dp[TEXBOX_]);
- )
+ image( special "MPlibTEXError=1"; )
fi
+ fi
enddef;
if known context_mlib:
- defaultfont := "cmtt10";
- let infont = normalinfont;
- let fontsize = normalfontsize;
- vardef thelabel@#(expr p,z) =
- if string p :
- thelabel@#(p infont defaultfont scaled defaultscale,z)
- else :
- p shifted (z + labeloffset*mfun_laboff@# -
- (mfun_labxf@#*lrcorner p + mfun_labyf@#*ulcorner p +
- (1-mfun_labxf@#-mfun_labyf@#)*llcorner p))
- fi
- enddef;
- def graphictext primary filename =
- if (readfrom filename = EOF):
- errmessage "Please prepare '"&filename&"' in advance with command"&
- " 'pstoedit -ssp -dt -f mpost yourfile.ps "&filename&"'";
- fi
- closefrom filename;
- def data_mpy_file = filename enddef;
- mfun_do_graphic_text (filename)
- enddef;
- if unknown TEXBOX_: def mfun_do_graphic_text text t = enddef; fi
+ defaultfont := "cmtt10";
+ let infont = normalinfont;
+ let fontsize = normalfontsize;
+ vardef thelabel@#(expr p,z) =
+ if string p :
+ thelabel@#(p infont defaultfont scaled defaultscale,z)
+ else :
+ p shifted (z + labeloffset*mfun_laboff@# -
+ (mfun_labxf@#*lrcorner p + mfun_labyf@#*ulcorner p +
+ (1-mfun_labxf@#-mfun_labyf@#)*llcorner p))
+ fi
+ enddef;
+ def graphictext primary filename =
+ if (readfrom filename = EOF):
+ errmessage "Please prepare '"&filename&"' in advance with"&
+ " 'pstoedit -ssp -dt -f mpost yourfile.ps "&filename&"'";
+ fi
+ closefrom filename;
+ def data_mpy_file = filename enddef;
+ mfun_do_graphic_text (filename)
+ enddef;
+ if unknown TEXBOX_: def mfun_do_graphic_text text t = enddef; fi
else:
- vardef textext@# (text t) = rawtextext (t) enddef;
+ vardef textext@# (text t) = rawtextext (t) enddef;
fi
def externalfigure primary filename =
- draw rawtextext("\includegraphics{"& filename &"}")
+ draw rawtextext("\includegraphics{"& filename &"}")
enddef;
def TEX = textext enddef;
def fontmapfile primary filename = enddef;
@@ -557,6 +557,20 @@ extra_beginfig := extra_beginfig & " let VerbatimTeX = ignoreVerbatimTeX;" ;
extra_endfig := extra_endfig & " let VerbatimTeX = specialVerbatimTeX;" ;
]]
+local textextlabelpreamble = [[
+primarydef s infont f = rawtextext(s) enddef;
+let normalinfont = infont;
+def fontsize expr f =
+ begingroup
+ save size,pic; numeric size; picture pic;
+ pic := rawtextext("\hskip\pdffontsize\font");
+ size := xpart urcorner pic - xpart llcorner pic;
+ if size = 0: 10pt else: size fi
+ endgroup
+enddef;
+let normalfontsize = fontsize;
+]]
+
local function protecttextext(data)
local everymplib = tex.toks['everymplibtoks'] or ''
local everyendmplib = tex.toks['everyendmplibtoks'] or ''
@@ -564,8 +578,8 @@ local function protecttextext(data)
data = stringgsub(data,"\r","\n")
data = stringgsub(data, "\"[^\n]-\"",
function(str)
- str = stringgsub(str,"%%","****PERCENT****")
- str = stringgsub(str,"([bem])tex%f[^A-Z_a-z]","%1***T***E***X***")
+ str = stringgsub(str,"%%","!!!!!PERCENT!!!!!")
+ str = stringgsub(str,"([bem])tex%f[^A-Z_a-z]","%1!!!T!!!E!!!X!!!")
return str
end)
data = stringgsub(data,"%%.-\n","")
@@ -585,11 +599,11 @@ local function protecttextext(data)
end)
data = stringgsub(data, "\"[^\n]-\"",
function(str)
- str = stringgsub(str,"([bem])***T***E***X***","%1tex")
- str = stringgsub(str,"{", "****LEFTBRCE****")
- str = stringgsub(str,"}", "****RGHTBRCE****")
- str = stringgsub(str,"#", "****SHARPE****")
- return format("\\unexpanded{%s}",str)
+ str = stringgsub(str,"([bem])!!!T!!!E!!!X!!!","%1tex")
+ str = stringgsub(str,"{", "!!!!!LEFTBRCE!!!!!")
+ str = stringgsub(str,"}", "!!!!!RGHTBRCE!!!!!")
+ str = stringgsub(str,"#", "!!!!!SHARPE!!!!!")
+ return format("\\detokenize{%s}",str)
end)
texsprint(data)
end
@@ -599,7 +613,7 @@ luamplib.protecttextext = protecttextext
local TeX_code_t = {}
local function domakeTEXboxes (data)
- local num = tex.count[14] -- newbox register
+ local num = 255 -- output box
if data and data.fig then
local figures = data.fig
for f=1, #figures do
@@ -628,13 +642,18 @@ end
local function makeTEXboxes (data)
data = stringgsub(data, "##", "#") -- restore # doubled in input string
- data = stringgsub(data, "****PERCENT****", "%%")
- data = stringgsub(data, "****LEFTBRCE****","{")
- data = stringgsub(data, "****RGHTBRCE****","}")
- data = stringgsub(data, "****SHARPE****", "#" )
+ data = stringgsub(data, "!!!!!PERCENT!!!!!", "%%")
+ data = stringgsub(data, "!!!!!LEFTBRCE!!!!!","{")
+ data = stringgsub(data, "!!!!!RGHTBRCE!!!!!","}")
+ data = stringgsub(data, "!!!!!SHARPE!!!!!", "#" )
+ local preamble = mplibcodepreamble
+ if luamplib.textextlabel then
+ preamble = textextlabelpreamble .. preamble
+ end
+ randomseed = math.random(65535)
local mpx = luamplib.load(currentformat)
if mpx and data then
- local result = mpx:execute(mplibcodepreamble .. data)
+ local result = mpx:execute(preamble .. data)
domakeTEXboxes(result)
end
return data
@@ -645,18 +664,22 @@ luamplib.makeTEXboxes = makeTEXboxes
local factor = 65536*(7227/7200)
local function processwithTEXboxes (data)
- local num = tex.count[14] -- the same newbox register
+ local num = 255 -- output box
local prepreamble = "TEXBOX_ := "..num..";\n"
while true do
num = num + 1
local box = tex.box[num]
if not box then break end
prepreamble = prepreamble ..
- "TEXBOX_wd["..num.."] := "..box.width /factor..";\n"..
- "TEXBOX_ht["..num.."] := "..box.height/factor..";\n"..
- "TEXBOX_dp["..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 .. mplibcodepreamble .. data)
+ local preamble = prepreamble .. mplibcodepreamble
+ if luamplib.textextlabel then
+ preamble = textextlabelpreamble .. preamble
+ end
+ process(preamble .. data)
end
luamplib.processwithTEXboxes = processwithTEXboxes
@@ -859,6 +882,9 @@ local function flush(result,flusher)
miterlimit, linecap, linejoin, dashed = -1, -1, -1, false
elseif objecttype == "special" then
-- not supported
+ if prescript and prescript.MPlibTEXError then
+ warn("textext() anomaly. Try disabling \\mplibtextextlabel.")
+ end
elseif objecttype == "text" then
local ot = object.transform -- 3,4,5,6,1,2
pdf_literalcode("q %f %f %f %f %f %f cm",ot[3],ot[4],ot[5],ot[6],ot[1],ot[2])
diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty
index be85a430f32..7d09685e809 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/01 v2.5.3 mplib package for LuaTeX]
+ [2014/03/08 v2.6.0 mplib package for LuaTeX]
\RequirePackage{luatexbase-modutils}
\RequirePackage{pdftexcmds}
\fi
@@ -145,6 +145,16 @@
\fi
}
\def\mplibcachedir#1{\directlua{luamplib.getcachedir("\unexpanded{#1}")}}
+\def\mplibtextextlabel#1{%
+ \begingroup
+ \def\tempa{enable}\def\tempb{#1}%
+ \ifx\tempa\tempb
+ \directlua{luamplib.textextlabel = true}%
+ \else
+ \directlua{luamplib.textextlabel = false}%
+ \fi
+ \endgroup
+}
\ifx\mplibscratchbox\undefined \newbox\mplibscratchbox \fi
\def\mplibstarttoPDF#1#2#3#4{%
\hbox\bgroup