diff options
author | Hans Hagen <pragma@wxs.nl> | 2010-05-13 23:36:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2010-05-13 23:36:00 +0200 |
commit | b34cc94e16a5baacd0201e20f190ec224c00f952 (patch) | |
tree | 90c95e14f2a2b099d99e39c31b08529f6e21fdfb /tex/context/base/font-otn.lua | |
parent | 8c0bb98e13632d6caf24fd08261ff4bca4fdd4eb (diff) | |
download | context-b34cc94e16a5baacd0201e20f190ec224c00f952.tar.gz |
beta 2010.05.13 23:36
Diffstat (limited to 'tex/context/base/font-otn.lua')
-rw-r--r-- | tex/context/base/font-otn.lua | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/tex/context/base/font-otn.lua b/tex/context/base/font-otn.lua index 3aa1927d3..d4f89adc6 100644 --- a/tex/context/base/font-otn.lua +++ b/tex/context/base/font-otn.lua @@ -123,6 +123,7 @@ results in different tables.</p> 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 |