From f6e7648f6126ffe087071531f03c674be32930f1 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Tue, 20 Aug 2019 19:19:52 +0200 Subject: 2019-08-20 17:28:00 --- tex/context/base/mkiv/driv-shp.lua | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 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 18f910225..ae99d84ce 100644 --- a/tex/context/base/mkiv/driv-shp.lua +++ b/tex/context/base/mkiv/driv-shp.lua @@ -43,6 +43,7 @@ local getboxglue = nuts.getboxglue local getexpansion = nuts.getexpansion local getreplace = nuts.getreplace local setreplace = nuts.setreplace +local getfont = nuts.getfont local setdirection = nuts.setdirection local setfield = nuts.setfield @@ -66,6 +67,7 @@ local parameters = fonthashes.parameters local nodecodes = nodes.nodecodes local whatsitcodes = nodes.whatsitcodes local leadercodes = nodes.leadercodes +local gluecodes = nodes.gluecodes local dircodes = nodes.dircodes local dirvalues = nodes.dirvalues local subtypes = nodes.subtypes @@ -94,6 +96,8 @@ local cleaders_code = leadercodes.cleaders local xleaders_code = leadercodes.xleaders local gleaders_code = leadercodes.gleaders +local spaceskip_code = gluecodes.spaceskip + local saveposwhatsit_code = whatsitcodes.savepos local userdefinedwhatsit_code = whatsitcodes.userdefined local openwhatsit_code = whatsitcodes.open @@ -170,6 +174,10 @@ local level = 0 local nesting = 0 local main = 0 +-- experiment (smaller page stream but might be fragile) + +local tospace = false directives.register("backends.spaces", function(v) tospace = v end) + -- todo: cache streams local function flush_vf_packet(pos_h,pos_v,pos_r,font,char,data,factor,vfcommands) @@ -532,7 +540,8 @@ local hlist_out, vlist_out do pos_v = ref_v - (cur_v - y_offset) -- synced end - local wd, ht, dp = flush_character(current,font,char,false,true,pos_h,pos_v,pos_r) + -- local wd, ht, dp = flush_character(current,font,char,false,true,pos_h,pos_v,pos_r) + local wd = flush_character(current,font,char,false,true,pos_h,pos_v,pos_r) cur_h = cur_h + wd elseif id == glue_code then local gluewidth = effectiveglue(current,this_box) @@ -564,7 +573,6 @@ local hlist_out, vlist_out do gluewidth = gluewidth + 10 local edge = cur_h + gluewidth local lx = 0 - -- local subtype = getsubtype(current) if subtype == gleaders_code then local save_h = cur_h if pos_r == righttoleft_code then @@ -628,6 +636,10 @@ local hlist_out, vlist_out do cur_h = cur_h + gluewidth end else + if tospace and subtype == spaceskip_code then + -- todo: flush_space + flush_character(false,getfont(current),32,false,true,pos_h,pos_v,pos_r) + end cur_h = cur_h + gluewidth end end @@ -757,10 +769,9 @@ local hlist_out, vlist_out do cur_h = cur_h + effectiveglue(current,this_box) -- end elseif id == dir_code then - -- we normally have proper begin-end pairs - -- a begin without end is (silently) handled - -- an end without a begin will be (silently) skipped - -- we only need to move forward so a faster calculation + -- We normally have proper begin-end pairs. A begin without end is (silently) handled + -- and an end without a begin will be (silently) skipped we only need to move forward + -- so we then have a faster calculation. local dir, cancel = getdirection(current) if cancel then local ds = dirstack[current] @@ -820,6 +831,8 @@ local hlist_out, vlist_out do elseif id == marginkern_code then cur_h = cur_h + getkern(current) end + -- There is no gain in skipping over this when we have zero progression + -- and such. if pos_r == righttoleft_code then pos_h = ref_h - cur_h else -- cgit v1.2.3