diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-04-16 16:06:47 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-04-16 16:06:47 +0200 |
commit | a104570ad82618ffffc82ffea3f12c5bb0a35232 (patch) | |
tree | f58dd337722644cc179ed4865aa0c1d6ca8b1b7b /tex/context/base/mkiv/font-map.lua | |
parent | daff89c886893f6bf7d092e45b7f78d5395f6274 (diff) | |
download | context-a104570ad82618ffffc82ffea3f12c5bb0a35232.tar.gz |
2016-04-16 15:32:00
Diffstat (limited to 'tex/context/base/mkiv/font-map.lua')
-rw-r--r-- | tex/context/base/mkiv/font-map.lua | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/tex/context/base/mkiv/font-map.lua b/tex/context/base/mkiv/font-map.lua index a91e5234f..ce84ca692 100644 --- a/tex/context/base/mkiv/font-map.lua +++ b/tex/context/base/mkiv/font-map.lua @@ -438,6 +438,95 @@ function mappings.addtounicode(data,filename,checklookups) checklookups(data,missing,nofmissing) end -- todo: go lowercase + + local unset = { } + for unic, glyph in next, descriptions do + if not glyph.unicode and glyph.class == "ligature" then + unset[unic] = glyph + end + end + if next(unset) then + local sequences = resources.sequences + local collected = { } + for i=1,#sequences do + local sequence = sequences[i] + if sequence.type == "gsub_ligature" then + local steps = sequence.steps + if steps then + local l = { } + local function traverse(p,k,v) + if k == "ligature" then + collected[v] = { unpack(l) } + else + table.insert(l,k) + for k, vv in next, v do + traverse(p,k,vv) + end + table.remove(l) + end + end + for i=1,#steps do + -- we actually had/have this in base mode + local coverage = steps[i].coverage + if coverage then + for k, v in next, coverage do + traverse(k,k,v) + end + end + end + end + end + end + if next(collected) then + while true do + local done = false + for k, v in next, collected do + for i=1,#v do + local vi = v[i] + if vi == k then + collected[k] = nil + unset[k] = nil + else + local c = collected[vi] + if c then + done = true + local t = { } + local n = i - 1 + for j=1,n do + t[j] = t[j] + end + for j=1,#c do + n = n + 1 + t[n] = c[j] + end + for j=i+1,#v do + n = n + 1 + t[n] = t[j] + end + collected[k] = t + break + end + end + end + end + if not done then + break + end + end + local n = 0 + for k, v in next, unset do + u = collected[k] + if u then + v.unicode = u + n = n + 1 + end + end + if trace_mapping and n > 0 then + report_fonts("%n ligature tounicode mappings deduced from gsub ligature feaures",n) + end + end + end + if trace_mapping then for unic, glyph in table.sortedhash(descriptions) do local name = glyph.name |