diff options
author | Karl Berry <karl@freefriends.org> | 2017-04-19 23:04:15 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-04-19 23:04:15 +0000 |
commit | f74161ca4e7eb3c5af9afcbe92522ae3b58987c1 (patch) | |
tree | 3c30a13df5ac7968195c85070a2b074578e669d2 /Master/texmf-dist/tex/context/base/mkiv/node-acc.lua | |
parent | 1d5a55ac8f5506a7ae9cfca52f4b588182e199d4 (diff) |
context beta/cont-tmf.zip (Apr 16 12:55)
git-svn-id: svn://tug.org/texlive/trunk@43931 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/node-acc.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/node-acc.lua | 114 |
1 files changed, 47 insertions, 67 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-acc.lua b/Master/texmf-dist/tex/context/base/mkiv/node-acc.lua index ed34dbec939..dccd7b7c003 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/node-acc.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/node-acc.lua @@ -8,92 +8,72 @@ if not modules then modules = { } end modules ['node-acc'] = { local nodes, node = nodes, node -local nodecodes = nodes.nodecodes -local tasks = nodes.tasks - -local nuts = nodes.nuts -local tonut = nodes.tonut -local tonode = nodes.tonode - -local getid = nuts.getid -local getfield = nuts.getfield -local getattr = nuts.getattr -local getlist = nuts.getlist -local getchar = nuts.getchar -local getnext = nuts.getnext - -local setfield = nuts.setfield -local setattr = nuts.setattr -local setlink = nuts.setlink -local setchar = nuts.setchar -local setsubtype = nuts.setsubtype - -local traverse_nodes = nuts.traverse -local traverse_id = nuts.traverse_id -local copy_node = nuts.copy -local free_nodelist = nuts.flush_list -local insert_after = nuts.insert_after - -local glue_code = nodecodes.glue -local kern_code = nodecodes.kern -local glyph_code = nodecodes.glyph -local hlist_code = nodecodes.hlist -local vlist_code = nodecodes.vlist - -local a_characters = attributes.private("characters") - -local threshold = 65536 -- not used -local nofreplaced = 0 +local nodecodes = nodes.nodecodes +local tasks = nodes.tasks + +local nuts = nodes.nuts +local tonut = nodes.tonut +local tonode = nodes.tonode + +local getid = nuts.getid +local getfield = nuts.getfield +local getattr = nuts.getattr +local getlist = nuts.getlist +local getchar = nuts.getchar +local getnext = nuts.getnext + +local setfield = nuts.setfield +local setattr = nuts.setattr +local setlink = nuts.setlink +local setchar = nuts.setchar +local setsubtype = nuts.setsubtype +local getwidth = nuts.getwidth +local setwidth = nuts.setwidth + +----- traverse_nodes = nuts.traverse +local traverse_id = nuts.traverse_id +----- copy_node = nuts.copy +local insert_after = nuts.insert_after +local copy_no_components = nuts.copy_no_components + +local glue_code = nodecodes.glue +----- kern_code = nodecodes.kern +local glyph_code = nodecodes.glyph +local hlist_code = nodecodes.hlist +local vlist_code = nodecodes.vlist + +local a_characters = attributes.private("characters") + +local threshold = 65536 -- not used +local nofreplaced = 0 -- todo: nbsp etc --- todo: collapse kerns - --- p_id +-- todo: collapse kerns (not needed, backend does this) +-- todo: maybe cache as we now create many nodes +-- todo: check for subtype related to spacing (13/14 but most seems to be user anyway) local function injectspaces(head) local p, p_id local n = head while n do local id = getid(n) - if id == glue_code then -- todo: check for subtype related to spacing (13/14 but most seems to be 0) - -- if getfield(n,."width") > 0 then -- threshold - -- if p and p_id == glyph_code then + if id == glue_code then if p and getid(p) == glyph_code then - local g = copy_node(p) - local c = getfield(g,"components") - if c then -- it happens that we copied a ligature - free_nodelist(c) - setfield(g,"components",nil) - setsubtype(g,256) - end + -- unless we don't care about the little bit of overhead + -- we can just: local g = copy_node(g) + local g = copy_no_components(p) local a = getattr(n,a_characters) setchar(g,32) - setlink(p,g) - setlink(g,n) --- we could cache as we now create many nodes - setfield(n,"width",getfield(n,"width") - getfield(g,"width")) + setlink(p,g,n) + setwidth(n,getwidth(n) - getwidth(g)) if a then setattr(g,a_characters,a) end setattr(n,a_characters,0) nofreplaced = nofreplaced + 1 end - -- end elseif id == hlist_code or id == vlist_code then injectspaces(getlist(n),attribute) - -- elseif id == kern_code then -- the backend already collapses - -- local first = n - -- while true do - -- local nn = getnext(n) - -- if nn and getid(nn) == kern_code then - -- -- maybe we should delete kerns but who cares at this stage - -- setfield(first,"kern",getfield(first,"kern") + getfield(nn,"kern") - -- setfield(nn,"kern",0) - -- n = nn - -- else - -- break - -- end - -- end end p_id = id p = n |