diff options
author | Marius <mariausol@gmail.com> | 2013-04-09 12:00:15 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2013-04-09 12:00:15 +0300 |
commit | 251d12e210b11448060dbc337bf4a4020802d200 (patch) | |
tree | 0ab1a414eabc4ca6981b5df49b9dc2e7cf62956f /tex/context/base/pack-rul.lua | |
parent | 0dba00ac9e85c9a82b8fc67bfd89cd993ff343fc (diff) | |
download | context-251d12e210b11448060dbc337bf4a4020802d200.tar.gz |
beta 2013.04.09 10:45
Diffstat (limited to 'tex/context/base/pack-rul.lua')
-rw-r--r-- | tex/context/base/pack-rul.lua | 74 |
1 files changed, 67 insertions, 7 deletions
diff --git a/tex/context/base/pack-rul.lua b/tex/context/base/pack-rul.lua index cd2e809e7..c91dec09c 100644 --- a/tex/context/base/pack-rul.lua +++ b/tex/context/base/pack-rul.lua @@ -14,7 +14,66 @@ local texsetdimen, texsetcount, texbox = tex.setdimen, tex.setcount, tex.box local hpack, free, copy, traverse_id = node.hpack, node.free, node.copy_list, node.traverse_id local texdimen, texcount = tex.dimen, tex.count --- fastrepack +local hlist_code = nodes.nodecodes.hlist +local node_dimensions = node.dimensions + +-- function commands.doreshapeframedbox(n) +-- local box = texbox[n] +-- local noflines = 0 +-- local firstheight = nil +-- local lastdepth = nil +-- local lastlinelength = 0 +-- local minwidth = 0 +-- local maxwidth = 0 +-- local totalwidth = 0 +-- if box.width ~= 0 then +-- local list = box.list +-- if list then +-- for h in traverse_id(hlist_code,list) do -- no dir etc needed +-- if not firstheight then +-- firstheight = h.height +-- end +-- lastdepth = h.depth +-- noflines = noflines + 1 +-- local l = h.list +-- if l then +-- local p = hpack(copy(l)) +-- lastlinelength = p.width +-- if lastlinelength > maxwidth then +-- maxwidth = lastlinelength +-- end +-- if lastlinelength < minwidth or minwidth == 0 then +-- minwidth = lastlinelength +-- end +-- totalwidth = totalwidth + lastlinelength +-- free(p) +-- end +-- end +-- if firstheight then +-- if maxwidth ~= 0 then +-- for h in traverse_id(hlist_code,list) do +-- local l = h.list +-- if l then +-- -- if h.width ~= maxwidth then -- else no display math handling (uses shift) +-- h.list = hpack(l,maxwidth,'exactly',h.dir) +-- h.shift = 0 -- needed for display math +-- h.width = maxwidth +-- -- end +-- end +-- end +-- end +-- box.width = maxwidth +-- end +-- end +-- end +-- -- print("reshape", noflines, firstheight or 0, lastdepth or 0) +-- texsetcount("global","framednoflines", noflines) +-- texsetdimen("global","framedfirstheight", firstheight or 0) +-- texsetdimen("global","framedlastdepth", lastdepth or 0) +-- texsetdimen("global","framedminwidth", minwidth) +-- texsetdimen("global","framedmaxwidth", maxwidth) +-- texsetdimen("global","framedaveragewidth", noflines > 0 and totalwidth/noflines or 0) +-- end function commands.doreshapeframedbox(n) local box = texbox[n] @@ -28,7 +87,7 @@ function commands.doreshapeframedbox(n) if box.width ~= 0 then local list = box.list if list then - for h in traverse_id('hlist',list) do -- no dir etc needed + for h in traverse_id(hlist_code,list) do -- no dir etc needed if not firstheight then firstheight = h.height end @@ -36,8 +95,7 @@ function commands.doreshapeframedbox(n) noflines = noflines + 1 local l = h.list if l then - local p = hpack(copy(l)) - lastlinelength = p.width + lastlinelength = node_dimensions(l) if lastlinelength > maxwidth then maxwidth = lastlinelength end @@ -45,15 +103,17 @@ function commands.doreshapeframedbox(n) minwidth = lastlinelength end totalwidth = totalwidth + lastlinelength - free(p) end end if firstheight then if maxwidth ~= 0 then - for h in traverse_id('hlist',list) do + for h in traverse_id(hlist_code,list) do local l = h.list if l then -- if h.width ~= maxwidth then -- else no display math handling (uses shift) + -- challenge: adapt glue_set + -- h.glue_set = h.glue_set * h.width/maxwidth -- interesting ... doesn't matter much + -- h.width = maxwidth h.list = hpack(l,maxwidth,'exactly',h.dir) h.shift = 0 -- needed for display math h.width = maxwidth @@ -82,7 +142,7 @@ function commands.doanalyzeframedbox(n) if box.width ~= 0 then local list = box.list if list then - for h in traverse_id('hlist',list) do + for h in traverse_id(hlist_code,list) do if not firstheight then firstheight = h.height end |