diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-06-25 15:40:51 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-06-25 15:40:51 +0200 |
commit | b2a2304cbb0c65040d7b118ac9b857d304e333e6 (patch) | |
tree | ed5212e37a91ec78c12d9f72ca1186a59c139b40 /tex/context/base | |
parent | b2276ae7a04a9f9c35403e508670049d8c3e4b3e (diff) | |
download | context-b2a2304cbb0c65040d7b118ac9b857d304e333e6.tar.gz |
2016-06-25 14:42:00
Diffstat (limited to 'tex/context/base')
36 files changed, 442 insertions, 91 deletions
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 91591b038..f6f778254 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/mkiv/char-enc.lua b/tex/context/base/mkiv/char-enc.lua index c2061891a..f4f9fb95a 100644 --- a/tex/context/base/mkiv/char-enc.lua +++ b/tex/context/base/mkiv/char-enc.lua @@ -162,7 +162,6 @@ characters.synonyms = allocate { -- afm mess -- if not enccodes[name] then enccodes[name] = unicode end -- end -- --- -- end -- -- storage.register("characters.enccodes", characters.enccodes, "characters.enccodes") diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 89a6d4c7f..3f90812a0 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2016.06.20 22:14} +\newcontextversion{2016.06.25 14:38} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index dd869f035..a59a31463 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -39,7 +39,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2016.06.20 22:14} +\edef\contextversion{2016.06.25 14:38} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/mkiv/font-age.lua b/tex/context/base/mkiv/font-age.lua index bb6883a74..b20a57538 100644 --- a/tex/context/base/mkiv/font-age.lua +++ b/tex/context/base/mkiv/font-age.lua @@ -12,7 +12,7 @@ if context then os.exit() end -return { -- generated: inspect(fonts.encodings.agl.unicodes) +return { ["A"]=65, ["AE"]=198, ["AEacute"]=508, @@ -1527,6 +1527,7 @@ return { -- generated: inspect(fonts.encodings.agl.unicodes) ["dotbelowcomb"]=803, ["dotkatakana"]=12539, ["dotlessi"]=305, + ["dotlessj"]=567, ["dotlessjstrokehook"]=644, ["dotmath"]=8901, ["dottedcircle"]=9676, diff --git a/tex/context/base/mkiv/font-agl.lua b/tex/context/base/mkiv/font-agl.lua index dd3490523..ec6c519ee 100644 --- a/tex/context/base/mkiv/font-agl.lua +++ b/tex/context/base/mkiv/font-agl.lua @@ -631,6 +631,8 @@ local extras = allocate { -- private extensions spade = 0x2660, theta1 = 0x03D1, twodotenleader = 0x2025, + + dotlessj = 0x0237, } -- We load this table only when needed. We could use a loading mechanism diff --git a/tex/context/base/mkiv/font-con.lua b/tex/context/base/mkiv/font-con.lua index 6139b8911..9a6f3f84d 100644 --- a/tex/context/base/mkiv/font-con.lua +++ b/tex/context/base/mkiv/font-con.lua @@ -259,17 +259,19 @@ local psfake = 0 local function fixedpsname(psname,fallback) local usedname = psname - if not psname or psname == "" then + if psname and psname ~= "" then + if find(psname," ") then + usedname = gsub(psname,"[%s]+","-") + else + -- we assume that the name is sane enough (we might sanitize completely some day) + end + elseif not fallback or fallback == "" then + psfake = psfake + 1 + psname = "fakename-" .. psfake + else -- filenames can be a mess so we do a drastic cleanup psname = fallback usedname = gsub(psname,"[^a-zA-Z0-9]+","-") - elseif find(psname," ") then - -- we assume that the name is sane enough (we might sanitize completely some day) - usedname = gsub(psname,"[%s]+","-") - end - if not psname or psname == "" then - psfake = psfake + 1 - psname = "fakename-" .. psfake end return usedname, psname ~= usedname end diff --git a/tex/context/base/mkiv/font-dsp.lua b/tex/context/base/mkiv/font-dsp.lua index 36511743a..49d5929f6 100644 --- a/tex/context/base/mkiv/font-dsp.lua +++ b/tex/context/base/mkiv/font-dsp.lua @@ -224,10 +224,15 @@ local function readcoverage(f,offset,simple) return coverage end -local function readclassdef(f,offset) +local function readclassdef(f,offset,preset) setposition(f,offset) local classdefformat = readushort(f) local classdef = { } + if type(preset) == "number" then + for k=0,preset-1 do + classdef[k] = 1 + end + end if classdefformat == 1 then local index = readushort(f) local nofclassdef = readushort(f) @@ -249,6 +254,13 @@ local function readclassdef(f,offset) else report("unknown classdef format %a ",classdefformat) end + if type(preset) == "table" then + for k in next, preset do + if not classdef[k] then + classdef[k] = 1 + end + end + end return classdef end @@ -459,7 +471,7 @@ local function unchainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,n local rules = { } if subclasssets then coverage = readcoverage(f,tableoffset + coverage) - currentclassdef = readclassdef(f,tableoffset + currentclassdef) + currentclassdef = readclassdef(f,tableoffset + currentclassdef,coverage) local currentclasses = classtocoverage(currentclassdef,fontdata.glyphs) for class=1,#subclasssets do local offset = subclasssets[class] @@ -588,9 +600,9 @@ local function chainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,nof local rules = { } if subclasssets then local coverage = readcoverage(f,tableoffset + coverage) - local beforeclassdef = readclassdef(f,tableoffset + beforeclassdef) - local currentclassdef = readclassdef(f,tableoffset + currentclassdef) - local afterclassdef = readclassdef(f,tableoffset + afterclassdef) + local beforeclassdef = readclassdef(f,tableoffset + beforeclassdef,nofglyphs) + local currentclassdef = readclassdef(f,tableoffset + currentclassdef,coverage) + local afterclassdef = readclassdef(f,tableoffset + afterclassdef,nofglyphs) local beforeclasses = classtocoverage(beforeclassdef,fontdata.glyphs) local currentclasses = classtocoverage(currentclassdef,fontdata.glyphs) local afterclasses = classtocoverage(afterclassdef,fontdata.glyphs) @@ -1014,8 +1026,8 @@ function gposhandlers.pair(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofgly local nofclasses2 = readushort(f) -- incl class 0 local classlist = readpairclasssets(f,nofclasses1,nofclasses2,format1,format2) coverage = readcoverage(f,tableoffset+coverage) - classdef1 = readclassdef(f,tableoffset+classdef1) - classdef2 = readclassdef(f,tableoffset+classdef2) + classdef1 = readclassdef(f,tableoffset+classdef1,coverage) + classdef2 = readclassdef(f,tableoffset+classdef2,nofglyphs) local usedcoverage = { } for g1, c1 in next, classdef1 do if coverage[g1] then diff --git a/tex/context/base/mkiv/font-enc.lua b/tex/context/base/mkiv/font-enc.lua index 2e8b722de..ba957bdf2 100644 --- a/tex/context/base/mkiv/font-enc.lua +++ b/tex/context/base/mkiv/font-enc.lua @@ -20,7 +20,7 @@ them in tables. But we may do so some day, for consistency.</p> local report_encoding = logs.reporter("fonts","encoding") -local encodings = { } +local encodings = fonts.encodings or { } fonts.encodings = encodings encodings.version = 1.03 @@ -79,6 +79,7 @@ function encodings.load(filename) local ok, encoding, size = resolvers.loadbinfile(foundname) if ok and encoding then encoding = gsub(encoding,"%%(.-)\n","") + local unicoding = fonts.encodings.agl.unicodes local tag, vec = match(encoding,"/(%w+)%s*%[(.*)%]%s*def") local i = 0 for ch in gmatch(vec,"/([%a%d%.]+)") do @@ -89,8 +90,9 @@ function encodings.load(filename) else -- duplicate, play safe for tex ligs and take first end - if enccodes[ch] then - unicodes[enccodes[ch]] = i + local u = unicoding[ch] or enccodes[ch] -- enccodes have also context names + if u then + unicodes[u] = i end end i = i + 1 diff --git a/tex/context/base/mkiv/font-mis.lua b/tex/context/base/mkiv/font-mis.lua index 7278f283f..f90247c89 100644 --- a/tex/context/base/mkiv/font-mis.lua +++ b/tex/context/base/mkiv/font-mis.lua @@ -21,7 +21,7 @@ local readers = otf.readers if readers then - otf.version = otf.version or 3.024 + otf.version = otf.version or 3.025 otf.cache = otf.cache or containers.define("fonts", "otl", otf.version, true) function fonts.helpers.getfeatures(name,save) diff --git a/tex/context/base/mkiv/font-otl.lua b/tex/context/base/mkiv/font-otl.lua index 6eb12cdcf..a35db5b0a 100644 --- a/tex/context/base/mkiv/font-otl.lua +++ b/tex/context/base/mkiv/font-otl.lua @@ -53,7 +53,7 @@ local report_otf = logs.reporter("fonts","otf loading") local fonts = fonts local otf = fonts.handlers.otf -otf.version = 3.024 -- beware: also sync font-mis.lua and in mtx-fonts +otf.version = 3.025 -- beware: also sync font-mis.lua and in mtx-fonts otf.cache = containers.define("fonts", "otl", otf.version, true) otf.svgcache = containers.define("fonts", "svg", otf.version, true) otf.pdfcache = containers.define("fonts", "pdf", otf.version, true) diff --git a/tex/context/base/mkiv/luat-fio.lua b/tex/context/base/mkiv/luat-fio.lua index 2b083b582..302d17a66 100644 --- a/tex/context/base/mkiv/luat-fio.lua +++ b/tex/context/base/mkiv/luat-fio.lua @@ -92,16 +92,16 @@ if not resolvers.instance then register('find_vf_file' , function(name) return findbinfile(name,"vf") end, true) register('find_cidmap_file' , function(name) return findbinfile(name,"cidmap") end, true) - register('read_data_file' , function(file) return loadbinfile(file,"tex") end, true) - register('read_enc_file' , function(file) return loadbinfile(file,"enc") end, true) - register('read_font_file' , function(file) return loadbinfile(file,"tfm") end, true) + register('read_data_file' , function(file) return loadbinfile(file,"tex") end, true) + register('read_enc_file' , function(file) return loadbinfile(file,"enc") end, true) + register('read_font_file' , function(file) return loadbinfile(file,"tfm") end, true) -- format -- image - register('read_map_file' , function(file) return loadbinfile(file,"map") end, true) + register('read_map_file' , function(file) return loadbinfile(file,"map") end, true) -- output - register('read_pk_file' , function(file) return loadbinfile(file,"pk") end, true) -- 600dpi/manfnt.720pk - register('read_sfd_file' , function(file) return loadbinfile(file,"sfd") end, true) - register('read_vf_file' , function(file) return loadbinfile(file,"vf" ) end, true) + register('read_pk_file' , function(file) return loadbinfile(file,"pk") end, true) -- 600dpi/manfnt.720pk + register('read_sfd_file' , function(file) return loadbinfile(file,"sfd") end, true) + register('read_vf_file' , function(file) return loadbinfile(file,"vf" ) end, true) -- register('find_font_file' , function(name) return findbinfile(name,"ofm") end, true) -- register('find_vf_file' , function(name) return findbinfile(name,"ovf") end, true) diff --git a/tex/context/base/mkiv/lxml-aux.lua b/tex/context/base/mkiv/lxml-aux.lua index abe36837e..9a829795d 100644 --- a/tex/context/base/mkiv/lxml-aux.lua +++ b/tex/context/base/mkiv/lxml-aux.lua @@ -257,7 +257,17 @@ function xml.replace(root,pattern,whatever) report('replacing',pattern,c,e) end local d = p.dt - d[e.ni] = copiedelement(element,p) + local n = e.ni + local t = copiedelement(element,p) + if type(t) == "table" then + d[n] = t[1] + for i=2,#t do + n = n + 1 + insert(d,n,t[i]) + end + else + d[n] = t + end redo_ni(d) -- probably not needed end end diff --git a/tex/context/base/mkiv/lxml-ini.mkiv b/tex/context/base/mkiv/lxml-ini.mkiv index 6fa14ddfc..bf641f10b 100644 --- a/tex/context/base/mkiv/lxml-ini.mkiv +++ b/tex/context/base/mkiv/lxml-ini.mkiv @@ -310,6 +310,16 @@ \unexpanded\def\xmlinstalldirective#1#2% {\clf_xmlinstalldirective{#1}{\csstring#2}} +% an example: + +% <?context-tex-directive bgroup ?> + +\appendtoks + \xmlinstalldirective{tex}{xmltexcommand}% +\to \everyjob + +\def\xmltexcommand#1{\begincsname#1\endcsname} + % \def\xmlcontextdirective#1% kind class key value % {\executeifdefined{xml#1directive}\gobblethreearguments} diff --git a/tex/context/base/mkiv/lxml-tab.lua b/tex/context/base/mkiv/lxml-tab.lua index 3c386b7a3..209dec7f9 100644 --- a/tex/context/base/mkiv/lxml-tab.lua +++ b/tex/context/base/mkiv/lxml-tab.lua @@ -1243,17 +1243,15 @@ generic table copier. Since we know what we're dealing with we can speed up things a bit. The second argument is not to be used!</p> --ldx]]-- --- local function copy(old,tables) +-- local function copy(old) -- if old then --- if not tables then --- tables = { } --- end -- local new = { } --- if not tables[old] then --- tables[old] = new --- end -- for k,v in next, old do --- new[k] = (type(v) == "table" and (tables[v] or copy(v, tables))) or v +-- if type(v) == "table" then +-- new[k] = table.copy(v) +-- else +-- new[k] = v +-- end -- end -- local mt = getmetatable(old) -- if mt then @@ -1264,15 +1262,27 @@ can speed up things a bit. The second argument is not to be used!</p> -- return { } -- end -- end +-- +-- We need to prevent __p__ recursio, so: -local function copy(old) +local function copy(old,p) if old then local new = { } - for k,v in next, old do - if type(v) == "table" then - new[k] = table.copy(v) - else + for k, v in next, old do + local t = type(v) == "table" + if k == "at" then + local t = { } + for k, v in next, v do + t[k] = v + end + new[k] = t + elseif k == "dt" then + v.__p__ = nil + v = copy(v,new) new[k] = v + v.__p__ = p + else + new[k] = v -- so we also share entities, etc in root end end local mt = getmetatable(old) diff --git a/tex/context/base/mkiv/lxml-tex.lua b/tex/context/base/mkiv/lxml-tex.lua index 026cf520d..eb7d15de8 100644 --- a/tex/context/base/mkiv/lxml-tex.lua +++ b/tex/context/base/mkiv/lxml-tex.lua @@ -2206,7 +2206,11 @@ local pattern = P("context-") * C((1-patterns.whitespace)^1) * C(P(1)^1) function lxml.applyselectors(id) local root = getid(id) local function filter(e) - local dt = e.dt + local dt = e.dt + if not dt then + report_lxml("error in selector, no data in %a",e.tg or "?") + return + end local ndt = #dt local done = false local i = 1 @@ -2312,7 +2316,7 @@ function lxml.applyselectors(id) end end end - else + elseif dti then filter(dti) end end diff --git a/tex/context/base/mkiv/math-ali.mkiv b/tex/context/base/mkiv/math-ali.mkiv index f9ac1e877..209d7a0fd 100644 --- a/tex/context/base/mkiv/math-ali.mkiv +++ b/tex/context/base/mkiv/math-ali.mkiv @@ -114,6 +114,14 @@ \the\mathdisplayaligntweaks \tabskip\centering} +\def\math_halign_checked + {\halign + \ifnum\c_strc_formulas_mode=\plustwo + % currently there is no need for width juggling + \else + \ifcase\eqalignmode \or to \checkeddisplaywidth \fi + \fi} + \def\math_both_eqalign_no_normal#1#2% {\ifmmode \the\mathdisplayaligntweaks @@ -123,7 +131,7 @@ \let\math_finish_eqalign_no\relax \fi #1% - \halign \ifcase\eqalignmode \or to \checkeddisplaywidth \fi \expandafter {\the\scratchtoks\crcr#2\crcr}% + \math_halign_checked\expandafter\bgroup\the\scratchtoks\crcr#2\crcr\egroup \math_finish_eqalign_no} \def\math_both_eqalign_no_aligned#1% @@ -139,7 +147,7 @@ \fi \fi #1% - \halign \ifcase\eqalignmode \or to \checkeddisplaywidth \fi \expandafter \bgroup\the\scratchtoks\crcr} + \math_halign_checked\expandafter\bgroup\the\scratchtoks\crcr} \def\math_rlap#1% {\setbox\scratchbox\hbox{#1}% diff --git a/tex/context/base/mkiv/math-vfu.lua b/tex/context/base/mkiv/math-vfu.lua index bba4112f0..2cfe0de10 100644 --- a/tex/context/base/mkiv/math-vfu.lua +++ b/tex/context/base/mkiv/math-vfu.lua @@ -563,6 +563,10 @@ function vfmath.addmissing(main,id,size) raise(main,characters,id,size,0x2032,0xFE325,1,id_of_smaller) -- prime raise(main,characters,id,size,0x2033,0xFE325,2,id_of_smaller) -- double prime raise(main,characters,id,size,0x2034,0xFE325,3,id_of_smaller) -- triple prime + -- to satisfy the prime resolver + characters[0xFE932] = characters[0x2032] + characters[0xFE933] = characters[0x2033] + characters[0xFE934] = characters[0x2034] end -- there are more (needs discussion first): diff --git a/tex/context/base/mkiv/meta-ini.mkiv b/tex/context/base/mkiv/meta-ini.mkiv index d0fff83df..c9b15c822 100644 --- a/tex/context/base/mkiv/meta-ini.mkiv +++ b/tex/context/base/mkiv/meta-ini.mkiv @@ -545,11 +545,9 @@ \fi} \def\MPrawvar#1#2% no checking - %{\csname\??graphicvariable#1:#2\endcsname} {\begincsname\??graphicvariable#1:#2\endcsname} \def\MPvariable#1% todo: could be a framed chain - %{\csname\??graphicvariable\currentmpvariableclass:#1\endcsname} {\begincsname\??graphicvariable\currentmpvariableclass:#1\endcsname} \unexpanded\def\useMPvariables diff --git a/tex/context/base/mkiv/mlib-lua.lua b/tex/context/base/mkiv/mlib-lua.lua index 5d30d38eb..d348981e7 100644 --- a/tex/context/base/mkiv/mlib-lua.lua +++ b/tex/context/base/mkiv/mlib-lua.lua @@ -356,9 +356,10 @@ end -- texts: -local factor = 65536*(7227/7200) -local textexts = nil -local mptriplet = mp.triplet +local factor = 65536*(7227/7200) +local textexts = nil +local mptriplet = mp.triplet +local nbdimensions = nodes.boxes.dimensions function mp.tt_initialize(tt) textexts = tt @@ -387,6 +388,12 @@ function mp.tt_dimensions(n) end end +function mp.tb_dimensions(category,name) + local w, h, d = nbdimensions(category,name) + mptriplet(w/factor,h/factor,d/factor) +end + + function mp.report(a,b) if b then report_message("%s : %s",a,b) diff --git a/tex/context/base/mkiv/mlib-pps.lua b/tex/context/base/mkiv/mlib-pps.lua index 358bd9f52..42a2cf12a 100644 --- a/tex/context/base/mkiv/mlib-pps.lua +++ b/tex/context/base/mkiv/mlib-pps.lua @@ -931,6 +931,8 @@ local function cl_reset(t) t[#t+1] = metapost.colorinitializer() -- only color end +-- text + local function tx_reset() if top then -- why ? @@ -1083,6 +1085,37 @@ local function tx_process(object,prescript,before,after) end end +-- we could probably redo normal textexts in the next way but as it's rather optimized +-- we keep away from that (at least for now) + +local function bx_process(object,prescript,before,after) + local bx_category = prescript.bx_category + local bx_name = prescript.bx_name + if bx_category and bx_name then + if trace_textexts then + report_textexts("category %a, name %a",bx_category,bx_name) + end + local sx, rx, ry, sy, tx, ty = cm(object) -- needs to be frozen outside the function + local wd, ht, dp = nodes.boxes.dimensions(bx_category,bx_name) + before[#before+1] = function() + context.MPLIBgetboxscaledcm(bx_category,bx_name, + f_f(sx), -- bah ... %s no longer checks + f_f(rx), -- bah ... %s no longer checks + f_f(ry), -- bah ... %s no longer checks + f_f(sy), -- bah ... %s no longer checks + f_f(tx), -- bah ... %s no longer checks + f_f(ty), -- bah ... %s no longer checks + sxsy(wd,ht,dp)) + end + if not trace_textexts then + object.path = false -- else: keep it + end + object.color = false + object.grouped = true + object.istext = true + end +end + -- graphics (we use the given index because pictures can be reused) local graphics = { } @@ -1508,6 +1541,7 @@ appendaction(processoractions,"system",sh_process) -- (processoractions,"system",gt_process) appendaction(processoractions,"system",bm_process) appendaction(processoractions,"system",tx_process) +appendaction(processoractions,"system",bx_process) appendaction(processoractions,"system",ps_process) appendaction(processoractions,"system",fg_process) appendaction(processoractions,"system",tr_process) -- last, as color can be reset diff --git a/tex/context/base/mkiv/mlib-pps.mkiv b/tex/context/base/mkiv/mlib-pps.mkiv index cdccfc379..3a3ab2623 100644 --- a/tex/context/base/mkiv/mlib-pps.mkiv +++ b/tex/context/base/mkiv/mlib-pps.mkiv @@ -91,6 +91,33 @@ \smashbox\MPbox \box\MPbox} +% \putnextboxincache{hans}{1}\hbox{foo} +% +% \startMPcode +% draw boundingbox rawtexbox("hans",1) ; +% draw rawtexbox("hans",1) ; +% \stopMPcode + +\unexpanded\def\MPLIBgetboxscaledcm#1#2% + {\begingroup + \copyboxfromcache{#1}{#2}\MPtextbox % can be \clf_ + \MPLIBgetboxscaledcm_next} + +\unexpanded\def\MPLIBgetboxscaledcm_next#1#2#3#4#5#6#7#8% 1-6: sx,rx,ry,sy,tx,ty + {\setbox\MPbox\hpack\bgroup + \dotransformnextbox{#1}{#2}{#3}{#4}{#5}{#6}% + \vpack to \zeropoint\bgroup + \vss + \hpack to \zeropoint \bgroup + \fastsxsy{#7}{#8}{\raise\dp\MPtextbox\box\MPtextbox}% + \hss + \egroup + \egroup + \egroup + \smashbox\MPbox + \box\MPbox + \endgroup} + \unexpanded\def\MPLIBgraphictext#1% use at mp end {\startTEXpage[\c!scale=10000]#1\stopTEXpage} diff --git a/tex/context/base/mkiv/mtx-context-listing.tex b/tex/context/base/mkiv/mtx-context-listing.tex index 2deffd795..41e468e1f 100644 --- a/tex/context/base/mkiv/mtx-context-listing.tex +++ b/tex/context/base/mkiv/mtx-context-listing.tex @@ -82,6 +82,8 @@ mkii = "tex", cld = "lua", lfg = "lua", + mpiv = "mp", + mpii = "mp", } local pattern = document.arguments.pattern diff --git a/tex/context/base/mkiv/mtx-context-xml.tex b/tex/context/base/mkiv/mtx-context-xml.tex index 9d0680e2a..8e4d229f5 100644 --- a/tex/context/base/mkiv/mtx-context-xml.tex +++ b/tex/context/base/mkiv/mtx-context-xml.tex @@ -23,6 +23,8 @@ % --bodyfont=list : additional bodyfont settings % --paperformat=spec : paper*print or paperxprint % +% context --extra=xml --analyze path::i-context.xml +% context --extra=xml --analyze selfautoparent:texmf-context/tex/context/interface/mkiv/i-*.xml % end help \input mtx-context-common.tex @@ -50,8 +52,8 @@ \starttext \startluacode - local pattern = document.arguments.pattern local files = document.files + local pattern = document.arguments.pattern or (#files == 1 and files[1]) if pattern then files = dir.glob(pattern) diff --git a/tex/context/base/mkiv/mult-aux.mkiv b/tex/context/base/mkiv/mult-aux.mkiv index d44c0242e..a64e09305 100644 --- a/tex/context/base/mkiv/mult-aux.mkiv +++ b/tex/context/base/mkiv/mult-aux.mkiv @@ -584,6 +584,11 @@ {\installbasicparameterhandler{#1}{#2}% \installautosetuphandler {#1}{#2}} +\unexpanded\def\installstylisticautosetuphandler#1#2#3% \??self name \??parent (can be \??self) + {\installbasicparameterhandler{#1}{#2}% + \installautosetuphandler {#1}{#2}% + \installstyleandcolorhandler {#1}{#2}} + \unexpanded\def\installcommandhandler#1#2#3% \??self name \??parent (can be \??self) {\installbasicparameterhandler{#1}{#2}% \installdefinehandler {#1}{#2}{#3}% diff --git a/tex/context/base/mkiv/mult-fun.lua b/tex/context/base/mkiv/mult-fun.lua index e7ab2c071..d32776b96 100644 --- a/tex/context/base/mkiv/mult-fun.lua +++ b/tex/context/base/mkiv/mult-fun.lua @@ -56,7 +56,7 @@ return { "checkedbounds", "checkbounds", "strut", "rule", "withmask", "bitmapimage", "colordecimals", "ddecimal", "dddecimal", "ddddecimal", - "textext", "thetextext", "rawtextext", "textextoffset", + "textext", "thetextext", "rawtextext", "textextoffset", "texbox", "thetexbox", "rawtexbox", "verbatim", "thelabel", "label", "autoalign", diff --git a/tex/context/base/mkiv/node-fnt.lua b/tex/context/base/mkiv/node-fnt.lua index c130f86ca..84c45d4b0 100644 --- a/tex/context/base/mkiv/node-fnt.lua +++ b/tex/context/base/mkiv/node-fnt.lua @@ -166,17 +166,17 @@ function handlers.characters(head) -- either next or not, but definitely no already processed list starttiming(nodes) - local usedfonts = { } - local attrfonts = { } - local basefonts = { } - local a, u, b = 0, 0, 0 - local basefont = nil - local prevfont = nil - local prevattr = 0 - local mode = nil - local done = false - local variants = nil - local redundant = nil + local usedfonts = { } + local attrfonts = { } + local basefonts = { } + local a, u, b, r = 0, 0, 0, 0 + local basefont = nil + local prevfont = nil + local prevattr = 0 + local mode = nil + local done = false + local variants = nil + local redundant = nil if trace_fontrun then run = run + 1 @@ -213,6 +213,7 @@ function handlers.characters(head) variants = fontvariants[font] if mode == "none" then -- skip + -- variants = false protect_glyph(n) else if basefont then @@ -231,7 +232,7 @@ function handlers.characters(head) a = a + 1 elseif force_basepass then b = b + 1 - basefont = { n, nil } + basefont = { n, false } basefonts[b] = basefont end end @@ -244,7 +245,7 @@ function handlers.characters(head) u = u + 1 elseif force_basepass then b = b + 1 - basefont = { n, nil } + basefont = { n, false } basefonts[b] = basefont end end @@ -265,19 +266,23 @@ function handlers.characters(head) report_fonts("replacing %C by %C",char,variant) end setchar(p,variant) - if not redundant then - redundant = { n } + if redundant then + r = r + 1 + redundant[r] = n else - redundant[#redundant+1] = n + r = 1 + redundant = { n } end end end elseif keep_redundant then -- go on, can be used for tracing - elseif not redundant then - redundant = { n } + elseif redundant then + r = r + 1 + redundant[r] = n else - redundant[#redundant+1] = n + r = 1 + redundant = { n } end end end @@ -292,8 +297,10 @@ function handlers.characters(head) for b in traverse_id(boundary_code,nuthead) do if getsubtype(b) == word_boundary then if redundant then - redundant[#redundant+1] = b + r = r + 1 + redundant[r] = b else + r = 1 redundant = { b } end end @@ -302,7 +309,7 @@ function handlers.characters(head) end if redundant then - for i=1,#redundant do + for i=1,r do local r = redundant[i] local p, n = getboth(r) if r == nuthead then diff --git a/tex/context/base/mkiv/page-mix.mkiv b/tex/context/base/mkiv/page-mix.mkiv index 7aaac5fd3..83ce22058 100644 --- a/tex/context/base/mkiv/page-mix.mkiv +++ b/tex/context/base/mkiv/page-mix.mkiv @@ -57,7 +57,7 @@ % old multicolumns mechanism % % \c!ntop=1, -% \c!rule=\v!off, +% \c!rule=\v!off, : now separator=rule % \c!height=, % \c!blank={\v!line,\v!fixed}, % \c!rulethickness=\linewidth, diff --git a/tex/context/base/mkiv/spac-ver.lua b/tex/context/base/mkiv/spac-ver.lua index 9a439e5c2..f1f5757b7 100644 --- a/tex/context/base/mkiv/spac-ver.lua +++ b/tex/context/base/mkiv/spac-ver.lua @@ -126,6 +126,7 @@ local skipcodes = nodes.skipcodes local penalty_code = nodecodes.penalty local kern_code = nodecodes.kern local glue_code = nodecodes.glue +local insert_code = nodecodes.ins local hlist_code = nodecodes.hlist local vlist_code = nodecodes.vlist local localpar_code = nodecodes.localpar @@ -1957,14 +1958,37 @@ function vspacing.collapsevbox(n,aslist) -- for boxes but using global a_snapmet end -- This one is needed to prevent bleeding of prevdepth to the next page --- which doesn't work well with forced skips. - -local outer = texnest[0] - -function vspacing.resetprevdepth() - if texlists.hold_head then - outer.prevdepth = 0 +-- which doesn't work well with forced skips. I'm not that sure if the +-- following is a good way out. + +do + + local outer = texnest[0] + local reset = true + local trace = false + local report = logs.reporter("vspacing") + + directives.register("vspacing.resetprevdepth",function(v) reset = v end) + trackers.register ("vspacing.resetprevdepth",function(v) trace = v end) + + function vspacing.resetprevdepth() + if reset then + local head = texlists.hold_head + local skip = 0 + while head and head.id == insert_code do + head = head.next + skip = skip + 1 + end + if head then + outer.prevdepth = 0 + end + if trace then + report("prevdepth %s at page %i, skipped %i, value %p", + head and "reset" or "kept",tex.getcount("realpageno"),skip,outer.prevdepth) + end + end end + end -- interface diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex c79387699..ef99b2374 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 e011f4e49..8f5ffceab 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/strc-num.lua b/tex/context/base/mkiv/strc-num.lua index 8b5230b65..ef18406b8 100644 --- a/tex/context/base/mkiv/strc-num.lua +++ b/tex/context/base/mkiv/strc-num.lua @@ -9,6 +9,7 @@ if not modules then modules = { } end modules ['strc-num'] = { local format = string.format local next, type = next, type local min, max = math.min, math.max +local insert, remove, copy = table.insert, table.remove, table.copy local texsetcount = tex.setcount -- Counters are managed here. They can have multiple levels which makes it easier to synchronize @@ -16,6 +17,7 @@ local texsetcount = tex.setcount local allocate = utilities.storage.allocate local setmetatableindex = table.setmetatableindex +local setmetatablecall = table.setmetatablecall local trace_counters = false trackers.register("structures.counters", function(v) trace_counters = v end) local report_counters = logs.reporter("structure","counters") @@ -429,14 +431,23 @@ end function counters.save(name) -- or just number local cd = counterdata[name] if cd then - table.insert(cd.saved,table.copy(cd.data)) + insert(cd.saved,copy(cd.data)) end end function counters.restore(name) local cd = counterdata[name] - if cd and cd.saved then - cd.data = table.remove(cd.saved) + if not cd then + report_counters("invalid restore, no counter %a",name) + return + end + local saved = cd.saved + if not saved then + -- is ok + elseif #saved > 1 then + cd.data = remove(saved) + else + report_counters("restore without save for counter %a",name) end end @@ -640,7 +651,7 @@ implement { name = "decrementedcounter", actions = { add, context }, argume implement { name = "showcounter", actions = showcounter, arguments = "string" } -- todo implement { name = "checkcountersetup", actions = checkcountersetup, arguments = { "string", "integer", "integer", "string" } } -table.setmetatablecall(counterdata,function(t,k) return t[k] end) +setmetatablecall(counterdata,function(t,k) return t[k] end) implement { name = "doifelsecounter", actions = { counterdata, commands.doifelse }, arguments = "string" } implement { name = "doifcounter", actions = { counterdata, commands.doif }, arguments = "string" } diff --git a/tex/context/base/mkiv/supp-box.lua b/tex/context/base/mkiv/supp-box.lua index bf41899bf..6c2846fd1 100644 --- a/tex/context/base/mkiv/supp-box.lua +++ b/tex/context/base/mkiv/supp-box.lua @@ -443,3 +443,144 @@ interfaces.implement { doifelse(firstdirinbox(n) == "TRT") end } + +-- new (handy for mp) .. might move to its own module + +do + + local flush_list = nodes.flush_list + local copy_list = nodes.copy_list + local takebox = nodes.takebox + local texsetbox = tex.setbox + + local new_hlist = nodes.pool.hlist + + local boxes = { } + nodes.boxes = boxes + local cache = table.setmetatableindex("table") + local report = logs.reporter("boxes","cache") + local trace = false + + trackers.register("nodes.boxes",function(v) trace = v end) + + function boxes.save(category,name,box) +name = tonumber(name) or name + local b = takebox(box) + if trace then + report("category %a, name %a, %s (%s)",category,name,"save",b and "content" or "empty") + end + cache[category][name] = b or false + end + + function boxes.direct(category,name,copy) +name = tonumber(name) or name + local c = cache[category] + local b = c[name] + if not b then + -- do nothing, maybe trace + elseif copy then + b = copy_list(b) + else + c[name] = false + end + if trace then + report("category %a, name %a, %s (%s)",category,name,"direct",b and "content" or "empty") + end + return b or nil + end + + function boxes.restore(category,name,box,copy) +name = tonumber(name) or name + local c = cache[category] + local b = takebox(box) + if b then + flush_list(b) + end + local b = c[name] + if not b then + -- do nothing, maybe trace + elseif copy then + b = copy_list(b) + else + c[name] = false + end + if trace then + report("category %a, name %a, %s (%s)",category,name,"restore",b and "content" or "empty") + end + texsetbox(box,b or nil) + end + + function boxes.dimensions(category,name) +name = tonumber(name) or name + local b = cache[category][name] + if b then + return b.width, b.height, b.depth + else + return 0, 0, 0 + end + end + + function boxes.reset(category,name) +name = tonumber(name) or name + local c = cache[category] + if name and name ~= "" then + local b = c[name] + if b then + flush_list(b) + c[name] = false + end + if trace then + report("category %a, name %a, reset",category,name) + end + else + for k, b in next, c do + if b then + flush_list(b) + end + end + cache[category] = { } + if trace then + report("category %a, reset",category) + end + end + end + + interfaces.implement { + name = "putboxincache", + arguments = { "string", "string", "integer" }, + actions = boxes.save, + } + + interfaces.implement { + name = "getboxfromcache", + arguments = { "string", "string", "integer" }, + actions = boxes.restore, + } + + interfaces.implement { + name = "directboxfromcache", + arguments = { "string", "string" }, + actions = { boxes.direct, context }, + -- actions = function(category,name) local b = boxes.direct(category,name) if b then context(b) end end, + } + + interfaces.implement { + name = "directcopyboxfromcache", + arguments = { "string", "string", true }, + actions = { boxes.direct, context }, + -- actions = function(category,name) local b = boxes.direct(category,name,true) if b then context(b) end end, + } + + interfaces.implement { + name = "copyboxfromcache", + arguments = { "string", "string", "integer", true }, + actions = boxes.restore, + } + + interfaces.implement { + name = "resetboxesincache", + arguments = { "string" }, + actions = boxes.reset, + } + +end diff --git a/tex/context/base/mkiv/supp-box.mkiv b/tex/context/base/mkiv/supp-box.mkiv index 499281ebe..d617c82db 100644 --- a/tex/context/base/mkiv/supp-box.mkiv +++ b/tex/context/base/mkiv/supp-box.mkiv @@ -2604,6 +2604,32 @@ \unexpanded\def\globalpushbox{\syst_boxes_push\global} \unexpanded\def\globalpopbox {\syst_boxes_pop \global} +%D And here is a more modern one (not yet in i-*): +%D +%D \starttyping +%D \dorecurse {100} { +%D \setbox\zerocount\hbox{test \recurselevel} +%D \putboxincache{foo}{\recurselevel}\zerocount +%D \copyboxfromcache{foo}{\recurselevel}\zerocount +%D \iftrue +%D \setbox\zerocount\hbox{\directboxfromcache{foo}{\recurselevel}}% +%D \else +%D \getboxfromcache{foo}{\recurselevel}\zerocount +%D \fi +%D } +%D \resetboxesincache{foo} +%D \stoptyping + +\unexpanded\def\putboxincache #1#2#3{\clf_putboxincache {#1}{#2}#3\relax} +\unexpanded\def\getboxfromcache #1#2#3{\clf_getboxfromcache {#1}{#2}#3\relax} +\unexpanded\def\copyboxfromcache #1#2#3{\clf_copyboxfromcache {#1}{#2}#3\relax} +\unexpanded\def\directboxfromcache #1#2{\clf_directboxfromcache {#1}{#2}} +\unexpanded\def\directcopyboxfromcache#1#2{\clf_directcopyboxfromcache{#1}{#2}} +\unexpanded\def\resetboxesincache #1{\clf_resetboxesincache {#1}} + +\unexpanded\def\putnextboxincache#1#2% + {\dowithnextbox{\putboxincache{#1}{#2}\nextbox}} + %D \macros %D {removedepth, obeydepth} %D diff --git a/tex/context/base/mkiv/util-sci.lua b/tex/context/base/mkiv/util-sci.lua index 43d873b63..33e520719 100644 --- a/tex/context/base/mkiv/util-sci.lua +++ b/tex/context/base/mkiv/util-sci.lua @@ -22,6 +22,7 @@ local lexerroot = file.dirname(resolvers.find_file("scite-context-lexer.lua")) local knownlexers = { tex = "tex", mkiv = "tex", mkvi = "tex", mkxi = "tex", mkix = "tex", mkii = "tex", cld = "tex", lua = "lua", lfg = "lua", lus = "lua", + mp = "mps", mpiv = "mps", mpii = "mps", w = "web", ww = "web", c = "cpp", h = "cpp", cpp = "cpp", hpp = "cpp", cxx = "cpp", hxx = "cpp", xml = "xml", lmx = "xml", ctx = "xml", xsl = "xml", xsd = "xml", rlx = "xml", css = "xml", dtd = "xml", diff --git a/tex/context/base/mkiv/util-str.lua b/tex/context/base/mkiv/util-str.lua index 28b75dbc5..a54a4aac9 100644 --- a/tex/context/base/mkiv/util-str.lua +++ b/tex/context/base/mkiv/util-str.lua @@ -824,6 +824,8 @@ end -- extensions : %!tag! +-- can be made faster but not called that often + local builder = Cs { "start", start = ( ( @@ -852,10 +854,10 @@ local builder = Cs { "start", + V("a") -- new + V("A") -- new + V("j") + V("J") -- stripped e E - + V("m") + V("M") -- new + + V("m") + V("M") -- new (formatted number) + V("z") -- new -- - -- + V("?") -- ignores probably messed up % + -- + V("?") -- ignored, probably messed up % ) + V("*") ) |