diff options
Diffstat (limited to 'tex')
21 files changed, 323 insertions, 218 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index e5b37429a..1cacc2484 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2021.07.02 13:15} +\newcontextversion{2021.07.06 18:44} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index 6be166bff..c58792280 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2021.07.02 13:15} +\edef\contextversion{2021.07.06 18:44} %D For those who want to use this: diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index d044a93b6..290b2ec1a 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2021.07.02 13:15} +\newcontextversion{2021.07.06 18:44} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index d543d7a37..d1466a091 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -45,7 +45,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2021.07.02 13:15} +\edef\contextversion{2021.07.06 18:44} %D Kind of special: diff --git a/tex/context/base/mkiv/mult-prm.lua b/tex/context/base/mkiv/mult-prm.lua index 2cb38e8a3..c3d0fa656 100644 --- a/tex/context/base/mkiv/mult-prm.lua +++ b/tex/context/base/mkiv/mult-prm.lua @@ -321,6 +321,7 @@ return { "fontid", "fontmathcontrol", "fontspecifiedsize", + "fonttextcontrol", "formatname", "frozen", "futurecsname", @@ -464,7 +465,7 @@ return { "overloaded", "overloadmode", "parametercount", - "parattr", + "parattribute", "pardirection", "permanent", "postexhyphenchar", @@ -831,7 +832,6 @@ return { "number", "omit", "or", - "ordlimits", "outer", "output", "outputpenalty", diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 20b39c38c..b4e417c5c 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex 3159027b6..71b72e28c 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index d977c4982..12f04a4ea 100644 --- a/tex/context/base/mkxl/cont-new.mkxl +++ b/tex/context/base/mkxl/cont-new.mkxl @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2021.07.02 13:15} +\newcontextversion{2021.07.06 18:44} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkxl/context.mkxl b/tex/context/base/mkxl/context.mkxl index a509a9205..0b00ec001 100644 --- a/tex/context/base/mkxl/context.mkxl +++ b/tex/context/base/mkxl/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \immutable\edef\contextformat {\jobname} -\immutable\edef\contextversion{2021.07.02 13:15} +\immutable\edef\contextversion{2021.07.06 18:44} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error diff --git a/tex/context/base/mkxl/font-con.lmt b/tex/context/base/mkxl/font-con.lmt index a9a04557b..f2b359e57 100644 --- a/tex/context/base/mkxl/font-con.lmt +++ b/tex/context/base/mkxl/font-con.lmt @@ -477,6 +477,10 @@ function constructors.scale(tfmdata,specification) local scaledheight = defaultheight * vdelta local scaleddepth = defaultdepth * vdelta -- + local textcontrol = properties.textcontrol + targetproperties.textcontrol = textcontrol + target.textcontrol = textcontrol + -- local hasmath = (properties.hasmath or next(mathparameters)) and true -- if hasmath then @@ -1095,6 +1099,7 @@ do local position = source.position setindeed("node",source,target,group,name,position) setindeed("base",source,target,group,name,position) + setindeed("none",source,target,group,name,position) setindeed("plug",source,target,group,name,position) end @@ -1162,10 +1167,10 @@ do defaults = { }, descriptions = tables and tables.features or { }, used = statistics and statistics.usedfeatures or { }, - initializers = { base = { }, node = { }, plug = { } }, - processors = { base = { }, node = { }, plug = { } }, - manipulators = { base = { }, node = { }, plug = { } }, - finalizers = { base = { }, node = { }, plug = { } }, + initializers = { base = { }, node = { }, none = { }, plug = { } }, + processors = { base = { }, node = { }, none = { }, plug = { } }, + manipulators = { base = { }, node = { }, none = { }, plug = { } }, + finalizers = { base = { }, node = { }, none = { }, plug = { } }, } features.register = function(specification) return register(features,specification) end handler.features = features -- will also become hidden diff --git a/tex/context/base/mkxl/font-imp-text.lmt b/tex/context/base/mkxl/font-imp-text.lmt new file mode 100644 index 000000000..3ca05eb04 --- /dev/null +++ b/tex/context/base/mkxl/font-imp-text.lmt @@ -0,0 +1,30 @@ +if not modules then modules = { } end modules ['font-imp-text'] = { + version = 1.001, + comment = "companion to font-ini.mkiv and hand-ini.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local type = type + +local fonts = fonts +local registerotffeature = fonts.handlers.otf.features.register + +local function initialize(tfmdata,value) + if type(value) == "string" then + tfmdata.properties.textcontrol = tex.stringtocodesbitmap(value,tex.textcontrolcodes) + end +end + +local specification = { + name = "textcontrol", + description = "control specific text handling", + initializers = { + none = initialize, + base = initialize, + node = initialize, + } +} + +registerotffeature(specification) diff --git a/tex/context/base/mkxl/font-ini.mklx b/tex/context/base/mkxl/font-ini.mklx index fa512b9b0..b43f43dfb 100644 --- a/tex/context/base/mkxl/font-ini.mklx +++ b/tex/context/base/mkxl/font-ini.mklx @@ -996,8 +996,8 @@ \newconstant\c_fonts_auto_language -\letvalue{\??fontslanguage\v!auto}\plusone % experimental -%letvalue{\??fontslanguage\v!yes }\plustwo % less efficient, for experiments +\letcsname\??fontslanguage\v!auto\endcsname\plusone % experimental +%letcsname\??fontslanguage\v!yes \endcsname\plustwo % less efficient, for experiments \appendtoks \c_fonts_auto_language @@ -1122,7 +1122,7 @@ \font_helpers_low_level_define{#2}\v_font_identifier_basic \csname\v_font_identifier_basic\endcsname \setfalse\c_font_auto_size - \setfontcharacteristics + \the\everyfont % \setfontcharacteristics \the\everyfontswitch \let\v_font_identifier_basic\v_font_identifier_basic_saved} @@ -1143,7 +1143,7 @@ \csname\v_font_identifier_class\endcsname \setfalse\c_font_auto_size \ifskipfontcharacteristics \else - \setfontcharacteristics + \the\everyfont % \setfontcharacteristics \the\everyfontswitch \fi \let\v_font_identifier_class\v_font_identifier_class_saved} @@ -1152,7 +1152,7 @@ {\csname\v_font_identifier_class\endcsname \setfalse\c_font_auto_size \ifskipfontcharacteristics \else - \setfontcharacteristics + \the\everyfont % \setfontcharacteristics \the\everyfontswitch \fi \let\v_font_identifier_class\v_font_identifier_class_saved} @@ -1974,7 +1974,7 @@ \fi \setfalse\c_font_auto_size \ifskipfontcharacteristics - \setfontcharacteristics + \the\everyfont % \setfontcharacteristics \the\everyfontswitch \fi} @@ -2187,7 +2187,7 @@ \font_scale_inherit\??fontscalex \fi \ifskipfontcharacteristics - \setfontcharacteristics + \the\everyfont % \setfontcharacteristics \the\everyfontswitch \fi} @@ -2198,7 +2198,7 @@ \font_scale_inherit\??fontscalexx \fi \ifskipfontcharacteristics - \setfontcharacteristics + \the\everyfont % \setfontcharacteristics \the\everyfontswitch \fi} diff --git a/tex/context/base/mkxl/font-lib.mklx b/tex/context/base/mkxl/font-lib.mklx index 063d84976..d865da949 100644 --- a/tex/context/base/mkxl/font-lib.mklx +++ b/tex/context/base/mkxl/font-lib.mklx @@ -102,6 +102,7 @@ \registerctxluafile{font-imp-reorder}{} \registerctxluafile{font-imp-properties}{} \registerctxluafile{font-imp-unicode}{} +\registerctxluafile{font-imp-text}{autosuffix} \registerctxluafile{font-imp-math}{autosuffix} \registerctxluafile{font-imp-notused}{} \registerctxluafile{font-imp-effects}{autosuffix} diff --git a/tex/context/base/mkxl/font-pre.mkxl b/tex/context/base/mkxl/font-pre.mkxl index 52a7dc60f..27b1f6fdf 100644 --- a/tex/context/base/mkxl/font-pre.mkxl +++ b/tex/context/base/mkxl/font-pre.mkxl @@ -53,6 +53,7 @@ script=auto, % on speed; 'base' just doesn't play well with dynamics; some day we can even autoscript=position, autolanguage=position, + textcontrol=collapsehyphens, kern=yes, % consider skipping the base passes when no base mode is used mark=yes, mkmk=yes, @@ -61,22 +62,23 @@ \definefontfeature [default] [always] - [liga=yes, -% ccmp=yes, % maybe too -% locl=yes, % maybe too -% calt=yes, % maybe too -% clig=yes, % maybe too -% rlig=yes, % maybe too -% tlig=yes, % no longer default -% trep=yes, % no longer default - ] % texligatures=yes,texquotes=yes + [liga=yes] + + % ccmp=yes, % maybe too + % locl=yes, % maybe too + % calt=yes, % maybe too + % clig=yes, % maybe too + % rlig=yes, % maybe too + % tlig=yes, % no longer default (texligatures=yes) + % trep=yes, % no longer default (texquotes=yes) % if needed users can add this to a local cont-loc.mkxl in texmf-local: % \definefontfeature % [default] % [default] -% [tlig=yes, +% [textcontrol=, +% tlig=yes, % trep=yes] \definefontfeature @@ -86,17 +88,13 @@ \definefontfeature [smallcaps] [always] - [smcp=yes, - tlig=yes, - trep=yes] % texligatures=yes,texquotes=yes + [smcp=yes] \definefontfeature [oldstyle] [always] [onum=yes, - liga=yes, - tlig=yes, - trep=yes] % texligatures=yes,texquotes=yes + liga=yes] \definefontfeature [inlinenumbers] @@ -123,9 +121,7 @@ \definefontfeature % == default unless redefined [ligatures] [always] - [liga=yes, - tlig=yes, - trep=yes] + [liga=yes] \definefontfeature [letterspacing] @@ -140,20 +136,15 @@ [complete] [always] [compose=yes, - liga=yes, -% ccmp=yes, -% locl=yes, -% calt=yes, -% clig=yes, -% rlig=yes, - tlig=yes, - trep=yes] + liga=yes] \definefontfeature [none] [mode=none, features=no] +% \definefontfeature[none][none][textcontrol=collapsehyphens] + \definefontfeature [semitic-complete] [mode=node,analyze=yes,language=dflt,ccmp=yes, @@ -409,8 +400,6 @@ % mode=none, % better, maybe do this last kern=yes, % liga=yes, % makes no sense - % tlig=yes, % makes no sense - % trep=yes, % makes no sense mathnolimitsmode={0,800}, % this looks okay on the average font mathalternates=yes, mathitalics=yes, % we pass them diff --git a/tex/context/base/mkxl/font-sty.mklx b/tex/context/base/mkxl/font-sty.mklx index 016d86421..5391f39b6 100644 --- a/tex/context/base/mkxl/font-sty.mklx +++ b/tex/context/base/mkxl/font-sty.mklx @@ -346,6 +346,12 @@ % {\bf test \mine test \sl test \mine test \bs oeps \mine oeps {\tt test \mine \bf test}} +% too messy for this: +% +% \definestylecollection[mine] +% \definestyleinstance[mine][tt][tf][\nohyphencollapsing] +% {\tt\mine test--test \bf test--test} + \installcorenamespace{stylecollection} \permanent\tolerant\protected\def\definestylecollection[#name]% diff --git a/tex/context/base/mkxl/mlib-fio.lmt b/tex/context/base/mkxl/mlib-fio.lmt index 9de61affe..8235fdbec 100644 --- a/tex/context/base/mkxl/mlib-fio.lmt +++ b/tex/context/base/mkxl/mlib-fio.lmt @@ -12,7 +12,8 @@ local concat = table.concat local suffix, addsuffix = file.suffix, file.addsuffix local findfile = resolvers.findfile -local new_instance = mplib.new +local mplibnew = mplib.new +----- mplibexecute = mplib.execute local trace_terminal = false trackers.register("metapost.terminal", function(v) trace_terminal = v end) @@ -23,42 +24,40 @@ local report_error = logs.reporter("metapost","error") mplib.realtimelogging = false -local l, nl, dl = { }, 0, false -local t, nt, dt = { }, 0, false -local e, ne, de = { }, 0, false - -local function logger(target,str) - if target == 1 then - -- log - elseif target == 2 or target == 3 then - -- term - if str == "\n" then - mplib.realtimelogging = true - if nl > 0 then - report_logger(concat(l,"",1,nl)) - nl, dl = 0, false - elseif not dl then - report_logger("") - dl = true +local handlelog do + + local l, nl, dl = { }, 0, false + + handlelog = function(instance,target,str) + if target == 1 then + -- log + elseif target == 2 or target == 3 then + -- term + if str == "\n" then + mplib.realtimelogging = true + if nl > 0 then + report_logger(concat(l,"",1,nl)) + nl, dl = 0, false + elseif not dl then + report_logger("") + dl = true + end + else + nl = nl + 1 + l[nl] = str end - else - nl = nl + 1 - l[nl] = str + elseif target == 4 then + report_error(str) end - elseif target == 4 then - report_error(str) end + end local finders = { } mplib.finders = finders -- also used in meta-lua.lua local function validftype(ftype) - if ftype == "mp" then - return "mp" - else - return nil - end + return ftype == "mp" and "mp" or nil end -- We can have a list! @@ -259,8 +258,7 @@ local function handleerror(instance, message, helpinfo, interaction) report(helpinfo) report() if interaction == 5 then - -- todo --- luatex.abort() + -- luatex.abort() end end @@ -271,19 +269,38 @@ local function handlewarning(instance, message) end function mplib.new(specification) - local instance local openfile = fileopener() - specification.find_file = finder - specification.run_logger = logger - specification.run_overload = overload - specification.run_error = function(...) handleerror (instance,...) end - specification.run_warning = function(...) handlewarning(instance,...) end - specification.open_file = openfile - specification.interaction = "silent" - specification.job_name = tex.jobname -- mandate in order to get something back - specification.halt_on_error = true - instance = new_instance(specification) + local handlers = specification.handlers + local instance + instance = mplibnew { + -- used + tolerance = specification.tolerance, + math_mode = specification.mathmode, + run_script = specification.runscript, + run_internal = specification.runinternal, + script_error = specification.scripterror, + make_text = specification.maketext, + -- always + extensions = 1, + -- random_seed = specification.seed, + utf8_mode = true, + text_mode = true, + -- not used + -- noninteractive = true; + -- ini_version = true, + -- always + find_file = finder, + run_overload = overload, + open_file = openfile, + interaction = "silent", + job_name = tex.jobname, -- mandate in order to get something back + halt_on_error = true, + run_logger = handlers.log or function(...) handlelog (instance,...) end, + run_error = handlers.error or function(...) handleerror (instance,...) end, + run_warning = handlers.warning or function(...) handlewarning(instance,...) end, + } return instance, openfile("terminal") end -mplib.finder = finder +mplib.finder = finder +-----.execute = executor diff --git a/tex/context/base/mkxl/mlib-mpf.lmt b/tex/context/base/mkxl/mlib-mpf.lmt index f60f31076..086bfb0ea 100644 --- a/tex/context/base/mkxl/mlib-mpf.lmt +++ b/tex/context/base/mkxl/mlib-mpf.lmt @@ -176,12 +176,22 @@ do local m = runmodes[code] if m == "direct" then result = f() + if trace_luarun then + report_luarun("%i: direct: %a",nesting,type(result)) + end nesting = nesting - 1 return result, true -- string and tables as string and objects elseif m == "tokens" then result = f() + if trace_luarun then + report_luarun("%i: tokens: %a",nesting,type(result)) + end nesting = nesting - 1 return result -- string and tables as text to be scanned + else + if trace_luarun then + report_luarun("%i: no mode",nesting) + end end else if trace_luarun then @@ -857,13 +867,15 @@ do mptriplet(w*bpfactor,h*bpfactor,d*bpfactor) end + -- todo: scan ( ... ) + function mp.report(a,b,c,...) if c then report_message("%s : %s",a,formatters[(gsub(b,"@","%%"))](c,...)) elseif b then report_message("%s : %s",a,b) elseif a then - report_message("%s : %s","message",a) + report_message("message : %s",a) end end @@ -997,13 +1009,22 @@ do -- injectstring(utfsub(scanstring(),skiptoken(comma_code) and scannumeric(),skiptoken(comma_code) and scannumeric())) -- end) - registerdirect("utfnum", function() utfnum(scanstring()) end) - registerdirect("utflen", function() utflen(scanstring()) end) + registerdirect("utfnum", function() return utfnum(scanstring()) end) + registerdirect("utflen", function() return utflen(scanstring()) end) registerdirect("utfsub", function() -- we have an optional third argument so we explicitly scan a text argument utfsub(scanstring(),skiptoken(comma_code) and scannumeric(),skiptoken(comma_code) and scannumeric()) end) + local setlogging = metapost.setlogging + + registerscript("message", function() + setlogging(false) + local str = scanstring() + setlogging(true) + report_message("message : %s",str) + end) + end -- position fun diff --git a/tex/context/base/mkxl/mlib-run.lmt b/tex/context/base/mkxl/mlib-run.lmt index 231bd4d20..3e950a2d9 100644 --- a/tex/context/base/mkxl/mlib-run.lmt +++ b/tex/context/base/mkxl/mlib-run.lmt @@ -38,9 +38,13 @@ local emptystring = string.is_empty local trace_graphics = false trackers.register("metapost.graphics", function(v) trace_graphics = v end) local trace_tracingall = false trackers.register("metapost.tracingall", function(v) trace_tracingall = v end) -local report_metapost = logs.reporter("metapost") local texerrormessage = logs.texerrormessage +local report_metapost = logs.reporter("metapost") +local report_terminal = logs.reporter("metapost","terminal") +local report_tracer = logs.reporter("metapost","trace") +local report_error = logs.reporter("metapost","error") + local starttiming = statistics.starttiming local stoptiming = statistics.stoptiming @@ -90,17 +94,7 @@ local function prepareddata(data) end end --- local function executempx(mpx,data) --- local terminal = mpxterminals[mpx] --- if terminal then --- terminal.writer(data) --- data = "" --- elseif type(data) == "table" then --- data = prepareddata(data,collapse) --- end --- metapost.nofruns = metapost.nofruns + 1 --- return mpx:execute(data) --- end +local execute = mplib.execute local function executempx(mpx,data) local terminal = mpxterminals[mpx] @@ -111,7 +105,8 @@ local function executempx(mpx,data) data = prepareddata(data,collapse) end metapost.nofruns = metapost.nofruns + 1 - return mpx:execute(data) + local result = execute(mpx,data) + return result end directives.register("mplib.texerrors", function(v) metapost.texerrors = v end) @@ -207,20 +202,20 @@ function metapost.load(name,method) seed = seed % 4096 end end +-- local loghandler = method = method and methods[method] or "scaled" local mpx, terminal = new_instance { --- noninteractive = true; --- ini_version = true, - tolerance = bend_tolerance, - math_mode = method, - run_script = metapost.runscript, - run_internal = metapost.runinternal, - script_error = metapost.scripterror, - make_text = metapost.maketext, - extensions = 1, - -- random_seed = seed, - utf8_mode = true, - text_mode = true, + tolerance = bend_tolerance, + mathmode = method, + runscript = metapost.runscript, + runinternal = metapost.runinternal, + scripterror = metapost.scripterror, + maketext = metapost.maketext, + handlers = { + log = metapost.newlogger(), + -- warning = function(...) end, + -- error = function(...) end, + }, } report_metapost("initializing number mode %a",method) local result @@ -384,9 +379,6 @@ function metapost.reset(mpx) end end -local mp_tra = { } -local mp_tag = 0 - -- key/values do @@ -448,116 +440,160 @@ end -- incontext boolean -- plugmode boolean -local function makebeginbanner(specification) - return formatters["%% begin graphic: n=%s\n\n"](metapost.n) -end +do -local function makeendbanner(specification) - return "\n% end graphic\n\n" -end + local function makebeginbanner(specification) + return formatters["%% begin graphic: n=%s\n\n"](metapost.n) + end -function metapost.run(specification) - local mpx = specification.mpx - local data = specification.data - local converted = false - local result = { } - local mpxdone = type(mpx) == "string" - if mpxdone then - mpx = metapost.pushformat { instance = mpx, format = mpx } - end - if mpx and data then - local tra = nil - starttiming(metapost) -- why not at the outer level ... - metapost.variables = { } -- todo also push / pop - metapost.pushscriptrunner(mpx) - if trace_graphics then - tra = mp_tra[mpx] - if not tra then - mp_tag = mp_tag + 1 - local jobname = tex.jobname - tra = { - inp = io.open(formatters["%s-mplib-run-%03i.mp"] (jobname,mp_tag),"w"), - log = io.open(formatters["%s-mplib-run-%03i.log"](jobname,mp_tag),"w"), - } - mp_tra[mpx] = tra + local function makeendbanner(specification) + return "\n% end graphic\n\n" + end + + -- This is somewhat complex. We want a logger that is bound to an instance and + -- we implement the rest elsewhere so we need some hook. When we decide to move + -- the mlib-fio code here we can avoid some of the fuzzyness. + + -- In the luatex lib we have log and error an dterm fields, but here we don't + -- because we handle that ourselves. + + -- mplib.realtimelogging = false + + local mp_tra = { } + local mp_tag = 0 + + local stack = { } + local logger = false + local logging = true + + local function pushlogger(mpx,tra) + insert(stack,logger) + logger = tra or false + end + + local function poplogger(mpx) + logger = remove(stack) or false + end + + function metapost.checktracingonline(n) + -- todo + end + + function metapost.setlogging(state) + logging = state + end + + function metapost.newlogger() + + -- In a traditional scenario there are three states: terminal, log as well + -- as both. The overhead of logging is large because metapost flushes each + -- character (maybe that should be improved but caching at the libs end also + -- has price, probably more than delegating to LUA). + + -- term=1 log=2 term+log =3 + + local l, nl, dl = { }, 0, false + + return function(target,str) + if not logging then + return + elseif target == 4 then + report_error(str) + else + if logger and (target == 2 or target == 3) then + logger:write(str) + end + if target == 1 or target == 3 then + if str == "\n" then + mplib.realtimelogging = true + if nl > 0 then + report_tracer(concat(l,"",1,nl)) + nl, dl = 0, false + elseif not dl then + report_tracer("") + dl = true + end + else + nl = nl + 1 + l[nl] = str + end + end end - local banner = makebeginbanner(specification) - tra.inp:write(banner) - tra.log:write(banner) end - local function process(d,i) - if d then + + end + + function metapost.run(specification) + local mpx = specification.mpx + local data = specification.data + local converted = false + local result = { } + local mpxdone = type(mpx) == "string" + if mpxdone then + mpx = metapost.pushformat { instance = mpx, format = mpx } + end + if mpx and data then + local tra = false + starttiming(metapost) -- why not at the outer level ... + metapost.variables = { } -- todo also push / pop + metapost.pushscriptrunner(mpx) + if trace_graphics then + tra = mp_tra[mpx] + if not tra then + mp_tag = mp_tag + 1 + local jobname = tex.jobname + tra = { + inp = io.open(formatters["%s-mplib-run-%03i.mp"] (jobname,mp_tag),"w"), + log = io.open(formatters["%s-mplib-run-%03i.log"](jobname,mp_tag),"w"), + } + mp_tra[mpx] = tra + end + local banner = makebeginbanner(specification) + tra.inp:write(banner) + tra.log:write(banner) + pushlogger(mpx,tra and tra.log) + else + pushlogger(mpx,false) + end + if trace_tracingall then + executempx(mpx,"tracingall;") + end + -- + if data then if trace_graphics then - if i then - tra.inp:write(formatters["\n%% begin snippet %s\n"](i)) - end - if type(d) == "table" then - for i=1,#d do - tra.inp:write(d[i]) + if type(data) == "table" then + for i=1,#data do + tra.inp:write(data[i]) end else - tra.inp:write(d) - end - if i then - tra.inp:write(formatters["\n%% end snippet %s\n"](i)) + tra.inp:write(data) end end starttiming(metapost.exectime) - result = executempx(mpx,d) + result = executempx(mpx,data) stoptiming(metapost.exectime) - if trace_graphics and result then - local str = result.log or result.error - if str and str ~= "" then - tra.log:write(str) - end + if not metapost.reporterror(result) and result.fig then + converted = metapost.convert(specification,result) end - if not metapost.reporterror(result) then - if metapost.showlog then - -- make function and overload in lmtx - local str = result.term ~= "" and result.term or "no terminal output" - if not emptystring(str) then - metapost.lastlog = metapost.lastlog .. "\n" .. str - report_metapost("log: %s",str) - end - end - if result.fig then - converted = metapost.convert(specification,result) - end - end - elseif i then - report_metapost("error: invalid graphic component %s",i) else report_metapost("error: invalid graphic") end - end - --- local data = prepareddata(data) - if type(data) == "table" then - if trace_tracingall then - executempx(mpx,"tracingall;") - end - process(data) --- for i=1,#data do --- process(data[i],i) --- end - else - if trace_tracingall then - data = "tracingall;" .. data + -- + if trace_graphics then + local banner = makeendbanner(specification) + tra.inp:write(banner) + tra.log:write(banner) end - process(data) + stoptiming(metapost) + poplogger() + metapost.popscriptrunner() end - if trace_graphics then - local banner = makeendbanner(specification) - tra.inp:write(banner) - tra.log:write(banner) + if mpxdone then + metapost.popformat() end - stoptiming(metapost) - metapost.popscriptrunner() - end - if mpxdone then - metapost.popformat() + return converted, result end - return converted, result + end if not metapost.convert then @@ -608,9 +644,6 @@ do format = "metafun", -- or: minifun method = "double", } --- if not code then --- code = "" --- end metapost.process { mpx = mpx, flusher = flusher, diff --git a/tex/context/base/mkxl/mlib-scn.lmt b/tex/context/base/mkxl/mlib-scn.lmt index 4f76ca545..6032fd861 100644 --- a/tex/context/base/mkxl/mlib-scn.lmt +++ b/tex/context/base/mkxl/mlib-scn.lmt @@ -902,6 +902,8 @@ do elseif action == 2 then -- restore records[index] = remove(stack[index]) or records[index] + elseif action == 3 then + metapost.checktracingonline(kind) end end diff --git a/tex/context/base/mkxl/toks-aux.lmt b/tex/context/base/mkxl/toks-aux.lmt index 1b640b8ad..35676841e 100644 --- a/tex/context/base/mkxl/toks-aux.lmt +++ b/tex/context/base/mkxl/toks-aux.lmt @@ -149,8 +149,9 @@ end tex.groupcodes = getthem(tex.getgroupvalues, "", "groupcode") tex.glyphoptioncodes = getthem(tex.getglyphoptionvalues, "", "code") tex.discoptioncodes = getthem(tex.getdiscoptionvalues, "", "code") -tex.mathoptioncodes = getthem(tex.getmathoptionvalues, "", "") +tex.mathoptioncodes = getthem(tex.getmathoptionvalues, "", "") -- only at lua end tex.mathcontrolcodes = getthem(tex.getmathcontrolvalues, "", "mathcontrolcode") +tex.textcontrolcodes = getthem(tex.gettextcontrolvalues, "", "") -- only at lua end tex.mathflattencodes = getthem(tex.getmathflattenvalues, "", "flattencode") tex.hyphenationcodes = getthem(tex.gethyphenationvalues, "", "hyphenationmodecode") tex.frozenparcodes = getthem(tex.getfrozenparvalues, "frozen", "code") diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 0d8121a41..366745bab 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 2021-07-02 13:15 +-- merge date : 2021-07-06 18:44 do -- begin closure to overcome local limits and interference |