diff options
author | Karl Berry <karl@freefriends.org> | 2014-06-19 20:24:05 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-06-19 20:24:05 +0000 |
commit | c46f74d4c2a102cc794be871c46f42519bf6da8a (patch) | |
tree | 30d13742844bdc1b9d493897cb29f17bfdc9ed1e /Master/texmf-dist | |
parent | 645977d2a193cba365984822764a2d97c2951249 (diff) |
luamplib (19jun14)
git-svn-id: svn://tug.org/texlive/trunk@34319 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/luatex/luamplib/NEWS | 6 | ||||
-rw-r--r-- | Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf | bin | 132807 -> 135492 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex | 8 | ||||
-rw-r--r-- | Master/texmf-dist/source/luatex/luamplib/Makefile | 6 | ||||
-rw-r--r-- | Master/texmf-dist/source/luatex/luamplib/luamplib.dtx | 90 | ||||
-rw-r--r-- | Master/texmf-dist/tex/luatex/luamplib/luamplib.lua | 53 | ||||
-rw-r--r-- | Master/texmf-dist/tex/luatex/luamplib/luamplib.sty | 21 |
7 files changed, 143 insertions, 41 deletions
diff --git a/Master/texmf-dist/doc/luatex/luamplib/NEWS b/Master/texmf-dist/doc/luatex/luamplib/NEWS index 14b03427dd0..36682f27656 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 +2014/06/17 2.8.0 + * support color/xcolor/spotcolor packages. + On LaTeX, color names or expressions of color/xcolor packages + can be used inside mplibcode environment with the command + \mpcolor{<color expression>}. + 2014/04/25 2.7.0 * support DVIPDFMx * default directory for cache is now '$TEXMFVAR/luamplib_cache' diff --git a/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf b/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf Binary files differindex 6af081358b9..6995c8cfed9 100644 --- a/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf +++ b/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf 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 84ef88c4149..9a07fa86f50 100644 --- a/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex +++ b/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex @@ -1,5 +1,6 @@ \documentclass{article} \usepackage{luamplib} +\usepackage{xcolor} \everymplib{ beginfig(0); } \everyendmplib{ endfig; } \begin{document} @@ -25,8 +26,8 @@ A% \begin{mplibcode} verbatimtex \lower.2em etex beginfig(0); -draw origin--(1cm,0) withcolor red; -draw btex g\begin{huge}g\end{huge}etex withcolor blue; +draw origin--(1cm,0) withcolor \mpcolor{teal}; +draw btex g\begin{huge}g\end{huge}etex withcolor \mpcolor{orange}; draw bbox currentpicture; endfig; @@ -50,7 +51,8 @@ numeric u; u=1cm; z1=-z2=(-u,0); for i = 1 upto 3: draw z1..(0, i*u)..z2; - label.top(TEX("$e_{" & decimal(i) & "}$"), (0, i*u)) withcolor blue; + label.top(TEX("$e_{" & decimal(i) & "}$"), (0, i*u)) + withcolor \mpcolor{red!70!blue}; endfor; endfig; \end{mplibcode}% diff --git a/Master/texmf-dist/source/luatex/luamplib/Makefile b/Master/texmf-dist/source/luatex/luamplib/Makefile index 772fb3b6b85..a842e2c30bc 100644 --- a/Master/texmf-dist/source/luatex/luamplib/Makefile +++ b/Master/texmf-dist/source/luatex/luamplib/Makefile @@ -17,10 +17,10 @@ RUNFILES = $(STY) $(LUA) ALL = $(SRCFILES) $(DOCFILES) $(RUNFILES) -TEXMFDIR = ./texmf RUNDIR = $(TEXMFDIR)/tex/$(FORMAT)/$(NAME) DOCDIR = $(TEXMFDIR)/doc/$(FORMAT)/$(NAME) SRCDIR = $(TEXMFDIR)/source/$(FORMAT)/$(NAME) +TEXMFDIR = $(shell kpsewhich --var-value TEXMFHOME) CTAN_ZIP = $(NAME).zip TDS_ZIP = $(NAME).tds.zip @@ -52,8 +52,8 @@ $(CTAN_ZIP): $(SOURCES) $(DOC) $(TDS_ZIP) @$(RM) -- $@ @mkdir -p $(NAME) @cp -f $(SOURCES) $(DOC) $(NAME) - @zip -9 -r $@ $(TDS_ZIP) $(NAME) >/dev/null - @rm -rf $(NAME) + @zip -q -9 -r $@ $(TDS_ZIP) $(NAME) + @$(RM) -r $(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 615e2e65421..0ac9a0a7dfc 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/04/25 v2.7.0 Interface for using the mplib library]% + [2014/06/17 v2.8.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/04/25 v2.7.0} +% \date{2014/06/17 v2.8.0} % % \maketitle % @@ -244,13 +244,19 @@ See source file '\inFileName' for licencing and contact information. % \begin{verbatim} % \begin{mplibcode} % draw origin--(\mpdim{\linewidth},0) withpen pencircle scaled 4 -% dashed evenly scaled 4 withcolor \myrulecolor; +% dashed evenly scaled 4 withcolor \mpcolor{orange}; % \end{mplibcode} % \end{verbatim} % \textsc{n.b.} Users should not use the protected variant of % |btex ... etex| as provided by gmp package. As \textsf{luamplib} % automatically protects \TeX\ code inbetween, \cs{btex} is not supported % here. +% \item With \cs{mpcolor} command, color names or expressions of +% \textsf{color} or \textsf{xcolor} package can be used inside mplibcode +% enviroment. In PDF mode, \textsf{spotcolor} package is supported +% as well. This is a \LaTeX-only functionality and \textsf{color} or +% \textsf{xcolor} package should be loaded by users. +% See the example code of the previous item. % \item Users can choose |numbersystem| option since v2.4. % The default value |scaled| can be changed to |double| by declaring % |\mplibnumbersystem{double}|. For details see @@ -322,8 +328,8 @@ luamplib.lastlog = "" local err, warn, info, log = luatexbase.provides_module({ name = "luamplib", - version = "2.7.0", - date = "2014/04/25", + version = "2.8.0", + date = "2014/06/17", description = "Lua package to typeset Metapost with LuaTeX's MPLib.", }) @@ -482,6 +488,7 @@ local noneedtoreplace = { ["mp-step.mpiv"] = true, ["mp-text.mpiv"] = true, ["mp-tool.mpiv"] = true, + ["mp-luas.mpiv"] = true, } luamplib.noneedtoreplace = noneedtoreplace @@ -1005,6 +1012,14 @@ local function protecttextext(data) str = stringgsub(str,"#", "!!!!!SHARPE!!!!!") return format("\\detokenize{%s}",str) end) + luamplib.mpxcolors = {} + data = stringgsub(data, "\\mpcolor%s*{(.-)}", + function(str) + local cnt = #luamplib.mpxcolors + 1 + luamplib.mpxcolors[cnt] = format( + "\\expandafter\\mplibcolor\\csname mpxcolor%i\\endcsname{%s}",cnt,str) + return format("\\csname mpxcolor%i\\endcsname",cnt) + end) texsprint(data) end @@ -1249,6 +1264,8 @@ local function color_normalize(ca,cb) end end +local prev_override_color + local function do_preobj_color(object,prescript) -- transparency local opaq = prescript and prescript.tr_transparency @@ -1260,9 +1277,26 @@ local function do_preobj_color(object,prescript) pdf_literalcode("/MPlibTr%i gs",tron_no) end -- color - local cs = object.color - if cs and #cs > 0 then - pdf_literalcode(luamplib.colorconverter(cs)) + local override = prescript and prescript.MPlibOverrideColor + if override then + if pdfmode then + pdf_literalcode(override) + override = nil + else + texsprint(format("\\special{color push %s}",override)) + prev_override_color = override + end + else + local cs = object.color + if cs and #cs > 0 then + pdf_literalcode(luamplib.colorconverter(cs)) + prev_override_color = nil + elseif not pdfmode then + override = prev_override_color + if override then + texsprint(format("\\special{color push %s}",override)) + end + end end -- shading local sh_type = prescript and prescript.sh_type @@ -1293,7 +1327,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 troff_no + else return troff_no,override end colora = tableconcat(colora, " ") colorb = tableconcat(colorb, " ") @@ -1308,15 +1342,18 @@ local function do_preobj_color(object,prescript) shade_no = sh_pdfpageresources(3,domain,colorspace,colora,colorb,coordinates) end pdf_literalcode("q /Pattern cs") - return troff_no,shade_no + return troff_no,override,shade_no end - return troff_no + return troff_no,override end -local function do_postobj_color(tr,sh) +local function do_postobj_color(tr,over,sh) if sh then pdf_literalcode("W n /MPlibSh%s sh Q",sh) end + if over then + texsprint("\\special{color pop}") + end if tr then pdf_literalcode("/MPlibTr%i gs",tr) end @@ -1363,7 +1400,7 @@ local function flush(result,flusher) % \begin{macrocode} local prescript = object.prescript prescript = prescript and script2table(prescript) -- prescript is now a table - local tr_opaq,shade_no = do_preobj_color(object,prescript) + local tr_opaq,cr_over,shade_no = do_preobj_color(object,prescript) if prescript and prescript.MPlibTEXboxID then putTEXboxes(object,prescript) elseif objecttype == "start_bounds" or objecttype == "stop_bounds" then @@ -1488,7 +1525,7 @@ local function flush(result,flusher) % Added to \ConTeXt{} code: color stuff % % \begin{macrocode} - do_postobj_color(tr_opaq,shade_no) + do_postobj_color(tr_opaq,cr_over,shade_no) end end stop_pdf_code() @@ -1535,9 +1572,8 @@ luamplib.colorconverter = colorconverter \else \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{luamplib} - [2014/04/25 v2.7.0 mplib package for LuaTeX] + [2014/06/17 v2.8.0 mplib package for LuaTeX] \RequirePackage{luatexbase-modutils} - \RequirePackage{pdftexcmds} \fi % \end{macrocode} % @@ -1630,12 +1666,14 @@ luamplib.colorconverter = colorconverter \mplibsetupcatcodes \ltxdomplibcodeindeed } +\def\mplib@mplibcode{mplibcode} \long\def\ltxdomplibcodeindeed#1\end#2{% \endgroup \toks@\expandafter{\the\toks@#1}% - \ifnum\pdf@strcmp{#2}{mplibcode}=\z@ - \def\reserved@a{\directlua{luamplib.protecttextext([===[\the\toks@]===])}}% - \directlua{luamplib.tempdata=luamplib.makeTEXboxes([===[\reserved@a]===])}% + \def\mplibtemp@a{#2}\ifx\mplib@mplibcode\mplibtemp@a + \edef\mplibtemp{\directlua{luamplib.protecttextext([===[\the\toks@]===])}}% + \directlua{ tex.sprint(table.concat(luamplib.mpxcolors)) }% + \directlua{luamplib.tempdata=luamplib.makeTEXboxes([===[\mplibtemp]===])}% \directlua{luamplib.processwithTEXboxes(luamplib.tempdata)}% \end{mplibcode}% \ifnum\mplibstartlineno<\inputlineno @@ -1645,6 +1683,20 @@ luamplib.colorconverter = colorconverter \toks@\expandafter{\the\toks@\end{#2}}\expandafter\ltxdomplibcode \fi } +% \end{macrocode} +% Support color/xcolor package on \LaTeX. +% User interface is: \verb|\mpcolor{teal}|, for example. +% \begin{macrocode} +\def\mplibcolor#1#2{% + \ifcsname\string\color @#2\endcsname + \edef#1{1 withprescript + "MPlibOverrideColor=\csname\string\color @#2\endcsname"}% + \else + \extractcolorspecs{#2}\mplibtemp@a\mplibtemp@b + \convertcolorspec\mplibtemp@a\mplibtemp@b{cmyk}\mplibtemp@c + \edef#1{(\mplibtemp@c)}% + \fi +} \fi % \end{macrocode} % diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua index fa176c813b9..4dd1b5e946c 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.7.0", - date = "2014/04/25", + version = "2.8.0", + date = "2014/06/17", description = "Lua package to typeset Metapost with LuaTeX's MPLib.", }) @@ -161,6 +161,7 @@ local noneedtoreplace = { ["mp-step.mpiv"] = true, ["mp-text.mpiv"] = true, ["mp-tool.mpiv"] = true, + ["mp-luas.mpiv"] = true, } luamplib.noneedtoreplace = noneedtoreplace @@ -633,6 +634,14 @@ local function protecttextext(data) str = stringgsub(str,"#", "!!!!!SHARPE!!!!!") return format("\\detokenize{%s}",str) end) + luamplib.mpxcolors = {} + data = stringgsub(data, "\\mpcolor%s*{(.-)}", + function(str) + local cnt = #luamplib.mpxcolors + 1 + luamplib.mpxcolors[cnt] = format( + "\\expandafter\\mplibcolor\\csname mpxcolor%i\\endcsname{%s}",cnt,str) + return format("\\csname mpxcolor%i\\endcsname",cnt) + end) texsprint(data) end @@ -870,6 +879,8 @@ local function color_normalize(ca,cb) end end +local prev_override_color + local function do_preobj_color(object,prescript) -- transparency local opaq = prescript and prescript.tr_transparency @@ -881,9 +892,26 @@ local function do_preobj_color(object,prescript) pdf_literalcode("/MPlibTr%i gs",tron_no) end -- color - local cs = object.color - if cs and #cs > 0 then - pdf_literalcode(luamplib.colorconverter(cs)) + local override = prescript and prescript.MPlibOverrideColor + if override then + if pdfmode then + pdf_literalcode(override) + override = nil + else + texsprint(format("\\special{color push %s}",override)) + prev_override_color = override + end + else + local cs = object.color + if cs and #cs > 0 then + pdf_literalcode(luamplib.colorconverter(cs)) + prev_override_color = nil + elseif not pdfmode then + override = prev_override_color + if override then + texsprint(format("\\special{color push %s}",override)) + end + end end -- shading local sh_type = prescript and prescript.sh_type @@ -914,7 +942,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 troff_no + else return troff_no,override end colora = tableconcat(colora, " ") colorb = tableconcat(colorb, " ") @@ -929,15 +957,18 @@ local function do_preobj_color(object,prescript) shade_no = sh_pdfpageresources(3,domain,colorspace,colora,colorb,coordinates) end pdf_literalcode("q /Pattern cs") - return troff_no,shade_no + return troff_no,override,shade_no end - return troff_no + return troff_no,override end -local function do_postobj_color(tr,sh) +local function do_postobj_color(tr,over,sh) if sh then pdf_literalcode("W n /MPlibSh%s sh Q",sh) end + if over then + texsprint("\\special{color pop}") + end if tr then pdf_literalcode("/MPlibTr%i gs",tr) end @@ -972,7 +1003,7 @@ local function flush(result,flusher) local objecttype = object.type local prescript = object.prescript prescript = prescript and script2table(prescript) -- prescript is now a table - local tr_opaq,shade_no = do_preobj_color(object,prescript) + local tr_opaq,cr_over,shade_no = do_preobj_color(object,prescript) if prescript and prescript.MPlibTEXboxID then putTEXboxes(object,prescript) elseif objecttype == "start_bounds" or objecttype == "stop_bounds" then @@ -1084,7 +1115,7 @@ local function flush(result,flusher) -- pdf_literalcode(cr) -- end end - do_postobj_color(tr_opaq,shade_no) + do_postobj_color(tr_opaq,cr_over,shade_no) end end stop_pdf_code() diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty index ef35c1fc42c..21e321e6a91 100644 --- a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty +++ b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty @@ -14,9 +14,8 @@ \else \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{luamplib} - [2014/04/25 v2.7.0 mplib package for LuaTeX] + [2014/06/17 v2.8.0 mplib package for LuaTeX] \RequirePackage{luatexbase-modutils} - \RequirePackage{pdftexcmds} \fi \RequireLuaModule{luamplib} \def\mplibsetformat#1{% @@ -77,12 +76,14 @@ \mplibsetupcatcodes \ltxdomplibcodeindeed } +\def\mplib@mplibcode{mplibcode} \long\def\ltxdomplibcodeindeed#1\end#2{% \endgroup \toks@\expandafter{\the\toks@#1}% - \ifnum\pdf@strcmp{#2}{mplibcode}=\z@ - \def\reserved@a{\directlua{luamplib.protecttextext([===[\the\toks@]===])}}% - \directlua{luamplib.tempdata=luamplib.makeTEXboxes([===[\reserved@a]===])}% + \def\mplibtemp@a{#2}\ifx\mplib@mplibcode\mplibtemp@a + \edef\mplibtemp{\directlua{luamplib.protecttextext([===[\the\toks@]===])}}% + \directlua{ tex.sprint(table.concat(luamplib.mpxcolors)) }% + \directlua{luamplib.tempdata=luamplib.makeTEXboxes([===[\mplibtemp]===])}% \directlua{luamplib.processwithTEXboxes(luamplib.tempdata)}% \end{mplibcode}% \ifnum\mplibstartlineno<\inputlineno @@ -92,6 +93,16 @@ \toks@\expandafter{\the\toks@\end{#2}}\expandafter\ltxdomplibcode \fi } +\def\mplibcolor#1#2{% + \ifcsname\string\color @#2\endcsname + \edef#1{1 withprescript + "MPlibOverrideColor=\csname\string\color @#2\endcsname"}% + \else + \extractcolorspecs{#2}\mplibtemp@a\mplibtemp@b + \convertcolorspec\mplibtemp@a\mplibtemp@b{cmyk}\mplibtemp@c + \edef#1{(\mplibtemp@c)}% + \fi +} \fi \newtoks\everymplibtoks \newtoks\everyendmplibtoks |