From 50476780411fb84f1f4d0dcb7cd865c1eba4141b Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 20 Aug 2016 21:31:35 +0200 Subject: [fontloader] sync with Context as of 2016-08-29 --- src/fontloader/misc/fontloader-font-osd.lua | 156 ++++++++++++++-------------- 1 file changed, 79 insertions(+), 77 deletions(-) (limited to 'src/fontloader/misc/fontloader-font-osd.lua') diff --git a/src/fontloader/misc/fontloader-font-osd.lua b/src/fontloader/misc/fontloader-font-osd.lua index 26af691..b67cc92 100644 --- a/src/fontloader/misc/fontloader-font-osd.lua +++ b/src/fontloader/misc/fontloader-font-osd.lua @@ -613,13 +613,12 @@ local function initializedevanagi(tfmdata) local steps = sequence.steps local nofsteps = sequence.nofsteps local features = sequence.features - if features["rphf"] then - -- deva + local has_rphf = features.rphf + local has_blwf = features.blwf + if has_rphf and has_rphf.deva then devanagari.reph = true - elseif features["blwf"] then - -- deva + elseif has_blwf and has_blwf.deva then devanagari.vattu = true - -- dev2 for i=1,nofsteps do local step = steps[i] local coverage = step.coverage @@ -632,59 +631,71 @@ local function initializedevanagi(tfmdata) end end end - if valid[kind] then - for i=1,nofsteps do - local step = steps[i] - local coverage = step.coverage - if coverage then - local reph = false - if step.osdstep 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 + for kind, spec in next, features do -- beware, this is + if spec.dev2 and valid[kind] then + for i=1,nofsteps do + local step = steps[i] + local coverage = step.coverage + 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 + break + end end end - if reph then - break - end + else + -- rphf might be result of other handler/chainproc end end - else - -- rphf might be result of other handler/chainproc + seqsubset[#seqsubset+1] = { kind, coverage, reph } end - seqsubset[#seqsubset+1] = { kind, coverage, reph } end end - end - if kind == "pref" then - local sequence = dataset[3] -- was [5] - local steps = sequence.steps - local nofsteps = sequence.nofsteps - for i=1,nofsteps do - local step = steps[i] - local coverage = step.coverage - if coverage then - for k, v in next, halant do - local h = coverage[k] - if h then - local found = false - for k, v in next, h do - found = v and v.ligature + if kind == "pref" then + local steps = sequence.steps + local nofsteps = sequence.nofsteps + for i=1,nofsteps do + local step = steps[i] + local coverage = step.coverage + if coverage then + for k, v in next, halant do + local h = coverage[k] + if h then + local found = false + for k, v in next, h do + found = v and v.ligature + if found then + pre_base_reordering_consonants[k] = found + break + end + end if found then - pre_base_reordering_consonants[k] = found break end end - if found then - break - end end end end @@ -1132,6 +1143,8 @@ function handlers.devanagari_reorder_matras(head,start) -- no leak start = startnext break end + else + break end current = next end @@ -1171,12 +1184,12 @@ function handlers.devanagari_reorder_reph(head,start) local startfont = getfont(start) local startattr = getprop(start,a_syllabe) while current do - local char = ischar(current,font) + local char = ischar(current,startfont) if char and getprop(current,a_syllabe) == startattr then -- step 2 if halant[char] and not getprop(current,a_state) then local next = getnext(current) if next then - local nextchar = ischar(next,font) + local nextchar = ischar(next,startfont) if nextchar and zw_char[nextchar] and getprop(next,a_syllabe) == startattr then current = next next = getnext(current) @@ -1198,7 +1211,7 @@ function handlers.devanagari_reorder_reph(head,start) if not startnext then current = getnext(start) while current do - local char = ischar(current,font) + local char = ischar(current,startfont) if char and getprop(current,a_syllabe) == startattr then -- step 4 if getprop(current,a_state) == s_pstf then -- post-base startnext = getnext(start) @@ -1223,7 +1236,7 @@ function handlers.devanagari_reorder_reph(head,start) current = getnext(start) local c = nil while current do - local char = ischar(current,font) + local char = ischar(current,startfont) if char and getprop(current,a_syllabe) == startattr then -- step 5 if not c and mark_above_below_post[char] and reorder_class[char] ~= "after subscript" then c = current @@ -1250,7 +1263,7 @@ function handlers.devanagari_reorder_reph(head,start) current = start local next = getnext(current) while next do - local nextchar = ischar(next,font) + local nextchar = ischar(next,startfont) if nextchar and getprop(next,a_syllabe) == startattr then --step 6 current = next next = getnext(current) @@ -1263,7 +1276,7 @@ function handlers.devanagari_reorder_reph(head,start) head = remove_node(head,start) local next = getnext(current) setlink(start,next) - setlink(current,"next",start) + setlink(current,start) start = startnext end end @@ -1290,12 +1303,12 @@ function handlers.devanagari_reorder_pre_base_reordering_consonants(head,start) local startattr = getprop(start,a_syllabe) -- can be fast for loop + caching state while current do - local char = ischar(current,font) + local char = ischar(current,startfont) if char and getprop(current,a_syllabe) == startattr then local next = getnext(current) if halant[char] and not getprop(current,a_state) then if next then - local nextchar = ischar(next,font) + local nextchar = ischar(next,startfont) if nextchar and getprop(next,a_syllabe) == startattr then if nextchar == c_zwnj or nextchar == c_zwj then current = next @@ -1319,13 +1332,13 @@ function handlers.devanagari_reorder_pre_base_reordering_consonants(head,start) current = getnext(start) startattr = getprop(start,a_syllabe) while current do - local char = ischar(current,font) + local char = ischar(current,startfont) if char and getprop(current,a_syllabe) == startattr then if not consonant[char] and getprop(current,a_state) then -- main startnext = getnext(start) removenode(start,start) local prev = getprev(current) - setlink(start,prev) + setlink(prev,start) setlink(start,current) start = startnext break @@ -1426,21 +1439,7 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa local kind = subset[1] local lookupcache = subset[2] if kind == "rphf" then - for k, v in next, ra do - local r = lookupcache[k] - if r then - 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 - end + reph = subset[3] local current = start local last = getnext(stop) while current ~= last do @@ -1473,7 +1472,7 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa if current ~= stop then local c = locl[current] or getchar(current) local found = lookupcache[c] - if found then + if found then -- pre-base: pref Halant + Consonant local next = getnext(current) local n = locl[next] or getchar(next) if found[n] then @@ -1718,7 +1717,7 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa local prev = getprev(current) if prev ~= target then local next = getnext(current) - setlink(next,prev) + setlink(prev,next) if current == stop then stop = prev end @@ -1752,7 +1751,7 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa stop = current end local prev = getprev(c) - setlink(next,prev) + setlink(prev,next) local nextnext = getnext(next) setnext(current,nextnext) local nextnextnext = getnext(nextnext) @@ -1766,6 +1765,9 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa end if getchar(base) == c_nbsp then + if base == stop then + stop = getprev(stop) + end nbspaces = nbspaces - 1 head = remove_node(head, base) flush_node(base) @@ -1815,7 +1817,7 @@ local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowe elseif (vv == c_zwnj or vv == c_zwj) and halant[vvv] then local nnnn = getnext(nnn) if nnnn then - local vvvv = ischar(nnnn) + local vvvv = ischar(nnnn,font) if vvvv and consonant[vvvv] then c = nnnn end @@ -1838,7 +1840,7 @@ local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowe local nn = getnext(n) if nn then local vv = ischar(nn,font) - if vv and zw_char[vv] then + if vv and zw_char[v] then n = nn v = vv nn = getnext(nn) -- cgit v1.2.3