summaryrefslogtreecommitdiff
path: root/tex/context/base/font-oth.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/font-oth.lua')
-rw-r--r--tex/context/base/font-oth.lua56
1 files changed, 31 insertions, 25 deletions
diff --git a/tex/context/base/font-oth.lua b/tex/context/base/font-oth.lua
index d1a68d809..59dca31d9 100644
--- a/tex/context/base/font-oth.lua
+++ b/tex/context/base/font-oth.lua
@@ -6,34 +6,40 @@ if not modules then modules = { } end modules ['font-oth'] = {
license = "see context related readme files"
}
-local lpegmatch = lpeg.match
-local splitter = lpeg.Ct(lpeg.splitat(" "))
+local fonts = fonts
+local otf = fonts.handlers.otf
-local collectlookups = fonts.otf.collectlookups
+-- todo: use nodemode data is available
--- For the moment there is no need to cache this but this might
--- happen when I get the feeling that there is a performance
--- penalty involved.
-
-function fonts.otf.getalternate(tfmdata,k,kind,value)
+function otf.getalternate(tfmdata,k,kind,value) -- just initialize nodemode and use that (larger mem print)
if value then
- local shared = tfmdata.shared
- local otfdata = shared and shared.otfdata
- if otfdata then
- local validlookups, lookuplist = collectlookups(otfdata,kind,tfmdata.script,tfmdata.language)
- if validlookups then
- local lookups = tfmdata.descriptions[k].slookups -- we assume only slookups (we can always extend)
- if lookups then
- local unicodes = tfmdata.unicodes -- names to unicodes
- local choice = tonumber(value)
- for l=1,#lookuplist do
- local lookup = lookuplist[l]
- local p = lookups[lookup]
- if p then
- local pc = p[2] -- p.components
- if pc then
- pc = lpegmatch(splitter,pc)
- return unicodes[pc[choice] or pc[#pc]]
+ local description = tfmdata.descriptions[k]
+ if description then
+ local slookups = description.slookups -- we assume only slookups (we can always extend)
+ if slookups then
+ local shared = tfmdata.shared
+ local rawdata = shared and shared.rawdata
+ if rawdata then
+ local lookuptypes = rawdata.resources.lookuptypes
+ if lookuptypes then
+ local properties = tfmdata.properties
+ -- we could cache these
+ local validlookups, lookuplist = otf.collectlookups(rawdata,kind,properties.script,properties.language)
+ if validlookups then
+ local choice = tonumber(value) or 1 -- no random here (yet)
+ for l=1,#lookuplist do
+ local lookup = lookuplist[l]
+ local found = slookups[lookup]
+ if found then
+ local lookuptype = lookuptypes[lookup]
+ if lookuptype == "substitution" then
+ return found
+ elseif lookuptype == "alternate" then
+ return found[choice] or found[#found]
+ else
+ -- ignore
+ end
+ end
end
end
end