texlive[71841] Master/texmf-dist: luamplib (19jul24)

commits+karl at tug.org commits+karl at tug.org
Fri Jul 19 22:28:36 CEST 2024


Revision: 71841
          https://tug.org/svn/texlive?view=revision&revision=71841
Author:   karl
Date:     2024-07-19 22:28:36 +0200 (Fri, 19 Jul 2024)
Log Message:
-----------
luamplib (19jul24)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/luatex/luamplib/NEWS
    trunk/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf
    trunk/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex
    trunk/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-plain.tex
    trunk/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx
    trunk/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
    trunk/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty

Modified: trunk/Master/texmf-dist/doc/luatex/luamplib/NEWS
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/luamplib/NEWS	2024-07-19 20:28:27 UTC (rev 71840)
+++ trunk/Master/texmf-dist/doc/luatex/luamplib/NEWS	2024-07-19 20:28:36 UTC (rev 71841)
@@ -1,5 +1,10 @@
                        History of the luamplib package
 
+2024/07/19 2.34.1
+   * transparency group is available with plain format as well.
+   * transparency group once used is reusable in the TeX code or
+   in other MetaPost code chunks. see the document for details.
+
 2024/07/17 2.34.0
    * support transparency group with metafun format
    * fix regarding default value in circular fading mode

Modified: trunk/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex	2024-07-19 20:28:27 UTC (rev 71840)
+++ trunk/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex	2024-07-19 20:28:36 UTC (rev 71841)
@@ -271,6 +271,7 @@
   picture tex;
   tex = mpliboutlinetext.p ("\bfseries \TeX");
   for i=1 upto mpliboutlinenum:
+    draw image(
     j:=0;
     for item within mpliboutlinepic[i]:
       j:=j+1;
@@ -279,12 +280,13 @@
           withpostscript "collect"
       else:
           withpattern "pattuncolored"
-          withfademethod "linear"
-          withfadebbox (10 llcorner mpliboutlinepic[i], 10 urcorner mpliboutlinepic[i])
           withpen pencircle scaled 1/2
           withcolor (i/4)[red,blue]
       fi;
     endfor
+    )
+    withfademethod "linear"
+    ;
   endfor
 \endmpfig
 \par\leavevmode
@@ -295,7 +297,7 @@
   draw mill
     withfademethod "circular"
     withfadecenter (center mill, center mill)
-    withfaderadius (20, abs(lrcorner mill - llcorner mill)/2)
+    withfaderadius (30, abs(lrcorner mill - llcorner mill)/2)
     withfadeopacity (1, 0)
     ;
 \endmpfig
@@ -318,6 +320,7 @@
       ;
   )
   asgroup "#1"
+  withgroupname "test:#1"
   withtransparency (1,.5)
   ;
   currentpicture := currentpicture scaled 3/4;
@@ -326,6 +329,9 @@
 \hbox{\test{isolated,knockout}\,\test{isolated}\vbox to\MPheight{\vss\hbox{~isolated}\vss}}%
 \hbox{\test{knockout}\,\test{}}%
 \hbox to\MPwidth{\hss knockout\hss}%
+\leavevmode
+\mpfig usemplibgroup "test:isolated,knockout" scaled 2/3 rotated 15 ; \endmpfig
+\usemplibgroup{test:isolated,knockout}%
 \tracingcommands0
 
 \vskip 2\baselineskip

Modified: trunk/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-plain.tex
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-plain.tex	2024-07-19 20:28:27 UTC (rev 71840)
+++ trunk/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-plain.tex	2024-07-19 20:28:36 UTC (rev 71841)
@@ -263,6 +263,7 @@
 \mpfig
   picture tex;
   tex = mpliboutlinetext.p ("\bf \TeX");
+  draw image(
   for i=1 upto mpliboutlinenum:
     j:=0;
     for item within mpliboutlinepic[i]:
@@ -272,16 +273,19 @@
           withpostscript "collect"
       else:
           withpattern "pattuncolored"
-          withfademethod "linear"
-          withfadebbox (10 llcorner tex, 10 urcorner tex)
           withpen pencircle scaled 1/2
           withcolor (i/4)[red,blue]
       fi;
     endfor
   endfor
+  )
+  withfademethod "linear"
+  ;
 \endmpfig
+\par\leavevmode
 \mpfig
 fill fullcircle scaled 125 withcolor 2/3[blue,white];
+fill fullcircle scaled 80  withcolor 2/3[red,white];
 draw image(
   draw (left--right) rotated 45 scaled 50
     withpen pencircle scaled 20
@@ -291,9 +295,18 @@
     ;
   )
   asgroup ""
+  withgroupname "testTRgroup"
   withprescript "tr_transparency=.3"
   ;
 \endmpfig
+\mpfig
+fill fullcircle scaled 125 withcolor 2/3[red,white];
+fill fullcircle scaled 80  withcolor 2/3[blue,white];
+usemplibgroup "testTRgroup"
+  withfademethod "circular"
+  withfaderadius (0,60)
+  ;
+\endmpfig
 \tracingcommands0
 
 \vskip 2\baselineskip

Modified: trunk/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx
===================================================================
--- trunk/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx	2024-07-19 20:28:27 UTC (rev 71840)
+++ trunk/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx	2024-07-19 20:28:36 UTC (rev 71841)
@@ -85,7 +85,7 @@
 %<*driver>
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesFile{luamplib.drv}%
-  [2024/07/17 v2.34.0 Interface for using the mplib library]%
+  [2024/07/19 v2.34.1 Interface for using the mplib library]%
 \documentclass{ltxdoc}
 \usepackage{metalogo,multicol,mdwlist,fancyvrb,xspace}
 \usepackage[x11names]{xcolor}
@@ -153,7 +153,7 @@
 % \author{Hans Hagen, Taco Hoekwater, Elie Roux, Philipp Gesang and Kim Dohyun\\
 % Current Maintainer: Kim Dohyun\\
 % Support: \url{https://github.com/lualatex/luamplib}}
-% \date{2024/07/17 v2.34.0}
+% \date{2024/07/19 v2.34.1}
 %
 % \maketitle
 %
@@ -254,6 +254,8 @@
 %   where \emph{<string>} should be |""| (empty), |"isolated"|, |"knockout"|, or |"isolated,knockout"|.
 %   Beware that currently many of the PDF rendering applications, except Adobe Acrobat Reader,
 %   cannot properly render the isolated or knockout effect.
+%   Transparency group is available with \emph{plain} format as well, with extended functionality.
+%   See below \S\,1.2.
 %
 %   One thing worth mentioning about shading is:
 %   when a color expression is given in string type,
@@ -765,6 +767,61 @@
 %     \endmpfig
 %\end{verbatim}
 %
+% \paragraph{Transparency Group}
+% As said before,
+% transparency group is available with \emph{plain} as well as \emph{metafun} format.
+% The syntax is exactly the same:
+% \emph{<picture>} \char"7C\ \emph{<path>} |asgroup|
+% |""| \char"7C\ |"isolated"| \char"7C\ |"knockout"| \char"7C\ |"isolated,knockout"|,
+% which will return a metapost picture.
+%
+% The additional feature provided by luamplib is that
+% you can reuse the group as many times as you want
+% in the \TeX{} code or in other MetaPost code chunks,
+% with infinitesimal increase in the size of PDF file.
+% For this functionality we provide \TeX{} and MetaPost macros as follows:
+% \begin{description}
+%   \let\bfseries\relax
+% \item[|withgroupname| \emph{<string>}] associates a transparency group with the given name.
+%   When this is not appended to the sentense with |asgroup| operator,
+%   the default group name `|lastmplibgroup|' will be used.
+%
+% \item[\cs{usemplibgroup\{...\}}] is a \TeX\ command to reuse a transparency group of the name
+%   once used.
+%   Note that the position of the group will be origin-based:
+%   in other words, lower-left corner of the group will be shifted to the origin.
+%
+% \item[|usemplibgroup| \emph{<string>}] is a MetaPost command which will add
+%   a transparency group of the name to the |currentpicture|.
+%   Contrary to the \TeX\ command just mentioned,
+%   the position of the group is the same as the original transparency group.
+% \end{description}
+% An example showing the difference between the \TeX\ and MetaPost commands:
+%\begin{verbatim}
+%   \mpfig
+%     draw image(
+%       fill fullcircle scaled 100 shifted 25right withcolor .5[blue,white];
+%       fill fullcircle scaled 100 withcolor .5[red,white] ;
+%     ) asgroup "" withgroupname "mygroup";
+%     draw (left--right) scaled 10;
+%     draw (up--down) scaled 10;
+%   \endmpfig
+%
+%   \noindent
+%   \llap{\vrule width 10pt height .25pt depth .25pt}%
+%   \clap{\vrule width .5pt height 10pt depth 10pt}%
+%   \rlap{\vrule width 10pt height .25pt depth .25pt}%
+%   \usemplibgroup{mygroup}
+%
+%   \mpfig
+%     usemplibgroup "mygroup" rotated 15;
+%     draw (left--right) scaled 10;
+%     draw (up--down) scaled 10;
+%   \endmpfig
+%\end{verbatim}
+% Also note that reused transparency groups are not affected by color commands,
+% transparency/fading commands will have effects though.
+%
 % \subsection{Lua}
 %
 % \paragraph{\texttt{runscript ...}}
@@ -850,8 +907,8 @@
 
 luatexbase.provides_module {
   name          = "luamplib",
-  version       = "2.34.0",
-  date          = "2024/07/17",
+  version       = "2.34.1",
+  date          = "2024/07/19",
   description   = "Lua package to typeset Metapost with LuaTeX's MPLib.",
 }
 
@@ -2558,6 +2615,22 @@
     decimal xpart b & ":" &
     decimal ypart b
 enddef;
+primarydef p asgroup s =
+  image(
+    fill llcorner p--lrcorner p--urcorner p--ulcorner p--cycle
+      withprescript "gr_state=start"
+      withprescript "gr_type=" & s;
+    draw p;
+    draw center p withprescript "gr_state=stop";
+  )
+enddef;
+def withgroupname expr s =
+  withprescript "mplibgroupname=" & s
+enddef;
+def usemplibgroup primary s =
+  draw maketext("\usemplibgroup{" & s & "}")
+    shifted runscript("return luamplib.trgroupshifts['" & s & "']")
+enddef;
 ]],
   legacyverbatimtex = [[
 def specialVerbatimTeX (text t) = runscript("luamplibprefig{"&t&"}") enddef;
@@ -3156,8 +3229,8 @@
 %    \begin{macrocode}
 pdfetcs.patterns = { }
 local patterns = pdfetcs.patterns
-local function gather_resources (do_pattern, optres)
-  local t = { }
+local function gather_resources (optres)
+  local t, do_pattern = { }, not optres
   local names = {"ExtGState","ColorSpace","Shading"}
   if do_pattern then
     names[#names+1] = "Pattern"
@@ -3173,10 +3246,12 @@
     else
       local res = pdfetcs.getpageres() or ""
       run_tex_code[[\mplibtmptoks\expandafter{\the\pdfvariable pageresources}]]
-      res = (res .. texgettoks'mplibtmptoks'):explode()
-      res = tableconcat(res," "):explode"/+"
+      res = res .. texgettoks'mplibtmptoks'
+      if do_pattern then return res end
+      res = res:explode"/+"
       for _,v in ipairs(res) do
-        if do_pattern or not v:find"Pattern" and not optres:find(v) then
+        v = v:match"^%s*(.-)%s*$"
+        if not v:find"Pattern" and not optres:find(v) then
           t[#t+1] = "/" .. v
         end
       end
@@ -3212,7 +3287,7 @@
       end
     end
   end
-  return t
+  return tableconcat(t)
 end
 function luamplib.registerpattern ( boxid, name, opts )
   local box = texgetbox(boxid)
@@ -3247,8 +3322,7 @@
     format("/Matrix [%s %s %s]", opts.matrix or "1 0 0 1", opts.xshift or 0, opts.yshift or 0),
   }
   local optres = opts.resources or ""
-  local t = gather_resources(false, optres)
-  optres = optres .. tableconcat(t)
+  optres = optres .. gather_resources(optres)
   if pdfmode then
     if opts.bbox then
       attr[#attr+1] = format("/BBox [%s]", opts.bbox)
@@ -3259,15 +3333,14 @@
     local objname = "@mplibpattern"..name
     local metric = format("bbox %s", opts.bbox or format("0 0 %s %s",wd,hd))
     texsprint {
-      [[\ifvmode\nointerlineskip\fi]],
-      format([[\hbox to0pt{\vbox to0pt{\hsize=\wd %i\vss\noindent]], boxid), -- force horiz mode?
-      [[\special{pdf:bcontent}]],
-      [[\special{pdf:bxobj ]], objname, format(" %s}", metric),
-      format([[\raise\dp %i\box %i]], boxid, boxid),
-      format([[\special{pdf:put @resources <<%s>>}]], optres),
-      [[\special{pdf:exobj <<]], tableconcat(attr), ">>}",
-      [[\special{pdf:econtent}]],
-      [[\par}\hss}]],
+      "\\ifvmode\\nointerlineskip\\fi\\vbox to0pt{\\vss\\hbox to0pt{",
+      "\\special{pdf:bcontent}",
+      "\\special{pdf:bxobj ", objname, " ", metric, "}",
+      "\\raise\\dp ", boxid, "\\box ", boxid,
+      "\\special{pdf:put @resources <<", optres, ">>}",
+      "\\special{pdf:exobj <<", tableconcat(attr), ">>}",
+      "\\special{pdf:econtent}",
+      "\\hss}}",
     }
     patterns[#patterns+1] = objname
     patterns[name] = { id = #patterns, colored = opts.colored }
@@ -3421,12 +3494,14 @@
 %
 %    Transparency Group
 %    \begin{macrocode}
-pdfetcs.tr_group = { }
+pdfetcs.tr_group = { shifts = { } }
+luamplib.trgroupshifts = pdfetcs.tr_group.shifts
 local function do_preobj_GRP (object, prescript)
   local grstate = prescript and prescript.gr_state
   if not grstate then return end
   local trgroup = pdfetcs.tr_group
   if grstate == "start" then
+    trgroup.name = prescript.mplibgroupname or "lastmplibgroup"
     trgroup.isolated, trgroup.knockout = false, false
     for _,v in ipairs(prescript.gr_type:explode",+") do
       trgroup[v] = true
@@ -3442,7 +3517,7 @@
   elseif grstate == "stop" then
     local llx,lly,urx,ury = tableunpack(trgroup.bbox)
     local grattr = format("/Group<</S/Transparency/I %s/K %s>>",trgroup.isolated,trgroup.knockout)
-    local res = tableconcat(gather_resources(true))
+    local res = gather_resources()
     put2output(tableconcat{
       "\\egroup",
       format("\\wd\\mplibscratchbox %fbp", urx-llx),
@@ -3457,6 +3532,9 @@
         [[\setbox\mplibscratchbox\hbox{\useboxresource\lastsavedboxresourceindex}]],
         [[\wd\mplibscratchbox 0pt\ht\mplibscratchbox 0pt\dp\mplibscratchbox 0pt]],
         [[\box\mplibscratchbox\endgroup]],
+        "\\expandafter\\xdef\\csname luamplib.group.", trgroup.name, "\\endcsname{",
+        "\\noexpand\\mplibstarttoPDF{",llx,"}{",lly,"}{",urx,"}{",ury,"}",
+        "\\useboxresource \\the\\lastsavedboxresourceindex\\noexpand\\mplibstoptoPDF}",
       })
     else
       trgroup.cnt = (trgroup.cnt or 0) + 1
@@ -3467,8 +3545,12 @@
         "\\special{pdf:put @resources <<", res, ">>}",
         "\\special{pdf:exobj <<", grattr, ">>}",
         "\\special{pdf:uxobj ", objname, "}\\endgroup",
+        "\\expandafter\\gdef\\csname luamplib.group.", trgroup.name, "\\endcsname{",
+        "\\mplibstarttoPDF{",llx,"}{",lly,"}{",urx,"}{",ury,"}",
+        "\\special{pdf:uxobj ", objname, "}\\mplibstoptoPDF}",
       })
     end
+    trgroup.shifts[trgroup.name] = { llx, lly }
   end
   return grstate
 end
@@ -3894,7 +3976,7 @@
 \else
   \NeedsTeXFormat{LaTeX2e}
   \ProvidesPackage{luamplib}
-    [2024/07/17 v2.34.0 mplib package for LuaTeX]
+    [2024/07/19 v2.34.1 mplib package for LuaTeX]
   \ifx\newluafunction\@undefined
   \input ltluatex
   \fi
@@ -3958,6 +4040,11 @@
 \def\mplibputtextbox#1{\vbox to 0pt{\vss\hbox to 0pt{\raise\dp#1\copy#1\hss}}}
 %    \end{macrocode}
 %
+%    use Transparency Group
+%    \begin{macrocode}
+\protected\def\usemplibgroup#1{\csname luamplib.group.#1\endcsname}
+%    \end{macrocode}
+%
 %    Patterns
 %    \begin{macrocode}
 {\def\:{\global\let\mplibsptoken= } \: }

Modified: trunk/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua	2024-07-19 20:28:27 UTC (rev 71840)
+++ trunk/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua	2024-07-19 20:28:36 UTC (rev 71841)
@@ -11,8 +11,8 @@
 
 luatexbase.provides_module {
   name          = "luamplib",
-  version       = "2.34.0",
-  date          = "2024/07/17",
+  version       = "2.34.1",
+  date          = "2024/07/19",
   description   = "Lua package to typeset Metapost with LuaTeX's MPLib.",
 }
 
@@ -1458,6 +1458,22 @@
     decimal xpart b & ":" &
     decimal ypart b
 enddef;
+primarydef p asgroup s =
+  image(
+    fill llcorner p--lrcorner p--urcorner p--ulcorner p--cycle
+      withprescript "gr_state=start"
+      withprescript "gr_type=" & s;
+    draw p;
+    draw center p withprescript "gr_state=stop";
+  )
+enddef;
+def withgroupname expr s =
+  withprescript "mplibgroupname=" & s
+enddef;
+def usemplibgroup primary s =
+  draw maketext("\usemplibgroup{" & s & "}")
+    shifted runscript("return luamplib.trgroupshifts['" & s & "']")
+enddef;
 ]],
   legacyverbatimtex = [[
 def specialVerbatimTeX (text t) = runscript("luamplibprefig{"&t&"}") enddef;
@@ -1993,8 +2009,8 @@
 
 pdfetcs.patterns = { }
 local patterns = pdfetcs.patterns
-local function gather_resources (do_pattern, optres)
-  local t = { }
+local function gather_resources (optres)
+  local t, do_pattern = { }, not optres
   local names = {"ExtGState","ColorSpace","Shading"}
   if do_pattern then
     names[#names+1] = "Pattern"
@@ -2010,10 +2026,12 @@
     else
       local res = pdfetcs.getpageres() or ""
       run_tex_code[[\mplibtmptoks\expandafter{\the\pdfvariable pageresources}]]
-      res = (res .. texgettoks'mplibtmptoks'):explode()
-      res = tableconcat(res," "):explode"/+"
+      res = res .. texgettoks'mplibtmptoks'
+      if do_pattern then return res end
+      res = res:explode"/+"
       for _,v in ipairs(res) do
-        if do_pattern or not v:find"Pattern" and not optres:find(v) then
+        v = v:match"^%s*(.-)%s*$"
+        if not v:find"Pattern" and not optres:find(v) then
           t[#t+1] = "/" .. v
         end
       end
@@ -2049,7 +2067,7 @@
       end
     end
   end
-  return t
+  return tableconcat(t)
 end
 function luamplib.registerpattern ( boxid, name, opts )
   local box = texgetbox(boxid)
@@ -2084,8 +2102,7 @@
     format("/Matrix [%s %s %s]", opts.matrix or "1 0 0 1", opts.xshift or 0, opts.yshift or 0),
   }
   local optres = opts.resources or ""
-  local t = gather_resources(false, optres)
-  optres = optres .. tableconcat(t)
+  optres = optres .. gather_resources(optres)
   if pdfmode then
     if opts.bbox then
       attr[#attr+1] = format("/BBox [%s]", opts.bbox)
@@ -2096,15 +2113,14 @@
     local objname = "@mplibpattern"..name
     local metric = format("bbox %s", opts.bbox or format("0 0 %s %s",wd,hd))
     texsprint {
-      [[\ifvmode\nointerlineskip\fi]],
-      format([[\hbox to0pt{\vbox to0pt{\hsize=\wd %i\vss\noindent]], boxid), -- force horiz mode?
-      [[\special{pdf:bcontent}]],
-      [[\special{pdf:bxobj ]], objname, format(" %s}", metric),
-      format([[\raise\dp %i\box %i]], boxid, boxid),
-      format([[\special{pdf:put @resources <<%s>>}]], optres),
-      [[\special{pdf:exobj <<]], tableconcat(attr), ">>}",
-      [[\special{pdf:econtent}]],
-      [[\par}\hss}]],
+      "\\ifvmode\\nointerlineskip\\fi\\vbox to0pt{\\vss\\hbox to0pt{",
+      "\\special{pdf:bcontent}",
+      "\\special{pdf:bxobj ", objname, " ", metric, "}",
+      "\\raise\\dp ", boxid, "\\box ", boxid,
+      "\\special{pdf:put @resources <<", optres, ">>}",
+      "\\special{pdf:exobj <<", tableconcat(attr), ">>}",
+      "\\special{pdf:econtent}",
+      "\\hss}}",
     }
     patterns[#patterns+1] = objname
     patterns[name] = { id = #patterns, colored = opts.colored }
@@ -2250,12 +2266,14 @@
   return "start"
 end
 
-pdfetcs.tr_group = { }
+pdfetcs.tr_group = { shifts = { } }
+luamplib.trgroupshifts = pdfetcs.tr_group.shifts
 local function do_preobj_GRP (object, prescript)
   local grstate = prescript and prescript.gr_state
   if not grstate then return end
   local trgroup = pdfetcs.tr_group
   if grstate == "start" then
+    trgroup.name = prescript.mplibgroupname or "lastmplibgroup"
     trgroup.isolated, trgroup.knockout = false, false
     for _,v in ipairs(prescript.gr_type:explode",+") do
       trgroup[v] = true
@@ -2271,7 +2289,7 @@
   elseif grstate == "stop" then
     local llx,lly,urx,ury = tableunpack(trgroup.bbox)
     local grattr = format("/Group<</S/Transparency/I %s/K %s>>",trgroup.isolated,trgroup.knockout)
-    local res = tableconcat(gather_resources(true))
+    local res = gather_resources()
     put2output(tableconcat{
       "\\egroup",
       format("\\wd\\mplibscratchbox %fbp", urx-llx),
@@ -2286,6 +2304,9 @@
         [[\setbox\mplibscratchbox\hbox{\useboxresource\lastsavedboxresourceindex}]],
         [[\wd\mplibscratchbox 0pt\ht\mplibscratchbox 0pt\dp\mplibscratchbox 0pt]],
         [[\box\mplibscratchbox\endgroup]],
+        "\\expandafter\\xdef\\csname luamplib.group.", trgroup.name, "\\endcsname{",
+        "\\noexpand\\mplibstarttoPDF{",llx,"}{",lly,"}{",urx,"}{",ury,"}",
+        "\\useboxresource \\the\\lastsavedboxresourceindex\\noexpand\\mplibstoptoPDF}",
       })
     else
       trgroup.cnt = (trgroup.cnt or 0) + 1
@@ -2296,8 +2317,12 @@
         "\\special{pdf:put @resources <<", res, ">>}",
         "\\special{pdf:exobj <<", grattr, ">>}",
         "\\special{pdf:uxobj ", objname, "}\\endgroup",
+        "\\expandafter\\gdef\\csname luamplib.group.", trgroup.name, "\\endcsname{",
+        "\\mplibstarttoPDF{",llx,"}{",lly,"}{",urx,"}{",ury,"}",
+        "\\special{pdf:uxobj ", objname, "}\\mplibstoptoPDF}",
       })
     end
+    trgroup.shifts[trgroup.name] = { llx, lly }
   end
   return grstate
 end

Modified: trunk/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty	2024-07-19 20:28:27 UTC (rev 71840)
+++ trunk/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty	2024-07-19 20:28:36 UTC (rev 71841)
@@ -14,7 +14,7 @@
 \else
   \NeedsTeXFormat{LaTeX2e}
   \ProvidesPackage{luamplib}
-    [2024/07/17 v2.34.0 mplib package for LuaTeX]
+    [2024/07/19 v2.34.1 mplib package for LuaTeX]
   \ifx\newluafunction\@undefined
   \input ltluatex
   \fi
@@ -46,6 +46,7 @@
   \catcode`\&=12 \catcode`\$=12 \catcode`\%=12 \catcode`\^^M=12
 }
 \def\mplibputtextbox#1{\vbox to 0pt{\vss\hbox to 0pt{\raise\dp#1\copy#1\hss}}}
+\protected\def\usemplibgroup#1{\csname luamplib.group.#1\endcsname}
 {\def\:{\global\let\mplibsptoken= } \: }
 \protected\def\mppattern#1{%
   \begingroup



More information about the tex-live-commits mailing list.