From 808e70bd7ccff7c25c4e1979bf9eec204ed8cb3c Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Thu, 28 Oct 2010 19:38:16 +0200 Subject: Sync with context 2010.10.22 This is a big sync and things might be seriously broken. --- otfl-font-otd.lua | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) (limited to 'otfl-font-otd.lua') diff --git a/otfl-font-otd.lua b/otfl-font-otd.lua index 46899fd..910725a 100644 --- a/otfl-font-otd.lua +++ b/otfl-font-otd.lua @@ -6,25 +6,28 @@ if not modules then modules = { } end modules ['font-otd'] = { license = "see context related readme files" } -local trace_dynamics = false trackers.register("otf.dynamics", function(v) trace_dynamics = v end) +local trace_dynamics = false trackers.register("otf.dynamics", function(v) trace_dynamics = v end) -fonts = fonts or { } -fonts.otf = fonts.otf or { } +local report_otf = logs.new("load otf") -local otf = fonts.otf -local fontdata = fonts.ids +local fonts = fonts +local otf = fonts.otf +local fontdata = fonts.ids otf.features = otf.features or { } otf.features.default = otf.features.default or { } -local context_setups = fonts.define.specify.context_setups -local context_numbers = fonts.define.specify.context_numbers +local definers = fonts.definers +local contextsetups = definers.specifiers.contextsetups +local contextnumbers = definers.specifiers.contextnumbers -local a_to_script = { } otf.a_to_script = a_to_script -local a_to_language = { } otf.a_to_language = a_to_language +-- todo: dynamics namespace -function otf.set_dynamics(font,dynamics,attribute) - local features = context_setups[context_numbers[attribute]] -- can be moved to caller +local a_to_script = { } +local a_to_language = { } + +function otf.setdynamics(font,dynamics,attribute) + local features = contextsetups[contextnumbers[attribute]] -- can be moved to caller if features then local script = features.script or 'dflt' local language = features.language or 'dflt' @@ -41,7 +44,7 @@ function otf.set_dynamics(font,dynamics,attribute) local dsla = dsl[attribute] if dsla then -- if trace_dynamics then - -- logs.report("otf define","using dynamics %s: attribute %s, script %s, language %s",context_numbers[attribute],attribute,script,language) + -- report_otf("using dynamics %s: attribute %s, script %s, language %s",contextnumbers[attribute],attribute,script,language) -- end return dsla else @@ -56,14 +59,15 @@ function otf.set_dynamics(font,dynamics,attribute) features = tfmdata.shared.features } tfmdata.mode = "node" + tfmdata.dynamics = true -- handy for tracing tfmdata.language = language tfmdata.script = script tfmdata.shared.features = { } -- end of save - local set = fonts.define.check(features,otf.features.default) - dsla = otf.set_features(tfmdata,set) + local set = definers.check(features,otf.features.default) + dsla = otf.setfeatures(tfmdata,set) if trace_dynamics then - logs.report("otf define","setting dynamics %s: attribute %s, script %s, language %s, set: %s",context_numbers[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,table.sequenced(set)) end -- we need to restore some values tfmdata.script = saved.script @@ -77,3 +81,11 @@ function otf.set_dynamics(font,dynamics,attribute) end return nil -- { } end + +function otf.scriptandlanguage(tfmdata,attr) + if attr and attr > 0 then + return a_to_script[attr] or tfmdata.script, a_to_language[attr] or tfmdata.language + else + return tfmdata.script, tfmdata.language + end +end -- cgit v1.2.3