summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2011-12-19 20:08:13 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2011-12-19 20:08:13 +0200
commitdb6d134438fee52b713c8a846d2275eea6a43123 (patch)
tree3b979d7a32776a828b0b30aaaa665c215ebb72e5
parent353e07d516b36a89cb7f3f3894664daba22e1271 (diff)
downloadluaotfload-db6d134438fee52b713c8a846d2275eea6a43123.tar.gz
Sync with ConTeXt beta 2011.12.19 13:06
-rw-r--r--otfl-font-otf.lua133
-rw-r--r--otfl-font-otn.lua50
2 files changed, 103 insertions, 80 deletions
diff --git a/otfl-font-otf.lua b/otfl-font-otf.lua
index 924e9a6..03376f9 100644
--- a/otfl-font-otf.lua
+++ b/otfl-font-otf.lua
@@ -1002,6 +1002,20 @@ local g_directions = {
gpos_reversecontextchain = -1,
}
+-- Research by Khaled Hosny has demonstrated that the font loader merges
+-- regular and AAT features and that these can interfere (especially because
+-- we dropped checking for valid features elsewhere. So, we just check for
+-- the special flag and drop the feature if such a tag is found.
+
+local function supported(features)
+ for i=1,#features do
+ if features[i].ismac then
+ return false
+ end
+ end
+ return true
+end
+
actions["reorganize subtables"] = function(data,filename,raw)
local resources = data.resources
local sequences = { }
@@ -1014,69 +1028,72 @@ actions["reorganize subtables"] = function(data,filename,raw)
if dw then
for k=1,#dw do
local gk = dw[k]
- local typ = gk.type
- local chain = g_directions[typ] or 0
- local subtables = gk.subtables
- if subtables then
- local t = { }
- for s=1,#subtables do
- t[s] = subtables[s].name
+ local features = gk.features
+ if features and supported(features) then
+ local typ = gk.type
+ local chain = g_directions[typ] or 0
+ local subtables = gk.subtables
+ if subtables then
+ local t = { }
+ for s=1,#subtables do
+ t[s] = subtables[s].name
+ end
+ subtables = t
end
- subtables = t
- end
- local flags, markclass = gk.flags, nil
- if flags then
- local t = { -- forcing false packs nicer
- (flags.ignorecombiningmarks and "mark") or false,
- (flags.ignoreligatures and "ligature") or false,
- (flags.ignorebaseglyphs and "base") or false,
- flags.r2l or false,
- }
- markclass = flags.mark_class
- if markclass then
- markclass = resources.markclasses[markclass]
+ local flags, markclass = gk.flags, nil
+ if flags then
+ local t = { -- forcing false packs nicer
+ (flags.ignorecombiningmarks and "mark") or false,
+ (flags.ignoreligatures and "ligature") or false,
+ (flags.ignorebaseglyphs and "base") or false,
+ flags.r2l or false,
+ }
+ markclass = flags.mark_class
+ if markclass then
+ markclass = resources.markclasses[markclass]
+ end
+ flags = t
end
- flags = t
- end
- --
- local name = gk.name
- --
- local features = gk.features
- if features then
- -- scripts, tag, ismac
- local f = { }
- for i=1,#features do
- local df = features[i]
- local tag = strip(lower(df.tag))
- local ft = f[tag] if not ft then ft = {} f[tag] = ft end
- local dscripts = df.scripts
- for i=1,#dscripts do
- local d = dscripts[i]
- local languages = d.langs
- local script = strip(lower(d.script))
- local fts = ft[script] if not fts then fts = {} ft[script] = fts end
- for i=1,#languages do
- fts[strip(lower(languages[i]))] = true
+ --
+ local name = gk.name
+ --
+ local features = gk.features
+ if features then
+ -- scripts, tag, ismac
+ local f = { }
+ for i=1,#features do
+ local df = features[i]
+ local tag = strip(lower(df.tag))
+ local ft = f[tag] if not ft then ft = {} f[tag] = ft end
+ local dscripts = df.scripts
+ for i=1,#dscripts do
+ local d = dscripts[i]
+ local languages = d.langs
+ local script = strip(lower(d.script))
+ local fts = ft[script] if not fts then fts = {} ft[script] = fts end
+ for i=1,#languages do
+ fts[strip(lower(languages[i]))] = true
+ end
end
end
+ sequences[#sequences+1] = {
+ type = typ,
+ chain = chain,
+ flags = flags,
+ name = name,
+ subtables = subtables,
+ markclass = markclass,
+ features = f,
+ }
+ else
+ lookups[name] = {
+ type = typ,
+ chain = chain,
+ flags = flags,
+ subtables = subtables,
+ markclass = markclass,
+ }
end
- sequences[#sequences+1] = {
- type = typ,
- chain = chain,
- flags = flags,
- name = name,
- subtables = subtables,
- markclass = markclass,
- features = f,
- }
- else
- lookups[name] = {
- type = typ,
- chain = chain,
- flags = flags,
- subtables = subtables,
- markclass = markclass,
- }
end
end
end
diff --git a/otfl-font-otn.lua b/otfl-font-otn.lua
index e11e8d9..12ea975 100644
--- a/otfl-font-otn.lua
+++ b/otfl-font-otn.lua
@@ -420,11 +420,11 @@ function handlers.gsub_single(start,kind,lookupname,replacement)
return start, true
end
-local function set_alternative_glyph(start,alternatives,kind,chainname,chainlookupname,lookupname) -- chainname and chainlookupname optional
+local function get_alternative_glyph(start,alternatives,value)
-- needs checking: (global value, brrr)
- local value = featurevalue == true and tfmdata.shared.features[kind] or featurevalue
local choice = nil
local n = #alternatives
+ local char = start.char
--
if value == "random" then
local r = random(1,n)
@@ -447,30 +447,14 @@ local function set_alternative_glyph(start,alternatives,kind,chainname,chainlook
value, choice = format("no %s variants, ignoring",value), false
end
elseif value == 0 then
- value, choice = format("choice %s (no change)",value), start.char
+ value, choice = format("choice %s (no change)",value), char
elseif value < 1 then
value, choice = format("no %s variants, taking %s",value,1), alternatives[1]
else
value, choice = format("choice %s",value), alternatives[value]
end
end
- if trace_alternatives then
- if choice then
- logprocess("%s: replacing %s by alternative %s (%s)",pref(kind,lookupname),gref(start.char),gref(choice),index)
- else
- logwarning("%s: no variant %s for %s",cref(kind,chainname,chainlookupname,lookupname),value,gref(start.char))
- end
- end
- if choice then
- start.char = choice
- if trace_alternatives then
- logprocess("%s: replacing %s by alternative %s (%s)",pref(kind,lookupname),gref(start.char),gref(choice),index)
- end
- else
- if trace_alternatives then
- logwarning("%s: no variant %s for %s",cref(kind,chainname,chainlookupname,lookupname),value,gref(start.char))
- end
- end
+ return choice
end
local function multiple_glyphs(start,multiple) -- marks ?
@@ -501,7 +485,18 @@ local function multiple_glyphs(start,multiple) -- marks ?
end
function handlers.gsub_alternate(start,kind,lookupname,alternative,sequence)
- set_alternative_glyph(start,alternative,kind,lookupname)
+ local value = featurevalue == true and tfmdata.shared.features[kind] or featurevalue
+ local choice = get_alternative_glyph(start,alternative,value)
+ if choice then
+ if trace_alternatives then
+ logprocess("%s: replacing %s by alternative %s (%s)",pref(kind,lookupname),gref(char),gref(choice),choice)
+ end
+ start.char = choice
+ else
+ if trace_alternatives then
+ logwarning("%s: no variant %s for %s",pref(kind,lookupname),tostring(value),gref(char))
+ end
+ end
return start, true
end
@@ -1102,6 +1097,7 @@ chainmores.gsub_multiple = chainprocs.gsub_multiple
function chainprocs.gsub_alternate(start,stop,kind,chainname,currentcontext,lookuphash,currentlookup,chainlookupname)
local current = start
local subtables = currentlookup.subtables
+ local value = featurevalue == true and tfmdata.shared.features[kind] or featurevalue
while current do
if current.id == glyph_code then -- is this check needed?
local currentchar = current.char
@@ -1114,7 +1110,17 @@ function chainprocs.gsub_alternate(start,stop,kind,chainname,currentcontext,look
else
alternatives = alternatives[currentchar]
if alternatives then
- set_alternative_glyph(current,alternatives,kind,chainname,chainlookupname,lookupname)
+ local choice = get_alternative_glyph(current,alternatives,value)
+ if choice then
+ if trace_alternatives then
+ logprocess("%s: replacing %s by alternative %s (%s)",cref(kind,chainname,chainlookupname,lookupname),gref(char),gref(choice),choice)
+ end
+ start.char = choice
+ else
+ if trace_alternatives then
+ logwarning("%s: no variant %s for %s",cref(kind,chainname,chainlookupname,lookupname),tostring(value),gref(char))
+ end
+ end
elseif trace_bugs then
logwarning("%s: no alternative for %s",cref(kind,chainname,chainlookupname,lookupname),gref(currentchar))
end