diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/font-otd.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/font-otd.lua | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/Master/texmf-dist/tex/context/base/font-otd.lua b/Master/texmf-dist/tex/context/base/font-otd.lua index b22889217cb..ebd4879599d 100644 --- a/Master/texmf-dist/tex/context/base/font-otd.lua +++ b/Master/texmf-dist/tex/context/base/font-otd.lua @@ -7,6 +7,7 @@ if not modules then modules = { } end modules ['font-otd'] = { } local match = string.match +local sequenced = table.sequenced local trace_dynamics = false trackers.register("otf.dynamics", function(v) trace_dynamics = v end) local trace_applied = false trackers.register("otf.applied", function(v) trace_applied = v end) @@ -16,11 +17,14 @@ local report_process = logs.reporter("fonts","otf process") local fonts = fonts local otf = fonts.handlers.otf -local fontdata = fonts.hashes.identifiers +local hashes = fonts.hashes local definers = fonts.definers local constructors = fonts.constructors local specifiers = fonts.specifiers +local fontdata = hashes.identifiers +----- fontresources = hashes.resources -- not yet defined + local contextsetups = specifiers.contextsetups local contextnumbers = specifiers.contextnumbers local contextmerged = specifiers.contextmerged @@ -31,7 +35,7 @@ local otffeatures = fonts.constructors.newfeatures("otf") local registerotffeature = otffeatures.register local fontdynamics = { } -fonts.hashes.dynamics = fontdynamics +hashes.dynamics = fontdynamics local a_to_script = { } local a_to_language = { } @@ -48,6 +52,10 @@ function otf.setdynamics(font,attribute) local dynamics = fontdynamics[font] local script = features.script or 'dflt' local language = features.language or 'dflt' + if script == "auto" then + -- checkedscript and resources are defined later so we cannot shortcut them + script = definers.checkedscript(fontdata[font],hashes.resources[font],features) + end local ds = dynamics[script] -- can be metatable magic (less testing) if not ds then ds = { } @@ -77,10 +85,10 @@ function otf.setdynamics(font,attribute) shared.features = { } -- end of save local set = constructors.checkedfeatures("otf",features) -set.mode = "node" -- really needed + set.mode = "node" -- really needed dsla = otf.setfeatures(tfmdata,set) if trace_dynamics then - report_otf("setting dynamics %s: attribute %s, script %s, language %s, set: %s",contextnumbers[attribute],attribute,script,language,table.sequenced(set)) + report_otf("setting dynamics %s: attribute %s, script %s, language %s, set: %s",contextnumbers[attribute],attribute,script,language,sequenced(set)) end -- we need to restore some values properties.script = s_script @@ -122,9 +130,9 @@ local function initialize(sequence,script,language,s_enabled,a_enabled,font,attr local features = sequence.features if features then for kind, scripts in next, features do - local s_e = s_enabled and s_enabled[kind] - local a_e = a_enabled and a_enabled[kind] - local e_e = s_e or a_e + local s_e = s_enabled and s_enabled[kind] -- the value + local a_e = a_enabled and a_enabled[kind] -- the value + local e_e = s_e or a_e -- todo: when one of them is true and the other is a value if e_e then local languages = scripts[script] or scripts[wildcard] if languages then @@ -133,13 +141,13 @@ local function initialize(sequence,script,language,s_enabled,a_enabled,font,attr -- only first attribute match check, so we assume simple fina's -- default can become a font feature itself if languages[language] then - valid = true + valid = e_e -- was true what = language -- elseif languages[default] then -- valid = true -- what = default elseif languages[wildcard] then - valid = true + valid = e_e -- was true what = wildcard end if valid then @@ -153,38 +161,45 @@ local function initialize(sequence,script,language,s_enabled,a_enabled,font,attr "%s font: %03i, dynamic: %03i, kind: %s, script: %-4s, language: %-4s (%-4s), type: %s, action: %s, name: %s", (valid and "+") or "-",font,attr or 0,kind,script,language,what,typ,action,sequence.name) end - return { valid, attribute, sequence.chain or 0, kind } + return { valid, attribute, sequence.chain or 0, kind, sequence } end end end end - return false -- { valid, attribute, chain, "generic" } -- false anyway, could be flag instead of table + return false -- { valid, attribute, chain, "generic", sequence } -- false anyway, could be flag instead of table else - return false -- { false, false, chain } -- indirect lookup, part of chain (todo: make this a separate table) + return false -- { false, false, chain, false, sequence } -- indirect lookup, part of chain (todo: make this a separate table) end end -function otf.dataset(tfmdata,sequences,font,attr) +-- local contextresolved = { } +-- +-- setmetatableindex(contextresolved, function(t,k) +-- local v = contextsetups[contextnumbers[k]] +-- t[k] = v +-- return v +-- end) - local shared = tfmdata.shared - local properties = tfmdata.properties +function otf.dataset(tfmdata,sequences,font,attr) -- attr only when explicit (as in special parbuilder) local script, language, s_enabled, a_enabled, dynamic if attr and attr ~= 0 then local features = contextsetups[contextnumbers[attr]] -- could be a direct list + -- local features = contextresolved[attr] language = features.language or "dflt" script = features.script or "dflt" a_enabled = features dynamic = contextmerged[attr] or 0 if dynamic == 2 or dynamic == -2 then -- font based - s_enabled = shared.features + s_enabled = tfmdata.shared.features end else + local properties = tfmdata.properties language = properties.language or "dflt" script = properties.script or "dflt" - s_enabled = shared.features -- can be made local to the resolver + s_enabled = tfmdata.shared.features -- can be made local to the resolver dynamic = 0 end @@ -209,7 +224,7 @@ function otf.dataset(tfmdata,sequences,font,attr) rl[attr] = ra setmetatableindex(ra, function(t,k) local v = initialize(sequences[k],script,language,s_enabled,a_enabled,font,attr,dynamic) - t[k] = v + t[k] = v or false return v end) end |