summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-03-01 21:45:34 +0000
committerKarl Berry <karl@freefriends.org>2024-03-01 21:45:34 +0000
commit78106bb24e28f74747fe222a8ecfe7e77dd0d1f0 (patch)
tree36f6625a4f4e674c6741349db1f59b2af221eb62 /Master/texmf-dist/tex/luatex
parent0eaa5c8aa577036e91ec287c5797a3e96bcffb8c (diff)
minim-mp (1mar24)
git-svn-id: svn://tug.org/texlive/trunk@70310 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex')
-rw-r--r--Master/texmf-dist/tex/luatex/minim-mp/minim-mp.lua37
-rw-r--r--Master/texmf-dist/tex/luatex/minim-mp/minim-mp.sty32
-rw-r--r--Master/texmf-dist/tex/luatex/minim-mp/minim-mp.tex1
3 files changed, 61 insertions, 9 deletions
diff --git a/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.lua b/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.lua
index 9069ab7147e..fba65732396 100644
--- a/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.lua
+++ b/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.lua
@@ -228,7 +228,7 @@ end
local function parse_lua_table(name, str)
local f, msg = load('return '..str, name, 't')
if msg then return alloc.err(msg) end
- t = f()
+ local t = f()
if not t or type(t) ~= 'table' then
return alloc.err('%s attributes must be given as lua table', name)
end
@@ -772,9 +772,9 @@ local function get_boxresource_center (id)
end
end
-E.set_boxresource_dimensions = set_boxresource_dimensions
-E.get_boxresource_dimensions = get_boxresource_dimensions
-E.get_boxresource_center = get_boxresource_center
+E.set_boxresource_dimensions = set_boxresource_dimensions
+E.get_boxresource_dimensions = get_boxresource_dimensions
+E.get_boxresource_center = get_boxresource_center
local function save_as_boxresource(pic)
-- attributes
@@ -1248,6 +1248,21 @@ function E.quote_for_lua(s)
return E.quote(mkluastring(s))
end
+-- These are here so that luametafun does not bug out immediately. Please note
+-- that using metafun is not otherwise supported or recommended.
+local cct_maketext = alloc.registernumber('minim:mp:catcodes:maketext')
+E.catcodes = { numbers =
+ { inicatcodes = cct_maketext , texcatcodes = cct_maketext
+ , luacatcodes = cct_maketext , notcatcodes = cct_maketext
+ , vrbcatcodes = cct_maketext , prtcatcodes = cct_maketext
+ , ctxcatcodes = cct_maketext , txtcatcodes = cct_maketext
+} }
+E.mp = mp or { } -- all seem nonessential
+E.mp.mf_path_reset = E.mp.mf_path_reset or function() end
+E.mp.mf_finish_saving_data = E.mp.mf_finish_saving_data or function() end
+E.mp.report = E.mp.report or function() end
+
+
-- 2 typesetting with tex
-- The result of the maketext function is fed back into metapost; on that side,
@@ -1330,7 +1345,6 @@ function M.make_glyph(glyphname, fnt)
alloc.err('Font not found: %s (id %s)', fnt, fontid)
return { }, 10
end
- local fontname = thefont.psname
local gid = luaotfload.aux.gid_of_name(fontid, glyphname)
if not gid then
alloc.err('Font %s has no glyph named %s', thefont.psname, glyphname)
@@ -1393,6 +1407,9 @@ M.get_contours = E.get_contours
-- 2 opening, running and and closing instances
+M.default_format = 'plain.mp'
+M.default_mathmode = 'scaled'
+
local function apply_default_instance_opts(t)
return
{ ini_version = true
@@ -1401,7 +1418,7 @@ local function apply_default_instance_opts(t)
, find_file = new_file_finder()
--, script_error = ...
, job_name = t.jobname
- , math_mode = t.math or 'scaled'
+ , math_mode = t.mathmode or t.math or M.default_mathmode
, random_seed = t.seed or nil
-- , file_line_error_style
, make_text = maketext
@@ -1440,14 +1457,18 @@ function M.run (nr, code)
save_image_list(self, picts)
end
-M.init_code = { 'let dump=endinput;', 'input INIT;', 'input minim-mp.mp;', 'input minim.mp;' }
+M.init_code = { 'let dump=endinput;'
+ , 'boolean mplib; mplib:=true;'
+ , 'input INIT;'
+ , 'input minim-mp.mp;'
+ , 'input minim.mp;' }
local maketext_catcodes = alloc.registernumber('minim:mp:catcodes:maketext')
function M.open (t)
local nr = #instances + 1
t.jobname = t.jobname or ':metapost:'
-- creating instance options
- local init = string.gsub(table.concat(M.init_code, ''), 'INIT', t.format or 'plain.mp')
+ local init = string.gsub(table.concat(M.init_code, ''), 'INIT', t.format or M.default_format)
local opts = apply_default_instance_opts(t)
local instance = mplib.new(opts)
-- adding the instance
diff --git a/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.sty b/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.sty
index 250e86668e0..6240c80b9a4 100644
--- a/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.sty
+++ b/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.sty
@@ -29,7 +29,7 @@
\newmetapostinstance[#1]\mnm@tmp
\expandafter\let\csname #2@instance\endcsname\mnm@tmp
\newenvironment{#2}{%
- \begingroup \catcode`\#=12
+ \begingroup \catcode`\#=12 \catcode`\%=12
\let\mpcolor = \minimpcolor
\csname:#2:\endcsname}
{\csname end:#2:\endcsname \endgroup}%
@@ -50,3 +50,33 @@
\newtoks\mpcolorspectoks \newtoks\mpcolorruntoks \newtoks\mpcolorvaltoks
\mpcolorruntoks{\expandafter\extractcolorspec\the\mpcolorspectoks\mptmpcolor
\expandafter\mpcolorvaltoks\expandafter\@gobble\mptmpcolor}
+
+% as a rather fragile drop-in replacement for luamplib
+\DeclareOption{luamplib}{%
+ \def\mplibtextextlabel#1{} % always enabled
+ \def\mplibshowlog#1{\directlua{
+ require 'minim-mp'.on_line = %
+ \ifcsname minimp@switch@#1\endcsname
+ true \else false \fi }}
+ \newmetapostenvironment[jobname='\jobname']{@mplibcode}
+ \def\mplibcodeinherit#1{%
+ \ifcsname minimp@switch@#1\endcsname
+ \let\mplibcode=\@mplibcode
+ \let\endmplibcode=\@mplibcode
+ \else
+ \let\mplibcode=\metapost
+ \let\endmplibcode=\endmetapost
+ \fi}
+ \mplibcodeinherit{disable}
+ \def\mplibsetformat#1{\directlua{
+ require 'minim-mp'.default_format = '#1.mp' }}
+ \def\mplibnumbersystem#1{\directlua{
+ require 'minim-mp'.default_math = '#1' }}
+} \ProcessOptions*
+
+\let\minimp@switch@@enable=\relax
+\let\minimp@switch@@enabled=\relax
+\let\minimp@switch@@true=\relax
+\let\minimp@switch@@yes=\relax
+
+
diff --git a/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.tex b/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.tex
index 6d953346776..7b8cef6c6b5 100644
--- a/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.tex
+++ b/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.tex
@@ -16,6 +16,7 @@
\newcatcodetable \minim:mp:catcodes:mpcode
{\catcodetable\minim:initcatcodes
\catcode`\{=1 \catcode`\}=2 \catcode9=10
+ \catcode`\#=12 \catcode`\%=12 \catcode`\~=12
\savecatcodetable\csname minim:mp:catcodes:mpcode\endcsname}
\directlua { require('minim-mp') }