diff options
author | Marius <mariausol@gmail.com> | 2011-03-29 14:20:13 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2011-03-29 14:20:13 +0300 |
commit | 67f847d4e7a4d05d95453df7b2285b41f6d72e2e (patch) | |
tree | 3a25514607d7c081e0cfab3f221964cc36ab3211 /tex/context/base/spac-ver.lua | |
parent | b83a2fdcd776ef22f96e4412e35953972834051e (diff) | |
download | context-67f847d4e7a4d05d95453df7b2285b41f6d72e2e.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.lua | 31 |
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 |