summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/supp-box.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/supp-box.lua')
-rw-r--r--tex/context/base/mkiv/supp-box.lua31
1 files changed, 31 insertions, 0 deletions
diff --git a/tex/context/base/mkiv/supp-box.lua b/tex/context/base/mkiv/supp-box.lua
index 98d0e0474..bf41899bf 100644
--- a/tex/context/base/mkiv/supp-box.lua
+++ b/tex/context/base/mkiv/supp-box.lua
@@ -38,6 +38,7 @@ 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
@@ -54,6 +55,7 @@ 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
@@ -389,6 +391,35 @@ interfaces.implement {
end
}
+interfaces.implement {
+ name = "getnaturalwd",
+ arguments = "integer",
+ actions = function(n)
+ local w, h, d = 0, 0, 0
+ local l = getlist(getbox(n))
+ if l then
+ w, h, d = dimensions(l)
+ end
+ context("\\dimexpr%i\\scaledpoint\\relax",w)
+ end
+}
+
+local function setboxtonaturalwd(n)
+ local old = takebox(n)
+ local new = hpack(getlist(old))
+ setlist(old,nil)
+ free_node(old)
+ setbox(n,new)
+end
+
+interfaces.implement {
+ name = "setnaturalwd",
+ arguments = "integer",
+ actions = setboxtonaturalwd
+}
+
+nodes.setboxtonaturalwd = setboxtonaturalwd
+
local function firstdirinbox(n)
local b = getbox(n)
if b then