diff options
author | Khaled Hosny <khaledhosny@eglug.org> | 2009-11-15 17:10:27 +0200 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2009-11-15 17:10:27 +0200 |
commit | 78d506538016cd295d9a84ac62e3e036f23feffc (patch) | |
tree | 4ce6ccaf20af843787f3f15ebc79df3b632d6c11 /otfl-node-inj.lua | |
parent | f3fdfa5bee1dad0307347ba6f14b22f0e19053a6 (diff) | |
download | luaotfload-78d506538016cd295d9a84ac62e3e036f23feffc.tar.gz |
updating to latest (beta 2009.11.13) ConTeXt code
Diffstat (limited to 'otfl-node-inj.lua')
-rw-r--r-- | otfl-node-inj.lua | 132 |
1 files changed, 90 insertions, 42 deletions
diff --git a/otfl-node-inj.lua b/otfl-node-inj.lua index dc676a4..4c58409 100644 --- a/otfl-node-inj.lua +++ b/otfl-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" @@ -10,7 +10,8 @@ if not modules then modules = { } end modules ['node-inj'] = { -- This is very experimental (this will change when we have luatex > .50 and -- a few pending thingies are available. Also, Idris needs to make a few more --- test fonts. +-- test fonts. Btw, future versions of luatex will have extended glyph properties +-- that can be of help. local next = next @@ -50,6 +51,8 @@ local kerns = { } -- explicitly i will provide an alternative; also, we can share -- tables +-- for the moment we pass the r2l key ... volt/arabtype tests + function nodes.set_cursive(start,nxt,factor,rlmode,exit,entry,tfmstart,tfmnext) local dx, dy = factor*(exit[1]-entry[1]), factor*(exit[2]-entry[2]) local ws, wn = tfmstart.width, tfmnext.width @@ -60,7 +63,7 @@ function nodes.set_cursive(start,nxt,factor,rlmode,exit,entry,tfmstart,tfmnext) return dx, dy, bound end -function nodes.set_pair(current,factor,rlmode,spec,tfmchr) +function nodes.set_pair(current,factor,rlmode,r2lflag,spec,tfmchr) local x, y, w, h = factor*spec[1], factor*spec[2], factor*spec[3], factor*spec[4] -- dy = y - h if x ~= 0 or w ~= 0 or y ~= 0 or h ~= 0 then @@ -71,7 +74,7 @@ function nodes.set_pair(current,factor,rlmode,spec,tfmchr) else bound = #kerns + 1 set_attribute(current,kernpair,bound) - kerns[bound] = { rlmode, x, y, w, h } + kerns[bound] = { rlmode, x, y, w, h, r2lflag, tfmchr.width } end return x, y, w, h, bound end @@ -171,6 +174,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 has_marks or has_cursives or has_kerns then if trace_injections then nodes.trace_injection(head) end @@ -190,7 +194,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 @@ -305,14 +309,15 @@ function nodes.inject_kerns(head,where,keep) local d = mrks[index] if d then -- local rlmode = d[3] -- not used - -- if rlmode and rlmode < 0 then - -- n.xoffset = p.xoffset + d[1] + -- if rlmode and rlmode > 0 then + -- todo -- else - n.xoffset = p.xoffset - d[1] ---~ local k = wx[p] ---~ if k then ---~ wx[n] = k ---~ end + local k = wx[p] + if k then + n.xoffset = p.xoffset - d[1] - k[2] + else + n.xoffset = p.xoffset - d[1] + end -- end if mk[p] then n.yoffset = p.yoffset + d[2] @@ -334,23 +339,41 @@ function nodes.inject_kerns(head,where,keep) if next(wx) then for n, k in next, wx do -- only w can be nil, can be sped up when w == nil - local rl, x, w = k[1], k[2] or 0, k[4] or 0 + local rl, x, w, r2l = k[1], k[2] or 0, k[4] or 0, k[6] local wx = w - x - if rl < 0 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)) +--~ if rl < 0 then +--~ if r2l 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 x ~= 0 then +--~ insert_node_before(head,n,newkern(x)) +--~ end +--~ if wx ~= 0 then +--~ insert_node_after(head,n,newkern(wx)) +--~ end +--~ end +--~ else + if r2l 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 x ~= 0 then + insert_node_before(head,n,newkern(x)) + end + if wx ~= 0 then + insert_node_after(head,n,newkern(wx)) + end end - end +--~ end end end if next(cx) then @@ -376,29 +399,54 @@ 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 + 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 - local wx = w - x - if rl < 0 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 + if w then + -- copied from above + local r2l = kk[6] + local wx = w - x +--~ if rl < 0 then +--~ if r2l then +--~ if x ~= 0 then +--~ insert_node_before(head,n,newkern(x)) +--~ end +--~ if wx ~= 0 then +--~ insert_node_after(head,n,newkern(wx)) +--~ end +--~ else +--~ if wx ~= 0 then +--~ insert_node_before(head,n,newkern(wx)) +--~ end +--~ if x ~= 0 then +--~ insert_node_after (head,n,newkern(x)) +--~ end +--~ end +--~ else + if r2l 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 x ~= 0 then + insert_node_before(head,n,newkern(x)) + end + if wx ~= 0 then + insert_node_after(head,n,newkern(wx)) + end + end +--~ end else - -- if wx ~= 0 then - -- insert_node_after(head,n,newkern(wx)) - -- end + -- simple (e.g. kernclass kerns) if x ~= 0 then insert_node_before(head,n,newkern(x)) end |