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.lua59
1 files changed, 51 insertions, 8 deletions
diff --git a/tex/context/base/mkiv/font-osd.lua b/tex/context/base/mkiv/font-osd.lua
index 34c047290..d169faf64 100644
--- a/tex/context/base/mkiv/font-osd.lua
+++ b/tex/context/base/mkiv/font-osd.lua
@@ -6,6 +6,16 @@ if not modules then modules = { } end modules ['font-osd'] = { -- script devanag
license = "see context related readme files"
}
+local experiment1 = false
+local experiment2 = false
+local experiment2b1 = false
+local experiment2b2 = false
+
+experiments.register("fonts.indic.experiment1", function(v) experiment1 = v end)
+experiments.register("fonts.indic.experiment2", function(v) experiment2 = v end)
+experiments.register("fonts.indic.experiment2b1", function(v) experiment2b1 = v end)
+experiments.register("fonts.indic.experiment2b2", function(v) experiment2b2 = v end)
+
-- we need to check nbsphash (context only)
-- A few remarks:
@@ -1382,13 +1392,16 @@ local function reorder_one(head,start,stop,font,attr,nbspaces)
end
if reph or vattu then
+-- print(">>> has reph or vattu")
local current = start
local cns = nil
local done = false
while current ~= stop do
+-- print("\t>>> current ~= stop yet")
local c = current
local n = getnext(current)
if ra[getchar(current)] and halant[getchar(n)] then
+-- print("\t\t>>> current ra; next halant")
c = n
n = getnext(n)
local b, bn = base, base
@@ -1402,6 +1415,7 @@ local function reorder_one(head,start,stop,font,attr,nbspaces)
if getstate(current,s_rphf) then
-- position Reph (Ra + H) after post-base 'matra' (if any) since these
-- become marks on the 'matra', not on the base glyph
+-- print("\t\t\t>>> ra + halant form → reph")
if b ~= current then
if current == start then
if head == start then
@@ -1421,6 +1435,7 @@ local function reorder_one(head,start,stop,font,attr,nbspaces)
end
elseif cns and getnext(cns) ~= current then -- todo: optimize next
-- position below-base Ra (vattu) following the consonants on which it is placed (either the base consonant or one of the pre-base consonants)
+-- print("\t\t\t>>> ra below base (vattu) → rkrf")
local cp = getprev(current)
local cnsn = getnext(cns)
setlink(cp,n)
@@ -1434,14 +1449,17 @@ local function reorder_one(head,start,stop,font,attr,nbspaces)
current = getprev(n)
end
else
+-- print("\t\t>>> NOT! current ra; next halant")
local char = getchar(current)
if consonant[char] then
+-- print("\t\t\t>>> is consonant")
cns = current
local next = getnext(cns)
if halant[getchar(next)] then
cns = next
end
if not vatucache[char] then
+-- print("\t\t\t\t>>> is in vatucache")
next = getnext(cns)
while dependent_vowel[getchar(next)] do
cns = next
@@ -1449,6 +1467,7 @@ local function reorder_one(head,start,stop,font,attr,nbspaces)
end
end
elseif char == c_nbsp then
+-- print("\t\t\t>>> is nbsp")
nbspaces = nbspaces + 1
cns = current
local next = getnext(cns)
@@ -1917,6 +1936,8 @@ local function reorder_two(head,start,stop,font,attr,nbspaces) -- maybe do a pas
reorderreph.coverage = { } -- use local
rephbase[font] = { } -- use local
+-- print("!!!!!! reorder two ")
+
for i=1,#seqsubset do
-- this can be done more efficient, the last test and less getnext
@@ -2104,6 +2125,7 @@ local function reorder_two(head,start,stop,font,attr,nbspaces) -- maybe do a pas
end
end
else -- not Stand Alone cluster
+-- print("!!!! not standalone cluster")
local last = getnext(stop)
while current ~= last do -- find base consonant
local next = getnext(current)
@@ -2173,7 +2195,10 @@ local function reorder_two(head,start,stop,font,attr,nbspaces) -- maybe do a pas
end
end
--
- if not moved[current] and dependent_vowel[char] then
+-- print("char: " .. char)
+-- if not moved[current] and dependent_vowel[char] then
+ if dependent_vowel[char] then
+-- print(">>!! dependent vowel")
if pre_mark[char] then -- or: if before_main or before_half
moved[current] = true
-- can be helper to remove one node
@@ -2384,8 +2409,8 @@ local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowe
if not n then
return c
end
+ local v = ischar(n,font)
if variant == 1 then
- local v = ischar(n,font)
if v and nukta[v] then
n = getnext(n)
if n then
@@ -2418,7 +2443,6 @@ local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowe
end
end
elseif variant == 2 then
- local v = ischar(n,font)
if v and nukta[v] then
c = n
end
@@ -2443,11 +2467,11 @@ local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowe
end
end
-- c = ms_matra(c)
- local n = getnext(c)
+ n = getnext(c)
if not n then
return c
end
- local v = ischar(n,font)
+ v = ischar(n,font)
if not v then
return c
end
@@ -2555,13 +2579,22 @@ local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowe
end
end
+-- Consonant syllable:
+--
+-- { C + [ N ] + < H + [ < ZWNJ | ZWJ > ] | < ZWNJ | ZWJ > + H > }
+-- + C
+-- + [ N ]
+-- + [ A ]
+-- + [ < H + [ < ZWNJ|ZWJ > ] | { M } + [ N ] + [ H ] > ]
+-- + [ SM ]
+-- + [ ( VD ) ]
+
local function analyze_next_chars_two(c,font)
- local n, v
- n = getnext(c)
+ local n = getnext(c)
if not n then
return c
end
- v = ischar(n,font)
+ local v = ischar(n,font)
if v and nukta[v] then
c = n
end
@@ -2677,6 +2710,10 @@ local function analyze_next_chars_two(c,font)
for k=1,#vowels do
local v = vowels[k]
if pre_mark[v] and not already_pre_mark then
+-- print(">>> pre_mark")
+-- if dependent_vowel[v] then
+-- print(">>>> dependent vowel")
+-- end
already_pre_mark = true
elseif above_mark[v] and not already_above_mark then
already_above_mark = true
@@ -3031,12 +3068,15 @@ local function method_two(head,font,attr)
end
end
if independent_vowel[char] then
+-- print("!!>>> independent_vowel")
-- vowel-based syllable: [Ra+H]+V+[N]+[<[<ZWJ|ZWNJ>]+H+C|ZWJ+C>]+[{M}+[N]+[H]]+[SM]+[(VD)]
current = analyze_next_chars_one(c,font,1)
syllableend = current
else
+-- print("!!>>> dependent vowel")
local standalone = char == c_nbsp
if standalone then
+-- print("!!>>> standalone")
nbspaces = nbspaces + 1
local p = getprev(current)
if not p then
@@ -3050,10 +3090,12 @@ local function method_two(head,font,attr)
end
end
if standalone then
+-- print("!!>>>>>>> next standalone")
-- Stand Alone cluster (at the start of the word only): #[Ra+H]+NBSP+[N]+[<[<ZWJ|ZWNJ>]+H+C>]+[{M}+[N]+[H]]+[SM]+[(VD)]
current = analyze_next_chars_one(c,font,2)
syllableend = current
elseif consonant[getchar(current)] then
+-- print("!!>>>>>>> a consonant")
-- WHY current INSTEAD OF c ?
-- Consonant syllable: {C+[N]+<H+[<ZWNJ|ZWJ>]|<ZWNJ|ZWJ>+H>} + C+[N]+[A] + [< H+[<ZWNJ|ZWJ>] | {M}+[N]+[H]>]+[SM]+[(VD)]
current = analyze_next_chars_two(current,font) -- not c !
@@ -3062,6 +3104,7 @@ local function method_two(head,font,attr)
end
end
if syllableend then
+-- print("!!!>>> syllable end")
syllabe = syllabe + 1
local c = syllablestart
local n = getnext(syllableend)