diff options
Diffstat (limited to 'tex/context/base/mkxl/node-fnt.lmt')
-rw-r--r-- | tex/context/base/mkxl/node-fnt.lmt | 162 |
1 files changed, 66 insertions, 96 deletions
diff --git a/tex/context/base/mkxl/node-fnt.lmt b/tex/context/base/mkxl/node-fnt.lmt index 658ea46bb..c96bdde3d 100644 --- a/tex/context/base/mkxl/node-fnt.lmt +++ b/tex/context/base/mkxl/node-fnt.lmt @@ -60,8 +60,6 @@ local setprev = nuts.setprev local isglyph = nuts.isglyph -- unchecked local ischar = nuts.ischar -- checked ------ traverse_id = nuts.traverse_id ------ traverse_char = nuts.traverse_char local nextboundary = nuts.traversers.boundary local nextdisc = nuts.traversers.disc local nextchar = nuts.traversers.char @@ -88,14 +86,6 @@ local run = 0 local setfontdynamics = { } local fontprocesses = { } --- setmetatableindex(setfontdynamics, function(t,font) --- local tfmdata = fontdata[font] --- local shared = tfmdata.shared --- local v = shared and shared.dynamics and otf.setdynamics or false --- t[font] = v --- return v --- end) - setmetatableindex(setfontdynamics, function(t,font) local tfmdata = fontdata[font] local shared = tfmdata.shared @@ -156,8 +146,8 @@ local function start_trace(head) local char, id = isglyph(n) if char then local font = id - local attr = getglyphdata(n) or 0 - report_fonts("font %03i, dynamic %03i, glyph %C",font,attr,char) + local dynamic = getglyphdata(n) or 0 + report_fonts("font %03i, dynamic %03i, glyph %C",font,dynamic,char) elseif id == disc_code then report_fonts("[disc] %s",nodes.listtoutf(n,true,false,n)) elseif id == boundary_code then @@ -169,10 +159,10 @@ local function start_trace(head) end end -local function stop_trace(u,usedfonts,a,attrfonts,b,basefonts,r,redundant) +local function stop_trace(u,usedfonts,d,dynamicfonts,b,basefonts,r,redundant) report_fonts() report_fonts("statics : %s",u > 0 and concat(keys(usedfonts)," ") or "none") - report_fonts("dynamics: %s",a > 0 and concat(keys(attrfonts)," ") or "none") + report_fonts("dynamics: %s",d > 0 and concat(keys(dynamicfonts)," ") or "none") report_fonts("built-in: %s",b > 0 and b or "none") report_fonts("removed : %s",r > 0 and r or "none") report_fonts() @@ -181,11 +171,11 @@ end do local usedfonts - local attrfonts + local dynamicfonts local basefonts -- could be reused local basefont local prevfont - local prevattr + local prevdynamic local variants local redundant -- could be reused local firstnone @@ -193,7 +183,7 @@ do local lastproc local lastnone - local a, u, b, r + local d, u, b, r local function protectnone() protect_glyphs(firstnone,lastnone) @@ -228,7 +218,7 @@ do end end - local function setnode(n,font,attr) -- we could use prevfont and prevattr when we set then first + local function setnode(n,font,dynamic) -- we could use prevfont and prevdynamic when we set then first if firstnone then protectnone() end @@ -236,17 +226,17 @@ do basefont[2] = getprev(n) basefont = false end - if attr > 0 then - local used = attrfonts[font] + if dynamic > 0 then + local used = dynamicfonts[font] if not used then used = { } - attrfonts[font] = used + dynamicfonts[font] = used end - if not used[attr] then + if not used[dynamic] then local fd = setfontdynamics[font] if fd then - used[attr] = fd[attr] - a = a + 1 + used[dynamic] = fd[dynamic] + d = d + 1 end end else @@ -266,22 +256,22 @@ do -- either next or not, but definitely no already processed list starttiming(nodes) - usedfonts = { } - attrfonts = { } - basefonts = { } - basefont = nil - prevfont = nil - prevattr = 0 - variants = nil - redundant = nil - firstnone = nil - lastfont = nil - lastproc = nil - lastnone = nil + usedfonts = { } + dynamicfonts = { } + basefonts = { } + basefont = nil + prevfont = nil + prevdynamic = 0 + variants = nil + redundant = nil + firstnone = nil + lastfont = nil + lastproc = nil + lastnone = nil -local fontmode = nil + local fontmode = nil -- base none or other - a, u, b, r = 0, 0, 0, 0 + d, u, b, r = 0, 0, 0, 0 if trace_fontrun then start_trace(head) @@ -290,48 +280,31 @@ local fontmode = nil -- There is no gain in checking for a single glyph and then having a fast path. On the -- metafun manual (with some 2500 single char lists) the difference is just noise. - for n, char, font in nextchar, head do - --- local attr = getglyphdata(n) or 0 -- zero attribute is reserved for fonts in context --- if font ~= prevfont or attr ~= prevattr then --- prevfont = font --- prevattr = attr --- variants = fontvariants[font] --- local fontmode = fontmodes[font] --- if fontmode == "none" then --- setnone(n) --- elseif fontmode == "base" then --- setbase(n) --- else --- setnode(n,font,attr) --- end --- elseif firstnone then --- lastnone = n --- end + for n, char, font, dynamic in nextchar, head do if font ~= prevfont then prevfont = font fontmode = fontmodes[font] if fontmode == "none" then - prevattr = 0 - variants = false + prevdynamic = 0 + variants = false setnone(n) elseif fontmode == "base" then - prevattr = 0 - variants = false + prevdynamic = 0 + variants = false setbase(n) else - local attr = getglyphdata(n) or 0 -- zero attribute is reserved for fonts in context - prevattr = attr - variants = fontvariants[font] - setnode(n,font,attr) + -- local dynamic = getglyphdata(n) or 0 -- zero dynamic is reserved for fonts in context + prevdynamic = dynamic + variants = fontvariants[font] + setnode(n,font,dynamic) end elseif fontmode == "node" then - local attr = getglyphdata(n) or 0 -- zero attribute is reserved for fonts in context - if attr ~= prevattr then - prevattr = attr - variants = fontvariants[font] - setnode(n,font,attr) + local dynamic = getglyphdata(n) or 0 -- zero dynamic is reserved for fonts in context + if dynamic ~= prevdynamic then + prevdynamic = dynamic + variants = fontvariants[font] + setnode(n,font,dynamic) end elseif firstnone then lastnone = n @@ -434,21 +407,21 @@ local fontmode = nil -- basefont is not supported in disc only runs ... it would mean a lot of -- ranges .. we could try to run basemode as a separate processor run but not -- for now (we can consider it when the new node code is tested - for d in nextdisc, head do + for disc in nextdisc, head do -- doing only replace is good enough because pre and post are normally used -- for hyphens and these come from fonts that part of the hyphenated word - local r = getreplace(d) + local r = getreplace(disc) if r then - local prevfont = nil - local prevattr = nil - local none = false - firstnone = nil - basefont = nil - for n, char, font in nextchar, r do - local attr = getglyphdata(n) or 0 -- zero attribute is reserved for fonts in context - if font ~= prevfont or attr ~= prevattr then - prevfont = font - prevattr = attr + local prevfont = nil + local prevdynamic = nil + local none = false + firstnone = nil + basefont = nil + for n, char, font, dynamic in nextchar, r do + -- local dynamic = getglyphdata(n) or 0 -- zero dynamic is reserved for fonts in context + if font ~= prevfont or dynamic ~= prevdynamic then + prevfont = font + prevdynamic = dynamic local fontmode = fontmodes[font] if fontmode == "none" then setnone(n) @@ -456,7 +429,7 @@ local fontmode = nil -- so the replace gets an extra treatment ... so be it setbase(n) else - setnode(n,font,attr) + setnode(n,font,dynamic) end elseif firstnone then -- lastnone = n @@ -475,40 +448,37 @@ local fontmode = nil end if trace_fontrun then - stop_trace(u,usedfonts,a,attrfonts,b,basefonts,r,redundant) + stop_trace(u,usedfonts,d,dynamicfonts,b,basefonts,r,redundant) end -- in context we always have at least 2 processors if u == 0 then -- skip elseif u == 1 then - local attr = a > 0 and 0 or false -- 0 is the savest way for i=1,#lastproc do - head = lastproc[i](head,lastfont,attr,direction) + head = lastproc[i](head,lastfont,0,direction) end else - -- local attr = a == 0 and false or 0 -- 0 is the savest way - local attr = a > 0 and 0 or false -- 0 is the savest way for font, processors in next, usedfonts do -- unordered for i=1,#processors do - head = processors[i](head,font,attr,direction,u) + head = processors[i](head,font,0,direction,u) -- u triggers disc optimizer end end end - if a == 0 then + if d == 0 then -- skip - elseif a == 1 then - local font, dynamics = next(attrfonts) - for attribute, processors in next, dynamics do -- unordered, attr can switch in between + elseif d == 1 then + local font, dynamics = next(dynamicfonts) + for dynamic, processors in next, dynamics do -- unordered, dynamic can switch in between for i=1,#processors do - head = processors[i](head,font,attribute,direction) + head = processors[i](head,font,dynamic,direction) end end else - for font, dynamics in next, attrfonts do - for attribute, processors in next, dynamics do -- unordered, attr can switch in between + for font, dynamics in next, dynamicfonts do + for dynamic, processors in next, dynamics do -- unordered, dynamic can switch in between for i=1,#processors do - head = processors[i](head,font,attribute,direction,a) + head = processors[i](head,font,dynamic,direction,d) -- d triggers disc optimizer end end end |