summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/spac-prf.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/spac-prf.lua')
-rw-r--r--tex/context/base/mkiv/spac-prf.lua147
1 files changed, 76 insertions, 71 deletions
diff --git a/tex/context/base/mkiv/spac-prf.lua b/tex/context/base/mkiv/spac-prf.lua
index 4cd39336e..841e5d271 100644
--- a/tex/context/base/mkiv/spac-prf.lua
+++ b/tex/context/base/mkiv/spac-prf.lua
@@ -34,13 +34,9 @@ local leaders_code = gluecodes.leaders
local lineskip_code = gluecodes.lineskip
local baselineskip_code = gluecodes.baselineskip
local line_code = listcodes.line
-local parskip_code = listcodes.parskip
local texlists = tex.lists
-local gettexdimen = tex.getdimen
local settexattribute = tex.setattribute
-local settexbox = tex.setbox
-local taketexbox = tex.takebox
local nuts = nodes.nuts
local tonut = nodes.tonut
@@ -54,11 +50,23 @@ local getprev = nuts.getprev
local getsubtype = nuts.getsubtype
local getlist = nuts.getlist
local gettexbox = nuts.getbox
+local getwhd = nuts.getwhd
+local getglue = nuts.getglue
+local getkern = nuts.getkern
+local getshift = nuts.getshift
+local getwidth = nuts.getwidth
+local getheight = nuts.getheight
+local getdepth = nuts.getdepth
local setfield = nuts.setfield
local setlink = nuts.setlink
local setlist = nuts.setlist
local setattr = nuts.setattr
+local setwhd = nuts.setwhd
+local setshift = nuts.setshift
+local setwidth = nuts.setwidth
+local setheight = nuts.setheight
+local setdepth = nuts.setdepth
local properties = nodes.properties.data
local setprop = nuts.setprop
@@ -72,7 +80,6 @@ local new_rule = nuts.pool.rule
local new_glue = nuts.pool.glue
local new_kern = nuts.pool.kern
local hpack_nodes = nuts.hpack
-local link_nodes = nuts.link
local find_node_tail = nuts.tail
local setglue = nuts.setglue
@@ -89,6 +96,8 @@ local v_strict = variables.strict
local setcolor = nodes.tracers.colors.set
local settransparency = nodes.tracers.transparencies.set
+local enableaction = nodes.tasks.enableaction
+
local profiling = { }
builders.profiling = profiling
@@ -120,7 +129,7 @@ local function getprofile(line,step)
local step = step or 65536 -- * 2 -- 2pt
local margin = step / 4
local min = 0
- local max = ceiling(getfield(line,"width")/step) + 1
+ local max = ceiling(getwidth(line)/step) + 1
for i=min,max do
heights[i] = 0
@@ -166,12 +175,10 @@ 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")
+ wd = getkern(current)
ht = 0
dp = 0
progress()
@@ -181,20 +188,26 @@ local function getprofile(line,step)
process(replace)
end
elseif id == glue_code then
- wd = getfield(current,"width")
+ local width, stretch, shrink, stretch_order, shrink_order = getglue(current)
if glue_sign == 1 then
- if getfield(current,"stretch_order") == glue_order then
- wd = wd + getfield(current,"stretch") * glue_set
+ if stretch_order == glue_order then
+ wd = width + stretch * glue_set
+ else
+ wd = width
end
elseif glue_sign == 2 then
- if getfield(current,"shrink_order") == glue_order then
- wd = wd - getfield(current,"shrink") * glue_set
+ if shrink_order == glue_order then
+ wd = width - shrink * glue_set
+ else
+ wd = width
end
+ else
+ wd = width
end
if getsubtype(current) >= leaders_code then
local leader = getleader(current)
- ht = getfield(leader,"height")
- dp = getfield(leader,"depth")
+ local w
+ w, ht, dp = getwhd(leader) -- can become getwhd(current) after 1.003
else
ht = 0
dp = 0
@@ -202,36 +215,34 @@ local function getprofile(line,step)
progress()
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 shift = getshift(current)
+ 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
+ local shift = getshift(current) -- todo
+ 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 = getkern(current) + getwidth(current) -- surround
ht = 0
dp = 0
progress()
elseif id == marginkern_code then
- wd = getfield(current,"width")
+ wd = getwidth(current)
ht = 0
dp = 0
progress()
@@ -300,19 +311,15 @@ local function addstring(height,depth)
local dptext = depth
local httext = typesetters.tohpack(height,infofont)
local dptext = typesetters.tohpack(depth,infofont)
- setfield(httext,"shift",- 1.2 * exheight)
- setfield(dptext,"shift", 0.6 * exheight)
- local text = nuts.hpack(
- nuts.linked(
- new_kern(-getfield(httext,"width")-emwidth),
- httext,
- new_kern(-getfield(dptext,"width")),
- dptext
- )
- )
- setfield(text,"height",0)
- setfield(text,"depth",0)
- setfield(text,"width",0)
+ setshift(httext,- 1.2 * exheight)
+ setshift(dptext, 0.6 * exheight)
+ local text = hpack_nodes(setlink(
+ new_kern(-getwidth(httext)-emwidth),
+ httext,
+ new_kern(-getwidth(dptext)),
+ dptext
+ ))
+ setwhd(text,0,0,0)
return text
end
@@ -389,15 +396,13 @@ 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
--
-- local text = addstring(
- -- formatters["%0.4f"](getfield(rule,"height")/65536),
- -- formatters["%0.4f"](getfield(rule,"depth") /65536)
+ -- formatters["%0.4f"](getheight(rule)/65536),
+ -- formatters["%0.4f"](getdepth(rule) /65536)
-- )
--
-- setlink(text,rule)
@@ -486,8 +491,8 @@ methods[v_strict] = function(top,bot,t_profile,b_profile,specification)
local strutdp = specification.depth or texdimen.strutdp
local lineheight = strutht + strutdp
- local depth = getfield(top,"depth")
- local height = getfield(bot,"height")
+ local depth = getdepth(top)
+ local height = getheight(bot)
local total = depth + height
local distance = specification.distance or 0
local delta = lineheight - total
@@ -522,8 +527,8 @@ methods[v_fixed] = function(top,bot,t_profile,b_profile,specification)
local strutdp = specification.depth or texdimen.strutdp
local lineheight = strutht + strutdp
- local depth = getfield(top,"depth")
- local height = getfield(bot,"height")
+ local depth = getdepth(top)
+ local height = getheight(bot)
local total = depth + height
local distance = specification.distance or 0
local delta = lineheight - total
@@ -535,8 +540,8 @@ methods[v_fixed] = function(top,bot,t_profile,b_profile,specification)
-- no distance (yet)
if delta < lineheight then
- setfield(top,"depth",strutdp)
- setfield(bot,"height",strutht)
+ setdepth(top,strutdp)
+ setheight(bot,strutht)
return true
end
@@ -547,13 +552,13 @@ methods[v_fixed] = function(top,bot,t_profile,b_profile,specification)
depth = depth - lineheight
dp = dp + lineheight
end
- setfield(top,"depth",dp)
+ setdepth(top,dp)
local ht = strutht
while height > lineheight - strutht do
height = height - lineheight
ht = ht + lineheight
end
- setfield(bot,"height",ht)
+ setheight(bot,ht)
local lines = floor(delta/lineheight)
if lines > 0 then
inject(top,bot,-lines * lineheight)
@@ -564,17 +569,17 @@ methods[v_fixed] = function(top,bot,t_profile,b_profile,specification)
end
if total < lineheight then
- setfield(top,"depth",strutdp)
- setfield(bot,"height",strutht)
+ setdepth(top,strutdp)
+ setheight(bot,strutht)
return true
end
if depth < strutdp then
- setfield(top,"depth",strutdp)
+ setdepth(top,strutdp)
total = total - depth + strutdp
end
if height < strutht then
- setfield(bot,"height",strutht)
+ setheight(bot,strutht)
total = total - height + strutht
end
@@ -674,7 +679,7 @@ local function profilelist(line,mvl)
end
break
elseif id == glue_code then
- local wd = getfield(current,"width")
+ local wd = getwidth(current)
if not wd or wd == 0 then
-- go on
else
@@ -748,7 +753,7 @@ local function profilelist(line,mvl)
if top then
local subtype = getsubtype(current)
-- if subtype == lineskip_code or subtype == baselineskip_code then
- local wd = getfield(current,"width")
+ local wd = getwidth(current)
if wd > 0 then
distance = wd
lastglue = current
@@ -792,9 +797,9 @@ local enabled = false
function profiling.set(specification)
if not enabled then
- nodes.tasks.enableaction("mvlbuilders", "builders.profiling.pagehandler")
+ enableaction("mvlbuilders", "builders.profiling.pagehandler")
-- too expensive so we expect that this happens explicitly, we keep for reference:
- -- nodes.tasks.enableaction("vboxbuilders","builders.profiling.vboxhandler")
+ -- enableaction("vboxbuilders","builders.profiling.vboxhandler")
enabled = true
end
local n = #specifications + 1
@@ -853,7 +858,7 @@ function profiling.profilebox(specification)
local subtype = getsubtype(current)
if subtype == lineskip_code or subtype == baselineskip_code then
if top then
- local wd = getfield(current,"width")
+ local wd = getwidth(current)
if wd > 0 then
distance = wd
lastglue = current
@@ -889,12 +894,12 @@ function profiling.profilebox(specification)
end
-local ignore = table.tohash {
- "split_keep",
- "split_off",
- -- "vbox",
-}
-
+-- local ignore = table.tohash {
+-- "split_keep",
+-- "split_off",
+-- -- "vbox",
+-- }
+--
-- function profiling.vboxhandler(head,where)
-- if head and not ignore[where] then
-- local h = tonut(head)