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/NEWS6
-rw-r--r--Master/texmf-dist/doc/luatex/luamplib/luamplib.pdfbin100198 -> 101829 bytes
-rw-r--r--Master/texmf-dist/source/luatex/luamplib/Makefile7
-rw-r--r--Master/texmf-dist/source/luatex/luamplib/luamplib.dtx186
-rw-r--r--Master/texmf-dist/tex/luatex/luamplib/luamplib.lua130
-rw-r--r--Master/texmf-dist/tex/luatex/luamplib/luamplib.sty32
6 files changed, 212 insertions, 149 deletions
diff --git a/Master/texmf-dist/doc/luatex/luamplib/NEWS b/Master/texmf-dist/doc/luatex/luamplib/NEWS
index 276b44d98f0..cd1398a0d22 100644
--- a/Master/texmf-dist/doc/luatex/luamplib/NEWS
+++ b/Master/texmf-dist/doc/luatex/luamplib/NEWS
@@ -1,5 +1,11 @@
History of the luamplib package
+2013/12/11 2.03
+ * implemented textext() macro which is identical to TEX() from TEX.mp.
+ TEX() is a synonym of textext().
+ * fix a bug regarding tex-text box inside for...endfor loop,
+ reported at http://www.ktug.org/xe/index.php?document_srl=178050
+
2013/09/24 2.01
* fix bug reported by Stephan Hennig: wrong baseline of tex-text box
diff --git a/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf b/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf
index a4aba43dcff..b8a91225742 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/Makefile b/Master/texmf-dist/source/luatex/luamplib/Makefile
index d437acb7405..cf17c9cfb8d 100644
--- a/Master/texmf-dist/source/luatex/luamplib/Makefile
+++ b/Master/texmf-dist/source/luatex/luamplib/Makefile
@@ -36,7 +36,7 @@ world: all ctan
.PHONY: all doc unpack ctan tds check world
%.pdf: %.dtx
- latexmk -pdf -e '$$pdflatex = q(lualatex %O %S)' -silent $< >/dev/null
+ latexmk -lualatex -recorder- -silent $< >/dev/null
$(UNPACKED): $(DTX)
tex -interaction=batchmode $< >/dev/null
@@ -50,7 +50,10 @@ check: $(UNPACKED)
$(CTAN_ZIP): $(SOURCES) $(DOC) $(TDS_ZIP)
@echo "Making $@ for CTAN upload."
@$(RM) -- $@
- @zip -9 $@ $^ >/dev/null
+ @mkdir -p $(NAME)
+ @cp -f $(SOURCES) $(DOC) $(NAME)
+ @zip -9 -r $@ $(TDS_ZIP) $(NAME) >/dev/null
+ @rm -rf $(NAME)
define run-install
@mkdir -p $(RUNDIR) && cp $(RUNFILES) $(RUNDIR)
diff --git a/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx b/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx
index c16885853e9..f56d8b19e1d 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}%
- [2013/09/24 v2.01 Interface for using the mplib library]%
+ [2013/12/11 v2.03 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{2013/09/24 v2.01}
+% \date{2013/12/11 v2.03}
%
% \maketitle
%
@@ -186,6 +186,9 @@ See source file '\inFileName' for licencing and contact information.
% \item all \TeX\ macros start by \texttt{mplib}
% \item use of luatexbase for errors, warnings and declaration
% \item possibility to use |btex ... etex| to typeset \TeX .
+% |textext()| is a more versatile macro equivalent to |TEX()| from TEX.mp.
+% |TEX()| is also allowed unless TEX.mp is loaded, which should be always
+% avoided.
% \end{itemize}
%
% Using this package is easy: in Plain, type your metapost code between the
@@ -222,8 +225,8 @@ luamplib.lastlog = ""
local err, warn, info, log = luatexbase.provides_module({
name = "luamplib",
- version = 2.01,
- date = "2013/09/24",
+ version = 2.03,
+ date = "2013/12/11",
description = "Lua package to typeset Metapost with LuaTeX's MPLib.",
})
@@ -559,55 +562,40 @@ end
% Below code has been contributed by Dohyun Kim.
% It implements \verb|btex| / \verb|etex| functions.
%
+% v2.2: \verb|textext()| is now available, which is equivalent to \verb|TEX()| macro from TEX.mp.
+% \verb|TEX()| is synonym of \verb|textext()| unless TEX.mp is loaded.
+%
% \begin{macrocode}
-local mplibcodepreamble = [[
-vardef textext@#(expr n, w, h, d) =
- image(
+local mplibcodepreamblefirst = [[
+def textext (expr t) =
+ image( special "%%mkTEXbox:"&t; )
+enddef;
+let TEX = textext;
+]]
+
+local mplibcodepreamblesecond = [[
+vardef textext (expr t) =
+ TEXBOX := TEXBOX + 1;
+ image (
addto currentpicture doublepath unitsquare
- xscaled w
- yscaled (h+d)
- shifted (0,-d)
- withprescript "%%textext:"&decimal n&":"&decimal w&":"&decimal(h+d);
- )
+ xscaled TEXBOXwd[TEXBOX]
+ yscaled (TEXBOXht[TEXBOX] + TEXBOXdp[TEXBOX])
+ shifted (0, -TEXBOXdp[TEXBOX])
+ withprescript "%%TEXtxtbox:" &
+ decimal TEXBOX & ":" &
+ decimal TEXBOXwd[TEXBOX] & ":" &
+ decimal(TEXBOXht[TEXBOX]+TEXBOXdp[TEXBOX]);
+)
enddef;
+def TEX (expr t) = textext (t) enddef;
]]
local factor = 65536*(7227/7200)
-local function settexboxes (data)
- local i = tex.count[14] -- newbox register
- for _,c,_ in stringgmatch(data,"(%A)btex(%A.-%A)etex(%A)") do
- i = i + 1
- c = stringgsub(c,"^%s*(.-)%s*$","%1")
- texsprint(format("\\setbox%i\\hbox{%s}",i,c))
- end
-end
-
-luamplib.settexboxes = settexboxes
-
-local function gettexboxes (data)
- local i = tex.count[14] -- the same newbox register
- data = stringgsub(data,"(%A)btex%A.-%Aetex(%A)",
- function(pre,post)
- i = i + 1
- local box = tex.box[i]
- local boxmetr = format("textext(%i,%f,%f,%f)",
- i,
- box and (box.width/factor) or 0,
- box and (box.height/factor) or 0,
- box and (box.depth/factor) or 0)
- return pre .. boxmetr .. post
- end)
- return mplibcodepreamble .. data
-end
-
-luamplib.gettexboxes = gettexboxes
-
-local function puttexboxes (object)
- local n,tw,th = stringmatch(
- object.prescript,
- "%%%%textext:(%d+):([%d%.%+%-]+):([%d%.%+%-]+)")
+local function putTEXboxes (object)
+ local n,tw,th = stringmatch(object.prescript,
+ "%%%%TEXtxtbox:(%d+):([%d%.%+%-]+):([%d%.%+%-]+)")
if n and tw and th then
local op = object.path
local first, second, fourth = op[1], op[2], op[4]
@@ -622,6 +610,64 @@ local function puttexboxes (object)
end
end
+local function domakeTEXboxes (data)
+ local num = tex.count[14] -- newbox register
+ if data and data.fig then
+ local figures = data.fig
+ for f=1, #figures do
+ local figure = figures[f]
+ local objects = getobjects(data,figure,f)
+ if objects then
+ for o=1,#objects do
+ local object = objects[o]
+ local prescript = object.prescript
+ if prescript and stringfind(prescript,"%%%%mkTEXbox:") then
+ num = num + 1
+ stringgsub(prescript, "%%%%mkTEXbox:(.+)",
+ function(str)
+ texsprint(format("\\setbox%i\\hbox{%s}",num,str))
+ end)
+ end
+ end
+ end
+ end
+ end
+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
+ end)
+ local mpx = luamplib.load(currentformat)
+ if mpx and data then
+ local result = mpx:execute(mplibcodepreamblefirst .. data)
+ domakeTEXboxes(result)
+ end
+ return data
+end
+
+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"
+ 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"
+ end
+ process(prepreamble .. mplibcodepreamblesecond .. data)
+end
+
+luamplib.processwithTEXboxes = processwithTEXboxes
+
% \end{macrocode}
% End of \verb|btex| -- \verb|etex| patch.
%
@@ -656,8 +702,8 @@ local function flush(result,flusher)
%
% \begin{macrocode}
local prescript = object.prescript --- [be]tex patch
- if prescript and stringfind(prescript,"%%%%textext:") then
- puttexboxes(object)
+ if prescript and stringfind(prescript,"%%%%TEXtxtbox:") then
+ putTEXboxes(object)
elseif objecttype == "start_bounds" or objecttype == "stop_bounds" then
-- skip
elseif objecttype == "start_clip" then
@@ -810,7 +856,7 @@ luamplib.colorconverter = colorconverter
%<*package>
% \end{macrocode}
%
-% First we need to load fancyvrb, to define the environment mplibcode.
+% First we need to load some packages.
%
% \begin{macrocode}
\bgroup\expandafter\expandafter\expandafter\egroup
@@ -819,7 +865,7 @@ luamplib.colorconverter = colorconverter
\else
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{luamplib}
- [2013/09/24 v2.01 mplib package for LuaTeX]
+ [2013/12/11 v2.03 mplib package for LuaTeX]
\RequirePackage{luatexbase-modutils}
\RequirePackage{pdftexcmds}
\fi
@@ -863,10 +909,15 @@ luamplib.colorconverter = colorconverter
}
% \end{macrocode}
%
+% Make \verb|btex...etex| box zero-metric.
+%
+% \begin{macrocode}
+\def\mplibputtextbox#1{\vbox to 0pt{\vss\hbox to 0pt{\raise\dp#1\copy#1\hss}}}
+% \end{macrocode}
+%
% The Plain-specific stuff.
%
% \begin{macrocode}
-\def\mplibputtextbox#1{\vbox to 0pt{\vss\hbox to 0pt{\raise\dp#1\box#1\hss}}}
\bgroup\expandafter\expandafter\expandafter\egroup
\expandafter\ifx\csname ProvidesPackage\endcsname\relax
\def\mplibcode{%
@@ -877,38 +928,16 @@ luamplib.colorconverter = colorconverter
\long\def\mplibdocode#1\endmplibcode{%
\egroup
\directlua{
- luamplib.settexboxes([===[\unexpanded{#1}]===])
+ luamplib.tempdata = luamplib.makeTEXboxes([===[\unexpanded{#1}]===])
}%
\directlua{
- local data = luamplib.gettexboxes([===[\unexpanded{#1}]===])
- luamplib.process(data)
+ luamplib.processwithTEXboxes(luamplib.tempdata)
}%
}
\else
% \end{macrocode}
%
-% The \LaTeX-specific parts. First a Hack for the catcodes in \LaTeX .
-%
-% \begin{macrocode}
-\begingroup
-\catcode`\,=13
-\catcode`\-=13
-\catcode`\<=13
-\catcode`\>=13
-\catcode`\^^I=13
-\catcode`\`=13 % must be last...
-\gdef\FV@hack{%
- \def,{\string,}%
- \def-{\string-}%
- \def<{\string<}%
- \def>{\string>}%
- \def`{\string`}%
- \def^^I{\string^^I}%
-}
-\endgroup
-% \end{macrocode}
-%
-% The \LaTeX\ environment.
+% The \LaTeX-specific parts: a new environment.
%
% \begin{macrocode}
\newenvironment{mplibcode}{\toks@{}\ltxdomplibcode}{}
@@ -925,10 +954,11 @@ luamplib.colorconverter = colorconverter
%
\def\ltxdomplibcodefinally#1{%
\ifnum\pdf@strcmp{#1}{mplibcode}=\z@
- \directlua{luamplib.settexboxes([===[\the\toks@]===])}%
\directlua{
- local data = luamplib.gettexboxes([===[\the\toks@]===])
- luamplib.process(data)
+ luamplib.tempdata = luamplib.makeTEXboxes([===[\the\toks@]===])
+ }%
+ \directlua{
+ luamplib.processwithTEXboxes(luamplib.tempdata)
}%
\end{mplibcode}%
\else
diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
index dab385288c0..4969538ec15 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.01,
- date = "2013/09/24",
+ version = 2.03,
+ date = "2013/12/11",
description = "Lua package to typeset Metapost with LuaTeX's MPLib.",
})
@@ -310,53 +310,35 @@ local function flushconcatpath(path,open)
end
-local mplibcodepreamble = [[
-vardef textext@#(expr n, w, h, d) =
- image(
+local mplibcodepreamblefirst = [[
+def textext (expr t) =
+ image( special "%%mkTEXbox:"&t; )
+enddef;
+let TEX = textext;
+]]
+
+local mplibcodepreamblesecond = [[
+vardef textext (expr t) =
+ TEXBOX := TEXBOX + 1;
+ image (
addto currentpicture doublepath unitsquare
- xscaled w
- yscaled (h+d)
- shifted (0,-d)
- withprescript "%%textext:"&decimal n&":"&decimal w&":"&decimal(h+d);
- )
+ xscaled TEXBOXwd[TEXBOX]
+ yscaled (TEXBOXht[TEXBOX] + TEXBOXdp[TEXBOX])
+ shifted (0, -TEXBOXdp[TEXBOX])
+ withprescript "%%TEXtxtbox:" &
+ decimal TEXBOX & ":" &
+ decimal TEXBOXwd[TEXBOX] & ":" &
+ decimal(TEXBOXht[TEXBOX]+TEXBOXdp[TEXBOX]);
+)
enddef;
+def TEX (expr t) = textext (t) enddef;
]]
local factor = 65536*(7227/7200)
-local function settexboxes (data)
- local i = tex.count[14] -- newbox register
- for _,c,_ in stringgmatch(data,"(%A)btex(%A.-%A)etex(%A)") do
- i = i + 1
- c = stringgsub(c,"^%s*(.-)%s*$","%1")
- texsprint(format("\\setbox%i\\hbox{%s}",i,c))
- end
-end
-
-luamplib.settexboxes = settexboxes
-
-local function gettexboxes (data)
- local i = tex.count[14] -- the same newbox register
- data = stringgsub(data,"(%A)btex%A.-%Aetex(%A)",
- function(pre,post)
- i = i + 1
- local box = tex.box[i]
- local boxmetr = format("textext(%i,%f,%f,%f)",
- i,
- box and (box.width/factor) or 0,
- box and (box.height/factor) or 0,
- box and (box.depth/factor) or 0)
- return pre .. boxmetr .. post
- end)
- return mplibcodepreamble .. data
-end
-
-luamplib.gettexboxes = gettexboxes
-
-local function puttexboxes (object)
- local n,tw,th = stringmatch(
- object.prescript,
- "%%%%textext:(%d+):([%d%.%+%-]+):([%d%.%+%-]+)")
+local function putTEXboxes (object)
+ local n,tw,th = stringmatch(object.prescript,
+ "%%%%TEXtxtbox:(%d+):([%d%.%+%-]+):([%d%.%+%-]+)")
if n and tw and th then
local op = object.path
local first, second, fourth = op[1], op[2], op[4]
@@ -371,6 +353,64 @@ local function puttexboxes (object)
end
end
+local function domakeTEXboxes (data)
+ local num = tex.count[14] -- newbox register
+ if data and data.fig then
+ local figures = data.fig
+ for f=1, #figures do
+ local figure = figures[f]
+ local objects = getobjects(data,figure,f)
+ if objects then
+ for o=1,#objects do
+ local object = objects[o]
+ local prescript = object.prescript
+ if prescript and stringfind(prescript,"%%%%mkTEXbox:") then
+ num = num + 1
+ stringgsub(prescript, "%%%%mkTEXbox:(.+)",
+ function(str)
+ texsprint(format("\\setbox%i\\hbox{%s}",num,str))
+ end)
+ end
+ end
+ end
+ end
+ end
+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
+ end)
+ local mpx = luamplib.load(currentformat)
+ if mpx and data then
+ local result = mpx:execute(mplibcodepreamblefirst .. data)
+ domakeTEXboxes(result)
+ end
+ return data
+end
+
+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"
+ 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"
+ end
+ process(prepreamble .. mplibcodepreamblesecond .. data)
+end
+
+luamplib.processwithTEXboxes = processwithTEXboxes
+
local function flush(result,flusher)
if result then
@@ -396,8 +436,8 @@ local function flush(result,flusher)
local object = objects[o]
local objecttype = object.type
local prescript = object.prescript --- [be]tex patch
- if prescript and stringfind(prescript,"%%%%textext:") then
- puttexboxes(object)
+ if prescript and stringfind(prescript,"%%%%TEXtxtbox:") then
+ putTEXboxes(object)
elseif objecttype == "start_bounds" or objecttype == "stop_bounds" then
-- skip
elseif objecttype == "start_clip" then
diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty
index 242280e05fd..ea377e7e895 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/09/24 v2.01 mplib package for LuaTeX]
+ [2013/12/11 v2.03 mplib package for LuaTeX]
\RequirePackage{luatexbase-modutils}
\RequirePackage{pdftexcmds}
\fi
@@ -40,7 +40,7 @@
%catcode`\%=12 %% don^^e2^^80^^99t in Plain!
\catcode`\&=12 \catcode`\$=12
}
-\def\mplibputtextbox#1{\vbox to 0pt{\vss\hbox to 0pt{\raise\dp#1\box#1\hss}}}
+\def\mplibputtextbox#1{\vbox to 0pt{\vss\hbox to 0pt{\raise\dp#1\copy#1\hss}}}
\bgroup\expandafter\expandafter\expandafter\egroup
\expandafter\ifx\csname ProvidesPackage\endcsname\relax
\def\mplibcode{%
@@ -51,30 +51,13 @@
\long\def\mplibdocode#1\endmplibcode{%
\egroup
\directlua{
- luamplib.settexboxes([===[\unexpanded{#1}]===])
+ luamplib.tempdata = luamplib.makeTEXboxes([===[\unexpanded{#1}]===])
}%
\directlua{
- local data = luamplib.gettexboxes([===[\unexpanded{#1}]===])
- luamplib.process(data)
+ luamplib.processwithTEXboxes(luamplib.tempdata)
}%
}
\else
-\begingroup
-\catcode`\,=13
-\catcode`\-=13
-\catcode`\<=13
-\catcode`\>=13
-\catcode`\^^I=13
-\catcode`\`=13 % must be last...
-\gdef\FV@hack{%
- \def,{\string,}%
- \def-{\string-}%
- \def<{\string<}%
- \def>{\string>}%
- \def`{\string`}%
- \def^^I{\string^^I}%
-}
-\endgroup
\newenvironment{mplibcode}{\toks@{}\ltxdomplibcode}{}
\def\ltxdomplibcode{%
\bgroup
@@ -87,10 +70,11 @@
}%
\def\ltxdomplibcodefinally#1{%
\ifnum\pdf@strcmp{#1}{mplibcode}=\z@
- \directlua{luamplib.settexboxes([===[\the\toks@]===])}%
\directlua{
- local data = luamplib.gettexboxes([===[\the\toks@]===])
- luamplib.process(data)
+ luamplib.tempdata = luamplib.makeTEXboxes([===[\the\toks@]===])
+ }%
+ \directlua{
+ luamplib.processwithTEXboxes(luamplib.tempdata)
}%
\end{mplibcode}%
\else