texlive[72995] Master/texmf-dist: luamplib (28nov24)
commits+karl at tug.org
commits+karl at tug.org
Thu Nov 28 22:25:35 CET 2024
Revision: 72995
https://tug.org/svn/texlive?view=revision&revision=72995
Author: karl
Date: 2024-11-28 22:25:35 +0100 (Thu, 28 Nov 2024)
Log Message:
-----------
luamplib (28nov24)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/luatex/luamplib/NEWS
trunk/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf
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-11-28 21:24:56 UTC (rev 72994)
+++ trunk/Master/texmf-dist/doc/luatex/luamplib/NEWS 2024-11-28 21:25:35 UTC (rev 72995)
@@ -1,5 +1,9 @@
History of the luamplib package
+2024/11/28 2.35.2
+ * fix height/depth of boxes made by \mplibgroup command
+ * enhanced tagging of \usemplibgroup
+
2024/11/25 2.35.1
* cope with 'TEX(char13)': remove everything from char13 to the end of
input string (https://tug.org/pipermail/metapost/2024-November/003572.html)
Modified: trunk/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx
===================================================================
--- trunk/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx 2024-11-28 21:24:56 UTC (rev 72994)
+++ trunk/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx 2024-11-28 21:25:35 UTC (rev 72995)
@@ -85,7 +85,7 @@
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{luamplib.drv}%
- [2024/11/25 v2.35.1 Interface for using the mplib library]%
+ [2024/11/28 v2.35.2 Interface for using the mplib library]%
\documentclass{ltxdoc}
\usepackage{metalogo,multicol,xspace}
\usepackage[x11names]{xcolor}
@@ -155,7 +155,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/11/25 v2.35.1}
+% \date{2024/11/28 v2.35.2}
%
% \maketitle
%
@@ -354,7 +354,7 @@
% will be typeset with the current \TeX\ font.
%
% From v2.35, however, the redefinition of |infont| operator has been revised:
-% when the character slot of the text argument is less than $32$~(control characters),
+% when the character code of the text argument is less than $32$~(control characters),
% or is equal to $35$~(|#|), $36$~(|$|), \iffalse |$|\fi
% $37$~(|%|), $38$~(|&|), $92$~(|\|), $94$~(|^|),
% $95$~(|_|), $123$~(|{|), $125$~(|}|), $126$~(|~|) or $127$~(DEL),
@@ -1009,7 +1009,8 @@
% As shown in the example, you can reuse the mplibgroup once defined
% using the \TeX\ command \cs{usemplibgroup} or
% the \metapost command |usemplibgroup|.
-% The behavior of these commands is the same as that described \hyperlink{usemplibgroup}{above}.
+% The behavior of these commands is the same as that described \hyperlink{usemplibgroup}{above},
+% excepting that mplibgroup made by \TeX\ code (not by \metapost code) respects original height and depth.
%
%
% \subsection{Lua}
@@ -1097,8 +1098,8 @@
luatexbase.provides_module {
name = "luamplib",
- version = "2.35.1",
- date = "2024/11/25",
+ version = "2.35.2",
+ date = "2024/11/28",
description = "Lua package to typeset Metapost with LuaTeX's MPLib.",
}
@@ -2811,7 +2812,7 @@
withprescript "mplibgroupname=" & s
enddef;
def usemplibgroup primary s =
- draw maketext("\mplibnoforcehmode\csname luamplib.group." & s & "\endcsname")
+ draw maketext("\csname luamplib.group." & s & "\endcsname")
shifted runscript("return luamplib.trgroupshifts['" & s & "']")
enddef;
]],
@@ -3684,12 +3685,17 @@
put2output(tableconcat{
"\\saveboxresource type 2 attr{/Type/XObject/Subtype/Form/FormType 1",
"/BBox[", bbox, "]", grattr, "} resources{", res, "}\\mplibscratchbox",
+ "\\luamplibtagasgroupbegin",
[[\setbox\mplibscratchbox\hbox{\useboxresource\lastsavedboxresourceindex}]],
[[\wd\mplibscratchbox 0pt\ht\mplibscratchbox 0pt\dp\mplibscratchbox 0pt]],
- [[\box\mplibscratchbox\endgroup]],
+ [[\box\mplibscratchbox]],
+ "\\luamplibtagasgroupend",
+ "\\endgroup",
"\\expandafter\\xdef\\csname luamplib.group.", trgroup.name, "\\endcsname{",
- "\\noexpand\\mplibstarttoPDF{",llx,"}{",lly,"}{",urx,"}{",ury,"}",
- "\\useboxresource \\the\\lastsavedboxresourceindex\\noexpand\\mplibstoptoPDF}",
+ "\\setbox\\mplibscratchbox\\hbox{\\hskip",-llx,"bp\\raise",-lly,"bp\\hbox{",
+ "\\useboxresource \\the\\lastsavedboxresourceindex",
+ "}}\\wd\\mplibscratchbox",urx-llx,"bp\\ht\\mplibscratchbox",ury-lly,"bp",
+ "\\box\\mplibscratchbox}",
})
else
trgroup.cnt = (trgroup.cnt or 0) + 1
@@ -3699,11 +3705,14 @@
"\\unhbox\\mplibscratchbox",
"\\special{pdf:put @resources <<", res, ">>}",
"\\special{pdf:exobj <<", grattr, ">>}",
- "\\special{pdf:uxobj ", objname, "}\\endgroup",
+ "\\special{pdf:uxobj ", objname, "}",
+ "\\endgroup",
})
token.set_macro("luamplib.group."..trgroup.name, tableconcat{
- "\\mplibstarttoPDF{",llx,"}{",lly,"}{",urx,"}{",ury,"}",
- "\\special{pdf:uxobj ", objname, "}\\mplibstoptoPDF",
+ "\\setbox\\mplibscratchbox\\hbox{\\hskip",-llx,"bp\\raise",-lly,"bp\\hbox{",
+ "\\special{pdf:uxobj ", objname, "}",
+ "}}\\wd\\mplibscratchbox",urx-llx,"bp\\ht\\mplibscratchbox",ury-lly,"bp",
+ "\\box\\mplibscratchbox",
}, "global")
end
trgroup.shifts[trgroup.name] = { llx, lly }
@@ -3739,16 +3748,13 @@
local trgroup = pdfetcs.tr_group
trgroup.shifts[name] = { get_macro'MPllx', get_macro'MPlly' }
local whd
- local urx, ury = wd/factor, (ht+dp)/factor
if pdfmode then
attr = tableconcat(attr) :gsub(decimals,rmzeros)
local index = tex.saveboxresource(boxid, attr, res, true, grtype)
token.set_macro("luamplib.group."..name, tableconcat{
- "\\mplibstarttoPDF{0}{0}{",urx,"}{",ury,"}",
"\\useboxresource ", index,
- "\\mplibstoptoPDF",
}, "global")
- whd = format("%.3f %.3f 0", urx, ury) :gsub(decimals,rmzeros)
+ whd = format("%.3f %.3f 0", wd/factor, (ht+dp)/factor) :gsub(decimals,rmzeros)
else
trgroup.cnt = (trgroup.cnt or 0) + 1
local objname = format("@mplibtrgr%s", trgroup.cnt)
@@ -3764,15 +3770,13 @@
"\\special{pdf:econtent}}",
}
token.set_macro("luamplib.group."..name, tableconcat{
- "\\mplibstarttoPDF{0}{0}{",urx,"}{",ury,"}",
"\\setbox\\mplibscratchbox\\hbox{\\special{pdf:uxobj ", objname, "}}",
"\\wd\\mplibscratchbox ", wd, "sp",
"\\ht\\mplibscratchbox ", ht, "sp",
"\\dp\\mplibscratchbox ", dp, "sp",
"\\box\\mplibscratchbox",
- "\\mplibstoptoPDF",
}, "global")
- whd = format("%.3f %.3f %.3f", urx, ht/factor, dp/factor) :gsub(decimals,rmzeros)
+ whd = format("%.3f %.3f %.3f", wd/factor, ht/factor, dp/factor) :gsub(decimals,rmzeros)
end
info("w/h/d of group '%s': %s", name, whd)
end
@@ -4201,7 +4205,7 @@
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{luamplib}
- [2024/11/25 v2.35.1 mplib package for LuaTeX]
+ [2024/11/28 v2.35.2 mplib package for LuaTeX]
\fi
\ifdefined\newluafunction\else
\input ltluatex
@@ -4286,7 +4290,13 @@
% use Transparency Group
% \begin{macrocode}
\protected\def\usemplibgroup#1#{\usemplibgroupmain}
-\def\usemplibgroupmain#1{\csname luamplib.group.#1\endcsname}
+\def\usemplibgroupmain#1{%
+ \mplibstarttousemplibgroup
+ \csname luamplib.group.#1\endcsname
+ \mplibstoptousemplibgroup
+}
+\def\mplibstarttousemplibgroup{\prependtomplibbox\hbox\bgroup}
+\def\mplibstoptousemplibgroup{\egroup}
\protected\def\mplibgroup#1{%
\begingroup
\def\MPllx{0}\def\MPlly{0}%
@@ -4713,6 +4723,8 @@
% \begin{macrocode}
\def\luamplibtagtextbegin#1{}
\let\luamplibtagtextend\relax
+\let\luamplibtagasgroupbegin\relax
+\let\luamplibtagasgroupend\relax
\ifcsname SuspendTagging\endcsname\else\endinput\fi
\ifcsname ver at tagpdf.sty\endcsname \else
\ExplSyntaxOn
@@ -4742,6 +4754,8 @@
\let\mplibstarttoPDForiginal\mplibstarttoPDF
\let\mplibstoptoPDForiginal\mplibstoptoPDF
\let\mplibputtextboxoriginal\mplibputtextbox
+\let\mplibstarttousemplibgrouporiginal\mplibstarttousemplibgroup
+\let\mplibstoptousemplibgrouporiginal\mplibstoptousemplibgroup
\ExplSyntaxOn
\tl_new:N \l__luamplib_tag_alt_tl
\tl_new:N \l__luamplib_tag_alt_dflt_tl
@@ -4773,8 +4787,8 @@
}
{
\tag_if_active:TF
- { \chardef\mplibtmpnum\@ne }
- { \chardef\mplibtmpnum\z@ }
+ { \bool_set_true:N \l_tmpa_bool }
+ { \bool_set_false:N \l_tmpa_bool }
\SuspendTagging{luamplib.textext}
}
}
@@ -4796,9 +4810,8 @@
\tag_mc_begin_pop:n{}
}
{
- \ifnum\mplibtmpnum=\@ne
- \ResumeTagging{luamplib.textext}
- \fi
+ \bool_if:NT \l_tmpa_bool
+ { \ResumeTagging{luamplib.textext} }
}
}
\msg_new:nnn {luamplib}{figure-text-reuse}
@@ -5082,6 +5095,46 @@
}
}
}
+\cs_set_nopar:Npn \luamplibtagasgroupbegin
+{
+ \bool_if:NT \l__luamplib_tag_usetext_bool
+ {
+ \ResumeTagging{luamplib.asgroup}
+ \tag_mc_begin:n{}
+ }
+}
+\cs_set_nopar:Npn \luamplibtagasgroupend
+{
+ \bool_if:NT \l__luamplib_tag_usetext_bool
+ {
+ \tag_mc_end:
+ \SuspendTagging{luamplib.asgroup}
+ }
+}
+\cs_set_nopar:Npn \mplibstarttousemplibgroup
+{
+ \prependtomplibbox\hbox\bgroup
+ \luamplibtaggingbegin
+ \setbox\mplibscratchbox\hbox\bgroup
+ \bool_if:NT \l__luamplib_tag_usetext_bool
+ {
+ \tag_mc_end:
+ \tag_mc_begin:n{}
+ }
+}
+\cs_set_nopar:Npn \mplibstoptousemplibgroup
+{
+ \bool_if:NT \l__luamplib_tag_usetext_bool
+ {
+ \tag_mc_end:
+ \tag_mc_begin:n{artifact}
+ }
+ \egroup
+ \luamplibtaggingBBox
+ \unhbox\mplibscratchbox
+ \luamplibtaggingend
+ \egroup
+}
\cs_set_nopar:Npn \mplibstarttoPDF #1 #2 #3 #4
{
\prependtomplibbox
@@ -5161,7 +5214,9 @@
}
\keys_set:nn{luamplib/tag}{#1}
\tl_set:Nn\l__luamplib_tag_alt_dflt_tl {metapost~figure~#2}
+ \mplibstarttousemplibgroup
\csname luamplib.group.#2\endcsname
+ \mplibstoptousemplibgroup
\endgroup
}
\cs_new_nopar:Npn \mplibalttext #1
Modified: trunk/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua 2024-11-28 21:24:56 UTC (rev 72994)
+++ trunk/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua 2024-11-28 21:25:35 UTC (rev 72995)
@@ -11,8 +11,8 @@
luatexbase.provides_module {
name = "luamplib",
- version = "2.35.1",
- date = "2024/11/25",
+ version = "2.35.2",
+ date = "2024/11/28",
description = "Lua package to typeset Metapost with LuaTeX's MPLib.",
}
@@ -1462,7 +1462,7 @@
withprescript "mplibgroupname=" & s
enddef;
def usemplibgroup primary s =
- draw maketext("\mplibnoforcehmode\csname luamplib.group." & s & "\endcsname")
+ draw maketext("\csname luamplib.group." & s & "\endcsname")
shifted runscript("return luamplib.trgroupshifts['" & s & "']")
enddef;
]],
@@ -2264,12 +2264,17 @@
put2output(tableconcat{
"\\saveboxresource type 2 attr{/Type/XObject/Subtype/Form/FormType 1",
"/BBox[", bbox, "]", grattr, "} resources{", res, "}\\mplibscratchbox",
+ "\\luamplibtagasgroupbegin",
[[\setbox\mplibscratchbox\hbox{\useboxresource\lastsavedboxresourceindex}]],
[[\wd\mplibscratchbox 0pt\ht\mplibscratchbox 0pt\dp\mplibscratchbox 0pt]],
- [[\box\mplibscratchbox\endgroup]],
+ [[\box\mplibscratchbox]],
+ "\\luamplibtagasgroupend",
+ "\\endgroup",
"\\expandafter\\xdef\\csname luamplib.group.", trgroup.name, "\\endcsname{",
- "\\noexpand\\mplibstarttoPDF{",llx,"}{",lly,"}{",urx,"}{",ury,"}",
- "\\useboxresource \\the\\lastsavedboxresourceindex\\noexpand\\mplibstoptoPDF}",
+ "\\setbox\\mplibscratchbox\\hbox{\\hskip",-llx,"bp\\raise",-lly,"bp\\hbox{",
+ "\\useboxresource \\the\\lastsavedboxresourceindex",
+ "}}\\wd\\mplibscratchbox",urx-llx,"bp\\ht\\mplibscratchbox",ury-lly,"bp",
+ "\\box\\mplibscratchbox}",
})
else
trgroup.cnt = (trgroup.cnt or 0) + 1
@@ -2279,11 +2284,14 @@
"\\unhbox\\mplibscratchbox",
"\\special{pdf:put @resources <<", res, ">>}",
"\\special{pdf:exobj <<", grattr, ">>}",
- "\\special{pdf:uxobj ", objname, "}\\endgroup",
+ "\\special{pdf:uxobj ", objname, "}",
+ "\\endgroup",
})
token.set_macro("luamplib.group."..trgroup.name, tableconcat{
- "\\mplibstarttoPDF{",llx,"}{",lly,"}{",urx,"}{",ury,"}",
- "\\special{pdf:uxobj ", objname, "}\\mplibstoptoPDF",
+ "\\setbox\\mplibscratchbox\\hbox{\\hskip",-llx,"bp\\raise",-lly,"bp\\hbox{",
+ "\\special{pdf:uxobj ", objname, "}",
+ "}}\\wd\\mplibscratchbox",urx-llx,"bp\\ht\\mplibscratchbox",ury-lly,"bp",
+ "\\box\\mplibscratchbox",
}, "global")
end
trgroup.shifts[trgroup.name] = { llx, lly }
@@ -2319,16 +2327,13 @@
local trgroup = pdfetcs.tr_group
trgroup.shifts[name] = { get_macro'MPllx', get_macro'MPlly' }
local whd
- local urx, ury = wd/factor, (ht+dp)/factor
if pdfmode then
attr = tableconcat(attr) :gsub(decimals,rmzeros)
local index = tex.saveboxresource(boxid, attr, res, true, grtype)
token.set_macro("luamplib.group."..name, tableconcat{
- "\\mplibstarttoPDF{0}{0}{",urx,"}{",ury,"}",
"\\useboxresource ", index,
- "\\mplibstoptoPDF",
}, "global")
- whd = format("%.3f %.3f 0", urx, ury) :gsub(decimals,rmzeros)
+ whd = format("%.3f %.3f 0", wd/factor, (ht+dp)/factor) :gsub(decimals,rmzeros)
else
trgroup.cnt = (trgroup.cnt or 0) + 1
local objname = format("@mplibtrgr%s", trgroup.cnt)
@@ -2344,15 +2349,13 @@
"\\special{pdf:econtent}}",
}
token.set_macro("luamplib.group."..name, tableconcat{
- "\\mplibstarttoPDF{0}{0}{",urx,"}{",ury,"}",
"\\setbox\\mplibscratchbox\\hbox{\\special{pdf:uxobj ", objname, "}}",
"\\wd\\mplibscratchbox ", wd, "sp",
"\\ht\\mplibscratchbox ", ht, "sp",
"\\dp\\mplibscratchbox ", dp, "sp",
"\\box\\mplibscratchbox",
- "\\mplibstoptoPDF",
}, "global")
- whd = format("%.3f %.3f %.3f", urx, ht/factor, dp/factor) :gsub(decimals,rmzeros)
+ whd = format("%.3f %.3f %.3f", wd/factor, ht/factor, dp/factor) :gsub(decimals,rmzeros)
end
info("w/h/d of group '%s': %s", name, whd)
end
Modified: trunk/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty 2024-11-28 21:24:56 UTC (rev 72994)
+++ trunk/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty 2024-11-28 21:25:35 UTC (rev 72995)
@@ -11,7 +11,7 @@
\ifcsname ProvidesPackage\endcsname
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{luamplib}
- [2024/11/25 v2.35.1 mplib package for LuaTeX]
+ [2024/11/28 v2.35.2 mplib package for LuaTeX]
\fi
\ifdefined\newluafunction\else
\input ltluatex
@@ -56,7 +56,13 @@
}
\def\mplibputtextbox#1{\vbox to 0pt{\vss\hbox to 0pt{\raise\dp#1\copy#1\hss}}}
\protected\def\usemplibgroup#1#{\usemplibgroupmain}
-\def\usemplibgroupmain#1{\csname luamplib.group.#1\endcsname}
+\def\usemplibgroupmain#1{%
+ \mplibstarttousemplibgroup
+ \csname luamplib.group.#1\endcsname
+ \mplibstoptousemplibgroup
+}
+\def\mplibstarttousemplibgroup{\prependtomplibbox\hbox\bgroup}
+\def\mplibstoptousemplibgroup{\egroup}
\protected\def\mplibgroup#1{%
\begingroup
\def\MPllx{0}\def\MPlly{0}%
@@ -417,6 +423,8 @@
\fi
\def\luamplibtagtextbegin#1{}
\let\luamplibtagtextend\relax
+\let\luamplibtagasgroupbegin\relax
+\let\luamplibtagasgroupend\relax
\ifcsname SuspendTagging\endcsname\else\endinput\fi
\ifcsname ver at tagpdf.sty\endcsname \else
\ExplSyntaxOn
@@ -446,6 +454,8 @@
\let\mplibstarttoPDForiginal\mplibstarttoPDF
\let\mplibstoptoPDForiginal\mplibstoptoPDF
\let\mplibputtextboxoriginal\mplibputtextbox
+\let\mplibstarttousemplibgrouporiginal\mplibstarttousemplibgroup
+\let\mplibstoptousemplibgrouporiginal\mplibstoptousemplibgroup
\ExplSyntaxOn
\tl_new:N \l__luamplib_tag_alt_tl
\tl_new:N \l__luamplib_tag_alt_dflt_tl
@@ -477,8 +487,8 @@
}
{
\tag_if_active:TF
- { \chardef\mplibtmpnum\@ne }
- { \chardef\mplibtmpnum\z@ }
+ { \bool_set_true:N \l_tmpa_bool }
+ { \bool_set_false:N \l_tmpa_bool }
\SuspendTagging{luamplib.textext}
}
}
@@ -500,9 +510,8 @@
\tag_mc_begin_pop:n{}
}
{
- \ifnum\mplibtmpnum=\@ne
- \ResumeTagging{luamplib.textext}
- \fi
+ \bool_if:NT \l_tmpa_bool
+ { \ResumeTagging{luamplib.textext} }
}
}
\msg_new:nnn {luamplib}{figure-text-reuse}
@@ -786,6 +795,46 @@
}
}
}
+\cs_set_nopar:Npn \luamplibtagasgroupbegin
+{
+ \bool_if:NT \l__luamplib_tag_usetext_bool
+ {
+ \ResumeTagging{luamplib.asgroup}
+ \tag_mc_begin:n{}
+ }
+}
+\cs_set_nopar:Npn \luamplibtagasgroupend
+{
+ \bool_if:NT \l__luamplib_tag_usetext_bool
+ {
+ \tag_mc_end:
+ \SuspendTagging{luamplib.asgroup}
+ }
+}
+\cs_set_nopar:Npn \mplibstarttousemplibgroup
+{
+ \prependtomplibbox\hbox\bgroup
+ \luamplibtaggingbegin
+ \setbox\mplibscratchbox\hbox\bgroup
+ \bool_if:NT \l__luamplib_tag_usetext_bool
+ {
+ \tag_mc_end:
+ \tag_mc_begin:n{}
+ }
+}
+\cs_set_nopar:Npn \mplibstoptousemplibgroup
+{
+ \bool_if:NT \l__luamplib_tag_usetext_bool
+ {
+ \tag_mc_end:
+ \tag_mc_begin:n{artifact}
+ }
+ \egroup
+ \luamplibtaggingBBox
+ \unhbox\mplibscratchbox
+ \luamplibtaggingend
+ \egroup
+}
\cs_set_nopar:Npn \mplibstarttoPDF #1 #2 #3 #4
{
\prependtomplibbox
@@ -865,7 +914,9 @@
}
\keys_set:nn{luamplib/tag}{#1}
\tl_set:Nn\l__luamplib_tag_alt_dflt_tl {metapost~figure~#2}
+ \mplibstarttousemplibgroup
\csname luamplib.group.#2\endcsname
+ \mplibstoptousemplibgroup
\endgroup
}
\cs_new_nopar:Npn \mplibalttext #1
More information about the tex-live-commits
mailing list.