diff options
author | Karl Berry <karl@freefriends.org> | 2017-05-02 22:24:44 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-05-02 22:24:44 +0000 |
commit | ced65a4c1daa9985de131a295943b6568df35e43 (patch) | |
tree | 01115172f4197c33173dd19ab08eea84d56a415b /Master/texmf-dist/tex/context/base/mkiv/math-act.lua | |
parent | e836e85e085cd03de13f7f95250d8178b2b8ae18 (diff) |
context/beta/cont-tmf.zip Apr 27 01:08
git-svn-id: svn://tug.org/texlive/trunk@44160 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/math-act.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/math-act.lua | 176 |
1 files changed, 154 insertions, 22 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/math-act.lua b/Master/texmf-dist/tex/context/base/mkiv/math-act.lua index 602c3dc891c..ee78b64f0ce 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/math-act.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/math-act.lua @@ -590,7 +590,134 @@ blocks["uppercasedoublestruck"].gaps = { -- todo: tounicode +-- function mathematics.injectfallbacks(target,original) +-- local properties = original.properties +-- if properties and properties.hasmath then +-- local specification = target.specification +-- if specification then +-- local fallbacks = specification.fallbacks +-- if fallbacks then +-- local definitions = fonts.collections.definitions[fallbacks] +-- if definitions then +-- if trace_collecting then +-- report_math("adding fallback characters to font %a",specification.hash) +-- end +-- local definedfont = fonts.definers.internal +-- local copiedglyph = fonts.handlers.vf.math.copy_glyph +-- local fonts = target.fonts +-- local size = specification.size -- target.size +-- local characters = target.characters +-- if not fonts then +-- fonts = { } +-- target.fonts = fonts +-- target.type = "virtual" +-- target.properties.virtualized = true +-- end +-- if #fonts == 0 then +-- fonts[1] = { id = 0, size = size } -- sel, will be resolved later +-- end +-- local done = { } +-- for i=1,#definitions do +-- local definition = definitions[i] +-- local name = definition.font +-- local start = definition.start +-- local stop = definition.stop +-- local gaps = definition.gaps +-- local check = definition.check +-- local force = definition.force +-- local rscale = definition.rscale or 1 +-- local offset = definition.offset or start +-- local id = definedfont { name = name, size = size * rscale } +-- local index = #fonts + 1 +-- fonts[index] = { id = id, size = size } +-- local chars = fontchars[id] +-- local function remap(unic,unicode,gap) +-- local unic = unicode + offset - start +-- if check and not chars[unicode] then +-- -- not in font +-- elseif force or (not done[unic] and not characters[unic]) then +-- if trace_collecting then +-- report_math("remapping math character, vector %a, font %a, character %C%s%s", +-- fallbacks,name,unic,check and ", checked",gap and ", gap plugged") +-- end +-- characters[unic] = copiedglyph(target,characters,chars,unicode,index) +-- done[unic] = true +-- end +-- end +-- for unicode = start, stop do +-- local unic = unicode + offset - start +-- remap(unic,unicode,false) +-- end +-- if gaps then +-- for unic, unicode in next, gaps do +-- remap(unic,unicode,true) +-- end +-- end +-- end +-- end +-- end +-- end +-- end +-- end + +local stack = { } + +function mathematics.registerfallbackid(n,id) + local top = stack[#stack] + if top then + top.list[n] = id + else + report_math("stack underrun in math fallbacks") + end +end + function mathematics.injectfallbacks(target,original) + if #stack > 0 then + -- for now + return + end + local properties = original.properties + if properties and properties.hasmath then + local specification = target.specification + if specification then + local fallbacks = specification.fallbacks + if fallbacks then + local definitions = fonts.collections.definitions[fallbacks] + if definitions then + table.insert(stack, { + target = target, + original = original, + list = { }, + }) + if trace_collecting then + report_math("adding fallback characters to font %a",specification.hash) + end + local size = specification.size -- target.size + context.pushcatcodes("prt") -- context.unprotect() + for i=1,#definitions do + local definition = definitions[i] + local name = definition.font + local features = definition.features or "" + local size = size * (definition.rscale or 1) + context.font_fallbacks_register_math(i,name,features,size) + end + context.font_fallbacks_finish_math() + context.popcatcodes() + end + end + end + end +end + +function mathematics.finishfallbacks() + local top = table.remove(stack) + if not top then + report_math("finish error in math fallbacks") + return + end + local target = top.target + local original = top.original + local list = top.list local properties = original.properties if properties and properties.hasmath then local specification = target.specification @@ -627,33 +754,38 @@ function mathematics.injectfallbacks(target,original) local force = definition.force local rscale = definition.rscale or 1 local offset = definition.offset or start - local id = definedfont { name = name, size = size * rscale } - local index = #fonts + 1 - fonts[index] = { id = id, size = size } - local chars = fontchars[id] - local function remap(unic,unicode,gap) - local unic = unicode + offset - start - if check and not chars[unicode] then - -- not in font - elseif force or (not done[unic] and not characters[unic]) then - if trace_collecting then - report_math("remapping math character, vector %a, font %a, character %C%s%s", - fallbacks,name,unic,check and ", checked",gap and ", gap plugged") + local id = list[i] + if id then + local index = #fonts + 1 + fonts[index] = { id = id, size = size } + local chars = fontchars[id] + local function remap(unic,unicode,gap) + local unic = unicode + offset - start + if check and not chars[unicode] then + -- not in font + elseif force or (not done[unic] and not characters[unic]) then + if trace_collecting then + report_math("remapping math character, vector %a, font %a, character %C%s%s", + fallbacks,name,unic,check and ", checked",gap and ", gap plugged") + end + characters[unic] = copiedglyph(target,characters,chars,unicode,index) + done[unic] = true end - characters[unic] = copiedglyph(target,characters,chars,unicode,index) - done[unic] = true end - end - for unicode = start, stop do - local unic = unicode + offset - start - remap(unic,unicode,false) - end - if gaps then - for unic, unicode in next, gaps do - remap(unic,unicode,true) + for unicode = start, stop do + local unic = unicode + offset - start + remap(unic,unicode,false) + end + if gaps then + for unic, unicode in next, gaps do + remap(unic,unicode,true) + end end end end + xlist = nil + xtarget = nil + xoriginal = nil end end end |