summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/spac-prf.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2017-02-17 10:31:56 +0100
committerContext Git Mirror Bot <phg42.2a@gmail.com>2017-02-17 10:31:56 +0100
commitb14f992ef5f4e868c9959b174278c86516d60dbc (patch)
tree28587bb46c025ea7b0d27ba93f09c93dcf53c73a /tex/context/base/mkiv/spac-prf.lua
parent95a1799032dc61dbca4a11e495be34b4397c8fec (diff)
downloadcontext-b14f992ef5f4e868c9959b174278c86516d60dbc.tar.gz
2017-02-17 10:23:00
Diffstat (limited to 'tex/context/base/mkiv/spac-prf.lua')
-rw-r--r--tex/context/base/mkiv/spac-prf.lua100
1 files changed, 58 insertions, 42 deletions
diff --git a/tex/context/base/mkiv/spac-prf.lua b/tex/context/base/mkiv/spac-prf.lua
index f89d836d8..841e5d271 100644
--- a/tex/context/base/mkiv/spac-prf.lua
+++ b/tex/context/base/mkiv/spac-prf.lua
@@ -51,12 +51,22 @@ 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
@@ -86,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
@@ -117,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,7 +178,7 @@ local function getprofile(line,step)
wd, ht, dp = getwhd(current)
progress()
elseif id == kern_code then
- wd = getfield(current,"kern")
+ wd = getkern(current)
ht = 0
dp = 0
progress()
@@ -176,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
@@ -197,7 +215,7 @@ 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")
+ local shift = getshift(current)
local w, h, d = getwhd(current)
-- if getattr(current,a_specialcontent) then
if getprop(current,"specialcontent") then
@@ -212,19 +230,19 @@ local function getprofile(line,step)
end
progress()
elseif id == vlist_code or id == unset_code then
- local shift = getfield(current,"shift") -- todo
+ local shift = getshift(current) -- todo
wd, ht, dp = getwhd(current)
progress()
elseif id == rule_code then
wd, ht, dp = getwhd(current)
progress()
elseif id == math_code then
- wd = getfield(current,"surround") + getfield(current,"width")
+ 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()
@@ -293,16 +311,14 @@ 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
- )
- )
+ 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
@@ -385,8 +401,8 @@ local function addprofile(node,profile,step)
-- 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)
@@ -475,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
@@ -511,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
@@ -524,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
@@ -536,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)
@@ -553,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
@@ -663,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
@@ -737,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
@@ -781,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
@@ -842,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