summaryrefslogtreecommitdiff
path: root/tex/context/base/node-fnt.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/node-fnt.lua')
-rw-r--r--tex/context/base/node-fnt.lua170
1 files changed, 5 insertions, 165 deletions
diff --git a/tex/context/base/node-fnt.lua b/tex/context/base/node-fnt.lua
index a97c98d83..530659eaa 100644
--- a/tex/context/base/node-fnt.lua
+++ b/tex/context/base/node-fnt.lua
@@ -24,7 +24,6 @@ local fontdata = fonthashes.identifiers
local otf = fonts.handlers.otf
local traverse_id = node.traverse_id
-local has_attribute = node.has_attribute
local starttiming = statistics.starttiming
local stoptiming = statistics.stoptiming
local nodecodes = nodes.nodecodes
@@ -85,9 +84,10 @@ function handlers.characters(head)
report_fonts()
local n = head
while n do
- if n.id == glyph_code then
+ local id = n.id
+ if id == glyph_code then
local font = n.font
- local attr = has_attribute(n,0) or 0
+ local attr = n[0] or 0
report_fonts("font %03i, dynamic %03i, glyph %s",font,attr,utf.char(n.char))
else
report_fonts("[%s]",nodecodes[n.id])
@@ -95,10 +95,11 @@ function handlers.characters(head)
n = n.next
end
end
+ -- todo: time a while and skip over or make a special traverse_id that skips over math
for n in traverse_id(glyph_code,head) do
-- if n.subtype<256 then -- all are 1
local font = n.font
- local attr = has_attribute(n,0) or 0 -- zero attribute is reserved for fonts in context
+ local attr = n[0] or 0 -- zero attribute is reserved for fonts in context
if font ~= prevfont or attr ~= prevattr then
if attr > 0 then
local used = attrfonts[font]
@@ -219,166 +220,5 @@ function handlers.characters(head)
return head, true
end
--- function handlers.characters(head)
--- -- either next or not, but definitely no already processed list
--- starttiming(nodes)
--- local usedfonts, attrfonts, done = { }, { }, false
--- local a, u, prevfont, prevattr = 0, 0, nil, nil
--- local ap = 0
--- if trace_fontrun then
--- run = run + 1
--- report_fonts()
--- report_fonts("checking node list, run %s",run)
--- report_fonts()
--- local n = head
--- while n do
--- if n.id == glyph_code then
--- local font = n.font
--- local attr = has_attribute(n,0) or 0
--- report_fonts("font %03i, dynamic %03i, glyph %s",font,attr,utf.char(n.char))
--- else
--- report_fonts("[%s]",nodecodes[n.id])
--- end
--- n = n.next
--- end
--- end
--- for n in traverse_id(glyph_code,head) do
--- -- if n.subtype<256 then
--- local font = n.font
--- local attr = n.attr
--- if attr ~= prevattr then
--- local an = has_attribute(n,0) or 0
--- if ap ~= an and an > 0 then
--- local used = attrfonts[font]
--- if not used then
--- used = { }
--- attrfonts[font] = used
--- end
--- if not used[an] then
--- local sd = setfontdynamics[font]
--- if sd then -- always true ?
--- local d = sd(font,an) -- can we cache this one?
--- if d then
--- used[an] = d
--- a = a + 1
--- else
--- -- can't happen ... otherwise best use nil/false distinction
--- end
--- end
--- end
--- elseif font ~= prevfont then
--- local used = usedfonts[font]
--- if not used then
--- local fp = fontprocesses[font]
--- if fp then
--- usedfonts[font] = fp
--- u = u + 1
--- else
--- -- can't happen ... otherwise best use nil/false distinction
--- end
--- end
--- end
--- prevfont = font
--- prevattr = attr
--- ap = an
--- elseif font ~= prevfont then
--- local used = usedfonts[font]
--- if not used then
--- local fp = fontprocesses[font]
--- if fp then
--- usedfonts[font] = fp
--- u = u + 1
--- else
--- -- can't happen ... otherwise best use nil/false distinction
--- end
--- end
--- prevfont = font
--- end
--- -- end
--- end
--- if trace_fontrun then
--- 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()
--- end
--- -- we could combine these and just make the attribute nil
--- if u == 1 then
--- local font, processors = next(usedfonts)
--- local n = #processors
--- if n > 0 then
--- local h, d = processors[1](head,font,0)
--- head = h or head
--- done = done or d
--- if n > 1 then
--- for i=2,n do
--- local h, d = processors[i](head,font,0)
--- head = h or head
--- done = done or d
--- end
--- end
--- end
--- elseif u > 0 then
--- for font, processors in next, usedfonts do
--- local n = #processors
--- local h, d = processors[1](head,font,0)
--- head = h or head
--- done = done or d
--- if n > 1 then
--- for i=2,n do
--- local h, d = processors[i](head,font,0)
--- head = h or head
--- done = done or d
--- end
--- end
--- end
--- end
--- if a == 1 then
--- local font, dynamics = next(attrfonts)
--- for attribute, processors in next, dynamics do -- attr can switch in between
--- local n = #processors
--- if n == 0 then
--- report_fonts("no processors associated with dynamic %s",attribute)
--- else
--- local h, d = processors[1](head,font,attribute)
--- head = h or head
--- done = done or d
--- if n > 1 then
--- for i=2,n do
--- local h, d = processors[i](head,font,attribute)
--- head = h or head
--- done = done or d
--- end
--- end
--- end
--- end
--- elseif a > 0 then
--- for font, dynamics in next, attrfonts do
--- for attribute, processors in next, dynamics do -- attr can switch in between
--- local n = #processors
--- if n == 0 then
--- report_fonts("no processors associated with dynamic %s",attribute)
--- else
--- local h, d = processors[1](head,font,attribute)
--- head = h or head
--- done = done or d
--- if n > 1 then
--- for i=2,n do
--- local h, d = processors[i](head,font,attribute)
--- head = h or head
--- done = done or d
--- end
--- end
--- end
--- end
--- end
--- end
--- stoptiming(nodes)
--- if trace_characters then
--- nodes.report(head,done)
--- end
--- return head, true
--- end
-
handlers.protectglyphs = node.protect_glyphs
handlers.unprotectglyphs = node.unprotect_glyphs