summaryrefslogtreecommitdiff
path: root/tex/context/base/font-ctx.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2013-03-14 16:12:00 +0100
committerHans Hagen <pragma@wxs.nl>2013-03-14 16:12:00 +0100
commita30800148afa03c7401d0d5ec961497bb1820632 (patch)
tree4a75b5980575cf7b697b98cb539b6f1dd41e94e7 /tex/context/base/font-ctx.lua
parenta62645f4006489c3537cb67d1d29304515593060 (diff)
downloadcontext-a30800148afa03c7401d0d5ec961497bb1820632.tar.gz
beta 2013.03.14 16:12
Diffstat (limited to 'tex/context/base/font-ctx.lua')
-rw-r--r--tex/context/base/font-ctx.lua37
1 files changed, 30 insertions, 7 deletions
diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua
index a9fba145f..39fee86f1 100644
--- a/tex/context/base/font-ctx.lua
+++ b/tex/context/base/font-ctx.lua
@@ -492,7 +492,7 @@ local function presetcontext(name,parent,features) -- will go to con and shared
features = parent
parent = ""
end
- if features == "" then
+ if not features or features == "" then
features = { }
elseif type(features) == "string" then
features = normalize_features(settings_to_hash(features))
@@ -608,6 +608,7 @@ local function mergecontext(currentnumber,extraname,option)
numbers[number] = mergedname
merged[number] = option
setups[mergedname] = mergedfeatures
+-- inspect(mergedfeatures)
return number -- contextnumber(mergedname)
else
return currentnumber
@@ -663,15 +664,15 @@ end
-- end of redefine
-local cache = { } -- concat might be less efficient than nested tables
+local withcache = { } -- concat might be less efficient than nested tables
local function withset(name,what)
local zero = texattribute[0]
local hash = zero .. "+" .. name .. "*" .. what
- local done = cache[hash]
+ local done = withcache[hash]
if not done then
done = mergecontext(zero,name,what)
- cache[hash] = done
+ withcache[hash] = done
end
texattribute[0] = done
end
@@ -679,10 +680,10 @@ end
local function withfnt(name,what,font)
local font = font or currentfont()
local hash = font .. "*" .. name .. "*" .. what
- local done = cache[hash]
+ local done = withcache[hash]
if not done then
done = registercontext(font,name,what)
- cache[hash] = done
+ withcache[hash] = done
end
texattribute[0] = done
end
@@ -1606,7 +1607,29 @@ end
-- more interfacing:
-commands.definefontfeature = fonts.specifiers.presetcontext
+commands.definefontfeature = presetcontext
+
+local namecache = { }
+
+function commands.feature(name,parent,font)
+ local font = font or currentfont()
+ local hash = font .. "*" .. name .. "*" .. 2 -- what
+ local done = withcache[hash]
+ if not done then
+ if namecache[name] then
+ else
+ presetcontext(name,parent)
+ namecache[name] = true
+ end
+ if trace_features then
+ report_features("cummulative %a, font %a, number %a, set % a",name,font,n,f)
+ end
+ done = registercontext(font,name,2) -- what
+ withcache[hash] = done
+ end
+-- context(done)
+ texattribute[0] = done
+end
function commands.featurelist(...)
context(fonts.specifiers.contexttostring(...))