diff options
Diffstat (limited to 'tex/context/modules/mkiv/s-math-characters.lua')
-rw-r--r-- | tex/context/modules/mkiv/s-math-characters.lua | 75 |
1 files changed, 47 insertions, 28 deletions
diff --git a/tex/context/modules/mkiv/s-math-characters.lua b/tex/context/modules/mkiv/s-math-characters.lua index 1888dabb4..61b2c8808 100644 --- a/tex/context/modules/mkiv/s-math-characters.lua +++ b/tex/context/modules/mkiv/s-math-characters.lua @@ -15,6 +15,8 @@ local concat = table.concat local lower = string.lower local utfchar = utf.char local round = math.round +local setmetatableindex = table.setmetatableindex +local sortedhash = table.sortedhash local context = context @@ -110,6 +112,38 @@ function moduledata.math.characters.showlist(specification) end end else + +local function collectalllookups(tfmdata,script,language) + local all = setmetatableindex(function(t,k) local v = setmetatableindex("table") t[k] = v return v end) + local shared = tfmdata.shared + local rawdata = shared and shared.rawdata + if rawdata then + local features = rawdata.resources.features + if features.gsub then + for kind, feature in next, features.gsub do + local validlookups, lookuplist = fonts.handlers.otf.collectlookups(rawdata,kind,script,language) + if validlookups then + for i=1,#lookuplist do + local lookup = lookuplist[i] + local steps = lookup.steps + for i=1,lookup.nofsteps do + local coverage = steps[i].coverage + if coverage then + for k, v in next, coverage do + all[k][lookup.type][kind] = v + end + end + end + end + end + end + end + end + return all +end + +local alllookups = collectalllookups(tfmdata,"math","dflt") + context.showmathcharactersstart() for _, unicode in next, sorted do if not limited or unicode < upperlimit then @@ -125,8 +159,6 @@ function moduledata.math.characters.showlist(specification) local next_sizes = char.next local v_variants = char.vert_variants local h_variants = char.horiz_variants - local slookups = desc and desc.slookups - local mlookups = desc and desc.mlookups local mathclass = info.mathclass local mathspec = info.mathspec local mathsymbol = info.mathsymbol @@ -203,39 +235,26 @@ function moduledata.math.characters.showlist(specification) end context.showmathcharactersstopvvariants() end - if slookups or mlookups then - local variants = { } - if slookups then - for lookupname, lookupdata in next, slookups do - local lookuptype = lookuptypes[lookupname] - if lookuptype == "substitution" then - variants[lookupdata] = "sub" - elseif lookuptype == "alternate" then - for i=1,#lookupdata do - variants[lookupdata[i]] = "alt" - end - end + local lookups = alllookups[unicode] + if lookups then + local variants = { } + local singles = lookups.gsub_single + local alternates = lookups.gsub_alternate + if singles then + for lookupname, code in next, singles do + variants[code] = lookupname end end - if mlookups then - for lookupname, lookuplist in next, mlookups do - local lookuptype = lookuptypes[lookupname] - for i=1,#lookuplist do - local lookupdata = lookuplist[i] - local lookuptype = lookuptypes[lookupname] - if lookuptype == "substitution" then - variants[lookupdata] = "sub" - elseif lookuptype == "alternate" then - for i=1,#lookupdata do - variants[lookupdata[i]] = "alt" - end - end + if singles then + for lookupname, codes in next, alternates do + for i=1,#codes do + variants[codes[i]] = lookupname .. " : " .. i end end end context.showmathcharactersstartlookupvariants() local i = 0 - for variant, lookuptype in table.sortedpairs(variants) do + for variant, lookuptype in sortedhash(variants) do i = i + 1 context.showmathcharacterslookupvariant(i,f_unicode(variant),variant,lookuptype) end |