summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/mkii/cont-new.mkii2
-rw-r--r--tex/context/base/mkii/context.mkii2
-rw-r--r--tex/context/base/mkiv/anch-pgr.lua7
-rw-r--r--tex/context/base/mkiv/anch-pos.lua261
-rw-r--r--tex/context/base/mkiv/attr-ini.lua2
-rw-r--r--tex/context/base/mkiv/cont-new.mkiv2
-rw-r--r--tex/context/base/mkiv/context.mkiv2
-rw-r--r--tex/context/base/mkiv/core-uti.lua12
-rw-r--r--tex/context/base/mkiv/font-ctx.lua2
-rw-r--r--tex/context/base/mkiv/font-mps.lua19
-rw-r--r--tex/context/base/mkiv/grph-rul.lua6
-rw-r--r--tex/context/base/mkiv/lpdf-ano.lua9
-rw-r--r--tex/context/base/mkiv/math-ali.mkiv29
-rw-r--r--tex/context/base/mkiv/math-fen.mkiv28
-rw-r--r--tex/context/base/mkiv/math-ini.mkiv18
-rw-r--r--tex/context/base/mkiv/mlib-int.lua4
-rw-r--r--tex/context/base/mkiv/mlib-pdf.mkiv2
-rw-r--r--tex/context/base/mkiv/mlib-pps.lua18
-rw-r--r--tex/context/base/mkiv/mult-prm.lua2
-rw-r--r--tex/context/base/mkiv/node-aux.lua6
-rw-r--r--tex/context/base/mkiv/node-bck.lua9
-rw-r--r--tex/context/base/mkiv/node-ltp.lua95
-rw-r--r--tex/context/base/mkiv/node-met.lua61
-rw-r--r--tex/context/base/mkiv/node-nut.lua73
-rw-r--r--tex/context/base/mkiv/node-ref.lua160
-rw-r--r--tex/context/base/mkiv/node-res.lua232
-rw-r--r--tex/context/base/mkiv/node-rul.lua4
-rw-r--r--tex/context/base/mkiv/node-typ.lua4
-rw-r--r--tex/context/base/mkiv/pack-rul.lua27
-rw-r--r--tex/context/base/mkiv/page-cst.lua21
-rw-r--r--tex/context/base/mkiv/page-mix.lua33
-rw-r--r--tex/context/base/mkiv/page-set.mkiv2
-rw-r--r--tex/context/base/mkiv/page-txt.mkvi6
-rw-r--r--tex/context/base/mkiv/scrn-ini.mkvi2
-rw-r--r--tex/context/base/mkiv/spac-grd.mkiv2
-rw-r--r--tex/context/base/mkiv/spac-hor.mkiv2
-rw-r--r--tex/context/base/mkiv/spac-prf.lua32
-rw-r--r--tex/context/base/mkiv/spac-ver.lua417
-rw-r--r--tex/context/base/mkiv/spac-ver.mkiv97
-rw-r--r--tex/context/base/mkiv/status-files.pdfbin25628 -> 25642 bytes
-rw-r--r--tex/context/base/mkiv/status-lua.pdfbin369790 -> 369339 bytes
-rw-r--r--tex/context/base/mkiv/strc-itm.mkvi2
-rw-r--r--tex/context/base/mkiv/strc-mat.mkiv44
-rw-r--r--tex/context/base/mkiv/strc-not.lua6
-rw-r--r--tex/context/base/mkiv/strc-ren.mkiv90
-rw-r--r--tex/context/base/mkiv/supp-box.lua136
-rw-r--r--tex/context/base/mkiv/supp-box.mkiv33
-rw-r--r--tex/context/base/mkiv/syst-aux.lua5
-rw-r--r--tex/context/base/mkiv/syst-aux.mkiv23
-rw-r--r--tex/context/base/mkiv/syst-ini.mkiv1
-rw-r--r--tex/context/base/mkiv/tabl-tbl.mkiv2
-rw-r--r--tex/context/base/mkiv/tabl-xtb.lua10
-rw-r--r--tex/context/base/mkiv/trac-jus.lua52
-rw-r--r--tex/context/base/mkiv/trac-vis.lua33
-rw-r--r--tex/context/base/mkiv/typo-bld.lua3
-rw-r--r--tex/context/base/mkiv/typo-del.mkiv2
-rw-r--r--tex/context/base/mkiv/typo-drp.lua19
-rw-r--r--tex/context/base/mkiv/typo-fln.lua6
-rw-r--r--tex/context/base/mkiv/typo-itc.lua4
-rw-r--r--tex/context/base/mkiv/typo-lin.lua10
-rw-r--r--tex/context/base/mkiv/typo-mar.lua24
-rw-r--r--tex/context/base/mkiv/typo-pag.lua4
-rw-r--r--tex/context/base/mkiv/typo-sus.lua4
-rw-r--r--tex/context/base/mkiv/typo-tal.lua6
-rw-r--r--tex/context/interface/mkiv/i-context.pdfbin803809 -> 804150 bytes
-rw-r--r--tex/context/interface/mkiv/i-readme.pdfbin60767 -> 60767 bytes
-rw-r--r--tex/context/interface/mkiv/i-system.xml40
-rw-r--r--tex/context/modules/mkiv/s-fonts-coverage.mkiv3
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua2
69 files changed, 1289 insertions, 987 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii
index a054df213..90d6159a1 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{2017.01.17 17:37}
+\newcontextversion{2017.01.27 14:39}
%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 de8003b5a..a1d9a912e 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{2017.01.17 17:37}
+\edef\contextversion{2017.01.27 14:39}
%D For those who want to use this:
diff --git a/tex/context/base/mkiv/anch-pgr.lua b/tex/context/base/mkiv/anch-pgr.lua
index 5c79f70a1..468b9eee3 100644
--- a/tex/context/base/mkiv/anch-pgr.lua
+++ b/tex/context/base/mkiv/anch-pgr.lua
@@ -88,6 +88,9 @@ local enabled = false
local function registerbackground(name)
local n = #data + 1
if n > recycle then
+ -- we could also free all e: that are beyond a page but we don't always
+ -- know the page so a recycle is nicer and the s lists are kept anyway
+ -- so the amount of kept data is not that large
n = 1
end
local b = jobpositions.tobesaved["b:"..name]
@@ -632,8 +635,8 @@ local function calculatemultipar(tag)
local bn = b.n
local p = bn and collected[f_p_tag(bn)] -- par
if p then
- left = left + p.ls
- right = right + p.rs
+ left = left + (p.ls or 0)
+ right = right + (p.rs or 0)
end
--
local bp = b.p -- page
diff --git a/tex/context/base/mkiv/anch-pos.lua b/tex/context/base/mkiv/anch-pos.lua
index b415fac3a..72d76301c 100644
--- a/tex/context/base/mkiv/anch-pos.lua
+++ b/tex/context/base/mkiv/anch-pos.lua
@@ -20,7 +20,7 @@ more efficient.</p>
-- this is one of the first modules using scanners and we need to replace
-- it by implement and friends
-local tostring, next, rawget, setmetatable, tonumber = tostring, next, rawget, setmetatable, tonumber
+local tostring, next, rawget, rawset, setmetatable, tonumber = tostring, next, rawget, rawset, setmetatable, tonumber
local sort, sortedhash, sortedkeys = table.sort, table.sortedhash, table.sortedkeys
local format, gmatch, match, find = string.format, string.gmatch, string.match, string.find
local rawget = rawget
@@ -51,7 +51,8 @@ local texsp = tex.sp
local pdf = pdf -- h and v are variables
-local setmetatableindex = table.setmetatableindex
+local setmetatableindex = table.setmetatableindex
+local setmetatablenewindex = table.setmetatablenewindex
local nuts = nodes.nuts
@@ -61,9 +62,10 @@ local setlink = nuts.setlink
local getlist = nuts.getlist
local setlist = nuts.setlist
local getbox = nuts.getbox
-local getskip = nuts.getskip
local getid = nuts.getid
-local getdimensions = nuts.dimensions
+local getwhd = nuts.getwhd
+
+local n_flush_node = nodes.flush
local hlist_code = nodes.listcodes.hlist
@@ -122,134 +124,31 @@ local f_region = formatters["region:%s"]
local f_tag_three = formatters["%s:%s:%s"]
local f_tag_two = formatters["%s:%s"]
-local function sorter(a,b)
- return a.y > b.y
-end
-
-local nofusedregions = 0
-local nofmissingregions = 0
-local nofregular = 0
-
-jobpositions.used = false
-
--- todo: register subsets and count them indepently
--- todo: categories, like par, page, ... saves find and also ordered tags then
-
--- local function initializer()
--- tobesaved = jobpositions.tobesaved
--- collected = jobpositions.collected
--- -- add sparse regions
--- local pages = structures.pages.collected
--- if pages then
--- local last = nil
--- for p=1,#pages do
--- local region = "page:" .. p
--- local data = collected[region]
--- if data then
--- last = data
--- last.p = nil -- no need for a page
--- elseif last and not collected[region] then
--- collected[region] = last
--- end
--- end
--- end
--- -- enhance regions with paragraphs -- could be a list of tags instead -- there can be too many
--- local regions = { }
--- -- for tag, data in sortedhash(collected) do --saves a sort later on but can be huge
--- for tag, data in next, collected do
--- if find(tag,"^p:") then
--- local region = data.r
--- if region then
--- local paragraphs = regions[region]
--- if paragraphs then
--- local par = match(tag,"%d+")
--- data.par = tonumber(par)
--- paragraphs[#paragraphs+1] = data
--- nofusedregions = nofusedregions + 1
--- elseif r == false then
--- nofmissingregions = nofmissingregions + 1
--- else
--- local r = collected[region]
--- if r then
--- local par = match(tag,"%d+")
--- data.par = tonumber(par)
--- paragraphs = { data }
--- regions[region] = paragraphs
--- nofusedregions = nofusedregions + 1
--- r.paragraphs = paragraphs
--- else
--- nofmissingregions = nofmissingregions + 1
--- regions[region] = false
--- end
--- end
--- else
--- nofregular = nofregular + 1
--- end
--- end
--- setmetatable(data,default)
--- end
--- -- sort this data
--- for tag, paragraphs in next, regions do
--- if paragraphs then
--- sort(paragraphs,function(a,b) return a.par < b.par end)
--- end
--- end
--- jobpositions.used = next(collected)
--- end
+jobpositions.used = false
-local splitter = lpeg.splitat(":")
+local nofregular = 0
+local nofspecial = 0
+local splitter = lpeg.splitat(":",true)
local function initializer()
tobesaved = jobpositions.tobesaved
collected = jobpositions.collected
- -- add sparse regions
- -- enhance regions with paragraphs -- could be a list of tags instead -- there can be too many
- local regiondata = { }
- local pagedata = { }
- local freedata = setmetatableindex("table")
- -- for tag, data in sortedhash(collected) do --saves a sort later on but can be huge
+ local pagedata = { }
+ local freedata = setmetatableindex("table")
for tag, data in next, collected do
local prefix, rest = lpegmatch(splitter,tag)
if prefix == "p" then
- local region = data.r
- if region then
- local paragraphs = regiondata[region]
- if paragraphs then
- data.par = tonumber(rest) or 0
- paragraphs[#paragraphs+1] = data
- nofusedregions = nofusedregions + 1
- elseif r == false then
- nofmissingregions = nofmissingregions + 1
- else
- local r = collected[region]
- if r then
- data.par = tonumber(rest) or 0
- paragraphs = { data }
- regiondata[region] = paragraphs
- nofusedregions = nofusedregions + 1
- r.paragraphs = paragraphs
- else
- nofmissingregions = nofmissingregions + 1
- regiondata[region] = false
- end
- end
- else
- nofregular = nofregular + 1
- end
+ nofregular = nofregular + 1
elseif prefix == "page" then
+ nofregular = nofregular + 1
pagedata[tonumber(rest) or 0] = data
elseif prefix == "free" then
+ nofspecial = nofspecial + 1
local t = freedata[data.p or 0]
t[#t+1] = data
end
setmetatable(data,default)
end
- -- sort this data
- for tag, paragraphs in next, regiondata do
- if paragraphs then
- sort(paragraphs,function(a,b) return a.par < b.par end)
- end
- end
--
local pages = structures.pages.collected
if pages then
@@ -280,6 +179,98 @@ local function initializer()
jobpositions.used = next(collected)
end
+-- -- we can gain a little when we group positions but then we still have to
+-- -- deal with regions and cells so we either end up with lots of extra small
+-- -- tables pointing to them and/or assembling/disassembling so in the end
+-- -- it makes no sense to do it (now) and still have such a mix
+--
+-- local splitter = lpeg.splitat(":",true)
+--
+-- local function setpos(t,k,v)
+-- local class, tag = lpegmatch(splitter,k)
+-- if tag then
+-- local c = rawget(t,class)
+-- if c then
+-- c[tonumber(tag) or tag] = v
+-- else
+-- rawset(t,class,{ [tonumber(tag) or tag] = v })
+-- end
+-- else
+-- t.default[tonumber(k) or k] = v
+-- end
+-- end
+--
+-- local function getpos(t,k)
+-- local class, tag = lpegmatch(splitter,k)
+-- if tag then
+-- local c = rawget(t,class)
+-- if c then
+-- return c[tonumber(tag) or tag]
+-- end
+-- else
+-- return c.default[tonumber(k) or k]
+-- end
+-- end
+--
+-- tobesaved.default = tobesaved.default or { }
+-- setmetatablenewindex(tobesaved,setpos)
+-- setmetatableindex (tobesaved,getpos)
+--
+-- local function initializer()
+-- tobesaved = jobpositions.tobesaved
+-- collected = jobpositions.collected
+--
+-- tobesaved.default = tobesaved.default or { }
+-- collected.default = collected.default or { }
+--
+-- setmetatablenewindex(tobesaved,setpos)
+-- setmetatableindex (collected,getpos)
+-- setmetatableindex (tobesaved,getpos)
+--
+-- for class, list in next, collected do
+-- for tag, data in next, list do
+-- setmetatable(data,default)
+-- nofregular = nofregular + 1
+-- end
+-- end
+--
+-- local pagedata = collected.page or { }
+-- local freedata = setmetatableindex("table")
+--
+-- for tag, data in next, collected.free or { } do
+-- local t = freedata[data.p or 0]
+-- t[#t+1] = data
+-- end
+--
+-- --
+-- local pages = structures.pages.collected
+-- if pages then
+-- local last = nil
+-- for p=1,#pages do
+-- local data = pagedata[p]
+-- local free = freedata[p]
+-- if free then
+-- sort(free,function(a,b) return b.y < a.y end) -- order matters !
+-- end
+-- if data then
+-- last = data
+-- last.free = free
+-- elseif last then
+-- local t = setmetatableindex({ free = free, p = p },last)
+-- if not pagedata[p] then
+-- pagedata[p] = t
+-- end
+-- end
+-- end
+-- end
+-- jobpositions.page = pagedata
+-- jobpositions.free = freedata
+-- jobpositions.used = next(collected)
+-- end
+--
+-- function jobpositions.getcollected(class,tag) if tag then return collected[class..tag] else return collected[class] end end
+-- function jobpositions.gettobesaved(class,tag) if tag then return tobesaved[class..tag] else return tobesaved[class] end end
+
job.register('job.positions.collected', tobesaved, initializer)
local regions = { }
@@ -494,7 +485,7 @@ local function setregionbox(n,tag,k,lo,ro,to,bo) -- kind
tag = f_region(nofregions)
end
local box = getbox(n)
- local w, h, d = getdimensions(box)
+ local w, h, d = getwhd(box)
local x, y = getpos() -- hm, makes no sense here
tobesaved[tag] = {
-- p = texgetcount("realpageno"), -- we copy them
@@ -556,7 +547,7 @@ scanners.parpos = function() -- todo: relate to localpar (so this is an intermed
nofparagraphs = nofparagraphs + 1
texsetcount("global","c_anch_positions_paragraph",nofparagraphs)
local box = getbox("strutbox")
- local w, h, d = getdimensions(box)
+ local w, h, d = getwhd(box)
local t = {
p = true,
c = true,
@@ -567,8 +558,8 @@ scanners.parpos = function() -- todo: relate to localpar (so this is an intermed
d = d,
hs = texget("hsize"), -- never 0
}
- local leftskip = getfield(getskip("leftskip"),"width")
- local rightskip = getfield(getskip("rightskip"),"width")
+ local leftskip = texget("leftskip",false)
+ local rightskip = texget("rightskip",false)
local hangindent = texget("hangindent")
local hangafter = texget("hangafter")
local parindent = texget("parindent")
@@ -633,7 +624,7 @@ end
scanners.dosetpositionbox = function() -- name box
local name = scanstring()
local box = getbox(scaninteger())
- local w, h, d = getdimensions(box)
+ local w, h, d = getwhd(box)
tobesaved[name] = {
p = true,
c = column,
@@ -673,7 +664,7 @@ end
scanners.dosetpositionstrut = function() -- name
local name = scanstring()
local box = getbox("strutbox")
- local w, h, d = getdimensions(box)
+ local w, h, d = getwhd(box)
tobesaved[name] = {
p = true,
c = column,
@@ -692,7 +683,7 @@ scanners.dosetpositionstrutkind = function() -- name
local name = scanstring()
local kind = scaninteger()
local box = getbox("strutbox")
- local w, h, d = getdimensions(box)
+ local w, h, d = getwhd(box)
tobesaved[name] = {
k = kind,
p = true,
@@ -876,6 +867,8 @@ function jobpositions.position(id)
end
end
+local splitter = lpeg.splitat(",")
+
function jobpositions.extra(id,n,default) -- assume numbers
local jpi = collected[id]
if jpi then
@@ -1282,6 +1275,13 @@ scanners.doifposition = function() -- name
doif(collected[scanstring()])
end
+-- local ctx_iftrue = context.protected.cs.iftrue
+-- local ctx_iffalse = context.protected.cs.iffalse
+--
+-- scanners.ifknownposition = function() -- name
+-- (collected[scanstring()] and ctx_iftrue or ctx_iffalse)()
+-- end
+
scanners.doifelsepositiononpage = function() -- name page -- probably always realpageno
local c = collected[scanstring()]
local p = scaninteger()
@@ -1331,11 +1331,20 @@ end
-- statistics (at least for the moment, when testing)
+-- statistics.register("positions", function()
+-- local total = nofregular + nofusedregions + nofmissingregions
+-- if total > 0 then
+-- return format("%s collected, %s regulars, %s regions, %s unresolved regions",
+-- total, nofregular, nofusedregions, nofmissingregions)
+-- else
+-- return nil
+-- end
+-- end)
+
statistics.register("positions", function()
- local total = nofregular + nofusedregions + nofmissingregions
+ local total = nofregular + nofspecial
if total > 0 then
- return format("%s collected, %s regulars, %s regions, %s unresolved regions",
- total, nofregular, nofusedregions, nofmissingregions)
+ return format("%s collected, %s regular, %s special",total,nofregular,nofspecial)
else
return nil
end
diff --git a/tex/context/base/mkiv/attr-ini.lua b/tex/context/base/mkiv/attr-ini.lua
index 3f5b24692..2a11558a5 100644
--- a/tex/context/base/mkiv/attr-ini.lua
+++ b/tex/context/base/mkiv/attr-ini.lua
@@ -130,7 +130,7 @@ function attributes.ofnode(n)
showlist(n,n.attr)
end
--- rather special
+-- rather special (can be optimized)
local store = { }
diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv
index 2e1068868..5b9050d6c 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{2017.01.17 17:37}
+\newcontextversion{2017.01.27 14:39}
%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 e4a97f01e..e92a39cbd 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{2017.01.17 17:37}
+\edef\contextversion{2017.01.27 14:39}
\edef\contextkind {beta}
%D For those who want to use this:
diff --git a/tex/context/base/mkiv/core-uti.lua b/tex/context/base/mkiv/core-uti.lua
index 601e5aa20..10f3ffcdc 100644
--- a/tex/context/base/mkiv/core-uti.lua
+++ b/tex/context/base/mkiv/core-uti.lua
@@ -400,15 +400,15 @@ end)
-- a sort of joke (for ctx meeting)
-local kg_per_watt_per_second = 1 / 15000000
-local watts_per_core = 50
-local speedup_by_other_engine = 1.2
-local used_wood_factor = watts_per_core * kg_per_watt_per_second / speedup_by_other_engine
-local used_wood_factor = (50 / 15000000) / 1.2
+-- local kg_per_watt_per_second = 1 / 15000000
+-- local watts_per_core = 50
+-- local speedup_by_other_engine = 1.2
+-- local used_wood_factor = watts_per_core * kg_per_watt_per_second / speedup_by_other_engine
+-- local used_wood_factor = (50 / 15000000) / 1.2
function statistics.formatruntime(runtime)
if not environment.initex then -- else error when testing as not counters yet
--- stoptiming(statistics) -- to be sure
+ -- stoptiming(statistics) -- to be sure
local shipped = texgetcount('nofshipouts')
local pages = texgetcount('realpageno')
if pages > shipped then
diff --git a/tex/context/base/mkiv/font-ctx.lua b/tex/context/base/mkiv/font-ctx.lua
index 8905cabc0..7c986f889 100644
--- a/tex/context/base/mkiv/font-ctx.lua
+++ b/tex/context/base/mkiv/font-ctx.lua
@@ -2243,7 +2243,7 @@ do
local copy_node = nuts.copy
local kern = nuts.pool.register(nuts.pool.kern())
- setattr(kern,attributes.private('fontkern'),1)
+ setattr(kern,attributes.private('fontkern'),1) -- no gain in setprop as it's shared
nodes.injections.installnewkern(function(k)
local c = copy_node(kern)
diff --git a/tex/context/base/mkiv/font-mps.lua b/tex/context/base/mkiv/font-mps.lua
index 39c17a1cc..0cda202e6 100644
--- a/tex/context/base/mkiv/font-mps.lua
+++ b/tex/context/base/mkiv/font-mps.lua
@@ -261,6 +261,7 @@ local getfont = nuts.getfont
local getsubtype = nuts.getsubtype
local getfield = nuts.getfield
local getbox = nuts.getbox
+local getwhd = nuts.getwhd
local effective_glue = nuts.effective_glue
@@ -354,10 +355,9 @@ function fonts.metapost.boxtomp(n,kind)
end
dx = dx + getfield(current,"width") * fc
elseif id == rule_code then
- local wd = getfield(current,"width") * fc
+ local wd, ht, dp = getwhd(current)
if wd ~= 0 then
- local ht = getfield(current,"height")
- local dp = getfield(current,"depth")
+ wd = wd * fc
if ht == signal then
ht = getfield(parent,"height")
end
@@ -381,12 +381,13 @@ function fonts.metapost.boxtomp(n,kind)
while current do
local id = getid(current)
if id == hlist_code then
- dy = dy - getfield(current,"height") * fc
+ local _, ht, dp = getwhd(current)
+ dy = dy - ht * fc
local list = getlist(current)
if list then
horizontal(current,list,xoffset+getfield(current,"shift")*fc,yoffset+dy)
end
- dy = dy - getfield(current,"depth") * fc
+ dy = dy - ht * fc
elseif id == vlist_code then
dy = dy - getfield(current,"height") * fc
local list = getlist(current)
@@ -399,11 +400,9 @@ function fonts.metapost.boxtomp(n,kind)
elseif id == glue_code then
dy = dy - effective_glue(current,parent) * fc
elseif id == rule_code then
- local ht = getfield(current,"height")
- local dp = getfield(current,"depth")
+ local wd, ht, dp = getwhd(current)
local hd = (ht + dp) * fc
if hd ~= 0 then
- local wd = getfield(current,"width")
if wd == signal then
wd = getfield(parent,"width") * fc
else
@@ -427,9 +426,7 @@ function fonts.metapost.boxtomp(n,kind)
(getid(box) == hlist_code and horizontal or vertical)(box,list,0,0)
end
- local wd = getfield(box,"width")
- local ht = getfield(box,"height")
- local dp = getfield(box,"depth")
+ local wd, ht, dp = getwhd(box)
result[#result+1] = f_bounds(0,-dp*fc,wd*fc,ht*fc)
diff --git a/tex/context/base/mkiv/grph-rul.lua b/tex/context/base/mkiv/grph-rul.lua
index d5a7577d2..4ac73b6ae 100644
--- a/tex/context/base/mkiv/grph-rul.lua
+++ b/tex/context/base/mkiv/grph-rul.lua
@@ -15,7 +15,7 @@ local userrule = nodes.rules.userrule
local bpfactor = number.dimenfactors.bp
local pdfprint = pdf.print
-local currentattr = nodes.current_attr
+local current_attr = nodes.current_attr
local setfield = nodes.setfield
local getattribute = tex.getattribute
@@ -179,7 +179,7 @@ interfaces.implement {
local ma = getattribute(a_colormodel) or 1
local ca = getattribute(a_color)
local ta = getattribute(a_transparency)
- setfield(rule,"attr",currentattr())
+ setfield(rule,"attr",current_attr())
if t.type == "mp" then
t.ma = ma
t.ca = ca
@@ -216,7 +216,7 @@ interfaces.implement {
type = "mp",
name = t.name,
}
- setfield(rule,"attr",currentattr())
+ setfield(rule,"attr",current_attr())
context(rule)
end
}
diff --git a/tex/context/base/mkiv/lpdf-ano.lua b/tex/context/base/mkiv/lpdf-ano.lua
index 15ce2ca82..138388c7c 100644
--- a/tex/context/base/mkiv/lpdf-ano.lua
+++ b/tex/context/base/mkiv/lpdf-ano.lua
@@ -70,8 +70,7 @@ local nodepool = nodes.pool
----- pdfannotation_node = nodepool.pdfannotation
----- pdfdestination_node = nodepool.pdfdestination
------ latelua_node = nodepool.latelua
-local latelua_function_node = nodepool.lateluafunction -- still node ... todo
+local new_latelua = nodepool.latelua
local texgetcount = tex.getcount
@@ -504,7 +503,7 @@ function nodeinjections.destination(width,height,depth,names,view)
end
end
if doview then
- return latelua_function_node(function() flushdestination(width,height,depth,names,view) end)
+ return new_latelua(function() flushdestination(width,height,depth,names,view) end)
end
end
@@ -732,7 +731,7 @@ function nodeinjections.reference(width,height,depth,prerolled)
if trace_references then
report_reference("link: width %p, height %p, depth %p, prerolled %a",width,height,depth,prerolled)
end
- return latelua_function_node(function() finishreference(width,height,depth,prerolled) end)
+ return new_latelua(function() finishreference(width,height,depth,prerolled) end)
end
end
@@ -741,7 +740,7 @@ function nodeinjections.annotation(width,height,depth,prerolled,r)
if trace_references then
report_reference("special: width %p, height %p, depth %p, prerolled %a",width,height,depth,prerolled)
end
- return latelua_function_node(function() finishannotation(width,height,depth,prerolled,r or false) end)
+ return new_latelua(function() finishannotation(width,height,depth,prerolled,r or false) end)
end
end
diff --git a/tex/context/base/mkiv/math-ali.mkiv b/tex/context/base/mkiv/math-ali.mkiv
index d8693f697..49a343ba0 100644
--- a/tex/context/base/mkiv/math-ali.mkiv
+++ b/tex/context/base/mkiv/math-ali.mkiv
@@ -1551,6 +1551,35 @@
\defineinnermathhandler\v!flushright{\strc_math_box_start\plusone }{\strc_math_box_stop}
\defineinnermathhandler\v!normal {\strc_math_box_start\plustwo }{\strc_math_box_stop}
+%D Some inline math tweak.
+
+\appendtoks
+ \ifcase\mathnestinglevel\or
+ % 4=disable 6=only when no spaces
+ \mathsurroundskip\mathematicsparameter\c!textdistance\relax
+ \ifzeropt\mathsurroundskip
+ \ifdim\gluestretch\mathsurroundskip=\zeropoint
+ \ifdim\glueshrink\mathsurroundskip=\zeropoint
+ \mathsurroundmode\plussix
+ \else
+ \mathsurroundskip\zeropoint
+ \mathsurroundmode\plusfour
+ \fi
+ \else
+ \mathsurroundmode\plussix
+ \fi
+ \else
+ \mathsurroundmode\plussix
+ \fi
+ \else
+ \mathsurroundmode\plusfour
+ \mathsurroundskip\zeropoint
+ \fi
+\to \everymathematics
+
+\setupmathematics
+ [\c!textdistance=\zeropoint]
+
%D For documentation, see \type {math-mkiv.tex}.
\protect \endinput
diff --git a/tex/context/base/mkiv/math-fen.mkiv b/tex/context/base/mkiv/math-fen.mkiv
index c26827cf1..2d2a9eb46 100644
--- a/tex/context/base/mkiv/math-fen.mkiv
+++ b/tex/context/base/mkiv/math-fen.mkiv
@@ -267,40 +267,40 @@
%
% \def\math_left
% {\settrue\c_math_fenced_done
-% \edef\m_math_left{\meaning\nexttoken}%
+% \edef\m_math_left{\normalmeaning\nexttoken}%
% \csname\??mathleft\ifcsname\??mathleft\m_math_left\endcsname\m_math_left\else\s!unknown\fi\endcsname}
%
% \def\math_right
% {\settrue\c_math_fenced_done
-% \edef\m_math_right{\meaning\nexttoken}%
+% \edef\m_math_right{\normalmeaning\nexttoken}%
% \csname\??mathright\ifcsname\??mathright\m_math_right\endcsname\m_math_right\else\s!unknown\fi\endcsname}
%
% \def\math_middle
% {\settrue\c_math_fenced_done
-% \edef\m_math_middle{\meaning\nexttoken}%
+% \edef\m_math_middle{\normalmeaning\nexttoken}%
% \csname\??mathmiddle\ifcsname\??mathmiddle\m_math_middle\endcsname\m_math_middle\else\s!unknown\fi\endcsname}
%
% \unexpanded\def\lfence#1%
% {\settrue\c_math_fenced_done
% \let\nexttoken#1%
-% \edef\m_math_left{\meaning#1}%
+% \edef\m_math_left{\normalmeaning#1}%
% \csname\??mathleft\ifcsname\??mathleft\m_math_left\endcsname\m_math_left\else\s!unknown\fi\endcsname}
%
% \unexpanded\def\rfence#1%
% {\settrue\c_math_fenced_done
% \let\nexttoken#1%
-% \edef\m_math_right{\meaning#1}%
+% \edef\m_math_right{\normalmeaning#1}%
% \csname\??mathright\ifcsname\??mathright\m_math_right\endcsname\m_math_right\else\s!unknown\fi\endcsname}
%
% \unexpanded\def\mfence#1%
% {\settrue\c_math_fenced_done
% \let\nexttoken#1%
-% \edef\m_math_middle{\meaning#1}%
+% \edef\m_math_middle{\normalmeaning#1}%
% \csname\??mathmiddle\ifcsname\??mathmiddle\m_math_middle\endcsname\m_math_middle\else\s!unknown\fi\endcsname}
\unexpanded\def\installmathfencepair#1#2#3#4%
- {\expandafter\let\csname\??mathleft \meaning#1\endcsname#2%
- \expandafter\let\csname\??mathright\meaning#3\endcsname#4}
+ {\expandafter\let\csname\??mathleft \normalmeaning#1\endcsname#2%
+ \expandafter\let\csname\??mathright\normalmeaning#3\endcsname#4}
\def\math_unknown_left {\setfalse\c_math_fenced_done\ifconditional\c_math_fenced_unknown\normalleft \nexttoken\fi}
\def\math_unknown_right {\setfalse\c_math_fenced_done\ifconditional\c_math_fenced_unknown\normalright \nexttoken\fi}
@@ -312,7 +312,7 @@
\def\math_left
{\settrue\c_math_fenced_done
- \ifcsname\??mathleft\meaning\nexttoken\endcsname
+ \ifcsname\??mathleft\normalmeaning\nexttoken\endcsname
\expandafter\lastnamedcs
\else
\expandafter\math_unknown_left
@@ -320,7 +320,7 @@
\def\math_right
{\settrue\c_math_fenced_done
- \ifcsname\??mathright\meaning\nexttoken\endcsname
+ \ifcsname\??mathright\normalmeaning\nexttoken\endcsname
\expandafter\lastnamedcs
\else
\expandafter\math_unknown_right
@@ -328,7 +328,7 @@
\def\math_middle
{\settrue\c_math_fenced_done
- \ifcsname\??mathmiddle\meaning\nexttoken\endcsname
+ \ifcsname\??mathmiddle\normalmeaning\nexttoken\endcsname
\expandafter\lastnamedcs
\else
\expandafter\math_unknown_middle
@@ -337,7 +337,7 @@
\unexpanded\def\lfence#1%
{\settrue\c_math_fenced_done
\let\nexttoken#1%
- \ifcsname\??mathleft\meaning\nexttoken\endcsname
+ \ifcsname\??mathleft\normalmeaning\nexttoken\endcsname
\expandafter\lastnamedcs
\else
\expandafter\math_unknown_left
@@ -346,7 +346,7 @@
\unexpanded\def\rfence#1%
{\settrue\c_math_fenced_done
\let\nexttoken#1%
- \ifcsname\??mathright\meaning\nexttoken\endcsname
+ \ifcsname\??mathright\normalmeaning\nexttoken\endcsname
\expandafter\lastnamedcs
\else
\expandafter\math_unknown_right
@@ -355,7 +355,7 @@
\unexpanded\def\mfence#1%
{\settrue\c_math_fenced_done
\let\nexttoken#1%
- \ifcsname\??mathmiddle\meaning\nexttoken\endcsname
+ \ifcsname\??mathmiddle\normalmeaning\nexttoken\endcsname
\expandafter\lastnamedcs
\else
\expandafter\math_unknown_middle
diff --git a/tex/context/base/mkiv/math-ini.mkiv b/tex/context/base/mkiv/math-ini.mkiv
index fbaac052c..90478771e 100644
--- a/tex/context/base/mkiv/math-ini.mkiv
+++ b/tex/context/base/mkiv/math-ini.mkiv
@@ -77,6 +77,24 @@
\registerctxluafile{math-fbk}{1.001}
\registerctxluafile{math-dir}{1.001}
+%D A starter:
+%D
+%D \startbuffer
+%D \mathsurround 10pt
+%D \mathsurroundskip30pt
+%D x $x + \ruledhbox{$x$} + x$ x
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D \start \blank \getbuffer \blank \stop
+
+\newcount\mathnestinglevel
+
+\appendtoks
+ \advance\mathnestinglevel\plusone
+\to \everymathematics
+
%D A few compatibility helpers:
\def\Umathbotaccent{\Umathaccent \s!bottom }
diff --git a/tex/context/base/mkiv/mlib-int.lua b/tex/context/base/mkiv/mlib-int.lua
index 13124807d..108002929 100644
--- a/tex/context/base/mkiv/mlib-int.lua
+++ b/tex/context/base/mkiv/mlib-int.lua
@@ -68,11 +68,11 @@ function mp.NOfPages () mpprint(getcount("lastpageno"))
function mp.CurrentColumn () mpprint(getcount("mofcolumns")) end
function mp.NOfColumns () mpprint(getcount("nofcolumns")) end
-function mp.BaseLineSkip () mpprint(get ("baselineskip").width *factor) end
+function mp.BaseLineSkip () mpprint(get ("baselineskip",true) *factor) end
function mp.LineHeight () mpprint(getdimen("lineheight") *factor) end
function mp.BodyFontSize () mpprint(getdimen("bodyfontsize") *factor) end
-function mp.TopSkip () mpprint(get ("topskip").width *factor) end
+function mp.TopSkip () mpprint(get ("topskip",true) *factor) end
function mp.StrutHeight () mpprint(getdimen("strutht") *factor) end
function mp.StrutDepth () mpprint(getdimen("strutdp") *factor) end
diff --git a/tex/context/base/mkiv/mlib-pdf.mkiv b/tex/context/base/mkiv/mlib-pdf.mkiv
index 78dab716d..5875c7635 100644
--- a/tex/context/base/mkiv/mlib-pdf.mkiv
+++ b/tex/context/base/mkiv/mlib-pdf.mkiv
@@ -93,7 +93,7 @@
\def\startMPLIBtoPDF#1#2#3#4%
{\meta_process_graphic_figure_start
\dostarttagged\t!mpgraphic\empty
- \naturalhbox attr \imageattribute 1 \bgroup
+ \naturalhpack attr \imageattribute \plusone \bgroup
\dousecolorparameter\s!black\forcecolorhack
\setMPboundingbox{#1}{#2}{#3}{#4}%
\setbox\MPbox\vpack\bgroup
diff --git a/tex/context/base/mkiv/mlib-pps.lua b/tex/context/base/mkiv/mlib-pps.lua
index 945830853..d08d5ddb7 100644
--- a/tex/context/base/mkiv/mlib-pps.lua
+++ b/tex/context/base/mkiv/mlib-pps.lua
@@ -23,7 +23,7 @@ local setmacro = interfaces.setmacro
----- texgetbox = tex.getbox
local texsetbox = tex.setbox
-local textakebox = tex.takebox
+local textakebox = tex.takebox -- or: nodes.takebox
local copy_list = node.copy_list
local flush_list = node.flush_list
local setmetatableindex = table.setmetatableindex
@@ -258,10 +258,10 @@ end
local function stopjob()
if top then
- for n, tn in next, top.textexts do
- flush_list(tn)
+ for slot, content in next, top.textexts do
+ flush_list(content)
if trace_textexts then
- report_textexts("freeing text %s",n)
+ report_textexts("freeing text %s",slot)
end
end
if trace_runs then
@@ -284,12 +284,7 @@ local function settext(box,slot)
-- if trace_textexts then
-- report_textexts("getting text %s from box %s",slot,box)
-- end
- -- top.textexts[slot] = copy_list(texgetbox(box))
- -- texsetbox(box,nil)
- -- this can become
top.textexts[slot] = textakebox(box)
- else
- -- weird error
end
end
@@ -300,9 +295,6 @@ local function gettext(box,slot)
-- if trace_textexts then
-- report_textexts("putting text %s in box %s",slot,box)
-- end
- -- top.textexts[slot] = nil -- no, pictures can be placed several times
- else
- -- weird error
end
end
@@ -745,6 +737,8 @@ function metapost.graphic_base_pass(specification) -- name will change (see mlib
context(stopjob)
end
+-- we overload metapost.process here
+
function metapost.process(mpx, data, trialrun, flusher, multipass, isextrapass, askedfig, plugmode) -- overloads
startjob(plugmode)
processmetapost(mpx, data, trialrun, flusher, multipass, isextrapass, askedfig)
diff --git a/tex/context/base/mkiv/mult-prm.lua b/tex/context/base/mkiv/mult-prm.lua
index d0116d263..4f01b66b6 100644
--- a/tex/context/base/mkiv/mult-prm.lua
+++ b/tex/context/base/mkiv/mult-prm.lua
@@ -290,6 +290,7 @@ return {
"mathscriptsmode",
"mathstyle",
"mathsurroundskip",
+ "mathsurroundmode",
"mathrulesmode",
"mathrulesfam",
"noboundary",
@@ -942,6 +943,7 @@ return {
"mathscriptsmode",
"mathstyle",
"mathsurroundskip",
+ "mathsurroundmode",
"mathsurround",
"maxdeadcycles",
"maxdepth",
diff --git a/tex/context/base/mkiv/node-aux.lua b/tex/context/base/mkiv/node-aux.lua
index f965128f9..7f2360276 100644
--- a/tex/context/base/mkiv/node-aux.lua
+++ b/tex/context/base/mkiv/node-aux.lua
@@ -88,13 +88,13 @@ local report_error = logs.reporter("node-aux:error")
local function takebox(id)
local box = getbox(id)
if box then
- local copy = copy_node(box)
local list = getlist(box)
+ setlist(box,nil)
+ local copy = copy_node(box)
if list then
setlist(copy,list)
- setlist(box,nil)
end
- texsetbox(id,nil)
+ texsetbox(id,false)
return copy
end
end
diff --git a/tex/context/base/mkiv/node-bck.lua b/tex/context/base/mkiv/node-bck.lua
index 2ee08a80e..9ecc62170 100644
--- a/tex/context/base/mkiv/node-bck.lua
+++ b/tex/context/base/mkiv/node-bck.lua
@@ -33,6 +33,7 @@ local getid = nuts.getid
local getlist = nuts.getlist
local getattr = nuts.getattr
local getsubtype = nuts.getsubtype
+local getwhd = nuts.getwhd
local setfield = nuts.setfield
local setattr = nuts.setattr
@@ -64,7 +65,7 @@ local function add_backgrounds(head) -- rather old code .. to be redone
list = head
end
end
- local width = getfield(current,"width")
+ local width, height, depth = getwhd(current)
if width > 0 then
local background = getattr(current,a_background)
if background then
@@ -72,8 +73,6 @@ local function add_backgrounds(head) -- rather old code .. to be redone
-- colorspace is already set so we can omit that and stick to color
local mode = getattr(current,a_colormodel)
if mode then
- local height = getfield(current,"height")
- local depth = getfield(current,"depth")
local skip = id == hlist_code and width or (height + depth)
local glue = new_glue(-skip)
local rule = new_rule(width,height,depth)
@@ -130,12 +129,12 @@ local function add_alignbackgrounds(head)
--
if background then
-- current has subtype 5 (cell)
- local width = getfield(current,"width")
+ local width, height, depth = getwhd(current)
if width > 0 then
local mode = getattr(found,a_colormodel)
if mode then
local glue = new_glue(-width)
- local rule = new_rule(width,getfield(current,"height"),getfield(current,"depth"))
+ local rule = new_rule(width,height,depth)
local color = getattr(found,a_color)
local transparency = getattr(found,a_transparency)
setattr(rule,a_colormodel,mode)
diff --git a/tex/context/base/mkiv/node-ltp.lua b/tex/context/base/mkiv/node-ltp.lua
index de1954386..32b11267b 100644
--- a/tex/context/base/mkiv/node-ltp.lua
+++ b/tex/context/base/mkiv/node-ltp.lua
@@ -206,6 +206,8 @@ local getdisc = nuts.getdisc
local getattr = nuts.getattr
local getdisc = nuts.getdisc
local getglue = nuts.getglue
+local getwhd = nuts.getwhd
+local setwhd = nuts.setwhd
local isglyph = nuts.isglyph
@@ -734,10 +736,11 @@ local function add_to_width(line_break_dir,checked_expansion,s) -- split into tw
while s do
local char, id = isglyph(s)
if char then
+ local wd, ht, dp = getwhd(s)
if is_rotated[line_break_dir] then -- can be shared
- size = size + getfield(s,"height") + getfield(s,"depth")
+ size = size + ht + dp
else
- size = size + getfield(s,"width")
+ size = size + wd
end
if checked_expansion then
local data = checked_expansion[getfont(s)]
@@ -750,10 +753,11 @@ local function add_to_width(line_break_dir,checked_expansion,s) -- split into tw
end
end
elseif id == hlist_code or id == vlist_code then
+ local wd, ht, dp = getwhd(s)
if is_parallel[getfield(s,"dir")][line_break_dir] then
- size = size + getfield(s,"width")
+ size = size + wd
else
- size = size + getfield(s,"height") + getfield(s,"depth")
+ size = size + ht + dp
end
elseif id == kern_code then
local kern = getfield(s,"kern")
@@ -817,10 +821,11 @@ local function compute_break_width(par,break_type,p) -- split in two
if id == glyph_code then
return -- happens often
elseif id == glue_code then
- local order = stretch_orders[getfield(p,"stretch_order")]
- break_width.size = break_width.size - getfield(p,"width")
- break_width[order] = break_width[order] - getfield(p,"stretch")
- break_width.shrink = break_width.shrink - getfield(p,"shrink")
+ local wd, stretch, shrink, stretch_order = getglue(p)
+ local order = stretch_orders[stretch_order]
+ break_width.size = break_width.size - wd
+ break_width[order] = break_width[order] - stretch
+ break_width.shrink = break_width.shrink - shrink
elseif id == penalty_code then
-- do nothing
elseif id == kern_code then
@@ -832,6 +837,12 @@ local function compute_break_width(par,break_type,p) -- split in two
end
elseif id == math_code then
break_width.size = break_width.size - getfield(p,"surround")
+ -- new in luatex
+ local wd, stretch, shrink, stretch_order = getglue(p)
+ local order = stretch_orders[stretch_order]
+ break_width.size = break_width.size - wd
+ break_width[order] = break_width[order] - stretch
+ break_width.shrink = break_width.shrink - shrink
else
return
end
@@ -1085,13 +1096,17 @@ local function initialize_line_break(head,display)
local l = check_shrinkage(par,left_skip)
local r = check_shrinkage(par,right_skip)
- local l_order = stretch_orders[getfield(l,"stretch_order")]
- local r_order = stretch_orders[getfield(r,"stretch_order")]
- background.size = getfield(l,"width") + getfield(r,"width")
- background.shrink = getfield(l,"shrink") + getfield(r,"shrink")
- background[l_order] = getfield(l,"stretch")
- background[r_order] = getfield(r,"stretch") + background[r_order]
+ local lwidth, lstretch, lshrink, lstretch_order, lshrink_order = getglue(l)
+ local rwidth, rstretch, rshrink, rstretch_order, rshrink_order = getglue(r)
+
+ local l_order = stretch_orders[lstretch_order]
+ local r_order = stretch_orders[rstretch_order]
+
+ background.size = lwidth + rwidth
+ background.shrink = lshrink + rshrink
+ background[l_order] = lstretch
+ background[r_order] = rstretch + background[r_order]
-- this will move up so that we can assign the whole par table
@@ -1291,6 +1306,8 @@ local function post_line_break(par)
setfield(lastnode,"kern",0)
elseif getid(lastnode) == math_code then
setfield(lastnode,"surround",0)
+ -- new in luatex
+ setglue(lastnode) -- zeros
end
end
lastnode = inject_dirs_at_end_of_line(stack,lastnode,getnext(head),current_break.cur_break)
@@ -1457,6 +1474,8 @@ local function post_line_break(par)
elseif id == math_code then
-- keep the math node
setfield(next,"surround",0)
+ -- new in luatex
+ setglue(lastnode) -- zeros
break
elseif id == kern_code then
local subtype = getsubtype(next)
@@ -2219,10 +2238,11 @@ function constructors.methods.basic(head,d)
while current and p_active ~= n_active do
local char, id = isglyph(current)
if char then
+ local wd, ht, dp = getwhd(current)
if is_rotated[par.line_break_dir] then
- active_width.size = active_width.size + getfield(current,"height") + getfield(current,"depth")
+ active_width.size = active_width.size + ht + dp
else
- active_width.size = active_width.size + getfield(current,"width")
+ active_width.size = active_width.size + wd
end
if checked_expansion then
local currentfont = getfont(current)
@@ -2242,10 +2262,11 @@ function constructors.methods.basic(head,d)
end
end
elseif id == hlist_code or id == vlist_code then
+ local wd, ht, dp = getwhd(current)
if is_parallel[getfield(current,"dir")][par.line_break_dir] then
- active_width.size = active_width.size + getfield(current,"width")
+ active_width.size = active_width.size + wd
else
- active_width.size = active_width.size + getfield(current,"depth") + getfield(current,"height")
+ active_width.size = active_width.size + ht + dp
end
elseif id == glue_code then
-- if par.auto_breaking then
@@ -2265,10 +2286,11 @@ function constructors.methods.basic(head,d)
end
end
check_shrinkage(par,current)
- local order = stretch_orders[getfield(current,"stretch_order")]
- active_width.size = active_width.size + getfield(current,"width")
- active_width[order] = active_width[order] + getfield(current,"stretch")
- active_width.shrink = active_width.shrink + getfield(current,"shrink")
+ local width, stretch, shrink, stretch_order = getglue(current)
+ local order = stretch_orders[stretch_order]
+ active_width.size = active_width.size + width
+ active_width[order] = active_width[order] + stretch
+ active_width.shrink = active_width.shrink + shrink
elseif id == disc_code then
local subtype = getsubtype(current)
if subtype ~= second_disc_code then
@@ -2383,6 +2405,8 @@ function constructors.methods.basic(head,d)
end
local active_width = par.active_width
active_width.size = active_width.size + getfield(current,"surround")
+ -- new in luatex
+ + getfield(current,"width")
elseif id == rule_code then
active_width.size = active_width.size + getfield(current,"width")
elseif id == penalty_code then
@@ -2629,9 +2653,7 @@ end)
-- with the glyph.
local function glyph_width_height_depth(curdir,pdir,p)
- local wd = getfield(p,"width")
- local ht = getfield(p,"height")
- local dp = getfield(p,"depth")
+ local wd, ht, dp = getwhd(p)
if is_rotated[curdir] then
if is_parallel[curdir][pdir] then
local half = (ht + dp) / 2
@@ -2659,9 +2681,7 @@ local function glyph_width_height_depth(curdir,pdir,p)
end
local function pack_width_height_depth(curdir,pdir,p)
- local wd = getfield(p,"width")
- local ht = getfield(p,"height")
- local dp = getfield(p,"depth")
+ local wd, ht, dp = getwhd(p)
if is_rotated[curdir] then
if is_parallel[curdir][pdir] then
local half = (ht + dp) / 2
@@ -2913,11 +2933,10 @@ local function hpack(head,width,method,direction,firstline,line) -- fast version
end
end
elseif id == glue_code then
- natural = natural + getfield(current,"width")
- local op = getfield(current,"stretch_order")
- local om = getfield(current,"shrink_order")
- total_stretch[op] = total_stretch[op] + getfield(current,"stretch")
- total_shrink [om] = total_shrink [om] + getfield(current,"shrink")
+ local wd, stretch, shrink, stretch_order, shrink_order = getglue(current)
+ natural = natural + wd
+ total_stretch[stretch_order] = total_stretch[stretch_order] + stretch
+ total_shrink [shrink_order] = total_shrink[shrink_order] + shrink
if getsubtype(current) >= leaders_code then
local leader = getleader(current)
local ht = getfield(leader,"height")
@@ -2941,9 +2960,7 @@ local function hpack(head,width,method,direction,firstline,line) -- fast version
depth = ds
end
elseif id == rule_code then
- local wd = getfield(current,"width")
- local ht = getfield(current,"height")
- local dp = getfield(current,"depth")
+ local wd, ht, dp = getwhd(current)
natural = natural + wd
if ht > height then
height = ht
@@ -2953,6 +2970,8 @@ local function hpack(head,width,method,direction,firstline,line) -- fast version
end
elseif id == math_code then
natural = natural + getfield(current,"surround")
+ -- new in luatex
+ + getfield(current,"width")
elseif id == unset_code then
local wd = getfield(current,"width")
local ht = getfield(current,"height")
@@ -3019,9 +3038,7 @@ local function hpack(head,width,method,direction,firstline,line) -- fast version
width = width + natural
end
- setfield(hlist,"width",width)
- setfield(hlist,"height",height)
- setfield(hlist,"depth",depth)
+ setwhd(hlist,width,height,depth)
local delta = width - natural
if delta == 0 then
diff --git a/tex/context/base/mkiv/node-met.lua b/tex/context/base/mkiv/node-met.lua
index ded2280c4..ea6ce6aca 100644
--- a/tex/context/base/mkiv/node-met.lua
+++ b/tex/context/base/mkiv/node-met.lua
@@ -146,6 +146,25 @@ if not node.rangedimensions then -- LUATEXVERSION < 0.99
end
+if not node.getwhd then
+ local getfield = node.getfield
+ function node.getwhd(n)
+ return getfield(n,"width"), getfield(n,"height"), getfield(n,"depth")
+ end
+end
+
+if not node.setwhd then
+ local setfield = node.setfield
+ function node.setwhd(n,w,h,d)
+ setfield(n,"width",w or 0)
+ setfield(n,"height",h or 0)
+ setfield(n,"depth",d or 0)
+ end
+end
+
+nodes.getwhd = node.getwhd
+nodes.setwhd = node.setwhd
+
nodes.effective_glue = node.effective_glue
nodes.getglue = node.getglue
nodes.setglue = node.setglue
@@ -177,6 +196,7 @@ local n_getfield = node.getfield
local n_setattr = node.setattr
local n_getattr = node.getattr
local n_getdisc = node.getdisc
+local n_getwhd = node.getwhd
local n_getleader = node.getleader
local n_setnext = node.setnext or
@@ -227,9 +247,8 @@ nodes.ischar = node.is_char
nodes.is_glyph = node.is_glyph
nodes.isglyph = node.is_glyph
-nodes.getbox = node.getbox or tex.getbox
-nodes.setbox = node.setbox or tex.setbox
-nodes.getskip = node.getskip or tex.get
+nodes.getbox = node.getbox or tex.getbox
+nodes.setbox = node.setbox or tex.setbox
local n_flush_node = nodes.flush
local n_copy_node = nodes.copy
@@ -680,3 +699,39 @@ end
nodes.keys = keys -- [id][subtype]
nodes.fields = nodefields -- (n)
+
+-- temporary hack
+
+if LUATEXVERSION <= 1.002 then
+
+ local get = tex.get
+ local flush = node.free
+
+ function tex.get(name,split)
+ local s = get(name)
+ if split == true then
+ if s then
+ local width = s.width
+ local stretch = s.stretch
+ local shrink = s.shrink
+ local stretch_order = s.stretch_order
+ local shrink_order = s.shrink_order
+ flush(s)
+ return width, stretch, shrink, stretch_order, shrink_order
+ else
+ return 0, 0, 0, 0, 0
+ end
+ elseif split == false then
+ if s then
+ local width = s.width
+ flush(s)
+ return width
+ else
+ return 0
+ end
+ else
+ return s
+ end
+ end
+
+end
diff --git a/tex/context/base/mkiv/node-nut.lua b/tex/context/base/mkiv/node-nut.lua
index 7562e5292..cec272bcf 100644
--- a/tex/context/base/mkiv/node-nut.lua
+++ b/tex/context/base/mkiv/node-nut.lua
@@ -93,9 +93,6 @@ local direct = node.direct
local fastcopy = table.fastcopy
-local texget = tex.get
-local texgetskip = tex.getskip
-
local nodecodes = nodes.nodecodes
local hlist_code = nodecodes.hlist
local vlist_code = nodecodes.vlist
@@ -120,6 +117,25 @@ nodes.tonut = tonut
-- getters
+if not direct.getwhd then
+ local getfield = direct.getfield
+ function direct.getwhd(n)
+ return getfield(n,"width"), getfield(n,"height"), getfield(n,"depth")
+ end
+end
+
+if not direct.setwhd then
+ local setfield = direct.setfield
+ function direct.setwhd(n,w,h,d)
+ setfield(n,"width",w or 0)
+ setfield(n,"height",h or 0)
+ setfield(n,"depth",d or 0)
+ end
+end
+
+nuts.getwhd = direct.getwhd
+nuts.setwhd = direct.setwhd
+
nuts.getfield = direct.getfield
nuts.getnext = direct.getnext
nuts.getprev = direct.getprev
@@ -147,14 +163,11 @@ nuts.getleader = direct.getleader
-- setters
-nuts.setfield = direct.setfield
-nuts.setattr = direct.set_attribute or setfield
+nuts.setfield = direct.setfield
+nuts.setattr = direct.set_attribute or setfield
-nuts.getbox = direct.getbox
-nuts.setbox = direct.setbox
-nuts.getskip = function(s)
- return tonut(type(s) == "number" and texgetskip(s) or texget(s))
-end
+nuts.getbox = direct.getbox
+nuts.setbox = direct.setbox
-- helpers
@@ -253,6 +266,7 @@ nuts.setglue = setglue
nuts.is_zero_glue = is_zero_glue
nuts.getdisc = direct.getdisc
+nuts.getwhd = direct.getwhd
nuts.setdisc = direct.setdisc
nuts.setchar = direct.setchar
nuts.setnext = direct.setnext
@@ -714,42 +728,3 @@ function nuts.copy_properties(source,target,what)
end
return newprops -- for checking
end
-
--- a bit special
-
-local getwidth = { }
-local setwidth = { }
-local getdimensions = { }
-local setdimensions = { }
-
-nodes.whatsitters = {
- getters = { width = getwidth, dimensions = getdimensions },
- setters = { width = setwidth, dimensions = setdimensions },
-}
-
--- obsolete
-
--- local function get_width(n,dir)
--- n = tonut(n)
--- return getfield(n,"width")
--- end
---
--- local function get_dimensions(n,dir)
--- n = tonut(n)
--- return getfield(n,"width"), getfield(n,"height"), getfield(n,"depth")
--- end
---
--- local whatcodes = nodes.whatcodes
--- local pdfrefximage_code = whatcodes.pdfrefximage
--- local pdfrefxform_code = whatcodes.pdfrefxform
---
--- if pdfrefxform_code then
--- getwidth [pdfrefxform_code ] = get_width
--- getdimensions[pdfrefxform_code ] = get_dimensions
--- end
---
--- if pdfrefximage_code then
--- getwidth [pdfrefximage_code] = get_width
--- getdimensions[pdfrefximage_code] = get_dimensions
--- end
-
diff --git a/tex/context/base/mkiv/node-ref.lua b/tex/context/base/mkiv/node-ref.lua
index 7520b18ae..c082ac817 100644
--- a/tex/context/base/mkiv/node-ref.lua
+++ b/tex/context/base/mkiv/node-ref.lua
@@ -63,6 +63,7 @@ local setlist = nuts.setlist
local getattr = nuts.getattr
local setattr = nuts.setattr
local getsubtype = nuts.getsubtype
+local getwhd = nuts.getwhd
local hpack_list = nuts.hpack
local vpack_list = nuts.vpack
@@ -91,6 +92,7 @@ local line_code = listcodes.line
local new_rule = nodepool.rule
local new_kern = nodepool.kern
+local new_hlist = nodepool.hlist
local flush_node = nuts.flush
@@ -118,9 +120,7 @@ local function vlist_dimensions(start,stop) -- also needs the stretch and so
setnext(stop,nil)
end
local v = vpack_list(start)
- local w = getfield(v,"width")
- local h = getfield(v,"height")
- local d = getfield(v,"depth")
+ local w, h, d = getwhd(v)
setlist(v) -- not needed
flush_node(v)
if temp then
@@ -129,22 +129,21 @@ local function vlist_dimensions(start,stop) -- also needs the stretch and so
return w, h, d
end
+-- not ok when vlist at mvl level
+
local function dimensions(parent,start,stop) -- in principle we could move some to the caller
local id = getid(start)
if start == stop then
- if id == hlist_code or id == vlist_code or id == glyph_code or id == rule_code then
+ if id == hlist_code or id == vlist_code or id == rule_code or id == glyph_code then
+ local sw, sh, sd = getwhd(start)
+ local pw, ph, pd = getwhd(parent)
+ local ht = sh == 0 and ph or sh -- changed
+ local dp = sd == 0 and pd or sd -- changed
if trace_areas then
- report_area("dimensions taken of %a",nodecodes[id])
- end
- -- hm, parent can be zero
- local width = getfield(start,"width")
- local height = getfield(parent,"height")
- local depth = getfield(parent,"depth")
- if height == 0 and depth == 0 then
- height = getfield(start,"height")
- depth = getfield(start,"depth")
+ report_area("dimensions taken of %a (%p,%p,%p) with parent (%p,%p,%p) -> (%p,%p,%p)",
+ nodecodes[id],sw,sh,sd,pw,ph,pd,sw,ht,dp)
end
- return width, height, depth
+ return sw, ht, dp
else
if trace_areas then
report_area("dimensions calculated of %a",nodecodes[id])
@@ -175,7 +174,8 @@ local function dimensions(parent,start,stop) -- in principle we could move some
if trace_areas then
report_area("dimensions taken of first line in vlist")
end
- return getfield(c,"width"), getfield(c,"height"), getfield(c,"depth"), c
+ local w, h, d = getwhd(c)
+ return w, h, d, c
else
if trace_areas then
report_area("dimensions taken of vlist (probably wrong)")
@@ -220,7 +220,8 @@ local function dimensions(parent,start,stop) -- in principle we could move some
if trace_areas then
report_area("dimensions taken of first line in vlist")
end
- return getfield(first,"width"), getfield(first,"height"), getfield(first,"depth"), first
+ local w, h, d = getwhd(first)
+ return w, h, d, first
else
if trace_areas then
report_area("dimensions taken of vlist (probably wrong)")
@@ -256,35 +257,39 @@ local function inject_range(head,first,last,reference,make,stack,parent,pardir,t
-- special case, we only treat the first line in a vlist
local l = getlist(line)
if trace_areas then
- report_area("%s: %i : %s %s %s => w=%p, h=%p, d=%p, c=%S","line",
+ report_area("%s: %i : %s %s %s => w=%p, h=%p, d=%p","line",
reference,pardir or "---",txtdir or "---",
- tosequence(l,nil,true),width,height,depth,resolved)
+ tosequence(l,nil,true),width,height,depth)
end
setlist(line,result)
setlink(result,l)
return head, last
+ elseif head == first then
+ if trace_areas then
+ report_area("%s: %i : %s %s %s => w=%p, h=%p, d=%p","head",
+ reference,pardir or "---",txtdir or "---",
+ tosequence(first,last,true),width,height,depth)
+ end
+ setlink(result,first)
+ return result, last
else
- if head == first then
- if trace_areas then
- report_area("%s: %i : %s %s %s => w=%p, h=%p, d=%p, c=%S","head",
- reference,pardir or "---",txtdir or "---",
- tosequence(first,last,true),width,height,depth,resolved)
- end
- setlink(result,first)
- return result, last
- else
- if trace_areas then
- report_area("%s: %i : %s %s %s => w=%p, h=%p, d=%p, c=%S","middle",
- reference,pardir or "---",txtdir or "---",
- tosequence(first,last,true),width,height,depth,resolved)
- end
- local prev = getprev(first)
- if prev then
- setlink(prev,result)
- end
- setlink(result,first)
- return head, last
+ if trace_areas then
+ report_area("%s: %i : %s %s %s => w=%p, h=%p, d=%p","middle",
+ reference,pardir or "---",txtdir or "---",
+ tosequence(first,last,true),width,height,depth)
end
+if first == last and getid(parent) == vlist_code and getid(first) == hlist_code then
+ if trace_areas then
+ -- think of a button without \dontleavehmode in the mvl
+ report_area("compensating for link in vlist")
+ end
+ setlink(result,getlist(first))
+ setlist(first,result)
+else
+ setlink(getprev(first),result)
+ setlink(result,first)
+end
+ return head, last
end
else
return head, last
@@ -292,9 +297,7 @@ local function inject_range(head,first,last,reference,make,stack,parent,pardir,t
end
local function inject_list(id,current,reference,make,stack,pardir,txtdir)
- local width = getfield(current,"width")
- local height = getfield(current,"height")
- local depth = getfield(current,"depth")
+ local width, height, depth = getwhd(current)
local correction = 0
local moveright = false
local first = getlist(current)
@@ -342,12 +345,8 @@ local function inject_list(id,current,reference,make,stack,pardir,txtdir)
setlist(current,result)
elseif moveright then -- brr no prevs done
-- result after first
- local n = getnext(first)
- setnext(result,n)
- setlink(first,first)
- if n then
- setprev(n,result)
- end
+ setlink(result,getnext(first))
+ setlink(first,result)
else
-- first after result
setlink(result,first)
@@ -545,20 +544,16 @@ local function colorize(width,height,depth,n,reference,what,sr,offset)
setnext(kern,rule)
setprev(rule,kern)
return kern
- else
-
-if sr and sr ~= "" then
- local text = addstring(what,sr,shift)
- if text then
- local kern = new_kern(-getfield(text,"width"))
- setlink(kern,text)
- setlink(text,rule)
- return kern
- end
-end
-
- return rule
+ elseif sr and sr ~= "" then
+ local text = addstring(what,sr,shift)
+ if text then
+ local kern = new_kern(-getfield(text,"width"))
+ setlink(kern,text)
+ setlink(text,rule)
+ return kern
+ end
end
+ return rule
end
local function justadd(what,sr,shift)
@@ -642,14 +637,16 @@ local function makereference(width,height,depth,reference) -- height and depth a
end
if trace_references then
local step = 65536
- result = hpack_list(colorize(width,height-step,depth-step,2,reference,"reference",texts,show_references)) -- step subtracted so that we can see seperate links
- setfield(result,"width",0)
+-- result = hpack_list(colorize(width,height-step,depth-step,2,reference,"reference",texts,show_references)) -- step subtracted so that we can see seperate links
+-- setfield(result,"width",0)
+result = new_hlist(colorize(width,height-step,depth-step,2,reference,"reference",texts,show_references)) -- step subtracted so that we can see seperate links
current = result
elseif texts then
texts = justadd("reference",texts,show_references)
if texts then
- result = hpack_list(texts)
- setfield(result,"width",0)
+-- result = hpack_list(texts)
+-- setfield(result,"width",0)
+result = new_hlist(texts)
current = result
end
end
@@ -659,10 +656,11 @@ local function makereference(width,height,depth,reference) -- height and depth a
result = annot
end
references.registerpage(n)
- result = hpack_list(result,0)
- setfield(result,"width",0)
- setfield(result,"height",0)
- setfield(result,"depth",0)
+-- result = hpack_list(result,0)
+-- setfield(result,"width",0)
+-- setfield(result,"height",0)
+-- setfield(result,"depth",0)
+result = new_hlist(result)
if cleanupreferences then stack[reference] = nil end
return result, resolved
elseif trace_references then
@@ -759,8 +757,9 @@ local function makedestination(width,height,depth,reference)
step = 4*65536
width, height, depth = 5*step, 5*step, 0
end
- local rule = hpack_list(colorize(width,height,depth,3,reference,"destination",texts,show_destinations))
- setfield(rule,"width",0)
+-- local rule = hpack_list(colorize(width,height,depth,3,reference,"destination",texts,show_destinations))
+-- setfield(rule,"width",0)
+local rule = new_list(colorize(width,height,depth,3,reference,"destination",texts,show_destinations))
if not result then
result, current = rule, rule
else
@@ -771,11 +770,13 @@ local function makedestination(width,height,depth,reference)
elseif texts then
texts = justadd("destination",texts,show_destinations)
if texts then
- result = hpack_list(texts)
- if result then
- setfield(result,"width",0)
- current = result
- end
+-- result = hpack_list(texts)
+-- if result then
+-- setfield(result,"width",0)
+-- current = result
+-- end
+result = new_list(texts)
+current = result
end
end
nofdestinations = nofdestinations + 1
@@ -791,10 +792,11 @@ local function makedestination(width,height,depth,reference)
end
if result then
-- some internal error
- result = hpack_list(result,0)
- setfield(result,"width",0)
- setfield(result,"height",0)
- setfield(result,"depth",0)
+-- result = hpack_list(result,0)
+-- setfield(result,"width",0)
+-- setfield(result,"height",0)
+-- setfield(result,"depth",0)
+result = new_hlist(result)
end
if cleanupdestinations then stack[reference] = nil end
return result, resolved
diff --git a/tex/context/base/mkiv/node-res.lua b/tex/context/base/mkiv/node-res.lua
index 68eb92d2b..cb06ae488 100644
--- a/tex/context/base/mkiv/node-res.lua
+++ b/tex/context/base/mkiv/node-res.lua
@@ -72,10 +72,13 @@ local getbox = nuts.getbox
local getfield = nuts.getfield
local getid = nuts.getid
local getlist = nuts.getlist
+local getglue = nuts.getglue
local setfield = nuts.setfield
local setchar = nuts.setchar
local setlist = nuts.setlist
+local setwhd = nuts.setwhd
+local setglue = nuts.setglue
local copy_nut = nuts.copy
local new_nut = nuts.new
@@ -184,19 +187,6 @@ local userrule = register_nut(new_nut("rule",rulecodes.user)) setfiel
local hlist = register_nut(new_nut("hlist")) setfield(hlist,"dir","TLT")
local vlist = register_nut(new_nut("vlist")) setfield(vlist,"dir","TLT")
-function nutpool.zeroglue(n)
- if n then
- return
- getfield(n,"width") == 0 and
- getfield(n,"stretch") == 0 and
- getfield(n,"shrink") == 0 and
- getfield(n,"stretch_order") == 0 and
- getfield(n,"shrink_order") == 0
- else
- return false
- end
-end
-
function nutpool.glyph(fnt,chr)
local n = copy_nut(glyph)
if fnt then setfield(n,"font",fnt) end
@@ -250,69 +240,106 @@ function nutpool.italickern(k)
return n
end
+-- function nutpool.gluespec(width,stretch,shrink,stretch_order,shrink_order)
+-- -- maybe setglue
+-- local s = copy_nut(glue_spec)
+-- if width and width ~= 0 then
+-- setfield(s,"width",width)
+-- end
+-- if stretch and stretch ~= 0 then
+-- setfield(s,"stretch",stretch)
+-- end
+-- if shrink and shrink ~= 0 then
+-- setfield(s,"shrink",shrink)
+-- end
+-- if stretch_order and stretch_order ~= 0 then
+-- setfield(s,"stretch_order",stretch_order)
+-- end
+-- if shrink_order and shrink_order ~= 0 then
+-- setfield(s,"shrink_order",shrink_order)
+-- end
+-- return s
+-- end
+
function nutpool.gluespec(width,stretch,shrink,stretch_order,shrink_order)
-- maybe setglue
local s = copy_nut(glue_spec)
- if width and width ~= 0 then
- setfield(s,"width",width)
- end
- if stretch and stretch ~= 0 then
- setfield(s,"stretch",stretch)
- end
- if shrink and shrink ~= 0 then
- setfield(s,"shrink",shrink)
- end
- if stretch_order and stretch_order ~= 0 then
- setfield(s,"stretch_order",stretch_order)
- end
- if shrink_order and shrink_order ~= 0 then
- setfield(s,"shrink_order",shrink_order)
+ if width or stretch or shrink or stretch_order or shrink_order then
+ setglue(s,width,stretch,shrink,stretch_order,shrink_order)
end
return s
end
+-- local function someskip(skip,width,stretch,shrink,stretch_order,shrink_order)
+-- -- maybe setglue
+-- local n = copy_nut(skip)
+-- if width and width ~= 0 then
+-- setfield(n,"width",width)
+-- end
+-- if stretch and stretch ~= 0 then
+-- setfield(n,"stretch",stretch)
+-- end
+-- if shrink and shrink ~= 0 then
+-- setfield(n,"shrink",shrink)
+-- end
+-- if stretch_order and stretch_order ~= 0 then
+-- setfield(n,"stretch_order",stretch_order)
+-- end
+-- if shrink_order and shrink_order ~= 0 then
+-- setfield(n,"shrink_order",shrink_order)
+-- end
+-- return n
+-- end
+
local function someskip(skip,width,stretch,shrink,stretch_order,shrink_order)
-- maybe setglue
local n = copy_nut(skip)
- if width and width ~= 0 then
- setfield(n,"width",width)
- end
- if stretch and stretch ~= 0 then
- setfield(n,"stretch",stretch)
- end
- if shrink and shrink ~= 0 then
- setfield(n,"shrink",shrink)
- end
- if stretch_order and stretch_order ~= 0 then
- setfield(n,"stretch_order",stretch_order)
- end
- if shrink_order and shrink_order ~= 0 then
- setfield(n,"shrink_order",shrink_order)
+ if width or stretch or shrink or stretch_order or shrink_order then
+ setglue(n,width,stretch,shrink,stretch_order,shrink_order)
end
return n
end
+-- function nutpool.stretch(a,b)
+-- local n = copy_nut(glue)
+-- if b then
+-- setfield(n,"stretch",a)
+-- setfield(n,"stretch_order",b)
+-- else
+-- setfield(n,"stretch",1)
+-- setfield(n,"stretch_order",a or 1)
+-- end
+-- return n
+-- end
+
function nutpool.stretch(a,b)
+ -- width stretch shrink stretch_order shrink_order
local n = copy_nut(glue)
- if b then
- setfield(n,"stretch",a)
- setfield(n,"stretch_order",b)
- else
- setfield(n,"stretch",1)
- setfield(n,"stretch_order",a or 1)
+ if not b then
+ a, b = 1, a or 1
end
+ setglue(n,0,a,0,b,0)
return n
end
+-- function nutpool.shrink(a,b)
+-- local n = copy_nut(glue)
+-- if b then
+-- setfield(n,"shrink",a)
+-- setfield(n,"shrink_order",b)
+-- else
+-- setfield(n,"shrink",1)
+-- setfield(n,"shrink_order",a or 1)
+-- end
+-- return n
+-- end
+
function nutpool.shrink(a,b)
local n = copy_nut(glue)
- if b then
- setfield(n,"shrink",a)
- setfield(n,"shrink_order",b)
- else
- setfield(n,"shrink",1)
- setfield(n,"shrink_order",a or 1)
+ if not b then
+ a, b = 1, a or 1
end
+ setglue(n,0,0,a,0,0,b)
return n
end
@@ -320,20 +347,27 @@ function nutpool.glue(width,stretch,shrink,stretch_order,shrink_order)
return someskip(glue,width,stretch,shrink,stretch_order,shrink_order)
end
+-- function nutpool.negatedglue(glue)
+-- local n = copy_nut(glue)
+-- local width = getfield(n,"width")
+-- local stretch = getfield(n,"stretch")
+-- local shrink = getfield(n,"shrink")
+-- if width and width ~= 0 then
+-- setfield(n,"width", -width)
+-- end
+-- if stretch and stretch ~= 0 then
+-- setfield(n,"stretch",-stretch)
+-- end
+-- if shrink and shrink ~= 0 then
+-- setfield(n,"shrink", -shrink)
+-- end
+-- return n
+-- end
+
function nutpool.negatedglue(glue)
local n = copy_nut(glue)
- local width = getfield(n,"width")
- local stretch = getfield(n,"stretch")
- local shrink = getfield(n,"shrink")
- if width and width ~= 0 then
- setfield(n,"width", -width)
- end
- if stretch and stretch ~= 0 then
- setfield(n,"stretch",-stretch)
- end
- if shrink and shrink ~= 0 then
- setfield(n,"shrink", -shrink)
- end
+ local width, stretch, shrink = getglue(n)
+ setglue(n,-width,-stretch,-shrink)
return n
end
@@ -365,14 +399,8 @@ end
function nutpool.rule(width,height,depth,dir) -- w/h/d == nil will let them adapt
local n = copy_nut(rule)
- if width then -- also 0 else adapt
- setfield(n,"width",width)
- end
- if height then -- also 0 else adapt
- setfield(n,"height",height)
- end
- if depth then -- also 0 else adapt
- setfield(n,"depth",depth)
+ if width or height or depth then
+ setwhd(n,width,height,depth)
end
if dir then
setfield(n,"dir",dir)
@@ -382,14 +410,8 @@ end
function nutpool.emptyrule(width,height,depth,dir) -- w/h/d == nil will let them adapt
local n = copy_nut(emptyrule)
- if width then -- also 0 else adapt
- setfield(n,"width",width)
- end
- if height then -- also 0 else adapt
- setfield(n,"height",height)
- end
- if depth then -- also 0 else adapt
- setfield(n,"depth",depth)
+ if width or height or depth then
+ setwhd(n,width,height,depth)
end
if dir then
setfield(n,"dir",dir)
@@ -399,14 +421,8 @@ end
function nutpool.userrule(width,height,depth,dir) -- w/h/d == nil will let them adapt
local n = copy_nut(userrule)
- if width then -- also 0 else adapt
- setfield(n,"width",width)
- end
- if height then -- also 0 else adapt
- setfield(n,"height",height)
- end
- if depth then -- also 0 else adapt
- setfield(n,"depth",depth)
+ if width or height or depth then
+ setwhd(n,width,height,depth)
end
if dir then
setfield(n,"dir",dir)
@@ -420,23 +436,7 @@ function nutpool.latelua(code)
return n
end
------ latelua_node = register_node(new_node("whatsit",whatsitcodes.latelua))
-local latelua_nut = register_nut (new_nut ("whatsit",whatsitcodes.latelua))
-
--- local setfield_node = nodes.setfield
--- local setfield_nut = nuts .setfield
-
--- function nodepool.lateluafunction(f)
--- local n = copy_node(latelua_node)
--- setfield_node(n,"string",f)
--- return n
--- end
-
-function nutpool.lateluafunction(f)
- local n = copy_nut(latelua_nut)
- setfield(n,"string",f)
- return n
-end
+nutpool.lateluafunction = nutpool.latelua
function nutpool.leftmarginkern(glyph,width)
local n = copy_nut(left_margin_kern)
@@ -481,14 +481,8 @@ local function new_hlist(list,width,height,depth,shift)
if list then
setlist(n,list)
end
- if width and width ~= 0 then
- setfield(n,"width",width)
- end
- if height and height ~= 0 then
- setfield(n,"height",height)
- end
- if depth and depth ~= 0 then
- setfield(n,"depth",depth)
+ if width or height or depth then
+ setwhd(n,width,height,depth)
end
if shift and shift ~= 0 then
setfield(n,"shift",shift)
@@ -501,14 +495,8 @@ local function new_vlist(list,width,height,depth,shift)
if list then
setlist(n,list)
end
- if width and width ~= 0 then
- setfield(n,"width",width)
- end
- if height and height ~= 0 then
- setfield(n,"height",height)
- end
- if depth and depth ~= 0 then
- setfield(n,"depth",depth)
+ if width or height or depth then
+ setwhd(n,width,height,depth)
end
if shift and shift ~= 0 then
setfield(n,"shift",shift)
diff --git a/tex/context/base/mkiv/node-rul.lua b/tex/context/base/mkiv/node-rul.lua
index 76be2a5c9..97100c896 100644
--- a/tex/context/base/mkiv/node-rul.lua
+++ b/tex/context/base/mkiv/node-rul.lua
@@ -49,7 +49,7 @@ local setglue = nuts.setglue
local traverse_id = nuts.traverse_id
local list_dimensions = nuts.rangedimensions
local hpack_nodes = nuts.hpack
-local attribs = nuts.current_attr
+local current_attr = nuts.current_attr
local nodecodes = nodes.nodecodes
local rulecodes = nodes.rulecodes
@@ -139,7 +139,7 @@ local function userrule(t,noattributes)
if noattributes == false or noattributes == nil then
-- avoid fuzzy ones
else
- setfield(r,"attr",attribs())
+ setfield(r,"attr",current_attr())
end
properties[r] = t
return tonode(r)
diff --git a/tex/context/base/mkiv/node-typ.lua b/tex/context/base/mkiv/node-typ.lua
index a40b45b56..efabe657b 100644
--- a/tex/context/base/mkiv/node-typ.lua
+++ b/tex/context/base/mkiv/node-typ.lua
@@ -33,7 +33,7 @@ local new_glue = nodepool.glue
local utfvalues = utf.values
local currentfont = font.current
------ currentattr = node.current_attr
+----- current_attr = node.current_attr
local fontparameters = fonts.hashes.parameters
local function tonodes(str,fontid,spacing,templateglyph) -- quick and dirty
@@ -45,7 +45,7 @@ local function tonodes(str,fontid,spacing,templateglyph) -- quick and dirty
-- attrid = getfield(templateglyph,"attr")
else
fontid = currentfont()
- -- attrid = currentattr()
+ -- attrid = current_attr()
end
end
local fp = fontparameters[fontid]
diff --git a/tex/context/base/mkiv/pack-rul.lua b/tex/context/base/mkiv/pack-rul.lua
index eb15111b8..3279dca51 100644
--- a/tex/context/base/mkiv/pack-rul.lua
+++ b/tex/context/base/mkiv/pack-rul.lua
@@ -41,13 +41,14 @@ local getnext = nuts.getnext
local getprev = nuts.getprev
local getlist = nuts.getlist
local setlist = nuts.setlist
+local getwhd = nuts.getwhd
local getid = nuts.getid
local getsubtype = nuts.getsubtype
local getbox = nuts.getbox
local hpack = nuts.hpack
local traverse_id = nuts.traverse_id
-local node_dimensions = nuts.dimensions
+local list_dimensions = nuts.dimensions
local flush_node = nuts.flush
local checkformath = false
@@ -72,22 +73,23 @@ local function doreshapeframedbox(n)
local list = getlist(box)
if list then
local function check(n,repack)
+ local width, height, depth = getwhd(n)
if not firstheight then
- firstheight = getfield(n,"height")
+ firstheight = height
end
- lastdepth = getfield(n,"depth")
- noflines = noflines + 1
- local l = getlist(n)
+ lastdepth = depth
+ noflines = noflines + 1
+ local l = getlist(n)
if l then
if repack then
local subtype = getsubtype(n)
if subtype == box_code or subtype == line_code then
- lastlinelength = node_dimensions(l,getfield(n,"dir"))
+ lastlinelength = list_dimensions(l,getfield(n,"dir"))
else
- lastlinelength = getfield(n,"width")
+ lastlinelength = width
end
else
- lastlinelength = getfield(n,"width")
+ lastlinelength = width
end
if lastlinelength > maxwidth then
maxwidth = lastlinelength
@@ -168,11 +170,12 @@ local function doanalyzeframedbox(n)
local list = getlist(box)
if list then
local function check(n)
+ local width, height, depth = getwhd(n)
if not firstheight then
- firstheight = getfield(n,"height")
+ firstheight = height
end
- lastdepth = getfield(n,"depth")
- noflines = noflines + 1
+ lastdepth = depth
+ noflines = noflines + 1
end
for h in traverse_id(hlist_code,list) do
check(h)
@@ -210,7 +213,7 @@ local function maxboxwidth(box)
if repack then
local subtype = getsubtype(n)
if subtype == box_code or subtype == line_code then
- lastlinelength = node_dimensions(l,getfield(n,"dir"))
+ lastlinelength = list_dimensions(l,getfield(n,"dir"))
else
lastlinelength = getfield(n,"width")
end
diff --git a/tex/context/base/mkiv/page-cst.lua b/tex/context/base/mkiv/page-cst.lua
index f27c4bf31..cd3b63c5d 100644
--- a/tex/context/base/mkiv/page-cst.lua
+++ b/tex/context/base/mkiv/page-cst.lua
@@ -50,6 +50,8 @@ local setnext = nuts.setnext
local setprev = nuts.setprev
local setsubtype = nuts.setsubtype
local setbox = nuts.setbox
+local getwhd = nuts.getwhd
+local setwhd = nuts.setwhd
local getnext = nuts.getnext
local getprev = nuts.getprev
@@ -59,7 +61,6 @@ local getsubtype = nuts.getsubtype
local takebox = nuts.takebox
local takelist = nuts.takelist
local splitbox = nuts.splitbox
-local getskip = nuts.getskip
local getattribute = nuts.getattribute
local copylist = nuts.copy_list
@@ -338,7 +339,7 @@ function columnsets.prepareflush(name)
end
local v = new_vlist(column[1])
setfield(v,"height",height)
--- setfield(v,"depth",linedepth)
+ -- setfield(v,"depth",linedepth)
setfield(v,"width",widths[c])
columns[c] = v
end
@@ -621,8 +622,9 @@ function columnsets.check(t)
if boxwidth > 0 and boxheight > 0 then
-- we're ok
elseif box then
- boxwidth = getfield(box,"width")
- boxheight = getfield(box,"height") + getfield(box,"depth")
+ local wd, ht, dp = getwhd(box)
+ boxwidth = wd
+ boxheight = ht + dp
else
report("empty box")
return
@@ -709,9 +711,7 @@ function columnsets.put(t)
end
end
cells[c][r] = box
- setfield(box,"height",lineheight)
- setfield(box,"depth",linedepth)
- setfield(box,"width",widths[c])
+ setwhd(box,widths[c],lineheight,linedepth)
dataset.reserved_c = false
dataset.reserved_r = false
dataset.reserved_nc = false
@@ -803,7 +803,8 @@ local function checkroom(head,available,row)
while head do
local id = getid(head)
if id == hlist_code or id == vlist_code or id == rule_code then -- <= rule_code
- used = used + getfield(head,"height") + getfield(head,"depth")
+ local wd, ht, dp = getwhd(head)
+ used = used + ht + dp
line = true
if used > available then
break
@@ -989,9 +990,7 @@ function columnsets.add(name,box)
-- getmetatable(v).columngap = nofcolumngaps
properties[v] = { columngap = nofcolumngaps }
-- report("setting gap %a at (%i,%i)",nofcolumngaps,foundc,foundr)
- setfield(v,"height",lineheight)
- setfield(v,"depth",linedepth)
- setfield(v,"width",widths[currentcolumn])
+ setwhd(v,widths[currentcolumn],lineheight,linedepth)
local column = cells[foundc]
--
column[foundr] = v
diff --git a/tex/context/base/mkiv/page-mix.lua b/tex/context/base/mkiv/page-mix.lua
index b5e97da4d..6bbc434dd 100644
--- a/tex/context/base/mkiv/page-mix.lua
+++ b/tex/context/base/mkiv/page-mix.lua
@@ -61,10 +61,12 @@ local getid = nuts.getid
local getlist = nuts.getlist
local getsubtype = nuts.getsubtype
local getbox = nuts.getbox
-local getskip = nuts.getskip
local getattribute = nuts.getattribute
+local getwhd = nuts.getwhd
+local setwhd = nuts.setwhd
local texgetcount = tex.getcount
+local texgetglue = tex.getglue
local theprop = nuts.theprop
@@ -108,15 +110,15 @@ local forcedbreak = -123
local function collectinserts(result,nxt,nxtid)
local inserts, currentskips, nextskips, inserttotal = { }, 0, 0, 0
-local i = result.i
-if not i then
- i = 0
- result.i = i
-end
+ local i = result.i
+ if not i then
+ i = 0
+ result.i = i
+ end
while nxt do
if nxtid == insert_code then
i = i + 1
-result.i = i
+ result.i = i
inserttotal = inserttotal + getfield(nxt,"height") -- height includes depth
local s = getsubtype(nxt)
local c = inserts[s]
@@ -124,11 +126,9 @@ result.i = i
report_state("insert of class %s found",s)
end
if not c then
-local skip = structures.notes.check_spacing(s,i) -- before
-local width = getfield(getskip(skip),"width")
+ local width = structures.notes.check_spacing(s,i) -- before
c = { }
inserts[s] = c
--- local width = getfield(getskip(s),"width")
if not result.inserts[s] then
currentskips = currentskips + width
end
@@ -256,7 +256,7 @@ local function preparesplit(specification) -- a rather large function
slidenodes(head) -- we can have set prev's to nil to prevent backtracking
local discarded = { }
local originalhead = head
- local originalwidth = specification.originalwidth or getfield(list,"width")
+ local originalwidth = specification.originalwidth or getfield(list,"width")
local originalheight = specification.originalheight or getfield(list,"height")
local current = head
local skipped = 0
@@ -620,7 +620,8 @@ local function preparesplit(specification) -- a rather large function
local nxtid = nxt and getid(nxt)
line = line + 1
local inserts, insertskips, nextskips, inserttotal = nil, 0, 0, 0
- local advance = getfield(current,"height")
+ local wd, ht, dp = getwhd(current)
+ local advance = ht
local more = nxt and (nxtid == insert_code or nxtid == mark_code)
if trace_state then
report_state("%-8s > column %s, content: %s","line (1)",column,listtoutf(getlist(current),true,true))
@@ -661,7 +662,7 @@ local function preparesplit(specification) -- a rather large function
else
height = height + insertskips
end
- depth = getfield(current,"depth")
+ depth = dp
skip = 0
if inserts then
-- so we already collect them ... makes backtracking tricky ... alternatively
@@ -783,11 +784,9 @@ local function finalize(result)
local h = new_hlist()
t[i] = h
setlist(h,getfield(l,"head"))
- local ht = getfield(l,"height")
- local dp = getfield(l,"depth")
+ local wd, ht, dp = getwhd(l)
-- here ht is still ht + dp !
- setfield(h,"height",ht)
- setfield(h,"depth",dp)
+ setwhd(h,getfield(h,"width"),ht,dp)
setfield(l,"head",nil)
end
setprev(t[1]) -- needs checking
diff --git a/tex/context/base/mkiv/page-set.mkiv b/tex/context/base/mkiv/page-set.mkiv
index 6e6759208..2cea31e1c 100644
--- a/tex/context/base/mkiv/page-set.mkiv
+++ b/tex/context/base/mkiv/page-set.mkiv
@@ -1515,7 +1515,7 @@
\def\doOTRSETgotoCOLROW#1% <number>|<number>*<number>
{\bgroup % really needed
- \splitstring#1\at*\to\column\and\row
+ \splitatasterisk{#1}\column\row
\bgroup
\ifx\column\empty\else\expanded{\doOTRSETgotoCOLUMN{\column}}\fi
\egroup
diff --git a/tex/context/base/mkiv/page-txt.mkvi b/tex/context/base/mkiv/page-txt.mkvi
index 7d0883a3c..ba5107885 100644
--- a/tex/context/base/mkiv/page-txt.mkvi
+++ b/tex/context/base/mkiv/page-txt.mkvi
@@ -900,16 +900,16 @@
%D mess.
\def\settextpagecontent#1#2#3% #2 and #3 will disappear / is overloaded
- {\setbox#1\hbox to \makeupwidth % maybe \hpack
+ {\setbox#1\hpack to \makeupwidth
{\hss % so don't change this
\setlayoutcomponentattribute{\v!page:\v!text}%
- \vbox \layoutcomponentboxattribute to \textheight
+ \vpack \layoutcomponentboxattribute to \textheight
{\offinterlineskip
\freezetextwidth
\hsize\textwidth % local variant of \sethsize <<< in columns?
\boxmaxdepth\maxdepth
\noindent % content can be < \hsize
- \page_otr_command_package_contents#2#3}%
+ \page_otr_command_package_contents#2#3}% this will vbox
\hss}%
\dp#1\zeropoint}
diff --git a/tex/context/base/mkiv/scrn-ini.mkvi b/tex/context/base/mkiv/scrn-ini.mkvi
index 7111e837f..93dde6962 100644
--- a/tex/context/base/mkiv/scrn-ini.mkvi
+++ b/tex/context/base/mkiv/scrn-ini.mkvi
@@ -235,7 +235,7 @@
\appendtoks % not interfaced i.e. english
\scrn_identity_document {title}\c!title
- \scrn_identity_document {subject}\c!subject
+ \scrn_identity_document {subject}\c!subtitle
\scrn_identity_document{subtitle}\c!subtitle
\scrn_identity_document {author}\c!author
\scrn_identity_document {authors}\c!author
diff --git a/tex/context/base/mkiv/spac-grd.mkiv b/tex/context/base/mkiv/spac-grd.mkiv
index be3c947eb..4864cd646 100644
--- a/tex/context/base/mkiv/spac-grd.mkiv
+++ b/tex/context/base/mkiv/spac-grd.mkiv
@@ -150,7 +150,7 @@
\dp\scratchbox\strutdp
\nointerlineskip
\forgetall
- \ruledvbox{\box\scratchbox}%
+ \ruledvpack{\box\scratchbox}%
\egroup
\prevdepth\strutdp}%
\def\dotopbaselinecorrection
diff --git a/tex/context/base/mkiv/spac-hor.mkiv b/tex/context/base/mkiv/spac-hor.mkiv
index e05e0ef75..405abcb5d 100644
--- a/tex/context/base/mkiv/spac-hor.mkiv
+++ b/tex/context/base/mkiv/spac-hor.mkiv
@@ -1123,7 +1123,7 @@
{\futurelet\nexttoken\spac_spaces_auto_insert_next}
\def\spac_spaces_auto_insert_next
- {\clf_autonextspace{\meaning\nexttoken}} % todo, just consult nexttoken at the lua end
+ {\clf_autonextspace{\normalmeaning\nexttoken}} % todo, just consult nexttoken at the lua end
%D Moved from bib module:
diff --git a/tex/context/base/mkiv/spac-prf.lua b/tex/context/base/mkiv/spac-prf.lua
index d2fc5860d..f89d836d8 100644
--- a/tex/context/base/mkiv/spac-prf.lua
+++ b/tex/context/base/mkiv/spac-prf.lua
@@ -50,11 +50,13 @@ local getprev = nuts.getprev
local getsubtype = nuts.getsubtype
local getlist = nuts.getlist
local gettexbox = nuts.getbox
+local getwhd = nuts.getwhd
local setfield = nuts.setfield
local setlink = nuts.setlink
local setlist = nuts.setlist
local setattr = nuts.setattr
+local setwhd = nuts.setwhd
local properties = nodes.properties.data
local setprop = nuts.setprop
@@ -161,9 +163,7 @@ local function getprofile(line,step)
while current do
local id = getid(current)
if id == glyph_code then
- wd = getfield(current,"width")
- ht = getfield(current,"height")
- dp = getfield(current,"depth")
+ wd, ht, dp = getwhd(current)
progress()
elseif id == kern_code then
wd = getfield(current,"kern")
@@ -198,30 +198,28 @@ local function getprofile(line,step)
elseif id == hlist_code then
-- we could do a nested check .. but then we need to push / pop glue
local shift = getfield(current,"shift")
- wd = getfield(current,"width")
+ local w, h, d = getwhd(current)
-- if getattr(current,a_specialcontent) then
if getprop(current,"specialcontent") then
-- like a margin note, maybe check for wd
+ wd = w
ht = 0
dp = 0
else
- ht = getfield(current,"height") - shift
- dp = getfield(current,"depth") + shift
+ wd = w
+ ht = h - shift
+ dp = d + shift
end
progress()
elseif id == vlist_code or id == unset_code then
local shift = getfield(current,"shift") -- todo
- wd = getfield(current,"width")
- ht = getfield(current,"height") -- - shift
- dp = getfield(current,"depth") -- + shift
+ wd, ht, dp = getwhd(current)
progress()
elseif id == rule_code then
- wd = getfield(current,"width")
- ht = getfield(current,"height")
- dp = getfield(current,"depth")
+ wd, ht, dp = getwhd(current)
progress()
elseif id == math_code then
- wd = getfield(current,"surround")
+ wd = getfield(current,"surround") + getfield(current,"width")
ht = 0
dp = 0
progress()
@@ -305,9 +303,7 @@ local function addstring(height,depth)
dptext
)
)
- setfield(text,"height",0)
- setfield(text,"depth",0)
- setfield(text,"width",0)
+ setwhd(text,0,0,0)
return text
end
@@ -384,9 +380,7 @@ local function addprofile(node,profile,step)
local rule = hpack_nodes(head)
- setfield(rule,"width", 0)
- setfield(rule,"height",0)
- setfield(rule,"depth", 0)
+ setwhd(rule,0,0,0)
-- if texttoo then
--
diff --git a/tex/context/base/mkiv/spac-ver.lua b/tex/context/base/mkiv/spac-ver.lua
index 29eabb64f..37f99e760 100644
--- a/tex/context/base/mkiv/spac-ver.lua
+++ b/tex/context/base/mkiv/spac-ver.lua
@@ -49,7 +49,10 @@ local context = context
local tex = tex
local texlists = tex.lists
+local texget = tex.get
+local texgetcount = tex.getcount
local texgetdimen = tex.getdimen
+local texset = tex.set
local texsetdimen = tex.setdimen
local texnest = tex.nest
@@ -59,6 +62,8 @@ local implement = interfaces.implement
local v_local = variables["local"]
local v_global = variables["global"]
local v_box = variables.box
+local v_page = variables.page -- reserved for future use
+local v_split = variables.split
local v_min = variables.min
local v_max = variables.max
local v_none = variables.none
@@ -66,6 +71,9 @@ local v_line = variables.line
local v_noheight = variables.noheight
local v_nodepth = variables.nodepth
local v_line = variables.line
+local v_halfline = variables.halfline
+local v_line_m = "-" .. variables.line
+local v_halfline_m = "-" .. variables.halfline
local v_first = variables.first
local v_last = variables.last
local v_top = variables.top
@@ -122,6 +130,12 @@ local getattr = nuts.getattr
local setattr = nuts.setattr
local getsubtype = nuts.getsubtype
local getbox = nuts.getbox
+local getwhd = nuts.getwhd
+local setwhd = nuts.setwhd
+local getprop = nuts.getprop
+local setprop = nuts.setprop
+local getglue = nuts.getglue
+local setglue = nuts.setglue
local find_node_tail = nuts.tail
local flush_node = nuts.flush_node
@@ -297,28 +311,32 @@ local function validvbox(parentid,list)
end
end
+-- we can use a property
+
local function already_done(parentid,list,a_snapmethod) -- todo: done when only boxes and all snapped
-- problem: any snapped vbox ends up in a line
if list and parentid == hlist_code then
local id = getid(list)
if id == localpar_code then -- check for initial par subtype
list = getnext(list)
- if not next then
+ if not list then
return false
end
end
---~ local i = 0
for n in traverse_nodes(list) do
local id = getid(n)
---~ i = i + 1 print(i,nodecodes[id],getattr(n,a_snapmethod))
if id == hlist_code or id == vlist_code then
- local a = getattr(n,a_snapmethod)
- if not a then
- -- return true -- not snapped at all
- elseif a == 0 then
- return true -- already snapped
- end
- elseif id == glue_code or id == penalty_code then
+-- local a = getattr(n,a_snapmethod)
+-- if not a then
+-- -- return true -- not snapped at all
+-- elseif a == 0 then
+-- return true -- already snapped
+-- end
+local p = getprop(n,"snapper")
+if p then
+ return p
+end
+ elseif id == glue_code or id == penalty_code then -- or id == kern_code then
-- go on
else
return false -- whatever
@@ -328,7 +346,6 @@ local function already_done(parentid,list,a_snapmethod) -- todo: done when only
return false
end
-
-- quite tricky: ceil(-something) => -0
local function ceiled(n)
@@ -362,7 +379,6 @@ local function snap_hlist(where,current,method,height,depth) -- method[v_strut]
local t = trace_vsnapping and { }
if t then
t[#t+1] = formatters["list content: %s"](listtoutf(list))
- t[#t+1] = formatters["parent id: %s"](nodereference(current))
t[#t+1] = formatters["snap method: %s"](method.name) -- not interfaced
t[#t+1] = formatters["specification: %s"](method.specification) -- not interfaced
end
@@ -395,8 +411,10 @@ local function snap_hlist(where,current,method,height,depth) -- method[v_strut]
end
end
- local h = (method[v_noheight] and 0) or height or getfield(current,"height")
- local d = (method[v_nodepth] and 0) or depth or getfield(current,"depth")
+ local wd, ht, dp = getwhd(current)
+
+ local h = (method[v_noheight] and 0) or height or ht
+ local d = (method[v_nodepth] and 0) or depth or dp
local hr = method[v_hfraction] or 1
local dr = method[v_dfraction] or 1
local br = method[v_bfraction] or 0
@@ -408,18 +426,12 @@ local function snap_hlist(where,current,method,height,depth) -- method[v_strut]
local plusht = snapht
local plusdp = snapdp
local snaphtdp = snapht + snapdp
+ local extra = 0
--- local properties = theprop(current)
--- local unsnapped = properties.unsnapped
--- if not unsnapped then -- experiment
--- properties.unsnapped = {
--- height = h,
--- depth = d,
--- snapht = snapht,
--- snapdp = snapdp,
--- }
--- end
-
+ if t then
+ t[#t+1] = formatters["hlist: wd %p ht %p (used %p) dp %p (used %p)"](wd,ht,h,dp,d)
+ t[#t+1] = formatters["fractions: hfraction %s dfraction %s bfraction %s tlines %s blines %s"](hr,dr,br,tlines,blines)
+ end
if method[v_box] then
local br = 1 - br
if br < 0 then
@@ -447,21 +459,40 @@ local function snap_hlist(where,current,method,height,depth) -- method[v_strut]
t[#t+1] = "none: plusht 0pt plusdp 0pt"
end
end
+ -- for now, we actually need to tag a box and then check at several points if something ended up
+ -- at the top of a page
if method[v_halfline] then -- extra halfline
- plusht = plusht + snaphtdp/2
- plusdp = plusdp + snaphtdp/2
+ extra = snaphtdp/2
+ plusht = plusht + extra
+ plusdp = plusdp + extra
if t then
t[#t+1] = formatters["halfline: plusht %p plusdp %p"](plusht,plusdp)
end
end
if method[v_line] then -- extra line
- plusht = plusht + snaphtdp
- plusdp = plusdp + snaphtdp
+ extra = snaphtdp
+ plusht = plusht + extra
+ plusdp = plusdp + extra
if t then
t[#t+1] = formatters["line: plusht %p plusdp %p"](plusht,plusdp)
end
end
-
+ if method[v_halfline_m] then -- extra halfline
+ extra = - snaphtdp/2
+ plusht = plusht + extra
+ plusdp = plusdp + extra
+ if t then
+ t[#t+1] = formatters["-halfline: plusht %p plusdp %p"](plusht,plusdp)
+ end
+ end
+ if method[v_line_m] then -- extra line
+ extra = - snaphtdp
+ plusht = plusht + extra
+ plusdp = plusdp + extra
+ if t then
+ t[#t+1] = formatters["-line: plusht %p plusdp %p"](plusht,plusdp)
+ end
+ end
if method[v_first] then
local thebox = current
local id = getid(thebox)
@@ -471,15 +502,13 @@ local function snap_hlist(where,current,method,height,depth) -- method[v_strut]
end
if thebox and id == vlist_code then
local list = getlist(thebox)
- local lh, ld
+ local lw, lh, ld
for n in traverse_nodes_id(hlist_code,list) do
- lh = getfield(n,"height")
- ld = getfield(n,"depth")
+ lw, lh, ld = getwhd(n)
break
end
if lh then
- local ht = getfield(thebox,"height")
- local dp = getfield(thebox,"depth")
+ local wd, ht, dp = getwhd(thebox)
if t then
t[#t+1] = formatters["first line: height %p depth %p"](lh,ld)
t[#t+1] = formatters["dimensions: height %p depth %p"](ht,dp)
@@ -509,14 +538,12 @@ local function snap_hlist(where,current,method,height,depth) -- method[v_strut]
end
if thebox and id == vlist_code then
local list = getlist(thebox)
- local lh, ld
+ local lw, lh, ld
for n in traverse_nodes_id(hlist_code,list) do
- lh = getfield(n,"height")
- ld = getfield(n,"depth")
+ lw, lh, ld = getwhd(n)
end
if lh then
- local ht = getfield(thebox,"height")
- local dp = getfield(thebox,"depth")
+ local wd, ht, dp = getwhd(thebox)
if t then
t[#t+1] = formatters["last line: height %p depth %p" ](lh,ld)
t[#t+1] = formatters["dimensions: height %p depth %p"](ht,dp)
@@ -587,13 +614,15 @@ local function snap_hlist(where,current,method,height,depth) -- method[v_strut]
if offset then
-- we need to set the attr
if t then
- t[#t+1] = formatters["before offset: %p (width %p height %p depth %p)"](offset,getfield(current,"width") or 0,getfield(current,"height"),getfield(current,"depth"))
+ local wd, ht, dp = getwhd(current)
+ t[#t+1] = formatters["before offset: %p (width %p height %p depth %p)"](offset,wd,ht,dp)
end
local shifted = hpack_node(getlist(current))
setfield(shifted,"shift",offset)
setlist(current,shifted)
if t then
- t[#t+1] = formatters["after offset: %p (width %p height %p depth %p)"](offset,getfield(current,"width") or 0,getfield(current,"height"),getfield(current,"depth"))
+ local wd, ht, dp = getwhd(current)
+ t[#t+1] = formatters["after offset: %p (width %p height %p depth %p)"](offset,wd,ht,dp)
end
setattr(shifted,a_snapmethod,0)
setattr(current,a_snapmethod,0)
@@ -627,7 +656,11 @@ local function snap_hlist(where,current,method,height,depth) -- method[v_strut]
if t then
report_snapper("trace: %s type %s\n\t%\n\tt",where,nodecodes[getid(current)],t)
end
- return h, d, ch, cd, lines
+ if not method[v_split] then
+ -- so extra will not be compensated at the top of a page
+ extra = 0
+ end
+ return h, d, ch, cd, lines, extra
end
local function snap_topskip(current,method)
@@ -718,112 +751,6 @@ do -- todo: interface.variables and properties
local ctx_stopblankhandling = context.stopblankhandling
local ctx_poplogger = context.poplogger
- --
-
- -- local function analyze(str,oldcategory) -- we could use shorter names
- -- for s in gmatch(str,"([^ ,]+)") do
- -- local amount, keyword, detail = lpegmatch(splitter,s) -- the comma splitter can be merged
- -- if not keyword then
- -- report_vspacing("unknown directive %a",s)
- -- else
- -- local mk = map[keyword]
- -- if mk then
- -- category = analyze(mk,category) -- category not used .. and we pass crap anyway
- -- elseif keyword == k_fixed then
- -- ctx_fixedblankskip()
- -- elseif keyword == k_flexible then
- -- ctx_flexibleblankskip()
- -- elseif keyword == k_category then
- -- local category = tonumber(detail)
- -- if category then
- -- ctx_setblankcategory(category)
- -- if category ~= oldcategory then
- -- ctx_flushblankhandling()
- -- oldcategory = category
- -- end
- -- end
- -- elseif keyword == k_order and detail then
- -- local order = tonumber(detail)
- -- if order then
- -- ctx_setblankorder(order)
- -- end
- -- elseif keyword == k_penalty and detail then
- -- local penalty = tonumber(detail)
- -- if penalty then
- -- ctx_setblankpenalty(penalty)
- -- end
- -- else
- -- amount = tonumber(amount) or 1
- -- local sk = skip[keyword]
- -- if sk then
- -- ctx_addpredefinedblankskip(amount,keyword)
- -- else -- no check
- -- ctx_addaskedblankskip(amount,keyword)
- -- end
- -- end
- -- end
- -- end
- -- return category
- -- end
-
- -- local function analyze(str) -- we could use shorter names
- -- for s in gmatch(str,"([^ ,]+)") do
- -- local amount, keyword, detail = lpegmatch(splitter,s) -- the comma splitter can be merged
- -- if not keyword then
- -- report_vspacing("unknown directive %a",s)
- -- else
- -- local mk = map[keyword]
- -- if mk then
- -- analyze(mk) -- category not used .. and we pass crap anyway
- -- elseif keyword == k_fixed then
- -- ctx_fixedblankskip()
- -- elseif keyword == k_flexible then
- -- ctx_flexibleblankskip()
- -- elseif keyword == k_category then
- -- local category = tonumber(detail)
- -- if category then
- -- ctx_setblankcategory(category)
- -- ctx_flushblankhandling()
- -- end
- -- elseif keyword == k_order and detail then
- -- local order = tonumber(detail)
- -- if order then
- -- ctx_setblankorder(order)
- -- end
- -- elseif keyword == k_penalty and detail then
- -- local penalty = tonumber(detail)
- -- if penalty then
- -- ctx_setblankpenalty(penalty)
- -- end
- -- else
- -- amount = tonumber(amount) or 1
- -- local sk = skip[keyword]
- -- if sk then
- -- ctx_addpredefinedblankskip(amount,keyword)
- -- else -- no check
- -- ctx_addaskedblankskip(amount,keyword)
- -- end
- -- end
- -- end
- -- end
- -- end
-
- -- function vspacing.analyze(str)
- -- if trace_vspacing then
- -- ctx_pushlogger(report_vspacing)
- -- ctx_startblankhandling()
- -- analyze(str,1)
- -- ctx_stopblankhandling()
- -- ctx_poplogger()
- -- else
- -- ctx_startblankhandling()
- -- analyze(str,1)
- -- ctx_stopblankhandling()
- -- end
- -- end
-
- -- alternative
-
local pattern = nil
local function handler(amount, keyword, detail)
@@ -987,8 +914,7 @@ function vspacing.snapbox(n,how)
-- report_snapper("box list not snapped, already done")
end
else
- local ht = getfield(box,"height")
- local dp = getfield(box,"depth")
+ local wd, ht, dp = getwhd(box)
if false then -- todo: already_done
-- assume that the box is already snapped
if trace_vsnapping then
@@ -996,9 +922,16 @@ function vspacing.snapbox(n,how)
ht,dp,listtoutf(list))
end
else
- local h, d, ch, cd, lines = snap_hlist("box",box,sv,ht,dp)
- setfield(box,"height",ch)
- setfield(box,"depth",cd)
+ local h, d, ch, cd, lines, extra = snap_hlist("box",box,sv,ht,dp)
+setprop(box,"snapper",{
+ ht = h,
+ dp = d,
+ ch = ch,
+ cd = cd,
+ extra = extra,
+ current = current,
+})
+ setwhd(box,wd,ch,cd)
if trace_vsnapping then
report_snapper("box list snapped from (%p,%p) to (%p,%p) using method %a (%s) for %a (%s lines): %s",
h,d,ch,cd,sv.name,sv.specification,"direct",lines,listtoutf(list))
@@ -1163,9 +1096,8 @@ local function check_experimental_overlay(head,current)
local c = current
local n = nil
local function overlay(p,n,mvl)
- local p_ht = getfield(p,"height")
- local p_dp = getfield(p,"depth")
- local n_ht = getfield(n,"height")
+ local p_wd, p_ht, p_dp = getwhd(p)
+ local n_wd, n_ht, n_dp = getwhd(n)
local skips = 0
--
-- We deal with this at the tex end .. we don't see spacing .. enabling this code
@@ -1278,6 +1210,7 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
local glue_order, glue_data, force_glue = 0, nil, false
local penalty_order, penalty_data, natural_penalty, special_penalty = 0, nil, nil, nil
local parskip, ignore_parskip, ignore_following, ignore_whitespace, keep_together = nil, false, false, false, false
+ local lastsnap = nil
--
-- todo: keep_together: between headers
--
@@ -1288,12 +1221,78 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
if not pagehead then
pagehead = texlists.page_head
if pagehead then
- pagehead = tonut(texlists.page_head)
+ pagehead = tonut(pagehead)
pagetail = find_node_tail(pagehead) -- no texlists.page_tail yet-- no texlists.page_tail yet
end
end
end
--
+ local function compensate(n)
+ local g = 0
+ while n and getid(n) == glue_code do
+ g = g + getfield(n,"width")
+ n = getnext(n)
+ end
+ if n then
+ local p = getprop(n,"snapper")
+ if p then
+ local extra = p.extra
+ if extra < 0 then
+ local h = p.ch -- getfield(n,"height")
+ -- maybe an extra check
+ -- if h - extra < g then
+ setfield(n,"height",h-2*extra)
+ p.extra = 0
+ if trace_vsnapping then
+ report_snapper("removed extra space at top: %p",extra)
+ end
+ -- end
+ end
+ end
+ return n
+ end
+ end
+ --
+ local function removetopsnap()
+ getpagelist()
+ if pagehead then
+ local n = pagehead and compensate(pagehead)
+ if n and n ~= pagetail then
+ local p = getprop(pagetail,"snapper")
+ if p then
+ local e = p.extra
+ if e < 0 then
+ local t = texget("pagetotal")
+ if t > 0 then
+ local g = texget("pagegoal") -- 1073741823 is signal
+ local d = g - t
+ if d < -e then
+ local penalty = new_penalty(1000000)
+ setlink(penalty,head)
+ head = penalty
+ report_snapper("force pagebreak due to extra space at bottom: %p",e)
+ end
+ end
+ end
+ end
+ end
+ elseif head then
+ compensate(head)
+ end
+ end
+ --
+ local function getavailable()
+ getpagelist()
+ if pagehead then
+ local t = texget("pagetotal")
+ if t > 0 then
+ local g = texget("pagegoal")
+ return g - t
+ end
+ end
+ return false
+ end
+ --
local function flush(why)
if penalty_data then
local p = new_penalty(penalty_data)
@@ -1356,45 +1355,26 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
parskip, ignore_parskip, ignore_following, ignore_whitespace = nil, false, false, false
end
--
-
--- quick hack, can be done nicer
--- local nobreakfound = nil
--- local function checknobreak()
--- local pagehead, pagetail = getpagelist()
--- local current = pagetail
--- while current do
--- local id = getid(current)
--- if id == hlist_code or id == vlist_code then
--- return false
--- elseif id == penalty_code then
--- return getfield(current,"penalty") >= 10000
--- end
--- current = getprev(current)
--- end
--- return false
--- end
-
- --
if trace_vsnapping then
report_snapper("global ht/dp = %p/%p, local ht/dp = %p/%p",
- texgetdimen("globalbodyfontstrutheight"), texgetdimen("globalbodyfontstrutdepth"),
- texgetdimen("bodyfontstrutheight"), texgetdimen("bodyfontstrutdepth")
+ texgetdimen("globalbodyfontstrutheight"),
+ texgetdimen("globalbodyfontstrutdepth"),
+ texgetdimen("bodyfontstrutheight"),
+ texgetdimen("bodyfontstrutdepth")
)
end
if trace then
trace_info("start analyzing",where,what)
end
-
--- local headprev = getprev(head)
-
+ if snap and where == "page" then
+ removetopsnap()
+ end
while current do
local id = getid(current)
if id == hlist_code or id == vlist_code then
--- if nobreakfound == nil then
--- nobreakfound = false
--- end
-- needs checking, why so many calls
if snap then
+ lastsnap = nil
local list = getlist(current)
local s = getattr(current,a_snapmethod)
if not s then
@@ -1409,15 +1389,25 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
local sv = snapmethods[s]
if sv then
-- check if already snapped
- if list and already_done(id,list,a_snapmethod) then
+ local done = list and already_done(id,list,a_snapmethod)
+ if done then
-- assume that the box is already snapped
if trace_vsnapping then
- local h = getfield(current,"height")
- local d = getfield(current,"depth")
+ local w, h, d = getwhd(current)
report_snapper("mvl list already snapped at (%p,%p): %s",h,d,listtoutf(list))
end
else
- local h, d, ch, cd, lines = snap_hlist("mvl",current,sv)
+ local h, d, ch, cd, lines, extra = snap_hlist("mvl",current,sv,false,false)
+lastsnap = {
+ ht = h,
+ dp = d,
+ ch = ch,
+ cd = cd,
+ extra = extra,
+ current = current,
+}
+setprop(current,"snapper",lastsnap)
+
if trace_vsnapping then
report_snapper("mvl %a snapped from (%p,%p) to (%p,%p) using method %a (%s) for %a (%s lines): %s",
nodecodes[id],h,d,ch,cd,sv.name,sv.specification,where,lines,listtoutf(list))
@@ -1440,17 +1430,6 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
-- trace_done("removed penalty",current)
-- end
-- head, current = remove_node(head, current, true)
-
--- if nobreakfound == nil then
--- nobreakfound = checknobreak()
--- end
--- if nobreakfound and getfield(current,"penalty") <= 10000 then
--- -- if trace then
--- trace_done("removed penalty",current)
--- -- end
--- head, current = remove_node(head, current, true)
--- end
-
current = getnext(current)
elseif id == kern_code then
if snap and trace_vsnapping and getfield(current,"kern") ~= 0 then
@@ -1477,12 +1456,6 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
special_penalty = sp
sp = p
end
-
--- else
--- if nobreakfound == nil then
--- nobreakfound = checknobreak()
--- end
-
end
if not penalty_data then
penalty_data = sp
@@ -1494,14 +1467,6 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
if trace then
trace_skip("penalty in skip",sc,so,sp,current)
end
-
--- if nobreakfound then
--- penalty_data = 10000
--- if trace then
--- trace_skip("nobreak found before penalty in skip",sc,so,sp,current)
--- end
--- end
-
head, current = remove_node(head, current, true)
elseif not sc then -- if not sc then
if glue_data then
@@ -1518,11 +1483,10 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
-- todo: prev can be whatsit (latelua)
local previous = getprev(current)
if previous and getid(previous) == glue_code and getsubtype(previous) == userskip_code then
- if getfield(previous,"stretch_order") == 0 and getfield(previous,"shrink_order") == 0 and
- getfield(current, "stretch_order") == 0 and getfield(current, "shrink_order") == 0 then
- setfield(previous,"width", (getfield(previous,"width") or 0) + (getfield(current,"width") or 0))
- setfield(previous,"stretch",(getfield(previous,"stretch") or 0) + (getfield(current,"stretch") or 0))
- setfield(previous,"shrink", (getfield(previous,"shrink") or 0) + (getfield(current,"shrink") or 0))
+ local pwidth, pstretch, pshrink, pstretch_order, pshrink_order = getglue(previous)
+ local cwidth, cstretch, cshrink, cstretch_order, cshrink_order = getglue(current)
+ if pstretch_order == 0 and pshrink_order == 0 and cstretch_order == 0 and cshrink_order == 0 then
+ setglue(previous,pwidth + cwidth, pstretch + cstretch, pshrink + cshrink)
if trace then
trace_natural("removed",current)
end
@@ -1647,9 +1611,9 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
if trace then
trace_skip("add",sc,so,sp,current)
end
- setfield(old,"width", (getfield(glue_data,"width") or 0) + (getfield(current,"width") or 0))
- setfield(old,"stretch",(getfield(glue_data,"stretch") or 0) + (getfield(current,"stretch") or 0))
- setfield(old,"shrink", (getfield(glue_data,"shrink") or 0) + (getfield(current,"shrink") or 0))
+ local cwidth, cstretch, cshrink = getglue(current)
+ local gwidth, gstretch, gshrink = getglue(glue_data)
+ setglue(old,gwidth + cwidth, gstretch + cstretch, gshrink + cshrink)
-- toto: order
head, current = remove_node(head, current, true)
else
@@ -1866,13 +1830,6 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
trace_info("head has been changed from %a to %a",nodecodes[getid(oldhead)],nodecodes[getid(head)])
end
end
-
--- if headprev then
--- setprev(head,headprev)
--- setnext(headprev,head)
--- end
--- print("C HEAD",tonode(head))
-
return head, true
end
@@ -2013,7 +1970,7 @@ do
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)
+ head and "reset" or "kept",texgetcount("realpageno"),skip,outer.prevdepth)
end
end
end
diff --git a/tex/context/base/mkiv/spac-ver.mkiv b/tex/context/base/mkiv/spac-ver.mkiv
index 5bc73abb8..229963997 100644
--- a/tex/context/base/mkiv/spac-ver.mkiv
+++ b/tex/context/base/mkiv/spac-ver.mkiv
@@ -1443,6 +1443,7 @@
\installcorenamespace{gridsnappers}
\installcorenamespace{gridsnapperattributes}
+\installcorenamespace{gridsnappersets}
\newskip \bodyfontlineheight
\newdimen \bodyfontstrutheight
@@ -1462,12 +1463,34 @@
\attribute \snapvboxattribute \attribute\snapmethodattribute}%
\fi}
-\unexpanded\def\installsnapvalues#1#2% todo: a proper define
- {\edef\currentsnapper{#1:#2}%
- \ifcsname\??gridsnapperattributes\currentsnapper\endcsname \else
- \setevalue{\??gridsnapperattributes\currentsnapper}{\clf_definesnapmethod{#1}{#2}}%
+% \unexpanded\def\installsnapvalues#1#2% todo: a proper define
+% {\edef\currentsnapper{#1:#2}%
+% \ifcsname\??gridsnapperattributes\currentsnapper\endcsname \else
+% \setevalue{\??gridsnapperattributes\currentsnapper}{\clf_definesnapmethod{#1}{#2}}%
+% \fi
+% \setevalue{\??gridsnappers#1}{\attribute\snapmethodattribute\csname\??gridsnapperattributes\currentsnapper\endcsname\space}}
+
+\def\spac_grids_expand_snapper#1%
+ {\edef\m_spac_snapper
+ {\ifx\m_spac_snapper\empty\else\m_spac_snapper,\fi
+ \ifcsname\??gridsnappersets#1\endcsname
+ \lastnamedcs\else#1%
+ \fi}}
+
+\unexpanded\def\installsnapvalues#1#2%
+ {\let\m_spac_snapper\empty
+ \rawprocesscommacommand[#2]\spac_grids_expand_snapper
+ \edef\currentsnapper{#1:\m_spac_snapper}%
+ \ifcsname\??gridsnapperattributes\currentsnapper\endcsname
+ \scratchcounter\lastnamedcs % already defined
+ \else
+ \scratchcounter\clf_definesnapmethod{#1}{\m_spac_snapper}%
+ \setevalue{\??gridsnapperattributes\currentsnapper}{\the\scratchcounter}%
\fi
- \setevalue{\??gridsnappers#1}{\attribute\snapmethodattribute\csname\??gridsnapperattributes\currentsnapper\endcsname\space}}
+ \setevalue{\??gridsnappers#1}{\attribute\snapmethodattribute\the\scratchcounter\relax}%
+ \letvalue{\??gridsnappersets#1}\m_spac_snapper}
+
+\def\theexpandedsnapperset#1{\begincsname\??gridsnappersets#1\endcsname} % only for manuals
\unexpanded\def\usegridparameter#1% no checking here
{\edef\m_spac_grid_asked{#1\c!grid}%
@@ -1518,6 +1541,9 @@
% offset:-3tp vertical shift within box
% bottom:lines
% top:lines
+% box centers a box rounded upwards (box:.5 -> tolerance)
+% min centers a box rounded downwards
+% max centers a box rounded upwards
%D We're not downward compatible with \MKII !
@@ -1527,7 +1553,6 @@
\definegridsnapping[\v!strict] [\v!maxdepth:0.8,\v!maxheight:0.8,\v!strut]
\definegridsnapping[\v!tolerant] [\v!maxdepth:1.2,\v!maxheight:1.2,\v!strut]
-\definegridsnapping[\v!math] [\v!maxdepth:1.05,\v!maxheight:1.05,\v!strut] % experimental, maybe 1.1
\definegridsnapping[\v!top] [\v!minheight,\v!maxdepth,\v!strut]
\definegridsnapping[\v!bottom] [\v!maxheight,\v!mindepth,\v!strut]
@@ -1544,15 +1569,18 @@
\definegridsnapping[\v!none] [\v!none]
\definegridsnapping[\v!line] [\v!line]
\definegridsnapping[\v!strut] [\v!strut]
-\definegridsnapping[\v!box] [\v!box] % centers a box rounded upwards (box:.5 -> tolerance)
-\definegridsnapping[\v!min] [\v!min] % centers a box rounded downwards
-\definegridsnapping[\v!max] [\v!max] % centers a box rounded upwards
-
-\definegridsnapping[\v!max] [\v!maxdepth,\v!maxheight,\v!strut]
-\definegridsnapping[\v!min] [\v!mindepth,\v!minheight,\v!strut]
+\definegridsnapping[\v!box] [\v!box]
+\definegridsnapping[\v!min] [\v!min]
+\definegridsnapping[\v!max] [\v!max]
\definegridsnapping[\v!middle] [\v!maxheight,\v!maxdepth] % used in placement
+\definegridsnapping[\v!math] [\v!maxdepth:1.05,\v!maxheight:1.05,\v!strut] % experimental, maybe 1.1
+\definegridsnapping[\v!math:\v!line] [\v!math,\v!line,\v!split]
+\definegridsnapping[\v!math:\v!halfline] [\v!math,\v!halfline,\v!split]
+\definegridsnapping[\v!math:-\v!line] [\v!math,-\v!line,\v!split]
+\definegridsnapping[\v!math:-\v!halfline][\v!math,-\v!halfline,\v!split]
+
\unexpanded\def\synchronizelocallinespecs
{\bodyfontlineheight \normallineheight
\bodyfontstrutheight\strutht
@@ -1653,6 +1681,51 @@
\spac_grids_check_yes
\fi\fi\fi}
+\unexpanded\def\setupgridsnapping[#1]% less overhead than setuplayout (needs testing)
+ {\setlayoutparameter\c!grid{#1}\synchronizegridsnapping}
+
+\unexpanded\def\checkgridmethod#1%
+ {\edef\p_grid{#1}%
+ \ifx\p_grid\empty
+ \let\checkedgridmethod\empty
+ \let\checkedgridscope \v!local
+ \else
+ \splitatcolon\p_grid\checkedgridscope\checkedgridmethod
+ \ifx\checkedgridmethod\empty
+ \ifx\checkedgridscope\v!local\else\ifx\checkedgridscope\v!global\else
+ \let\checkedgridmethod\checkedgridscope
+ \let\checkedgridscope \v!local
+ \fi\fi
+ \fi
+ \fi}
+
+\unexpanded\def\applygridmethod#1#2#3% content localsettings (used in head rendering)
+ {\checkgridmethod{#1}%
+ \ifx\checkedgridscope\v!global
+ \ifx\checkedgridmethod\empty \else
+ % we assume that the call is grouped because grouping here has the side
+ % effect that the eventually constructed line will get the value outside
+ % the group
+ %
+ % overkill: \setupgridsnapping[\checkedgridmethod]%
+ % maybe : \spac_grids_snap_value_auto\checkedgridmethod
+ \spac_grids_snap_value_set\checkedgridmethod
+ \fi
+ \hbox{#3}%
+ \else
+ % the extra hbox will trigger the global snapper on top of the local and
+ % we really need that in this case (compatibility etc etc) so here we don't
+ % het an already done hit (otherwise we would not snap)
+ \hbox\bgroup
+ \ifx\checkedgridmethod\empty\else
+ \ifconditional\headisdisplay
+ #2%
+ \fi
+ \fi
+ \snaptogrid[\checkedgridmethod]\hbox{#3}%
+ \egroup
+ \fi}
+
\unexpanded\gdef\page_layouts_calculate_overshoot
{\ifgridsnapping\ifcase\layoutlines
\getnoflines\textheight
diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf
index f535d39b3..ed9a82192 100644
--- a/tex/context/base/mkiv/status-files.pdf
+++ b/tex/context/base/mkiv/status-files.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf
index d3fb5d973..c6c5939bb 100644
--- a/tex/context/base/mkiv/status-lua.pdf
+++ b/tex/context/base/mkiv/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/strc-itm.mkvi b/tex/context/base/mkiv/strc-itm.mkvi
index eaae6a7c7..e622318c3 100644
--- a/tex/context/base/mkiv/strc-itm.mkvi
+++ b/tex/context/base/mkiv/strc-itm.mkvi
@@ -393,7 +393,7 @@
\def\strc_itemgroups_process_option#option%
{\edef\itemgroupconstantvalue{#option}%
\ifx\itemgroupconstantvalue\empty\else
- \splitstring\itemgroupconstantvalue\at*\to\itemgroupfirst\and\itemgroupsecond
+ \splitatasterisk\itemgroupconstantvalue\itemgroupfirst\itemgroupsecond
\ifx\itemgroupsecond\empty
\let\itemgroupsecond\itemgroupfirst
\let\itemgroupfirst\!!plusone
diff --git a/tex/context/base/mkiv/strc-mat.mkiv b/tex/context/base/mkiv/strc-mat.mkiv
index 643f6d22d..4c6b88c8a 100644
--- a/tex/context/base/mkiv/strc-mat.mkiv
+++ b/tex/context/base/mkiv/strc-mat.mkiv
@@ -730,6 +730,26 @@
{\d_strc_formulas_display_skip_left \zeropoint
\d_strc_formulas_display_skip_right\zeropoint}
+\setvalue{\??formulaoption\v!line}%
+ {\ifgridsnapping
+ \setformulaparameter\c!grid{\v!math:\v!line}%
+ \fi}
+
+\setvalue{\??formulaoption\v!halfline}%
+ {\ifgridsnapping
+ \setformulaparameter\c!grid{\v!math:\v!halfline}%
+ \fi}
+
+\setvalue{\??formulaoption-\v!line}%
+ {\ifgridsnapping
+ \setformulaparameter\c!grid{\v!math:-\v!line}%
+ \fi}
+
+\setvalue{\??formulaoption-\v!halfline}%
+ {\ifgridsnapping
+ \setformulaparameter\c!grid{\v!math:-\v!halfline}%
+ \fi}
+
\unexpanded\def\strc_formulas_start_formula_indeed[#1][#2]% setting leftskip adaption is slow !
{\ifhmode
\par
@@ -737,18 +757,20 @@
\bgroup % HERE
\def\currentformula{#1}%
\dostarttaggedchained\t!formula\currentformula\??formula
- \the\everybeforedisplayformula
\setfalse\c_strc_formulas_tight
- %\formulastrutdp\strutdepth
- %\formulastrutht\strutheight
\d_strc_formulas_display_skip_left \leftskip
\d_strc_formulas_display_skip_right \rightskip
\d_strc_formulas_display_width \formulaparameter\c!width\relax
\d_strc_formulas_display_margin_left \formulaparameter\c!leftmargin\relax
\d_strc_formulas_display_margin_right\formulaparameter\c!rightmargin\relax
- \edef\p_option{\formulaparameter\c!option}%
\ifsecondargument
- \edef\p_option{\ifx\p_option\empty\else\p_option,\fi#2}%
+ \doifelseassignment{#2}% this is new, so that we can also set the grid
+ {\setupcurrentformula[#2]%
+ \edef\p_option{\formulaparameter\c!option}}%
+ {\edef\p_option{\formulaparameter\c!option}%
+ \edef\p_option{\ifx\p_option\empty\else\p_option,\fi#2}}%
+ \else
+ \edef\p_option{\formulaparameter\c!option}
\fi
\ifx\p_option\empty \else
\rawprocesscommacommand[\p_option]\strc_formulas_option
@@ -760,6 +782,7 @@
\fi
\let\strc_formulas_start_formula\strc_formulas_start_formula_nested
\strc_formulas_forget_display_skips
+ \the\everybeforedisplayformula
\csname\e!start\formulaparameter\c!alternative\v!formula\endcsname}
\unexpanded\def\strc_formulas_start_formula_nested#1%
@@ -791,11 +814,16 @@
% experiment:
-\appendtoks
- \edef\p_grid{\formulaparameter\c!grid}%
+\def\strc_formulas_set_grid_snapping
+ {\edef\p_grid{\formulaparameter\c!grid}%
\ifx\p_grid\empty \else
\spac_grids_snap_value_auto\p_grid
- \fi
+ \fi}
+
+\appendtoks
+ \ifgridsnapping
+ \strc_formulas_set_grid_snapping
+ \fi
\to \everybeforedisplayformula
% \unexpanded\def\switchtoformulabodyfont
diff --git a/tex/context/base/mkiv/strc-not.lua b/tex/context/base/mkiv/strc-not.lua
index 523b9dc92..c54cd442e 100644
--- a/tex/context/base/mkiv/strc-not.lua
+++ b/tex/context/base/mkiv/strc-not.lua
@@ -455,7 +455,7 @@ local report_insert = logs.reporter("pagebuilder","insert")
local trace_insert = false trackers.register("pagebuilder.insert",function(v) trace_insert = v end)
local texgetglue = tex.getglue
-local texsetglue = tex.setglue
+----- texsetglue = tex.setglue
function notes.check_spacing(n,i)
local gn, pn, mn = texgetglue(n)
@@ -466,8 +466,8 @@ function notes.check_spacing(n,i)
report_insert("%s %i: %p plus %p minus %p",i > 1 and "inbetween" or "before ",n,gi,pi,mi)
report_insert("%s %i: %p plus %p minus %p","effective",n,gt,pt,mt)
end
- texsetglue(0,gt,pt,mt) -- for the moment we use skip register 0
- return 0
+ -- texsetglue(0,gt,pt,mt) -- for the moment we use skip register 0
+ return gt, pt, mt
end
callback.register("build_page_insert", notes.check_spacing)
diff --git a/tex/context/base/mkiv/strc-ren.mkiv b/tex/context/base/mkiv/strc-ren.mkiv
index 507cb9921..b5fc9e11d 100644
--- a/tex/context/base/mkiv/strc-ren.mkiv
+++ b/tex/context/base/mkiv/strc-ren.mkiv
@@ -308,28 +308,88 @@
\d_strc_rendering_hang_height\zeropoint
\fi}
+% \def\strc_rendering_stop_placement
+% {\n_strc_rendering_hang_lines\zerocount
+% \ifconditional\headisdisplay
+% \strc_rendering_initialize_line_hang
+% % kind of special, we want to snap heads also according to local specs local
+% \ifgridsnapping
+% \hbox\bgroup % extra hbox will trigger global snapper on top of local
+% \edef\p_grid{\headparameter\c!grid}%
+% \ifconditional\headisdisplay
+% \ifx\p_grid\empty\else
+% \useheadstyleandcolor\c!style\c!color
+% \setupinterlinespace
+% \useheadstyleandcolor\c!textstyle\c!textcolor
+% \setupinterlinespace
+% \fi
+% \fi
+% \snaptogrid[\p_grid]\hbox
+% {\hskip\dimexpr\d_strc_rendering_local_leftoffset+\headparameter\c!margin\relax\box\b_strc_rendering_head}%
+% \egroup
+% \else
+% \hbox
+% {\hskip\dimexpr\d_strc_rendering_local_leftoffset+\headparameter\c!margin\relax\box\b_strc_rendering_head}%
+% \fi
+% \flushnotes % new, not really needed
+% \endgraf
+% \ifvmode
+% \ifnum\n_strc_rendering_hang_lines>\zerocount
+% \dorecurse\n_strc_rendering_hang_lines{\nointerlineskip\dosomebreak\nobreak\strut\endgraf}% to be checked
+% \fi
+% \nointerlineskip
+% \dosomebreak\nobreak
+% \fi
+% \getheadsyncs
+% \else
+% % somehow this goes ok even when we push in the margin probably because we gobble pars
+% % in the process of collecting index entries etc
+% \strut
+% \flushnotes % new, here since we're in par mode
+% \unhbox\b_strc_rendering_head
+% \getheadsyncs
+% \ifconditional\headissomewhere
+% % nothing special
+% \else
+% %\hskip\headnumberdistance\s!plus\headnumberdistance\s!minus.25\dimexpr\headnumberdistance\relax
+% \hskip\headtextdistance\relax
+% \strc_sectioning_inject_continuous_signal
+% \fi
+% \fi
+% \ifconditional\headisdisplay
+% \ifvmode
+% \ifgridsnapping % important, font related depth, see comment
+% \prevdepth\strutdp
+% \else
+% \prevdepth\d_strc_rendering_local_depth
+% \fi
+% \fi
+% \fi
+% \egroup
+% \egroup
+% \ifconditional\headisdisplay
+% \useindentnextparameter\headparameter
+% \else
+% \nonoindentation % recently added, was a bug
+% \fi}
+
\def\strc_rendering_stop_placement
{\n_strc_rendering_hang_lines\zerocount
\ifconditional\headisdisplay
\strc_rendering_initialize_line_hang
% kind of special, we want to snap heads also according to local specs local
+ \setbox\b_strc_rendering_head\hbox
+ {\hskip\dimexpr\d_strc_rendering_local_leftoffset+\headparameter\c!margin\relax
+ \box\b_strc_rendering_head}%
\ifgridsnapping
- \hbox\bgroup % extra hbox will trigger global snapper on top of local
- \edef\p_grid{\headparameter\c!grid}%
- \ifconditional\headisdisplay
- \ifx\p_grid\empty\else
- \useheadstyleandcolor\c!style\c!color
- \setupinterlinespace
- \useheadstyleandcolor\c!textstyle\c!textcolor
- \setupinterlinespace
- \fi
- \fi
- \snaptogrid[\p_grid]\hbox
- {\hskip\dimexpr\d_strc_rendering_local_leftoffset+\headparameter\c!margin\relax\box\b_strc_rendering_head}%
- \egroup
+ \applygridmethod
+ {\headparameter\c!grid}%
+ {\ifconditional\headisdisplay
+ \strc_rendering_initialize_style_and_color_display\c!textstyle\c!textcolor
+ \fi}%
+ {\box\b_strc_rendering_head}
\else
- \hbox
- {\hskip\dimexpr\d_strc_rendering_local_leftoffset+\headparameter\c!margin\relax\box\b_strc_rendering_head}%
+ \box\b_strc_rendering_head
\fi
\flushnotes % new, not really needed
\endgraf
diff --git a/tex/context/base/mkiv/supp-box.lua b/tex/context/base/mkiv/supp-box.lua
index f5974daf7..4e28f2805 100644
--- a/tex/context/base/mkiv/supp-box.lua
+++ b/tex/context/base/mkiv/supp-box.lua
@@ -12,63 +12,63 @@ local lpegmatch = lpeg.match
local report_hyphenation = logs.reporter("languages","hyphenation")
-local tex = tex
-local context = context
-local nodes = nodes
-
-local implement = interfaces.implement
-
-local nodecodes = nodes.nodecodes
-
-local disc_code = nodecodes.disc
-local hlist_code = nodecodes.hlist
-local vlist_code = nodecodes.vlist
-local glue_code = nodecodes.glue
-local glyph_code = nodecodes.glyph
-
-local nuts = nodes.nuts
-local tonut = nuts.tonut
-local tonode = nuts.tonode
-
-local getfield = nuts.getfield
-local getnext = nuts.getnext
-local getprev = nuts.getprev
-local getdisc = nuts.getdisc
-local getid = nuts.getid
-local getlist = nuts.getlist
-local getattribute = nuts.getattribute
-local getbox = nuts.getbox
-local takebox = nuts.takebox
-
-local setfield = nuts.setfield
-local setlink = nuts.setlink
-local setboth = nuts.setboth
-local setnext = nuts.setnext
-local setbox = nuts.setbox
-local setlist = nuts.setlist
-
-local flush_node = nuts.flush_node
-local flush_list = nuts.flush_list
-local copy_node = nuts.copy
-local copy_list = nuts.copy_list
-local find_tail = nuts.tail
-local traverse_id = nuts.traverse_id
-local link_nodes = nuts.linked
-local dimensions = nuts.dimensions
-local hpack = nuts.hpack
-
-local listtoutf = nodes.listtoutf
-
-local nodepool = nuts.pool
-local new_penalty = nodepool.penalty
-local new_hlist = nodepool.hlist
-local new_glue = nodepool.glue
-
-local setlistcolor = nodes.tracers.colors.setlist
-
-local texget = tex.get
-local texgetbox = tex.getbox
-local texsetdimen = tex.setdimen
+local tex = tex
+local context = context
+local nodes = nodes
+
+local implement = interfaces.implement
+
+local nodecodes = nodes.nodecodes
+
+local disc_code = nodecodes.disc
+local hlist_code = nodecodes.hlist
+local vlist_code = nodecodes.vlist
+local glue_code = nodecodes.glue
+local glyph_code = nodecodes.glyph
+
+local nuts = nodes.nuts
+local tonut = nuts.tonut
+local tonode = nuts.tonode
+
+local getfield = nuts.getfield
+local getnext = nuts.getnext
+local getprev = nuts.getprev
+local getdisc = nuts.getdisc
+local getid = nuts.getid
+local getlist = nuts.getlist
+local getattribute = nuts.getattribute
+local getbox = nuts.getbox
+local takebox = nuts.takebox
+
+local setfield = nuts.setfield
+local setlink = nuts.setlink
+local setboth = nuts.setboth
+local setnext = nuts.setnext
+local setbox = nuts.setbox
+local setlist = nuts.setlist
+
+local flush_node = nuts.flush_node
+local flush_list = nuts.flush_list
+local copy_node = nuts.copy
+local copy_list = nuts.copy_list
+local find_tail = nuts.tail
+local traverse_id = nuts.traverse_id
+local link_nodes = nuts.linked
+local list_dimensions = nuts.dimensions
+local hpack = nuts.hpack
+
+local listtoutf = nodes.listtoutf
+
+local nodepool = nuts.pool
+local new_penalty = nodepool.penalty
+local new_hlist = nodepool.hlist
+local new_glue = nodepool.glue
+
+local setlistcolor = nodes.tracers.colors.setlist
+
+local texget = tex.get
+local texgetbox = tex.getbox
+local texsetdimen = tex.setdimen
local function hyphenatedlist(head,usecolor)
local current = head and tonut(head)
@@ -350,7 +350,7 @@ implement {
arguments = "integer",
actions = function(n)
local b = getbox(n)
- local factor = texget("baselineskip").width / texget("hsize")
+ local factor = texget("baselineskip",false) / texget("hsize")
setfield(b,"depth",0)
setfield(b,"height",getfield(b,"width") * factor)
end
@@ -368,7 +368,7 @@ local function getnaturaldimensions(n)
local w, h, d = 0, 0, 0
local l = getlist(getbox(n))
if l then
- w, h, d = dimensions(l)
+ w, h, d = list_dimensions(l)
end
texsetdimen("lastnaturalboxwd",w)
texsetdimen("lastnaturalboxht",h)
@@ -398,7 +398,7 @@ interfaces.implement {
local w, h, d = 0, 0, 0
local l = getlist(getbox(n))
if l then
- w, h, d = dimensions(l)
+ w, h, d = list_dimensions(l)
end
context("\\dimexpr%i\\scaledpoint\\relax",w)
end
@@ -464,7 +464,7 @@ do
trackers.register("nodes.boxes",function(v) trace = v end)
function boxes.save(category,name,box)
-name = tonumber(name) or name
+ 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")
@@ -473,12 +473,12 @@ name = tonumber(name) or name
end
function boxes.found(category,name)
-name = tonumber(name) or name
+ name = tonumber(name) or name
return cache[category][name] and true or false
end
function boxes.direct(category,name,copy)
-name = tonumber(name) or name
+ name = tonumber(name) or name
local c = cache[category]
local b = c[name]
if not b then
@@ -495,7 +495,7 @@ name = tonumber(name) or name
end
function boxes.restore(category,name,box,copy)
-name = tonumber(name) or name
+ name = tonumber(name) or name
local c = cache[category]
local b = takebox(box)
if b then
@@ -515,18 +515,20 @@ name = tonumber(name) or name
texsetbox(box,b or nil)
end
+ local getwhd = nodes.getwhd
+
function boxes.dimensions(category,name)
-name = tonumber(name) or name
+ name = tonumber(name) or name
local b = cache[category][name]
if b then
- return b.width, b.height, b.depth
+ return getwhd(b)
else
return 0, 0, 0
end
end
function boxes.reset(category,name)
-name = tonumber(name) or name
+ name = tonumber(name) or name
local c = cache[category]
if name and name ~= "" then
local b = c[name]
diff --git a/tex/context/base/mkiv/supp-box.mkiv b/tex/context/base/mkiv/supp-box.mkiv
index 6e31d2139..8e38c4afa 100644
--- a/tex/context/base/mkiv/supp-box.mkiv
+++ b/tex/context/base/mkiv/supp-box.mkiv
@@ -905,7 +905,7 @@
\ifzeropt\ht\oldshapebox % \ifdim\ht\oldshapebox=\zeropoint
\setbox\newshapebox\emptyvbox
\else
- \setbox\newshapebox\vbox
+ \setbox\newshapebox\vbox % can be \vpack
{\unvcopy\oldshapebox
\setbox\newshapebox\emptybox
\shapecounter\zerocount
@@ -915,7 +915,7 @@
\ifx\originalshapebox\undefined \let\originalshapebox\oldshapebox \fi
-% We will turn this into a \MKIV\ variant.
+% We will turn this into a \MKIV\ variant (we can use \type {\vpack} too).
\unexpanded\def\insertshapesignal
{\hpack to \shapesignal{\strut\hss}% plus \strut
@@ -1313,8 +1313,7 @@
\egroup}
\unexpanded\def\limitatetext#1#2#3% \expanded added 2003/01/16
- {\expanded{\beforesplitstring#2}\at,\to\leftlimit
- \expanded{\aftersplitstring #2}\at,\to\rightlimit
+ {\splitatcomma{#2}\leftlimit\rightlimit
\ifx\rightlimit\empty
\normallimitatetext {#1}\leftlimit {#3}%
\else
@@ -1727,7 +1726,7 @@
{\ifnum\rigidcolumns=1 % tzt ook h/d correctie
\ifinner\ifhmode\box\else\unvbox\fi\else\unvbox\fi#1\relax
\else
- \vbox
+ \vbox % \vpack
{\forgetall
\nopenalties
\dontcomplain
@@ -2948,6 +2947,30 @@
\unexpanded\def\startvboxregister#1{\setbox#1\vbox\bgroup} \let\stopvboxregister\egroup
\unexpanded\def\startvtopregister#1{\setbox#1\vtop\bgroup} \let\stopvtopregister\egroup
+%D For whatever third party package needs it:
+%D
+%D \starttyping
+%D \newlocalbox\BoxOne
+%D \newlocalbox\BoxTwo
+%D
+%D \setbox\BoxOne\hbox{Box One}
+%D \setbox\BoxTwo\hbox{Box Two}
+%D
+%D [\box\BoxTwo] [\box\BoxOne]
+%D \stoptyping
+
+\installcorenamespace{localbox}
+
+\unexpanded\def\newlocalbox#1%
+ {\expandafter\let\expandafter#1\csname\??localbox\string#1\endcsname
+ \ifx#1\relax
+ \syst_aux_new_localbox#1%
+ \fi}
+
+\def\syst_aux_new_localbox#1%
+ {\expandafter\newbox\csname\??localbox\string#1\endcsname
+ \newlocalbox#1}
+
\protect \endinput
% a bit of test code:
diff --git a/tex/context/base/mkiv/syst-aux.lua b/tex/context/base/mkiv/syst-aux.lua
index 7cdda273d..34e5c4e88 100644
--- a/tex/context/base/mkiv/syst-aux.lua
+++ b/tex/context/base/mkiv/syst-aux.lua
@@ -257,7 +257,7 @@ local spaces = space^0
local option = (
P("single")
+ P("double")
- + P("tripple")
+ + P("triple")
+ P("quadruple")
+ P("quintuple")
+ P("sixtuple")
@@ -296,7 +296,8 @@ local function texdefinition_two()
optional ..
[[\csname _do_]] ..
csname ..
- [[_\endcsname}\unexpanded\expandafter]] ..
+ -- [[_\endcsname}\unexpanded\expandafter]] ..
+ [[_\endcsname}\expandafter]] ..
(global and [[\gdef]] or [[\edef]]) ..
[[\csname _do_]] ..
csname ..
diff --git a/tex/context/base/mkiv/syst-aux.mkiv b/tex/context/base/mkiv/syst-aux.mkiv
index 6c2fb2014..bff1b8428 100644
--- a/tex/context/base/mkiv/syst-aux.mkiv
+++ b/tex/context/base/mkiv/syst-aux.mkiv
@@ -4197,9 +4197,9 @@
%D Watch the one level expansion of the second argument.
\unexpanded\def\doifelsemeaning#1#2%
- {\edef\m_syst_string_one{\meaning#1}%
+ {\edef\m_syst_string_one{\normalmeaning#1}%
\def \m_syst_string_two{#2}%
- \edef\m_syst_string_two{\meaning\m_syst_string_two}%
+ \edef\m_syst_string_two{\normalmeaning\m_syst_string_two}%
\ifx\m_syst_string_one\m_syst_string_two
\expandafter\firstoftwoarguments
\else
@@ -5138,6 +5138,25 @@
\expandafter\syst_helpers_split_string#1#2#2\empty\\}
%D \macros
+%D {splitatperiod,
+%D {splitatcomma,
+%D splitatasterisk,
+%D splitatcolon,
+%D splitatcolons}
+
+\unexpanded\def\splitatperiod #1{\normalexpanded{\syst_helpers_splitatperiod #1}..\relax}
+\unexpanded\def\splitatcomma #1{\normalexpanded{\syst_helpers_splitatcomma #1},,\relax} % not at ", "
+\unexpanded\def\splitatasterisk#1{\normalexpanded{\syst_helpers_splitatasterisk#1}**\relax}
+\unexpanded\def\splitatcolon #1{\normalexpanded{\syst_helpers_splitatcolon #1}::\relax}
+\unexpanded\def\splitatcolons #1{\normalexpanded{\syst_helpers_splitatcolons #1}::::\relax}
+
+\unexpanded\def\syst_helpers_splitatperiod #1.#2.#3\relax#4#5{\def#4{#1}\def#5{#2}}
+\unexpanded\def\syst_helpers_splitatcomma #1,#2,#3\relax#4#5{\def#4{#1}\def#5{#2}}
+\unexpanded\def\syst_helpers_splitatasterisk #1*#2*#3\relax#4#5{\def#4{#1}\def#5{#2}}
+\unexpanded\def\syst_helpers_splitatcolon #1:#2:#3\relax#4#5{\def#4{#1}\def#5{#2}}
+\unexpanded\def\syst_helpers_splitatcolons #1::#2::#3\relax#4#5{\edef#4{#1}\edef#5{#2}}
+
+%D \macros
%D {removesubstring}
%D
%D A first application of the two routines defined above is:
diff --git a/tex/context/base/mkiv/syst-ini.mkiv b/tex/context/base/mkiv/syst-ini.mkiv
index 97c612db7..1bdc9daae 100644
--- a/tex/context/base/mkiv/syst-ini.mkiv
+++ b/tex/context/base/mkiv/syst-ini.mkiv
@@ -1170,5 +1170,6 @@
\ifdefined\mathrulesfam \else \newcount\mathrulesfam \fi
\ifdefined\mathrulesmode \else \newcount\mathrulesmode \fi
+\ifdefined\mathsurroundmode \else \newcount\mathsurroundmode \fi
\protect \endinput
diff --git a/tex/context/base/mkiv/tabl-tbl.mkiv b/tex/context/base/mkiv/tabl-tbl.mkiv
index 4493db4f8..b21771009 100644
--- a/tex/context/base/mkiv/tabl-tbl.mkiv
+++ b/tex/context/base/mkiv/tabl-tbl.mkiv
@@ -575,7 +575,7 @@
% future let but just pick up the key.
% \installtabulatepreambleoption \s!unknown %
-% {\writestatus{tabulate}{unknown preamble key [\meaning\next]}%
+% {\writestatus{tabulate}{unknown preamble key [\normalmeaning\next]}%
% \tabl_tabulate_set_preamble}
%
% \def\tabl_tabulate_set_preamble
diff --git a/tex/context/base/mkiv/tabl-xtb.lua b/tex/context/base/mkiv/tabl-xtb.lua
index c3e022b24..62c95cbe6 100644
--- a/tex/context/base/mkiv/tabl-xtb.lua
+++ b/tex/context/base/mkiv/tabl-xtb.lua
@@ -67,7 +67,7 @@ local getprev = nuts.getprev
local getlist = nuts.getlist
local getfield = nuts.getfield
local getbox = nuts.getbox
-local getdimensions = nuts.dimensions
+local getwhd = nuts.getwhd
local setfield = nuts.setfield
local setlink = nuts.setlink
@@ -257,7 +257,7 @@ function xtables.set_reflow_width()
--
drc.list = true -- we don't need to keep the content around as we're in trial mode (no: copy_node_list(tb))
--
- local width, height, depth = getdimensions(tb)
+ local width, height, depth = getwhd(tb)
--
local widths = data.widths
local heights = data.heights
@@ -427,7 +427,7 @@ function xtables.set_reflow_height()
local tb = getbox("b_tabl_x")
local drc = row[c]
--
- local width, height, depth = getdimensions(tb)
+ local width, height, depth = getwhd(tb)
--
if drc.ny < 2 then
if data.fixedrows[r] == 0 then -- and drc.dimensionstate < 2
@@ -818,7 +818,7 @@ function xtables.construct()
end
local list = drc.list
if list then
- local w, h, d = getdimensions(list)
+ local w, h, d = getwhd(list)
setfield(list,"shift",h+d)
-- list = hpack_node_list(list) -- is somehow needed
-- setfield(list,"width",0)
@@ -1166,7 +1166,7 @@ function xtables.cleanup()
-- local cell = row[i]
-- local list = cell.list
-- if list then
- -- cell.width, cell.height, cell.depth = getdimensions(list)
+ -- cell.width, cell.height, cell.depth = getwhd(list)
-- cell.list = true
-- end
-- end
diff --git a/tex/context/base/mkiv/trac-jus.lua b/tex/context/base/mkiv/trac-jus.lua
index dbf2b8d33..76d6438a1 100644
--- a/tex/context/base/mkiv/trac-jus.lua
+++ b/tex/context/base/mkiv/trac-jus.lua
@@ -6,43 +6,43 @@ if not modules then modules = { } end modules ['trac-jus'] = {
license = "see context related readme files"
}
-local checkers = typesetters.checkers or { }
-typesetters.checkers = checkers
+local checkers = typesetters.checkers or { }
+typesetters.checkers = checkers
----- report_justification = logs.reporter("visualize","justification")
-local a_alignstate = attributes.private("alignstate")
-local a_justification = attributes.private("justification")
+local a_alignstate = attributes.private("alignstate")
+local a_justification = attributes.private("justification")
-local nuts = nodes.nuts
-local tonut = nuts.tonut
+local nuts = nodes.nuts
+local tonut = nuts.tonut
-local getfield = nuts.getfield
-local setfield = nuts.setfield
-local getlist = nuts.getlist
-local getattr = nuts.getattr
-local setattr = nuts.setattr
-local setlist = nuts.setlist
+local getfield = nuts.getfield
+local setfield = nuts.setfield
+local getlist = nuts.getlist
+local getattr = nuts.getattr
+local setattr = nuts.setattr
+local setlist = nuts.setlist
-local traverse_id = nuts.traverse_id
-local get_list_dimensions = nuts.dimensions
-local linked_nodes = nuts.linked
-local copy_node = nuts.copy
+local traverse_id = nuts.traverse_id
+local list_dimensions = nuts.dimensions
+local linked_nodes = nuts.linked
+local copy_node = nuts.copy
-local tracedrule = nodes.tracers.pool.nuts.rule
+local tracedrule = nodes.tracers.pool.nuts.rule
-local nodepool = nuts.pool
+local nodepool = nuts.pool
-local new_hlist = nodepool.hlist
-local new_kern = nodepool.kern
+local new_hlist = nodepool.hlist
+local new_kern = nodepool.kern
-local hlist_code = nodes.nodecodes.hlist
+local hlist_code = nodes.nodecodes.hlist
-local texsetattribute = tex.setattribute
-local unsetvalue = attributes.unsetvalue
+local texsetattribute = tex.setattribute
+local unsetvalue = attributes.unsetvalue
-local min_threshold = 0
-local max_threshold = 0
+local min_threshold = 0
+local max_threshold = 0
local function set(n)
nodes.tasks.enableaction("mvlbuilders", "typesetters.checkers.handler")
@@ -81,7 +81,7 @@ function checkers.handler(head)
if width > 0 then
local list = getlist(current)
if list then
- local naturalwidth, naturalheight, naturaldepth = get_list_dimensions(list)
+ local naturalwidth, naturalheight, naturaldepth = list_dimensions(list)
local delta = naturalwidth - width
if naturalwidth == 0 or delta == 0 then
-- special box
diff --git a/tex/context/base/mkiv/trac-vis.lua b/tex/context/base/mkiv/trac-vis.lua
index 27ec38f42..52ab3e935 100644
--- a/tex/context/base/mkiv/trac-vis.lua
+++ b/tex/context/base/mkiv/trac-vis.lua
@@ -90,6 +90,7 @@ local getnext = nuts.getnext
local getprev = nuts.getprev
local getboth = nuts.getboth
local getdisc = nuts.getdisc
+local getwhd = nuts.getwhd
local hpack_nodes = nuts.hpack
local vpack_nodes = nuts.vpack
@@ -370,7 +371,7 @@ local function sometext(str,layer,color,textcolor,lap) -- we can just paste verb
end
local info = linked_nodes(rule,kern,text)
setlisttransparency(info,c_zero)
- info = new_hlist(info)
+ info = hpack_nodes(info)
local width = getfield(info,"width")
if lap then
info = new_hlist(linked_nodes(new_kern(-width),info))
@@ -472,7 +473,10 @@ local function user(head,current)
return head, current
end
-local m_cache = { }
+local m_cache = {
+ beginmath = { },
+ endmath = { },
+}
local tags = {
beginmath = "B",
endmath = "E",
@@ -480,14 +484,24 @@ local tags = {
local function math(head,current)
local what = getsubtype(current)
- local info = m_cache[what]
+ local tag = mathcodes[what]
+ local skip = getfield(current,"surround") + getfield(current,"width")
+ local info = m_cache[tag][skip]
if info then
-- print("hit math")
else
- local tag = mathcodes[what]
- info = sometext(formatters["M:%s"](tag and tags[tag] or what),usedfont,nil,c_math_d)
+ local text, width = sometext(formatters["M:%s"](tag and tags[tag] or what),usedfont,nil,c_math_d)
+ local rule = new_rule(skip,-655360/fraction,2*655360/fraction)
+ setcolor(rule,c_math_d)
+ settransparency(rule,c_math_d)
+ setattr(rule,a_layer,l_math)
+ if tag == "beginmath" then
+ info = new_hlist(linked_nodes(new_glue(-skip),rule,new_glue(-width),text))
+ else
+ info = new_hlist(linked_nodes(new_glue(-skip),rule,new_glue(-skip),text))
+ end
setattr(info,a_layer,l_math)
- m_cache[what] = info
+ m_cache[tag][skip] = info
end
head, current = insert_node_after(head,current,copy_list(info))
return head, current
@@ -506,10 +520,8 @@ local o_cache = table.setmetatableindex(function(t,size)
end)
local function ruledbox(head,current,vertical,layer,what,simple,previous,trace_origin,parent)
- local wd = getfield(current,"width")
+ local wd, ht, dp = getwhd(current)
if wd ~= 0 then
- local ht = getfield(current,"height")
- local dp = getfield(current,"depth")
local shift = getfield(current,"shift")
local dir = getfield(current,"dir")
-- if dir == "LTL" or dir == "RRT" then
@@ -643,8 +655,7 @@ local function ruledglyph(head,current,previous) -- wrong for vertical glyphs
local wd = getfield(current,"width")
-- local wd = chardata[getfont(current)][getchar(current)].width
if wd ~= 0 then
- local ht = getfield(current,"height")
- local dp = getfield(current,"depth")
+ local wd, ht, dp = getwhd(current)
-- local dir = getfield(current,"dir")
-- if dir == "LTL" or dir = "RTT" then
-- wd, ht, dp = ht + dp, wd, 0
diff --git a/tex/context/base/mkiv/typo-bld.lua b/tex/context/base/mkiv/typo-bld.lua
index 27171bfbd..04cc4db8d 100644
--- a/tex/context/base/mkiv/typo-bld.lua
+++ b/tex/context/base/mkiv/typo-bld.lua
@@ -227,9 +227,8 @@ end
-- check why box is called before after_linebreak .. maybe make categories and
-- call 'm less
-
-- this will be split into contribute_filter for these 4 so at some point
--- thecheck can go away
+-- the check can go away
function builders.buildpage_filter(groupcode)
-- the next check saves 1% runtime on 1000 tufte pages
diff --git a/tex/context/base/mkiv/typo-del.mkiv b/tex/context/base/mkiv/typo-del.mkiv
index 93406bb52..84fe2c469 100644
--- a/tex/context/base/mkiv/typo-del.mkiv
+++ b/tex/context/base/mkiv/typo-del.mkiv
@@ -298,7 +298,7 @@
\typo_delimited_set_language_nop}}
\def\typo_delimited_set_language_yes_b
- {\splitstring\m_delimited_argument\at:\to\outerdelimitedlanguage\and\innerdelimitedlanguage
+ {\splitatcolon\m_delimited_argument\outerdelimitedlanguage\innerdelimitedlanguage
\ifx\outerdelimitedlanguage\empty
\typo_delimited_set_language_nop
\else
diff --git a/tex/context/base/mkiv/typo-drp.lua b/tex/context/base/mkiv/typo-drp.lua
index dd49591f2..0683a3472 100644
--- a/tex/context/base/mkiv/typo-drp.lua
+++ b/tex/context/base/mkiv/typo-drp.lua
@@ -35,6 +35,7 @@ local getid = nuts.getid
local getsubtype = nuts.getsubtype
local getfield = nuts.getfield
local getattr = nuts.getattr
+local getwhd = nuts.getwhd
local setfield = nuts.setfield
local setattr = nuts.setattr
@@ -42,6 +43,7 @@ local setlink = nuts.setlink
local setprev = nuts.setprev
local setnext = nuts.setnext
local setchar = nuts.setchar
+local setwhd = nuts.setwhd
local hpack_nodes = nuts.hpack
@@ -64,6 +66,7 @@ local v_first = variables.first
local v_last = variables.last
local texget = tex.get
+local texset = tex.set
local texsetattribute = tex.setattribute
local unsetvalue = attributes.unsetvalue
@@ -155,8 +158,8 @@ actions[v_default] = function(head,setting)
local distance = setting.distance or 0
local voffset = setting.voffset or 0
local hoffset = setting.hoffset or 0
- local parindent = tex.parindent
- local baseline = texget("baselineskip").width
+ local parindent = texget("parindent")
+ local baseline = texget("baselineskip",false)
local lines = tonumber(setting.n) or 0
local dynamic = setting.dynamic
local font = setting.font
@@ -290,12 +293,8 @@ actions[v_default] = function(head,setting)
setprev(first)
setnext(last)
local dropper = hpack_nodes(first)
- local width = getfield(dropper,"width")
- local height = getfield(dropper,"height")
- local depth = getfield(dropper,"depth")
- setfield(dropper,"width",0)
- setfield(dropper,"height",0)
- setfield(dropper,"depth",0)
+ local width, height, depth = getwhd(dropper)
+ setwhd(dropper,0,0,0)
--
setlink(prev,dropper)
setlink(dropper,next)
@@ -339,8 +338,8 @@ actions[v_default] = function(head,setting)
if trace_initials then
report_initials("setting hangafter to %i and hangindent to %p",hangafter,hangindent)
end
- tex.hangafter = hangafter
- tex.hangindent = hangindent
+ texset("hangafter",hangafter)
+ texset("hangindent",hangindent)
end
if indent then
insert_after(first,first,new_kern(-parindent))
diff --git a/tex/context/base/mkiv/typo-fln.lua b/tex/context/base/mkiv/typo-fln.lua
index bd6d749cc..fcd9b2c1f 100644
--- a/tex/context/base/mkiv/typo-fln.lua
+++ b/tex/context/base/mkiv/typo-fln.lua
@@ -44,7 +44,6 @@ local setattr = nuts.setattr
local getbox = nuts.getbox
local getdisc = nuts.getdisc
local setdisc = nuts.setdisc
-local getdimensions = nuts.dimensions
local setlink = nuts.setlink
local nodecodes = nodes.nodecodes
@@ -58,6 +57,7 @@ local flush_node = nuts.flush_node
local copy_node_list = nuts.copy_list
local insert_node_after = nuts.insert_after
local remove_node = nuts.remove
+local list_dimensions = nuts.dimensions
local nodepool = nuts.pool
local newpenalty = nodepool.penalty
@@ -163,9 +163,9 @@ actions[v_line] = function(head,setting)
end
local function try(extra)
- local width = getdimensions(list,start)
+ local width = list_dimensions(list,start)
if extra then
- width = width + getdimensions(extra)
+ width = width + list_dimensions(extra)
end
if width > hsize then
list = prev
diff --git a/tex/context/base/mkiv/typo-itc.lua b/tex/context/base/mkiv/typo-itc.lua
index 38d4968df..61a1bfe6c 100644
--- a/tex/context/base/mkiv/typo-itc.lua
+++ b/tex/context/base/mkiv/typo-itc.lua
@@ -117,7 +117,7 @@ end
-- todo: clear attribute
local function okay(data,current,font,prevchar,previtalic,char,what)
- if not data then
+ if data then
if trace_italics then
report_italics("ignoring %p between %s italic %C and italic %C",previtalic,what,prevchar,char)
end
@@ -278,7 +278,7 @@ local function texthandler(head)
local previnserted = nil
local pre = nil
- local pretail = nil
+ local pretail = nil
local post = nil
local posttail = nil
diff --git a/tex/context/base/mkiv/typo-lin.lua b/tex/context/base/mkiv/typo-lin.lua
index 10d83661e..119b94cdc 100644
--- a/tex/context/base/mkiv/typo-lin.lua
+++ b/tex/context/base/mkiv/typo-lin.lua
@@ -94,8 +94,6 @@ local setprop = nuts.setprop
local getprop = nuts.rawprop -- getprop
local effectiveglue = nuts.effective_glue
-local n_is_zero_glue = nodes.is_zero_glue
-local n_getglue = nodes.getglue
local nodepool = nuts.pool
local new_kern = nodepool.kern
@@ -106,7 +104,7 @@ local new_rule = nodepool.rule
local new_glue = nodepool.glue
local texgetcount = tex.getcount
-local texgetskip = tex.getskip
+local texgetglue = tex.getglue
local setmetatableindex = table.setmetatableindex
local formatters = string.formatters
@@ -244,8 +242,8 @@ function paragraphs.normalize(head,islocal)
return head, false
end
-- this can become a separate handler but it makes sense to integrate it here
- local parfillleftskip = texgetskip("parfillleftskip")
- if not n_is_zero_glue(parfillleftskip) then
+ local l_width, l_stretch, l_shrink = texgetglue("parfillleftskip")
+ if l_width ~= 0 or l_stretch ~= 0 or l_shrink ~= 0 then
local last = nil -- a nut
local done = false
for line in traverse_id(hlist_code,tonut(head)) do
@@ -265,7 +263,7 @@ function paragraphs.normalize(head,islocal)
current = getnext(current)
end
if current then
- head, current = insert_before(head,current,new_glue(n_getglue(parfillleftskip)))
+ head, current = insert_before(head,current,new_glue(l_width,l_stretch,l_shrink))
if head == current then
setlist(last,head)
end
diff --git a/tex/context/base/mkiv/typo-mar.lua b/tex/context/base/mkiv/typo-mar.lua
index dbf6602e7..680fb20cc 100644
--- a/tex/context/base/mkiv/typo-mar.lua
+++ b/tex/context/base/mkiv/typo-mar.lua
@@ -75,6 +75,7 @@ local getattr = nuts.getattr
local setattr = nuts.setattr
local getsubtype = nuts.getsubtype
local getlist = nuts.getlist
+local getwhd = nuts.getwhd
local setlist = nuts.setlist
local setlink = nuts.setlink
@@ -94,6 +95,8 @@ local vlist_code = nodecodes.vlist
local whatsit_code = nodecodes.whatsit
local userdefined_code = whatsitcodes.userdefined
+local n_flush_node = nodes.flush
+
local nodepool = nuts.pool
local new_usernumber = nodepool.usernumber
@@ -268,16 +271,17 @@ function margins.save(t)
local leftmargindistance = texgetdimen("naturalleftmargindistance")
local rightmargindistance = texgetdimen("naturalrightmargindistance")
local strutbox = getbox("strutbox")
+ local _, strutht, strutdp = getwhd(strutbox)
-- better make a new table and make t entry in t
t.box = content
t.n = nofsaved
-- used later (we will clean up this natural mess later)
-- nice is to make a special status table mechanism
- t.strutdepth = getfield(strutbox,"depth")
- t.strutheight = getfield(strutbox,"height")
- -- beware: can be different from the applied one
- t.leftskip = getfield(texget("leftskip"),"width") -- we're not in forgetall
- t.rightskip = getfield(texget("rightskip"),"width") -- we're not in forgetall
+ t.strutheight = strutht
+ t.strutdepth = strutdp
+ -- beware: can be different from the applied one (we're not in forgetall)
+ t.leftskip = texget("leftskip",false)
+ t.rightskip = texget("rightskip",false)
--
t.leftmargindistance = leftmargindistance -- todo:layoutstatus table
t.rightmargindistance = rightmargindistance
@@ -497,9 +501,8 @@ local function inject(parent,head,candidate)
if not box then
return head, nil, false -- we can have empty texts
end
- local width = getfield(box,"width")
- local height = getfield(box,"height")
- local depth = getfield(box,"depth")
+ local width, height, depth
+ = getwhd(box)
local shift = getfield(box,"shift")
local stack = candidate.stack
local stackname = candidate.stackname
@@ -622,8 +625,9 @@ local function inject(parent,head,candidate)
shift = shift + voffset + delta
end
elseif method == v_line then
- if getfield(parent,"depth") == 0 then
- local delta = height - getfield(parent,"height")
+ local _, ph, pd = getwhd(parent)
+ if pd == 0 then
+ local delta = height - ph
if trace_margindata then
report_margindata("top aligned by %p (no depth)",delta)
end
diff --git a/tex/context/base/mkiv/typo-pag.lua b/tex/context/base/mkiv/typo-pag.lua
index 355becff6..063b5214a 100644
--- a/tex/context/base/mkiv/typo-pag.lua
+++ b/tex/context/base/mkiv/typo-pag.lua
@@ -35,6 +35,7 @@ local getprev = nuts.getprev
local getid = nuts.getid
local getattr = nuts.getattr
local setattr = nuts.setattr
+local getwhd = nuts.getwhd
local insert_node_after = nuts.insert_after
local new_penalty = nuts.pool.penalty
@@ -118,7 +119,8 @@ local function keeptogether(start,a)
while current do
local id = getid(current)
if id == vlist_code or id == hlist_code then
- total = total + getfield(current,"height") + getfield(current,"depth")
+ local wd, ht, dp = getwhd(current)
+ total = total + ht + dp
if trace_keeptogether then
report_keeptogether("%s, index %s, total %p, threshold %p","list",a,total,threshold)
end
diff --git a/tex/context/base/mkiv/typo-sus.lua b/tex/context/base/mkiv/typo-sus.lua
index ce1933330..d3526bb5d 100644
--- a/tex/context/base/mkiv/typo-sus.lua
+++ b/tex/context/base/mkiv/typo-sus.lua
@@ -132,9 +132,9 @@ local function mark(head,current,id,color)
-- head = insert_before(head,current,kern)
-- setcolor(rule,color)
else
- local width = getfield(current,"width")
+ local width, height, depth = getWhd(current)
local extra = fonts.hashes.xheights[getfont(current)] / 2
- local rule = new_rule(width,getfield(current,"height")+extra,getfield(current,"depth")+extra)
+ local rule = new_rule(width,height+extra,depth+extra)
local hlist = new_hlist(rule)
head = insert_before(head,current,hlist)
setcolor(rule,color)
diff --git a/tex/context/base/mkiv/typo-tal.lua b/tex/context/base/mkiv/typo-tal.lua
index 21c6794c4..b3a1601d9 100644
--- a/tex/context/base/mkiv/typo-tal.lua
+++ b/tex/context/base/mkiv/typo-tal.lua
@@ -52,7 +52,7 @@ local setchar = nuts.setchar
local insert_node_before = nuts.insert_before
local insert_node_after = nuts.insert_after
local traverse_list_by_id = nuts.traverse_id
-local dimensions_of_list = nuts.dimensions
+local list_dimensions = nuts.dimensions
local first_glyph = nuts.first_glyph
local setglue = nuts.setglue
@@ -381,8 +381,8 @@ function characteralign.handler(originalhead,where)
end
else
entry = {
- before = b_start and dimensions_of_list(b_start,getnext(b_stop)) or 0,
- after = a_start and dimensions_of_list(a_start,getnext(a_stop)) or 0,
+ before = b_start and list_dimensions(b_start,getnext(b_stop)) or 0,
+ after = a_start and list_dimensions(a_start,getnext(a_stop)) or 0,
}
list[row] = entry
end
diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf
index db1aca861..bf623a1eb 100644
--- a/tex/context/interface/mkiv/i-context.pdf
+++ b/tex/context/interface/mkiv/i-context.pdf
Binary files differ
diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf
index 49433f88f..850c10386 100644
--- a/tex/context/interface/mkiv/i-readme.pdf
+++ b/tex/context/interface/mkiv/i-readme.pdf
Binary files differ
diff --git a/tex/context/interface/mkiv/i-system.xml b/tex/context/interface/mkiv/i-system.xml
index 85c6a25d7..aa12bd779 100644
--- a/tex/context/interface/mkiv/i-system.xml
+++ b/tex/context/interface/mkiv/i-system.xml
@@ -2244,6 +2244,46 @@
</cd:arguments>
</cd:command>
+ <cd:command name="splitatcolon" file="syst-aux.mkiv">
+ <cd:arguments>
+ <cd:resolve name="string-text"/>
+ <cd:csname/>
+ <cd:csname/>
+ </cd:arguments>
+ </cd:command>
+
+ <cd:command name="splitatcomma" file="syst-aux.mkiv">
+ <cd:arguments>
+ <cd:resolve name="string-text"/>
+ <cd:csname/>
+ <cd:csname/>
+ </cd:arguments>
+ </cd:command>
+
+ <cd:command name="splitatasterisk" file="syst-aux.mkiv">
+ <cd:arguments>
+ <cd:resolve name="string-text"/>
+ <cd:csname/>
+ <cd:csname/>
+ </cd:arguments>
+ </cd:command>
+
+ <cd:command name="splitatcolon" file="syst-aux.mkiv">
+ <cd:arguments>
+ <cd:resolve name="string-text"/>
+ <cd:csname/>
+ <cd:csname/>
+ </cd:arguments>
+ </cd:command>
+
+ <cd:command name="splitatcolons" file="syst-aux.mkiv">
+ <cd:arguments>
+ <cd:resolve name="string-text"/>
+ <cd:csname/>
+ <cd:csname/>
+ </cd:arguments>
+ </cd:command>
+
<cd:command name="removesubstring" file="syst-aux.mkiv">
<cd:arguments>
<cd:resolve name="string-text"/>
diff --git a/tex/context/modules/mkiv/s-fonts-coverage.mkiv b/tex/context/modules/mkiv/s-fonts-coverage.mkiv
index c09d943bc..305bb9b7b 100644
--- a/tex/context/modules/mkiv/s-fonts-coverage.mkiv
+++ b/tex/context/modules/mkiv/s-fonts-coverage.mkiv
@@ -38,6 +38,9 @@
[list={texgyrepagella-regular.otf,texgyretermes-regular.otf,texgyrebonum-regular.otf},
pattern=ogonek]
+% \showfontcomparison
+% [list={texgyrepagella-regular.otf,texgyretermes-regular.otf,nimbusroman-regular.afm}]
+
\page
% $e=mc²$ ${}²$ $²$ $x²ᶞ$ $x⁽²⁺²⁼²⁺²⁾$ $x²⁺²⁼²⁺²$ $x₅²$ $x²₅²$
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index cc7ed88ad..3a4a70c62 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 : 01/17/17 17:37:54
+-- merge date : 01/27/17 14:39:39
do -- begin closure to overcome local limits and interference