diff options
Diffstat (limited to 'tex/context/base/font-odv.lua')
-rw-r--r-- | tex/context/base/font-odv.lua | 351 |
1 files changed, 101 insertions, 250 deletions
diff --git a/tex/context/base/font-odv.lua b/tex/context/base/font-odv.lua index 69f74dfa5..b518fb79c 100644 --- a/tex/context/base/font-odv.lua +++ b/tex/context/base/font-odv.lua @@ -58,7 +58,7 @@ if not modules then modules = { } end modules ['font-odv'] = { -- local function ms_matra(c) -- local prebase, abovebase, belowbase, postbase = true, true, true, true -- local n = c.next --- while n and n.id == glyph_code and n.subtype < 256 and n.font == font do +-- while n and n.id == glyph_code and n.subtype<256 and n.font == font do -- local char = n.char -- if not dependent_vowel[char] then -- break @@ -83,6 +83,7 @@ if not modules then modules = { } end modules ['font-odv'] = { local insert, imerge = table.insert, table.imerge local next = next +local trace_analyzing = false trackers.register("otf.analyzing", function(v) trace_analyzing = v end) local report_devanagari = logs.reporter("otf","devanagari") fonts = fonts or { } @@ -100,11 +101,13 @@ local methods = fonts.analyzers.methods local otffeatures = fonts.constructors.newfeatures("otf") local registerotffeature = otffeatures.register -local insert_node_after = nodes.insert_after -local copy_node = nodes.copy -local free_node = nodes.free -local remove_node = nodes.remove -local flush_list = nodes.flush_list +local processcharacters = nodes.handlers.characters + +local insert_node_after = node.insert_after +local copy_node = node.copy +local free_node = node.free +local remove_node = node.remove +local flush_list = node.flush_list local unsetvalue = attributes.unsetvalue @@ -123,41 +126,11 @@ local s_pref = states.pref local s_blwf = states.blwf local s_pstf = states.pstf -local replace_all_nbsp = nil - -replace_all_nbsp = function(head) -- delayed definition - replace_all_nbsp = typesetters and typesetters.characters and typesetters.characters.replacenbspaces or function(head) - return head - end - return replace_all_nbsp(head) -end - -local fontprocesses = fonts.hashes.processes -local xprocesscharacters = nil - -xprocesscharacters = function(head,font) - xprocesscharacters = nodes.handlers.characters - return xprocesscharacters(head,font) -end - -local function processcharacters(head,font) - return xprocesscharacters(head) -end - --- function processcharacters(head,font) --- local processors = fontprocesses[font] --- for i=1,#processors do --- head = processors[i](head,font,0) --- end --- return head, true --- end - -- In due time there will be entries here for scripts like Bengali, Gujarati, -- Gurmukhi, Kannada, Malayalam, Oriya, Tamil, Telugu. Feel free to provide the -- code points. local consonant = { - -- devanagari [0x0915] = true, [0x0916] = true, [0x0917] = true, [0x0918] = true, [0x0919] = true, [0x091A] = true, [0x091B] = true, [0x091C] = true, [0x091D] = true, [0x091E] = true, [0x091F] = true, [0x0920] = true, @@ -170,22 +143,9 @@ local consonant = { [0x0939] = true, [0x0958] = true, [0x0959] = true, [0x095A] = true, [0x095B] = true, [0x095C] = true, [0x095D] = true, [0x095E] = true, [0x095F] = true, [0x0979] = true, [0x097A] = true, - -- kannada - [0x0C95] = true, [0x0C96] = true, [0x0C97] = true, [0x0C98] = true, - [0x0C99] = true, [0x0C9A] = true, [0x0C9B] = true, [0x0C9C] = true, - [0x0C9D] = true, [0x0C9E] = true, [0x0C9F] = true, [0x0CA0] = true, - [0x0CA1] = true, [0x0CA2] = true, [0x0CA3] = true, [0x0CA4] = true, - [0x0CA5] = true, [0x0CA6] = true, [0x0CA7] = true, [0x0CA8] = true, - [0x0CA9] = true, [0x0CAA] = true, [0x0CAB] = true, [0x0CAC] = true, - [0x0CAD] = true, [0x0CAE] = true, [0x0CAF] = true, [0x0CB0] = true, - [0x0CB1] = true, [0x0CB2] = true, [0x0CB3] = true, [0x0CB4] = true, - [0x0CB5] = true, [0x0CB6] = true, [0x0CB7] = true, [0x0CB8] = true, - [0x0CB9] = true, - [0x0CDE] = true, -- obsolete } local independent_vowel = { - -- devanagari [0x0904] = true, [0x0905] = true, [0x0906] = true, [0x0907] = true, [0x0908] = true, [0x0909] = true, [0x090A] = true, [0x090B] = true, [0x090C] = true, [0x090D] = true, [0x090E] = true, [0x090F] = true, @@ -193,32 +153,20 @@ local independent_vowel = { [0x0914] = true, [0x0960] = true, [0x0961] = true, [0x0972] = true, [0x0973] = true, [0x0974] = true, [0x0975] = true, [0x0976] = true, [0x0977] = true, - -- kannada - [0x0C85] = true, [0x0C86] = true, [0x0C87] = true, [0x0C88] = true, - [0x0C89] = true, [0x0C8A] = true, [0x0C8B] = true, [0x0C8C] = true, - [0x0C8D] = true, [0x0C8E] = true, [0x0C8F] = true, [0x0C90] = true, - [0x0C91] = true, [0x0C92] = true, [0x0C93] = true, [0x0C94] = true, } local dependent_vowel = { -- matra - -- devanagari [0x093A] = true, [0x093B] = true, [0x093E] = true, [0x093F] = true, [0x0940] = true, [0x0941] = true, [0x0942] = true, [0x0943] = true, [0x0944] = true, [0x0945] = true, [0x0946] = true, [0x0947] = true, [0x0948] = true, [0x0949] = true, [0x094A] = true, [0x094B] = true, [0x094C] = true, [0x094E] = true, [0x094F] = true, [0x0955] = true, [0x0956] = true, [0x0957] = true, [0x0962] = true, [0x0963] = true, - -- kannada - [0x0CBE] = true, [0x0CBF] = true, [0x0CC0] = true, [0x0CC1] = true, - [0x0CC2] = true, [0x0CC3] = true, [0x0CC4] = true, [0x0CC5] = true, - [0x0CC6] = true, [0x0CC7] = true, [0x0CC8] = true, [0x0CC9] = true, - [0x0CCA] = true, [0x0CCB] = true, [0x0CCC] = true, } local vowel_modifier = { - -- devanagari [0x0900] = true, [0x0901] = true, [0x0902] = true, [0x0903] = true, - -- A8E0 - A8F1 are cantillation marks for the Samaveda and may not belong here. + -- A8E0 - A8F1 are cantillation marks for the Samaveda and may not belong here. [0xA8E0] = true, [0xA8E1] = true, [0xA8E2] = true, [0xA8E3] = true, [0xA8E4] = true, [0xA8E5] = true, [0xA8E6] = true, [0xA8E7] = true, [0xA8E8] = true, [0xA8E9] = true, [0xA8EA] = true, [0xA8EB] = true, @@ -230,21 +178,9 @@ local stress_tone_mark = { [0x0951] = true, [0x0952] = true, [0x0953] = true, [0x0954] = true, } -local nukta = { - -- devanagari - [0x093C] = true, - -- kannada: - [0x0CBC] = true, -} - -local halant = { - -- devanagari - [0x094D] = true, - -- kannada - [0x0CCD] = true, -} - -local c_ra = 0x0930 -- used to be tables (also used as constant) +local c_nukta = 0x093C -- used to be tables +local c_halant = 0x094D -- used to be tables +local c_ra = 0x0930 -- used to be tables local c_anudatta = 0x0952 -- used to be tables local c_nbsp = 0x00A0 -- used to be tables local c_zwnj = 0x200C -- used to be tables @@ -255,19 +191,6 @@ local zw_char = { -- could also be inlined [0x200D] = true, } --- 0C82 anusvara --- 0C83 visarga --- 0CBD avagraha --- 0CD5 length mark --- 0CD6 ai length mark --- 0CE0 letter ll --- 0CE1 letter rr --- 0CE2 vowel sign l --- 0CE2 vowel sign ll --- 0CF1 sign --- 0CF2 sign --- OCE6 - OCEF digits - local pre_mark = { [0x093F] = true, [0x094E] = true, } @@ -309,11 +232,10 @@ for k, v in next, below_mark do mark_above_below_post[k] = below_mark end for k, v in next, post_mark do mark_above_below_post[k] = post_mark end -- Again, this table can be extended for other scripts than devanagari. Actually, --- for ConTeXt this kind of data is kept elsewhere so eventually we might move +-- for ConTeXt this kind of dat is kept elsewhere so eventually we might move -- tables to someplace else. local reorder_class = { - -- devanagari [0x0930] = "before postscript", [0x093F] = "before half", [0x0940] = "after subscript", @@ -332,20 +254,6 @@ local reorder_class = { [0x0962] = "after subscript", [0x0963] = "after subscript", [0x093E] = "after subscript", - -- kannada: - [0x0CB0] = "after postscript", -- todo in code below - [0x0CBF] = "before subscript", -- todo in code below - [0x0CC6] = "before subscript", -- todo in code below - [0x0CCC] = "before subscript", -- todo in code below - [0x0CBE] = "before subscript", -- todo in code below - [0x0CE2] = "before subscript", -- todo in code below - [0x0CE3] = "before subscript", -- todo in code below - [0x0CC1] = "before subscript", -- todo in code below - [0x0CC2] = "before subscript", -- todo in code below - [0x0CC3] = "after subscript", - [0x0CC4] = "after subscript", - [0x0CD5] = "after subscript", - [0x0CD6] = "after subscript", } -- We use some pseudo features as we need to manipulate the nodelist based @@ -549,22 +457,22 @@ local function deva_initialize(font,attr) end -local function deva_reorder(head,start,stop,font,attr,nbspaces) +local function deva_reorder(head,start,stop,font,attr) local lookuphash, reph, vattu, blwfcache = deva_initialize(font,attr) -- could be inlines but ugly - local current = start - local n = start.next - local base = nil + local current = start + local n = start.next + local base = nil local firstcons = nil - local lastcons = nil + local lastcons = nil local basefound = false - if start.char == c_ra and halant[n.char] and reph then + if start.char == c_ra and n.char == c_halant and reph then -- if syllable starts with Ra + H and script has 'Reph' then exclude Reph -- from candidates for base consonants if n == stop then - return head, stop, nbspaces + return head, stop end if n.next.char == c_zwj then current = start @@ -580,31 +488,28 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces) stop = stop.prev head = remove_node(head,current) free_node(current) - return head, stop, nbspaces + return head, stop else - nbspaces = nbspaces + 1 - base = current - firstcons = current - lastcons = current - current = current.next + base, firstcons, lastcons = current, current, current + current = current.next if current ~= stop then - if nukta[current.char] then + if current.char == c_nukta then current = current.next end if current.char == c_zwj then if current ~= stop then local next = current.next - if next ~= stop and halant[next.char] then + if next ~= stop and next.char == c_halant then current = next next = current.next - local tmp = next and next.next or nil -- needs checking + local tmp = next.next local changestop = next == stop local tempcurrent = copy_node(next) local nextcurrent = copy_node(current) tempcurrent.next = nextcurrent nextcurrent.prev = tempcurrent tempcurrent[a_state] = s_blwf - tempcurrent = processcharacters(tempcurrent,font) + tempcurrent = processcharacters(tempcurrent) tempcurrent[a_state] = unsetvalue if next.char == tempcurrent.char then flush_list(tempcurrent) @@ -615,9 +520,7 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces) current.char = tempcurrent.char -- (assumes that result of blwf consists of one node) local freenode = current.next current.next = tmp - if tmp then - tmp.prev = current - end + tmp.prev = current free_node(freenode) flush_list(tempcurrent) if changestop then @@ -656,14 +559,14 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces) -- if base consonant is not last one then move halant from base consonant to last one local np = base local n = base.next - if nukta[n.char] then + if n.char == c_nukta then np = n n = n.next end - if halant[n.char] then + if n.char == c_halant then if lastcons ~= stop then local ln = lastcons.next - if nukta[ln.char] then + if ln.char == c_nukta then lastcons = ln end end @@ -685,8 +588,7 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces) end n = start.next - -- if start.char == c_ra and halant[n.char] and not (n ~= stop and zw_char[n.next.char]) then - if n ~= stop and start.char == c_ra and halant[n.char] and not zw_char[n.next.char] then + if start.char == c_ra and n.char == c_halant and not (n ~= stop and zw_char[n.next.char]) then -- if syllable starts with Ra + H then move this combination so that it follows either: -- the post-base 'matra' (if any) or the base consonant local matra = base @@ -723,7 +625,7 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces) local current = start while current ~= stop do local next = current.next - if next ~= stop and halant[next.char] and next.next.char == c_zwnj then + if next ~= stop and next.char == c_halant and next.next.char == c_zwnj then current[a_state] = unsetvalue end current = next @@ -731,7 +633,7 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces) if base ~= stop and base[a_state] then local next = base.next - if halant[next.char] and not (next ~= stop and next.next.char == c_zwj) then + if next.char == c_halant and not (next ~= stop and next.next.char == c_zwj) then base[a_state] = unsetvalue end end @@ -743,7 +645,7 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces) local current, allreordered, moved = start, false, { [base] = true } local a, b, p, bn = base, base, base, base.next - if base ~= stop and nukta[bn.char] then + if base ~= stop and bn.char == c_nukta then a, b, p = bn, bn, bn end while not allreordered do @@ -752,12 +654,12 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces) local n = current.next local l = nil -- used ? if c ~= stop then - if nukta[n.char] then + if n.char == c_nukta then c = n n = n.next end if c ~= stop then - if halant[n.char] then + if n.char == c_halant then c = n n = n.next end @@ -817,7 +719,7 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces) while current ~= stop do local c = current local n = current.next - if current.char == c_ra and halant[n.char] then + if current.char == c_ra and n.char == c_halant then c = n n = n.next local b, bn = base, base @@ -880,17 +782,10 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces) end else local char = current.char - if consonant[char] then + if consonant[char] or char == c_nbsp then -- maybe combined hash cns = current local next = cns.next - if halant[next.char] then - cns = next - end - elseif char == c_nbsp then - nbspaces = nbspaces + 1 - cns = current - local next = cns.next - if halant[next.char] then + if next.char == c_halant then cns = next end end @@ -900,12 +795,11 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces) end if base.char == c_nbsp then - nbspaces = nbspaces - 1 head = remove_node(head,base) free_node(base) end - return head, stop, nbspaces + return head, stop end -- If a pre-base matra character had been reordered before applying basic features, @@ -924,7 +818,7 @@ function handlers.devanagari_reorder_matras(head,start,kind,lookupname,replaceme -- can be fast loop while current and current.id == glyph_code and current.subtype<256 and current.font == font and current[a_syllabe] == startattr do local next = current.next - if halant[current.char] and not current[a_state] then + if current.char == c_halant and not current[a_state] then if next and next.id == glyph_code and next.subtype<256 and next.font == font and next[a_syllabe] == startattr and zw_char[next.char] then current = next end @@ -978,7 +872,7 @@ function handlers.devanagari_reorder_reph(head,start,kind,lookupname,replacement local startfont = start.font local startattr = start[a_syllabe] while current and current.id == glyph_code and current.subtype<256 and current.font == startfont and current[a_syllabe] == startattr do --step 2 - if halant[current.char] and not current[a_state] then + if current.char == c_halant and not current[a_state] then local next = current.next if next and next.id == glyph_code and next.subtype<256 and next.font == startfont and next[a_syllabe] == startattr and zw_char[next.char] then current = next @@ -1091,7 +985,7 @@ function handlers.devanagari_reorder_pre_base_reordering_consonants(head,start,k -- can be fast for loop + caching state while current and current.id == glyph_code and current.subtype<256 and current.font == startfont and current[a_syllabe] == startattr do local next = current.next - if halant[current.char] and not current[a_state] then + if current.char == c_halant and not current[a_state] then if next and next.id == glyph_code and next.subtype<256 and next.font == font and next[a_syllabe] == startattr then local char = next.char if char == c_zwnj or char == c_zwj then @@ -1152,9 +1046,6 @@ function handlers.devanagari_remove_joiners(head,start,kind,lookupname,replaceme if prev then prev.next = stop end - if head == start then - head = stop - end flush_list(start) return head, stop, true end @@ -1235,18 +1126,13 @@ end -- this one will be merged into the caller: it saves a call, but we will then make function -- of the actions -local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pass over (determine stop in sweep) +local function dev2_reorder(head,start,stop,font,attr) -- maybe do a pass over (determine stop in sweep) local lookuphash, seqsubset = dev2_initialize(font,attr) - local pre_base_reordering_consonants = { } -- was nil ... probably went unnoticed because never assigned - - local reph = false -- was nil ... probably went unnoticed because never assigned - local halfpos = nil - local basepos = nil - local subpos = nil - local postpos = nil - local locl = { } + local reph, pre_base_reordering_consonants = false, { } -- was nil ... probably went unnoticed because never assigned + local halfpos, basepos, subpos, postpos = nil, nil, nil, nil + local locl = { } for i=1,#seqsubset do @@ -1256,15 +1142,8 @@ 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 - -- todo: rphf might be result of other handler/chainproc - -- todo: rphf actualy acts on consonant + halant. - -- todo: the consonant might not necesseraly be 0x0930 ... (but for devanagari it is) - local lookup = lookupcache[0x0930] - if lookup then - local hit = lookup[0x094D] - if hit then - reph = hit["ligature"] - end + if subset[3] then + reph = true end local current = start local last = stop.next @@ -1294,7 +1173,6 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa elseif kind == "pref" then -- why not global? pretty ineffient this way -- this will move to the initializer and we will store the hash in dataset - -- todo: reph might also be result of chain for k, v in lookupcache[0x094D], next do pre_base_reordering_consonants[k] = v and v["ligature"] --ToDo: reph might also be result of chain end @@ -1328,15 +1206,15 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa local next = current.next local n = locl[next] or next.char if found[n] then - if next ~= stop and next.next.char == c_zwnj then -- zwnj prevent creation of half - current = next + if next ~= stop and next.next.char == c_zwnj then --ZWNJ prevent creation of half + current = current.next else current[a_state] = s_half if not halfpos then halfpos = current end end - current = current.next + current = next end end end @@ -1397,40 +1275,38 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa current = start.next.next end - local function stand_alone(is_nbsp) + if current ~= stop.next and current.char == c_nbsp then + -- Stand Alone cluster if current == stop then stop = stop.prev head = remove_node(head,current) free_node(current) - return head, stop, nbspaces + return head, stop else - if is_nbsp then - nbspaces = nbspaces + 1 - end - base = current + base = current current = current.next if current ~= stop then local char = current.char - if nukta[char] then + if char == c_nukta then current = current.next char = current.char end if char == c_zwj then local next = current.next - if current ~= stop and next ~= stop and halant[next.char] then + if current ~= stop and next ~= stop and next.char == c_halant then current = next next = current.next local tmp = next.next local changestop = next == stop next.next = nil current[a_state] = s_pref - current = processcharacters(current,font) + current = processcharacters(current) current[a_state] = s_blwf - current = processcharacters(current,font) + current = processcharacters(current) current[a_state] = s_pstf - current = processcharacters(current,font) + current = processcharacters(current) current[a_state] = unsetvalue - if halant[current.char] then + if current.char == c_halant then current.next.next = tmp local nc = copy_node(current) current.char = dotted_circle @@ -1445,26 +1321,18 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa end end end - end - - if current ~= stop.next then - -- Stand Alone cluster - stand_alone() - elseif current.char == c_nbsp then - -- Stand Alone cluster - stand_alone(true) else -- not Stand Alone cluster local last = stop.next while current ~= last do -- find base consonant local next = current.next if consonant[current.char] then - if not (current ~= stop and next ~= stop and halant[next.char] and next.next.char == c_zwj) then + if not (current ~= stop and next ~= stop and next.char == c_halant and next.next.char == c_zwj) then if not firstcons then firstcons = current end -- check whether consonant has below-base or post-base form or is pre-base reordering Ra local a = current[a_state] - if not (a == s_pref or a == s_blwf or a == s_pstf) then + if not (a == s_pref or a == s_blwf or a == pstf) then base = current end end @@ -1480,7 +1348,7 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa if start[a_state] == s_rphf then start[a_state] = unsetvalue end - return head, stop, nbspaces + return head, stop else if base[a_state] then base[a_state] = unsetvalue @@ -1582,7 +1450,7 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa local current, c = start, nil while current ~= stop do local char = current.char - if halant[char] or stress_tone_mark[char] then + if char == c_halant or stress_tone_mark[char] then if not c then c = current end @@ -1590,7 +1458,7 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa c = nil end local next = current.next - if c and nukta[next.char] then + if c and next.char == c_nukta then if head == c then head = next end @@ -1616,12 +1484,11 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa end if base.char == c_nbsp then - nbspaces = nbspaces - 1 head = remove_node(head, base) free_node(base) end - return head, stop, nbspaces + return head, stop end -- cleaned up and optimized ... needs checking (local, check order, fixes, extra hash, etc) @@ -1634,8 +1501,8 @@ imerge(separator,dependent_vowel) imerge(separator,vowel_modifier) imerge(separator,stress_tone_mark) -for k, v in next, nukta do separator[k] = true end -for k, v in next, halant do separator[k] = true end +separator[0x093C] = true -- nukta +separator[0x094D] = true -- halant local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowel -- why two variants ... the comment suggests that it's the same ruleset @@ -1645,7 +1512,7 @@ local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowe end if variant == 1 then local v = n.id == glyph_code and n.subtype<256 and n.font == font - if v and nukta[n.char] then + if v and n.char == c_nukta then n = n.next if n then v = n.id == glyph_code and n.subtype<256 and n.font == font @@ -1660,7 +1527,7 @@ local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowe local nnnc = nnn.char if nnc == c_zwj and consonant[nnnc] then c = nnn - elseif (nnc == c_zwnj or nnc == c_zwj) and halant[nnnc] then + elseif (nnc == c_zwnj or nnc == c_zwj) and nnnc == c_halant then local nnnn = nnn.next if nnnn and nnnn.id == glyph_code and consonant[nnnn.char] and nnnn.subtype<256 and nnnn.font == font then c = nnnn @@ -1670,7 +1537,7 @@ local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowe end end elseif variant == 2 then - if n.id == glyph_code and nukta[n.char] and n.subtype<256 and n.font == font then + if n.id == glyph_code and n.char == c_nukta and n.subtype<256 and n.font == font then c = n end n = c.next @@ -1681,9 +1548,9 @@ local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowe if nv and zw_char[n.char] then n = nn nn = nn.next - nv = nn and nn.id == glyph_code and nn.subtype<256 and nn.font == font + nv = nn.id == glyph_code and nn.subtype<256 and nn.font == font end - if nv and halant[n.char] and consonant[nn.char] then + if nn and nv and n.char == c_halant and consonant[nn.char] then c = nn end end @@ -1711,7 +1578,7 @@ local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowe end char = n.char end - if nukta[char] then + if char == c_nukta then c = c.next n = c.next if not n then @@ -1723,7 +1590,7 @@ local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowe end char = n.char end - if halant[char] then + if char == c_halant then c = c.next n = c.next if not n then @@ -1771,7 +1638,7 @@ local function analyze_next_chars_two(c,font) if not n then return c end - if n.id == glyph_code and nukta[n.char] and n.subtype<256 and n.font == font then + if n.id == glyph_code and n.char == c_nukta and n.subtype<256 and n.font == font then c = n end n = c @@ -1779,7 +1646,7 @@ local function analyze_next_chars_two(c,font) local nn = n.next if nn and nn.id == glyph_code and nn.subtype<256 and nn.font == font then local char = nn.char - if halant[char] then + if char == c_halant then n = nn local nnn = nn.next if nnn and nnn.id == glyph_code and zw_char[nnn.char] and nnn.subtype<256 and nnn.font == font then @@ -1788,7 +1655,7 @@ local function analyze_next_chars_two(c,font) elseif char == c_zwnj or char == c_zwj then -- n = nn -- not here (?) local nnn = nn.next - if nnn and nnn.id == glyph_code and halant[nnn.char] and nnn.subtype<256 and nnn.font == font then + if nnn and nnn.id == glyph_code and nnn.char == c_halant and nnn.subtype<256 and nnn.font == font then n = nnn end else @@ -1798,7 +1665,7 @@ local function analyze_next_chars_two(c,font) if nn and nn.id == glyph_code and consonant[nn.char] and nn.subtype<256 and nn.font == font then n = nn local nnn = nn.next - if nnn and nnn.id == glyph_code and nukta[nnn.char] and nnn.subtype<256 and nnn.font == font then + if nnn and nnn.id == glyph_code and nnn.char == c_nukta and nnn.subtype<256 and nnn.font == font then n = nnn end c = n @@ -1835,7 +1702,7 @@ local function analyze_next_chars_two(c,font) end char = n.char end - if halant[char] then + if char == c_halant then c = c.next n = c.next if not n then @@ -1873,7 +1740,7 @@ local function analyze_next_chars_two(c,font) end char = n.char end - if nukta[char] then + if char == c_nukta then c = c.next n = c.next if not n then @@ -1885,7 +1752,7 @@ local function analyze_next_chars_two(c,font) end char = n.char end - if halant[char] then + if char == c_halant then c = c.next n = c.next if not n then @@ -1944,10 +1811,7 @@ end -- a lot. Common code has been synced. function methods.deva(head,font,attr) - local current = head - local start = true - local done = false - local nbspaces = 0 + local current, start, done = head, true, false while current do if current.id == glyph_code and current.subtype<256 and current.font == font then done = true @@ -1955,7 +1819,7 @@ function methods.deva(head,font,attr) local syllableend = nil local c = current local n = c.next - if n and c.char == c_ra and n.id == glyph_code and halant[n.char] and n.subtype<256 and n.font == font then + if n and c.char == c_ra and n.id == glyph_code and n.char == c_halant and n.subtype<256 and n.font == font then local n = n.next if n and n.id == glyph_code and n.subtype<256 and n.font == font then c = n @@ -1976,10 +1840,9 @@ function methods.deva(head,font,attr) end if standalone then -- stand alone cluster (at the start of the word only): #[Ra+H]+NBSP+[N]+[<[<ZWJ|ZWNJ>]+H+C>]+[{M}+[N]+[H]]+[SM]+[(VD)] - local syllableend = analyze_next_chars_one(c,font,2) - current = syllableend.next + local syllabeend, current = analyze_next_chars_one(c,font,2) -- watch out, here we set current to next if syllablestart ~= syllableend then - head, current, nbspaces = deva_reorder(head,syllablestart,syllableend,font,attr,nbspaces) + head, current = deva_reorder(head,syllablestart,syllableend,font,attr) current = current.next end else @@ -2001,7 +1864,7 @@ function methods.deva(head,font,attr) break end local c = n.char - if nukta[c] then + if c == c_nukta then n = n.next if not n then break @@ -2012,7 +1875,7 @@ function methods.deva(head,font,attr) end c = n.char end - if halant[c] then + if c == c_halant then n = n.next if not n then break @@ -2040,7 +1903,7 @@ function methods.deva(head,font,attr) end end local n = current.next - if n and n.id == glyph_code and nukta[n.char] and n.subtype<256 and n.font == font then + if n and n.id == glyph_code and n.char == c_nukta and n.subtype<256 and n.font == font then -- nukta (not specified in Microsft Devanagari OpenType specification) current = n n = current.next @@ -2050,7 +1913,7 @@ function methods.deva(head,font,attr) if current then local v = current.id == glyph_code and current.subtype<256 and current.font == font if v then - if halant[current.char] then + if current.char == c_halant then -- syllable containing consonant without vowels: {C + [Nukta] + H} + C + H local n = current.next if n and n.id == glyph_code and zw_char[n.char] and n.subtype<256 and n.font == font then @@ -2088,7 +1951,7 @@ function methods.deva(head,font,attr) end end if syllablestart ~= syllableend then - head, current, nbspaces = deva_reorder(head,syllablestart,syllableend,font,attr,nbspaces) + head, current = deva_reorder(head,syllablestart,syllableend,font,attr) current = current.next end elseif independent_vowel[char] then @@ -2127,12 +1990,6 @@ function methods.deva(head,font,attr) start = false end - if nbspaces > 0 then - head = replace_all_nbsp(head) - end - - head = typesetters.characters.handler(head) - return head, done end @@ -2142,11 +1999,10 @@ end -- handler(head,start,kind,lookupname,lookupmatch,sequence,lookuphash,1) function methods.dev2(head,font,attr) - local current = head - local start = true - local done = false - local syllabe = 0 - local nbspaces = 0 + local current = head + local start = true + local done = false + local syllabe = 0 while current do local syllablestart, syllableend = nil, nil if current.id == glyph_code and current.subtype<256 and current.font == font then @@ -2154,7 +2010,7 @@ function methods.dev2(head,font,attr) syllablestart = current local c = current local n = current.next - if n and c.char == c_ra and n.id == glyph_code and halant[n.char] and n.subtype<256 and n.font == font then + if n and c.char == c_ra and n.id == glyph_code and n.char == c_halant and n.subtype<256 and n.font == font then local n = n.next if n and n.id == glyph_code and n.subtype<256 and n.font == font then c = n @@ -2168,7 +2024,6 @@ function methods.dev2(head,font,attr) else local standalone = char == c_nbsp if standalone then - nbspaces = nbspaces + 1 local p = current.prev if not p then -- begin of paragraph or box @@ -2203,7 +2058,7 @@ function methods.dev2(head,font,attr) end end if syllableend and syllablestart ~= syllableend then - head, current, nbspaces = dev2_reorder(head,syllablestart,syllableend,font,attr,nbspaces) + head, current = dev2_reorder(head,syllablestart,syllableend,font,attr) end if not syllableend and current.id == glyph_code and current.subtype<256 and current.font == font and not current[a_state] then local mark = mark_four[current.char] @@ -2215,9 +2070,5 @@ function methods.dev2(head,font,attr) current = current.next end - if nbspaces > 0 then - head = replace_all_nbsp(head) - end - return head, done end |