summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/node-acc.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/node-acc.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/node-acc.lua63
1 files changed, 46 insertions, 17 deletions
diff --git a/Master/texmf-dist/tex/context/base/node-acc.lua b/Master/texmf-dist/tex/context/base/node-acc.lua
index 53740592102..d91bb921b69 100644
--- a/Master/texmf-dist/tex/context/base/node-acc.lua
+++ b/Master/texmf-dist/tex/context/base/node-acc.lua
@@ -14,40 +14,69 @@ local tasks = nodes.tasks
local traverse_nodes = node.traverse
local traverse_id = node.traverse_id
local has_attribute = node.has_attribute
+local set_attribute = node.set_attribute
local copy_node = node.copy
local free_nodelist = node.flush_list
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
+
+-- todo: nbsp etc
+-- todo: collapse kerns
+
local function injectspaces(head)
local p
- for n in traverse_nodes(head) do
+ local n = head
+ while n do
local id = n.id
if id == glue_code then -- todo: check for subtype related to spacing (13/14 but most seems to be 0)
- -- local at = has_attribute(n,attribute)
- -- if at then
- if p and p.id == glyph_code then
- local g = copy_node(p)
- local c = g.components
- if c then -- it happens that we copied a ligature
- free_nodelist(c)
- g.components = nil
- g.subtype = 256
- end
- local s = copy_node(n.spec)
- g.char, n.spec = 32, s
- p.next, g.prev = g, p
- g.next, n.prev = n, g
- s.width = s.width - g.width
+--~ if n.spec.width > 0 then -- threshold
+ if p and p.id == glyph_code then
+ local g = copy_node(p)
+ local c = g.components
+ if c then -- it happens that we copied a ligature
+ free_nodelist(c)
+ g.components = nil
+ g.subtype = 256
end
- -- end
+ local a = has_attribute(n,a_characters)
+ local s = copy_node(n.spec)
+ g.char, n.spec = 32, s
+ p.next, g.prev = g, p
+ g.next, n.prev = n, g
+ s.width = s.width - g.width
+ if a then
+ set_attribute(g,a_characters,a)
+ end
+ set_attribute(s,a_characters,0)
+ set_attribute(n,a_characters,0)
+ end
+--~ end
elseif id == hlist_code or id == vlist_code then
injectspaces(n.list,attribute)
+ -- elseif id == kern_code then -- the backend already collapses
+ -- local first = n
+ -- while true do
+ -- local nn = n.next
+ -- if nn and nn.id == kern_code then
+ -- -- maybe we should delete kerns but who cares at this stage
+ -- first.kern = first.kern + nn.kern
+ -- nn.kern = 0
+ -- n = nn
+ -- else
+ -- break
+ -- end
+ -- end
end
p = n
+ n = n.next
end
return head, true
end