diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-07-15 23:43:51 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-07-15 23:43:51 +0200 |
commit | 3eb2d078f0023266585aec42d98326d72567b9d6 (patch) | |
tree | 115ce667ddeb5c3e4a3c2ba6e14ff1869c63fbd5 /tex/context/base/mkiv/math-noa.lua | |
parent | 1373cbe7fd26acc28c673ebee8eeab3ec120f294 (diff) | |
download | context-3eb2d078f0023266585aec42d98326d72567b9d6.tar.gz |
2016-07-15 23:35:00
Diffstat (limited to 'tex/context/base/mkiv/math-noa.lua')
-rw-r--r-- | tex/context/base/mkiv/math-noa.lua | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/tex/context/base/mkiv/math-noa.lua b/tex/context/base/mkiv/math-noa.lua index 4532bf5cb..a291b3a59 100644 --- a/tex/context/base/mkiv/math-noa.lua +++ b/tex/context/base/mkiv/math-noa.lua @@ -1007,6 +1007,7 @@ end) -- todo: set alternate for specific symbols -- todo: no need to do this when already loaded +-- todo: use a fonts.hashes.mathalternates do @@ -1043,6 +1044,7 @@ do alternates = alternates, registered = registered, presets = { }, +hashes = setmetatableindex("table") } resources.mathalternates = mathalternates end @@ -1103,11 +1105,11 @@ do local a_mathalternate = privateattribute("mathalternate") local alternate = { } -- processors.alternate = alternate + local fontdata = fonts.hashes.identifiers + local fontresources = fonts.hashes.resources local function getalternate(fam,tag) - local id = font_of_family(fam) - local tfmdata = fontdata[id] - local resources = tfmdata.resources -- was tfmdata.shared + local resources = fontresources[font_of_family(fam)] local attribute = unsetvalue if resources then local mathalternates = resources.mathalternates @@ -1145,25 +1147,6 @@ do arguments = { "integer", "string" } } --- local function setalternate(fam,tag) --- local id = font_of_family(fam) --- local tfmdata = fontdata[id] --- local resources = tfmdata.resources -- was tfmdata.shared --- if resources then --- local mathalternates = resources.mathalternates --- if mathalternates then --- local v = mathalternates.alternates[tag] --- if v then --- local a = texgetattribute(a_mathalternate) --- if a and a > 0 then --- v = setbit(a,v) --- end --- texsetattribute(a_mathalternate,v) --- end --- end --- end --- end - local function setalternate(fam,tag) local a = texgetattribute(a_mathalternate) local v = getalternate(fam,tag) @@ -1183,24 +1166,31 @@ do local a = getattr(pointer,a_mathalternate) if a and a > 0 then setattr(pointer,a_mathalternate,0) - local tfmdata = fontdata[getfont(pointer)] - local resources = tfmdata.resources -- was tfmdata.shared + local fontid = getfont(pointer) + local resources = fontresources[fontid] if resources then local mathalternates = resources.mathalternates if mathalternates then local attributes = mathalternates.attributes local registered = mathalternates.registered + local hashes = mathalternates.hashes for i=1,#registered do local r = registered[i] if hasbit(a,r) then - local what = attributes[r] local char = getchar(pointer) - local alt = otf.getalternate(tfmdata,char,what.feature,what.value) - if alt ~= char then - if trace_alternates then + local alt = hashes[i][char] + if alt == nil then + local what = attributes[r] + alt = otf.getalternate(fontdata[fontid],char,what.feature,what.value) or false + if alt == char then + alt = false + elseif trace_alternates then report_alternates("alternate %a, value %a, replacing glyph %U by glyph %U", tostring(what.feature),tostring(what.value),getchar(pointer),alt) end + hashes[i][char] = alt + end + if alt then setchar(pointer,alt) break end |