summaryrefslogtreecommitdiff
path: root/tex/context/base/typo-spa.lua
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2014-05-03 13:55:34 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2014-05-03 13:55:34 +0200
commit624cbb5da392e9403984dd1cf368c0d408b1c2a8 (patch)
tree489c049ac849bb5bbce7d32e4df477872c58373d /tex/context/base/typo-spa.lua
parent088de88944c1f2254250bb448c7371a87ff7ee39 (diff)
downloadcontext-624cbb5da392e9403984dd1cf368c0d408b1c2a8.tar.gz
2014-01-03 00:42:00
Diffstat (limited to 'tex/context/base/typo-spa.lua')
-rw-r--r--tex/context/base/typo-spa.lua57
1 files changed, 22 insertions, 35 deletions
diff --git a/tex/context/base/typo-spa.lua b/tex/context/base/typo-spa.lua
index 5cf9ab837..c3f50fe98 100644
--- a/tex/context/base/typo-spa.lua
+++ b/tex/context/base/typo-spa.lua
@@ -15,7 +15,10 @@ local report_spacing = logs.reporter("typesetting","spacing")
local nodes, fonts, node = nodes, fonts, node
-local tasks = nodes.tasks
+local insert_node_before = node.insert_before
+local insert_node_after = node.insert_after
+local remove_node = nodes.remove
+local end_of_math = node.end_of_math
local fonthashes = fonts.hashes
local fontdata = fonthashes.identifiers
@@ -26,28 +29,6 @@ local unsetvalue = attributes.unsetvalue
local v_reset = interfaces.variables.reset
-local nuts = nodes.nuts
-local tonut = nuts.tonut
-local tonode = nuts.tonode
-
-local getnext = nuts.getnext
-local getprev = nuts.getprev
-local getchar = nuts.getchar
-local getid = nuts.getid
-local getfont = nuts.getfont
-local getattr = nuts.getattr
-
-local setattr = nuts.setattr
-
-local insert_node_before = nuts.insert_before
-local insert_node_after = nuts.insert_after
-local remove_node = nuts.remove
-local end_of_math = nuts.end_of_math
-
-local nodepool = nuts.pool
-local new_penalty = nodepool.penalty
-local new_glue = nodepool.glue
-
local nodecodes = nodes.nodecodes
local glyph_code = nodecodes.glyph
local math_code = nodecodes.math
@@ -55,6 +36,12 @@ local math_code = nodecodes.math
local somespace = nodes.somespace
local somepenalty = nodes.somepenalty
+local nodepool = nodes.pool
+local tasks = nodes.tasks
+
+local new_penalty = nodepool.penalty
+local new_glue = nodepool.glue
+
typesetters = typesetters or { }
local typesetters = typesetters
@@ -65,6 +52,7 @@ spacings.mapping = spacings.mapping or { }
spacings.numbers = spacings.numbers or { }
local a_spacings = attributes.private("spacing")
+spacings.attribute = a_spacings
storage.register("typesetters/spacings/mapping", spacings.mapping, "typesetters.spacings.mapping")
@@ -79,30 +67,29 @@ end
-- todo cache lastattr
function spacings.handler(head)
- head = tonut(head)
local done = false
local start = head
-- head is always begin of par (whatsit), so we have at least two prev nodes
-- penalty followed by glue
while start do
- local id = getid(start)
+ local id = start.id
if id == glyph_code then
- local attr = getattr(start,a_spacings)
+ local attr = start[a_spacings]
if attr and attr > 0 then
local data = mapping[attr]
if data then
- local char = getchar(start)
+ local char = start.char
local map = data.characters[char]
- setattr(start,a_spacings,unsetvalue) -- needed?
+ start[a_spacings] = unsetvalue -- needed?
if map then
local left = map.left
local right = map.right
local alternative = map.alternative
- local quad = quaddata[getfont(start)]
- local prev = getprev(start)
+ local quad = quaddata[start.font]
+ local prev = start.prev
if left and left ~= 0 and prev then
local ok = false
- local prevprev = getprev(prev)
+ local prevprev = prev.prev
if alternative == 1 then
local somespace = somespace(prev,true)
if somespace then
@@ -133,10 +120,10 @@ function spacings.handler(head)
done = true
end
end
- local next = getnext(start)
+ local next = start.next
if right and right ~= 0 and next then
local ok = false
- local nextnext = getnext(next)
+ local nextnext = next.next
if alternative == 1 then
local somepenalty = somepenalty(next,10000)
if somepenalty then
@@ -177,10 +164,10 @@ function spacings.handler(head)
start = end_of_math(start) -- weird, can return nil .. no math end?
end
if start then
- start = getnext(start)
+ start = start.next
end
end
- return tonode(head), done
+ return head, done
end
local enabled = false