From fb3b765b371f68ddb981a34defc17358d18b29bc Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 3 Jul 2024 19:30:33 +0000 Subject: luamplib (3jul24) git-svn-id: svn://tug.org/texlive/trunk@71698 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/luatex/luamplib/NEWS | 5 +++ Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf | Bin 213718 -> 214279 bytes .../texmf-dist/source/luatex/luamplib/luamplib.dtx | 36 +++++++++++++-------- Master/texmf-dist/tex/luatex/luamplib/luamplib.lua | 25 +++++++------- Master/texmf-dist/tex/luatex/luamplib/luamplib.sty | 2 +- 5 files changed, 42 insertions(+), 26 deletions(-) diff --git a/Master/texmf-dist/doc/luatex/luamplib/NEWS b/Master/texmf-dist/doc/luatex/luamplib/NEWS index 81f07ac38fa..50e7c625a95 100644 --- a/Master/texmf-dist/doc/luatex/luamplib/NEWS +++ b/Master/texmf-dist/doc/luatex/luamplib/NEWS @@ -1,5 +1,10 @@ History of the luamplib package +2024/07/03 2.32.4 + * make the variable 'patterns' local + * 'math.randomseed' on plain TeX + * remove redundant code 'fullcircle scaled 0' + 2024/06/21 2.32.3 * 'coloured' is a synonym of the option 'colored' in pattern definition. diff --git a/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf b/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf index e51324ffe40..5e8e97a778a 100644 Binary files a/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf and b/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf differ diff --git a/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx b/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx index fd6afd4e657..c050955a398 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}% - [2024/06/21 v2.32.3 Interface for using the mplib library]% + [2024/07/03 v2.32.4 Interface for using the mplib library]% \documentclass{ltxdoc} \usepackage{metalogo,multicol,mdwlist,fancyvrb,xspace} \usepackage[x11names]{xcolor} @@ -153,7 +153,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{2024/06/21 v2.32.3} +% \date{2024/07/03 v2.32.4} % % \maketitle % @@ -690,8 +690,8 @@ See source file '\inFileName' for licencing and contact information. luatexbase.provides_module { name = "luamplib", - version = "2.32.3", - date = "2024/06/21", + version = "2.32.4", + date = "2024/07/03", description = "Lua package to typeset Metapost with LuaTeX's MPLib.", } @@ -1076,6 +1076,12 @@ local function reporterror (result, prevlog) end end +% \end{macrocode} +% +% |lualibs-os.lua| installs a randomseed. When this file is not loaded, +% we should explicitly seed a unique interger to get random randomseed for each run. +% \begin{macrocode} +if not math.initialseed then math.randomseed(currenttime) end local function luamplibload (name) local mpx = mplib.new { ini_version = true, @@ -1888,7 +1894,7 @@ function luamplib.glyph (f, c) if not gid then return mperr"cannot get GID (glyph id)" end local fac = 1000 / (shapedata.units or 1000) local t = shapedata.glyphs[gid].segments - if not t then return "image(fill fullcircle scaled 0;)" end + if not t then return "image()" end for i,v in ipairs(t) do if type(v) == "table" then for ii,vv in ipairs(v) do @@ -2142,7 +2148,7 @@ function luamplib.outlinetext (text) local id = tonumber(fmt:match"mplibtexboxid=(%d+):") local box = texgetbox(id) local res = outline_horz({ }, box, box.head, 0, 0) - if #res == 0 then res = { "mpliboutlinepic[1]:=image(fill fullcircle scaled 0;);" } end + if #res == 0 then res = { "mpliboutlinepic[1]:=image();" } end return tableconcat(res) .. format("mpliboutlinenum:=%i;", #res) end @@ -2718,13 +2724,14 @@ end if pdfmode then pdfetcs.getpageres = pdf.getpageresources or function() return pdf.pageresources end - pdfetcs.setpageres = pdf.setpageresources or function(s) pdf.pageresources = s end - pdfetcs.initialize_resources = function (name) + local getpageres = pdfetcs.getpageres + local setpageres = pdf.setpageresources or function(s) pdf.pageresources = s end + local initialize_resources = function (name) local tabname = format("%s_res",name) pdfetcs[tabname] = { } if luatexbase.callbacktypes.finish_pdffile then -- ltluatex local obj = pdf.reserveobj() - pdfetcs.setpageres(format("%s/%s %i 0 R", pdfetcs.getpageres() or "", name, obj)) + setpageres(format("%s/%s %i 0 R", getpageres() or "", name, obj)) luatexbase.add_to_callback("finish_pdffile", function() pdf.immediateobj(obj, format("<<%s>>", tableconcat(pdfetcs[tabname]))) end, @@ -2734,18 +2741,18 @@ if pdfmode then pdfetcs.fallback_update_resources = function (name, res) local tabname = format("%s_res",name) if not pdfetcs[tabname] then - pdfetcs.initialize_resources(name) + initialize_resources(name) end if luatexbase.callbacktypes.finish_pdffile then local t = pdfetcs[tabname] t[#t+1] = res else - local tpr, n = pdfetcs.getpageres() or "", 0 + local tpr, n = getpageres() or "", 0 tpr, n = tpr:gsub(format("/%s<<",name), "%1"..res) if n == 0 then tpr = format("%s/%s<<%s>>", tpr, name, res) end - pdfetcs.setpageres(tpr) + setpageres(tpr) end end else @@ -3025,7 +3032,8 @@ end % % Patterns % \begin{macrocode} -patterns = { } +pdfetcs.patterns = { } +local patterns = pdfetcs.patterns function luamplib.registerpattern ( boxid, name, opts ) local box = texgetbox(boxid) local wd = format("%.3f",box.width/factor) @@ -3495,7 +3503,7 @@ end \else \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{luamplib} - [2024/06/21 v2.32.3 mplib package for LuaTeX] + [2024/07/03 v2.32.4 mplib package for LuaTeX] \ifx\newluafunction\@undefined \input ltluatex \fi diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua index a68edaf9fdb..ffe7c0e0c41 100644 --- a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua +++ b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua @@ -11,8 +11,8 @@ luatexbase.provides_module { name = "luamplib", - version = "2.32.3", - date = "2024/06/21", + version = "2.32.4", + date = "2024/07/03", description = "Lua package to typeset Metapost with LuaTeX's MPLib.", } @@ -316,6 +316,7 @@ local function reporterror (result, prevlog) end end +if not math.initialseed then math.randomseed(currenttime) end local function luamplibload (name) local mpx = mplib.new { ini_version = true, @@ -965,7 +966,7 @@ function luamplib.glyph (f, c) if not gid then return mperr"cannot get GID (glyph id)" end local fac = 1000 / (shapedata.units or 1000) local t = shapedata.glyphs[gid].segments - if not t then return "image(fill fullcircle scaled 0;)" end + if not t then return "image()" end for i,v in ipairs(t) do if type(v) == "table" then for ii,vv in ipairs(v) do @@ -1215,7 +1216,7 @@ function luamplib.outlinetext (text) local id = tonumber(fmt:match"mplibtexboxid=(%d+):") local box = texgetbox(id) local res = outline_horz({ }, box, box.head, 0, 0) - if #res == 0 then res = { "mpliboutlinepic[1]:=image(fill fullcircle scaled 0;);" } end + if #res == 0 then res = { "mpliboutlinepic[1]:=image();" } end return tableconcat(res) .. format("mpliboutlinenum:=%i;", #res) end @@ -1737,13 +1738,14 @@ end if pdfmode then pdfetcs.getpageres = pdf.getpageresources or function() return pdf.pageresources end - pdfetcs.setpageres = pdf.setpageresources or function(s) pdf.pageresources = s end - pdfetcs.initialize_resources = function (name) + local getpageres = pdfetcs.getpageres + local setpageres = pdf.setpageresources or function(s) pdf.pageresources = s end + local initialize_resources = function (name) local tabname = format("%s_res",name) pdfetcs[tabname] = { } if luatexbase.callbacktypes.finish_pdffile then -- ltluatex local obj = pdf.reserveobj() - pdfetcs.setpageres(format("%s/%s %i 0 R", pdfetcs.getpageres() or "", name, obj)) + setpageres(format("%s/%s %i 0 R", getpageres() or "", name, obj)) luatexbase.add_to_callback("finish_pdffile", function() pdf.immediateobj(obj, format("<<%s>>", tableconcat(pdfetcs[tabname]))) end, @@ -1753,18 +1755,18 @@ if pdfmode then pdfetcs.fallback_update_resources = function (name, res) local tabname = format("%s_res",name) if not pdfetcs[tabname] then - pdfetcs.initialize_resources(name) + initialize_resources(name) end if luatexbase.callbacktypes.finish_pdffile then local t = pdfetcs[tabname] t[#t+1] = res else - local tpr, n = pdfetcs.getpageres() or "", 0 + local tpr, n = getpageres() or "", 0 tpr, n = tpr:gsub(format("/%s<<",name), "%1"..res) if n == 0 then tpr = format("%s/%s<<%s>>", tpr, name, res) end - pdfetcs.setpageres(tpr) + setpageres(tpr) end end else @@ -2032,7 +2034,8 @@ local function do_preobj_SH(object,prescript) return shade_no end -patterns = { } +pdfetcs.patterns = { } +local patterns = pdfetcs.patterns function luamplib.registerpattern ( boxid, name, opts ) local box = texgetbox(boxid) local wd = format("%.3f",box.width/factor) diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty index 3d20838d3f0..94ad015d473 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} - [2024/06/21 v2.32.3 mplib package for LuaTeX] + [2024/07/03 v2.32.4 mplib package for LuaTeX] \ifx\newluafunction\@undefined \input ltluatex \fi -- cgit v1.2.3