summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/font-ots.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2017-08-04 09:53:17 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2017-08-04 09:53:17 +0200
commit817e18d3f6969b1b50b4883ec4d5bb05c985db88 (patch)
tree3569da776df0f8bcf449efd99b11380544d44ec5 /tex/context/base/mkiv/font-ots.lua
parentab253433729006addd4336870face2facce5f894 (diff)
downloadcontext-817e18d3f6969b1b50b4883ec4d5bb05c985db88.tar.gz
2017-08-04 09:46:00
Diffstat (limited to 'tex/context/base/mkiv/font-ots.lua')
-rw-r--r--tex/context/base/mkiv/font-ots.lua208
1 files changed, 97 insertions, 111 deletions
diff --git a/tex/context/base/mkiv/font-ots.lua b/tex/context/base/mkiv/font-ots.lua
index 6af5aa405..7194109a1 100644
--- a/tex/context/base/mkiv/font-ots.lua
+++ b/tex/context/base/mkiv/font-ots.lua
@@ -693,7 +693,7 @@ function handlers.gsub_single(head,start,dataset,sequence,replacement)
return head, start, true
end
-function handlers.gsub_alternate(head,start,dataset,sequence,alternative)
+function handlers.gsub_alternate(head,start,dataset,sequence,alternative,rlmode,skiphash)
local kind = dataset[4]
local what = dataset[1]
local value = what == true and tfmdata.shared.features[kind] or what
@@ -712,14 +712,17 @@ function handlers.gsub_alternate(head,start,dataset,sequence,alternative)
return head, start, true
end
-function handlers.gsub_multiple(head,start,dataset,sequence,multiple)
+function handlers.gsub_multiple(head,start,dataset,sequence,multiple,rlmode,skiphash)
if trace_multiples then
logprocess("%s: replacing %s by multiple %s",pref(dataset,sequence),gref(getchar(start)),gref(multiple))
end
return multiple_glyphs(head,start,multiple,sequence.flags[1],dataset[1])
end
-function handlers.gsub_ligature(head,start,dataset,sequence,ligature)
+-- Don't we deal with disc otherwise now? I need to check if the next one can be
+-- simplified.
+
+function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skiphash)
local current = getnext(start)
if not current then
return head, start, false, nil
@@ -838,7 +841,7 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature)
return head, start, false, discfound
end
-function handlers.gpos_single(head,start,dataset,sequence,kerns,rlmode,step,i,injection)
+function handlers.gpos_single(head,start,dataset,sequence,kerns,rlmode,skiphash,step,injection)
local startchar = getchar(start)
local format = step.format
if format == "single" or type(kerns) == "table" then -- the table check can go
@@ -855,14 +858,7 @@ function handlers.gpos_single(head,start,dataset,sequence,kerns,rlmode,step,i,in
return head, start, false
end
--- elseif krn and step.format == "pair"
--- and (not krn[1] or type(krn[1]) == "boolean")
--- and (not krn[2] or type(krn[2]) == "boolean")
--- and marks[nextchar] then --KE
--- prev = snext --KE
--- snext = getnext(snext) --KE
-
-function handlers.gpos_pair(head,start,dataset,sequence,kerns,rlmode,step,i,injection)
+function handlers.gpos_pair(head,start,dataset,sequence,kerns,rlmode,skiphash,step,injection)
local snext = getnext(start)
if not snext then
return head, start, false
@@ -871,17 +867,10 @@ function handlers.gpos_pair(head,start,dataset,sequence,kerns,rlmode,step,i,inje
while snext do
local nextchar = ischar(snext,currentfont)
if nextchar then
- -- local krn = kerns[nextchar]
- -- if not krn and marks[nextchar] then
- -- prev = snext
- -- snext = getnext(snext)
- -- elseif not krn then
- -- break
- -- else
if marks[nextchar] and sequence.flags[1] then
prev = snext
snext = getnext(snext)
--- if sequence.skipsome and sequence.skipsome[nextchar] then
+-- if skiphash and skiphash[nextchar] then -- includes marks too when flag
-- prev = snext
-- snext = getnext(snext)
else
@@ -938,7 +927,7 @@ end
we need to explicitly test for basechar, baselig and basemark entries.</p>
--ldx]]--
-function handlers.gpos_mark2base(head,start,dataset,sequence,markanchors,rlmode)
+function handlers.gpos_mark2base(head,start,dataset,sequence,markanchors,rlmode,skiphash)
local markchar = getchar(start)
if marks[markchar] then
local base = getprev(start) -- [glyph] [start=mark]
@@ -993,7 +982,7 @@ function handlers.gpos_mark2base(head,start,dataset,sequence,markanchors,rlmode)
return head, start, false
end
-function handlers.gpos_mark2ligature(head,start,dataset,sequence,markanchors,rlmode)
+function handlers.gpos_mark2ligature(head,start,dataset,sequence,markanchors,rlmode,skiphash)
local markchar = getchar(start)
if marks[markchar] then
local base = getprev(start) -- [glyph] [optional marks] [start=mark]
@@ -1058,7 +1047,7 @@ function handlers.gpos_mark2ligature(head,start,dataset,sequence,markanchors,rlm
return head, start, false
end
-function handlers.gpos_mark2mark(head,start,dataset,sequence,markanchors,rlmode)
+function handlers.gpos_mark2mark(head,start,dataset,sequence,markanchors,rlmode,skiphash)
local markchar = getchar(start)
if marks[markchar] then
local base = getprev(start) -- [glyph] [basemark] [start=mark]
@@ -1094,7 +1083,7 @@ function handlers.gpos_mark2mark(head,start,dataset,sequence,markanchors,rlmode)
return head, start, false
end
-function handlers.gpos_cursive(head,start,dataset,sequence,exitanchors,rlmode,step,i) -- to be checked
+function handlers.gpos_cursive(head,start,dataset,sequence,exitanchors,rlmode,skiphash,step) -- to be checked
local startchar = getchar(start)
if marks[startchar] then
if trace_cursive then
@@ -1162,7 +1151,7 @@ local logwarning = report_chain
-- in a bit weird way. There is no lookup and the replacement comes from the lookup
-- itself. It is meant mostly for dealing with Urdu.
-local function reversesub(head,start,stop,dataset,sequence,replacements,rlmode)
+local function reversesub(head,start,stop,dataset,sequence,replacements,rlmode,skiphash)
local char = getchar(start)
local replacement = replacements[char]
if replacement then
@@ -1216,7 +1205,7 @@ end
-- logwarning("%s: bad step, no proper return values",cref(dataset,sequence))
-- end
-function chainprocs.gsub_single(head,start,stop,dataset,sequence,currentlookup,chainindex)
+function chainprocs.gsub_single(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex)
local steps = currentlookup.steps
local nofsteps = currentlookup.nofsteps
if nofsteps > 1 then
@@ -1433,7 +1422,7 @@ function chainprocs.gsub_ligature(head,start,stop,dataset,sequence,currentlookup
return head, start, false, 0, false
end
-function chainprocs.gpos_single(head,start,stop,dataset,sequence,currentlookup,rlmode,chainindex)
+function chainprocs.gpos_single(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex)
local steps = currentlookup.steps
local nofsteps = currentlookup.nofsteps
if nofsteps > 1 then
@@ -1465,7 +1454,7 @@ function chainprocs.gpos_single(head,start,stop,dataset,sequence,currentlookup,r
return head, start, false
end
-function chainprocs.gpos_pair(head,start,stop,dataset,sequence,currentlookup,rlmode,chainindex) -- todo: injections ?
+function chainprocs.gpos_pair(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex) -- todo: injections ?
local steps = currentlookup.steps
local nofsteps = currentlookup.nofsteps
if nofsteps > 1 then
@@ -1486,17 +1475,10 @@ function chainprocs.gpos_pair(head,start,stop,dataset,sequence,currentlookup,rlm
if not nextchar then
break
end
- -- local krn = kerns[nextchar]
- -- if not krn and marks[nextchar] then
- -- prev = snext
- -- snext = getnext(snext)
- -- elseif not krn then
- -- break
- -- else
if marks[nextchar] and sequence.flags[1] then
prev = snext
snext = getnext(snext)
--- elseif sequence.markclass and sequence.markclass[nextchar] then - skipsome
+-- if skiphash and skiphash[nextchar] then
-- prev = snext
-- snext = getnext(snext)
else
@@ -1547,7 +1529,7 @@ function chainprocs.gpos_pair(head,start,stop,dataset,sequence,currentlookup,rlm
return head, start, false
end
-function chainprocs.gpos_mark2base(head,start,stop,dataset,sequence,currentlookup,rlmode)
+function chainprocs.gpos_mark2base(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash)
local steps = currentlookup.steps
local nofsteps = currentlookup.nofsteps
if nofsteps > 1 then
@@ -1615,7 +1597,7 @@ function chainprocs.gpos_mark2base(head,start,stop,dataset,sequence,currentlooku
return head, start, false
end
-function chainprocs.gpos_mark2ligature(head,start,stop,dataset,sequence,currentlookup,rlmode)
+function chainprocs.gpos_mark2ligature(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash)
local steps = currentlookup.steps
local nofsteps = currentlookup.nofsteps
if nofsteps > 1 then
@@ -1687,7 +1669,7 @@ function chainprocs.gpos_mark2ligature(head,start,stop,dataset,sequence,currentl
return head, start, false
end
-function chainprocs.gpos_mark2mark(head,start,stop,dataset,sequence,currentlookup,rlmode)
+function chainprocs.gpos_mark2mark(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash)
local steps = currentlookup.steps
local nofsteps = currentlookup.nofsteps
if nofsteps > 1 then
@@ -1743,7 +1725,7 @@ function chainprocs.gpos_mark2mark(head,start,stop,dataset,sequence,currentlooku
return head, start, false
end
-function chainprocs.gpos_cursive(head,start,stop,dataset,sequence,currentlookup,rlmode)
+function chainprocs.gpos_cursive(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash)
local steps = currentlookup.steps
local nofsteps = currentlookup.nofsteps
if nofsteps > 1 then
@@ -1880,7 +1862,7 @@ end
local noflags = { false, false, false, false }
-local function chainrun(head,start,last,dataset,sequence,rlmode,ck,skipsome) -- skipped)
+local function chainrun(head,start,last,dataset,sequence,rlmode,skiphash,ck)
local size = ck[5] - ck[4] + 1
local chainlookups = ck[6]
@@ -1904,7 +1886,7 @@ local function chainrun(head,start,last,dataset,sequence,rlmode,ck,skipsome) --
local chainproc = chainprocs[chainkind]
if chainproc then
local ok
- head, start, ok = chainproc(head,start,last,dataset,sequence,chainstep,rlmode,1)
+ head, start, ok = chainproc(head,start,last,dataset,sequence,chainstep,rlmode,skiphash)
if ok then
done = true
end
@@ -1929,19 +1911,15 @@ local function chainrun(head,start,last,dataset,sequence,rlmode,ck,skipsome) --
-- It's very unlikely that we will have skip classes here but still ... we seldom
-- enter this branch anyway.
- if skipsome then
- skipsome = sequence.skipsome
- end
-
local i = 1
local laststart = start
local nofchainlookups = #chainlookups -- useful?
while start do
- if skipsome then -- hm, so we know we skip some
+ if skiphash then -- hm, so we know we skip some
while start do
local char = ischar(start,currentfont)
if char then
- if skipsome[char] then
+ if skiphash and skiphash[char] then
start = getnext(start)
else
break
@@ -1959,7 +1937,7 @@ local function chainrun(head,start,last,dataset,sequence,rlmode,ck,skipsome) --
local chainproc = chainprocs[chainkind]
if chainproc then
local ok, n
- head, start, ok, n = chainproc(head,start,last,dataset,sequence,chainstep,rlmode,i)
+ head, start, ok, n = chainproc(head,start,last,dataset,sequence,chainstep,rlmode,skiphash)
-- messy since last can be changed !
if ok then
done = true
@@ -1992,7 +1970,7 @@ local function chainrun(head,start,last,dataset,sequence,rlmode,ck,skipsome) --
-- todo: needs checking for holes in the replacements
local replacements = ck[7]
if replacements then
- head, start, done = reversesub(head,start,last,dataset,sequence,replacements,rlmode)
+ head, start, done = reversesub(head,start,last,dataset,sequence,replacements,rlmode,skiphash)
else
done = true
if trace_contexts then
@@ -2003,7 +1981,7 @@ local function chainrun(head,start,last,dataset,sequence,rlmode,ck,skipsome) --
return head, start, done
end
-local function chaindisk(head,start,dataset,sequence,rlmode,ck,skipped)
+local function chaindisk(head,start,dataset,sequence,rlmode,skiphash,ck)
if not start then
return head, start, false
@@ -2233,14 +2211,14 @@ local function chaindisk(head,start,dataset,sequence,rlmode,ck,skipped)
end
if not notmatchpre[lookaheaddisc] then
local ok = false
- cf, start, ok = chainrun(cf,start,cl,dataset,sequence,rlmode,ck,skipped)
+ cf, start, ok = chainrun(cf,start,cl,dataset,sequence,rlmode,skiphash,ck)
if ok then
done = true
end
end
if not notmatchreplace[lookaheaddisc] then
local ok = false
- new, cnew, ok = chainrun(new,cnew,clast,dataset,sequence,rlmode,ck,skipped)
+ new, cnew, ok = chainrun(new,cnew,clast,dataset,sequence,rlmode,skiphash,ck)
if ok then
done = true
end
@@ -2289,14 +2267,14 @@ local function chaindisk(head,start,dataset,sequence,rlmode,ck,skipped)
end
if not notmatchpost[backtrackdisc] then
local ok = false
- cf, start, ok = chainrun(cf,start,last,dataset,sequence,rlmode,ck,skipped)
+ cf, start, ok = chainrun(cf,start,last,dataset,sequence,rlmode,skiphash,ck)
if ok then
done = true
end
end
if not notmatchreplace[backtrackdisc] then
local ok = false
- new, cnew, ok = chainrun(new,cnew,clast,dataset,sequence,rlmode,ck,skipped)
+ new, cnew, ok = chainrun(new,cnew,clast,dataset,sequence,rlmode,skiphash,ck)
if ok then
done = true
end
@@ -2323,7 +2301,7 @@ local function chaindisk(head,start,dataset,sequence,rlmode,ck,skipped)
else
local ok = false
- head, start, ok = chainrun(head,start,last,dataset,sequence,rlmode,ck,skipped)
+ head, start, ok = chainrun(head,start,last,dataset,sequence,rlmode,skiphash,ck)
if ok then
done = true
end
@@ -2333,7 +2311,7 @@ local function chaindisk(head,start,dataset,sequence,rlmode,ck,skipped)
return head, start, done
end
-local function chaintrac(head,start,dataset,sequence,rlmode,ck,skipped,match)
+local function chaintrac(head,start,dataset,sequence,rlmode,skiphash,ck,match)
local rule = ck[1]
local lookuptype = ck[8] or ck[2]
local nofseq = #ck[3]
@@ -2348,7 +2326,7 @@ end
-- tests because they have many steps with one context (having multiple contexts makes more sense)
-- also because we (can) reduce them.
--- local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode)
+-- local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode,skiphash)
-- local sweepnode = sweepnode
-- local sweeptype = sweeptype
-- local currentfont = currentfont
@@ -2356,7 +2334,6 @@ end
-- local checkdisc = sweeptype and getprev(head)
-- local flags = sequence.flags or noflags
-- local done = false
--- local skipsome = sequence.skipsome
-- local skipped = false
-- local startprev,
-- startnext = getboth(start)
@@ -2395,7 +2372,7 @@ end
-- if last then
-- local char, id = ischar(last,currentfont)
-- if char then
--- if skipsome and skipsome[char] then
+-- if skiphash and skiphash[char] then
-- skipped = true
-- if trace_skips then
-- show_skip(dataset,sequence,char,ck,classes[char])
@@ -2504,7 +2481,7 @@ end
-- if prev then
-- local char, id = ischar(prev,currentfont)
-- if char then
--- if skipsome and skipsome[char] then
+-- if skiphash and skiphash[char] then
-- skipped = true
-- if trace_skips then
-- show_skip(dataset,sequence,char,ck,classes[char])
@@ -2644,7 +2621,7 @@ end
-- if current then
-- local char, id = ischar(current,currentfont)
-- if char then
--- if skipsome and skipsome[char] then
+-- if skiphash and skiphash[char] then
-- skipped = true
-- if trace_skips then
-- show_skip(dataset,sequence,char,ck,classes[char])
@@ -2761,12 +2738,12 @@ end
-- end
-- if match then
-- if trace_contexts then
--- chaintrac(head,start,dataset,sequence,rlmode,ck,skipped,true)
+-- chaintrac(head,start,dataset,sequence,rlmode,skipped and skiphash,ck,true)
-- end
-- if diskseen or sweepnode then
--- head, start, done = chaindisk(head,start,dataset,sequence,rlmode,ck,skipped)
+-- head, start, done = chaindisk(head,start,dataset,sequence,rlmode,skipped and skiphash,ck)
-- else
--- head, start, done = chainrun(head,start,last,dataset,sequence,rlmode,ck,skipped)
+-- head, start, done = chainrun(head,start,last,dataset,sequence,rlmode,skipped and skiphash,ck)
-- end
-- if done then
-- break
@@ -2774,7 +2751,7 @@ end
-- -- next context
-- end
-- -- elseif trace_chains then
--- -- chaintrac(head,start,dataset,sequence,rlmode,ck,skipped,match)
+-- -- chaintrac(head,start,dataset,sequence,rlmode,skipped and skiphash,ck,match)
-- end
-- end
-- if diskseen then
@@ -2789,7 +2766,7 @@ end
-- "labels" instead. This is one of the cases where it makes th ecode more readable and we might
-- even gain a bit performance.
-local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode)
+local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode,skiphash)
-- optimizing for rlmode gains nothing
local sweepnode = sweepnode
local sweeptype = sweeptype
@@ -2810,7 +2787,6 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode)
local currentfont = currentfont
local skipped -- = false
- local skipsome = sequence.skipsome
local startprev,
startnext = getboth(start)
@@ -2849,7 +2825,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode)
if last then
local char, id = ischar(last,currentfont)
if char then
- if skipsome and skipsome[char] then
+ if skiphash and skiphash[char] then
skipped = true
if trace_skips then
show_skip(dataset,sequence,char,ck,classes[char])
@@ -2956,7 +2932,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode)
if prev then
local char, id = ischar(prev,currentfont)
if char then
- if skipsome and skipsome[char] then
+ if skiphash and skiphash[char] then
skipped = true
if trace_skips then
show_skip(dataset,sequence,char,ck,classes[char])
@@ -3082,7 +3058,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode)
if current then
local char, id = ischar(current,currentfont)
if char then
- if skipsome and skipsome[char] then
+ if skiphash and skiphash[char] then
skipped = true
if trace_skips then
show_skip(dataset,sequence,char,ck,classes[char])
@@ -3195,12 +3171,12 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode)
end
end
if trace_contexts then
- chaintrac(head,start,dataset,sequence,rlmode,ck,skipped,true)
+ chaintrac(head,start,dataset,sequence,rlmode,skipped and skiphash,ck,true)
end
if diskseen or sweepnode then
- head, start, done = chaindisk(head,start,dataset,sequence,rlmode,ck,skipped)
+ head, start, done = chaindisk(head,start,dataset,sequence,rlmode,skipped and skiphash,ck)
else
- head, start, done = chainrun(head,start,last,dataset,sequence,rlmode,ck,skipped)
+ head, start, done = chainrun(head,start,last,dataset,sequence,rlmode,skipped and skiphash,ck)
end
if done then
break
@@ -3209,7 +3185,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode)
end
::next::
-- if trace_chains then
- -- chaintrac(head,start,dataset,sequence,rlmode,ck,skipped,match)
+ -- chaintrac(head,start,dataset,sequence,rlmode,skipped and skiphash,ck,false)
-- end
end
if diskseen then
@@ -3228,13 +3204,13 @@ handlers.gpos_context = handle_contextchain
-- this needs testing
-local function chained_contextchain(head,start,stop,dataset,sequence,currentlookup,rlmode)
+local function chained_contextchain(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash)
local steps = currentlookup.steps
local nofsteps = currentlookup.nofsteps
if nofsteps > 1 then
reportmoresteps(dataset,sequence)
end
- return handle_contextchain(head,start,dataset,sequence,currentlookup,rlmode)
+ return handle_contextchain(head,start,dataset,sequence,currentlookup,rlmode,skiphash)
end
chainprocs.gsub_context = chained_contextchain
@@ -3249,12 +3225,12 @@ chainprocs.gpos_context = chained_contextchain
--
-- function otf.registerchainproc(name,f)
-- -- chainprocs[name] = f
--- chainprocs[name] = function(head,start,stop,dataset,sequence,currentlookup,rlmode)
+-- chainprocs[name] = function(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash)
-- local done = currentlookup.nofsteps > 0
-- if not done then
-- reportzerosteps(dataset,sequence)
-- else
--- head, start, done = f(head,start,stop,dataset,sequence,currentlookup,rlmode)
+-- head, start, done = f(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash)
-- if not head or not start then
-- reportbadsteps(dataset,sequence)
-- end
@@ -3665,7 +3641,7 @@ end
local nesting = 0
-local function c_run_single(head,font,attr,lookupcache,step,dataset,sequence,rlmode,handler)
+local function c_run_single(head,font,attr,lookupcache,step,dataset,sequence,rlmode,skiphash,handler)
local done = false
local sweep = sweephead[head]
if sweep then
@@ -3686,7 +3662,7 @@ local function c_run_single(head,font,attr,lookupcache,step,dataset,sequence,rlm
local lookupmatch = lookupcache[char]
if lookupmatch then
local ok
- head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,1)
+ head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step)
if ok then
done = true
end
@@ -3787,7 +3763,7 @@ local function t_run_single(start,stop,font,attr,lookupcache)
return 0
end
-local function k_run_single(sub,injection,last,font,attr,lookupcache,step,dataset,sequence,rlmode,handler)
+local function k_run_single(sub,injection,last,font,attr,lookupcache,step,dataset,sequence,rlmode,skiphash,handler)
local a -- happens often so no assignment is faster
if attr then
a = getattr(sub,0)
@@ -3801,7 +3777,7 @@ local function k_run_single(sub,injection,last,font,attr,lookupcache,step,datase
if char then
local lookupmatch = lookupcache[char]
if lookupmatch then
- local h, d, ok = handler(sub,n,dataset,sequence,lookupmatch,rlmode,step,1,injection)
+ local h, d, ok = handler(sub,n,dataset,sequence,lookupmatch,rlmode,skiphash,step,injection)
if ok then
return true
end
@@ -3811,7 +3787,7 @@ local function k_run_single(sub,injection,last,font,attr,lookupcache,step,datase
end
end
-local function c_run_multiple(head,font,attr,steps,nofsteps,dataset,sequence,rlmode,handler)
+local function c_run_multiple(head,font,attr,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler)
local done = false
local sweep = sweephead[head]
if sweep then
@@ -3836,7 +3812,7 @@ local function c_run_multiple(head,font,attr,steps,nofsteps,dataset,sequence,rlm
if lookupmatch then
-- we could move all code inline but that makes things even more unreadable
local ok
- head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,i)
+ head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step)
if ok then
done = true
break
@@ -3947,7 +3923,7 @@ local function t_run_multiple(start,stop,font,attr,steps,nofsteps)
return 0
end
-local function k_run_multiple(sub,injection,last,font,attr,steps,nofsteps,dataset,sequence,rlmode,handler)
+local function k_run_multiple(sub,injection,last,font,attr,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler)
local a -- happens often so no assignment is faster
if attr then
a = getattr(sub,0)
@@ -3964,7 +3940,7 @@ local function k_run_multiple(sub,injection,last,font,attr,steps,nofsteps,datase
local lookupcache = step.coverage
local lookupmatch = lookupcache[char]
if lookupmatch then
- local h, d, ok = handler(sub,n,dataset,sequence,lookupmatch,rlmode,step,i,injection) -- sub was head
+ local h, d, ok = handler(sub,n,dataset,sequence,lookupmatch,rlmode,skiphash,step,injection) -- sub was head
if ok then
return true
end
@@ -4148,16 +4124,18 @@ do
local handler = handlers[typ] -- store in dataset
local steps = sequence.steps
local nofsteps = sequence.nofsteps
- local skipsome = sequence.skipsome
+ local skiphash = sequence.skiphash
if not steps then
- -- this permits injection, watch the different arguments
- local h, d, ok = handler(head,head,dataset,sequence,nil,nil,nil,0,font,attr)
+ -- This permits injection, watch the different arguments. Watch out, the arguments passed
+ -- are not frozen as we might extend or change this. Is this used at all apart from some
+ -- experiments?
+ local h, ok = handler(head,dataset,sequence,initialrl,font,attr) -- less arguments now
if ok then
done = true
- if h then
- head = h
- end
+ end
+ if h and h ~= head then
+ head = h
end
elseif typ == "gsub_reversecontextchain" then
--
@@ -4185,9 +4163,8 @@ do
local lookupcache = step.coverage
local lookupmatch = lookupcache[char]
if lookupmatch then
- -- todo: disc?
local ok
- head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,i)
+ head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step)
if ok then
done = true
break
@@ -4216,7 +4193,7 @@ do
while start do
local char, id = ischar(start,font)
if char then
- if skipsome and skipsome[char] then -- we never needed it here but let's try
+ if skiphash and skiphash[char] then -- we never needed it here but let's try
start = getnext(start)
else
local lookupmatch = lookupcache[char]
@@ -4231,7 +4208,7 @@ do
end
if a then
local ok
- head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,1)
+ head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step)
if ok then
done = true
end
@@ -4252,11 +4229,11 @@ do
if not discs or discs[start] == true then
local ok
if gpossing then
- start, ok = kernrun(start,k_run_single, font,attr,lookupcache,step,dataset,sequence,rlmode,handler)
+ start, ok = kernrun(start,k_run_single, font,attr,lookupcache,step,dataset,sequence,rlmode,skiphash,handler)
elseif typ == "gsub_ligature" then
- start, ok = testrun(start,t_run_single,c_run_single,font,attr,lookupcache,step,dataset,sequence,rlmode,handler)
+ start, ok = testrun(start,t_run_single,c_run_single,font,attr,lookupcache,step,dataset,sequence,rlmode,skiphash,handler)
else
- start, ok = comprun(start,c_run_single, font,attr,lookupcache,step,dataset,sequence,rlmode,handler)
+ start, ok = comprun(start,c_run_single, font,attr,lookupcache,step,dataset,sequence,rlmode,skiphash,handler)
end
if ok then
done = true
@@ -4281,7 +4258,7 @@ do
if char then
local m = merged[char]
if m then
- if skipsome and skipsome[char] then -- we never needed it here but let's try
+ if skiphash and skiphash[char] then -- we never needed it here but let's try
start = getnext(start)
else
local a -- happens often so no assignment is faster
@@ -4302,7 +4279,7 @@ do
if lookupmatch then
-- we could move all code inline but that makes things even more unreadable
local ok
- head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,i)
+ head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step)
if ok then
done = true
break
@@ -4329,11 +4306,11 @@ do
if not discs or discs[start] == true then
local ok
if gpossing then
- start, ok = kernrun(start,k_run_multiple, font,attr,steps,nofsteps,dataset,sequence,rlmode,handler)
+ start, ok = kernrun(start,k_run_multiple, font,attr,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler)
elseif typ == "gsub_ligature" then
- start, ok = testrun(start,t_run_multiple,c_run_multiple,font,attr,steps,nofsteps,dataset,sequence,rlmode,handler)
+ start, ok = testrun(start,t_run_multiple,c_run_multiple,font,attr,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler)
else
- start, ok = comprun(start,c_run_multiple, font,attr,steps,nofsteps,dataset,sequence,rlmode,handler)
+ start, ok = comprun(start,c_run_multiple, font,attr,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler)
end
if ok then
done = true
@@ -4419,7 +4396,7 @@ do
position = position + 1
local m = merged[char]
if m then
- if skipsome and skipsome[char] then -- we never needed it here but let's try
+ if skiphash and skiphash[char] then -- we never needed it here but let's try
start = getnext(start)
else
for i=m[1],m[2] do
@@ -4428,7 +4405,7 @@ do
local lookupmatch = lookupcache[char]
if lookupmatch then
local ok
- head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,step,i)
+ head, start, ok = handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step)
if ok then
-- if matches then
-- matches[position] = i
@@ -4526,27 +4503,35 @@ otf.handlers = handlers -- used in devanagari
local setspacekerns = nodes.injections.setspacekerns if not setspacekerns then os.exit() end
+-- This pseudo feature has no steps, so it gets called as:
+--
+-- function(head,dataset,sequence,initialrl,font,attr)
+-- return head, done
+-- end
+--
+-- Also see (!!).
+
if fontfeatures then
- function otf.handlers.trigger_space_kerns(head,start,dataset,sequence,_,_,_,_,font,attr)
+ function handlers.trigger_space_kerns(head,dataset,sequence,initialrl,font,attr)
local features = fontfeatures[font]
local enabled = features and features.spacekern and features.kern
if enabled then
setspacekerns(font,sequence)
end
- return head, start, enabled
+ return head, enabled
end
else -- generic (no hashes)
- function otf.handlers.trigger_space_kerns(head,start,dataset,sequence,_,_,_,_,font,attr)
+ function handlers.trigger_space_kerns(head,dataset,sequence,initialrl,font,attr)
local shared = fontdata[font].shared
local features = shared and shared.features
local enabled = features and features.spacekern and features.kern
if enabled then
setspacekerns(font,sequence)
end
- return head, start, enabled
+ return head, enabled
end
end
@@ -4676,6 +4661,7 @@ local function spaceinitializer(tfmdata,value) -- attr
}
if last > 0 then
local triggersequence = {
+ -- no steps, see (!!)
features = { kern = feat or { dflt = { dflt = true, } } },
flags = noflags,
name = "trigger_space_kerns",