diff options
author | Marius <mariausol@gmail.com> | 2010-08-14 15:54:19 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2010-08-14 15:54:19 +0300 |
commit | 39e30629c15ae4a899532d84c4abea127f2847a6 (patch) | |
tree | ce9007341b23338cc6d73dad028f307c78dcb0ed /tex/context/base/font-oth.lua | |
parent | 83a331fff83ac18314885a39e959ca0c10f316f7 (diff) | |
download | context-39e30629c15ae4a899532d84c4abea127f2847a6.tar.gz |
stable 2010.07.30 11:35
Diffstat (limited to 'tex/context/base/font-oth.lua')
-rw-r--r-- | tex/context/base/font-oth.lua | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tex/context/base/font-oth.lua b/tex/context/base/font-oth.lua new file mode 100644 index 000000000..62ff41c40 --- /dev/null +++ b/tex/context/base/font-oth.lua @@ -0,0 +1,45 @@ +if not modules then modules = { } end modules ['font-oth'] = { + version = 1.001, + comment = "companion to font-oth.lua (helpers)", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local lpegmatch = lpeg.match +local splitter = lpeg.Ct(lpeg.splitat(" ")) + +local collect_lookups = fonts.otf.collect_lookups + +-- 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.get_alternate(tfmdata,k,kind,value) + if value then + local shared = tfmdata.shared + local otfdata = shared and shared.otfdata + if otfdata then + local validlookups, lookuplist = collect_lookups(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]] + end + end + end + end + end + end + end + return k +end |