summaryrefslogtreecommitdiff
path: root/tex/context/base/node-inj.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2009-08-26 01:43:00 +0200
committerHans Hagen <pragma@wxs.nl>2009-08-26 01:43:00 +0200
commit431ad6f512041aa658f6b080adbc17c2b4dffba3 (patch)
tree885dd27e0c2cfa17ca7c35c17e267210bcd5eee9 /tex/context/base/node-inj.lua
parent59ba8ee162a46adb0b41a4255c2aab552e5a8b31 (diff)
downloadcontext-431ad6f512041aa658f6b080adbc17c2b4dffba3.tar.gz
beta 2009.08.26 01:43
Diffstat (limited to 'tex/context/base/node-inj.lua')
-rw-r--r--tex/context/base/node-inj.lua112
1 files changed, 86 insertions, 26 deletions
diff --git a/tex/context/base/node-inj.lua b/tex/context/base/node-inj.lua
index dc676a412..2a7ea9263 100644
--- a/tex/context/base/node-inj.lua
+++ b/tex/context/base/node-inj.lua
@@ -1,6 +1,6 @@
if not modules then modules = { } end modules ['node-inj'] = {
version = 1.001,
- comment = "companion to node-ini.tex",
+ comment = "companion to node-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
license = "see context related readme files"
@@ -171,6 +171,7 @@ end
function nodes.inject_kerns(head,where,keep)
local has_marks, has_cursives, has_kerns = next(marks), next(cursives), next(kerns)
if has_marks or has_cursives then
+--~ if true then
if trace_injections then
nodes.trace_injection(head)
end
@@ -190,7 +191,7 @@ function nodes.inject_kerns(head,where,keep)
if k then
local kk = kerns[k]
if kk then
- local x, y, w, h = kk[2], kk[3], kk[4], kk[5]
+ local x, y, w, h = kk[2] or 0, kk[3] or 0, kk[4] or 0, kk[5] or 0
local dy = y - h
if dy ~= 0 then
ky[n] = dy
@@ -337,12 +338,21 @@ function nodes.inject_kerns(head,where,keep)
local rl, x, w = k[1], k[2] or 0, k[4] or 0
local wx = w - x
if rl < 0 then
+--~ if false then
if wx ~= 0 then
insert_node_before(head,n,newkern(wx))
end
if x ~= 0 then
insert_node_after (head,n,newkern(x))
end
+--~ else
+--~ if wx ~= 0 then
+--~ insert_node_after(head,n,newkern(wx))
+--~ end
+--~ if x ~= 0 then
+--~ insert_node_before(head,n,newkern(x))
+--~ end
+--~ end
else
-- if wx ~= 0 then
-- insert_node_after(head,n,newkern(wx))
@@ -376,35 +386,46 @@ function nodes.inject_kerns(head,where,keep)
if trace_injections then
nodes.trace_injection(head)
end
- -- we assume done is true because there are kerns
- for n in traverse_id(glyph,head) do
- local k = has_attribute(n,kernpair)
- if k then
- local kk = kerns[k]
- if kk then
- -- only w can be nil, can be sped up when w == nil
- local rl, x, y, w = kk[1], kk[2] or 0, kk[3] or 0, kk[4] or 0
- if y ~= 0 then
- n.yoffset = y -- todo: h ?
- end
- local wx = w - x
- if rl < 0 then
- if wx ~= 0 then
- insert_node_before(head,n,newkern(wx))
+ local n = head
+ while n do
+ local id = n.id
+ if id == glyph then
+ local k = has_attribute(n,kernpair)
+ if k then
+ local kk = kerns[k]
+ if kk then
+ local rl, x, y, w = kk[1], kk[2] or 0, kk[3], kk[4]
+ if y and y ~= 0 then
+ n.yoffset = y -- todo: h ?
end
- if x ~= 0 then
- insert_node_after (head,n,newkern(x))
- end
- else
- -- if wx ~= 0 then
- -- insert_node_after(head,n,newkern(wx))
- -- end
- if x ~= 0 then
- insert_node_before(head,n,newkern(x))
+ if w then
+ -- gpospair kerns
+ local wx = w - x
+ if rl < 0 then
+ if wx ~= 0 then
+ head, _ = insert_node_before(head,n,newkern(wx))
+ end
+ if x ~= 0 then
+ head, n = insert_node_after(head,n,newkern(x))
+ end
+ else
+ -- if wx ~= 0 then
+ -- head, n = insert_node_after(head,n,newkern(wx))
+ -- end
+ if x ~= 0 then
+ head, _ = insert_node_before(head,n,newkern(x))
+ end
+ end
+ else
+ -- simple (e.g. kernclass kerns)
+ if x ~= 0 then
+ head, _ = insert_node_before(head,n,newkern(x))
+ end
end
end
end
end
+ n = n.next
end
if not keep then
kerns = { }
@@ -415,3 +436,42 @@ function nodes.inject_kerns(head,where,keep)
end
return head, false
end
+
+--~ for n in traverse_id(glyph,head) do
+--~ local k = has_attribute(n,kernpair)
+--~ if k then
+--~ local kk = kerns[k]
+--~ if kk then
+--~ -- only w can be nil, can be sped up when w == nil
+--~ local rl, x, y, w = kk[1], kk[2] or 0, kk[3] or 0, kk[4] or 0
+--~ if y ~= 0 then
+--~ n.yoffset = y -- todo: h ?
+--~ end
+--~ local wx = w - x
+--~ if rl < 0 then
+--~ if false then
+--~ if wx ~= 0 then
+--~ insert_node_before(head,n,newkern(wx))
+--~ end
+--~ if x ~= 0 then
+--~ insert_node_after (head,n,newkern(x))
+--~ end
+--~ else
+--~ if wx ~= 0 then
+--~ insert_node_after(head,n,newkern(wx))
+--~ end
+--~ if x ~= 0 then
+--~ insert_node_before(head,n,newkern(x))
+--~ end
+--~ end
+--~ else
+--~ -- if wx ~= 0 then
+--~ -- insert_node_after(head,n,newkern(wx))
+--~ -- end
+--~ if x ~= 0 then
+--~ insert_node_before(head,n,newkern(x))
+--~ end
+--~ end
+--~ end
+--~ end
+--~ end