summaryrefslogtreecommitdiff
path: root/tex/context/base/spac-ver.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2011-03-29 12:49:00 +0200
committerHans Hagen <pragma@wxs.nl>2011-03-29 12:49:00 +0200
commit28621e7ae94bca4954eecd07da1d542711daeb18 (patch)
treea71bc7bc0e6d86c301459be4a8681f5a714853aa /tex/context/base/spac-ver.lua
parent1a2108ffa6b5808b0117aee0e6ff26d4503a06e2 (diff)
downloadcontext-28621e7ae94bca4954eecd07da1d542711daeb18.tar.gz
beta 2011.03.29 12:49
Diffstat (limited to 'tex/context/base/spac-ver.lua')
-rw-r--r--tex/context/base/spac-ver.lua31
1 files changed, 27 insertions, 4 deletions
diff --git a/tex/context/base/spac-ver.lua b/tex/context/base/spac-ver.lua
index a734c5f38..5d016eb7b 100644
--- a/tex/context/base/spac-ver.lua
+++ b/tex/context/base/spac-ver.lua
@@ -246,6 +246,25 @@ local function already_done(parentid,list,a_snapmethod) -- todo: done when only
return false
end
+
+-- quite tricky: ceil(-something) => -0
+
+local function ceiled(n)
+ if n < 0 or n < 0.01 then
+ return 0
+ else
+ return ceil(n)
+ end
+end
+
+local function lower(n)
+ if n < 0 or n < 0.01 then
+ return 0
+ else
+ return floored(n)
+ end
+end
+
local function snap_hlist(where,current,method,height,depth) -- method.strut is default
local list = current.list
--~ print(table.serialize(method))
@@ -384,12 +403,14 @@ h, d = ch, cd
--~ -- first or last
--~ else
if method.minheight then
- ch = max(floor((h-hr*snapht)/snaphtdp),0)*snaphtdp + plusht
+ -- ch = max(floor((h-hr*snapht)/snaphtdp),0)*snaphtdp + plusht
+ ch = floored((h-hr*snapht)/snaphtdp)*snaphtdp + plusht
if t then
t[#t+1] = format("minheight: %s",points(ch))
end
elseif method.maxheight then
- ch = max(ceil((h-hr*snapht)/snaphtdp),0)*snaphtdp + plusht
+ -- ch = max(ceil((h-hr*snapht)/snaphtdp),0)*snaphtdp + plusht
+ ch = ceiled((h-hr*snapht)/snaphtdp)*snaphtdp + plusht
if t then
t[#t+1] = format("maxheight: %s",points(ch))
end
@@ -403,12 +424,14 @@ h, d = ch, cd
--~ -- first or last
--~ else
if method.mindepth then
- cd = max(floor((d-dr*snapdp)/snaphtdp),0)*snaphtdp + plusdp
+ -- cd = max(floor((d-dr*snapdp)/snaphtdp),0)*snaphtdp + plusdp
+ cd = floored((d-dr*snapdp)/snaphtdp)*snaphtdp + plusdp
if t then
t[#t+1] = format("mindepth: %s",points(cd))
end
elseif method.maxdepth then
- cd = max(ceil((d-dr*snapdp)/snaphtdp),0)*snaphtdp + plusdp
+ -- cd = max(ceil((d-dr*snapdp)/snaphtdp),0)*snaphtdp + plusdp
+ cd = ceiled((d-dr*snapdp)/snaphtdp)*snaphtdp + plusdp
if t then
t[#t+1] = format("maxdepth: %s",points(cd))
end