It is pretty easy to get the font filename and the glyph index. I don't know what you mean by “face index”. Getting the position on the page is much more tricky and is not contained in the example below, because at the point where the mlist_to_hlist
callback is triggered it is not yet know where on the page the glyphs will end up.
\documentclass{article}
\usepackage{amsmath}
\usepackage{unicode-math}
\directlua{
local glyph_id = node.id("glyph")
recurse_sublists = function(head)
for n in node.traverse(head) do
if n.id == glyph_id then
print("Glyph")
print(" Filename: " .. font.fonts[n.font].filename)
print(" Glyph index: " .. n.char)
end
if n.list then
recurse_sublists(n.list)
end
end
end
local print_slots = function(head, display_type, penalties)
local newhead = node.mlist_to_hlist(head, display_type, penalties)
recurse_sublists(newhead)
return newhead
end
luatexbase.add_to_callback("mlist_to_hlist", print_slots, "print_slots")
}
\begin{document}
\[
\frac{1}{2\pi i} \int\limits_\gamma f\Bigl(x^{\mathbf{N}\in\mathbb{C}^{N\times 10}}\Bigr)
= \sum_{k=1}^m n(\gamma;a_k)\operatorname{Res}(f;a_k)\,.
\]
\end{document}
In the log I get
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 984713
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 984714
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 49
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 50
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 120587
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 119894
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 984962
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 120574
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 119891
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 984713
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 119909
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman7-bold.otf
Glyph index: 78
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 8712
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 8450
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 119873
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 215
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 49
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 48
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 984714
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 61
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 119898
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 984973
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 119896
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 61
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 49
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 119899
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 40
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 120574
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 59
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 119886
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 119896
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 41
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf
Glyph index: 82
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf
Glyph index: 101
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf
Glyph index: 115
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 40
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 119891
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 59
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 119886
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 119896
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 41
Glyph
Filename: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf
Glyph index: 46
Even after your comments I am not really sure, which information you actually need. That is why I have implemented some sort of JSON serialization, which simply writes the complete mlist
to a file.
\documentclass{article}
\usepackage{amsmath}
\usepackage{unicode-math}
\directlua{
local glyph_id = node.id("glyph")
f = io.open("\jobname.mlist", "w")
recurse_sublists = function(head, indent)
indent = indent or 0
local s = string.rep(" ", indent)
f:write("{\string\n")
for n in node.traverse(head) do
for _,v in ipairs(node.fields(n.id)) do
f:write(s .. '"' .. v .. '": ')
if type(n[v]) == "number" then
f:write(n[v])
elseif type(n[v]) == "nil" then
f:write('null')
else
f:write('"' .. tostring(n[v]) .. '"')
end
f:write(',\string\n')
end
if n.list then
f:write(s .. '"list": ')
recurse_sublists(n.list, indent + 2)
end
end
f:write(string.rep(" ", indent - 2) .. "},\string\n")
end
local print_slots = function(head, display_type, penalties)
local newhead = node.mlist_to_hlist(head, display_type, penalties)
recurse_sublists(newhead, 2)
return newhead
end
luatexbase.add_to_callback("mlist_to_hlist", print_slots, "print_slots")
}
\AtEndDocument{\directlua{f:close()}}
\begin{document}
\[
\frac{1}{2\pi i} \int\limits_\gamma f\Bigl(x^{\mathbf{N}\in\mathbb{C}^{N\times 10}}\Bigr)
= \sum_{k=1}^m n(\gamma;a_k)\operatorname{Res}(f;a_k)\,.
\]
\end{document}