From 7ecbcaaf68d152851591dbb5931a6eb15d155019 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Mon, 25 Nov 2019 23:15:50 +0100 Subject: 2019-11-25 17:37:00 --- tex/context/base/mkiv/driv-shp.lua | 121 ++++++++++++++++++++++++------------- 1 file changed, 80 insertions(+), 41 deletions(-) (limited to 'tex/context/base/mkiv/driv-shp.lua') diff --git a/tex/context/base/mkiv/driv-shp.lua b/tex/context/base/mkiv/driv-shp.lua index 2d242b1a1..5e4d9a29a 100644 --- a/tex/context/base/mkiv/driv-shp.lua +++ b/tex/context/base/mkiv/driv-shp.lua @@ -54,8 +54,9 @@ local findtail = nuts.tail local nextdir = nuts.traversers.dir local nextnode = nuts.traversers.node -local rangedimensions = node.direct.rangedimensions +local rangedimensions = node.direct.rangedimensions -- nuts ? local effectiveglue = nuts.effective_glue +local start_of_par = nuts.start_of_par local texget = tex.get @@ -423,21 +424,23 @@ local function reset_state() -- page_v_origin = 0 -- trueinch end -local function dirstackentry(t,k) - local v = { - cur_h = 0, - cur_v = 0, - ref_h = 0, - ref_v = 0, - } - t[k] = v - return v -end - +-- local function dirstackentry(t,k) +-- local v = { +-- cur_h = 0, +-- cur_v = 0, +-- ref_h = 0, +-- ref_v = 0, +-- } +-- t[k] = v +-- return v +-- end + +----- dirstack = { } local dirstack = setmetatableindex(dirstackentry) local function reset_dir_stack() - dirstack = setmetatableindex(dirstackentry) + -- dirstack = setmetatableindex(dirstackentry) + dirstack = { } end local function flushlatelua(current,h,v) @@ -802,38 +805,69 @@ local hlist_out, vlist_out do local dir, cancel = getdirection(current) if cancel then local ds = dirstack[current] - ref_h = ds.ref_h - ref_v = ds.ref_v - cur_h = ds.cur_h - cur_v = ds.cur_v - pos_r = dir - else - local enddir, width = calculate_width_to_enddir(this_box,current) - local ds = dirstack[enddir] - ds.cur_h = cur_h + width - if dir ~= pos_r then + if ds then + ref_h = ds.ref_h + ref_v = ds.ref_v cur_h = ds.cur_h - end - if enddir ~= current then - local ds = dirstack[enddir] - ds.cur_v = cur_v - ds.ref_h = ref_h - ds.ref_v = ref_v - setdirection(enddir,pos_r) - end - if pos_r == righttoleft_code then - pos_h = ref_h - cur_h + cur_v = ds.cur_v else - pos_h = ref_h + cur_h + -- pardir end - pos_v = ref_v - cur_v - -- synced - ref_h = pos_h - ref_v = pos_v - cur_h = 0 - cur_v = 0 pos_r = dir - end + else +-- local enddir, width = calculate_width_to_enddir(this_box,current) +-- local ds = dirstack[enddir] +-- ds.cur_h = cur_h + width +-- if dir ~= pos_r then +-- cur_h = ds.cur_h +-- end +-- if enddir ~= current then +-- -- local ds = dirstack[enddir] +-- ds.cur_v = cur_v +-- ds.ref_h = ref_h +-- ds.ref_v = ref_v +-- setdirection(enddir,pos_r) +-- end +-- if pos_r == righttoleft_code then +-- pos_h = ref_h - cur_h +-- else +-- pos_h = ref_h + cur_h +-- end +-- pos_v = ref_v - cur_v +-- -- synced +-- ref_h = pos_h +-- ref_v = pos_v +-- cur_h = 0 +-- cur_v = 0 +-- pos_r = dir +-- end +local enddir, width = calculate_width_to_enddir(this_box,current) +local new_h = cur_h + width +if dir ~= pos_r then + cur_h = new_h +end +if enddir ~= current then + dirstack[enddir] = { + cur_h = new_h, + cur_v = cur_v, + ref_h = ref_h, + ref_v = ref_v, + } + setdirection(enddir,pos_r) +end +if pos_r == righttoleft_code then + pos_h = ref_h - cur_h +else + pos_h = ref_h + cur_h +end +pos_v = ref_v - cur_v +-- synced +ref_h = pos_h +ref_v = pos_v +cur_h = 0 +cur_v = 0 +pos_r = dir +end elseif id == whatsit_code then if subtype == literalwhatsit_code then flushliteral(current,pos_h,pos_v) @@ -857,6 +891,11 @@ local hlist_out, vlist_out do end elseif id == marginkern_code then cur_h = cur_h + getkern(current) +-- elseif id == localpar_code and start_of_par(current) then +-- local pardir = getdirection(current) or lefttoright_code +-- if pardir == righttoleft_code then +-- end +-- end end -- There is no gain in skipping over this when we have zero progression -- and such. -- cgit v1.2.3