summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/meta-imp-txt.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/meta-imp-txt.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/mkiv/meta-imp-txt.mkiv76
1 files changed, 36 insertions, 40 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/meta-imp-txt.mkiv b/Master/texmf-dist/tex/context/base/mkiv/meta-imp-txt.mkiv
index e9660b3a7e2..d4329cd6ffd 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/meta-imp-txt.mkiv
+++ b/Master/texmf-dist/tex/context/base/mkiv/meta-imp-txt.mkiv
@@ -202,7 +202,10 @@
\stopMPdefinitions
\startluacode
+ local context = context
+
local nodecodes = nodes.nodecodes
+ local kerncodes = nodes.kerncodes
local visible_code = {
[nodecodes.glyph] = true,
@@ -212,72 +215,66 @@
[nodecodes.rule] = true,
}
- local disc_code = nodecodes.disc
- local kern_code = nodecodes.kern
-
- local c_userkern = nodes.kerncodes.userkern
+ local kern_code = nodecodes.kern
+ local c_userkern = kerncodes.userkern
local a_fontkern = attributes.private("fontkern")
+ local copynode = nodes.copy
+ local freenode = nodes.free
+
+ local topoints = number.topoints
+ local mpprint = mp.print
+
local n = nil
local s = 0
function mp.follow_reset()
- r = nil
+ for i=1,#n do
+ freenode(n[i])
+ end
+ n = nil
s = 0
end
function mp.follow_initialize(b)
- if not r then
- local l = tex.takebox(b).list
- n = { }
- s = 0
- while l do
- local c = l
- l = l.next
- local id = c.id
- if visible_code[id] then
- s = s + 1
- n[s] = c
- c.prev = nil
- c.next = nil
- elseif id == kern_code then
- if c.subtype == c_userkern and not c[a_fontkern] then
+ if not n then
+ local head = tex.takebox(b).list
+ if head then
+ n = { }
+ s = 0
+ head = node.flatten_discretionaries(head)
+ local current = head
+ while current do
+ local id = current.id
+ if visible_code[id] then
s = s + 1
- n[s] = c
- c.prev = nil
- else
- n[s].next = c
- c.prev = n[s]
- end
- c.next = nil
- elseif id == disc_code then
- local r = c.replace
- while r do
+ head, current, n[s] = nodes.remove(head,current)
+ elseif id == kern_code and current.subtype == c_userkern and not current[a_fontkern] then
s = s + 1
- n[s] = r
- r = r.next
- r.prev = nil
- r.next = nil
+ head, current, n[s] = nodes.remove(head,current)
+ else
+ current = current.next
end
end
+ nodes.flush_list(head)
end
end
end
function mp.follow_size()
- mp.print(s)
+ mpprint(s)
end
function mp.follow_slot(i)
- mp.print('textext("\\getfollowtoken{' .. i .. '}")')
+ mpprint('textext("\\getfollowtoken{' .. i .. '}")')
end
function mp.follow_text(s)
- context(n[s])
+ context(copynode(n[s]))
end
function mp.follow_width(i)
- mp.print(number.topoints(n[i].width))
+ mpprint(topoints(n[i].width))
end
\stopluacode
@@ -373,9 +370,8 @@
[medium]
\startuniqueMPgraphic{EnglishRule}{height,width,color}
- height = \MPvar{height} ;
x1 = 0 ; x3 = \MPvar{width} ; x2 = x4 = .5x3 ;
- y1 = y3 = 0 ; y2 = -y4 = height/2 ;
+ y1 = y3 = 0 ; y2 = -y4 = \MPvar{height}/2 ;
fill z1..z2..z3 & z3..z4..z1 & cycle withcolor \MPvar{color} ;
\stopuniqueMPgraphic