From b7a7de31716616b7a5176259e2b60349f8089615 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Fri, 21 Jan 2022 20:54:31 +0100 Subject: 2022-01-21 20:12:00 --- tex/context/base/mkxl/cont-new.mkxl | 2 +- tex/context/base/mkxl/context.mkxl | 2 +- tex/context/base/mkxl/font-ctx.lmt | 46 ++++-- tex/context/base/mkxl/font-ini.mklx | 13 +- tex/context/base/mkxl/good-gen.lmt | 6 +- tex/context/base/mkxl/lang-lab.mkxl | 2 +- tex/context/base/mkxl/lang-tra.lmt | 322 ++++++++++++++++++++++++++++++++++++ tex/context/base/mkxl/lang-tra.mkxl | 42 ++++- tex/context/base/mkxl/lpdf-lmt.lmt | 8 +- tex/context/base/mkxl/math-act.lmt | 9 +- tex/context/base/mkxl/math-fen.mkxl | 22 ++- tex/context/base/mkxl/meta-ini.mkxl | 4 +- tex/context/base/mkxl/mlib-ctx.lmt | 15 ++ tex/context/base/mkxl/node-syn.lmt | 82 ++------- tex/context/base/mkxl/pack-mrl.mkxl | 74 +++++++-- tex/context/base/mkxl/spac-hor.mkxl | 32 ++-- tex/context/base/mkxl/trac-deb.lmt | 20 ++- 17 files changed, 553 insertions(+), 148 deletions(-) create mode 100644 tex/context/base/mkxl/lang-tra.lmt (limited to 'tex/context/base/mkxl') diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index e8d91be4c..77ef89d5d 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{2022.01.18 10:48} +\newcontextversion{2022.01.21 20:10} %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 1c3563ee3..ca6e796c1 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{2022.01.18 10:48} +\immutable\edef\contextversion{2022.01.21 20:10} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error diff --git a/tex/context/base/mkxl/font-ctx.lmt b/tex/context/base/mkxl/font-ctx.lmt index 05cad84f0..399de7421 100644 --- a/tex/context/base/mkxl/font-ctx.lmt +++ b/tex/context/base/mkxl/font-ctx.lmt @@ -1052,23 +1052,30 @@ local sizepattern, splitpattern, specialscale do local withinparents = leftparent * (1-rightparent)^0 * rightparent local withinbraces = leftbrace * (1-rightbrace )^0 * rightbrace local value = C((withinparents + withinbraces + (1-space))^1) - -- local dimension = C((space/"" + P(1))^1) - local dimension = Cs((digit+period)^1 * (spaces/"") * (P(1)-digit)^0) --- local scaler = C((digit+period)^1) + local dimension = Cs((digit+period)^1 * (spaces/"") * (P(1)-digit-space)^0) + -- local dimension_x = C((space/"" + P(1))^1) + local dimension_x = C((1-space)^1) + -- local scaler = C((digit+period)^1) local scaler = lpeg.patterns.unsigned/function(s) return round(tonumber(s)*1000) end + C(lpeg.patterns.cardinal) local rest = C(P(1)^0) local scale_none = Cc(0) - local scale_at = (P("at") + P("@")) * Cc(1) * spaces * dimension -- dimension - local scale_sa = P("sa") * Cc(2) * spaces * dimension -- number - local scale_mo = P("mo") * Cc(3) * spaces * dimension -- number - local scale_scaled = P("scaled") * Cc(4) * spaces * dimension -- number - local scale_ht = P("ht") * Cc(5) * spaces * dimension -- dimension - local scale_cp = P("cp") * Cc(6) * spaces * dimension -- dimension + local scale_at = (P("at") + P("@")) * Cc(1) * spaces * dimension -- dimension + local scale_sa = P("sa") * Cc(2) * spaces * dimension_x -- number or string + local scale_mo = P("mo") * Cc(3) * spaces * dimension_x -- number or string + local scale_scaled = P("scaled") * Cc(4) * spaces * dimension -- number + local scale_ht = P("ht") * Cc(5) * spaces * dimension -- dimension + local scale_cp = P("cp") * Cc(6) * spaces * dimension -- dimension + local scale_sx = P("sx") * spaces * scaler -- scale + local scale_sy = P("sy") * spaces * scaler -- scale specialscale = { [5] = "ht", [6] = "cp" } - sizepattern = spaces * ((scale_at + scale_sa + scale_mo + scale_ht + scale_cp + scale_scaled) * (spaces * scaler)^0 + scale_none) + -- sizepattern = spaces * ((scale_at + scale_sa + scale_mo + scale_ht + scale_cp + scale_scaled) * (spaces * scaler)^0 + scale_none) + + scaler = spaces * ( (scale_sx + Cc(0)) * spaces * (scale_sy + Cc(0)) )^-1 + sizepattern = spaces * ((scale_at + scale_sa + scale_mo + scale_ht + scale_cp + scale_scaled) * scaler + scale_none) + splitpattern = spaces * value * spaces * rest end @@ -1112,6 +1119,12 @@ do -- else too many locals return v end) + local obey_designsize = false + + experiments.register("fonts.compact.obeydesignsize",function(v) + obey_designsize = v + end) + implement { name = "definefont_one", arguments = "string", @@ -1134,13 +1147,14 @@ do -- else too many locals end -- we can also use a count for the size if size and size ~= "" then - local mode, size, sx, sy = lpegmatch(sizepattern,size) - if mode and size and size ~= "" then + local mode, fontsize, sx, sy = lpegmatch(sizepattern,size) +-- print(size,mode,fontsize,sx,sy) + if mode and fontsize and fontsize ~= "" then texsetcount("scaledfontmode",mode) - -- ctx_setsomefontsize(size) + -- ctx_setsomefontsize(fontsize) -- We use a catcodetable, just in case it's 1.2\exheight (a corner case that showed -- up in the lmtx manual: marking that changed size in the mids of some verbatim). - setmacro(ctxcatcodes,"somefontsize",size) + setmacro(ctxcatcodes,"somefontsize",fontsize) if sx then setmacro("somefontsizex",sx) end @@ -1215,7 +1229,7 @@ do -- else too many locals local lookup, name, sub, method, detail = getspecification(str or "") -- new (todo: inheritancemode) local designsize = fontdesignsize ~= "" and fontdesignsize or classdesignsize or "" - local designname = designsizefilename(name,designsize,size) + local designname = designsizefilename(name,designsize,size,obey_designsize) if designname and designname ~= "" then if trace_defining or trace_designsize then report_defining("remapping name %a, specification %a, size %a, designsize %a",name,designsize,size,designname) @@ -1624,7 +1638,7 @@ do -- else too many locals return infofont end - -- abstract interfacing + -- abstract interfacing : we could actually do a runmacro or so implement { name = "tf", actions = function() setmacro("fontalternative","tf") end } implement { name = "bf", actions = function() setmacro("fontalternative","bf") end } diff --git a/tex/context/base/mkxl/font-ini.mklx b/tex/context/base/mkxl/font-ini.mklx index 6a926bcbd..c30a610cc 100644 --- a/tex/context/base/mkxl/font-ini.mklx +++ b/tex/context/base/mkxl/font-ini.mklx @@ -921,16 +921,15 @@ % \glyphscale \ifnum\c_font_scaled_font_mode_saved>\plusfour + % \c_font_scaled_points is set when we pass the font to the engine \numexpr\plusthousand*\dimexpr\d_font_scaled_default\relax/\c_font_scaled_points\relax \else \c_font_future_glyph_scale \fi -% \ifempty\somefontsizex\else -% \edef\somefontsizex{\glyphxscale\somefontsizex\relax}% todo: inserts relax -% \fi -% \ifempty\somefontsizey\else -% \edef\somefontsizey{\glyphyscale\somefontsizey\relax}% -% \fi + % experiment + \glyphxscale\ifempty\somefontsizex\plusthousand\else\somefontsizex\fi\relax + \glyphyscale\ifempty\somefontsizey\plusthousand\else\somefontsizey\fi\relax + % experiment \expandafter\let\expandafter\lastrawfontcall\csname#csname\endcsname \ifrelax\lastrawfontcall \let\somefontspec\empty @@ -2138,7 +2137,7 @@ \enforced\let\tx\empty \enforced\let\txx\empty} -%D This alterative is not really needed, but for old time's sake we keep it there. +%D This alternative is not really needed, but for old time's sake we keep it there. %D We can speed it up when needed. \def\font_helpers_set_current_font_x_style_alternative #alternative{\csname#alternative\endcsname\tx} diff --git a/tex/context/base/mkxl/good-gen.lmt b/tex/context/base/mkxl/good-gen.lmt index 33147260d..49b379304 100644 --- a/tex/context/base/mkxl/good-gen.lmt +++ b/tex/context/base/mkxl/good-gen.lmt @@ -197,10 +197,12 @@ function fontgoodies.designsizes.register(name,size,specification) end end -function fontgoodies.designsizes.filename(name,spec,size) -- returns nil of no match +function fontgoodies.designsizes.filename(name,spec,size,force) -- returns nil of no match local data = designdata[lower(name)] if data then - if not spec or spec == "" or spec == "default" or texconditionals["c_font_compact"] then + if not spec or spec == "" or spec == "default" then + return data.default + elseif not force and texconditionals["c_font_compact"] then return data.default elseif spec == "auto" then local ranges = data.ranges diff --git a/tex/context/base/mkxl/lang-lab.mkxl b/tex/context/base/mkxl/lang-lab.mkxl index 369049ed1..3ce9d027f 100644 --- a/tex/context/base/mkxl/lang-lab.mkxl +++ b/tex/context/base/mkxl/lang-lab.mkxl @@ -21,7 +21,7 @@ %D Left-overs: \ifdefined\sixperemspace \else - \permanent\def\sixperemspace{\normalUchar"2006} + \permanent\edef\sixperemspace{\normalUchar"2006} \fi %D In this module we deal with language dependant labels and prefixes, like in {\em diff --git a/tex/context/base/mkxl/lang-tra.lmt b/tex/context/base/mkxl/lang-tra.lmt new file mode 100644 index 000000000..b3fedc7c1 --- /dev/null +++ b/tex/context/base/mkxl/lang-tra.lmt @@ -0,0 +1,322 @@ +if not modules then modules = { } end modules ['lang-tra'] = { + version = 1.001, + comment = "companion to lang-tra.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- The indic transliterations was researched by kauĊ›ika and after some experiments +-- we settled on the current approach (mappings and a more specific lpeg). + +local concat = table.concat +local utfbyte, utfchar, utfsplit, utfvalues = utf.byte, utf.char, utf.split, utf.values +local C, Cc, Cs, lpegmatch = lpeg.C, lpeg.Cc, lpeg.Cs, lpeg.match +local utfchartabletopattern = lpeg.utfchartabletopattern +local utfcharacterpattern = lpeg.patterns.utf8character + +local nuts = nodes.nuts + +local nextchar = nuts.traversers.char + +local getattr = nuts.getattr +local setchar = nuts.setchar +local getnext = nuts.getnext +local isnextchar = nuts.isnextchar + +local insertafter = nuts.insertafter +local copynode = nuts.copy +local removenode = nuts.remove + +local texsetattribute = tex.setattribute + +local transliteration = { } +languages.transliteration = transliteration + +local a_transliteration = attributes.private("transliteration") +local unsetvalue = attributes.unsetvalue + +local implement = interfaces.implement +local context = context + +local zwj = utf.char(0x200D) + +local lastmapping = 0 +local loadedmappings = { } +local loadedlibraries = { } + +local report = logs.reporter("transliteration") +local trace = false trackers.register("languages.transliteration", function(v) trace = v end) + +local converters = { +-- ["iast to deva"] = function(m) +-- local t_svara = m.svara +-- local p_svara = utfchartabletopattern(t_svara) +-- local t_vyanjana = m.vyanjana +-- local p_vyanjana = utfchartabletopattern(t_vyanjana) +-- local t_maatra = m.maatra +-- local p_maatra = utfchartabletopattern(t_maatra) +-- local t_viraama = m.viraama +-- local p_viraama = utfchartabletopattern(t_viraama) +-- local t_boundary = m.boundary +-- local p_boundary = utfchartabletopattern(t_boundary) +-- local t_yogavaaha = m.yogavaaha +-- local p_yogavaaha = utfchartabletopattern(t_yogavaaha) +-- local p_svara_boundary = 1 - p_svara - p_vyanjana - p_yogavaaha +-- local p = Cs ( ( +-- p_svara / t_svara +-- + p_vyanjana / t_vyanjana +-- + p_viraama / t_viraama +-- + p_yogavaaha / t_yogavaaha +-- + C(utfcharacterpattern) +-- )^0 ) +-- return function(s) +-- -- for now +-- -- s = zwj .. s +-- -- +-- return lpegmatch(p,s) or s +-- end +-- end, + ["mapping"] = function(m) + local t_mapping = m.mapping + if t_mapping then + local p = Cs ( ( + utfchartabletopattern(t_mapping) / t_mapping + + C(utfcharacterpattern) + )^0 ) + -- lpeg.print(p) + return function(s) + return lpegmatch(p,s) or s + end + else + return false + end + end, + ["default"] = function(m) + return function(s) + return s + end + end, +} + +function transliteration.use(library) + local lib = loadedlibraries[library] + if lib == nil then + -- todo: use library loader + local data = require("lang-imp-" .. library) + if data then + local transliterations = data.transliterations + if transliterations then + for name, d in table.sortedhash(transliterations) do + local vector = d.vector + if vector then + report("vector %a in %a is %sloaded with index %i",name,library," already",d.attribute) + else + lastmapping = lastmapping + 1 + d.vector = (converters[name] or converters.mapping or converters.default)(d) + or (converters.default)(d) + report("vector %a in set %a is %sloaded with index %i",name,library,"",lastmapping) + end + d.attribute = lastmapping + d.library = library + d.name = name + loadedmappings[name] = d + loadedmappings[lastmapping] = d + end + else + report("library %a has no transliterations",library) + end + loadedlibraries[library] = data + else + loadedlibraries[library] = false + end + end +end + +local enable = false + +enable = function() + nodes.tasks.enableaction("processors", "languages.transliteration.handler") + enable = false +end + +function transliteration.set(vector) + if enable then + enable() + end + local m = loadedmappings[vector] + local a = m and m.attribute or unsetvalue + if trace then + report("setting transliteration %s",vector) + end + texsetattribute(a_transliteration,a) +end + +function transliteration.register(vector) + if enable then + enable() + end + local m = loadedmappings[vector] + local a = m and m.attribute or unsetvalue + if trace then + report("registering transliteration %s",vector) + end + return a +end + +-- When there is need I will improve the performance of the next handler. + +function transliteration.handler(head) + local aprev = nil + local vector = nil + local current = head + local first = nil + local last = nil + local list = { } + local size = 0 + + -- we need a more clever one: run over small ranges in order to keep colors etc + + -- actually we can generalize the replacer elsewhere + + local function flush(nxt) + -- we can do some optimization here by having the split as replacement + local old = concat(list,"",1,size) + local new = vector(old) + if old ~= new then + if trace then + report("old: %s",old) + report("new: %s",new) + end + local c = first + local x = false + for s in utfvalues(new) do + if x then + head, c = insertafter(head,c,copynode(first)) + setchar(c,s) + else + setchar(c,s) + if c == last then + x = true + else + c = getnext(c) + end + end + end + if not x then + while c do + head, c = removenode(head,c,true) + if c == nxt then + break + end + end + end + end + end + + while current do + local nxt, chr, more = isnextchar(current) + if chr then + local a = getattr(current,a_transliteration) + if a then + if a ~= aprev then + if first then + flush(nxt) + first = nil + size = 0 + end + aprev = a + vector = loadedmappings[a] + if vector then + vector = vector.vector + end + end + if not first then + first = current + end + last = current + size = size + 1 + list[size] = utfchar(chr) + if not more then + flush(nxt) + first = nil + size = 0 + -- we can go ahead one next + end + else + if first then + flush(nxt) + first = nil + size = 0 + end + end + end + current = nxt + end + if first then + flush(nxt) + end + return head +end + +interfaces.implement { + name = "usetransliteration", + public = true, + protected = true, + arguments = "optional", + actions = transliteration.use, +} + +implement { + name = "settransliteration", + arguments = "string", + actions = transliteration.set, +} + +implement { + name = "registertransliteration", + arguments = "string", + actions = { transliteration.register, context }, +} + +nodes.tasks.prependaction("processors", "normalizers", "languages.transliteration.handler", nil, "nut", "disabled" ) + +local function transliterate(scheme,str) + if str and str ~= "" then + local m = loadedmappings[scheme] + local c = m and m.vector + context(c and c(str) or str) + end +end + +local getbuffer = buffers.getcontent + +implement { + name = "transliterate", + public = true, + protected = true, + arguments = { "optional", "string" }, + actions = transliterate, +} + +implement { + name = "transliteratebuffer", + public = true, + protected = true, + arguments = { "optional", "string" }, + actions = function(scheme,name) transliterate(scheme,getbuffer(name)) end, +} + +implement { + name = "transliterated", + public = true, + arguments = { "optional", "string" }, + actions = transliterate, +} + +implement { + name = "transliteratedbuffer", + public = true, + arguments = { "optional", "string" }, + actions = function(scheme,name) transliterate(scheme,getbuffer(name)) end, +} diff --git a/tex/context/base/mkxl/lang-tra.mkxl b/tex/context/base/mkxl/lang-tra.mkxl index b087832e0..96dcc7d94 100644 --- a/tex/context/base/mkxl/lang-tra.mkxl +++ b/tex/context/base/mkxl/lang-tra.mkxl @@ -13,23 +13,49 @@ \writestatus{loading}{ConTeXt Language Macros / Transliteration} -\registerctxluafile{lang-tra}{} +\registerctxluafile{lang-tra}{autosuffix} \unprotect +\installcorenamespace {transliteration} + +\installcommandhandler \??transliteration {transliteration} \??transliteration + \definesystemattribute[transliteration][public,global] -\installcorenamespace {transliteration} +% define in lua: \usetransliteration[#1] -\permanent\tolerant\protected\def\definetransliteration[#1]#*[#2]% - {\clf_definedtransliteration{#1}{#2}} +% todo: define fast attribute at the tex end do we can have a proper define -\permanent\protected\def\settransliteration[#1]% - {\clf_settransliteration{#1}} +\def\lang_transliteration_set#1% + {\ifcsname\??transliteration#1\endcsname + \c_attr_transliteration\lastnamedcs + \edef\currenttransliteration{#1}% + \usetransliterationstyleandcolor\c!style\c!color + \uselanguageparameter\transliterationparameter + \else + \clf_settransliteration{#1}% + \fi} -\permanent\protected\def\starttransliteration[#1]% +\permanent\tolerant\protected\def\settransliteration[#1]#;#2% + {\lang_transliteration_set{#1}} + +\permanent\tolerant\protected\def\starttransliteration[#1]#*[#2]% {\begingroup - \clf_settransliteration{#1}} + \ifparameter#2\or + \edef\currenttransliteration{#1}% + \setupcurrenttransliteration[#2]% + \fi + \lang_transliteration_set{#1}} + +\permanent\tolerant\protected\def\transliteration[#1]#;#2% + {\groupedcommand{\lang_transliteration_set{#1#2}}\donothing} + +\appendtoks + \expandafter\integerdef\csname\??transliteration\currenttransliteration\endcsname + \clf_registertransliteration{\transliterationparameter\c!vector}% + \relax +\to \everydefinetransliteration \permanent\protected\def\stoptransliteration {\endgroup} diff --git a/tex/context/base/mkxl/lpdf-lmt.lmt b/tex/context/base/mkxl/lpdf-lmt.lmt index 0861e0916..9bb3319d4 100644 --- a/tex/context/base/mkxl/lpdf-lmt.lmt +++ b/tex/context/base/mkxl/lpdf-lmt.lmt @@ -480,10 +480,16 @@ do local w local e = c and c[char] if e then - w = e.width or 0 +-- w = e.width or 0 +-- local a = e.advance +-- if a then +-- w = a +-- end local a = e.advance if a then w = a + else + w = e.width or 0 end end if not w then diff --git a/tex/context/base/mkxl/math-act.lmt b/tex/context/base/mkxl/math-act.lmt index 0ac497d57..48d389bf9 100644 --- a/tex/context/base/mkxl/math-act.lmt +++ b/tex/context/base/mkxl/math-act.lmt @@ -459,7 +459,14 @@ do if trace_tweaking then report_tweak("setting width of %U to %p",target,original,unicode,width) end - characters[unicode] = { width = width } + characters[unicode] = { + width = width, + -- advance = width, + unicode = unicode, + commands = { + -- { "slot", 0, 32 }, + }, + } end end end diff --git a/tex/context/base/mkxl/math-fen.mkxl b/tex/context/base/mkxl/math-fen.mkxl index 4a3144530..b8347eb66 100644 --- a/tex/context/base/mkxl/math-fen.mkxl +++ b/tex/context/base/mkxl/math-fen.mkxl @@ -63,7 +63,8 @@ \appendtoks \edef\p_command{\mathfenceparameter\c!command}% \ifx\p_command\v!yes - \setuevalue\currentmathfence{\math_fenced_fenced[\currentmathfence]}% + % \instance + \protected\edefcsname\currentmathfence\endcsname{\math_fenced_fenced[\currentmathfence]}% \fi \to \everydefinemathfence @@ -230,12 +231,15 @@ {\advance\c_math_fenced_nesting\plusone \begingroup \edef\currentmathfence{#1}% -% under test: -\c_attr_mathsize\attributeunsetvalue -\letmathfenceparameter\c!size\empty -\letmathfenceparameter\c!factor\v!auto -% so far - \ifparameter#2\or\setupcurrentmathfence[#2]\fi + % under test: + \c_attr_mathsize\attributeunsetvalue + \letmathfenceparameter\c!size\empty + \letmathfenceparameter\c!factor\v!auto + % so far + \ifparameter#2\or + \setupcurrentmathfence[#2]% + \bigmathdelimitervariant\mathfenceparameter\c!alternative\relax + \fi \math_fenced_fenced_common \edef\p_size{\mathfenceparameter\c!size}% \ifempty\p_size @@ -637,7 +641,7 @@ \bigmathdelimitervariant\mathfenceparameter\c!alternative\relax \to \everysetupmathfence -\setupmathfence[\c!method=1,\c!alternative=2] +\setupmathfence[\c!method=1,\c!alternative=1] % \protected\def\plainbigdelimiters % traditional method % {\bigmathdelimitermethod\plustwo} @@ -704,7 +708,7 @@ \fi \fi} -\permanent\protected\def\mathdelimiterstep#1#2% +\permanent\protected\def\mathdelimiterstep#1#2% not used {\begingroup \math_fenced_force_size\plusone{#1}% \math_fenced_step#2\relax diff --git a/tex/context/base/mkxl/meta-ini.mkxl b/tex/context/base/mkxl/meta-ini.mkxl index b30f4826f..6ddf4def8 100644 --- a/tex/context/base/mkxl/meta-ini.mkxl +++ b/tex/context/base/mkxl/meta-ini.mkxl @@ -168,8 +168,8 @@ \t_meta_inclusions \emptytoks % in case we redefine \to \everydefineMPinstance -\permanent\protected\def\resetMPinstance[#1]% - {\writestatus\m!metapost{reset will be implemented when needed}} +% \permanent\protected\def\resetMPinstance[#1]% +% {\writestatus\m!metapost{reset will be implemented when needed}} \def\meta_analyze_graphicname[#1]% {\normalexpanded{\meta_analyze_graphicname_indeed[#1::::]}} diff --git a/tex/context/base/mkxl/mlib-ctx.lmt b/tex/context/base/mkxl/mlib-ctx.lmt index 64225e308..8ed6b0b00 100644 --- a/tex/context/base/mkxl/mlib-ctx.lmt +++ b/tex/context/base/mkxl/mlib-ctx.lmt @@ -410,3 +410,18 @@ MP = MP or { } -- user namespace table.setmetatablecall(mp,function(t,k,...) return t[k](...) end) table.setmetatablecall(MP,function(t,k,...) return t[k](...) end) + +-- A secret option: + +implement { + name = "resetMPinstance", + protected = true, + public = true, + arguments = "optional", + actions = function(s) + if s and s ~= "" then + report_metapost("resetting instance %a",s) + metapost.reset(s) + end + end, +} diff --git a/tex/context/base/mkxl/node-syn.lmt b/tex/context/base/mkxl/node-syn.lmt index dfa1a19e8..916e85c9e 100644 --- a/tex/context/base/mkxl/node-syn.lmt +++ b/tex/context/base/mkxl/node-syn.lmt @@ -530,52 +530,6 @@ local function collect_min(head) return head end --- local function collect_min(head) --- local first = false --- local last = false --- local tag = 0 --- local line = 0 --- for current, id, subtype in nextnode, head do --- if id == glyph_code then --- local tc, lc = getsynctexfields(current) --- if tc and tc > 0 then --- if tag == 0 then --- first = current --- end --- tag = tc --- line = lc --- last = current --- elseif tag > 0 then --- head = inject(head,first,last,tag,line) --- tag = 0 --- end --- elseif id == disc_code then --- last = current --- elseif id == kern_code and subtype == fontkern_code then --- last = current --- elseif id == hlist_code or id == vlist_code then --- if tag > 0 then --- head = inject(head,first,last,tag,line) --- tag = 0 --- end --- local list = getlist(current) --- if list then --- local l = collect(list) --- if l ~= list then --- setlist(current,l) --- end --- end --- elseif tag > 0 then --- head = inject(head,first,last,tag,line) --- tag = 0 --- end --- end --- if tag > 0 then --- head = inject(head,first,last,tag,line) --- end --- return head --- end - local function inject(parent,head,first,last,tag,line) local w, h, d = getrangedimensions(parent,first,getnext(last)) if h < height then @@ -630,24 +584,24 @@ local function collect_max(head,parent) last = current end elseif id == glue_code then - if tag > 0 then - local tc, lc = getsynctexfields(current) - if tc and tc > 0 then - if tag ~= tc or line ~= lc then - head = inject(parent,head,first,last,tag,line) - tag = 0 - break - end - else - head = inject(parent,head,first,last,tag,line) - tag = 0 - break - end - else - tag = 0 - break - end - id = nil -- so no test later on + -- if tag > 0 then + -- local tc, lc = getsynctexfields(current) + -- if tc and tc > 0 then + -- if tag ~= tc or line ~= lc then + -- head = inject(parent,head,first,last,tag,line) + -- tag = 0 + -- break + -- end + -- else + -- head = inject(parent,head,first,last,tag,line) + -- tag = 0 + -- break + -- end + -- else + -- tag = 0 + -- break + -- end + -- id = nil -- so no test later on elseif id == penalty_code then -- go on (and be nice for math) else diff --git a/tex/context/base/mkxl/pack-mrl.mkxl b/tex/context/base/mkxl/pack-mrl.mkxl index ce25fe1dd..7a04f3904 100644 --- a/tex/context/base/mkxl/pack-mrl.mkxl +++ b/tex/context/base/mkxl/pack-mrl.mkxl @@ -39,32 +39,82 @@ \installsimplecommandhandler \??blackrules {blackrules} \??blackrules \permanent\protected\def\blackrule - {\hpack\bgroup + {% this was \hpack\bgroup\dontleavehmode but we want leader support + \begingroup \doifelsenextoptionalcs\pack_black_rule_pickup\pack_black_rule_indeed} \def\pack_black_rule_pickup[#1]% {\setupcurrentblackrules[#1]% \pack_black_rule_indeed} +% \def\pack_black_rule_indeed +% {\edef\p_width {\directblackrulesparameter\c!width }% +% \edef\p_height{\directblackrulesparameter\c!height}% +% \edef\p_depth {\directblackrulesparameter\c!depth }% +% \ifx\p_height\v!max +% \setstrut +% \orelse\ifx\p_depth\v!max +% \setstrut +% \fi +% \useblackrulesstyleandcolor\c!style\c!color +% \ifcsname\??blackruletype\directblackrulesparameter\c!type\endcsname +% \lastnamedcs +% \else +% \vrule +% \fi +% \ifx\p_width \v!max\s!width \emwidth\orelse\ifempty\p_width \else\s!width \p_width \fi +% \ifx\p_height\v!max\s!height\strutht\orelse\ifempty\p_height\else\s!height\p_height\fi +% \ifx\p_depth \v!max\s!depth \strutdp\orelse\ifempty\p_depth \else\s!depth \p_depth \fi +% \egroup} + \def\pack_black_rule_indeed - {\edef\p_width {\directblackrulesparameter\c!width }% - \edef\p_height{\directblackrulesparameter\c!height}% - \edef\p_depth {\directblackrulesparameter\c!depth }% + {\edef\p_width {\directblackrulesparameter\c!width}% + \edef\p_height {\directblackrulesparameter\c!height}% + \edef\p_depth {\directblackrulesparameter\c!depth}% + \edef\p_stretch{\directblackrulesparameter\c!stretch}% + \edef\p_shrink {\directblackrulesparameter\c!shrink}% \ifx\p_height\v!max \setstrut + \let\p_height\strutdp \orelse\ifx\p_depth\v!max \setstrut \fi + % \ifx\p_height\v!max + % \let\p_height\strutdp + % \fi + \ifx\p_depth\v!max + \let\p_depth\strutdp + \fi + \ifx\p_width\v!max + \let\p_width\emwidth + \fi \useblackrulesstyleandcolor\c!style\c!color + \ifempty\p_stretch + \ifempty\p_shrink + \donefalse + \else + \donetrue + \leaders + \fi + \else + \donetrue + \leaders + \fi \ifcsname\??blackruletype\directblackrulesparameter\c!type\endcsname \lastnamedcs \else \vrule \fi - \ifx\p_width \v!max\s!width \emwidth\orelse\ifempty\p_width \else\s!width \p_width \fi - \ifx\p_height\v!max\s!height\strutht\orelse\ifempty\p_height\else\s!height\p_height\fi - \ifx\p_depth \v!max\s!depth \strutdp\orelse\ifempty\p_depth \else\s!depth \p_depth \fi - \egroup} + \ifempty\p_height\else\s!height\p_height\fi + \ifempty\p_depth\else\s!depth\p_depth\fi + \ifdone + \hskip\ifempty\p_width\zeropoint\else\p_width\fi + \ifempty\p_stretch\else\s!plus\p_stretch\fi + \ifempty\p_shrink\else\s!minus\p_shrink\fi + \else + \ifempty\p_width\else\s!width\p_width\fi + \fi + \endgroup} \setupblackrules [\c!width=\emwidth, @@ -99,7 +149,7 @@ %D would probably have taken more tokens. \permanent\tolerant\protected\def\blackrules[#1]% probably never used - {\hpack\bgroup + {\hpack\bgroup % we keep this because breaking into lines breaks compatibility \ifarguments\or\setupcurrentblackrules[#1]\fi \scratchwidth \directblackrulesparameter\c!width \scratchheight \directblackrulesparameter\c!height @@ -136,15 +186,15 @@ \installcorenamespace{blackruletype} -\setvalue{\??blackruletype mp}% +\defcsname\??blackruletype mp\endcsname {\frule type {mp}% data {\includeMPgraphic{\directblackrulesparameter\c!mp}} line \dimexpr\directblackrulesparameter\c!rulethickness\relax } -\letvalue{\??blackruletype\s!no }\novrule -%letvalue{\??blackruletype\s!yes}\vrule +\letcsname\??blackruletype\s!no \endcsname\novrule +%letcsname\??blackruletype\s!yes\endcsname\vrule \setupblackrules [\c!n=3, diff --git a/tex/context/base/mkxl/spac-hor.mkxl b/tex/context/base/mkxl/spac-hor.mkxl index 245195011..c8ac4c74c 100644 --- a/tex/context/base/mkxl/spac-hor.mkxl +++ b/tex/context/base/mkxl/spac-hor.mkxl @@ -1021,22 +1021,22 @@ \overloaded\permanent\protected \def\negthickspace{\textormathspace-\thickmuskip3} \overloaded\permanent\protected\edef\medspace {\textormathspacecommand+\medmuskip{\Uchar"205F}} -% needed for unicode: - -% \protected\def\breakablethinspace {\breakabletextormathspace+\thinmuskip1} -% \protected\def\twoperemspace {\hskip\dimexpr\emwidth/2\relax} % == \enspace -% \protected\def\threeperemspace {\hskip\dimexpr\emwidth/3\relax} -% \protected\def\fourperemspace {\hskip\dimexpr\emwidth/4\relax} -% \protected\def\fiveperemspace {\hskip\dimexpr\emwidth/5\relax} % goodie -% \protected\def\sixperemspace {\hskip\dimexpr\emwidth/6\relax} -% \protected\def\figurespace {\begingroup\setbox\scratchbox\hbox{0}\hskip\wd\scratchbox\endgroup} % there is a command for this -% \protected\def\punctuationspace {\begingroup\setbox\scratchbox\hbox{.}\hskip\wd\scratchbox\endgroup} -% \protected\def\ideographicspace {\hskip\dimexpr\emwidth/1\relax} -% \protected\def\ideographichalffillspace{\hskip\dimexpr\emwidth/2\relax} -% \protected\def\nobreakspace {\penalty\plustenthousand\kern\interwordspace} -% \protected\def\narrownobreakspace {\penalty\plustenthousand\thinspace} -% \protected\def\zerowidthnobreakspace {\penalty\plustenthousand\kern\zeropoint} -% \protected\def\zerowidthspace {\hskip\zeropoint} +% maybe + +% \protected\def\breakablethinskip {\breakabletextormathspace+\thinmuskip1} +% \protected\def\twoperemskip {\hskip\dimexpr\emwidth/2\relax} % == \enspace +% \protected\def\threeperemskip {\hskip\dimexpr\emwidth/3\relax} +% \protected\def\fourperemskip {\hskip\dimexpr\emwidth/4\relax} +% \protected\def\fiveperemskip {\hskip\dimexpr\emwidth/5\relax} % goodie +% \protected\def\sixperemskip {\hskip\dimexpr\emwidth/6\relax} +% \protected\def\figureskip {\begingroup\setbox\scratchbox\hbox{0}\hskip\wd\scratchbox\endgroup} % there is a command for this +% \protected\def\punctuationskip {\begingroup\setbox\scratchbox\hbox{.}\hskip\wd\scratchbox\endgroup} +% \protected\def\ideographicskip {\hskip\dimexpr\emwidth/1\relax} +% \protected\def\ideographichalffillskip{\hskip\dimexpr\emwidth/2\relax} +% \protected\def\nobreakskip {\penalty\plustenthousand\kern\interwordspace} +% \protected\def\narrownobreakskip {\penalty\plustenthousand\thinspace} +% \protected\def\zerowidthnobreakskip {\penalty\plustenthousand\kern\zeropoint} +% \protected\def\zerowidthskip {\hskip\zeropoint} \definehspace[.5][.1250\emwidth] % hair \definehspace[1] [.1667\emwidth] % thin diff --git a/tex/context/base/mkxl/trac-deb.lmt b/tex/context/base/mkxl/trac-deb.lmt index f54e0605e..caa5464f8 100644 --- a/tex/context/base/mkxl/trac-deb.lmt +++ b/tex/context/base/mkxl/trac-deb.lmt @@ -25,6 +25,7 @@ local implement = interfaces.implement local ioflush = io.flush local ioread = io.read local ossleep = os.sleep +local osexit = os.exit local writenl = texio.writenl local write = texio.write @@ -428,14 +429,19 @@ implement { -- protected = false, -- expandable arguments = { "optional", "string" }, actions = function(t,s) - t = tonumber(t) - if t then - report("%s (sleep: %.3N)",s,t) - ioflush() - ossleep(t) - else + if t == "quit" then report(s) - ioflush() + osexit() + else + t = tonumber(t) + if t then + report("%s (sleep: %.3N)",s,t) + ioflush() + ossleep(t) + else + report(s) + ioflush() + end end end } -- cgit v1.2.3