summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/font-osd.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/font-osd.lua')
-rw-r--r--tex/context/base/mkiv/font-osd.lua98
1 files changed, 27 insertions, 71 deletions
diff --git a/tex/context/base/mkiv/font-osd.lua b/tex/context/base/mkiv/font-osd.lua
index ca20f6782..04fbf88f5 100644
--- a/tex/context/base/mkiv/font-osd.lua
+++ b/tex/context/base/mkiv/font-osd.lua
@@ -6,13 +6,6 @@ if not modules then modules = { } end modules ['font-osd'] = { -- script devanag
license = "see context related readme files"
}
--- I'll optimize this one with ischar (much faster) when I see a reason (read: I need a
--- proper test case first).
-
--- This is a version of font-odv.lua adapted to the new font loader and more
--- direct hashing. The initialization code has been adapted (more efficient). One day
--- I'll speed this up ... char swapping and properties.
-
-- A few remarks:
--
-- This code is a partial rewrite of the code that deals with devanagari. The data and logic
@@ -29,7 +22,8 @@ if not modules then modules = { } end modules ['font-osd'] = { -- script devanag
-- much can get messed up in over a week work) it could be that I introduced bugs. There
-- is more to gain (esp in the functions applied to a range) but I'll do that when
-- everything works as expected. Kai's original code is kept in font-odk.lua as a reference
--- so blame me (HH) for bugs.
+-- so blame me (HH) for bugs. (We no longer ship that file as the code below has diverted
+-- too much and in the meantime has more than doubled in size.)
--
-- Interesting is that Kai managed to write this on top of the existing otf handler. Only a
-- few extensions were needed, like a few more analyzing states and dealing with changed
@@ -467,7 +461,6 @@ local sequence_reorder_matras = {
nofsteps = 1,
steps = {
{
- osdstep = true,
coverage = pre_mark,
}
}
@@ -482,7 +475,6 @@ local sequence_reorder_reph = {
nofsteps = 1,
steps = {
{
- osdstep = true,
coverage = { },
}
}
@@ -497,7 +489,6 @@ local sequence_reorder_pre_base_reordering_consonants = {
nofsteps = 1,
steps = {
{
- osdstep = true,
coverage = { },
}
}
@@ -511,7 +502,7 @@ local sequence_remove_joiners = {
type = "devanagari_remove_joiners",
nofsteps = 1,
steps = {
- { osdstep = true,
+ {
coverage = both_joiners_true,
},
}
@@ -639,35 +630,22 @@ local function initializedevanagi(tfmdata)
if coverage then
local reph = false
if kind == "rphf" then
- --
- -- KE: I don't understand the rationale behind osdstep. The original if
- -- statement checked whether coverage is contextual chaining.
- --
- -- HH: The osdstep signals that we deal with our own feature here, not
- -- one in the font itself so it was just a safeguard against us overloading
- -- something driven by the font.
- --
- -- if step.osdstep then -- selective
- if true then -- always
- -- rphf acts on consonant + halant
- for k, v in next, ra do
- local r = coverage[k]
- if r then
- local h = false
- for k, v in next, halant do
- local h = r[k]
- if h then
- reph = h.ligature or false
- break
- end
- end
- if reph then
+ -- rphf acts on consonant + halant
+ for k, v in next, ra do
+ local r = coverage[k]
+ if r then
+ local h = false
+ for k, v in next, halant do
+ local h = r[k]
+ if h then
+ reph = h.ligature or false
break
end
end
+ if reph then
+ break
+ end
end
- else
- -- rphf might be result of other handler/chainproc
end
end
seqsubset[#seqsubset+1] = { kind, coverage, reph }
@@ -1140,7 +1118,7 @@ function handlers.devanagari_reorder_matras(head,start) -- no leak
head = remove_node(head,start)
setlink(start,next)
setlink(current,start)
- -- setlink(current,start,next) -- maybe
+ -- setlink(current,start,next) -- maybe
start = startnext
break
end
@@ -1200,7 +1178,7 @@ function handlers.devanagari_reorder_reph(head,start)
head = remove_node(head,start)
setlink(start,next)
setlink(current,start)
- -- setlink(current,start,next) -- maybe
+ -- setlink(current,start,next) -- maybe
start = startnext
startattr = getprop(start,a_syllabe)
break
@@ -1220,7 +1198,7 @@ function handlers.devanagari_reorder_reph(head,start)
head = remove_node(head,start)
setlink(getprev(current),start)
setlink(start,current)
- -- setlink(getprev(current),start,current) -- maybe
+ -- setlink(getprev(current),start,current) -- maybe
start = startnext
startattr = getprop(start,a_syllabe)
break
@@ -1254,7 +1232,7 @@ function handlers.devanagari_reorder_reph(head,start)
head = remove_node(head,start)
setlink(getprev(c),start)
setlink(start,c)
- -- setlink(getprev(c),start,c) -- maybe
+ -- setlink(getprev(c),start,c) -- maybe
-- end
start = startnext
startattr = getprop(start,a_syllabe)
@@ -1278,7 +1256,7 @@ function handlers.devanagari_reorder_reph(head,start)
head = remove_node(head,start)
setlink(start,getnext(current))
setlink(current,start)
- -- setlink(current,start,getnext(current)) -- maybe
+ -- setlink(current,start,getnext(current)) -- maybe
start = startnext
end
end
@@ -1295,7 +1273,11 @@ end
-- 2 Try to find a target position the same way as for pre-base matra. If it is found, reorder pre-base consonant glyph.
-- 3 If position is not found, reorder immediately before main consonant.
--- UNTESTED: NOT CALLED IN EXAMPLE
+-- Here we implement a few handlers:
+--
+-- function(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step)
+-- return head, start, done
+-- end
function handlers.devanagari_reorder_pre_base_reordering_consonants(head,start)
local current = start
@@ -1322,7 +1304,7 @@ function handlers.devanagari_reorder_pre_base_reordering_consonants(head,start)
removenode(start,start)
setlink(start,next)
setlink(current,start)
- -- setlink(current,start,next) -- maybe
+ -- setlink(current,start,next) -- maybe
start = startnext
break
end
@@ -1355,32 +1337,6 @@ function handlers.devanagari_reorder_pre_base_reordering_consonants(head,start)
return head, start, true
end
--- function handlers.devanagari_remove_joiners(head,start,kind,lookupname,replacement)
--- local stop = getnext(start)
--- local font = getfont(start)
--- while stop do
--- local char = ischar(stop)
--- if char and (char == c_zwnj or char == c_zwj) then
--- stop = getnext(stop)
--- else
--- break
--- end
--- end
--- if stop then
--- setnext(getprev(stop))
--- setprev(stop,getprev(start))
--- end
--- local prev = getprev(start)
--- if prev then
--- setnext(prev,stop)
--- end
--- if head == start then
--- head = stop
--- end
--- flush_list(start)
--- return head, stop, true
--- end
-
function handlers.devanagari_remove_joiners(head,start,kind,lookupname,replacement)
local stop = getnext(start)
local font = getfont(start)
@@ -1592,7 +1548,7 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa
next = getnext(current)
local tmp = getnext(next)
local changestop = next == stop
- setnext(next,nil)
+ setnext(next)
setprop(current,a_state,s_pref)
current = processcharacters(current,font)
setprop(current,a_state,s_blwf)