summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/page-flt.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/page-flt.lua')
-rw-r--r--tex/context/base/mkiv/page-flt.lua45
1 files changed, 31 insertions, 14 deletions
diff --git a/tex/context/base/mkiv/page-flt.lua b/tex/context/base/mkiv/page-flt.lua
index 41a35d47b..b1f729f7a 100644
--- a/tex/context/base/mkiv/page-flt.lua
+++ b/tex/context/base/mkiv/page-flt.lua
@@ -87,22 +87,32 @@ end
local function setdimensions(t,b)
local bw, bh, bd = 0, 0, 0
local nw, nh, nd = 0, 0, 0
+ local cw, ch, cd = 0, 0, 0
if b then
bw = b.width
bh = b.height
bd = b.depth
+ cw = b.cwidth
+ ch = b.cheight
+ cd = b.cdepth
end
if t then
- nw = t.width or bw
- nh = t.height or bh
- nd = t.depth or bd
+ nw = t.width or bw
+ nh = t.height or bh
+ nd = t.depth or bd
+ cw = t.cwidth or cw
+ ch = t.cheight or ch
+ cd = t.cdepth or cd
end
setdimen("global","floatwidth", bw)
setdimen("global","floatheight", bh+bd)
setdimen("global","naturalfloatwd", nw)
setdimen("global","naturalfloatht", nh)
setdimen("global","naturalfloatdp", nd)
- return bw, bh, bd, nw, nh, dp
+ setdimen("global","floatcaptionwd", cw)
+ setdimen("global","floatcaptionht", ch)
+ setdimen("global","floatcaptiondp", cd)
+ return bw, bh, bd, nw, nh, dp, cw, xh, xp
end
local function get(stack,n,bylabel)
@@ -125,19 +135,22 @@ local function get(stack,n,bylabel)
end
end
-function floats.save(which,data)
+function floats.save(which,data) -- todo: just pass
which = which or default
local b = textakebox("floatbox")
if b then
local stack = stacks[which]
noffloats = noffloats + 1
local t = {
- n = noffloats,
- data = data or { },
- width = getdimen("naturalfloatwd"),
- height = getdimen("naturalfloatht"),
- depth = getdimen("naturalfloatdp"),
- box = b,
+ n = noffloats,
+ data = data or { },
+ width = getdimen("naturalfloatwd"),
+ height = getdimen("naturalfloatht"),
+ depth = getdimen("naturalfloatdp"),
+ cwidth = getdimen("floatcaptionwd"),
+ cheight = getdimen("floatcaptionht"),
+ cdepth = getdimen("floatcaptiondp"),
+ box = b,
}
insert(stack,t)
-- inspect(stacks)
@@ -240,11 +253,15 @@ function floats.collect(which,maxwidth,distance)
for i=1,stacksize do
local t, b, n = get(stack,i)
if t then
- local w, h, d, nw = setdimensions(t,b)
+ local w, h, d, nw, nh, nd, cw, ch, cd = setdimensions(t,b)
-- we use the real width
- w = nw
+ if cw > nw then
+ w = cw
+ else
+ w = nw
+ end
-- which could be an option
- local rest = maxwidth - w - (1 == 1 and 0 or distance)
+ local rest = maxwidth - w - distance
local fits = rest > -10
if trace_collecting then
report_collecting("%s, category %a, number %a, slot %a width %p, rest %p, fit %a","collecting",