From 3cbef76101d9aaef3b2c355c58675bf9f386d949 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Fri, 21 May 2010 06:46:45 +0300 Subject: Sync with ConTeXt beta (beta 2010.05.20) --- otfl-font-otn.lua | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) (limited to 'otfl-font-otn.lua') diff --git a/otfl-font-otn.lua b/otfl-font-otn.lua index 3aa1927..d4f89ad 100644 --- a/otfl-font-otn.lua +++ b/otfl-font-otn.lua @@ -123,6 +123,7 @@ results in different tables.

local concat, insert, remove = table.concat, table.insert, table.remove local format, gmatch, gsub, find, match, lower, strip = string.format, string.gmatch, string.gsub, string.find, string.match, string.lower, string.strip local type, next, tonumber, tostring = type, next, tonumber, tostring +local lpegmatch = lpeg.match local otf = fonts.otf local tfm = fonts.tfm @@ -166,7 +167,7 @@ local zwj = 0x200D local wildcard = "*" local default = "dflt" -local split_at_space = lpeg.Ct(lpeg.splitat(" ")) -- no trailing or multiple spaces anyway +local split_at_space = lpeg.splitters[" "] or lpeg.Ct(lpeg.splitat(" ")) -- no trailing or multiple spaces anyway local glyph = node.id('glyph') local glue = node.id('glue') @@ -2208,11 +2209,11 @@ otf.features.prepare = { } -- document) local function split(replacement,original,cache,unicodes) - -- we can cache this too, but not the same + -- we can cache this too, but not the same (although unicode is a unique enough hash) local o, t, n = { }, { }, 0 for s in gmatch(original,"[^ ]+") do local us = unicodes[s] - if type(us) == "number" then + if type(us) == "number" then -- tonumber(us) o[#o+1] = us else o[#o+1] = us[1] @@ -2221,7 +2222,7 @@ local function split(replacement,original,cache,unicodes) for s in gmatch(replacement,"[^ ]+") do n = n + 1 local us = unicodes[s] - if type(us) == "number" then + if type(us) == "number" then -- tonumber(us) t[o[n]] = us else t[o[n]] = us[1] @@ -2579,6 +2580,46 @@ function prepare_contextchains(tfmdata) end end end + elseif fmt == "glyphs" then + if lookuptype ~= "chainsub" and lookuptype ~= "chainpos" then + logs.report("otf process","unsupported coverage %s for %s",lookuptype,lookupname) + else + local contexts = contextchain[lookupname] + if not contexts then + contexts = { } + contextchain[lookupname] = contexts + end + local t = { } + for nofrules=1,#rules do + -- nearly the same as coverage so we could as well rename it + local rule = rules[nofrules] + local glyphs = rule.glyphs + if glyphs and glyphs.names then + local fore, back, names, sequence = glyphs.fore, glyphs.back, glyphs.names, { } + if fore and fore ~= "" then + fore = lpegmatch(split_at_space,fore) + uncover(fore,sequence,cache,unicodes) + end + local start = #sequence + 1 + names = lpegmatch(split_at_space,names) + uncover(names,sequence,cache,unicodes) + local stop = #sequence + if back and back ~= "" then + back = lpegmatch(split_at_space,back) + uncover(back,sequence,cache,unicodes) + end + if sequence[1] then + t[#t+1] = { nofrules, lookuptype, sequence, start, stop, rule.lookups } + for unic, _ in next, sequence[start] do + local cu = contexts[unic] + if not cu then + contexts[unic] = t + end + end + end + end + end + end end end end -- cgit v1.2.3