summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/font-otj.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/font-otj.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/mkiv/font-otj.lua110
1 files changed, 50 insertions, 60 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-otj.lua b/Master/texmf-dist/tex/context/base/mkiv/font-otj.lua
index bb30389357c..9037939df10 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-otj.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-otj.lua
@@ -97,11 +97,8 @@ local setlink = nuts.setlink
local setwidth = nuts.setwidth
local getwidth = nuts.getwidth
------ traverse_id = nuts.traverse_id
------ traverse_char = nuts.traverse_char
-local nextchar = nuts.traversers.char
-local nextglue = nuts.traversers.glue
-
+local traverse_id = nuts.traverse_id
+local traverse_char = nuts.traverse_char
local insert_node_before = nuts.insert_before
local insert_node_after = nuts.insert_after
@@ -131,10 +128,6 @@ do if not fontkern then -- generic
return n
end
-end end
-
-do if not italickern then -- generic
-
local thekern = nuts.new("kern",3) -- italiccorrection
local setkern = nuts.setkern
local copy_node = nuts.copy_node
@@ -305,10 +298,10 @@ end
-- kind: 0=single 1=first of pair, 2=second of pair
function injections.setposition(kind,current,factor,rlmode,spec,injection)
- local x = factor * (spec[1] or 0)
- local y = factor * (spec[2] or 0)
- local w = factor * (spec[3] or 0)
- local h = factor * (spec[4] or 0)
+ local x = factor*spec[1]
+ local y = factor*spec[2]
+ local w = factor*spec[3]
+ local h = factor*spec[4]
if x ~= 0 or w ~= 0 or y ~= 0 or h ~= 0 then -- okay?
local yoffset = y - h
local leftkern = x -- both kerns are set in a pair kern compared
@@ -456,8 +449,7 @@ function injections.setmove(current,factor,rlmode,x,injection)
end
function injections.setmark(start,base,factor,rlmode,ba,ma,tfmbase,mkmk,checkmark) -- ba=baseanchor, ma=markanchor
- local dx = factor*(ba[1]-ma[1])
- local dy = factor*(ba[2]-ma[2])
+ local dx, dy = factor*(ba[1]-ma[1]), factor*(ba[2]-ma[2])
nofregisteredmarks = nofregisteredmarks + 1
if rlmode >= 0 then
dx = tfmbase.width - dx -- see later commented ox
@@ -470,18 +462,15 @@ function injections.setmark(start,base,factor,rlmode,ba,ma,tfmbase,mkmk,checkmar
if i.markmark then
-- out of order mkmk: yes or no or option
else
- -- if dx ~= 0 then
- -- i.markx = dx
- -- end
- -- if y ~= 0 then
- -- i.marky = dy
- -- end
- -- if rlmode then
- -- i.markdir = rlmode
- -- end
- i.markx = dx
- i.marky = dy
- i.markdir = rlmode or 0
+ if dx ~= 0 then
+ i.markx = dx
+ end
+ if y ~= 0 then
+ i.marky = dy
+ end
+ if rlmode then
+ i.markdir = rlmode
+ end
i.markbase = nofregisteredmarks
i.markbasenode = base
i.markmark = mkmk
@@ -569,7 +558,7 @@ end
local function showsub(n,what,where)
report_injections("begin subrun: %s",where)
- for n in nextchar, n do
+ for n in traverse_char(n) do
showchar(n,where)
show(n,what,where," ")
end
@@ -639,6 +628,7 @@ end
-- +D-replace +D-replace
local function inject_kerns_only(head,where)
+ head = tonut(head)
if trace_injections then
trace(head,"kerns")
end
@@ -694,8 +684,7 @@ local function inject_kerns_only(head,where)
-- glyph|disc|glyph (special case)
local leftkern = i.leftkern
if leftkern and leftkern ~= 0 then
- replace = fontkern(leftkern)
- done = true
+ setfield(prev,"replace",fontkern(leftkern)) -- maybe also leftkern
end
end
end
@@ -715,7 +704,7 @@ local function inject_kerns_only(head,where)
local done = false
if pre then
-- left|pre glyphs|right
- for n in nextchar, pre do
+ for n in traverse_char(pre) do
local p = rawget(properties,n)
if p then
local i = p.injections or p.preinjections
@@ -731,7 +720,7 @@ local function inject_kerns_only(head,where)
end
if post then
-- left|post glyphs|right
- for n in nextchar, post do
+ for n in traverse_char(post) do
local p = rawget(properties,n)
if p then
local i = p.injections or p.postinjections
@@ -747,7 +736,7 @@ local function inject_kerns_only(head,where)
end
if replace then
-- left|replace glyphs|right
- for n in nextchar, replace do
+ for n in traverse_char(replace) do
local p = rawget(properties,n)
if p then
local i = p.injections or p.replaceinjections
@@ -782,10 +771,11 @@ local function inject_kerns_only(head,where)
if trace_injections then
show_result(head)
end
- return head
+ return tonode(head), true
end
local function inject_positions_only(head,where)
+ head = tonut(head)
if trace_injections then
trace(head,"positions")
end
@@ -836,9 +826,7 @@ local function inject_positions_only(head,where)
if replace then
-- error, we expect an empty one
else
---KE setfield(next,"replace",fontkern(rightkern)) -- maybe also leftkern
- replace = fontkern(rightkern) -- maybe also leftkern --KE
- done = true --KE
+ setfield(next,"replace",fontkern(rightkern)) -- maybe also leftkern
end
end
end
@@ -871,8 +859,7 @@ local function inject_positions_only(head,where)
-- new .. okay?
local leftkern = i.leftkern
if leftkern and leftkern ~= 0 then
- replace = fontkern(leftkern)
- done = true
+ setfield(prev,"replace",fontkern(leftkern)) -- maybe also leftkern
end
end
end
@@ -891,7 +878,7 @@ local function inject_positions_only(head,where)
local done = false
if pre then
-- left|pre glyphs|right
- for n in nextchar, pre do
+ for n in traverse_char(pre) do
local p = rawget(properties,n)
if p then
local i = p.injections or p.preinjections
@@ -916,7 +903,7 @@ local function inject_positions_only(head,where)
end
if post then
-- left|post glyphs|right
- for n in nextchar, post do
+ for n in traverse_char(post) do
local p = rawget(properties,n)
if p then
local i = p.injections or p.postinjections
@@ -941,7 +928,7 @@ local function inject_positions_only(head,where)
end
if replace then
-- left|replace glyphs|right
- for n in nextchar, replace do
+ for n in traverse_char(replace) do
local p = rawget(properties,n)
if p then
local i = p.injections or p.replaceinjections
@@ -1015,7 +1002,7 @@ local function inject_positions_only(head,where)
if trace_injections then
show_result(head)
end
- return head
+ return tonode(head), true
end
local function showoffset(n,flag)
@@ -1026,6 +1013,7 @@ local function showoffset(n,flag)
end
local function inject_everything(head,where)
+ head = tonut(head)
if trace_injections then
trace(head,"everything")
end
@@ -1288,8 +1276,7 @@ local function inject_everything(head,where)
if replace then
-- error, we expect an empty one
else
- replace = fontkern(rightkern)
- done = true
+ setfield(next,"replace",fontkern(rightkern)) -- maybe also leftkern
end
end
end
@@ -1322,8 +1309,7 @@ local function inject_everything(head,where)
if i then
local leftkern = i.leftkern
if leftkern and leftkern ~= 0 then
- replace = fontkern(leftkern)
- done = true
+ setfield(prev,"replace",fontkern(leftkern)) -- maybe also leftkern
end
end
end
@@ -1358,7 +1344,7 @@ local function inject_everything(head,where)
local done = false
if pre then
-- left|pre glyphs|right
- for n in nextchar, pre do
+ for n in traverse_char(pre) do
local p = rawget(properties,n)
if p then
local i = p.injections or p.preinjections
@@ -1389,7 +1375,7 @@ local function inject_everything(head,where)
end
if post then
-- left|post glyphs|right
- for n in nextchar, post do
+ for n in traverse_char(post) do
local p = rawget(properties,n)
if p then
local i = p.injections or p.postinjections
@@ -1420,7 +1406,7 @@ local function inject_everything(head,where)
end
if replace then
-- left|replace glyphs|right
- for n in nextchar, replace do
+ for n in traverse_char(replace) do
local p = rawget(properties,n)
if p then
local i = p.injections or p.replaceinjections
@@ -1528,7 +1514,7 @@ local function inject_everything(head,where)
if trace_injections then
show_result(head)
end
- return head
+ return tonode(head), true
end
-- space triggers
@@ -1617,7 +1603,7 @@ end
local function injectspaces(head)
if not triggers then
- return head
+ return head, false
end
local lastfont = nil
local spacekerns = nil
@@ -1627,6 +1613,7 @@ local function injectspaces(head)
local threshold = 0
local leftkern = false
local rightkern = false
+ local nuthead = tonut(head)
local function updatefont(font,trig)
leftkerns = trig.left
@@ -1636,7 +1623,7 @@ local function injectspaces(head)
factor = getthreshold(font)
end
- for n in nextglue, head do
+ for n in traverse_id(glue_code,nuthead) do
local prev, next = getspaceboth(n)
local prevchar = prev and ischar(prev)
local nextchar = next and ischar(next)
@@ -1674,8 +1661,12 @@ local function injectspaces(head)
if trace_spaces then
report_spaces("%C [%p + %p + %p] %C",prevchar,lnew,old,rnew,nextchar)
end
- head = insert_node_before(head,n,italickern(lnew))
- insert_node_after(head,n,italickern(rnew))
+ local h = insert_node_before(nuthead,n,italickern(lnew))
+ if h == nuthead then
+ head = tonode(h)
+ nuthead = h
+ end
+ insert_node_after(nuthead,n,italickern(rnew))
else
local new = old + (leftkern + rightkern) * factor
if trace_spaces then
@@ -1690,7 +1681,7 @@ local function injectspaces(head)
if trace_spaces then
report_spaces("%C [%p + %p]",prevchar,old,new)
end
- insert_node_after(head,n,italickern(new)) -- tricky with traverse but ok
+ insert_node_after(nuthead,n,italickern(new)) -- tricky with traverse but ok
else
local new = old + leftkern * factor
if trace_spaces then
@@ -1709,7 +1700,7 @@ local function injectspaces(head)
if trace_spaces then
report_spaces("%C [%p + %p]",nextchar,old,new)
end
- insert_node_after(head,n,italickern(new))
+ insert_node_after(nuthead,n,italickern(new))
else
local new = old + rightkern * factor
if trace_spaces then
@@ -1723,8 +1714,7 @@ local function injectspaces(head)
end
triggers = false
-
- return head
+ return head, true
end
--
@@ -1750,6 +1740,6 @@ function injections.handler(head,where)
end
return inject_kerns_only(head,where)
else
- return head
+ return head, false
end
end