summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/font-ots.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2021-08-19 20:32:31 +0200
committerContext Git Mirror Bot <phg@phi-gamma.net>2021-08-19 20:32:31 +0200
commitaf60125ab3fa9e482720f0f46c2143fa08512113 (patch)
tree3e85c8a8a5979ebd05b891f8ecfb93d1b69ac41b /tex/context/base/mkiv/font-ots.lua
parentd3d93bc4f0d21a259fdafee5ba1a744999474c28 (diff)
downloadcontext-af60125ab3fa9e482720f0f46c2143fa08512113.tar.gz
2021-08-19 19:43:00
Diffstat (limited to 'tex/context/base/mkiv/font-ots.lua')
-rw-r--r--tex/context/base/mkiv/font-ots.lua57
1 files changed, 31 insertions, 26 deletions
diff --git a/tex/context/base/mkiv/font-ots.lua b/tex/context/base/mkiv/font-ots.lua
index 30d79c407..8e8be6f95 100644
--- a/tex/context/base/mkiv/font-ots.lua
+++ b/tex/context/base/mkiv/font-ots.lua
@@ -763,7 +763,7 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skip
while current do
local char = ischar(current,currentfont)
if char then
- local lg = ligature[char]
+ local lg = not tonumber(ligature) and ligature[char]
if lg then
stop = current
ligature = lg
@@ -776,14 +776,14 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skip
end
end
if stop then
- local lig = ligature.ligature
- if lig then
+ local ligature = tonumber(ligature) or ligature.ligature
+ if ligature then
if trace_ligatures then
local stopchar = getchar(stop)
- head, start = markstoligature(head,start,stop,lig)
+ head, start = markstoligature(head,start,stop,ligature)
logprocess("%s: replacing %s upto %s by ligature %s case 1",pref(dataset,sequence),gref(startchar),gref(stopchar),gref(getchar(start)))
else
- head, start = markstoligature(head,start,stop,lig)
+ head, start = markstoligature(head,start,stop,ligature)
end
return head, start, true, false
else
@@ -799,7 +799,7 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skip
if skiphash and skiphash[char] then
current = getnext(current)
else
- local lg = ligature[char]
+ local lg = not tonumber(ligature) and ligature[char]
if lg then
if marks[char] then
hasmarks = true
@@ -833,20 +833,20 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skip
local match
if replace then
local char = ischar(replace,currentfont)
- if char and ligature[char] then
+ if char and (not tonumber(ligature) and ligature[char]) then
match = true
end
end
if not match and pre then
local char = ischar(pre,currentfont)
- if char and ligature[char] then
+ if char and (not tonumber(ligature) and ligature[char]) then
match = true
end
end
if not match and not pre or not replace then
local n = getnext(discfound)
local char = ischar(n,currentfont)
- if char and ligature[char] then
+ if char and (not tonumber(ligature) and ligature[char]) then
match = true
end
end
@@ -890,24 +890,26 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skip
return head, start, true, true
end
end
- local lig = ligature.ligature
- if lig then
+ local ligature = tonumber(ligature) or ligature.ligature
+ if ligature then
if stop then
if trace_ligatures then
local stopchar = getchar(stop)
- -- head, start = toligature(head,start,stop,lig,dataset,sequence,skiphash,discfound,hasmarks)
- head, start = toligature(head,start,stop,lig,dataset,sequence,skiphash,false,hasmarks)
- logprocess("%s: replacing %s upto %s by ligature %s case 2",pref(dataset,sequence),gref(startchar),gref(stopchar),gref(lig))
+ -- head, start = toligature(head,start,stop,ligature,dataset,sequence,skiphash,discfound,hasmarks)
+ head, start = toligature(head,start,stop,ligature,dataset,sequence,skiphash,false,hasmarks)
+ logprocess("%s: replacing %s upto %s by ligature %s case 2",pref(dataset,sequence),gref(startchar),gref(stopchar),gref(ligature))
+ -- we can have a rare case of multiple disc in a lig but that makes no sense language wise but if really
+ -- needed we could backtrack if we're in a disc node
else
- -- head, start = toligature(head,start,stop,lig,dataset,sequence,skiphash,discfound,hasmarks)
- head, start = toligature(head,start,stop,lig,dataset,sequence,skiphash,false,hasmarks)
+ -- head, start = toligature(head,start,stop,ligature,dataset,sequence,skiphash,discfound,hasmarks)
+ head, start = toligature(head,start,stop,ligature,dataset,sequence,skiphash,false,hasmarks)
end
else
-- weird but happens (in some arabic font)
resetinjection(start)
- setchar(start,lig)
+ setchar(start,ligature)
if trace_ligatures then
- logprocess("%s: replacing %s by (no real) ligature %s case 3",pref(dataset,sequence),gref(startchar),gref(lig))
+ logprocess("%s: replacing %s by (no real) ligature %s case 3",pref(dataset,sequence),gref(startchar),gref(ligature))
end
end
return head, start, true, false
@@ -1484,7 +1486,7 @@ function chainprocs.gsub_ligature(head,start,stop,dataset,sequence,currentlookup
current = getnext(current)
-- end
else
- local lg = ligatures[schar]
+ local lg = not tonumber(ligatures) and ligatures[schar]
if lg then
ligatures = lg
last = current
@@ -1503,7 +1505,7 @@ function chainprocs.gsub_ligature(head,start,stop,dataset,sequence,currentlookup
end
end
end
- local ligature = ligatures.ligature
+ local ligature = tonumber(ligatures) or ligatures.ligature
if ligature then
if chainindex then
stop = last
@@ -1978,7 +1980,9 @@ local function chainrun(head,start,last,dataset,sequence,rlmode,skiphash,ck)
local chainproc = chainprocs[chainkind]
if chainproc then
local ok
- head, start, ok = chainproc(head,start,last,dataset,sequence,chainstep,rlmode,skiphash)
+ -- HH: chainindex 1 added here (for KAI to check too), there are weird ligatures e.g.
+ -- char + mark -> char where mark has to disappear
+ head, start, ok = chainproc(head,start,last,dataset,sequence,chainstep,rlmode,skiphash,1)
if ok then
done = true
end
@@ -2471,6 +2475,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode,s
local ck = contexts[k]
local seq = ck[3]
local f = ck[4] -- first current
+local last = start
if not startchar or not seq[f][startchar] then
-- report("no hit in %a at %i of %i contexts",sequence.type,k,nofcontexts)
goto next
@@ -2481,7 +2486,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode,s
else
local l = ck[5] -- last current
local current = start
- local last = start
+-- local last = start
-- current match
@@ -3409,7 +3414,7 @@ local function t_run_single(start,stop,font,attr,lookupcache)
while s do
local char = ischar(s,font)
if char then
- local lg = lookupmatch[char]
+ local lg = not tonumber(lookupmatch) and lookupmatch[char]
if lg then
if sstop then
d = 1
@@ -3439,7 +3444,7 @@ local function t_run_single(start,stop,font,attr,lookupcache)
break
end
end
- if l and l.ligature then -- so we test for ligature
+ if l and (tonumber(l) or l.ligature) then -- so we test for ligature
lastd = d
end
-- why not: if not l then break elseif l.ligature then return d end
@@ -3580,7 +3585,7 @@ local function t_run_multiple(start,stop,font,attr,steps,nofsteps)
while s do
local char = ischar(s)
if char then
- local lg = lookupmatch[char]
+ local lg = not tonumber(lookupmatch) and lookupmatch[char]
if lg then
if sstop then
d = 1
@@ -3610,7 +3615,7 @@ local function t_run_multiple(start,stop,font,attr,steps,nofsteps)
break
end
end
- if l and l.ligature then
+ if l and (tonumber(l) or l.ligature) then
lastd = d
end
end