summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/typo-pnc.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/typo-pnc.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/mkiv/typo-pnc.lua21
1 files changed, 13 insertions, 8 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-pnc.lua b/Master/texmf-dist/tex/context/base/mkiv/typo-pnc.lua
index 732970884f2..1ed8d9940af 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-pnc.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-pnc.lua
@@ -9,6 +9,7 @@ if not modules then modules = { } end modules ['typo-pnc'] = {
local nodes = nodes
local fonts = fonts
+local prependaction = nodes.tasks.prependaction
local enableaction = nodes.tasks.enableaction
local nuts = nodes.nuts
@@ -22,8 +23,7 @@ local spaceskip_code = gluecodes.spaceskip
local new_kern = nuts.pool.kern
local insert_after = nuts.insert_after
-
-local nextglyph = nuts.traversers.glyph
+local traverse_id = nuts.traverse_id
local getchar = nuts.getchar
local getfont = nuts.getfont
@@ -68,8 +68,10 @@ local mapping = periodkerns.mapping
local factors = periodkerns.factors
function periodkerns.handler(head)
- for current, char, font in nextglyph, head do
- if char == period then
+ local done = false
+ local hnut = tonut(head)
+ for current in traverse_id(glyph_code,tonut(hnut)) do
+ if getchar(current) == period then
local a = getattr(current,a_periodkern)
if a then
local factor = mapping[a]
@@ -77,10 +79,10 @@ function periodkerns.handler(head)
local prev, next = getboth(current)
if prev and next and getid(prev) == glyph_code and getid(next) == glyph_code then
local pchar = getchar(prev)
- local pcode = categories[pchar]
+ local pcode = categories[getchar(prev)]
if pcode == "lu" or pcode == "ll" then
local nchar = getchar(next)
- local ncode = categories[nchar]
+ local ncode = categories[getchar(next)]
if ncode == "lu" or ncode == "ll" then
local next2 = getnext(next)
if next2 and getid(next2) == glyph_code and getchar(next2) == period then
@@ -89,10 +91,11 @@ function periodkerns.handler(head)
if factor ~= 0 then
fontspace = parameters[getfont(current)].space -- can be sped up
inserted = factor * fontspace
- insert_after(head,current,new_kern(inserted))
+ insert_after(hnut,current,new_kern(inserted))
if trace then
report("inserting space at %C . [%p] %C .",pchar,inserted,nchar)
end
+ done = true
end
local next3 = getnext(next2)
if next3 and getid(next3) == glue_code and getsubtype(next3) == spaceskip_code then
@@ -112,6 +115,7 @@ function periodkerns.handler(head)
end
end
setwidth(next3,space)
+ done = true
else
if trace then
if inserted then
@@ -132,7 +136,7 @@ function periodkerns.handler(head)
end
end
end
- return head
+ return head, done
end
local enabled = false
@@ -140,6 +144,7 @@ local enabled = false
function periodkerns.set(factor)
factor = tonumber(factor) or 0
if not enabled then
+ prependaction("processors","normalizers","typesetters.periodkerns.handler")
enableaction("processors","typesetters.periodkerns.handler")
enabled = true
end