summaryrefslogtreecommitdiff
path: root/macros/luatex/generic/minim-mp/minim-mp.lua
diff options
context:
space:
mode:
Diffstat (limited to 'macros/luatex/generic/minim-mp/minim-mp.lua')
-rw-r--r--macros/luatex/generic/minim-mp/minim-mp.lua37
1 files changed, 29 insertions, 8 deletions
diff --git a/macros/luatex/generic/minim-mp/minim-mp.lua b/macros/luatex/generic/minim-mp/minim-mp.lua
index 9069ab7147..fba6573239 100644
--- a/macros/luatex/generic/minim-mp/minim-mp.lua
+++ b/macros/luatex/generic/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